Router
The router
contract contains the logic to facilitate multi-hop swap operations. It is the entry point for all swaps in the interface. The swaps, while facilitated by the router
contract, in reality happen on each pair
contract.
InstantiateMsg
The instantiation of the router contract requires the factory
contract address.
{
"halo_factory": "aura...", // The address of the factory contract
}
ExecuteMsg
Below are the available ExecuteMsg (write) methods for the router
contract.
ExecuteSwapOperations
The execute_swap_operations
allows the user to execute any swaps in a path defined in the operations
parameter. These are executed on their respective pair
contracts.
{
"execute_swap_operations" {
"operations": [
{
"offer_asset_info": {
"token": {
"contract_addr": "aura...",
}
},
"ask_asset_info": {
"native_token": {
"denom": "uaura"
}
},
},
],
"minimum_receive": None,
"to": "aura...",
},
}
Where:
operations
is the list of swap operations. Each operation contains the offer asset and the ask asset. The offer asset is the asset that the user wants to swap. The ask asset is the asset that the user wants to receive.minimum_receive
is the minimum amount of the ask asset that the user wants to receive. If the amount of the ask asset is less than the minimum amount, the swap operation will fail.to
is the address that the user wants to receive the ask asset.
QueryMsg
Below are the available QueryMsg (read) methods for the router
contract.
Config
Displays the current configuration values for the contract. This query returns a ConfigResponse
response type.
{
"config" {}
}
The ConfigResponse
struct is shown below.
pub struct ConfigResponse {
pub halo_factory: String,
}
SimulateSwapOperations
Shows the result of a simulated swap. This query returns a SimulateSwapOperationsResponse
response type.
{
"simulate_swap_operations": {
"offer_amount": 10000,
"operations": {[
"offer_asset_info": {
"token": {
"contract_addr": "aura...",
}
},
"ask_asset_info": {
"native_token": {
"denom": "uaura"
}
},
]},
},
}
The SimulateSwapOperationsResponse
struct is shown below.
SimulateSwapOperations {
offer_amount: Uint128,
operations: Vec<SwapOperation>,
}
ReverseSimulateSwapOperations
Shows the result of a reversed simulated swap. This query returns a ReverseSimulateSwapOperationsResponse
response type same as the method above.
{
"reverse_simulate_swap_operations": {
"ask_amount": 10000,
"operations": {[
"offer_asset_info": {
"token": {
"contract_addr": "aura...",
}
},
"ask_asset_info": {
"native_token": {
"denom": "uaura"
}
},
]},
},
}
The ReverseSimulateSwapOperationsResponse
struct is shown below.
ReverseSimulateSwapOperations {
ask_amount: Uint128,
operations: Vec<SwapOperation>,
}