Skip to main content

query_fees

/query_fees

query the token path, how much do sell_token need for buy_amount of buy_token, estimate gas will use, and how much native token this transaction will need.

for sell_token, gateway can accept any token that have liquidity on DEX, for buy_token, plz refer to this token list

https://api.anyway.network/query_fees

Param

typenamedetail
str (address regex limiting)token_fromthe token address user going to pay
str (address regex limiting)token_tothe token address recipient want to receive
Networksnetwork_fromthe source network of the transaction
Networksnetwork_tothe destination network of the transaction
intbuy_amounthow many token_to going to buy

Request

curl -X 'POST' \
'http://api.anyway.network/query_fees' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"token_from": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"token_to": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
"network_from": "Ethereum",
"network_to": "Polygon",
"buy_amount": 100000
}'

Response

{
"path": {
"Ethereum": [
{
"name": "usdt",
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7"
}
],
"Polygon": [
{
"name": "usdc",
"address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
},
{
"name": "dai",
"address": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"
}
]
},
"sell_amount": 100000,
"gas": 150000,
"value": 585568979078716,
"price": 1,
"chainId": 1,
"to": "0xAcd696A237025f6113640F6bBD029b95e9bde5Ff"
}