@meteora-ag/dlmm 1.2.4-rc2.0 → 1.3.1-sam.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.
- package/dist/index.d.ts +346 -250
- package/dist/index.js +595 -669
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +548 -622
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
// src/dlmm/idl.ts
|
|
11
11
|
var IDL = {
|
|
12
|
-
"version": "0.8.
|
|
12
|
+
"version": "0.8.2",
|
|
13
13
|
"name": "lb_clmm",
|
|
14
14
|
"constants": [
|
|
15
15
|
{
|
|
@@ -97,6 +97,21 @@ var IDL = {
|
|
|
97
97
|
},
|
|
98
98
|
"value": "15"
|
|
99
99
|
},
|
|
100
|
+
{
|
|
101
|
+
"name": "MAX_BIN_STEP",
|
|
102
|
+
"type": "u16",
|
|
103
|
+
"value": "400"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "MAX_BASE_FEE",
|
|
107
|
+
"type": "u128",
|
|
108
|
+
"value": "100_000_000"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "MIN_BASE_FEE",
|
|
112
|
+
"type": "u128",
|
|
113
|
+
"value": "100_000"
|
|
114
|
+
},
|
|
100
115
|
{
|
|
101
116
|
"name": "BIN_ARRAY",
|
|
102
117
|
"type": "bytes",
|
|
@@ -294,6 +309,90 @@ var IDL = {
|
|
|
294
309
|
}
|
|
295
310
|
]
|
|
296
311
|
},
|
|
312
|
+
{
|
|
313
|
+
"name": "initializeCustomizablePermissionlessLbPair",
|
|
314
|
+
"accounts": [
|
|
315
|
+
{
|
|
316
|
+
"name": "lbPair",
|
|
317
|
+
"isMut": true,
|
|
318
|
+
"isSigner": false
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"name": "binArrayBitmapExtension",
|
|
322
|
+
"isMut": true,
|
|
323
|
+
"isSigner": false,
|
|
324
|
+
"isOptional": true
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"name": "tokenMintX",
|
|
328
|
+
"isMut": false,
|
|
329
|
+
"isSigner": false
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"name": "tokenMintY",
|
|
333
|
+
"isMut": false,
|
|
334
|
+
"isSigner": false
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "reserveX",
|
|
338
|
+
"isMut": true,
|
|
339
|
+
"isSigner": false
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"name": "reserveY",
|
|
343
|
+
"isMut": true,
|
|
344
|
+
"isSigner": false
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"name": "oracle",
|
|
348
|
+
"isMut": true,
|
|
349
|
+
"isSigner": false
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"name": "userTokenX",
|
|
353
|
+
"isMut": false,
|
|
354
|
+
"isSigner": false
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"name": "funder",
|
|
358
|
+
"isMut": true,
|
|
359
|
+
"isSigner": true
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"name": "tokenProgram",
|
|
363
|
+
"isMut": false,
|
|
364
|
+
"isSigner": false
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"name": "systemProgram",
|
|
368
|
+
"isMut": false,
|
|
369
|
+
"isSigner": false
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"name": "rent",
|
|
373
|
+
"isMut": false,
|
|
374
|
+
"isSigner": false
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "eventAuthority",
|
|
378
|
+
"isMut": false,
|
|
379
|
+
"isSigner": false
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"name": "program",
|
|
383
|
+
"isMut": false,
|
|
384
|
+
"isSigner": false
|
|
385
|
+
}
|
|
386
|
+
],
|
|
387
|
+
"args": [
|
|
388
|
+
{
|
|
389
|
+
"name": "params",
|
|
390
|
+
"type": {
|
|
391
|
+
"defined": "CustomizableParams"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
]
|
|
395
|
+
},
|
|
297
396
|
{
|
|
298
397
|
"name": "initializeBinArrayBitmapExtension",
|
|
299
398
|
"accounts": [
|
|
@@ -1026,6 +1125,11 @@ var IDL = {
|
|
|
1026
1125
|
"isMut": false,
|
|
1027
1126
|
"isSigner": false
|
|
1028
1127
|
},
|
|
1128
|
+
{
|
|
1129
|
+
"name": "owner",
|
|
1130
|
+
"isMut": false,
|
|
1131
|
+
"isSigner": false
|
|
1132
|
+
},
|
|
1029
1133
|
{
|
|
1030
1134
|
"name": "operator",
|
|
1031
1135
|
"isMut": false,
|
|
@@ -1035,12 +1139,17 @@ var IDL = {
|
|
|
1035
1139
|
]
|
|
1036
1140
|
},
|
|
1037
1141
|
{
|
|
1038
|
-
"name": "
|
|
1142
|
+
"name": "operatorTokenX",
|
|
1039
1143
|
"isMut": false,
|
|
1040
1144
|
"isSigner": false
|
|
1041
1145
|
},
|
|
1042
1146
|
{
|
|
1043
|
-
"name": "
|
|
1147
|
+
"name": "ownerTokenX",
|
|
1148
|
+
"isMut": false,
|
|
1149
|
+
"isSigner": false
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
"name": "systemProgram",
|
|
1044
1153
|
"isMut": false,
|
|
1045
1154
|
"isSigner": false
|
|
1046
1155
|
},
|
|
@@ -1065,12 +1174,12 @@ var IDL = {
|
|
|
1065
1174
|
"type": "i32"
|
|
1066
1175
|
},
|
|
1067
1176
|
{
|
|
1068
|
-
"name": "
|
|
1177
|
+
"name": "feeOwner",
|
|
1069
1178
|
"type": "publicKey"
|
|
1070
1179
|
},
|
|
1071
1180
|
{
|
|
1072
|
-
"name": "
|
|
1073
|
-
"type": "
|
|
1181
|
+
"name": "lockReleasePoint",
|
|
1182
|
+
"type": "u64"
|
|
1074
1183
|
}
|
|
1075
1184
|
]
|
|
1076
1185
|
},
|
|
@@ -2048,73 +2157,6 @@ var IDL = {
|
|
|
2048
2157
|
],
|
|
2049
2158
|
"args": []
|
|
2050
2159
|
},
|
|
2051
|
-
{
|
|
2052
|
-
"name": "removeLiquiditySingleSide",
|
|
2053
|
-
"accounts": [
|
|
2054
|
-
{
|
|
2055
|
-
"name": "position",
|
|
2056
|
-
"isMut": true,
|
|
2057
|
-
"isSigner": false
|
|
2058
|
-
},
|
|
2059
|
-
{
|
|
2060
|
-
"name": "lbPair",
|
|
2061
|
-
"isMut": true,
|
|
2062
|
-
"isSigner": false
|
|
2063
|
-
},
|
|
2064
|
-
{
|
|
2065
|
-
"name": "binArrayBitmapExtension",
|
|
2066
|
-
"isMut": true,
|
|
2067
|
-
"isSigner": false,
|
|
2068
|
-
"isOptional": true
|
|
2069
|
-
},
|
|
2070
|
-
{
|
|
2071
|
-
"name": "userToken",
|
|
2072
|
-
"isMut": true,
|
|
2073
|
-
"isSigner": false
|
|
2074
|
-
},
|
|
2075
|
-
{
|
|
2076
|
-
"name": "reserve",
|
|
2077
|
-
"isMut": true,
|
|
2078
|
-
"isSigner": false
|
|
2079
|
-
},
|
|
2080
|
-
{
|
|
2081
|
-
"name": "tokenMint",
|
|
2082
|
-
"isMut": false,
|
|
2083
|
-
"isSigner": false
|
|
2084
|
-
},
|
|
2085
|
-
{
|
|
2086
|
-
"name": "binArrayLower",
|
|
2087
|
-
"isMut": true,
|
|
2088
|
-
"isSigner": false
|
|
2089
|
-
},
|
|
2090
|
-
{
|
|
2091
|
-
"name": "binArrayUpper",
|
|
2092
|
-
"isMut": true,
|
|
2093
|
-
"isSigner": false
|
|
2094
|
-
},
|
|
2095
|
-
{
|
|
2096
|
-
"name": "sender",
|
|
2097
|
-
"isMut": false,
|
|
2098
|
-
"isSigner": true
|
|
2099
|
-
},
|
|
2100
|
-
{
|
|
2101
|
-
"name": "tokenProgram",
|
|
2102
|
-
"isMut": false,
|
|
2103
|
-
"isSigner": false
|
|
2104
|
-
},
|
|
2105
|
-
{
|
|
2106
|
-
"name": "eventAuthority",
|
|
2107
|
-
"isMut": false,
|
|
2108
|
-
"isSigner": false
|
|
2109
|
-
},
|
|
2110
|
-
{
|
|
2111
|
-
"name": "program",
|
|
2112
|
-
"isMut": false,
|
|
2113
|
-
"isSigner": false
|
|
2114
|
-
}
|
|
2115
|
-
],
|
|
2116
|
-
"args": []
|
|
2117
|
-
},
|
|
2118
2160
|
{
|
|
2119
2161
|
"name": "togglePairStatus",
|
|
2120
2162
|
"accounts": [
|
|
@@ -2131,27 +2173,6 @@ var IDL = {
|
|
|
2131
2173
|
],
|
|
2132
2174
|
"args": []
|
|
2133
2175
|
},
|
|
2134
|
-
{
|
|
2135
|
-
"name": "updateWhitelistedWallet",
|
|
2136
|
-
"accounts": [
|
|
2137
|
-
{
|
|
2138
|
-
"name": "lbPair",
|
|
2139
|
-
"isMut": true,
|
|
2140
|
-
"isSigner": false
|
|
2141
|
-
},
|
|
2142
|
-
{
|
|
2143
|
-
"name": "creator",
|
|
2144
|
-
"isMut": false,
|
|
2145
|
-
"isSigner": true
|
|
2146
|
-
}
|
|
2147
|
-
],
|
|
2148
|
-
"args": [
|
|
2149
|
-
{
|
|
2150
|
-
"name": "wallet",
|
|
2151
|
-
"type": "publicKey"
|
|
2152
|
-
}
|
|
2153
|
-
]
|
|
2154
|
-
},
|
|
2155
2176
|
{
|
|
2156
2177
|
"name": "migratePosition",
|
|
2157
2178
|
"accounts": [
|
|
@@ -2327,42 +2348,6 @@ var IDL = {
|
|
|
2327
2348
|
}
|
|
2328
2349
|
]
|
|
2329
2350
|
},
|
|
2330
|
-
{
|
|
2331
|
-
"name": "setLockReleasePoint",
|
|
2332
|
-
"accounts": [
|
|
2333
|
-
{
|
|
2334
|
-
"name": "position",
|
|
2335
|
-
"isMut": true,
|
|
2336
|
-
"isSigner": false
|
|
2337
|
-
},
|
|
2338
|
-
{
|
|
2339
|
-
"name": "lbPair",
|
|
2340
|
-
"isMut": false,
|
|
2341
|
-
"isSigner": false
|
|
2342
|
-
},
|
|
2343
|
-
{
|
|
2344
|
-
"name": "sender",
|
|
2345
|
-
"isMut": false,
|
|
2346
|
-
"isSigner": true
|
|
2347
|
-
},
|
|
2348
|
-
{
|
|
2349
|
-
"name": "eventAuthority",
|
|
2350
|
-
"isMut": false,
|
|
2351
|
-
"isSigner": false
|
|
2352
|
-
},
|
|
2353
|
-
{
|
|
2354
|
-
"name": "program",
|
|
2355
|
-
"isMut": false,
|
|
2356
|
-
"isSigner": false
|
|
2357
|
-
}
|
|
2358
|
-
],
|
|
2359
|
-
"args": [
|
|
2360
|
-
{
|
|
2361
|
-
"name": "newLockReleasePoint",
|
|
2362
|
-
"type": "u64"
|
|
2363
|
-
}
|
|
2364
|
-
]
|
|
2365
|
-
},
|
|
2366
2351
|
{
|
|
2367
2352
|
"name": "removeLiquidityByRange",
|
|
2368
2353
|
"accounts": [
|
|
@@ -2598,7 +2583,7 @@ var IDL = {
|
|
|
2598
2583
|
"args": [
|
|
2599
2584
|
{
|
|
2600
2585
|
"name": "preActivationDuration",
|
|
2601
|
-
"type": "
|
|
2586
|
+
"type": "u64"
|
|
2602
2587
|
}
|
|
2603
2588
|
]
|
|
2604
2589
|
},
|
|
@@ -2909,11 +2894,16 @@ var IDL = {
|
|
|
2909
2894
|
"type": "i64"
|
|
2910
2895
|
},
|
|
2911
2896
|
{
|
|
2912
|
-
"name": "
|
|
2897
|
+
"name": "padding2",
|
|
2913
2898
|
"docs": [
|
|
2914
|
-
"
|
|
2899
|
+
"_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
|
|
2915
2900
|
],
|
|
2916
|
-
"type":
|
|
2901
|
+
"type": {
|
|
2902
|
+
"array": [
|
|
2903
|
+
"u8",
|
|
2904
|
+
32
|
|
2905
|
+
]
|
|
2906
|
+
}
|
|
2917
2907
|
},
|
|
2918
2908
|
{
|
|
2919
2909
|
"name": "preActivationSwapAddress",
|
|
@@ -2944,9 +2934,9 @@ var IDL = {
|
|
|
2944
2934
|
"type": "u64"
|
|
2945
2935
|
},
|
|
2946
2936
|
{
|
|
2947
|
-
"name": "
|
|
2937
|
+
"name": "padding3",
|
|
2948
2938
|
"docs": [
|
|
2949
|
-
"_padding
|
|
2939
|
+
"_padding 3 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
|
|
2950
2940
|
],
|
|
2951
2941
|
"type": {
|
|
2952
2942
|
"array": [
|
|
@@ -2956,9 +2946,9 @@ var IDL = {
|
|
|
2956
2946
|
}
|
|
2957
2947
|
},
|
|
2958
2948
|
{
|
|
2959
|
-
"name": "
|
|
2949
|
+
"name": "padding4",
|
|
2960
2950
|
"docs": [
|
|
2961
|
-
"
|
|
2951
|
+
"_padding_4, previous lock_duration, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
|
|
2962
2952
|
],
|
|
2963
2953
|
"type": "u64"
|
|
2964
2954
|
},
|
|
@@ -3255,9 +3245,9 @@ var IDL = {
|
|
|
3255
3245
|
"type": "u64"
|
|
3256
3246
|
},
|
|
3257
3247
|
{
|
|
3258
|
-
"name": "
|
|
3248
|
+
"name": "padding0",
|
|
3259
3249
|
"docs": [
|
|
3260
|
-
"
|
|
3250
|
+
"_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
|
|
3261
3251
|
],
|
|
3262
3252
|
"type": "u8"
|
|
3263
3253
|
},
|
|
@@ -3364,28 +3354,128 @@ var IDL = {
|
|
|
3364
3354
|
],
|
|
3365
3355
|
"types": [
|
|
3366
3356
|
{
|
|
3367
|
-
"name": "
|
|
3357
|
+
"name": "InitPresetParametersIx",
|
|
3368
3358
|
"type": {
|
|
3369
3359
|
"kind": "struct",
|
|
3370
3360
|
"fields": [
|
|
3371
3361
|
{
|
|
3372
|
-
"name": "
|
|
3362
|
+
"name": "binStep",
|
|
3373
3363
|
"docs": [
|
|
3374
|
-
"
|
|
3364
|
+
"Bin step. Represent the price increment / decrement."
|
|
3375
3365
|
],
|
|
3376
|
-
"type": "
|
|
3366
|
+
"type": "u16"
|
|
3377
3367
|
},
|
|
3378
3368
|
{
|
|
3379
|
-
"name": "
|
|
3369
|
+
"name": "baseFactor",
|
|
3380
3370
|
"docs": [
|
|
3381
|
-
"
|
|
3371
|
+
"Used for base fee calculation. base_fee_rate = base_factor * bin_step"
|
|
3382
3372
|
],
|
|
3383
|
-
"type": "
|
|
3373
|
+
"type": "u16"
|
|
3384
3374
|
},
|
|
3385
3375
|
{
|
|
3386
|
-
"name": "
|
|
3376
|
+
"name": "filterPeriod",
|
|
3387
3377
|
"docs": [
|
|
3388
|
-
"
|
|
3378
|
+
"Filter period determine high frequency trading time window."
|
|
3379
|
+
],
|
|
3380
|
+
"type": "u16"
|
|
3381
|
+
},
|
|
3382
|
+
{
|
|
3383
|
+
"name": "decayPeriod",
|
|
3384
|
+
"docs": [
|
|
3385
|
+
"Decay period determine when the volatile fee start decay / decrease."
|
|
3386
|
+
],
|
|
3387
|
+
"type": "u16"
|
|
3388
|
+
},
|
|
3389
|
+
{
|
|
3390
|
+
"name": "reductionFactor",
|
|
3391
|
+
"docs": [
|
|
3392
|
+
"Reduction factor controls the volatile fee rate decrement rate."
|
|
3393
|
+
],
|
|
3394
|
+
"type": "u16"
|
|
3395
|
+
},
|
|
3396
|
+
{
|
|
3397
|
+
"name": "variableFeeControl",
|
|
3398
|
+
"docs": [
|
|
3399
|
+
"Used to scale the variable fee component depending on the dynamic of the market"
|
|
3400
|
+
],
|
|
3401
|
+
"type": "u32"
|
|
3402
|
+
},
|
|
3403
|
+
{
|
|
3404
|
+
"name": "maxVolatilityAccumulator",
|
|
3405
|
+
"docs": [
|
|
3406
|
+
"Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate."
|
|
3407
|
+
],
|
|
3408
|
+
"type": "u32"
|
|
3409
|
+
},
|
|
3410
|
+
{
|
|
3411
|
+
"name": "minBinId",
|
|
3412
|
+
"docs": [
|
|
3413
|
+
"Min bin id supported by the pool based on the configured bin step."
|
|
3414
|
+
],
|
|
3415
|
+
"type": "i32"
|
|
3416
|
+
},
|
|
3417
|
+
{
|
|
3418
|
+
"name": "maxBinId",
|
|
3419
|
+
"docs": [
|
|
3420
|
+
"Max bin id supported by the pool based on the configured bin step."
|
|
3421
|
+
],
|
|
3422
|
+
"type": "i32"
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
"name": "protocolShare",
|
|
3426
|
+
"docs": [
|
|
3427
|
+
"Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee"
|
|
3428
|
+
],
|
|
3429
|
+
"type": "u16"
|
|
3430
|
+
}
|
|
3431
|
+
]
|
|
3432
|
+
}
|
|
3433
|
+
},
|
|
3434
|
+
{
|
|
3435
|
+
"name": "FeeParameter",
|
|
3436
|
+
"type": {
|
|
3437
|
+
"kind": "struct",
|
|
3438
|
+
"fields": [
|
|
3439
|
+
{
|
|
3440
|
+
"name": "protocolShare",
|
|
3441
|
+
"docs": [
|
|
3442
|
+
"Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee"
|
|
3443
|
+
],
|
|
3444
|
+
"type": "u16"
|
|
3445
|
+
},
|
|
3446
|
+
{
|
|
3447
|
+
"name": "baseFactor",
|
|
3448
|
+
"docs": [
|
|
3449
|
+
"Base factor for base fee rate"
|
|
3450
|
+
],
|
|
3451
|
+
"type": "u16"
|
|
3452
|
+
}
|
|
3453
|
+
]
|
|
3454
|
+
}
|
|
3455
|
+
},
|
|
3456
|
+
{
|
|
3457
|
+
"name": "LiquidityParameterByStrategyOneSide",
|
|
3458
|
+
"type": {
|
|
3459
|
+
"kind": "struct",
|
|
3460
|
+
"fields": [
|
|
3461
|
+
{
|
|
3462
|
+
"name": "amount",
|
|
3463
|
+
"docs": [
|
|
3464
|
+
"Amount of X token or Y token to deposit"
|
|
3465
|
+
],
|
|
3466
|
+
"type": "u64"
|
|
3467
|
+
},
|
|
3468
|
+
{
|
|
3469
|
+
"name": "activeId",
|
|
3470
|
+
"docs": [
|
|
3471
|
+
"Active bin that integrator observe off-chain"
|
|
3472
|
+
],
|
|
3473
|
+
"type": "i32"
|
|
3474
|
+
},
|
|
3475
|
+
{
|
|
3476
|
+
"name": "maxActiveBinSlippage",
|
|
3477
|
+
"docs": [
|
|
3478
|
+
"max active bin slippage allowed"
|
|
3389
3479
|
],
|
|
3390
3480
|
"type": "i32"
|
|
3391
3481
|
},
|
|
@@ -3697,137 +3787,97 @@ var IDL = {
|
|
|
3697
3787
|
}
|
|
3698
3788
|
},
|
|
3699
3789
|
{
|
|
3700
|
-
"name": "
|
|
3790
|
+
"name": "CustomizableParams",
|
|
3701
3791
|
"type": {
|
|
3702
3792
|
"kind": "struct",
|
|
3703
3793
|
"fields": [
|
|
3704
3794
|
{
|
|
3705
3795
|
"name": "activeId",
|
|
3796
|
+
"docs": [
|
|
3797
|
+
"Pool price"
|
|
3798
|
+
],
|
|
3706
3799
|
"type": "i32"
|
|
3707
3800
|
},
|
|
3708
|
-
{
|
|
3709
|
-
"name": "binStep",
|
|
3710
|
-
"type": "u16"
|
|
3711
|
-
},
|
|
3712
|
-
{
|
|
3713
|
-
"name": "baseFactor",
|
|
3714
|
-
"type": "u16"
|
|
3715
|
-
},
|
|
3716
|
-
{
|
|
3717
|
-
"name": "minBinId",
|
|
3718
|
-
"type": "i32"
|
|
3719
|
-
},
|
|
3720
|
-
{
|
|
3721
|
-
"name": "maxBinId",
|
|
3722
|
-
"type": "i32"
|
|
3723
|
-
},
|
|
3724
|
-
{
|
|
3725
|
-
"name": "lockDuration",
|
|
3726
|
-
"type": "u64"
|
|
3727
|
-
},
|
|
3728
|
-
{
|
|
3729
|
-
"name": "activationType",
|
|
3730
|
-
"type": "u8"
|
|
3731
|
-
}
|
|
3732
|
-
]
|
|
3733
|
-
}
|
|
3734
|
-
},
|
|
3735
|
-
{
|
|
3736
|
-
"name": "InitPresetParametersIx",
|
|
3737
|
-
"type": {
|
|
3738
|
-
"kind": "struct",
|
|
3739
|
-
"fields": [
|
|
3740
3801
|
{
|
|
3741
3802
|
"name": "binStep",
|
|
3742
3803
|
"docs": [
|
|
3743
|
-
"Bin step
|
|
3804
|
+
"Bin step"
|
|
3744
3805
|
],
|
|
3745
3806
|
"type": "u16"
|
|
3746
3807
|
},
|
|
3747
3808
|
{
|
|
3748
3809
|
"name": "baseFactor",
|
|
3749
3810
|
"docs": [
|
|
3750
|
-
"
|
|
3751
|
-
],
|
|
3752
|
-
"type": "u16"
|
|
3753
|
-
},
|
|
3754
|
-
{
|
|
3755
|
-
"name": "filterPeriod",
|
|
3756
|
-
"docs": [
|
|
3757
|
-
"Filter period determine high frequency trading time window."
|
|
3758
|
-
],
|
|
3759
|
-
"type": "u16"
|
|
3760
|
-
},
|
|
3761
|
-
{
|
|
3762
|
-
"name": "decayPeriod",
|
|
3763
|
-
"docs": [
|
|
3764
|
-
"Decay period determine when the volatile fee start decay / decrease."
|
|
3765
|
-
],
|
|
3766
|
-
"type": "u16"
|
|
3767
|
-
},
|
|
3768
|
-
{
|
|
3769
|
-
"name": "reductionFactor",
|
|
3770
|
-
"docs": [
|
|
3771
|
-
"Reduction factor controls the volatile fee rate decrement rate."
|
|
3811
|
+
"Base factor"
|
|
3772
3812
|
],
|
|
3773
3813
|
"type": "u16"
|
|
3774
3814
|
},
|
|
3775
3815
|
{
|
|
3776
|
-
"name": "
|
|
3777
|
-
"docs": [
|
|
3778
|
-
"Used to scale the variable fee component depending on the dynamic of the market"
|
|
3779
|
-
],
|
|
3780
|
-
"type": "u32"
|
|
3781
|
-
},
|
|
3782
|
-
{
|
|
3783
|
-
"name": "maxVolatilityAccumulator",
|
|
3816
|
+
"name": "activationType",
|
|
3784
3817
|
"docs": [
|
|
3785
|
-
"
|
|
3818
|
+
"Activation type. 0 = Slot, 1 = Time. Check ActivationType enum"
|
|
3786
3819
|
],
|
|
3787
|
-
"type": "
|
|
3820
|
+
"type": "u8"
|
|
3788
3821
|
},
|
|
3789
3822
|
{
|
|
3790
|
-
"name": "
|
|
3823
|
+
"name": "hasAlphaVault",
|
|
3791
3824
|
"docs": [
|
|
3792
|
-
"
|
|
3825
|
+
"Whether the pool has an alpha vault"
|
|
3793
3826
|
],
|
|
3794
|
-
"type": "
|
|
3827
|
+
"type": "bool"
|
|
3795
3828
|
},
|
|
3796
3829
|
{
|
|
3797
|
-
"name": "
|
|
3830
|
+
"name": "activationPoint",
|
|
3798
3831
|
"docs": [
|
|
3799
|
-
"
|
|
3832
|
+
"Decide when does the pool start trade. None = Now"
|
|
3800
3833
|
],
|
|
3801
|
-
"type":
|
|
3834
|
+
"type": {
|
|
3835
|
+
"option": "u64"
|
|
3836
|
+
}
|
|
3802
3837
|
},
|
|
3803
3838
|
{
|
|
3804
|
-
"name": "
|
|
3839
|
+
"name": "padding",
|
|
3805
3840
|
"docs": [
|
|
3806
|
-
"
|
|
3841
|
+
"Padding, for future use"
|
|
3807
3842
|
],
|
|
3808
|
-
"type":
|
|
3843
|
+
"type": {
|
|
3844
|
+
"array": [
|
|
3845
|
+
"u8",
|
|
3846
|
+
64
|
|
3847
|
+
]
|
|
3848
|
+
}
|
|
3809
3849
|
}
|
|
3810
3850
|
]
|
|
3811
3851
|
}
|
|
3812
3852
|
},
|
|
3813
3853
|
{
|
|
3814
|
-
"name": "
|
|
3854
|
+
"name": "InitPermissionPairIx",
|
|
3815
3855
|
"type": {
|
|
3816
3856
|
"kind": "struct",
|
|
3817
3857
|
"fields": [
|
|
3818
3858
|
{
|
|
3819
|
-
"name": "
|
|
3820
|
-
"
|
|
3821
|
-
|
|
3822
|
-
|
|
3859
|
+
"name": "activeId",
|
|
3860
|
+
"type": "i32"
|
|
3861
|
+
},
|
|
3862
|
+
{
|
|
3863
|
+
"name": "binStep",
|
|
3823
3864
|
"type": "u16"
|
|
3824
3865
|
},
|
|
3825
3866
|
{
|
|
3826
3867
|
"name": "baseFactor",
|
|
3827
|
-
"docs": [
|
|
3828
|
-
"Base factor for base fee rate"
|
|
3829
|
-
],
|
|
3830
3868
|
"type": "u16"
|
|
3869
|
+
},
|
|
3870
|
+
{
|
|
3871
|
+
"name": "minBinId",
|
|
3872
|
+
"type": "i32"
|
|
3873
|
+
},
|
|
3874
|
+
{
|
|
3875
|
+
"name": "maxBinId",
|
|
3876
|
+
"type": "i32"
|
|
3877
|
+
},
|
|
3878
|
+
{
|
|
3879
|
+
"name": "activationType",
|
|
3880
|
+
"type": "u8"
|
|
3831
3881
|
}
|
|
3832
3882
|
]
|
|
3833
3883
|
}
|
|
@@ -4286,35 +4336,35 @@ var IDL = {
|
|
|
4286
4336
|
}
|
|
4287
4337
|
},
|
|
4288
4338
|
{
|
|
4289
|
-
"name": "
|
|
4339
|
+
"name": "ActivationType",
|
|
4290
4340
|
"docs": [
|
|
4291
|
-
"
|
|
4341
|
+
"Type of the activation"
|
|
4292
4342
|
],
|
|
4293
4343
|
"type": {
|
|
4294
4344
|
"kind": "enum",
|
|
4295
4345
|
"variants": [
|
|
4296
4346
|
{
|
|
4297
|
-
"name": "
|
|
4347
|
+
"name": "Slot"
|
|
4298
4348
|
},
|
|
4299
4349
|
{
|
|
4300
|
-
"name": "
|
|
4350
|
+
"name": "Timestamp"
|
|
4301
4351
|
}
|
|
4302
4352
|
]
|
|
4303
4353
|
}
|
|
4304
4354
|
},
|
|
4305
4355
|
{
|
|
4306
|
-
"name": "
|
|
4356
|
+
"name": "LayoutVersion",
|
|
4307
4357
|
"docs": [
|
|
4308
|
-
"
|
|
4358
|
+
"Layout version"
|
|
4309
4359
|
],
|
|
4310
4360
|
"type": {
|
|
4311
4361
|
"kind": "enum",
|
|
4312
4362
|
"variants": [
|
|
4313
4363
|
{
|
|
4314
|
-
"name": "
|
|
4364
|
+
"name": "V0"
|
|
4315
4365
|
},
|
|
4316
4366
|
{
|
|
4317
|
-
"name": "
|
|
4367
|
+
"name": "V1"
|
|
4318
4368
|
}
|
|
4319
4369
|
]
|
|
4320
4370
|
}
|
|
@@ -4322,7 +4372,7 @@ var IDL = {
|
|
|
4322
4372
|
{
|
|
4323
4373
|
"name": "PairType",
|
|
4324
4374
|
"docs": [
|
|
4325
|
-
"Type of the Pair. 0 = Permissionless, 1 = Permission. Putting 0 as permissionless for backward compatibility."
|
|
4375
|
+
"Type of the Pair. 0 = Permissionless, 1 = Permission, 2 = CustomizablePermissionless. Putting 0 as permissionless for backward compatibility."
|
|
4326
4376
|
],
|
|
4327
4377
|
"type": {
|
|
4328
4378
|
"kind": "enum",
|
|
@@ -4332,6 +4382,9 @@ var IDL = {
|
|
|
4332
4382
|
},
|
|
4333
4383
|
{
|
|
4334
4384
|
"name": "Permission"
|
|
4385
|
+
},
|
|
4386
|
+
{
|
|
4387
|
+
"name": "CustomizablePermissionless"
|
|
4335
4388
|
}
|
|
4336
4389
|
]
|
|
4337
4390
|
}
|
|
@@ -5166,6 +5219,41 @@ var IDL = {
|
|
|
5166
5219
|
"code": 6058,
|
|
5167
5220
|
"name": "InvalidActivationType",
|
|
5168
5221
|
"msg": "Invalid activation type"
|
|
5222
|
+
},
|
|
5223
|
+
{
|
|
5224
|
+
"code": 6059,
|
|
5225
|
+
"name": "InvalidActivationDuration",
|
|
5226
|
+
"msg": "Invalid activation duration"
|
|
5227
|
+
},
|
|
5228
|
+
{
|
|
5229
|
+
"code": 6060,
|
|
5230
|
+
"name": "MissingTokenAmountAsTokenLaunchProof",
|
|
5231
|
+
"msg": "Missing token amount as token launch owner proof"
|
|
5232
|
+
},
|
|
5233
|
+
{
|
|
5234
|
+
"code": 6061,
|
|
5235
|
+
"name": "InvalidQuoteToken",
|
|
5236
|
+
"msg": "Quote token must be SOL or USDC"
|
|
5237
|
+
},
|
|
5238
|
+
{
|
|
5239
|
+
"code": 6062,
|
|
5240
|
+
"name": "InvalidBinStep",
|
|
5241
|
+
"msg": "Invalid bin step"
|
|
5242
|
+
},
|
|
5243
|
+
{
|
|
5244
|
+
"code": 6063,
|
|
5245
|
+
"name": "InvalidBaseFee",
|
|
5246
|
+
"msg": "Invalid base fee"
|
|
5247
|
+
},
|
|
5248
|
+
{
|
|
5249
|
+
"code": 6064,
|
|
5250
|
+
"name": "InvalidPreActivationDuration",
|
|
5251
|
+
"msg": "Invalid pre-activation duration"
|
|
5252
|
+
},
|
|
5253
|
+
{
|
|
5254
|
+
"code": 6065,
|
|
5255
|
+
"name": "AlreadyPassPreActivationSwapPoint",
|
|
5256
|
+
"msg": "Already pass pre-activation swap point"
|
|
5169
5257
|
}
|
|
5170
5258
|
]
|
|
5171
5259
|
};
|
|
@@ -5217,6 +5305,9 @@ var MAX_CLAIM_ALL_ALLOWED = 3;
|
|
|
5217
5305
|
var MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = 26;
|
|
5218
5306
|
var MAX_BIN_PER_TX = 69;
|
|
5219
5307
|
var MAX_ACTIVE_BIN_SLIPPAGE = 3;
|
|
5308
|
+
var ILM_BASE = new PublicKey(
|
|
5309
|
+
"MFGQxwAmB91SwuYX36okv2Qmdc9aMuHTwWGUrp4AtB1"
|
|
5310
|
+
);
|
|
5220
5311
|
|
|
5221
5312
|
// src/dlmm/types/index.ts
|
|
5222
5313
|
import { u64, i64, struct } from "@coral-xyz/borsh";
|
|
@@ -6301,6 +6392,13 @@ function deriveLbPair(tokenX, tokenY, binStep, programId) {
|
|
|
6301
6392
|
programId
|
|
6302
6393
|
);
|
|
6303
6394
|
}
|
|
6395
|
+
function deriveCustomizablePermissionlessLbPair(tokenX, tokenY, programId) {
|
|
6396
|
+
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
6397
|
+
return PublicKey2.findProgramAddressSync(
|
|
6398
|
+
[ILM_BASE.toBuffer(), minKey.toBuffer(), maxKey.toBuffer()],
|
|
6399
|
+
programId
|
|
6400
|
+
);
|
|
6401
|
+
}
|
|
6304
6402
|
function derivePermissionLbPair(baseKey, tokenX, tokenY, binStep, programId) {
|
|
6305
6403
|
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
6306
6404
|
return PublicKey2.findProgramAddressSync(
|
|
@@ -7877,49 +7975,14 @@ var DLMM = class {
|
|
|
7877
7975
|
opt?.programId ?? LBCLMM_PROGRAM_IDS[cluster],
|
|
7878
7976
|
provider
|
|
7879
7977
|
);
|
|
7880
|
-
const
|
|
7881
|
-
|
|
7882
|
-
{
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
offset: 8 + 32
|
|
7886
|
-
}
|
|
7887
|
-
}
|
|
7888
|
-
]),
|
|
7889
|
-
program.account.positionV2.all([
|
|
7890
|
-
{
|
|
7891
|
-
memcmp: {
|
|
7892
|
-
bytes: bs58.encode(userPubKey.toBuffer()),
|
|
7893
|
-
offset: 8 + 32
|
|
7894
|
-
}
|
|
7978
|
+
const positionsV2 = await program.account.positionV2.all([
|
|
7979
|
+
{
|
|
7980
|
+
memcmp: {
|
|
7981
|
+
bytes: bs58.encode(userPubKey.toBuffer()),
|
|
7982
|
+
offset: 8 + 32
|
|
7895
7983
|
}
|
|
7896
|
-
|
|
7984
|
+
}
|
|
7897
7985
|
]);
|
|
7898
|
-
const binArrayPubkeySet = /* @__PURE__ */ new Set();
|
|
7899
|
-
const lbPairSet = /* @__PURE__ */ new Set();
|
|
7900
|
-
positions.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
7901
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
7902
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new BN9(upperBinId));
|
|
7903
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
7904
|
-
lbPair,
|
|
7905
|
-
lowerBinArrayIndex,
|
|
7906
|
-
program.programId
|
|
7907
|
-
);
|
|
7908
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
7909
|
-
lbPair,
|
|
7910
|
-
upperBinArrayIndex,
|
|
7911
|
-
program.programId
|
|
7912
|
-
);
|
|
7913
|
-
binArrayPubkeySet.add(lowerBinArrayPubKey.toBase58());
|
|
7914
|
-
binArrayPubkeySet.add(upperBinArrayPubKey.toBase58());
|
|
7915
|
-
lbPairSet.add(lbPair.toBase58());
|
|
7916
|
-
});
|
|
7917
|
-
const binArrayPubkeyArray = Array.from(binArrayPubkeySet).map(
|
|
7918
|
-
(pubkey) => new PublicKey6(pubkey)
|
|
7919
|
-
);
|
|
7920
|
-
const lbPairArray = Array.from(lbPairSet).map(
|
|
7921
|
-
(pubkey) => new PublicKey6(pubkey)
|
|
7922
|
-
);
|
|
7923
7986
|
const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
|
|
7924
7987
|
const lbPairSetV2 = /* @__PURE__ */ new Set();
|
|
7925
7988
|
positionsV2.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
@@ -7947,46 +8010,12 @@ var DLMM = class {
|
|
|
7947
8010
|
);
|
|
7948
8011
|
const [clockAccInfo, ...binArraysAccInfo] = await chunkedGetMultipleAccountInfos(connection, [
|
|
7949
8012
|
SYSVAR_CLOCK_PUBKEY,
|
|
7950
|
-
...binArrayPubkeyArray,
|
|
7951
|
-
...lbPairArray,
|
|
7952
8013
|
...binArrayPubkeyArrayV2,
|
|
7953
8014
|
...lbPairArrayV2
|
|
7954
8015
|
]);
|
|
7955
|
-
const positionBinArraysMap = /* @__PURE__ */ new Map();
|
|
7956
|
-
for (let i = 0; i < binArrayPubkeyArray.length; i++) {
|
|
7957
|
-
const binArrayPubkey = binArrayPubkeyArray[i];
|
|
7958
|
-
const binArrayAccInfoBuffer = binArraysAccInfo[i];
|
|
7959
|
-
if (!binArrayAccInfoBuffer)
|
|
7960
|
-
throw new Error(
|
|
7961
|
-
`Bin Array account ${binArrayPubkey.toBase58()} not found`
|
|
7962
|
-
);
|
|
7963
|
-
const binArrayAccInfo = program.coder.accounts.decode(
|
|
7964
|
-
"binArray",
|
|
7965
|
-
binArrayAccInfoBuffer.data
|
|
7966
|
-
);
|
|
7967
|
-
positionBinArraysMap.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
7968
|
-
}
|
|
7969
|
-
const lbPairArraysMap = /* @__PURE__ */ new Map();
|
|
7970
|
-
for (let i = binArrayPubkeyArray.length; i < binArrayPubkeyArray.length + lbPairArray.length; i++) {
|
|
7971
|
-
const lbPairPubkey = lbPairArray[i - binArrayPubkeyArray.length];
|
|
7972
|
-
const lbPairAccInfoBuffer = binArraysAccInfo[i];
|
|
7973
|
-
if (!lbPairAccInfoBuffer)
|
|
7974
|
-
throw new Error(`LB Pair account ${lbPairPubkey.toBase58()} not found`);
|
|
7975
|
-
const lbPairAccInfo = program.coder.accounts.decode(
|
|
7976
|
-
"lbPair",
|
|
7977
|
-
lbPairAccInfoBuffer.data
|
|
7978
|
-
);
|
|
7979
|
-
lbPairArraysMap.set(lbPairPubkey.toBase58(), lbPairAccInfo);
|
|
7980
|
-
}
|
|
7981
|
-
const reservePublicKeys = Array.from(lbPairArraysMap.values()).map(({ reserveX, reserveY, tokenXMint, tokenYMint }) => [
|
|
7982
|
-
reserveX,
|
|
7983
|
-
reserveY,
|
|
7984
|
-
tokenXMint,
|
|
7985
|
-
tokenYMint
|
|
7986
|
-
]).flat();
|
|
7987
8016
|
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
7988
|
-
for (let i =
|
|
7989
|
-
const binArrayPubkey = binArrayPubkeyArrayV2[i
|
|
8017
|
+
for (let i = 0; i < binArrayPubkeyArrayV2.length; i++) {
|
|
8018
|
+
const binArrayPubkey = binArrayPubkeyArrayV2[i];
|
|
7990
8019
|
const binArrayAccInfoBufferV2 = binArraysAccInfo[i];
|
|
7991
8020
|
if (!binArrayAccInfoBufferV2)
|
|
7992
8021
|
throw new Error(
|
|
@@ -7999,8 +8028,8 @@ var DLMM = class {
|
|
|
7999
8028
|
positionBinArraysMapV2.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8000
8029
|
}
|
|
8001
8030
|
const lbPairArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8002
|
-
for (let i =
|
|
8003
|
-
const lbPairPubkey = lbPairArrayV2[i -
|
|
8031
|
+
for (let i = binArrayPubkeyArrayV2.length; i < binArraysAccInfo.length; i++) {
|
|
8032
|
+
const lbPairPubkey = lbPairArrayV2[i - binArrayPubkeyArrayV2.length];
|
|
8004
8033
|
const lbPairAccInfoBufferV2 = binArraysAccInfo[i];
|
|
8005
8034
|
if (!lbPairAccInfoBufferV2)
|
|
8006
8035
|
throw new Error(`LB Pair account ${lbPairPubkey.toBase58()} not found`);
|
|
@@ -8018,43 +8047,14 @@ var DLMM = class {
|
|
|
8018
8047
|
]).flat();
|
|
8019
8048
|
const reserveAccountsInfo = await chunkedGetMultipleAccountInfos(
|
|
8020
8049
|
program.provider.connection,
|
|
8021
|
-
|
|
8050
|
+
reservePublicKeysV2
|
|
8022
8051
|
);
|
|
8023
|
-
const lbPairReserveMap = /* @__PURE__ */ new Map();
|
|
8024
|
-
const lbPairMintMap = /* @__PURE__ */ new Map();
|
|
8025
|
-
lbPairArray.forEach((lbPair, idx) => {
|
|
8026
|
-
const index = idx * 4;
|
|
8027
|
-
const reserveAccBufferX = reserveAccountsInfo[index];
|
|
8028
|
-
const reserveAccBufferY = reserveAccountsInfo[index + 1];
|
|
8029
|
-
if (!reserveAccBufferX || !reserveAccBufferY)
|
|
8030
|
-
throw new Error(
|
|
8031
|
-
`Reserve account for LB Pair ${lbPair.toBase58()} not found`
|
|
8032
|
-
);
|
|
8033
|
-
const reserveAccX = AccountLayout.decode(reserveAccBufferX.data);
|
|
8034
|
-
const reserveAccY = AccountLayout.decode(reserveAccBufferY.data);
|
|
8035
|
-
lbPairReserveMap.set(lbPair.toBase58(), {
|
|
8036
|
-
reserveX: reserveAccX.amount,
|
|
8037
|
-
reserveY: reserveAccY.amount
|
|
8038
|
-
});
|
|
8039
|
-
const mintXBuffer = reserveAccountsInfo[index + 2];
|
|
8040
|
-
const mintYBuffer = reserveAccountsInfo[index + 3];
|
|
8041
|
-
if (!mintXBuffer || !mintYBuffer)
|
|
8042
|
-
throw new Error(
|
|
8043
|
-
`Mint account for LB Pair ${lbPair.toBase58()} not found`
|
|
8044
|
-
);
|
|
8045
|
-
const mintX = MintLayout.decode(mintXBuffer.data);
|
|
8046
|
-
const mintY = MintLayout.decode(mintYBuffer.data);
|
|
8047
|
-
lbPairMintMap.set(lbPair.toBase58(), {
|
|
8048
|
-
mintXDecimal: mintX.decimals,
|
|
8049
|
-
mintYDecimal: mintY.decimals
|
|
8050
|
-
});
|
|
8051
|
-
});
|
|
8052
8052
|
const lbPairReserveMapV2 = /* @__PURE__ */ new Map();
|
|
8053
8053
|
const lbPairMintMapV2 = /* @__PURE__ */ new Map();
|
|
8054
8054
|
lbPairArrayV2.forEach((lbPair, idx) => {
|
|
8055
8055
|
const index = idx * 4;
|
|
8056
|
-
const reserveAccBufferXV2 = reserveAccountsInfo[
|
|
8057
|
-
const reserveAccBufferYV2 = reserveAccountsInfo[
|
|
8056
|
+
const reserveAccBufferXV2 = reserveAccountsInfo[index];
|
|
8057
|
+
const reserveAccBufferYV2 = reserveAccountsInfo[index + 1];
|
|
8058
8058
|
if (!reserveAccBufferXV2 || !reserveAccBufferYV2)
|
|
8059
8059
|
throw new Error(
|
|
8060
8060
|
`Reserve account for LB Pair ${lbPair.toBase58()} not found`
|
|
@@ -8065,8 +8065,8 @@ var DLMM = class {
|
|
|
8065
8065
|
reserveX: reserveAccX.amount,
|
|
8066
8066
|
reserveY: reserveAccY.amount
|
|
8067
8067
|
});
|
|
8068
|
-
const mintXBufferV2 = reserveAccountsInfo[
|
|
8069
|
-
const mintYBufferV2 = reserveAccountsInfo[
|
|
8068
|
+
const mintXBufferV2 = reserveAccountsInfo[index + 2];
|
|
8069
|
+
const mintYBufferV2 = reserveAccountsInfo[index + 3];
|
|
8070
8070
|
if (!mintXBufferV2 || !mintYBufferV2)
|
|
8071
8071
|
throw new Error(
|
|
8072
8072
|
`Mint account for LB Pair ${lbPair.toBase58()} not found`
|
|
@@ -8082,74 +8082,6 @@ var DLMM = class {
|
|
|
8082
8082
|
clockAccInfo.data.readBigInt64LE(32).toString()
|
|
8083
8083
|
).toNumber();
|
|
8084
8084
|
const positionsMap = /* @__PURE__ */ new Map();
|
|
8085
|
-
for (let position of positions) {
|
|
8086
|
-
const { account, publicKey: positionPubKey } = position;
|
|
8087
|
-
const { upperBinId, lowerBinId, lbPair } = account;
|
|
8088
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
8089
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new BN9(upperBinId));
|
|
8090
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8091
|
-
lbPair,
|
|
8092
|
-
lowerBinArrayIndex,
|
|
8093
|
-
program.programId
|
|
8094
|
-
);
|
|
8095
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8096
|
-
lbPair,
|
|
8097
|
-
upperBinArrayIndex,
|
|
8098
|
-
program.programId
|
|
8099
|
-
);
|
|
8100
|
-
const lowerBinArray = positionBinArraysMap.get(
|
|
8101
|
-
lowerBinArrayPubKey.toBase58()
|
|
8102
|
-
);
|
|
8103
|
-
const upperBinArray = positionBinArraysMap.get(
|
|
8104
|
-
upperBinArrayPubKey.toBase58()
|
|
8105
|
-
);
|
|
8106
|
-
const lbPairAcc = lbPairArraysMap.get(lbPair.toBase58());
|
|
8107
|
-
const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
|
|
8108
|
-
lbPair.toBase58()
|
|
8109
|
-
);
|
|
8110
|
-
const reserveXBalance = lbPairReserveMap.get(lbPair.toBase58())?.reserveX ?? BigInt(0);
|
|
8111
|
-
const reserveYBalance = lbPairReserveMap.get(lbPair.toBase58())?.reserveY ?? BigInt(0);
|
|
8112
|
-
const tokenX = {
|
|
8113
|
-
publicKey: lbPairAcc.tokenXMint,
|
|
8114
|
-
reserve: lbPairAcc.reserveX,
|
|
8115
|
-
amount: reserveXBalance,
|
|
8116
|
-
decimal: mintXDecimal
|
|
8117
|
-
};
|
|
8118
|
-
const tokenY = {
|
|
8119
|
-
publicKey: lbPairAcc.tokenYMint,
|
|
8120
|
-
reserve: lbPairAcc.reserveY,
|
|
8121
|
-
amount: reserveYBalance,
|
|
8122
|
-
decimal: mintYDecimal
|
|
8123
|
-
};
|
|
8124
|
-
const positionData = await DLMM.processPosition(
|
|
8125
|
-
program,
|
|
8126
|
-
0 /* V1 */,
|
|
8127
|
-
lbPairAcc,
|
|
8128
|
-
onChainTimestamp,
|
|
8129
|
-
account,
|
|
8130
|
-
mintXDecimal,
|
|
8131
|
-
mintYDecimal,
|
|
8132
|
-
lowerBinArray,
|
|
8133
|
-
upperBinArray,
|
|
8134
|
-
PublicKey6.default
|
|
8135
|
-
);
|
|
8136
|
-
if (positionData) {
|
|
8137
|
-
positionsMap.set(lbPair.toBase58(), {
|
|
8138
|
-
publicKey: lbPair,
|
|
8139
|
-
lbPair: lbPairAcc,
|
|
8140
|
-
tokenX,
|
|
8141
|
-
tokenY,
|
|
8142
|
-
lbPairPositionsData: [
|
|
8143
|
-
...positionsMap.get(lbPair.toBase58())?.lbPairPositionsData ?? [],
|
|
8144
|
-
{
|
|
8145
|
-
publicKey: positionPubKey,
|
|
8146
|
-
positionData,
|
|
8147
|
-
version: 0 /* V1 */
|
|
8148
|
-
}
|
|
8149
|
-
]
|
|
8150
|
-
});
|
|
8151
|
-
}
|
|
8152
|
-
}
|
|
8153
8085
|
for (let position of positionsV2) {
|
|
8154
8086
|
const { account, publicKey: positionPubKey } = position;
|
|
8155
8087
|
const { upperBinId, lowerBinId, lbPair, feeOwner } = account;
|
|
@@ -8221,56 +8153,6 @@ var DLMM = class {
|
|
|
8221
8153
|
}
|
|
8222
8154
|
return positionsMap;
|
|
8223
8155
|
}
|
|
8224
|
-
static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
|
|
8225
|
-
const cluster = opt?.cluster || "mainnet-beta";
|
|
8226
|
-
const provider = new AnchorProvider2(
|
|
8227
|
-
connection,
|
|
8228
|
-
{},
|
|
8229
|
-
AnchorProvider2.defaultOptions()
|
|
8230
|
-
);
|
|
8231
|
-
const program = new Program2(
|
|
8232
|
-
IDL,
|
|
8233
|
-
opt?.programId ?? LBCLMM_PROGRAM_IDS[cluster],
|
|
8234
|
-
provider
|
|
8235
|
-
);
|
|
8236
|
-
const positionsState = await program.account.position.fetchMultiple(
|
|
8237
|
-
positions
|
|
8238
|
-
);
|
|
8239
|
-
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
8240
|
-
return Promise.all(
|
|
8241
|
-
positionsState.map(async ({ lbPair, lowerBinId }, idx) => {
|
|
8242
|
-
const position = positions[idx];
|
|
8243
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
8244
|
-
const upperBinArrayIndex = lowerBinArrayIndex.add(new BN9(1));
|
|
8245
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8246
|
-
lbPair,
|
|
8247
|
-
lowerBinArrayIndex,
|
|
8248
|
-
program.programId
|
|
8249
|
-
);
|
|
8250
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8251
|
-
lbPair,
|
|
8252
|
-
upperBinArrayIndex,
|
|
8253
|
-
program.programId
|
|
8254
|
-
);
|
|
8255
|
-
const migrateTx = await program.methods.migratePosition().accounts({
|
|
8256
|
-
binArrayLower: lowerBinArrayPubKey,
|
|
8257
|
-
binArrayUpper: upperBinArrayPubKey,
|
|
8258
|
-
lbPair,
|
|
8259
|
-
owner: walletPubkey,
|
|
8260
|
-
positionV1: position,
|
|
8261
|
-
positionV2: newPositions[idx],
|
|
8262
|
-
program: program.programId,
|
|
8263
|
-
rentReceiver: walletPubkey,
|
|
8264
|
-
systemProgram: SystemProgram2.programId
|
|
8265
|
-
}).transaction();
|
|
8266
|
-
return new Transaction({
|
|
8267
|
-
blockhash,
|
|
8268
|
-
lastValidBlockHeight,
|
|
8269
|
-
feePayer: walletPubkey
|
|
8270
|
-
}).add(migrateTx);
|
|
8271
|
-
})
|
|
8272
|
-
);
|
|
8273
|
-
}
|
|
8274
8156
|
static getPricePerLamport(tokenXDecimal, tokenYDecimal, price) {
|
|
8275
8157
|
return new Decimal4(price).mul(new Decimal4(10 ** (tokenYDecimal - tokenXDecimal))).toString();
|
|
8276
8158
|
}
|
|
@@ -8280,7 +8162,7 @@ var DLMM = class {
|
|
|
8280
8162
|
return (min ? binId.floor() : binId.ceil()).toNumber();
|
|
8281
8163
|
}
|
|
8282
8164
|
/** Public methods */
|
|
8283
|
-
static async createPermissionLbPair(connection, binStep, tokenX, tokenY, activeId, baseKey, creatorKey, feeBps,
|
|
8165
|
+
static async createPermissionLbPair(connection, binStep, tokenX, tokenY, activeId, baseKey, creatorKey, feeBps, activationType, opt) {
|
|
8284
8166
|
const provider = new AnchorProvider2(
|
|
8285
8167
|
connection,
|
|
8286
8168
|
{},
|
|
@@ -8312,7 +8194,6 @@ var DLMM = class {
|
|
|
8312
8194
|
baseFactor: computeBaseFactorFromFeeBps(binStep, feeBps).toNumber(),
|
|
8313
8195
|
minBinId: minBinId.toNumber(),
|
|
8314
8196
|
maxBinId: maxBinId.toNumber(),
|
|
8315
|
-
lockDuration,
|
|
8316
8197
|
activationType
|
|
8317
8198
|
};
|
|
8318
8199
|
return program.methods.initializePermissionLbPair(ixData).accounts({
|
|
@@ -8330,6 +8211,54 @@ var DLMM = class {
|
|
|
8330
8211
|
base: baseKey
|
|
8331
8212
|
}).transaction();
|
|
8332
8213
|
}
|
|
8214
|
+
static async createCustomizablePermissionlessLbPair(connection, binStep, tokenX, tokenY, activeId, feeBps, activationType, hasAlphaVault, creatorKey, activationPoint, opt) {
|
|
8215
|
+
const provider = new AnchorProvider2(
|
|
8216
|
+
connection,
|
|
8217
|
+
{},
|
|
8218
|
+
AnchorProvider2.defaultOptions()
|
|
8219
|
+
);
|
|
8220
|
+
const program = new Program2(
|
|
8221
|
+
IDL,
|
|
8222
|
+
opt?.programId ?? LBCLMM_PROGRAM_IDS[opt.cluster],
|
|
8223
|
+
provider
|
|
8224
|
+
);
|
|
8225
|
+
const [lbPair] = deriveCustomizablePermissionlessLbPair(
|
|
8226
|
+
tokenX,
|
|
8227
|
+
tokenY,
|
|
8228
|
+
program.programId
|
|
8229
|
+
);
|
|
8230
|
+
const [reserveX] = deriveReserve(tokenX, lbPair, program.programId);
|
|
8231
|
+
const [reserveY] = deriveReserve(tokenY, lbPair, program.programId);
|
|
8232
|
+
const [oracle] = deriveOracle(lbPair, program.programId);
|
|
8233
|
+
const activeBinArrayIndex = binIdToBinArrayIndex(activeId);
|
|
8234
|
+
const binArrayBitmapExtension = isOverflowDefaultBinArrayBitmap(
|
|
8235
|
+
activeBinArrayIndex
|
|
8236
|
+
) ? deriveBinArrayBitmapExtension(lbPair, program.programId)[0] : null;
|
|
8237
|
+
const ixData = {
|
|
8238
|
+
activeId: activeId.toNumber(),
|
|
8239
|
+
binStep: binStep.toNumber(),
|
|
8240
|
+
baseFactor: computeBaseFactorFromFeeBps(binStep, feeBps).toNumber(),
|
|
8241
|
+
activationType,
|
|
8242
|
+
activationPoint: activationPoint ? activationPoint : null,
|
|
8243
|
+
hasAlphaVault,
|
|
8244
|
+
padding: Array(64).fill(0)
|
|
8245
|
+
};
|
|
8246
|
+
const userTokenX = getAssociatedTokenAddressSync2(tokenX, creatorKey);
|
|
8247
|
+
return program.methods.initializeCustomizablePermissionlessLbPair(ixData).accounts({
|
|
8248
|
+
lbPair,
|
|
8249
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
8250
|
+
reserveX,
|
|
8251
|
+
reserveY,
|
|
8252
|
+
binArrayBitmapExtension,
|
|
8253
|
+
tokenMintX: tokenX,
|
|
8254
|
+
tokenMintY: tokenY,
|
|
8255
|
+
tokenProgram: TOKEN_PROGRAM_ID2,
|
|
8256
|
+
oracle,
|
|
8257
|
+
systemProgram: SystemProgram2.programId,
|
|
8258
|
+
userTokenX,
|
|
8259
|
+
funder: creatorKey
|
|
8260
|
+
}).transaction();
|
|
8261
|
+
}
|
|
8333
8262
|
static async createLbPair(connection, funder, tokenX, tokenY, binStep, baseFactor, presetParameter, activeId, opt) {
|
|
8334
8263
|
const provider = new AnchorProvider2(
|
|
8335
8264
|
connection,
|
|
@@ -8715,20 +8644,6 @@ var DLMM = class {
|
|
|
8715
8644
|
async getPositionsByUserAndLbPair(userPubKey) {
|
|
8716
8645
|
const promiseResults = await Promise.all([
|
|
8717
8646
|
this.getActiveBin(),
|
|
8718
|
-
userPubKey && this.program.account.position.all([
|
|
8719
|
-
{
|
|
8720
|
-
memcmp: {
|
|
8721
|
-
bytes: bs58.encode(userPubKey.toBuffer()),
|
|
8722
|
-
offset: 8 + 32
|
|
8723
|
-
}
|
|
8724
|
-
},
|
|
8725
|
-
{
|
|
8726
|
-
memcmp: {
|
|
8727
|
-
bytes: bs58.encode(this.pubkey.toBuffer()),
|
|
8728
|
-
offset: 8
|
|
8729
|
-
}
|
|
8730
|
-
}
|
|
8731
|
-
]),
|
|
8732
8647
|
userPubKey && this.program.account.positionV2.all([
|
|
8733
8648
|
{
|
|
8734
8649
|
memcmp: {
|
|
@@ -8744,7 +8659,7 @@ var DLMM = class {
|
|
|
8744
8659
|
}
|
|
8745
8660
|
])
|
|
8746
8661
|
]);
|
|
8747
|
-
const [activeBin,
|
|
8662
|
+
const [activeBin, positionsV2] = promiseResults;
|
|
8748
8663
|
if (!activeBin) {
|
|
8749
8664
|
throw new Error("Error fetching active bin");
|
|
8750
8665
|
}
|
|
@@ -8754,29 +8669,9 @@ var DLMM = class {
|
|
|
8754
8669
|
userPositions: []
|
|
8755
8670
|
};
|
|
8756
8671
|
}
|
|
8757
|
-
if (!
|
|
8672
|
+
if (!positionsV2) {
|
|
8758
8673
|
throw new Error("Error fetching positions");
|
|
8759
8674
|
}
|
|
8760
|
-
const binArrayPubkeySet = /* @__PURE__ */ new Set();
|
|
8761
|
-
positions.forEach(({ account: { upperBinId, lowerBinId } }) => {
|
|
8762
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
8763
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new BN9(upperBinId));
|
|
8764
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8765
|
-
this.pubkey,
|
|
8766
|
-
lowerBinArrayIndex,
|
|
8767
|
-
this.program.programId
|
|
8768
|
-
);
|
|
8769
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8770
|
-
this.pubkey,
|
|
8771
|
-
upperBinArrayIndex,
|
|
8772
|
-
this.program.programId
|
|
8773
|
-
);
|
|
8774
|
-
binArrayPubkeySet.add(lowerBinArrayPubKey.toBase58());
|
|
8775
|
-
binArrayPubkeySet.add(upperBinArrayPubKey.toBase58());
|
|
8776
|
-
});
|
|
8777
|
-
const binArrayPubkeyArray = Array.from(binArrayPubkeySet).map(
|
|
8778
|
-
(pubkey) => new PublicKey6(pubkey)
|
|
8779
|
-
);
|
|
8780
8675
|
const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
|
|
8781
8676
|
positionsV2.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
8782
8677
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
@@ -8802,28 +8697,13 @@ var DLMM = class {
|
|
|
8802
8697
|
[
|
|
8803
8698
|
this.pubkey,
|
|
8804
8699
|
SYSVAR_CLOCK_PUBKEY,
|
|
8805
|
-
...binArrayPubkeyArray,
|
|
8806
8700
|
...binArrayPubkeyArrayV2
|
|
8807
8701
|
]
|
|
8808
8702
|
);
|
|
8809
8703
|
const [lbPairAccInfo, clockAccInfo, ...binArraysAccInfo] = lbPairAndBinArrays;
|
|
8810
|
-
const positionBinArraysMap = /* @__PURE__ */ new Map();
|
|
8811
|
-
for (let i = 0; i < binArrayPubkeyArray.length; i++) {
|
|
8812
|
-
const binArrayPubkey = binArrayPubkeyArray[i];
|
|
8813
|
-
const binArrayAccBuffer = binArraysAccInfo[i];
|
|
8814
|
-
if (!binArrayAccBuffer)
|
|
8815
|
-
throw new Error(
|
|
8816
|
-
`Bin Array account ${binArrayPubkey.toBase58()} not found`
|
|
8817
|
-
);
|
|
8818
|
-
const binArrayAccInfo = this.program.coder.accounts.decode(
|
|
8819
|
-
"binArray",
|
|
8820
|
-
binArrayAccBuffer.data
|
|
8821
|
-
);
|
|
8822
|
-
positionBinArraysMap.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8823
|
-
}
|
|
8824
8704
|
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8825
|
-
for (let i =
|
|
8826
|
-
const binArrayPubkey = binArrayPubkeyArrayV2[i
|
|
8705
|
+
for (let i = 0; i < binArraysAccInfo.length; i++) {
|
|
8706
|
+
const binArrayPubkey = binArrayPubkeyArrayV2[i];
|
|
8827
8707
|
const binArrayAccBufferV2 = binArraysAccInfo[i];
|
|
8828
8708
|
if (!binArrayAccBufferV2)
|
|
8829
8709
|
throw new Error(
|
|
@@ -8840,45 +8720,6 @@ var DLMM = class {
|
|
|
8840
8720
|
const onChainTimestamp = new BN9(
|
|
8841
8721
|
clockAccInfo.data.readBigInt64LE(32).toString()
|
|
8842
8722
|
).toNumber();
|
|
8843
|
-
const userPositions = await Promise.all(
|
|
8844
|
-
positions.map(async ({ publicKey, account }) => {
|
|
8845
|
-
const { lowerBinId, upperBinId } = account;
|
|
8846
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
8847
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new BN9(upperBinId));
|
|
8848
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8849
|
-
this.pubkey,
|
|
8850
|
-
lowerBinArrayIndex,
|
|
8851
|
-
this.program.programId
|
|
8852
|
-
);
|
|
8853
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8854
|
-
this.pubkey,
|
|
8855
|
-
upperBinArrayIndex,
|
|
8856
|
-
this.program.programId
|
|
8857
|
-
);
|
|
8858
|
-
const lowerBinArray = positionBinArraysMap.get(
|
|
8859
|
-
lowerBinArrayPubKey.toBase58()
|
|
8860
|
-
);
|
|
8861
|
-
const upperBinArray = positionBinArraysMap.get(
|
|
8862
|
-
upperBinArrayPubKey.toBase58()
|
|
8863
|
-
);
|
|
8864
|
-
return {
|
|
8865
|
-
publicKey,
|
|
8866
|
-
positionData: await DLMM.processPosition(
|
|
8867
|
-
this.program,
|
|
8868
|
-
0 /* V1 */,
|
|
8869
|
-
this.lbPair,
|
|
8870
|
-
onChainTimestamp,
|
|
8871
|
-
account,
|
|
8872
|
-
this.tokenX.decimal,
|
|
8873
|
-
this.tokenY.decimal,
|
|
8874
|
-
lowerBinArray,
|
|
8875
|
-
upperBinArray,
|
|
8876
|
-
PublicKey6.default
|
|
8877
|
-
),
|
|
8878
|
-
version: 0 /* V1 */
|
|
8879
|
-
};
|
|
8880
|
-
})
|
|
8881
|
-
);
|
|
8882
8723
|
const userPositionsV2 = await Promise.all(
|
|
8883
8724
|
positionsV2.map(async ({ publicKey, account }) => {
|
|
8884
8725
|
const { lowerBinId, upperBinId, feeOwner } = account;
|
|
@@ -8920,7 +8761,7 @@ var DLMM = class {
|
|
|
8920
8761
|
);
|
|
8921
8762
|
return {
|
|
8922
8763
|
activeBin,
|
|
8923
|
-
userPositions:
|
|
8764
|
+
userPositions: userPositionsV2
|
|
8924
8765
|
};
|
|
8925
8766
|
}
|
|
8926
8767
|
async quoteCreatePosition({ strategy }) {
|
|
@@ -8976,6 +8817,72 @@ var DLMM = class {
|
|
|
8976
8817
|
feePayer: user
|
|
8977
8818
|
}).add(setComputeUnitLimitIx, createPositionIx, ...createBinArrayIxs);
|
|
8978
8819
|
}
|
|
8820
|
+
/**
|
|
8821
|
+
* The function `getPosition` retrieves position information for a given public key and processes it
|
|
8822
|
+
* using various data to return a `LbPosition` object.
|
|
8823
|
+
* @param {PublicKey} positionPubKey - The `getPosition` function you provided is an asynchronous
|
|
8824
|
+
* function that fetches position information based on a given public key. Here's a breakdown of the
|
|
8825
|
+
* parameters used in the function:
|
|
8826
|
+
* @returns The `getPosition` function returns a Promise that resolves to an object of type
|
|
8827
|
+
* `LbPosition`. The object contains the following properties:
|
|
8828
|
+
* - `publicKey`: The public key of the position account
|
|
8829
|
+
* - `positionData`: Position Object
|
|
8830
|
+
* - `version`: The version of the position (in this case, `Position.V2`)
|
|
8831
|
+
*/
|
|
8832
|
+
async getPosition(positionPubKey) {
|
|
8833
|
+
const positionAccountInfo = await this.program.account.positionV2.fetch(positionPubKey);
|
|
8834
|
+
if (!positionAccountInfo) {
|
|
8835
|
+
throw new Error(`Position account ${positionPubKey.toBase58()} not found`);
|
|
8836
|
+
}
|
|
8837
|
+
const { lowerBinId, upperBinId, feeOwner } = positionAccountInfo;
|
|
8838
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinId));
|
|
8839
|
+
const upperBinArrayIndex = binIdToBinArrayIndex(new BN9(upperBinId));
|
|
8840
|
+
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8841
|
+
this.pubkey,
|
|
8842
|
+
lowerBinArrayIndex,
|
|
8843
|
+
this.program.programId
|
|
8844
|
+
);
|
|
8845
|
+
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8846
|
+
this.pubkey,
|
|
8847
|
+
upperBinArrayIndex,
|
|
8848
|
+
this.program.programId
|
|
8849
|
+
);
|
|
8850
|
+
const [clockAccInfo, lowerBinArrayAccInfo, upperBinArrayAccInfo] = await chunkedGetMultipleAccountInfos(
|
|
8851
|
+
this.program.provider.connection,
|
|
8852
|
+
[
|
|
8853
|
+
SYSVAR_CLOCK_PUBKEY,
|
|
8854
|
+
lowerBinArrayPubKey,
|
|
8855
|
+
upperBinArrayPubKey
|
|
8856
|
+
]
|
|
8857
|
+
);
|
|
8858
|
+
const onChainTimestamp = new BN9(
|
|
8859
|
+
clockAccInfo.data.readBigInt64LE(32).toString()
|
|
8860
|
+
).toNumber();
|
|
8861
|
+
const lowerBinArray = this.program.coder.accounts.decode(
|
|
8862
|
+
"binArray",
|
|
8863
|
+
lowerBinArrayAccInfo.data
|
|
8864
|
+
);
|
|
8865
|
+
const upperBinArray = this.program.coder.accounts.decode(
|
|
8866
|
+
"binArray",
|
|
8867
|
+
upperBinArrayAccInfo.data
|
|
8868
|
+
);
|
|
8869
|
+
return {
|
|
8870
|
+
publicKey: positionPubKey,
|
|
8871
|
+
positionData: await DLMM.processPosition(
|
|
8872
|
+
this.program,
|
|
8873
|
+
1 /* V2 */,
|
|
8874
|
+
this.lbPair,
|
|
8875
|
+
onChainTimestamp,
|
|
8876
|
+
positionAccountInfo,
|
|
8877
|
+
this.tokenX.decimal,
|
|
8878
|
+
this.tokenY.decimal,
|
|
8879
|
+
lowerBinArray,
|
|
8880
|
+
upperBinArray,
|
|
8881
|
+
feeOwner
|
|
8882
|
+
),
|
|
8883
|
+
version: 1 /* V2 */
|
|
8884
|
+
};
|
|
8885
|
+
}
|
|
8979
8886
|
/**
|
|
8980
8887
|
* The function `initializePositionAndAddLiquidityByStrategy` function is used to initializes a position and adds liquidity
|
|
8981
8888
|
* @param {TInitializePositionAndAddLiquidityParamsByStrategy}
|
|
@@ -9338,8 +9245,12 @@ var DLMM = class {
|
|
|
9338
9245
|
const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
|
|
9339
9246
|
const binArrayBitmapExtension = useExtension ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
|
|
9340
9247
|
const strategyParameters = toStrategyParameters(strategy);
|
|
9341
|
-
const positionAccount = await this.program.account.positionV2.fetch(
|
|
9342
|
-
|
|
9248
|
+
const positionAccount = await this.program.account.positionV2.fetch(
|
|
9249
|
+
positionPubKey
|
|
9250
|
+
);
|
|
9251
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(
|
|
9252
|
+
new BN9(positionAccount.lowerBinId)
|
|
9253
|
+
);
|
|
9343
9254
|
const upperBinArrayIndex = lowerBinArrayIndex.add(new BN9(1));
|
|
9344
9255
|
const [binArrayLower] = deriveBinArray(
|
|
9345
9256
|
this.pubkey,
|
|
@@ -9650,9 +9561,40 @@ var DLMM = class {
|
|
|
9650
9561
|
bps,
|
|
9651
9562
|
shouldClaimAndClose = false
|
|
9652
9563
|
}) {
|
|
9653
|
-
const
|
|
9654
|
-
const
|
|
9655
|
-
const
|
|
9564
|
+
const lowerBinIdToRemove = Math.min(...binIds);
|
|
9565
|
+
const upperBinIdToRemove = Math.max(...binIds);
|
|
9566
|
+
const [lowerBinArrayPubKey] = deriveBinArray(this.pubkey, binIdToBinArrayIndex(new BN9(binIds[0])), this.program.programId);
|
|
9567
|
+
const [upperBinArrayPubKey] = deriveBinArray(this.pubkey, binIdToBinArrayIndex(new BN9(binIds[binIds.length - 1])), this.program.programId);
|
|
9568
|
+
const [positionAccInfo, lbPairAccInfo, upperBinArrayInfoAcc, lowerBinArrayInfoAcc] = await this.program.provider.connection.getMultipleAccountsInfo([
|
|
9569
|
+
position,
|
|
9570
|
+
this.pubkey,
|
|
9571
|
+
upperBinArrayPubKey,
|
|
9572
|
+
lowerBinArrayPubKey
|
|
9573
|
+
]);
|
|
9574
|
+
const { lbPair, owner, feeOwner, upperBinId: positionUpperBinId, lowerBinId: positionLowerBinId } = this.program.coder.accounts.decode(
|
|
9575
|
+
"positionV2",
|
|
9576
|
+
positionAccInfo.data
|
|
9577
|
+
);
|
|
9578
|
+
const { reserveX, reserveY, tokenXMint, tokenYMint } = this.program.coder.accounts.decode(
|
|
9579
|
+
"lbPair",
|
|
9580
|
+
lbPairAccInfo.data
|
|
9581
|
+
);
|
|
9582
|
+
const upperBinArray = this.program.coder.accounts.decode("binArray", upperBinArrayInfoAcc.data);
|
|
9583
|
+
const lowerBinArray = this.program.coder.accounts.decode("binArray", lowerBinArrayInfoAcc.data);
|
|
9584
|
+
const bins = await this.getBins(
|
|
9585
|
+
this.pubkey,
|
|
9586
|
+
positionLowerBinId,
|
|
9587
|
+
positionUpperBinId,
|
|
9588
|
+
this.tokenX.decimal,
|
|
9589
|
+
this.tokenY.decimal,
|
|
9590
|
+
lowerBinArray,
|
|
9591
|
+
upperBinArray
|
|
9592
|
+
);
|
|
9593
|
+
const positionHasNoLiquidity = bins.every(({ supply }) => supply.isZero());
|
|
9594
|
+
if (positionHasNoLiquidity) {
|
|
9595
|
+
throw new Error("No liquidity to remove");
|
|
9596
|
+
}
|
|
9597
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new BN9(positionLowerBinId));
|
|
9656
9598
|
const upperBinArrayIndex = lowerBinArrayIndex.add(new BN9(1));
|
|
9657
9599
|
const [binArrayLower] = deriveBinArray(
|
|
9658
9600
|
lbPair,
|
|
@@ -9768,13 +9710,11 @@ var DLMM = class {
|
|
|
9768
9710
|
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
9769
9711
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
9770
9712
|
}
|
|
9771
|
-
const
|
|
9772
|
-
const
|
|
9773
|
-
const minBinArrayIndex = binIdToBinArrayIndex(new BN9(minBinId));
|
|
9774
|
-
const maxBinArrayIndex = binIdToBinArrayIndex(new BN9(maxBinId));
|
|
9713
|
+
const minBinArrayIndex = binIdToBinArrayIndex(new BN9(lowerBinIdToRemove));
|
|
9714
|
+
const maxBinArrayIndex = binIdToBinArrayIndex(new BN9(upperBinIdToRemove));
|
|
9775
9715
|
const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
|
|
9776
9716
|
const binArrayBitmapExtension = useExtension ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
|
|
9777
|
-
const removeLiquidityTx = await this.program.methods.removeLiquidityByRange(
|
|
9717
|
+
const removeLiquidityTx = await this.program.methods.removeLiquidityByRange(lowerBinIdToRemove, upperBinIdToRemove, bps.toNumber()).accounts({
|
|
9778
9718
|
position,
|
|
9779
9719
|
lbPair,
|
|
9780
9720
|
userTokenX,
|
|
@@ -10396,27 +10336,6 @@ var DLMM = class {
|
|
|
10396
10336
|
lastValidBlockHeight
|
|
10397
10337
|
}).add(setActivationPointTx);
|
|
10398
10338
|
}
|
|
10399
|
-
/**
|
|
10400
|
-
* The function `updateWhitelistedWallet` is used to whitelist a wallet, enabling it to deposit into a permissioned pool before the activation point.
|
|
10401
|
-
* @param
|
|
10402
|
-
* - `walletsToWhitelist`: The public key of the wallet.
|
|
10403
|
-
* - `overrideIndexes`: Index of the whitelisted wallet to be inserted. Check DLMM.lbPair.whitelistedWallet for the index
|
|
10404
|
-
* @returns {Promise<Transaction>}
|
|
10405
|
-
*/
|
|
10406
|
-
async updateWhitelistedWallet(walletsToWhitelist) {
|
|
10407
|
-
const instructions = [];
|
|
10408
|
-
const updateWhitelistedWalletIx = await this.program.methods.updateWhitelistedWallet(walletsToWhitelist).accounts({
|
|
10409
|
-
lbPair: this.pubkey,
|
|
10410
|
-
creator: this.lbPair.creator
|
|
10411
|
-
}).instruction();
|
|
10412
|
-
instructions.push(updateWhitelistedWalletIx);
|
|
10413
|
-
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
10414
|
-
return new Transaction({
|
|
10415
|
-
feePayer: this.lbPair.creator,
|
|
10416
|
-
blockhash,
|
|
10417
|
-
lastValidBlockHeight
|
|
10418
|
-
}).add(...instructions);
|
|
10419
|
-
}
|
|
10420
10339
|
/**
|
|
10421
10340
|
* The function `claimSwapFee` is used to claim swap fees for a specific position owned by a specific owner.
|
|
10422
10341
|
* @param
|
|
@@ -10552,15 +10471,13 @@ var DLMM = class {
|
|
|
10552
10471
|
* The `seedLiquidity` function create multiple grouped instructions. The grouped instructions will be either [initialize bin array + initialize position instructions] or [deposit instruction] combination.
|
|
10553
10472
|
* @param
|
|
10554
10473
|
* - `owner`: The public key of the positions owner.
|
|
10555
|
-
* - `operator`: The public key of the operator. Operator can add liquidity for the position owner, withdraw on behalf of position owner (only can withdraw to position owner), and claim fee on behalf of position owner / fee owner (only can claim fee to position / fee owner)
|
|
10556
|
-
* - `feeOwner`: The public key to receive claimed fee.
|
|
10557
10474
|
* - `seedAmount`: Lamport amount to be seeded to the pool.
|
|
10558
10475
|
* - `minPrice`: Start price in UI format
|
|
10559
10476
|
* - `maxPrice`: End price in UI format
|
|
10560
10477
|
* - `base`: Base key
|
|
10561
10478
|
* @returns {Promise<SeedLiquidityResponse>}
|
|
10562
10479
|
*/
|
|
10563
|
-
async seedLiquidity(owner,
|
|
10480
|
+
async seedLiquidity(owner, seedAmount, curvature, minPrice, maxPrice, base) {
|
|
10564
10481
|
const toLamportMultiplier = new Decimal4(
|
|
10565
10482
|
10 ** (this.tokenY.decimal - this.tokenX.decimal)
|
|
10566
10483
|
);
|
|
@@ -10606,7 +10523,7 @@ var DLMM = class {
|
|
|
10606
10523
|
const positionCount = getPositionCount(minBinId, maxBinId.sub(new BN9(1)));
|
|
10607
10524
|
const seederTokenX = getAssociatedTokenAddressSync2(
|
|
10608
10525
|
this.lbPair.tokenXMint,
|
|
10609
|
-
|
|
10526
|
+
owner,
|
|
10610
10527
|
false
|
|
10611
10528
|
);
|
|
10612
10529
|
const initializeBinArraysAndPositionIxs = [];
|
|
@@ -10646,7 +10563,7 @@ var DLMM = class {
|
|
|
10646
10563
|
await this.program.methods.initializeBinArray(lowerBinArrayIndex).accounts({
|
|
10647
10564
|
lbPair: this.pubkey,
|
|
10648
10565
|
binArray: lowerBinArray,
|
|
10649
|
-
funder:
|
|
10566
|
+
funder: owner
|
|
10650
10567
|
}).instruction()
|
|
10651
10568
|
);
|
|
10652
10569
|
appendedInitBinArrayIx.add(lowerBinArray.toBase58());
|
|
@@ -10657,7 +10574,7 @@ var DLMM = class {
|
|
|
10657
10574
|
await this.program.methods.initializeBinArray(upperBinArrayIndex).accounts({
|
|
10658
10575
|
lbPair: this.pubkey,
|
|
10659
10576
|
binArray: upperBinArray,
|
|
10660
|
-
funder:
|
|
10577
|
+
funder: owner
|
|
10661
10578
|
}).instruction()
|
|
10662
10579
|
);
|
|
10663
10580
|
appendedInitBinArrayIx.add(upperBinArray.toBase58());
|
|
@@ -10665,17 +10582,15 @@ var DLMM = class {
|
|
|
10665
10582
|
const positionAccount = accounts[2];
|
|
10666
10583
|
if (!positionAccount) {
|
|
10667
10584
|
instructions.push(
|
|
10668
|
-
await this.program.methods.
|
|
10585
|
+
await this.program.methods.initializePositionPda(
|
|
10669
10586
|
lowerBinId.toNumber(),
|
|
10670
|
-
MAX_BIN_PER_POSITION.toNumber()
|
|
10671
|
-
owner,
|
|
10672
|
-
feeOwner
|
|
10587
|
+
MAX_BIN_PER_POSITION.toNumber()
|
|
10673
10588
|
).accounts({
|
|
10674
10589
|
lbPair: this.pubkey,
|
|
10675
10590
|
position: positionPda,
|
|
10676
10591
|
base,
|
|
10677
|
-
|
|
10678
|
-
payer:
|
|
10592
|
+
owner,
|
|
10593
|
+
payer: owner
|
|
10679
10594
|
}).instruction()
|
|
10680
10595
|
);
|
|
10681
10596
|
}
|
|
@@ -10709,7 +10624,7 @@ var DLMM = class {
|
|
|
10709
10624
|
tokenMint: this.lbPair.tokenXMint,
|
|
10710
10625
|
binArrayLower: lowerBinArray,
|
|
10711
10626
|
binArrayUpper: upperBinArray,
|
|
10712
|
-
sender:
|
|
10627
|
+
sender: owner
|
|
10713
10628
|
}).instruction()
|
|
10714
10629
|
);
|
|
10715
10630
|
if (i + 1 >= positionCount.toNumber() && !finalLoss.isZero()) {
|
|
@@ -10733,7 +10648,7 @@ var DLMM = class {
|
|
|
10733
10648
|
tokenMint: this.lbPair.tokenXMint,
|
|
10734
10649
|
binArrayLower: lowerBinArray,
|
|
10735
10650
|
binArrayUpper: upperBinArray,
|
|
10736
|
-
sender:
|
|
10651
|
+
sender: owner
|
|
10737
10652
|
}).instruction()
|
|
10738
10653
|
);
|
|
10739
10654
|
}
|
|
@@ -10783,6 +10698,7 @@ var DLMM = class {
|
|
|
10783
10698
|
* - `base`: Base key
|
|
10784
10699
|
* - `feeOwner`: Owner of the fees earned by the position.
|
|
10785
10700
|
* - `payer`: Payer for the position account rental.
|
|
10701
|
+
* - `lockReleasePoint`: The lock release point of the position.
|
|
10786
10702
|
* @returns
|
|
10787
10703
|
*/
|
|
10788
10704
|
async initializePositionByOperator({
|
|
@@ -10792,7 +10708,8 @@ var DLMM = class {
|
|
|
10792
10708
|
feeOwner,
|
|
10793
10709
|
base,
|
|
10794
10710
|
operator,
|
|
10795
|
-
payer
|
|
10711
|
+
payer,
|
|
10712
|
+
lockReleasePoint
|
|
10796
10713
|
}) {
|
|
10797
10714
|
const [positionPda, _bump] = derivePosition(
|
|
10798
10715
|
this.pubkey,
|
|
@@ -10801,16 +10718,29 @@ var DLMM = class {
|
|
|
10801
10718
|
positionWidth,
|
|
10802
10719
|
this.program.programId
|
|
10803
10720
|
);
|
|
10721
|
+
const operatorTokenX = getAssociatedTokenAddressSync2(
|
|
10722
|
+
this.lbPair.tokenXMint,
|
|
10723
|
+
operator,
|
|
10724
|
+
true
|
|
10725
|
+
);
|
|
10726
|
+
const ownerTokenX = getAssociatedTokenAddressSync2(
|
|
10727
|
+
this.lbPair.tokenXMint,
|
|
10728
|
+
owner,
|
|
10729
|
+
true
|
|
10730
|
+
);
|
|
10804
10731
|
let initializePositionByOperatorTx = await this.program.methods.initializePositionByOperator(
|
|
10805
10732
|
lowerBinId.toNumber(),
|
|
10806
10733
|
MAX_BIN_PER_POSITION.toNumber(),
|
|
10807
|
-
|
|
10808
|
-
|
|
10734
|
+
feeOwner,
|
|
10735
|
+
lockReleasePoint
|
|
10809
10736
|
).accounts({
|
|
10810
10737
|
lbPair: this.pubkey,
|
|
10811
10738
|
position: positionPda,
|
|
10812
10739
|
base,
|
|
10813
10740
|
operator,
|
|
10741
|
+
owner,
|
|
10742
|
+
ownerTokenX,
|
|
10743
|
+
operatorTokenX,
|
|
10814
10744
|
payer
|
|
10815
10745
|
}).transaction();
|
|
10816
10746
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
@@ -11050,7 +10980,6 @@ var DLMM = class {
|
|
|
11050
10980
|
}
|
|
11051
10981
|
}
|
|
11052
10982
|
}
|
|
11053
|
-
console.log(binPriceWithLastLiquidity);
|
|
11054
10983
|
return this.fromPricePerLamport(
|
|
11055
10984
|
Number(binPriceWithLastLiquidity) / (2 ** 64 - 1)
|
|
11056
10985
|
);
|
|
@@ -11339,12 +11268,7 @@ var DLMM = class {
|
|
|
11339
11268
|
let totalYAmount = new Decimal4(0);
|
|
11340
11269
|
bins.forEach((bin, idx) => {
|
|
11341
11270
|
const binSupply = new Decimal4(bin.supply.toString());
|
|
11342
|
-
|
|
11343
|
-
if (bin.version === 1 && version === 0 /* V1 */) {
|
|
11344
|
-
posShare = new Decimal4(posShares[idx].shln(64).toString());
|
|
11345
|
-
} else {
|
|
11346
|
-
posShare = new Decimal4(posShares[idx].toString());
|
|
11347
|
-
}
|
|
11271
|
+
const posShare = new Decimal4(posShares[idx].toString());
|
|
11348
11272
|
const positionXAmount = binSupply.eq(new Decimal4("0")) ? new Decimal4("0") : posShare.mul(bin.xAmount.toString()).div(binSupply);
|
|
11349
11273
|
const positionYAmount = binSupply.eq(new Decimal4("0")) ? new Decimal4("0") : posShare.mul(bin.yAmount.toString()).div(binSupply);
|
|
11350
11274
|
totalXAmount = totalXAmount.add(positionXAmount);
|
|
@@ -11774,6 +11698,7 @@ export {
|
|
|
11774
11698
|
EXTENSION_BINARRAY_BITMAP_SIZE,
|
|
11775
11699
|
FEE_PRECISION,
|
|
11776
11700
|
IDL,
|
|
11701
|
+
ILM_BASE,
|
|
11777
11702
|
LBCLMM_PROGRAM_IDS,
|
|
11778
11703
|
MAX_ACTIVE_BIN_SLIPPAGE,
|
|
11779
11704
|
MAX_BIN_ARRAY_SIZE,
|
|
@@ -11812,6 +11737,7 @@ export {
|
|
|
11812
11737
|
src_default as default,
|
|
11813
11738
|
deriveBinArray,
|
|
11814
11739
|
deriveBinArrayBitmapExtension,
|
|
11740
|
+
deriveCustomizablePermissionlessLbPair,
|
|
11815
11741
|
deriveLbPair,
|
|
11816
11742
|
deriveLbPair2,
|
|
11817
11743
|
deriveOracle,
|