Skip to content

Instantly share code, notes, and snippets.

@eloyesp
Created September 12, 2024 14:52
Show Gist options
  • Save eloyesp/72fc8f725a5708ee94ed5a8f4a3aa6bd to your computer and use it in GitHub Desktop.
Save eloyesp/72fc8f725a5708ee94ed5a8f4a3aa6bd to your computer and use it in GitHub Desktop.
Compare BTC to USDT swap price (FixedFloat, ThorChain, Maya)
#!/bin/bash
# Get quotes for FixedFloat, Thorchain and Mayachain
#
# Usage compare [amount]
# amount expressed in BTC (defaults to 0.01 BTC)
#
# Requirements: jq httpie bc
# set -x
set -e
export LC_ALL=C
amount=${1:-"0.01"}
amount_sats=$(echo "scale=0; $amount * 100000000 / 1" | bc)
echo "Getting exchange rate for:"
printf "%9.8f btc\n" "$amount"
printf "%10d sat\n" "$amount_sats"
parse_output() {
jq ".expected_amount_out | tonumber | . / 100000000"
}
echo Making queries
fixed=$(https -f ff.io/ajax/exchPrice accept-language:en type=float fromCcy=BTC toCcy=USDTARBITRUM fromAmount=$amount | jq '.data.to.amount')
maya=$(https mayanode.mayachain.info/mayachain/quote/swap from_asset==btc.btc to_asset==ARB.usdt amount==$amount_sats streaming_interval==3 | parse_output)
thor=$(https thornode.ninerealms.com/thorchain/quote/swap from_asset==btc.btc to_asset==AVAX.USDT amount==$amount_sats streaming_interval==3 | parse_output)
printf "FixedFloat ARB.USDT: %6.3f\n" "$fixed"
printf "Thor AVAX.USDT: %6.3f\n" "$thor"
printf "Maya ARB.USDT: %6.3f\n" "$maya"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment