API Documentation Juno

The TFM DEX aggregator API can be found under the following URL:
The API consists of the following endpoints:

/route

Parameter name
Type
Description
token0
string
Contract address of the token to sell, e.g. USDC
token1
string
Contract address of the token to buy, e.g. ujuno
amount
integer
Amount of the token to sell, set in minimal divisible units, e.g. 13.45 JUNO set as 13450000
exchange
string
Optional parameter to limit the search of the best route within a given exchange. For example, input of "junoswap" will only search on Junoswap, while "junoswap, loop" will search on both Junoswap and Loop. The default setting is to search on all the DEX's if no value is passed.
use_split
bool
indicates if volume splitting should be applied

List of available exchanges:

junoswap
loop

Example:

https://junoagg-api.tfm.dev/route?use_split=true&exchange_specific_results=true&token0=juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g&token1=juno1dd0k0um5rqncfueza62w9sentdfh3ec4nw4aq4lk5hkjl63vljqscth9gv&amount=11000000
Return structure:
{
"alternatives": {
"junoswap": {
"input_amount": 11.0,
"return_amount": 0.066741,
"routes": [
{
"input_amount": 11.0,
"operations": [
{
"ask_token": "juno1dd0k0um5rqncfueza62w9sentdfh3ec4nw4aq4lk5hkjl63vljqscth9gv",
"contract_addr": "juno1ytntasjjyzpdfhsw60yp7rt3ww57nqth45lfaek9ae65ylm0xpkqsp47fz",
"exchange": "junoswap",
"offer_token": "juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g"
}
],
"return_amount": 0.066741
}
]
}
},
"input_amount": 11.0,
"price_impact": 0.013403091854050642,
"return_amount": 0.066741,
"routes": [
{
"input_amount": 11.0,
"operations": [
{
"ask_token": "juno1dd0k0um5rqncfueza62w9sentdfh3ec4nw4aq4lk5hkjl63vljqscth9gv",
"contract_addr": "juno1ytntasjjyzpdfhsw60yp7rt3ww57nqth45lfaek9ae65ylm0xpkqsp47fz",
"exchange": "junoswap",
"offer_token": "juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g"
}
],
"price_impact": 0.013403091854050642,
"return_amount": 0.066741
}
]
}
The response structure is defined by the following components:
  1. 1.
    input_amount: the amount to swap
  2. 2.
    return_amount: the amount returned by the swap simulation
  3. 3.
    routes/operations: array that indicates the swap operations to be taken
  4. 4.
    ask_token: the output token
  5. 5.
    offer_token: the input token
  6. 6.
    exchange: the exchange where the swap is being performed
  7. 7.
    price_impact: the price impact on the swap operation

/swap

Parameter name
Type
Description
token0
string
Contract address of the token to sell, e.g. USDC
token1
string
Contract address of the token to buy, e.g. ujuno
amount
integer
Amount of the token to sell, set in minimal divisible units, e.g. 13.45 JUNO set as 13450000
exchange
string
Optional parameter to limit the search of the best route within a given exchange. For example, input of "junoswap" will only search on Junoswap, while "junoswap, loop" will search on both Junoswap and Loop. The default setting is to search on all the DEX's if no value is passed.
slippage
decimal
The slippage for the trade. Value between 0 and 1. For example, for a 15% slippage, we can enter 0.15
use_split
bool
Indicates if volume splitting should be applied

Example:

https://juno.api.tfm.dev/swap?use_split=true&exchange_specific_results=true&token0=juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g&token1=juno1dd0k0um5rqncfueza62w9sentdfh3ec4nw4aq4lk5hkjl63vljqscth9gv&amount=11000000&slipage=0.1
Return structure:
{
"type": "wasm/MsgExecuteContract",
"value": {
"coins": [
{
"amount": "11000000",
"denom": "juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g"
}
],
"contract": "REPLACE_ROUTER",
"execute_msg": {
"execute_swap_operations": {
"max_spread": "0.50",
"minimum_receive": "60258",
"offer_amount": "11000000",
"routes": [
{
"offer_amount": "11000000",
"operations": [
{
"t_f_m_swap": {
"ask_asset_info": {
"native_token": {
"denom": "juno1dd0k0um5rqncfueza62w9sentdfh3ec4nw4aq4lk5hkjl63vljqscth9gv"
}
},
"factory_name": "junoswap",
"offer_asset_info": {
"native_token": {
"denom": "juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g"
}
},
"pair_contract": "juno1ytntasjjyzpdfhsw60yp7rt3ww57nqth45lfaek9ae65ylm0xpkqsp47fz"
}
}
]
}
]
}
},
"sender": "REPLACE_SENDER"
}
}
Returns the WASM message to be executed.
The "REPLACE_SENDER" has to be replaced with the address of the sender.
The "REPLACE_ROUTER" has to be replaced with juno14237hj4uvjruu4ucfzz0kpc8lxauwjhuzr3y8wqxlwcw9vhwkw9s9hxtw8

/tokens

Returns the list of all supported tokens on the aggregator
Return structure:
[{"contract_addr":"ujuno","decimals":6,"id":1,"name":"Juno","symbol":"JUNO"},{"contract_addr":"juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g","decimals":6,"id":2,"name":"Raw","symbol":"RAW"},
...