SecretSwap
Search…
Create a New Pair
A pre-stored pair is used in this procedure. Token contract should be instantiated in advance.
The Factory JSON parameter for instantiation is below:
1
{
2
"pair_code_id": 1,
3
"pair_code_hash": "<HASH>",
4
"token_code_id": 2,
5
"token_code_hash": "<HASH>",
6
"init_hook": { // optional
7
"msg": "base64_encoded_json_data",
8
"contract_addr": "secret...",
9
"callback_code_hash": "<HASH>"
10
}
11
}
Copied!
The factory contract is responsible for creation of SecretSwap pairs as well as being the directory for all pairs. You may input numbers corresponding to pair_code_id and token_code_id. If an init_hook is given, the factory will call init_hook.contract_addr with init_hook.msg after being initialized.
After the factory is created, to create a new pair, you must first organize another JSON as below:
1
{
2
"create_pair": {
3
"asset_infos": [
4
{
5
"token": {
6
"contract_addr": "secret...",
7
"token_code_hash": "<HASH>",
8
"viewing_key": "" // ignored, can be whatever
9
}
10
},
11
{
12
"token": {
13
"contract_addr": "secret...",
14
"token_code_hash": "<HASH>",
15
"viewing_key": "" // ignored, can be whatever
16
}
17
}
18
],
19
"init_hook": { // optional
20
"msg": "base64_encoded_json_data",
21
"contract_addr": "secret...",
22
"callback_code_hash": "<HASH>"
23
}
24
}
25
}
Copied!
This is a JSON constructor of pair contract.
  • A token pair can be either a contract-based token, or a Native token (SCRT).
    • asset_infos[x].token.contract_addr: SNIP20 token address is entered here.
    • asset_infos[x].native_token.denom: Native token denominator is entered here.
The use of SCRT (the network's native token) is discouraged, as swaps involving SCRT would not be front-running resistant.
Last modified 7mo ago
Copy link