Router
Overview
The Router contract contains logic to facilitate multi-hop swaps for Cosmos native & CW20 tokens.
Links
- Contract Address: terra1j8hayvehh3yy02c2vtw5fdhz9f4drhtee8p5n5rguvg3nyd6m83qd2y90a
- Testnet Address: terra1na348k6rvwxje9jj6ftpsapfeyaejxjeq6tuzdmzysps20l6z23smnlv64
- Contract Repo: https://github.com/astroport-fi/astroport-core/tree/main/contracts/router
- contract.rs: https://github.com/astroport-fi/astroport-core/blob/main/contracts/router/src/contract.rs
- router.rs: https://github.com/astroport-fi/astroport-core/blob/main/packages/astroport/src/router.rs
- Tests: https://github.com/astroport-fi/astroport-core/tree/main/contracts/router/tests
InstantiateMsg
Initializes the Router contract with the Astroport factory contract address.
ExecuteMsg
receive
CW20 receive msg.
Params | Type | Description |
---|---|---|
receive | Cw20ReceiveMsg | CW20 receive message |
execute_swap_operations
Performs multi-hop swap operations for native Cosmos & CW20 tokens. Swaps execute one-by-one and the last swap will return the ask token. This function is public (can be called by anyone).
Params | Type | Description |
---|---|---|
operations | Vec<SwapOperation> | A vector of swap operations |
minimum_receive | Option<Uint128> | The minimum amount of tokens to get from a swap |
to | Option<String> | Addess receving tokens (if different from sender) |
max_spread | Option<Decimal> | Max spread |
SwapOperation
Variants | Description |
---|---|
NativeSwap | Native swap |
AstroSwap | ASTRO swap |
execute_swap_operation
Executes a single swap operation. This message is for internal use.
Params | Type | Description |
---|---|---|
operation | <SwapOperation> | Native or Astro swap operation |
to | Option<String> | Addess receving tokens (if different from sender) |
max_spread | Option<Decimal> | Max spread |
single | bool | Defines whether this swap is single or part of a multi hop route |
assert_minimum_receive
Checks that an amount of ask tokens exceeds minimum_receive
. This message is for internal use.
Params | Type | Description |
---|---|---|
asset_info | AssetInfo | Information about an asset stored in an AssetInfo struct |
prev_balance | Uint128 | Previous balance |
minimum_receive | Uint128 | The minimum amount of tokens to get from a swap |
receiver | String | Addess receving tokens |
QueryMsg
config
Queries the general configuration for the router contract.
ConfigResponse
This structure describes a custom struct to return a query response containing the base contract configuration.
Params | Type | Description |
---|---|---|
astroport_factory | String | The Astroport factory contract address |
simulate_swap_operations
Simulates multi-hop swap operations.
Params | Type | Description |
---|---|---|
offer_amount | Uint128 | The amount of tokens to swap |
operations | Vec<SwapOperation> | The swap operations to perform, each swap involving a specific pool |
SimulateSwapOperationsResponse
This structure describes a custom struct to return a query response containing the end amount of a swap simulation.
Params | Type | Description |
---|---|---|
amount | Uint128 | The amount of tokens received in a swap simulation |