[add] Quote API for Swap/Deposit/Withdraw #unsafe
NOTE: The only #unsafe changes are to function signatures to export the tx height calculation, there should be no logic changes in historical handlers.
The intention of this change is to provide UIs with a simple API to preflight a transaction for a breakdown of the expected fees, inbound confirmation counting delays, the outbound delay, the appropriate inbound address, and the generated transaction memo if appropriate. This was started from #1425 (closed) and extended to include quote endpoints for saver deposit and withdraw. We add the following endpoints:
/quote/swap
/quote/saver/deposit
/quote/saver/withdraw
This is running on a synced mainnet node for testing convenience: http://34.28.221.190:1317/thorchain/doc.
Examples
Swap
$ http -pb http://34.28.221.190:1317/quote/swap \
from_asset==BTC.BTC \
to_asset==ETH.ETH \
amount==1000000000 \
affiliate_bps==10 \
affiliate==t \
destination==0x4C9264521dB4DfB0a2125B26E855A8761C00A5e7
{
"fees": {
"affiliate": "12236943",
"outbound": "240000",
"slippage": "426560477"
},
"inbound_address": "bc1qjk3xzu5slu7mtmc8jc9yed3zqvkhkttm700g9a",
"inbound_confirmation_blocks": 2,
"memo": "=:ETH.ETH:0x4C9264521dB4DfB0a2125B26E855A8761C00A5e7::t:10",
"min_amount": "12224466737",
"outbound_delay_blocks": 720
}
Deposit
$ http -pb http://34.28.221.190:1317/quote/saver/deposit \
asset==ETH.ETH \
amount==10000000 \
affiliate_bps==100 \
affiliate==tt
{
"fees": {
"affiliate": "99996",
"outbound": "2078",
"slippage": "320035"
},
"inbound_address": "0xd42af2a7274743cd424a15f2fdeba51e1eb71842",
"memo": "+:ETH/ETH::tt:100",
"min_amount": "9897589"
}
Withdraw
$ http -pb http://34.28.221.190:1317/quote/saver/withdraw \
asset==BTC.BTC \
address==bc1qcxssye4j6730h7ehgega3gyykkuwgdgmmpu62n \
bps==10000
{
"dust_amount": "20000",
"fees": {
"affiliate": "0",
"outbound": "54000",
"slippage": "0"
},
"inbound_address": "bc1qkuqleavh7gdhnmdslcjsv8kvtjdtnxke06nmtx",
"memo": "-:BTC/BTC:10000",
"min_amount": "45998",
"outbound_delay_blocks": 0
}