Create Pool
Create Pool
For general pool creation, use the create_pool_v3/create_pool_v2/create_pool function in the registry module.
The original create_pool relied on the CoinMetadata of both coins, so after Sui’s metadata mechanism changed and some CoinMetadata got destroyed, it no longer worked for those coins. create_pool_v2 and create_pool_v3 both support creating pools without coin metadata, and create_pool_v3 is now recommended. The difference between them is how global_config is passed: create_pool_v2 one uses a mutable reference, and create_pool_v3 uses an immutable reference.
Function params
registry: the reference to the global registry.
mainnet
0xb1d55e7d895823c65f98d99b81a69436cf7d1638629c9ccb921326039cda1f1b
testnet
0x319070e26a6809f439d3c4a45e63bf74939c5fe3165de7b65968ee8547f71bd0
metadata_a: Metadata object id for token A.(
create_pool_v2don't need it)metadata_b: Metadata object id for token B.(
create_pool_v2don't need it)bin_step: Bin step configuration for the pool.
base_factor: Base factor for the pool configuration
0.01%
1
10,000
0.02%
1
20,000
0.03%
2
15,000
0.04%
2
20,000
0.05%
5
10,000
0.10%
10
10,000
0.15%
15
10,000
0.20%
20
10,000
0.25%
25
10,000
0.30%
30
10,000
0.40%
50
8,000
0.60%
80
7,500
0.80%
100
8,000
1.00%
100
10,000
2.00%
200
10,000
4.00%
400
10,000
active_id: Initial active bin ID for the pool
How to calculate bin id by price?Formula:
bin_id = log(price) / log(1 + bin_step/10000)Explanation: The bin ID represents which price level (bin) a given price falls into within a geometric sequence. Each bin is
(1 + bin_step/10000)times larger than the previous one, wherebin_stepis measured in basis points (1/10000). The logarithm calculates how many multiplicative steps are needed to reach the target price from the base price of 1.Example: If
bin_step = 20(0.2%) andprice = 1.5, thenbin_id = log(1.5) / log(1.002) ≈ 203, meaning the price 1.5 is at the 203rd bin in the geometric price scale.
url: URL for pool metadata.
config: Reference to the global config for validations
mainnet
0xf31b605d117f959b9730e8c07b08b856cb05143c5e81d5751c90d2979e82f599
testnet
0x88bb33e9eff2fccab980a0e4b43fc4572abd08f08304d47a20d3e4e99d94d159
versioned: Versioned object for version checking
mainnet
0x05370b2d656612dd5759cbe80463de301e3b94a921dfc72dd9daa2ecdeb2d0a8
testnet
0xa710caae87b2129acc97fbb98ea7011e3137c3291b02c0fcce866d67d5d9e8d0
clock: Clock object for timestamp operations. (0x6)
Types
coinTypeA: the coin type address about coinA.coinTypeB: the coin type address about coinB.
Last updated