@cetusprotocol/sui-clmm-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/.turbo/turbo-build.log +11100 -0
  2. package/README.md +108 -0
  3. package/dist/index.d.mts +2251 -0
  4. package/dist/index.d.ts +2251 -0
  5. package/dist/index.js +13 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +13 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/docs/add_liquidity.md +145 -0
  10. package/docs/close_position.md +57 -0
  11. package/docs/collect_fees.md +37 -0
  12. package/docs/create_clmm_pool.md +228 -0
  13. package/docs/error_code.md +69 -0
  14. package/docs/get_clmm_pools.md +92 -0
  15. package/docs/get_positions.md +70 -0
  16. package/docs/get_reward.md +53 -0
  17. package/docs/get_ticks.md +39 -0
  18. package/docs/migrate_to_version_6.0.md +143 -0
  19. package/docs/open_position.md +224 -0
  20. package/docs/partner_swap.md +60 -0
  21. package/docs/pre_swap.md +136 -0
  22. package/docs/remove_liquidity.md +124 -0
  23. package/docs/swap.md +153 -0
  24. package/docs/utils.md +85 -0
  25. package/package.json +37 -0
  26. package/src/config/index.ts +2 -0
  27. package/src/config/mainnet.ts +41 -0
  28. package/src/config/testnet.ts +40 -0
  29. package/src/errors/errors.ts +93 -0
  30. package/src/errors/index.ts +1 -0
  31. package/src/index.ts +10 -0
  32. package/src/math/apr.ts +167 -0
  33. package/src/math/index.ts +1 -0
  34. package/src/modules/configModule.ts +540 -0
  35. package/src/modules/index.ts +5 -0
  36. package/src/modules/poolModule.ts +1066 -0
  37. package/src/modules/positionModule.ts +932 -0
  38. package/src/modules/rewarderModule.ts +430 -0
  39. package/src/modules/swapModule.ts +389 -0
  40. package/src/sdk.ts +131 -0
  41. package/src/types/clmm_type.ts +1002 -0
  42. package/src/types/clmmpool.ts +366 -0
  43. package/src/types/config_type.ts +241 -0
  44. package/src/types/index.ts +8 -0
  45. package/src/types/sui.ts +124 -0
  46. package/src/types/token_type.ts +189 -0
  47. package/src/utils/common.ts +426 -0
  48. package/src/utils/index.ts +3 -0
  49. package/src/utils/positionUtils.ts +434 -0
  50. package/src/utils/swapUtils.ts +499 -0
  51. package/tests/add_liquidity.test.ts +121 -0
  52. package/tests/add_liquidity_fix_token.test.ts +182 -0
  53. package/tests/apr.test.ts +71 -0
  54. package/tests/cetus_config.test.ts +26 -0
  55. package/tests/collect_fees.test.ts +11 -0
  56. package/tests/pool.test.ts +267 -0
  57. package/tests/position.test.ts +145 -0
  58. package/tests/remove_liquidity.test.ts +119 -0
  59. package/tests/rewarder.test.ts +60 -0
  60. package/tests/sdk_config.test.ts +49 -0
  61. package/tests/swap.test.ts +254 -0
  62. package/tests/tsconfig.json +26 -0
  63. package/tsconfig.json +5 -0
  64. package/tsup.config.ts +10 -0
