@meteora-ag/dlmm 1.0.51 → 1.0.52-rc.6
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 +104 -31
- package/dist/index.js +185 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +185 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2048,6 +2048,73 @@ var IDL = {
|
|
|
2048
2048
|
],
|
|
2049
2049
|
"args": []
|
|
2050
2050
|
},
|
|
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
|
+
},
|
|
2051
2118
|
{
|
|
2052
2119
|
"name": "togglePairStatus",
|
|
2053
2120
|
"accounts": [
|
|
@@ -2559,7 +2626,7 @@ var IDL = {
|
|
|
2559
2626
|
],
|
|
2560
2627
|
"accounts": [
|
|
2561
2628
|
{
|
|
2562
|
-
"name": "
|
|
2629
|
+
"name": "BinArrayBitmapExtension",
|
|
2563
2630
|
"type": {
|
|
2564
2631
|
"kind": "struct",
|
|
2565
2632
|
"fields": [
|
|
@@ -2605,7 +2672,7 @@ var IDL = {
|
|
|
2605
2672
|
}
|
|
2606
2673
|
},
|
|
2607
2674
|
{
|
|
2608
|
-
"name": "
|
|
2675
|
+
"name": "BinArray",
|
|
2609
2676
|
"docs": [
|
|
2610
2677
|
"An account to contain a range of bin. For example: Bin 100 <-> 200.",
|
|
2611
2678
|
"For example:",
|
|
@@ -2654,7 +2721,7 @@ var IDL = {
|
|
|
2654
2721
|
}
|
|
2655
2722
|
},
|
|
2656
2723
|
{
|
|
2657
|
-
"name": "
|
|
2724
|
+
"name": "LbPair",
|
|
2658
2725
|
"type": {
|
|
2659
2726
|
"kind": "struct",
|
|
2660
2727
|
"fields": [
|
|
@@ -2902,7 +2969,7 @@ var IDL = {
|
|
|
2902
2969
|
}
|
|
2903
2970
|
},
|
|
2904
2971
|
{
|
|
2905
|
-
"name": "
|
|
2972
|
+
"name": "Oracle",
|
|
2906
2973
|
"type": {
|
|
2907
2974
|
"kind": "struct",
|
|
2908
2975
|
"fields": [
|
|
@@ -2931,7 +2998,7 @@ var IDL = {
|
|
|
2931
2998
|
}
|
|
2932
2999
|
},
|
|
2933
3000
|
{
|
|
2934
|
-
"name": "
|
|
3001
|
+
"name": "Position",
|
|
2935
3002
|
"type": {
|
|
2936
3003
|
"kind": "struct",
|
|
2937
3004
|
"fields": [
|
|
@@ -3052,7 +3119,7 @@ var IDL = {
|
|
|
3052
3119
|
}
|
|
3053
3120
|
},
|
|
3054
3121
|
{
|
|
3055
|
-
"name": "
|
|
3122
|
+
"name": "PositionV2",
|
|
3056
3123
|
"type": {
|
|
3057
3124
|
"kind": "struct",
|
|
3058
3125
|
"fields": [
|
|
@@ -3201,7 +3268,7 @@ var IDL = {
|
|
|
3201
3268
|
}
|
|
3202
3269
|
},
|
|
3203
3270
|
{
|
|
3204
|
-
"name": "
|
|
3271
|
+
"name": "PresetParameter",
|
|
3205
3272
|
"type": {
|
|
3206
3273
|
"kind": "struct",
|
|
3207
3274
|
"fields": [
|
|
@@ -3724,38 +3791,38 @@ var IDL = {
|
|
|
3724
3791
|
}
|
|
3725
3792
|
},
|
|
3726
3793
|
{
|
|
3727
|
-
"name": "
|
|
3794
|
+
"name": "FeeParameter",
|
|
3728
3795
|
"type": {
|
|
3729
3796
|
"kind": "struct",
|
|
3730
3797
|
"fields": [
|
|
3731
3798
|
{
|
|
3732
|
-
"name": "
|
|
3733
|
-
"
|
|
3799
|
+
"name": "protocolShare",
|
|
3800
|
+
"docs": [
|
|
3801
|
+
"Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee"
|
|
3802
|
+
],
|
|
3803
|
+
"type": "u16"
|
|
3734
3804
|
},
|
|
3735
3805
|
{
|
|
3736
|
-
"name": "
|
|
3806
|
+
"name": "baseFactor",
|
|
3807
|
+
"docs": [
|
|
3808
|
+
"Base factor for base fee rate"
|
|
3809
|
+
],
|
|
3737
3810
|
"type": "u16"
|
|
3738
3811
|
}
|
|
3739
3812
|
]
|
|
3740
3813
|
}
|
|
3741
3814
|
},
|
|
3742
3815
|
{
|
|
3743
|
-
"name": "
|
|
3816
|
+
"name": "BinLiquidityReduction",
|
|
3744
3817
|
"type": {
|
|
3745
3818
|
"kind": "struct",
|
|
3746
3819
|
"fields": [
|
|
3747
3820
|
{
|
|
3748
|
-
"name": "
|
|
3749
|
-
"
|
|
3750
|
-
"Portion of swap fees retained by the protocol by controlling protocol_share parameter. protocol_swap_fee = protocol_share * total_swap_fee"
|
|
3751
|
-
],
|
|
3752
|
-
"type": "u16"
|
|
3821
|
+
"name": "binId",
|
|
3822
|
+
"type": "i32"
|
|
3753
3823
|
},
|
|
3754
3824
|
{
|
|
3755
|
-
"name": "
|
|
3756
|
-
"docs": [
|
|
3757
|
-
"Base factor for base fee rate"
|
|
3758
|
-
],
|
|
3825
|
+
"name": "bpsToRemove",
|
|
3759
3826
|
"type": "u16"
|
|
3760
3827
|
}
|
|
3761
3828
|
]
|
|
@@ -7237,7 +7304,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
|
|
|
7237
7304
|
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _18 => _18.cluster]), () => ( "mainnet-beta"))],
|
|
7238
7305
|
provider
|
|
7239
7306
|
);
|
|
7240
|
-
const poolAccount = await program.account.
|
|
7307
|
+
const poolAccount = await program.account.LbPair.fetchNullable(
|
|
7241
7308
|
new (0, _web3js.PublicKey)(poolAddress)
|
|
7242
7309
|
);
|
|
7243
7310
|
if (!poolAccount)
|
|
@@ -7257,7 +7324,7 @@ function chunks(array, size) {
|
|
|
7257
7324
|
async function chunkedFetchMultiplePoolAccount(program, pks, chunkSize = 100) {
|
|
7258
7325
|
const accounts = (await Promise.all(
|
|
7259
7326
|
chunks(pks, chunkSize).map(
|
|
7260
|
-
(chunk) => program.account.
|
|
7327
|
+
(chunk) => program.account.LbPair.fetchMultiple(chunk)
|
|
7261
7328
|
)
|
|
7262
7329
|
)).flat();
|
|
7263
7330
|
return accounts.filter(Boolean);
|
|
@@ -7265,7 +7332,7 @@ async function chunkedFetchMultiplePoolAccount(program, pks, chunkSize = 100) {
|
|
|
7265
7332
|
async function chunkedFetchMultipleBinArrayBitmapExtensionAccount(program, pks, chunkSize = 100) {
|
|
7266
7333
|
const accounts = (await Promise.all(
|
|
7267
7334
|
chunks(pks, chunkSize).map(
|
|
7268
|
-
(chunk) => program.account.
|
|
7335
|
+
(chunk) => program.account.BinArrayBitmapExtension.fetchMultiple(chunk)
|
|
7269
7336
|
)
|
|
7270
7337
|
)).flat();
|
|
7271
7338
|
return accounts;
|
|
@@ -7407,7 +7474,7 @@ var DLMM = class {
|
|
|
7407
7474
|
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _22 => _22.cluster]), () => ( "mainnet-beta"))])),
|
|
7408
7475
|
provider
|
|
7409
7476
|
);
|
|
7410
|
-
return program.account.
|
|
7477
|
+
return program.account.LbPair.all();
|
|
7411
7478
|
}
|
|
7412
7479
|
static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
7413
7480
|
const cluster = _optionalChain([opt, 'optionalAccess', _23 => _23.cluster]) || "mainnet-beta";
|
|
@@ -7429,7 +7496,7 @@ var DLMM = class {
|
|
|
7429
7496
|
baseFactor,
|
|
7430
7497
|
program.programId
|
|
7431
7498
|
);
|
|
7432
|
-
const account2 = await program.account.
|
|
7499
|
+
const account2 = await program.account.LbPair.fetchNullable(lbPair2Key);
|
|
7433
7500
|
if (account2)
|
|
7434
7501
|
return lbPair2Key;
|
|
7435
7502
|
const [lbPairKey] = deriveLbPair(
|
|
@@ -7438,7 +7505,7 @@ var DLMM = class {
|
|
|
7438
7505
|
binStep,
|
|
7439
7506
|
program.programId
|
|
7440
7507
|
);
|
|
7441
|
-
const account = await program.account.
|
|
7508
|
+
const account = await program.account.LbPair.fetchNullable(lbPairKey);
|
|
7442
7509
|
if (account && account.parameters.baseFactor === baseFactor.toNumber()) {
|
|
7443
7510
|
return lbPairKey;
|
|
7444
7511
|
}
|
|
@@ -7669,7 +7736,7 @@ var DLMM = class {
|
|
|
7669
7736
|
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _37 => _37.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _38 => _38.cluster]), () => ( "mainnet-beta"))])),
|
|
7670
7737
|
provider
|
|
7671
7738
|
);
|
|
7672
|
-
const presetParameter = await program.account.
|
|
7739
|
+
const presetParameter = await program.account.PresetParameter.all();
|
|
7673
7740
|
return presetParameter;
|
|
7674
7741
|
}
|
|
7675
7742
|
/**
|
|
@@ -7696,7 +7763,7 @@ var DLMM = class {
|
|
|
7696
7763
|
provider
|
|
7697
7764
|
);
|
|
7698
7765
|
const [positions, positionsV2] = await Promise.all([
|
|
7699
|
-
program.account.
|
|
7766
|
+
program.account.Position.all([
|
|
7700
7767
|
{
|
|
7701
7768
|
memcmp: {
|
|
7702
7769
|
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
@@ -7704,7 +7771,7 @@ var DLMM = class {
|
|
|
7704
7771
|
}
|
|
7705
7772
|
}
|
|
7706
7773
|
]),
|
|
7707
|
-
program.account.
|
|
7774
|
+
program.account.PositionV2.all([
|
|
7708
7775
|
{
|
|
7709
7776
|
memcmp: {
|
|
7710
7777
|
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
@@ -8051,7 +8118,7 @@ var DLMM = class {
|
|
|
8051
8118
|
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _60 => _60.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
|
|
8052
8119
|
provider
|
|
8053
8120
|
);
|
|
8054
|
-
const positionsState = await program.account.
|
|
8121
|
+
const positionsState = await program.account.Position.fetchMultiple(
|
|
8055
8122
|
positions
|
|
8056
8123
|
);
|
|
8057
8124
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
@@ -8264,7 +8331,7 @@ var DLMM = class {
|
|
|
8264
8331
|
* @returns a Promise that resolves to an array of BinArrayAccount objects.
|
|
8265
8332
|
*/
|
|
8266
8333
|
async getBinArrays() {
|
|
8267
|
-
return this.program.account.
|
|
8334
|
+
return this.program.account.BinArray.all([
|
|
8268
8335
|
{
|
|
8269
8336
|
memcmp: {
|
|
8270
8337
|
bytes: _bytes.bs58.encode(this.pubkey.toBuffer()),
|
|
@@ -8493,7 +8560,7 @@ var DLMM = class {
|
|
|
8493
8560
|
* @returns an object with two properties: "binId" which is a number, and "price" which is a string.
|
|
8494
8561
|
*/
|
|
8495
8562
|
async getActiveBin() {
|
|
8496
|
-
const { activeId } = await this.program.account.
|
|
8563
|
+
const { activeId } = await this.program.account.LbPair.fetch(this.pubkey);
|
|
8497
8564
|
const [activeBinState] = await this.getBins(
|
|
8498
8565
|
this.pubkey,
|
|
8499
8566
|
activeId,
|
|
@@ -8543,7 +8610,7 @@ var DLMM = class {
|
|
|
8543
8610
|
async getPositionsByUserAndLbPair(userPubKey) {
|
|
8544
8611
|
const promiseResults = await Promise.all([
|
|
8545
8612
|
this.getActiveBin(),
|
|
8546
|
-
userPubKey && this.program.account.
|
|
8613
|
+
userPubKey && this.program.account.Position.all([
|
|
8547
8614
|
{
|
|
8548
8615
|
memcmp: {
|
|
8549
8616
|
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
@@ -8557,7 +8624,7 @@ var DLMM = class {
|
|
|
8557
8624
|
}
|
|
8558
8625
|
}
|
|
8559
8626
|
]),
|
|
8560
|
-
userPubKey && this.program.account.
|
|
8627
|
+
userPubKey && this.program.account.PositionV2.all([
|
|
8561
8628
|
{
|
|
8562
8629
|
memcmp: {
|
|
8563
8630
|
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
@@ -9244,7 +9311,7 @@ var DLMM = class {
|
|
|
9244
9311
|
slippage
|
|
9245
9312
|
}) {
|
|
9246
9313
|
const maxActiveBinSlippage = slippage ? Math.ceil(slippage / (this.lbPair.binStep / 100)) : MAX_ACTIVE_BIN_SLIPPAGE;
|
|
9247
|
-
const positionAccount = await this.program.account.
|
|
9314
|
+
const positionAccount = await this.program.account.PositionV2.fetch(
|
|
9248
9315
|
positionPubKey
|
|
9249
9316
|
);
|
|
9250
9317
|
const { lowerBinId, upperBinId, binIds } = this.processXYAmountDistribution(xYAmountDistribution);
|
|
@@ -9443,8 +9510,8 @@ var DLMM = class {
|
|
|
9443
9510
|
bps,
|
|
9444
9511
|
shouldClaimAndClose = false
|
|
9445
9512
|
}) {
|
|
9446
|
-
const { lbPair, lowerBinId, owner, feeOwner } = await this.program.account.
|
|
9447
|
-
const { reserveX, reserveY, tokenXMint, tokenYMint } = await this.program.account.
|
|
9513
|
+
const { lbPair, lowerBinId, owner, feeOwner } = await this.program.account.PositionV2.fetch(position);
|
|
9514
|
+
const { reserveX, reserveY, tokenXMint, tokenYMint } = await this.program.account.LbPair.fetch(lbPair);
|
|
9448
9515
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
9449
9516
|
const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(1));
|
|
9450
9517
|
const [binArrayLower] = deriveBinArray(
|
|
@@ -9604,6 +9671,77 @@ var DLMM = class {
|
|
|
9604
9671
|
}).add(removeLiquidityTx);
|
|
9605
9672
|
}
|
|
9606
9673
|
}
|
|
9674
|
+
async removeLiquiditySingleSide({
|
|
9675
|
+
user,
|
|
9676
|
+
position,
|
|
9677
|
+
binIds,
|
|
9678
|
+
removeLiquidityForY = false
|
|
9679
|
+
}) {
|
|
9680
|
+
const { lbPair, lowerBinId, owner, feeOwner } = await this.program.account.PositionV2.fetch(position);
|
|
9681
|
+
console.log("removeLiquidityFor2Y", removeLiquidityForY);
|
|
9682
|
+
const { reserveX, reserveY, tokenXMint, tokenYMint } = await this.program.account.LbPair.fetch(lbPair);
|
|
9683
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
9684
|
+
const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(1));
|
|
9685
|
+
const [binArrayLower] = deriveBinArray(
|
|
9686
|
+
lbPair,
|
|
9687
|
+
lowerBinArrayIndex,
|
|
9688
|
+
this.program.programId
|
|
9689
|
+
);
|
|
9690
|
+
const [binArrayUpper] = deriveBinArray(
|
|
9691
|
+
lbPair,
|
|
9692
|
+
upperBinArrayIndex,
|
|
9693
|
+
this.program.programId
|
|
9694
|
+
);
|
|
9695
|
+
const preInstructions = [];
|
|
9696
|
+
const setComputeUnitLimitIx = computeBudgetIx();
|
|
9697
|
+
preInstructions.push(setComputeUnitLimitIx);
|
|
9698
|
+
const { ataPubKey: userToken, ix: createPayerTokenIx } = removeLiquidityForY ? await getOrCreateATAInstruction(
|
|
9699
|
+
this.program.provider.connection,
|
|
9700
|
+
this.tokenY.publicKey,
|
|
9701
|
+
owner,
|
|
9702
|
+
user
|
|
9703
|
+
) : await getOrCreateATAInstruction(
|
|
9704
|
+
this.program.provider.connection,
|
|
9705
|
+
this.tokenX.publicKey,
|
|
9706
|
+
owner,
|
|
9707
|
+
user
|
|
9708
|
+
);
|
|
9709
|
+
createPayerTokenIx && preInstructions.push(createPayerTokenIx);
|
|
9710
|
+
const postInstructions = [];
|
|
9711
|
+
if ([
|
|
9712
|
+
this.tokenX.publicKey.toBase58(),
|
|
9713
|
+
this.tokenY.publicKey.toBase58()
|
|
9714
|
+
].includes(_spltoken.NATIVE_MINT.toBase58())) {
|
|
9715
|
+
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
9716
|
+
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
9717
|
+
}
|
|
9718
|
+
const minBinId = Math.min(...binIds);
|
|
9719
|
+
const maxBinId = Math.max(...binIds);
|
|
9720
|
+
const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
|
|
9721
|
+
const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
|
|
9722
|
+
const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
|
|
9723
|
+
const binArrayBitmapExtension = useExtension ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
|
|
9724
|
+
const reserve = removeLiquidityForY ? reserveY : reserveX;
|
|
9725
|
+
const tokenMint = removeLiquidityForY ? tokenYMint : tokenXMint;
|
|
9726
|
+
const removeLiquiditySingleSideTx = await this.program.methods.removeLiquiditySingleSide().accounts({
|
|
9727
|
+
position,
|
|
9728
|
+
lbPair,
|
|
9729
|
+
binArrayBitmapExtension,
|
|
9730
|
+
userToken,
|
|
9731
|
+
reserve,
|
|
9732
|
+
tokenMint,
|
|
9733
|
+
binArrayLower,
|
|
9734
|
+
binArrayUpper,
|
|
9735
|
+
sender: user,
|
|
9736
|
+
tokenProgram: _spltoken.TOKEN_PROGRAM_ID
|
|
9737
|
+
}).preInstructions(preInstructions).transaction();
|
|
9738
|
+
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
9739
|
+
return new (0, _web3js.Transaction)({
|
|
9740
|
+
blockhash,
|
|
9741
|
+
lastValidBlockHeight,
|
|
9742
|
+
feePayer: user
|
|
9743
|
+
}).add(removeLiquiditySingleSideTx);
|
|
9744
|
+
}
|
|
9607
9745
|
/**
|
|
9608
9746
|
* The `closePosition` function closes a position
|
|
9609
9747
|
* @param
|
|
@@ -9615,7 +9753,7 @@ var DLMM = class {
|
|
|
9615
9753
|
owner,
|
|
9616
9754
|
position
|
|
9617
9755
|
}) {
|
|
9618
|
-
const { lowerBinId } = await this.program.account.
|
|
9756
|
+
const { lowerBinId } = await this.program.account.PositionV2.fetch(
|
|
9619
9757
|
position.publicKey
|
|
9620
9758
|
);
|
|
9621
9759
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
@@ -9854,7 +9992,7 @@ var DLMM = class {
|
|
|
9854
9992
|
user,
|
|
9855
9993
|
binArraysPubkey
|
|
9856
9994
|
}) {
|
|
9857
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.
|
|
9995
|
+
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.LbPair.fetch(lbPair);
|
|
9858
9996
|
const preInstructions = [computeBudgetIx()];
|
|
9859
9997
|
const [
|
|
9860
9998
|
{ ataPubKey: userTokenIn, ix: createInTokenAccountIx },
|
|
@@ -9939,7 +10077,7 @@ var DLMM = class {
|
|
|
9939
10077
|
priceImpact,
|
|
9940
10078
|
binArraysPubkey
|
|
9941
10079
|
}) {
|
|
9942
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.
|
|
10080
|
+
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.LbPair.fetch(lbPair);
|
|
9943
10081
|
const preInstructions = [computeBudgetIx()];
|
|
9944
10082
|
const [
|
|
9945
10083
|
{ ataPubKey: userTokenIn, ix: createInTokenAccountIx },
|
|
@@ -10028,7 +10166,7 @@ var DLMM = class {
|
|
|
10028
10166
|
user,
|
|
10029
10167
|
binArraysPubkey
|
|
10030
10168
|
}) {
|
|
10031
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.
|
|
10169
|
+
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.LbPair.fetch(lbPair);
|
|
10032
10170
|
const preInstructions = [computeBudgetIx()];
|
|
10033
10171
|
const [
|
|
10034
10172
|
{ ataPubKey: userTokenIn, ix: createInTokenAccountIx },
|
|
@@ -10825,7 +10963,7 @@ var DLMM = class {
|
|
|
10825
10963
|
}
|
|
10826
10964
|
/** Private static method */
|
|
10827
10965
|
static async getBinArrays(program, lbPairPubkey) {
|
|
10828
|
-
return program.account.
|
|
10966
|
+
return program.account.BinArray.all([
|
|
10829
10967
|
{
|
|
10830
10968
|
memcmp: {
|
|
10831
10969
|
bytes: _bytes.bs58.encode(lbPairPubkey.toBuffer()),
|
|
@@ -10854,7 +10992,7 @@ var DLMM = class {
|
|
|
10854
10992
|
upperBinArrayIdx,
|
|
10855
10993
|
program.programId
|
|
10856
10994
|
);
|
|
10857
|
-
[_lowerBinArray, _upperBinArray] = await program.account.
|
|
10995
|
+
[_lowerBinArray, _upperBinArray] = await program.account.BinArray.fetchMultiple([
|
|
10858
10996
|
lowerBinArray2,
|
|
10859
10997
|
upperBinArray2
|
|
10860
10998
|
]);
|
|
@@ -10925,7 +11063,7 @@ var DLMM = class {
|
|
|
10925
11063
|
upperBinArrayIdx,
|
|
10926
11064
|
program.programId
|
|
10927
11065
|
);
|
|
10928
|
-
[_lowerBinArray, _upperBinArray] = await program.account.
|
|
11066
|
+
[_lowerBinArray, _upperBinArray] = await program.account.BinArray.fetchMultiple([
|
|
10929
11067
|
lowerBinArray2,
|
|
10930
11068
|
upperBinArray2
|
|
10931
11069
|
]);
|
|
@@ -11130,7 +11268,7 @@ var DLMM = class {
|
|
|
11130
11268
|
lowerBinArrayIndex,
|
|
11131
11269
|
this.program.programId
|
|
11132
11270
|
);
|
|
11133
|
-
const binArray = await _asyncNullishCoalesce(lowerBinArrays, async () => ( await this.program.account.
|
|
11271
|
+
const binArray = await _asyncNullishCoalesce(lowerBinArrays, async () => ( await this.program.account.BinArray.fetch(binArrayPubKey).catch(() => {
|
|
11134
11272
|
const [lowerBinId2, upperBinId2] = getBinArrayLowerUpperBinId(lowerBinArrayIndex);
|
|
11135
11273
|
const binArrayBins = [];
|
|
11136
11274
|
for (let i = lowerBinId2.toNumber(); i <= upperBinId2.toNumber(); i++) {
|
|
@@ -11185,7 +11323,7 @@ var DLMM = class {
|
|
|
11185
11323
|
);
|
|
11186
11324
|
const binArrays = await (async () => {
|
|
11187
11325
|
if (!lowerBinArrays || !upperBinArrays) {
|
|
11188
|
-
return (await this.program.account.
|
|
11326
|
+
return (await this.program.account.BinArray.fetchMultiple([
|
|
11189
11327
|
lowerBinArrayPubKey,
|
|
11190
11328
|
upperBinArrayPubKey
|
|
11191
11329
|
])).filter((binArray) => binArray !== null);
|