The Router contract contains logic to facilitate multi-hop swaps for Terra native & Astroport tokens.
For every swap, the contract checks if the resulting token is the one that was asked for and whether the receiving amount exceeds the minimum to receive.
Initializes the contract with the Astroport factory contract address.
{
"astroport_factory": "terra..."
}
CW20 receive msg.
{
"receive": {
"sender": "terra...",
"amount": "123",
"msg": "<base64_encoded_json_string>"
}
}
Swaps one token to another. This message is for internal use.
Swap UST => mABNB
{
"execute_swap_operation": {
"operation": {
"astro_swap": {
"offer_asset_info": {
"native_token": {
"denom": "uusd"
}
},
"ask_asset_info": {
"token": {
"contract_addr": "terra..."
}
}
}
},
"to": "terra...",
"max_spread": "0.05"
}
}
Performs multi-hop swap operations for native & Astroport tokens. Swaps execute one-by-one and the last swap will return the ask token. This function is public (can be called by anyone).
Swap KRT => UST => mABNB
{
"execute_swap_operations": {
"operations": [
{
"native_swap":{
"offer_denom":"ukrw",
"ask_denom":"uusd"
}
},
{
"astro_swap": {
"offer_asset_info": {
"native_token": {
"denom": "uusd"
}
},
"ask_asset_info": {
"token": {
"contract_addr": "terra..."
}
}
}
}
],
"minimum_receive": "123",
"to": "terra...",
"max_spread": "0.05"
}
}
Checks that an amount of ask tokens exceeds minimum_receive
. This message is for internal use.
{
"assert_minimum_receive": {
"asset_info": {
"token": {
"contract_addr": "terra..."
}
},
"prev_balance": "123",
"minimum_receive": "123",
"receiver": "terra..."
}
}
All query messages are described below. A custom struct is defined for each query response.
Returns the general configuration for the router contract.
{
"config": {}
}
Simulates multi-hop swap operations. Examples:
- KRT => UST => mABNB
{
"simulate_swap_operations" : {
"offer_amount": "123",
"operations": [
{
"native_swap": {
"offer_denom": "ukrw",
"ask_denom": "uusd"
}
},
{
"astro_swap": {
"offer_asset_info": {
"native_token": {
"denom": "uusd"
}
},
"ask_asset_info": {
"token": {
"contract_addr": "terra..."
}
}
}
}
]
}
}
- mABNB => UST => KRT
{
"simulate_swap_operations" : {
"offer_amount": "123",
"operations": [
{
"native_swap": {
"offer_denom": "uusd",
"ask_denom": "ukrw"
}
},
{
"astro_swap": {
"offer_asset_info": {
"token": {
"contract_addr": "terra..."
}
},
"ask_asset_info": {
"native_token": {
"denom": "uusd"
}
}
}
}
]
}
}