@@ -0,0 +1,70 @@
1
+ # Get Positions
2
+
3
+ ## 1. Get all positions of one pool by ownerAddress
4
+
5
+ Use `sdk.Position.getPositionList()` method.
6
+
7
+ ### Function Parameters
8
+
9
+ - `account_address`: The user account address
10
+ - `assign_pool_ids`: An array of pool ID
11
+ - `show_display`: When some testnet rpc nodes can't return object's display data, you can set this option to false to avoid returning errors. Default is true.
12
+
13
+ ### Example
14
+
15
+ ```typescript
16
+ const account_address = '0xcd0247d0b67e53dde69b285e7a748e3dc390e8a5244eb9dd9c5c53d95e4cf0aa'
17
+ const assign_pool_ids = ['0x83c101a55563b037f4cd25e5b326b26ae6537dc8048004c1408079f7578dd160']
18
+ const res = await sdk.Position.getPositionList(account_address, assign_pool_ids, false)
19
+ ```
20
+
21
+ ## 2. Get all positions of one pool
22
+
23
+ Use `sdk.Pool.getPositionList()` method.
24
+
25
+ ### Function Parameters
26
+
27
+ - `position_handle`: The position handle of pool
28
+
29
+ ### Example
30
+
31
+ ```typescript
32
+ const position_handle = '0x83c101a55563b037f4cd25e5b326b26ae6537dc8048004c1408079f7578dd160'
33
+ const pool = await sdk.Pool.getPool(position_handle)
34
+ const res = await sdk.Pool.getPositionList(pool.position_manager.positions_handle)
35
+ ```
36
+
37
+ ## 3. Get one position
38
+
39
+ Use `sdk.Position.getPositionById()` method.
40
+
41
+ ### Function Parameters
42
+
43
+ - `position_id`: The position object ID
44
+ - `calculate_rewarder`: Whether to calculate the rewarder of the position
45
+ - `show_display`: When some testnet rpc nodes can't return object's display data, you can set this option to false to avoid returning errors. Default is true.
46
+
47
+ ### Example
48
+
49
+ ```typescript
50
+ const position_id = '0xfbf94213d59d285f66bacdb3d667a4db00b491af35887022e9197bb244705bde'
51
+ const res = await sdk.Position.getPositionById(position_id)
52
+ ```
53
+
54
+ ## 4. Batch get position fees
55
+
56
+ Use `sdk.Position.batchFetchPositionFees()` method.
57
+
58
+ ### Function Parameters
59
+
60
+ - `position_ids`: An array of position ID
61
+
62
+ ### Example
63
+
64
+ ```typescript
65
+ const position_ids = [
66
+ '0xf10d37cc00bcd60f85cef3fe473ea979e3f7f3631d522618e80c876b349e56bc',
67
+ '0xfbf94213d59d285f66bacdb3d667a4db00b491af35887022e9197bb244705bde',
68
+ ]
69
+ const fees = await TestnetSDK.Position.batchFetchPositionFees(position_ids)
70
+ ```
@@ -0,0 +1,53 @@
1
+ # Get Position Rewards
2
+
3
+ ## 1. Get Position Reward List of One Pool
4
+
5
+ Use `SDK.Pool.fetchPositionRewardList()` method.
6
+
7
+ ### Parameters
8
+
9
+ - `pool_id`: The pool object ID
10
+ - `coin_type_a`: Coin A type
11
+ - `coin_type_b`: Coin B type
12
+
13
+ ### Example
14
+
15
+ ```typescript
16
+ const pool_id = '0x83c101a55563b037f4cd25e5b326b26ae6537dc8048004c1408079f7578dd160'
17
+ const pool = await sdk.Pool.getPool(pool_id)
18
+ const res = await sdk.Pool.fetchPositionRewardList({
19
+ pool_id: pool.id,
20
+ coin_type_a: pool.coin_type_a,
21
+ coin_type_b: pool.coin_type_b,
22
+ })
23
+ ```
24
+
25
+ ## 2. Get Daily Reward Emission Info for One Pool
26
+
27
+ Use `sdk.Rewarder.emissionsEveryDay()` method.
28
+
29
+ ### Parameters
30
+
31
+ - `pool_id`: The pool object ID
32
+
33
+ ### Example
34
+
35
+ ```typescript
36
+ const pool_id = '0x83c101a55563b037f4cd25e5b326b26ae6537dc8048004c1408079f7578dd160'
37
+ const emissions_everyday = await sdk.Rewarder.emissionsEveryDay(pool_id)
38
+ ```
39
+
40
+ ## 3. Get Rewards of Position
41
+
42
+ Use `sdk.Rewarder.batchFetchPositionRewarders()` method.
43
+
44
+ ### Parameters
45
+
46
+ - `position_ids`: Array of position object ID
47
+
48
+ ### Example
49
+
50
+ ```typescript
51
+ const position_ids = ['0xf10d37cc00bcd60f85cef3fe473ea979e3f7f3631d522618e80c876b349e56bc']
52
+ const pos_rewarders_amount = await sdk.Rewarder.batchFetchPositionRewarders(position_ids)
53
+ ```
@@ -0,0 +1,39 @@
1
+ # Get ticks
2
+
3
+ ## 1. Batch get ticks by pool ID
4
+
5
+ Use `SDK.Pool.fetchTicks()` method.
6
+
7
+ ### Parameters
8
+
9
+ - `pool_id`: The pool object ID
10
+ - `coin_type_a`: Coin A type
11
+ - `coin_type_b`: Coin B type
12
+
13
+ ### Example
14
+
15
+ ```typescript
16
+ const pool_id = '0xbed3136f15b0ea649fb94bcdf9d3728fb82ba1c3e189bf6062d78ff547850054'
17
+ const coin_type_a = '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::usdt::USDT'
18
+ const coin_type_b = '0x26b3bc67befc214058ca78ea9a2690298d731a2d4309485ec3d40198063c4abc::cetus::CETUS'
19
+ const tick_data = await sdk.Pool.fetchTicks({
20
+ pool_id,
21
+ coin_type_a,
22
+ coin_type_b,
23
+ })
24
+ ```
25
+
26
+ ## 2.Batch get ticks by tickHandle
27
+
28
+ Use `sdk.Pool.fetchTicksByRpc()` method.
29
+
30
+ ### Parameters
31
+
32
+ - `tick_handle`: The tick handle of pool.
33
+
34
+ ### Example
35
+
36
+ ```typescript
37
+ const pool = await sdk.Pool.getPool('0x6fd4915e6d8d3e2ba6d81787046eb948ae36fdfc75dad2e24f0d4aaa2417a416')
38
+ const tick_data = await sdk.Pool.fetchTicksByRpc(pool.ticks_handle)
39
+ ```
@@ -0,0 +1,143 @@
1
+ # 📦 Migrate to SDK Version 6.0
2
+
3
+ > In SDK version 6.0, we’ve made significant upgrades and refactoring across the entire SDK. Function names, parameter styles, and return value field formats have been unified. Deprecated APIs have been removed. **It is strongly recommended to migrate as soon as possible.**
4
+
5
+ > The following are the main migration highlights. Please refer to the TypeScript types for specific details.
6
+
7
+ ---
8
+
9
+ ## 🚨 Important Notice
10
+
11
+ > All method parameters and response fields now use **snake_case naming convention**.
12
+ > Example: `tickSpacing` → `tick_spacing`
13
+
14
+ > ⚠️ This migration guide focuses only on major structural changes.Minor field name updates and signature adjustments are not exhaustively listed here.Please rely on TypeScript type hints and editor autocomplete to complete the migration accurately
15
+
16
+ ---
17
+
18
+ ## 1. CetusClmmSDK
19
+
20
+ 🛠 SDK Initialization Updated
21
+
22
+ ```diff
23
+ - const cetusClmmSDK = initCetusSDK({network: 'mainnet'})
24
+ + const sdk = CetusClmmSDK.createSDK({ env: 'mainnet' })
25
+
26
+ // Setting `senderAddress` has changed
27
+ - sdk.senderAddress = "0x..."
28
+ + sdk.setSenderAddress("0x...")
29
+ ```
30
+
31
+ 🔄 Method Migration
32
+
33
+ ```diff
34
+ // Get wallet balance
35
+ - sdk.getOwnerCoinAssets()
36
+ + sdk.FullClient.getOwnerCoinAssets()
37
+ - sdk.getOwnerCoinBalances()
38
+ + sdk.FullClient.getOwnerCoinAssets()
39
+
40
+ export type CoinAsset = {
41
+ - coinAddress: string
42
+ + coin_type: string
43
+ }
44
+ ```
45
+
46
+ ❌ Removed Modules
47
+ The Router and RouterV2 modules have been removed for better maintenance.
48
+ Use the recommended [Cetus Aggregator SDK](https://cetus-1.gitbook.io/cetus-developer-docs/developer/cetus-aggregator) instead.
49
+
50
+ | Deprecated Modules | Replacement |
51
+ | ------------------ | -------------- |
52
+ | Router | Aggregator SDK |
53
+ | RouterV2 | Aggregator SDK |
54
+
55
+ ## 2. Pool Module
56
+
57
+ 🔄 Method Migration
58
+
59
+ ```diff
60
+ - sdk.Pool.getSuiTransactionResponse(previousTx)
61
+ + sdk.FullClient.getSuiTransactionResponse(previousTx)
62
+
63
+ - sdk.Pool.getPoolsWithPage([], 'all', true)
64
+ + sdk.Pool.getPoolsWithPage('all', true)
65
+ + sdk.Pool.getAssignPools([])
66
+
67
+ export type Pool = {
68
+ - poolAddress: string
69
+ + id: string
70
+ - coinTypeA: string
71
+ + coin_type_a: string
72
+ - coinTypeB: string
73
+ + coin_type_b: string
74
+ ...
75
+ }
76
+ ```
77
+
78
+ ❌ Removed Methods
79
+ | Removed | Replacement |
80
+ | ---------------------------------- | ------------------------- |
81
+ | ~~`getPoolImmutables`~~ | getPoolImmutablesWithPage |
82
+ | ~~`getPools`~~ | getPoolsWithPage |
83
+ | ~~`creatPoolsTransactionPayload`~~ | createPoolPayload |
84
+ | ~~`creatPoolTransactionPayload`~~ | createPoolPayload |
85
+
86
+ ✏️ Renamed Methods
87
+ | Old Method | New Method |
88
+ | ------------------------------- | -------------------- |
89
+ | createPoolTransactionPayload | createPoolPayload |
90
+ | createPoolTransactionRowPayload | createPoolRowPayload |
91
+
92
+ ## 3. Position Module
93
+
94
+ ❌ Removed Methods
95
+ | Removed Method | Replacement |
96
+ | ------------------ | ----------------- |
97
+ | ~~`calculateFee`~~ | fetchPosFeeAmount |
98
+
99
+ ✏️ Renamed Methods
100
+ | Old Method | New Method |
101
+ | --------------------------------- | ----------------------------- |
102
+ | getSipmlePositionList | getSimplePositionList |
103
+ | removeLiquidityTransactionPayload | removeLiquidityPayload |
104
+ | closePositionTransactionPayload | closePositionPayload |
105
+ | openPositionTransactionPayload | openPositionPayload |
106
+ | collectFeeTransactionPayload | collectFeePayload |
107
+ | createCollectFeePaylod | createCollectFeePayload |
108
+ | createCollectFeeNoSendPaylod | createCollectFeeNoSendPayload |
109
+
110
+ ## 4. Rewarder Module
111
+
112
+ ❌ Removed Methods
113
+ | Removed Method | Replacement |
114
+ | ------------------------- | ------------------------ |
115
+ | ~~`posRewardersAmount`~~ | fetchPosRewardersAmount |
116
+ | ~~`poolRewardersAmount`~~ | fetchPoolRewardersAmount |
117
+
118
+ ✏️ Renamed Methods
119
+ | Old Method | New Method |
120
+ | --------------------------------- | ---------------------------------- |
121
+ | collectRewarderTransactionPayload | collectRewarderPayload |
122
+ | batchCollectRewardePayload | batchCollectRewardsPayload |
123
+ | createCollectRewarderPaylod | createCollectRewarderPayload |
124
+ | createCollectRewarderNoSendPaylod | createCollectRewarderNoSendPayload |
125
+
126
+ ## 5. helpers
127
+
128
+ 🔄 Method Migration
129
+ Several commonly used utility methods have been moved from @cetusprotocol/sui-clmm-sdk to @cetusprotocol/common-sdk.
130
+ Below are some typical import and usage changes:
131
+
132
+ > 🚫 `TransactionUtil` is deprecated and replaced CoinAssist
133
+
134
+ ```diff
135
+ - import type { CoinAssist, ClmmPoolUtil, TickMath,TickUtil } from '@cetusprotocol/sui-clmm-sdk'
136
+ + import type { CoinAssist, ClmmPoolUtil, TickMath,TickUtil } from '@cetusprotocol/common-sdk'
137
+
138
+ - TransactionUtil.buildCoinForAmount()
139
+ + CoinAssist.buildCoinForAmount()
140
+
141
+ - TransactionUtil.buildCoinWithBalance()
142
+ + CoinAssist.buildCoinWithBalance()
143
+ ```
@@ -0,0 +1,224 @@
1
+ # Open Position
2
+
3
+ Before you want to deposit liquidity, you need to choose an appropriate price range (corresponding to the tick range) to open a position.
4
+
5
+ There are two situations:
6
+
7
+ 1. Open a position only
8
+ 2. Open position and add liquidity (recommended)
9
+
10
+ In most cases, opening a position and adding liquidity are supposed to be done simultaneously.
11
+
12
+ ## 1.1. Open a Position Only with tick range
13
+
14
+ Use `sdk.Position.openPositionPayload()` method.
15
+
16
+ ### Function Parameters
17
+
18
+ - `pool_id`: The object id about which pool you want to operation
19
+ - `coin_type_a`: The coin type address about coinA
20
+ - `coin_type_b`: The coin type address about coinB
21
+ - `tick_lower`: Represents the index of the lower tick boundary
22
+ - `tick_upper`: Represents the index of the upper tick boundary
23
+
24
+ ### Important Notes
25
+
26
+ - The tick index must be an integer multiple of tickSpacing. If the provided parameter is not a multiple of tickSpacing, the contract will throw an error.
27
+ - `-443636 < tick_lower_index < tick_upper_index < 443636`, 443636 is a constant, derived from the maximum range representable by the Q32.62 fixed-point number format.
28
+ - If you know price range, you can use `TickMath.priceToTickIndex()` to transform real price to tick index.
29
+ - You can just open one position near the current price of the pool, use `TickMath.getPrevInitializeTickIndex()` and `TickMath.getNextInitializeTickIndex()` to find the next initialized tick.
30
+ - If you want to add global liquidity, you can set:
31
+ - `tick_lower_index = -443636 + (443636 % tick_spacing)`
32
+ - `tick_upper_index = 443636 - (443636 % tick_spacing)`
33
+
34
+ ### 1 Example
35
+
36
+ ```typescript
37
+ const send_key_pair = 'The key pair generated by your private key'
38
+ // fetch pool data
39
+ const pool = await sdk.Pool.getPool(pool_id)
40
+ // build tick range
41
+ const lower_tick = TickMath.getPrevInitializeTickIndex(new BN(pool.current_tick_index).toNumber(), new BN(pool.tick_spacing).toNumber())
42
+ const upper_tick = TickMath.getNextInitializeTickIndex(new BN(pool.current_tick_index).toNumber(), new BN(pool.tick_spacing).toNumber())
43
+ // build open position payload
44
+ const open_position_payload = sdk.Position.openPositionPayload({
45
+ coin_type_a: pool.coin_type_a,
46
+ coin_type_b: pool.coin_type_b,
47
+ tick_lower: lower_tick.toString(),
48
+ tick_upper: upper_tick.toString(),
49
+ pool_id: pool.id,
50
+ })
51
+ const transfer_txn = await sdk.FullClient.executeTx(send_key_pair, open_position_payload, true)
52
+ ```
53
+
54
+ ### 1.2 Open a Position Only with price range
55
+
56
+ Use `sdk.Position.openPositionWithPricePayload()` method.
57
+
58
+ #### Required Parameters
59
+
60
+ - `pool_id`: The object id about which pool you want to operation
61
+ - `add_mode_params`: Configuration for price range:
62
+ - For custom range: `{ is_full_range: false, min_price: string, max_price: string , price_base_coin: string}`
63
+ - For full range: `{ is_full_range: true }`
64
+ - `coin_decimals_a`: Number of decimal places for coin A
65
+ - `coin_decimals_b`: Number of decimal places for coin B
66
+ - `price_base_coin`: Base coin for price calculation ('coin_a' or 'coin_b')
67
+
68
+ ```typescript
69
+ const pool_id = '0x0...'
70
+
71
+ // use full range price mode
72
+ const full_range_params: OpenPositionWithPriceParams = {
73
+ pool_id,
74
+ is_full_range: true,
75
+ }
76
+ const open_payload = await sdk.Position.openPositionWithPricePayload(full_range_params)
77
+
78
+ // or
79
+ // use custom price range
80
+ const custom_price_range_params: OpenPositionWithPriceParams = {
81
+ pool_id,
82
+ coin_decimals_a: 6,
83
+ coin_decimals_b: 9,
84
+ is_full_range: false,
85
+ min_price: '0.2',
86
+ max_price: '0.9',
87
+ price_base_coin: 'coin_a',
88
+ }
89
+ const open_payload = await sdk.Position.openPositionWithPricePayload(custom_price_range_params)
90
+
91
+ const transfer_txn = await sdk.FullClient.executeTx(send_key_pair, open_payload, true)
92
+ ```
93
+
94
+ ## 2.1 Open Position with Add Liquidity by tick range
95
+
96
+ Use `sdk.Position.createAddLiquidityFixTokenPayload()` method.
97
+
98
+ ### Function Parameters
99
+
100
+ - `pool_id`: The object id about which pool you want to operation
101
+ - `coin_type_a`: The coin type address about coinA
102
+ - `coin_type_b`: The coin type address about coinB
103
+ - `tick_lower`: Represents the index of the lower tick boundary
104
+ - `tick_upper`: Represents the index of the upper tick boundary
105
+ - `is_open`: true means if first add liquidity, so needs open one position
106
+ - `pos_id`: The object id about position
107
+ - `fix_amount_a`: true means fixed coinA amount, false means fixed coinB amount
108
+ - `amount_a`: If fixed amount A, you must set amount_a, amount_b will be auto calculated by `ClmmPoolUtil.estLiquidityAndCoinAmountFromOneAmounts()`
109
+ - `amount_b`: If fixed amount B, you must set amount_b, amount_a will be auto calculated by `ClmmPoolUtil.estLiquidityAndCoinAmountFromOneAmounts()`
110
+ - `collect_fee`: If you already has one position, you can select collect fees while adding liquidity
111
+ - `rewarder_coin_types`: If these not empty, it will collect rewarder in this position, if you already open the position
112
+
113
+ ### Important Notes
114
+
115
+ - The tick index must be an integer multiple of tickSpacing. If the provided parameter is not a multiple of tickSpacing, the contract will throw an error.
116
+ - `-443636 < tick_lower_index < tick_upper_index < 443636`, 443636 is a constant, derived from the maximum range representable by the Q32.62 fixed-point number format.
117
+ - If you know price range, you can use `TickMath.priceToTickIndex()` to transform real price to tick index.
118
+ - You can just open one position near the current price of the pool, use `TickMath.getPrevInitializeTickIndex()` and `TickMath.getNextInitializeTickIndex()` to find the next initialized tick.
119
+ - If you want to add global liquidity, you can set:
120
+ - `tick_lower_index = -443636 + (443636 % tick_spacing)`
121
+ - `tick_upper_index = 443636 - (443636 % tick_spacing)`
122
+
123
+ ### Example
124
+
125
+ ```typescript
126
+ const pool = await sdk.Pool.getPool(pool_id)
127
+ const coin_amount = new BN(500)
128
+ const fix_amount_a = true
129
+ const slippage = 0.1
130
+ const cur_sqrt_price = new BN(pool.current_sqrt_price)
131
+
132
+ const tick_lower_index = TickMath.getPrevInitializeTickIndex(
133
+ new BN(pool.current_tick_index).toNumber(),
134
+ new BN(pool.tick_spacing).toNumber()
135
+ )
136
+ const tick_upper_index = TickMath.getNextInitializeTickIndex(
137
+ new BN(pool.current_tick_index).toNumber(),
138
+ new BN(pool.tick_spacing).toNumber()
139
+ )
140
+
141
+ const liquidity_input = ClmmPoolUtil.estLiquidityAndCoinAmountFromOneAmounts(
142
+ tick_lower_index,
143
+ tick_upper_index,
144
+ coin_amount,
145
+ fix_amount_a,
146
+ true,
147
+ slippage,
148
+ cur_sqrt_price
149
+ )
150
+
151
+ const amount_a = fix_amount_a ? coin_amount.toNumber() : Number(liquidity_input.coin_amount_limit_a)
152
+ const amount_b = fix_amount_a ? Number(liquidity_input.coin_amount_limit_b) : coin_amount.toNumber()
153
+
154
+ const add_liquidity_payload_params: AddLiquidityFixTokenParams = {
155
+ coin_type_a: pool.coin_type_a,
156
+ coin_type_b: pool.coin_type_b,
157
+ pool_id: pool.id,
158
+ tick_lower: tick_lower_index.toString(),
159
+ tick_upper: tick_upper_index.toString(),
160
+ fix_amount_a,
161
+ amount_a,
162
+ amount_b,
163
+ slippage,
164
+ is_open: true,
165
+ pos_id: position.pos_object_id,
166
+ rewarder_coin_types: [],
167
+ collect_fee: false,
168
+ }
169
+ const add_liquidity_payload = await sdk.Position.createAddLiquidityFixTokenPayload(add_liquidity_payload_params)
170
+
171
+ const transfer_txn = await sdk.FullClient.executeTx(send_key_pair, add_liquidity_payload, true)
172
+ ```
173
+
174
+ ## 2.2 Open Position with Add Liquidity by price range
175
+
176
+ Use `sdk.Position.createAddLiquidityFixCoinWithPricePayload()` method.
177
+
178
+ ### Function Parameters
179
+
180
+ - `pool_id`: The object id about which pool you want to operation
181
+ - `add_mode_params`: Configuration for price range:
182
+ - For custom range: `{ is_full_range: false, min_price: string, max_price: string , price_base_coin: string, coin_decimals_a: number, coin_decimals_b: number}`
183
+ - For full range: `{ is_full_range: true }`
184
+ - `coin_decimals_a`: Number of decimal places for coin A
185
+ - `coin_decimals_b`: Number of decimal places for coin B
186
+ - `price_base_coin`: Base coin for price calculation ('coin_a' or 'coin_b')
187
+
188
+ ### Example
189
+
190
+ Use `sdk.Position.createAddLiquidityFixTokenPayload()` method.
191
+
192
+ ```typescript
193
+ // custom price range
194
+ const params: CustomRangeParams = {
195
+ s_full_range: false,
196
+ min_price: '0.2',
197
+ max_price: '0.7',
198
+ coin_decimals_a: 6,
199
+ coin_decimals_b: 9,
200
+ price_base_coin: 'coin_a',
201
+ }
202
+
203
+ // or
204
+ // full range price
205
+ const params: FullRangeParams = {
206
+ is_full_range: true,
207
+ }
208
+
209
+ const result = await sdk.Position.calculateAddLiquidityResultWithPrice({
210
+ add_mode_params: params,
211
+ pool_id,
212
+ slippage: 0.01,
213
+ coin_amount: toDecimalsAmount(1, 6).toString(),
214
+ fix_amount_a: true,
215
+ })
216
+
217
+ const payload = await sdk.Position.createAddLiquidityFixCoinWithPricePayload({
218
+ pool_id,
219
+ calculate_result: result,
220
+ add_mode_params: params,
221
+ })
222
+
223
+ const transfer_txn = await sdk.FullClient.executeTx(send_key_pair, payload, true)
224
+ ```
@@ -0,0 +1,60 @@
1
+ # Partner Swap
2
+
3
+ Currently, only established project teams are eligible for applying for partner swap.
4
+
5
+ ## Partner
6
+
7
+ We offer a partner function. When you utilize the standard swap method, we will allocate the agreed-upon share to the partner. However, due to Sui contract limitations, partner functionality doesn't work in the latest smart router function with split order or when integrating other pools like DeepBook.
8
+
9
+ ## Partner AccountCap
10
+
11
+ Only verified accounts are eligible to collect partner referral fees. When creating a partner, we generate a Partner AccountCap object (visible in your NFT list). Only accounts that possess the AccountCap are able to claim the fees.
12
+
13
+ ## Claim Referral Fee
14
+
15
+ We provide a function `sdk.Pool.claimPartnerRefFeePayload()` to check referral fees.
16
+
17
+ ### Function Parameters
18
+
19
+ Please refer to the original function for specific parameter types.
20
+
21
+ - `partner_cap`: The object ID of the partner cap
22
+ - `partner`: The object ID of the partner
23
+ - `coin_type`: The coin type for the fee coin type. You can obtain the referral fee using this specified method.
24
+
25
+ ### Example
26
+
27
+ ```typescript
28
+ const partner_cap = '0x...'
29
+ const partner = '0x...'
30
+ const coin_type = '0x...::...::....'
31
+ const claim_ref_ree_payload = await sdk.Pool.claimPartnerRefFeePayload(partner_cap, partner, coin_type)
32
+ const transfer_txn = await sdk.fullClient.sendTransaction(buildTestAccount(), claim_ref_ree_payload)
33
+ ```
34
+
35
+ ## Check Referral Fee
36
+
37
+ We provide a function `sdk.Pool.getPartnerRefFeeAmount()` to check referral fees.
38
+
39
+ ### Function Parameters
40
+
41
+ Please refer to the original function for specific parameter types.
42
+
43
+ - `partner_id`: The object ID of the partner
44
+
45
+ ### Example
46
+
47
+ ```typescript
48
+ import BN from 'bn.js'
49
+ import { CetusClmmSDK } from '@cetusprotocol/sui-clmm-sdk'
50
+
51
+ const sdk = CetusClmmSDK.createSDK({ env: 'mainnet' })
52
+
53
+ const partner_id = '0x...'
54
+ const ref_fee = await sdk.Pool.getPartnerRefFeeAmount(partner_id)
55
+ ```
56
+
57
+ ## Apply for Partner Swap
58
+
59
+ Interested in Partner Swap? Submit a request from here:
60
+ [https://4bx69zjogri.typeform.com/to/UUETIX2f](https://4bx69zjogri.typeform.com/to/UUETIX2f)