@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.js CHANGED
@@ -9,7 +9,7 @@ var _web3js = require('@solana/web3.js');
9
9
 
10
10
  // src/dlmm/idl.ts
11
11
  var IDL = {
12
- "version": "0.8.0",
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": "systemProgram",
1142
+ "name": "operatorTokenX",
1039
1143
  "isMut": false,
1040
1144
  "isSigner": false
1041
1145
  },
1042
1146
  {
1043
- "name": "rent",
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": "owner",
1177
+ "name": "feeOwner",
1069
1178
  "type": "publicKey"
1070
1179
  },
1071
1180
  {
1072
- "name": "feeOwner",
1073
- "type": "publicKey"
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": "u16"
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": "whitelistedWallet",
2897
+ "name": "padding2",
2913
2898
  "docs": [
2914
- "Whitelisted wallet"
2899
+ "_padding_2, previous whitelisted_wallet, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
2915
2900
  ],
2916
- "type": "publicKey"
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": "padding2",
2937
+ "name": "padding3",
2948
2938
  "docs": [
2949
- "_padding 2 is reclaimed free space from swap_cap_deactivate_point and swap_cap_amount before, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
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": "lockDuration",
2949
+ "name": "padding4",
2960
2950
  "docs": [
2961
- "Liquidity lock duration for positions which created before activate. Only applicable for permission pair."
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": "subjectedToBootstrapLiquidityLocking",
3248
+ "name": "padding0",
3259
3249
  "docs": [
3260
- "Is the position subjected to liquidity locking for the launch pool."
3250
+ "_padding_0, previous subjected_to_bootstrap_liquidity_locking, BE CAREFUL FOR TOMBSTONE WHEN REUSE !!"
3261
3251
  ],
3262
3252
  "type": "u8"
3263
3253
  },
@@ -3363,6 +3353,106 @@ var IDL = {
3363
3353
  }
3364
3354
  ],
3365
3355
  "types": [
3356
+ {
3357
+ "name": "InitPresetParametersIx",
3358
+ "type": {
3359
+ "kind": "struct",
3360
+ "fields": [
3361
+ {
3362
+ "name": "binStep",
3363
+ "docs": [
3364
+ "Bin step. Represent the price increment / decrement."
3365
+ ],
3366
+ "type": "u16"
3367
+ },
3368
+ {
3369
+ "name": "baseFactor",
3370
+ "docs": [
3371
+ "Used for base fee calculation. base_fee_rate = base_factor * bin_step"
3372
+ ],
3373
+ "type": "u16"
3374
+ },
3375
+ {
3376
+ "name": "filterPeriod",
3377
+ "docs": [
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
+ },
3366
3456
  {
3367
3457
  "name": "LiquidityParameterByStrategyOneSide",
3368
3458
  "type": {
@@ -3697,137 +3787,97 @@ var IDL = {
3697
3787
  }
3698
3788
  },
3699
3789
  {
3700
- "name": "InitPermissionPairIx",
3701
- "type": {
3702
- "kind": "struct",
3703
- "fields": [
3704
- {
3705
- "name": "activeId",
3706
- "type": "i32"
3707
- },
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
- {
3741
- "name": "binStep",
3742
- "docs": [
3743
- "Bin step. Represent the price increment / decrement."
3744
- ],
3745
- "type": "u16"
3746
- },
3747
- {
3748
- "name": "baseFactor",
3749
- "docs": [
3750
- "Used for base fee calculation. base_fee_rate = base_factor * bin_step"
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
- },
3790
+ "name": "CustomizableParams",
3791
+ "type": {
3792
+ "kind": "struct",
3793
+ "fields": [
3761
3794
  {
3762
- "name": "decayPeriod",
3795
+ "name": "activeId",
3763
3796
  "docs": [
3764
- "Decay period determine when the volatile fee start decay / decrease."
3797
+ "Pool price"
3765
3798
  ],
3766
- "type": "u16"
3799
+ "type": "i32"
3767
3800
  },
3768
3801
  {
3769
- "name": "reductionFactor",
3802
+ "name": "binStep",
3770
3803
  "docs": [
3771
- "Reduction factor controls the volatile fee rate decrement rate."
3804
+ "Bin step"
3772
3805
  ],
3773
3806
  "type": "u16"
3774
3807
  },
3775
3808
  {
3776
- "name": "variableFeeControl",
3809
+ "name": "baseFactor",
3777
3810
  "docs": [
3778
- "Used to scale the variable fee component depending on the dynamic of the market"
3811
+ "Base factor"
3779
3812
  ],
3780
- "type": "u32"
3813
+ "type": "u16"
3781
3814
  },
3782
3815
  {
3783
- "name": "maxVolatilityAccumulator",
3816
+ "name": "activationType",
3784
3817
  "docs": [
3785
- "Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate."
3818
+ "Activation type. 0 = Slot, 1 = Time. Check ActivationType enum"
3786
3819
  ],
3787
- "type": "u32"
3820
+ "type": "u8"
3788
3821
  },
3789
3822
  {
3790
- "name": "minBinId",
3823
+ "name": "hasAlphaVault",
3791
3824
  "docs": [
3792
- "Min bin id supported by the pool based on the configured bin step."
3825
+ "Whether the pool has an alpha vault"
3793
3826
  ],
3794
- "type": "i32"
3827
+ "type": "bool"
3795
3828
  },
3796
3829
  {
3797
- "name": "maxBinId",
3830
+ "name": "activationPoint",
3798
3831
  "docs": [
3799
- "Max bin id supported by the pool based on the configured bin step."
3832
+ "Decide when does the pool start trade. None = Now"
3800
3833
  ],
3801
- "type": "i32"
3834
+ "type": {
3835
+ "option": "u64"
3836
+ }
3802
3837
  },
3803
3838
  {
3804
- "name": "protocolShare",
3839
+ "name": "padding",
3805
3840
  "docs": [
3806
- "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee"
3841
+ "Padding, for future use"
3807
3842
  ],
3808
- "type": "u16"
3843
+ "type": {
3844
+ "array": [
3845
+ "u8",
3846
+ 64
3847
+ ]
3848
+ }
3809
3849
  }
3810
3850
  ]
3811
3851
  }
3812
3852
  },
3813
3853
  {
3814
- "name": "FeeParameter",
3854
+ "name": "InitPermissionPairIx",
3815
3855
  "type": {
3816
3856
  "kind": "struct",
3817
3857
  "fields": [
3818
3858
  {
3819
- "name": "protocolShare",
3820
- "docs": [
3821
- "Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee"
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": "LayoutVersion",
4339
+ "name": "ActivationType",
4290
4340
  "docs": [
4291
- "Layout version"
4341
+ "Type of the activation"
4292
4342
  ],
4293
4343
  "type": {
4294
4344
  "kind": "enum",
4295
4345
  "variants": [
4296
4346
  {
4297
- "name": "V0"
4347
+ "name": "Slot"
4298
4348
  },
4299
4349
  {
4300
- "name": "V1"
4350
+ "name": "Timestamp"
4301
4351
  }
4302
4352
  ]
4303
4353
  }
4304
4354
  },
4305
4355
  {
4306
- "name": "ActivationType",
4356
+ "name": "LayoutVersion",
4307
4357
  "docs": [
4308
- "Type of the activation"
4358
+ "Layout version"
4309
4359
  ],
4310
4360
  "type": {
4311
4361
  "kind": "enum",
4312
4362
  "variants": [
4313
4363
  {
4314
- "name": "Slot"
4364
+ "name": "V0"
4315
4365
  },
4316
4366
  {
4317
- "name": "Timestamp"
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 (0, _web3js.PublicKey)(
5309
+ "MFGQxwAmB91SwuYX36okv2Qmdc9aMuHTwWGUrp4AtB1"
5310
+ );
5220
5311
 
5221
5312
  // src/dlmm/types/index.ts
5222
5313
  var _borsh = require('@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 _web3js.PublicKey.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 _web3js.PublicKey.findProgramAddressSync(
@@ -7877,49 +7975,14 @@ var DLMM = class {
7877
7975
  _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _46 => _46.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7878
7976
  provider
7879
7977
  );
7880
- const [positions, positionsV2] = await Promise.all([
7881
- program.account.position.all([
7882
- {
7883
- memcmp: {
7884
- bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
7885
- offset: 8 + 32
7886
- }
7887
- }
7888
- ]),
7889
- program.account.positionV2.all([
7890
- {
7891
- memcmp: {
7892
- bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
7893
- offset: 8 + 32
7894
- }
7978
+ const positionsV2 = await program.account.positionV2.all([
7979
+ {
7980
+ memcmp: {
7981
+ bytes: _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 (0, _anchor.BN)(lowerBinId));
7902
- const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(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 (0, _web3js.PublicKey)(pubkey)
7919
- );
7920
- const lbPairArray = Array.from(lbPairSet).map(
7921
- (pubkey) => new (0, _web3js.PublicKey)(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
  _web3js.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 = binArrayPubkeyArray.length + lbPairArray.length; i < binArrayPubkeyArray.length + lbPairArray.length + binArrayPubkeyArrayV2.length; i++) {
7989
- const binArrayPubkey = binArrayPubkeyArrayV2[i - (binArrayPubkeyArray.length + lbPairArray.length)];
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 = binArrayPubkeyArray.length + lbPairArray.length + binArrayPubkeyArrayV2.length; i < binArraysAccInfo.length; i++) {
8003
- const lbPairPubkey = lbPairArrayV2[i - (binArrayPubkeyArray.length + lbPairArray.length + binArrayPubkeyArrayV2.length)];
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`);
@@ -8012,144 +8041,47 @@ var DLMM = class {
8012
8041
  }
8013
8042
  const reservePublicKeysV2 = Array.from(lbPairArraysMapV2.values()).map(({ reserveX, reserveY, tokenXMint, tokenYMint }) => [
8014
8043
  reserveX,
8015
- reserveY,
8016
- tokenXMint,
8017
- tokenYMint
8018
- ]).flat();
8019
- const reserveAccountsInfo = await chunkedGetMultipleAccountInfos(
8020
- program.provider.connection,
8021
- [...reservePublicKeys, ...reservePublicKeysV2]
8022
- );
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 = _spltoken.AccountLayout.decode(reserveAccBufferX.data);
8034
- const reserveAccY = _spltoken.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 = _spltoken.MintLayout.decode(mintXBuffer.data);
8046
- const mintY = _spltoken.MintLayout.decode(mintYBuffer.data);
8047
- lbPairMintMap.set(lbPair.toBase58(), {
8048
- mintXDecimal: mintX.decimals,
8049
- mintYDecimal: mintY.decimals
8050
- });
8051
- });
8052
- const lbPairReserveMapV2 = /* @__PURE__ */ new Map();
8053
- const lbPairMintMapV2 = /* @__PURE__ */ new Map();
8054
- lbPairArrayV2.forEach((lbPair, idx) => {
8055
- const index = idx * 4;
8056
- const reserveAccBufferXV2 = reserveAccountsInfo[reservePublicKeys.length + index];
8057
- const reserveAccBufferYV2 = reserveAccountsInfo[reservePublicKeys.length + index + 1];
8058
- if (!reserveAccBufferXV2 || !reserveAccBufferYV2)
8059
- throw new Error(
8060
- `Reserve account for LB Pair ${lbPair.toBase58()} not found`
8061
- );
8062
- const reserveAccX = _spltoken.AccountLayout.decode(reserveAccBufferXV2.data);
8063
- const reserveAccY = _spltoken.AccountLayout.decode(reserveAccBufferYV2.data);
8064
- lbPairReserveMapV2.set(lbPair.toBase58(), {
8065
- reserveX: reserveAccX.amount,
8066
- reserveY: reserveAccY.amount
8067
- });
8068
- const mintXBufferV2 = reserveAccountsInfo[reservePublicKeys.length + index + 2];
8069
- const mintYBufferV2 = reserveAccountsInfo[reservePublicKeys.length + index + 3];
8070
- if (!mintXBufferV2 || !mintYBufferV2)
8071
- throw new Error(
8072
- `Mint account for LB Pair ${lbPair.toBase58()} not found`
8073
- );
8074
- const mintX = _spltoken.MintLayout.decode(mintXBufferV2.data);
8075
- const mintY = _spltoken.MintLayout.decode(mintYBufferV2.data);
8076
- lbPairMintMapV2.set(lbPair.toBase58(), {
8077
- mintXDecimal: mintX.decimals,
8078
- mintYDecimal: mintY.decimals
8079
- });
8080
- });
8081
- const onChainTimestamp = new (0, _anchor.BN)(
8082
- clockAccInfo.data.readBigInt64LE(32).toString()
8083
- ).toNumber();
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 (0, _anchor.BN)(lowerBinId));
8089
- const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(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 = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.reserveX]), () => ( BigInt(0)));
8111
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.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
- _web3js.PublicKey.default
8135
- );
8136
- if (positionData) {
8137
- positionsMap.set(lbPair.toBase58(), {
8138
- publicKey: lbPair,
8139
- lbPair: lbPairAcc,
8140
- tokenX,
8141
- tokenY,
8142
- lbPairPositionsData: [
8143
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.lbPairPositionsData]), () => ( [])),
8144
- {
8145
- publicKey: positionPubKey,
8146
- positionData,
8147
- version: 0 /* V1 */
8148
- }
8149
- ]
8150
- });
8151
- }
8152
- }
8044
+ reserveY,
8045
+ tokenXMint,
8046
+ tokenYMint
8047
+ ]).flat();
8048
+ const reserveAccountsInfo = await chunkedGetMultipleAccountInfos(
8049
+ program.provider.connection,
8050
+ reservePublicKeysV2
8051
+ );
8052
+ const lbPairReserveMapV2 = /* @__PURE__ */ new Map();
8053
+ const lbPairMintMapV2 = /* @__PURE__ */ new Map();
8054
+ lbPairArrayV2.forEach((lbPair, idx) => {
8055
+ const index = idx * 4;
8056
+ const reserveAccBufferXV2 = reserveAccountsInfo[index];
8057
+ const reserveAccBufferYV2 = reserveAccountsInfo[index + 1];
8058
+ if (!reserveAccBufferXV2 || !reserveAccBufferYV2)
8059
+ throw new Error(
8060
+ `Reserve account for LB Pair ${lbPair.toBase58()} not found`
8061
+ );
8062
+ const reserveAccX = _spltoken.AccountLayout.decode(reserveAccBufferXV2.data);
8063
+ const reserveAccY = _spltoken.AccountLayout.decode(reserveAccBufferYV2.data);
8064
+ lbPairReserveMapV2.set(lbPair.toBase58(), {
8065
+ reserveX: reserveAccX.amount,
8066
+ reserveY: reserveAccY.amount
8067
+ });
8068
+ const mintXBufferV2 = reserveAccountsInfo[index + 2];
8069
+ const mintYBufferV2 = reserveAccountsInfo[index + 3];
8070
+ if (!mintXBufferV2 || !mintYBufferV2)
8071
+ throw new Error(
8072
+ `Mint account for LB Pair ${lbPair.toBase58()} not found`
8073
+ );
8074
+ const mintX = _spltoken.MintLayout.decode(mintXBufferV2.data);
8075
+ const mintY = _spltoken.MintLayout.decode(mintYBufferV2.data);
8076
+ lbPairMintMapV2.set(lbPair.toBase58(), {
8077
+ mintXDecimal: mintX.decimals,
8078
+ mintYDecimal: mintY.decimals
8079
+ });
8080
+ });
8081
+ const onChainTimestamp = new (0, _anchor.BN)(
8082
+ clockAccInfo.data.readBigInt64LE(32).toString()
8083
+ ).toNumber();
8084
+ const positionsMap = /* @__PURE__ */ new Map();
8153
8085
  for (let position of positionsV2) {
8154
8086
  const { account, publicKey: positionPubKey } = position;
8155
8087
  const { upperBinId, lowerBinId, lbPair, feeOwner } = account;
@@ -8176,8 +8108,8 @@ var DLMM = class {
8176
8108
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
8177
8109
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
8178
8110
  ]);
8179
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _56 => _56.get, 'call', _57 => _57(lbPair.toBase58()), 'optionalAccess', _58 => _58.reserveX]), () => ( BigInt(0)));
8180
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _59 => _59.get, 'call', _60 => _60(lbPair.toBase58()), 'optionalAccess', _61 => _61.reserveY]), () => ( BigInt(0)));
8111
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.reserveX]), () => ( BigInt(0)));
8112
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.reserveY]), () => ( BigInt(0)));
8181
8113
  const tokenX = {
8182
8114
  publicKey: lbPairAcc.tokenXMint,
8183
8115
  reserve: lbPairAcc.reserveX,
@@ -8209,7 +8141,7 @@ var DLMM = class {
8209
8141
  tokenX,
8210
8142
  tokenY,
8211
8143
  lbPairPositionsData: [
8212
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _62 => _62.get, 'call', _63 => _63(lbPair.toBase58()), 'optionalAccess', _64 => _64.lbPairPositionsData]), () => ( [])),
8144
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.lbPairPositionsData]), () => ( [])),
8213
8145
  {
8214
8146
  publicKey: positionPubKey,
8215
8147
  positionData,
@@ -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 = _optionalChain([opt, 'optionalAccess', _65 => _65.cluster]) || "mainnet-beta";
8226
- const provider = new (0, _anchor.AnchorProvider)(
8227
- connection,
8228
- {},
8229
- _anchor.AnchorProvider.defaultOptions()
8230
- );
8231
- const program = new (0, _anchor.Program)(
8232
- IDL,
8233
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _66 => _66.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 (0, _anchor.BN)(lowerBinId));
8244
- const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(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: _web3js.SystemProgram.programId
8265
- }).transaction();
8266
- return new (0, _web3js.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 (0, _decimaljs2.default)(price).mul(new (0, _decimaljs2.default)(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, lockDuration, activationType, opt) {
8165
+ static async createPermissionLbPair(connection, binStep, tokenX, tokenY, activeId, baseKey, creatorKey, feeBps, activationType, opt) {
8284
8166
  const provider = new (0, _anchor.AnchorProvider)(
8285
8167
  connection,
8286
8168
  {},
@@ -8288,7 +8170,7 @@ var DLMM = class {
8288
8170
  );
8289
8171
  const program = new (0, _anchor.Program)(
8290
8172
  IDL,
8291
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _67 => _67.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8173
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _56 => _56.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8292
8174
  provider
8293
8175
  );
8294
8176
  const [lbPair] = derivePermissionLbPair(
@@ -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 (0, _anchor.AnchorProvider)(
8216
+ connection,
8217
+ {},
8218
+ _anchor.AnchorProvider.defaultOptions()
8219
+ );
8220
+ const program = new (0, _anchor.Program)(
8221
+ IDL,
8222
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _57 => _57.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 = _spltoken.getAssociatedTokenAddressSync.call(void 0, tokenX, creatorKey);
8247
+ return program.methods.initializeCustomizablePermissionlessLbPair(ixData).accounts({
8248
+ lbPair,
8249
+ rent: _web3js.SYSVAR_RENT_PUBKEY,
8250
+ reserveX,
8251
+ reserveY,
8252
+ binArrayBitmapExtension,
8253
+ tokenMintX: tokenX,
8254
+ tokenMintY: tokenY,
8255
+ tokenProgram: _spltoken.TOKEN_PROGRAM_ID,
8256
+ oracle,
8257
+ systemProgram: _web3js.SystemProgram.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 (0, _anchor.AnchorProvider)(
8335
8264
  connection,
@@ -8338,7 +8267,7 @@ var DLMM = class {
8338
8267
  );
8339
8268
  const program = new (0, _anchor.Program)(
8340
8269
  IDL,
8341
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _68 => _68.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8270
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _58 => _58.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8342
8271
  provider
8343
8272
  );
8344
8273
  const existsPool = await this.getPairPubkeyIfExists(
@@ -8474,7 +8403,7 @@ var DLMM = class {
8474
8403
  swapForY,
8475
8404
  new (0, _anchor.BN)(activeIdToLoop),
8476
8405
  this.lbPair,
8477
- _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.binArrayBitmapExtension, 'optionalAccess', _70 => _70.account]), () => ( null))
8406
+ _nullishCoalesce(_optionalChain([this, 'access', _59 => _59.binArrayBitmapExtension, 'optionalAccess', _60 => _60.account]), () => ( null))
8478
8407
  );
8479
8408
  if (binArrayIndex === null)
8480
8409
  shouldStop = true;
@@ -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: _bytes.bs58.encode(userPubKey.toBuffer()),
8722
- offset: 8 + 32
8723
- }
8724
- },
8725
- {
8726
- memcmp: {
8727
- bytes: _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, positions, positionsV2] = promiseResults;
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 (!positions || !positionsV2) {
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 (0, _anchor.BN)(lowerBinId));
8763
- const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(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 (0, _web3js.PublicKey)(pubkey)
8779
- );
8780
8675
  const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
8781
8676
  positionsV2.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
8782
8677
  const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
@@ -8802,28 +8697,13 @@ var DLMM = class {
8802
8697
  [
8803
8698
  this.pubkey,
8804
8699
  _web3js.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 = binArrayPubkeyArray.length; i < binArraysAccInfo.length; i++) {
8826
- const binArrayPubkey = binArrayPubkeyArrayV2[i - binArrayPubkeyArray.length];
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 (0, _anchor.BN)(
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 (0, _anchor.BN)(lowerBinId));
8847
- const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(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
- _web3js.PublicKey.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: [...userPositions, ...userPositionsV2]
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 (0, _anchor.BN)(lowerBinId));
8839
+ const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(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
+ _web3js.SYSVAR_CLOCK_PUBKEY,
8854
+ lowerBinArrayPubKey,
8855
+ upperBinArrayPubKey
8856
+ ]
8857
+ );
8858
+ const onChainTimestamp = new (0, _anchor.BN)(
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(positionPubKey);
9342
- const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(positionAccount.lowerBinId));
9248
+ const positionAccount = await this.program.account.positionV2.fetch(
9249
+ positionPubKey
9250
+ );
9251
+ const lowerBinArrayIndex = binIdToBinArrayIndex(
9252
+ new (0, _anchor.BN)(positionAccount.lowerBinId)
9253
+ );
9343
9254
  const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(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 { lbPair, lowerBinId, owner, feeOwner } = await this.program.account.positionV2.fetch(position);
9654
- const { reserveX, reserveY, tokenXMint, tokenYMint } = await this.program.account.lbPair.fetch(lbPair);
9655
- const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
9564
+ const lowerBinIdToRemove = Math.min(...binIds);
9565
+ const upperBinIdToRemove = Math.max(...binIds);
9566
+ const [lowerBinArrayPubKey] = deriveBinArray(this.pubkey, binIdToBinArrayIndex(new (0, _anchor.BN)(binIds[0])), this.program.programId);
9567
+ const [upperBinArrayPubKey] = deriveBinArray(this.pubkey, binIdToBinArrayIndex(new (0, _anchor.BN)(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 (0, _anchor.BN)(positionLowerBinId));
9656
9598
  const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(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 minBinId = Math.min(...binIds);
9772
- const maxBinId = Math.max(...binIds);
9773
- const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
9774
- const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
9713
+ const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinIdToRemove));
9714
+ const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(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(minBinId, maxBinId, bps.toNumber()).accounts({
9717
+ const removeLiquidityTx = await this.program.methods.removeLiquidityByRange(lowerBinIdToRemove, upperBinIdToRemove, bps.toNumber()).accounts({
9778
9718
  position,
9779
9719
  lbPair,
9780
9720
  userTokenX,
@@ -9891,7 +9831,7 @@ var DLMM = class {
9891
9831
  swapForY,
9892
9832
  activeId,
9893
9833
  this.lbPair,
9894
- _nullishCoalesce(_optionalChain([this, 'access', _71 => _71.binArrayBitmapExtension, 'optionalAccess', _72 => _72.account]), () => ( null)),
9834
+ _nullishCoalesce(_optionalChain([this, 'access', _61 => _61.binArrayBitmapExtension, 'optionalAccess', _62 => _62.account]), () => ( null)),
9895
9835
  binArrays
9896
9836
  );
9897
9837
  if (binArrayAccountToSwap == null) {
@@ -9995,7 +9935,7 @@ var DLMM = class {
9995
9935
  swapForY,
9996
9936
  activeId,
9997
9937
  this.lbPair,
9998
- _nullishCoalesce(_optionalChain([this, 'access', _73 => _73.binArrayBitmapExtension, 'optionalAccess', _74 => _74.account]), () => ( null)),
9938
+ _nullishCoalesce(_optionalChain([this, 'access', _63 => _63.binArrayBitmapExtension, 'optionalAccess', _64 => _64.account]), () => ( null)),
9999
9939
  binArrays
10000
9940
  );
10001
9941
  if (binArrayAccountToSwap == null) {
@@ -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 (0, _web3js.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, operator, feeOwner, seedAmount, curvature, minPrice, maxPrice, base) {
10480
+ async seedLiquidity(owner, seedAmount, curvature, minPrice, maxPrice, base) {
10564
10481
  const toLamportMultiplier = new (0, _decimaljs2.default)(
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 (0, _anchor.BN)(1)));
10607
10524
  const seederTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
10608
10525
  this.lbPair.tokenXMint,
10609
- operator,
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: operator
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: operator
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.initializePositionByOperator(
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
- operator,
10678
- payer: operator
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: operator
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: operator
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 = _spltoken.getAssociatedTokenAddressSync.call(void 0,
10722
+ this.lbPair.tokenXMint,
10723
+ operator,
10724
+ true
10725
+ );
10726
+ const ownerTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
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
- owner,
10808
- feeOwner
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");
@@ -10939,7 +10869,7 @@ var DLMM = class {
10939
10869
  swapForY,
10940
10870
  new (0, _anchor.BN)(activeBinId),
10941
10871
  this.lbPair,
10942
- _nullishCoalesce(_optionalChain([this, 'access', _75 => _75.binArrayBitmapExtension, 'optionalAccess', _76 => _76.account]), () => ( null))
10872
+ _nullishCoalesce(_optionalChain([this, 'access', _65 => _65.binArrayBitmapExtension, 'optionalAccess', _66 => _66.account]), () => ( null))
10943
10873
  );
10944
10874
  if (toBinArrayIndex === null)
10945
10875
  return true;
@@ -10976,7 +10906,7 @@ var DLMM = class {
10976
10906
  swapForY,
10977
10907
  new (0, _anchor.BN)(activeBinId),
10978
10908
  this.lbPair,
10979
- _nullishCoalesce(_optionalChain([this, 'access', _77 => _77.binArrayBitmapExtension, 'optionalAccess', _78 => _78.account]), () => ( null))
10909
+ _nullishCoalesce(_optionalChain([this, 'access', _67 => _67.binArrayBitmapExtension, 'optionalAccess', _68 => _68.account]), () => ( null))
10980
10910
  );
10981
10911
  const accountsToFetch = [];
10982
10912
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -11007,13 +10937,13 @@ var DLMM = class {
11007
10937
  let fromBinArray = null;
11008
10938
  let toBinArray = null;
11009
10939
  let binArrayBitmapExtension = null;
11010
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _79 => _79[0]])) {
10940
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _69 => _69[0]])) {
11011
10941
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
11012
10942
  }
11013
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _80 => _80[1]])) {
10943
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _70 => _70[1]])) {
11014
10944
  fromBinArray = fromBinArrayPubkey;
11015
10945
  }
11016
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _81 => _81[2]]) && !!toBinArrayIndex) {
10946
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _71 => _71[2]]) && !!toBinArrayIndex) {
11017
10947
  toBinArray = toBinArrayPubkey;
11018
10948
  }
11019
10949
  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 (0, _decimaljs2.default)(0);
11340
11269
  bins.forEach((bin, idx) => {
11341
11270
  const binSupply = new (0, _decimaljs2.default)(bin.supply.toString());
11342
- let posShare;
11343
- if (bin.version === 1 && version === 0 /* V1 */) {
11344
- posShare = new (0, _decimaljs2.default)(posShares[idx].shln(64).toString());
11345
- } else {
11346
- posShare = new (0, _decimaljs2.default)(posShares[idx].toString());
11347
- }
11271
+ const posShare = new (0, _decimaljs2.default)(posShares[idx].toString());
11348
11272
  const positionXAmount = binSupply.eq(new (0, _decimaljs2.default)("0")) ? new (0, _decimaljs2.default)("0") : posShare.mul(bin.xAmount.toString()).div(binSupply);
11349
11273
  const positionYAmount = binSupply.eq(new (0, _decimaljs2.default)("0")) ? new (0, _decimaljs2.default)("0") : posShare.mul(bin.yAmount.toString()).div(binSupply);
11350
11274
  totalXAmount = totalXAmount.add(positionXAmount);
@@ -11850,5 +11774,7 @@ var src_default = DLMM;
11850
11774
 
11851
11775
 
11852
11776
 
11853
- exports.ADMIN = ADMIN; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BitmapType = BitmapType; exports.ClockLayout = ClockLayout; exports.DLMMError = DLMMError; exports.DlmmSdkError = DlmmSdkError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.PairStatus = PairStatus; exports.PairType = PairType; exports.PositionVersion = PositionVersion; exports.SCALE = SCALE; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SIMULATION_USER = SIMULATION_USER; exports.Strategy = Strategy; exports.StrategyType = StrategyType; exports.autoFillXByStrategy = autoFillXByStrategy; exports.autoFillXByWeight = autoFillXByWeight; exports.autoFillYByStrategy = autoFillYByStrategy; exports.autoFillYByWeight = autoFillYByWeight; exports.binIdToBinArrayIndex = binIdToBinArrayIndex; exports.calculateBidAskDistribution = calculateBidAskDistribution; exports.calculateNormalDistribution = calculateNormalDistribution; exports.calculateSpotDistribution = calculateSpotDistribution; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeBudgetIx = computeBudgetIx; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveLbPair = deriveLbPair; exports.deriveLbPair2 = deriveLbPair2; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.derivePresetParameter2 = derivePresetParameter2; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinArraysRequiredByPositionRange = getBinArraysRequiredByPositionRange; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTokensMintFromPoolAddress = getTokensMintFromPoolAddress; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
11777
+
11778
+
11779
+ exports.ADMIN = ADMIN; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BitmapType = BitmapType; exports.ClockLayout = ClockLayout; exports.DLMMError = DLMMError; exports.DlmmSdkError = DlmmSdkError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.ILM_BASE = ILM_BASE; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.PairStatus = PairStatus; exports.PairType = PairType; exports.PositionVersion = PositionVersion; exports.SCALE = SCALE; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SIMULATION_USER = SIMULATION_USER; exports.Strategy = Strategy; exports.StrategyType = StrategyType; exports.autoFillXByStrategy = autoFillXByStrategy; exports.autoFillXByWeight = autoFillXByWeight; exports.autoFillYByStrategy = autoFillYByStrategy; exports.autoFillYByWeight = autoFillYByWeight; exports.binIdToBinArrayIndex = binIdToBinArrayIndex; exports.calculateBidAskDistribution = calculateBidAskDistribution; exports.calculateNormalDistribution = calculateNormalDistribution; exports.calculateSpotDistribution = calculateSpotDistribution; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeBudgetIx = computeBudgetIx; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveCustomizablePermissionlessLbPair = deriveCustomizablePermissionlessLbPair; exports.deriveLbPair = deriveLbPair; exports.deriveLbPair2 = deriveLbPair2; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.derivePresetParameter2 = derivePresetParameter2; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinArraysRequiredByPositionRange = getBinArraysRequiredByPositionRange; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTokensMintFromPoolAddress = getTokensMintFromPoolAddress; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
11854
11780
  //# sourceMappingURL=index.js.map