- Introduction
- Sections
The Router is stateless between transactions and can be replaced safely except for view keys specific to the SNIP20 to be traded. Before swapping the router contract, make sure all SNIP20s to be traded in the new contract are registered. This is to ensure upgradability of functionality with minimal impact. Stateful data is stored within the factory.
Initialize a Router Contract
Name | Type | Description | Optional |
---|---|---|---|
prng_seed | Binary | Seed used for generated viewing key | no |
entropy | Binary | Entropy used for generated viewing key | no |
admin_auth | Contract | The Contract used for admin authentication | no |
It is used to recover by sending some funds to a specific address.
Name | Type | Description | Optional |
---|---|---|---|
token | TokenType | Token type information | no |
amount | Unit128 | The amount to recover | no |
to | HumanAddr | The address to send the amount to | no |
msg | Binary | Message to pass in the send | yes |
{
"complete_task": {
"status": "success"
}
}
Register the router's viewing key with SNIP20 contract. This is required to verify the amount of tokens that the router contract receives on each step of a swap.
Name | Type | Description | Optional |
---|---|---|---|
token_addr | String | Register the viewing key for the router to the SNIP20 Token Contract | no |
token_code_hash | String | Token code hash used to verify the contract that is being registered | no |
{
"complete_task": {
"status": "success"
}
}
Extension of the SNIP20 receive callback used when receiving SNIP20 tokens used for trades.
Name | Type | Description | Optional |
---|---|---|---|
from | HumanAddr | who invokes the callback | no |
amount | Uint128 | amount sent | no |
msg | Binary | Message to Invoke in Pair Contract | yes |
{
"complete_task": {
"status": "success"
}
}
Used to trade the native token. Calls to this interface directly sending a SNIP20 token will not work, instead use the SNIP20 send with a embedded invoke.
Name | Type | Description | Optional |
---|---|---|---|
offer | TokenAmount | The native token amount sent into the start of the router trade | no |
expected_return | Binary | When given, the minimum amount of tokens that need to come out of the router trade | yes |
path | Vec(Hop) | The pair addresses in a array used for each leg of the trade | no |
recipient | String | Specify a recepient besides the sender of the native token | yes |
{
"complete_task": {
"status": "success"
}
}
Simulates the execution of a swap and returns the estimated values.
Name | Type | Description | Optional |
---|---|---|---|
offer | TokenAmount | The native token amount sent into the start of the router trade | no |
path | Vec(Hop) | The pair addresses in a array used for each leg of the trade | no |
{
"total_fee_amount": "Uint128",
"lp_fee_amount": "Uint128",
"shade_dao_fee_amount": "Uint128",
"result": "SwapResult",
"price": "String"
}
Gets the fonfiguration of a router.
Name | Type | Description | Optional |
---|---|---|---|
{
}
Swap callback is called by the pair contract after completing a trade to initialize the next step in the trade.
Name | Type | Description | Optional |
---|---|---|---|
last_token_out | TokenAmount | The token coming out from the pair contract trade | no |
signature | Binary | Signature to verify correct contract is calling back | no |
{
"complete_task": {
"status": "success"
}
}
Best path is calculated within the client, when invoking a swap that path is then provided to the router.