Usage
Last updated
If you need to deploy the router contract manually you will need to pass the hashes of the other contracts as parameters. Following is the command to deploy the Router contract.
Before deploying a Router Contract, you need to deploy other contracts first and pass hashes of these contracts to the respective parameters above. We have already deployed these contracts and the tables belows displays the hashes of the contracts.
Name | Network | Account info contract hash | Contract owner |
---|---|---|---|
For manual deployments of these contracts, here are the command templates.
Here are the Router's entry point methods.
This method adds liquidity to ERC-20⇄ERC-20 pool. To cover all possible scenarios, msg.sender should have already given the router an allowance of at least amount_a_desired/amount_b_desired on token_a/token_b. Always adds assets at the ideal ratio, according to the price when the transaction is executed.
Here is the table of parameters.
This method returns amount_a:U256, amount_b:U256, liquidity:U256
This method adds liquidity to ERC-20⇄CSPR pool with CSPR. To cover all possible scenarios, msg.sender should have already given the router an allowance of at least amount_token_desired on token. Always adds assets at the ideal ratio, according to the price when the transaction is executed. Leftovers of cspr tokens (if any), is returned to msg.sender
Here is the table of parameters.
This method returns amount_token:U256, amount_cspr:U256, liquidity:U256
This method Removes liquidity from an ERC-20⇄ERC-20 pool. msg.sender should have already given the router an allowance of at least liquidity on the pool.
Here is the table of parameters.
This method returns amount_a:U256, amount_b:U256
This method Removes liquidity from an ERC-20⇄ERC-20 pool. msg.sender should have already given the router an allowance of at least liquidity on the pool.
Here is the table of parameters.
This method returns amount_token:U256, amount_cspr:U256
This method Removes liquidity from an ERC-20⇄ERC-20 pool without pre-approval.
Here is the table of parameters.
This method returns amount_a:U256, amount_b:U256
Note: To know the steps of calculating the signature, refer to the documentation of Pair contract, in the pair repository.
This method Removes liquidity from an ERC-20⇄ERC-20 pool without pre-approval.
Here is the table of parameters.
This method returns amount_token:U256, amount_cspr:U256
Note: To know the steps of calculating the signature, refer to the documentation of Pair contract, in the pair repository.
Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of the path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). msg.sender should have already given the router an allowance of at least amount_in on the input token.
Here is the table of parameters.
This method returns amounts: Vector<U256>
Receive an exact amount of output tokens for as few input tokens as possible, along the route determined by the path. The first element of the path is the input token, the last is the output token, and any intermediate elements represent intermediate tokens to trade through (if, for example, a direct pair does not exist). msg.sender should have already given the router an allowance of at least amount_in_max on the input token.
Here is the table of parameters.
This method returns amounts: Vector<U256>
Swaps an exact amount of cspr for as many output tokens as possible, along the route determined by the path. The first element of the path must be WCSPR, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
Here is the table of parameters.
This method returns amounts: Vector<U256>
Receive an exact amount of CSPR for as few input tokens as possible, along the route determined by the path. The first element of the path is the input token, the last must be WCSPR, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). msg.sender should have already given the router an allowance of at least amount_in_max on the input token. If the address is a smart contract, it must have the ability to receive cspr.
Here is the table of parameters.
This method returns amounts: Vector<U256>
Swaps an exact amount of tokens for as much cspr as possible, along the route determined by the path. The first element of the path is the input token, the last must be WCSPR, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). If the address is a smart contract, it must have the ability to receive cspr.
Here is the table of parameters.
This method returns amounts: Vector<U256>
Receive an exact amount of tokens for as little CSPR as possible, along the route determined by the path. The first element of the path must be WCSPR, the last is the output token and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). Leftover of CSPR tokens, if any, is returned to msg.sender.
Here is the table of parameters.
This method returns amounts: Vector<U256>
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Parameter Name | Type |
---|---|
Factory
Testnet
hash-5028190b8a5b6addbf3d51ee2c6ae5b913f09223d65eff9bcf5985f74ae976ec
Casper Association
Wcspr
Testnet
hash-083756dee38a7e3a8a7190a17623cfbc8bc107511de206f03c3dbd1af5463a45
Casper Association
Library
Testnet
hash-fa073d1a95a606871983689633dab9464fb5fbe5f723b0855e025ea01b9bf308
Casper Association
Pair
Testnet
hash-8e6fbaae9f5ff3bb3cca7cb15723b2a47917d074922575187cb136e8d4b169a7
Casper Association
token_a
Key
token_b
Key
amount_a_desired
U256
amount_b_desired
U256
amount_a_min
U256
amount_b_min
U256
to
KEY
deadline
U256
token
Key
amount_token_desired
U256
amount_cspr_desired
U256
amount_token_min
U256
amount_cspr_min
U256
to
KEY
deadline
U256
token_a
Key
token_b
Key
liquidity
U256
amount_a_min
U256
amount_b_min
U256
to
Key
deadline
U256
token
Key
liquidity
U256
amount_token_min
U256
amount_cspr_min
U256
to
Key
deadline
U256
token_a
Key
token_b
Key
liquidity
U256
amount_a_min
U256
amount_b_min
U256
to
Key
deadline
U256
approve_max
Bool
public_key
String
signature
String
token
Key
liquidity
U256
amount_token_min
U256
amount_cspr_min
U256
to
Key
deadline
U256
approve_max
Bool
public_key
String
signature
String
amount_in
U256
amount_out_min
U256
path
Vec
to
Key
deadline
U256
amount_out
U256
amount_in_max
U256
path
Vec
to
Key
deadline
U256
amount_out_min
U256
amount_in
U256
path
Vec
to
Key
deadline
U256
amount_out
U256
amount_in_max
U256
path
Vec
to
Key
deadline
U256
amount_in
U256
amount_in_min
U256
path
Vec
to
Key
deadline
U256
amount_out
U256
amount_in_max
U256
path
Vec
to
Key
deadline
U256