@meteora-ag/dlmm 1.3.14-sam.0 → 1.3.17-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +247 -103
- package/dist/index.js +748 -559
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +754 -565
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -9,6 +9,8 @@ var _bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
|
|
13
|
+
|
|
12
14
|
var _spltoken = require('@solana/spl-token');
|
|
13
15
|
|
|
14
16
|
|
|
@@ -25,7 +27,7 @@ var _decimaljs = require('decimal.js'); var _decimaljs2 = _interopRequireDefault
|
|
|
25
27
|
|
|
26
28
|
// src/dlmm/idl.ts
|
|
27
29
|
var IDL = {
|
|
28
|
-
"version": "0.8.
|
|
30
|
+
"version": "0.8.6",
|
|
29
31
|
"name": "lb_clmm",
|
|
30
32
|
"constants": [
|
|
31
33
|
{
|
|
@@ -113,6 +115,16 @@ var IDL = {
|
|
|
113
115
|
},
|
|
114
116
|
"value": "15"
|
|
115
117
|
},
|
|
118
|
+
{
|
|
119
|
+
"name": "ILM_PROTOCOL_SHARE",
|
|
120
|
+
"type": "u16",
|
|
121
|
+
"value": "2000"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "PROTOCOL_SHARE",
|
|
125
|
+
"type": "u16",
|
|
126
|
+
"value": "500"
|
|
127
|
+
},
|
|
116
128
|
{
|
|
117
129
|
"name": "MAX_BIN_STEP",
|
|
118
130
|
"type": "u16",
|
|
@@ -128,6 +140,11 @@ var IDL = {
|
|
|
128
140
|
"type": "u128",
|
|
129
141
|
"value": "100_000"
|
|
130
142
|
},
|
|
143
|
+
{
|
|
144
|
+
"name": "MINIMUM_LIQUIDITY",
|
|
145
|
+
"type": "u128",
|
|
146
|
+
"value": "1_000_000"
|
|
147
|
+
},
|
|
131
148
|
{
|
|
132
149
|
"name": "BIN_ARRAY",
|
|
133
150
|
"type": "bytes",
|
|
@@ -385,7 +402,7 @@ var IDL = {
|
|
|
385
402
|
"isSigner": false
|
|
386
403
|
},
|
|
387
404
|
{
|
|
388
|
-
"name": "
|
|
405
|
+
"name": "userTokenY",
|
|
389
406
|
"isMut": false,
|
|
390
407
|
"isSigner": false
|
|
391
408
|
},
|
|
@@ -1964,7 +1981,40 @@ var IDL = {
|
|
|
1964
1981
|
"args": []
|
|
1965
1982
|
},
|
|
1966
1983
|
{
|
|
1967
|
-
"name": "
|
|
1984
|
+
"name": "updateBaseFeeParameters",
|
|
1985
|
+
"accounts": [
|
|
1986
|
+
{
|
|
1987
|
+
"name": "lbPair",
|
|
1988
|
+
"isMut": true,
|
|
1989
|
+
"isSigner": false
|
|
1990
|
+
},
|
|
1991
|
+
{
|
|
1992
|
+
"name": "admin",
|
|
1993
|
+
"isMut": false,
|
|
1994
|
+
"isSigner": true
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
"name": "eventAuthority",
|
|
1998
|
+
"isMut": false,
|
|
1999
|
+
"isSigner": false
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
"name": "program",
|
|
2003
|
+
"isMut": false,
|
|
2004
|
+
"isSigner": false
|
|
2005
|
+
}
|
|
2006
|
+
],
|
|
2007
|
+
"args": [
|
|
2008
|
+
{
|
|
2009
|
+
"name": "feeParameter",
|
|
2010
|
+
"type": {
|
|
2011
|
+
"defined": "BaseFeeParameter"
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
]
|
|
2015
|
+
},
|
|
2016
|
+
{
|
|
2017
|
+
"name": "updateDynamicFeeParameters",
|
|
1968
2018
|
"accounts": [
|
|
1969
2019
|
{
|
|
1970
2020
|
"name": "lbPair",
|
|
@@ -1991,7 +2041,7 @@ var IDL = {
|
|
|
1991
2041
|
{
|
|
1992
2042
|
"name": "feeParameter",
|
|
1993
2043
|
"type": {
|
|
1994
|
-
"defined": "
|
|
2044
|
+
"defined": "DynamicFeeParameter"
|
|
1995
2045
|
}
|
|
1996
2046
|
}
|
|
1997
2047
|
]
|
|
@@ -2174,7 +2224,7 @@ var IDL = {
|
|
|
2174
2224
|
"args": []
|
|
2175
2225
|
},
|
|
2176
2226
|
{
|
|
2177
|
-
"name": "
|
|
2227
|
+
"name": "setPairStatus",
|
|
2178
2228
|
"accounts": [
|
|
2179
2229
|
{
|
|
2180
2230
|
"name": "lbPair",
|
|
@@ -2187,7 +2237,12 @@ var IDL = {
|
|
|
2187
2237
|
"isSigner": true
|
|
2188
2238
|
}
|
|
2189
2239
|
],
|
|
2190
|
-
"args": [
|
|
2240
|
+
"args": [
|
|
2241
|
+
{
|
|
2242
|
+
"name": "status",
|
|
2243
|
+
"type": "u8"
|
|
2244
|
+
}
|
|
2245
|
+
]
|
|
2191
2246
|
},
|
|
2192
2247
|
{
|
|
2193
2248
|
"name": "migratePosition",
|
|
@@ -2623,6 +2678,27 @@ var IDL = {
|
|
|
2623
2678
|
"type": "publicKey"
|
|
2624
2679
|
}
|
|
2625
2680
|
]
|
|
2681
|
+
},
|
|
2682
|
+
{
|
|
2683
|
+
"name": "setPairStatusPermissionless",
|
|
2684
|
+
"accounts": [
|
|
2685
|
+
{
|
|
2686
|
+
"name": "lbPair",
|
|
2687
|
+
"isMut": true,
|
|
2688
|
+
"isSigner": false
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
"name": "creator",
|
|
2692
|
+
"isMut": false,
|
|
2693
|
+
"isSigner": true
|
|
2694
|
+
}
|
|
2695
|
+
],
|
|
2696
|
+
"args": [
|
|
2697
|
+
{
|
|
2698
|
+
"name": "status",
|
|
2699
|
+
"type": "u8"
|
|
2700
|
+
}
|
|
2701
|
+
]
|
|
2626
2702
|
}
|
|
2627
2703
|
],
|
|
2628
2704
|
"accounts": [
|
|
@@ -2814,9 +2890,9 @@ var IDL = {
|
|
|
2814
2890
|
"type": "u8"
|
|
2815
2891
|
},
|
|
2816
2892
|
{
|
|
2817
|
-
"name": "
|
|
2893
|
+
"name": "creatorPoolOnOffControl",
|
|
2818
2894
|
"docs": [
|
|
2819
|
-
"
|
|
2895
|
+
"Allow pool creator to enable/disable pool with restricted validation. Only applicable for customizable permissionless pair type."
|
|
2820
2896
|
],
|
|
2821
2897
|
"type": "u8"
|
|
2822
2898
|
},
|
|
@@ -3448,7 +3524,7 @@ var IDL = {
|
|
|
3448
3524
|
}
|
|
3449
3525
|
},
|
|
3450
3526
|
{
|
|
3451
|
-
"name": "
|
|
3527
|
+
"name": "BaseFeeParameter",
|
|
3452
3528
|
"type": {
|
|
3453
3529
|
"kind": "struct",
|
|
3454
3530
|
"fields": [
|
|
@@ -3469,6 +3545,49 @@ var IDL = {
|
|
|
3469
3545
|
]
|
|
3470
3546
|
}
|
|
3471
3547
|
},
|
|
3548
|
+
{
|
|
3549
|
+
"name": "DynamicFeeParameter",
|
|
3550
|
+
"type": {
|
|
3551
|
+
"kind": "struct",
|
|
3552
|
+
"fields": [
|
|
3553
|
+
{
|
|
3554
|
+
"name": "filterPeriod",
|
|
3555
|
+
"docs": [
|
|
3556
|
+
"Filter period determine high frequency trading time window."
|
|
3557
|
+
],
|
|
3558
|
+
"type": "u16"
|
|
3559
|
+
},
|
|
3560
|
+
{
|
|
3561
|
+
"name": "decayPeriod",
|
|
3562
|
+
"docs": [
|
|
3563
|
+
"Decay period determine when the volatile fee start decay / decrease."
|
|
3564
|
+
],
|
|
3565
|
+
"type": "u16"
|
|
3566
|
+
},
|
|
3567
|
+
{
|
|
3568
|
+
"name": "reductionFactor",
|
|
3569
|
+
"docs": [
|
|
3570
|
+
"Reduction factor controls the volatile fee rate decrement rate."
|
|
3571
|
+
],
|
|
3572
|
+
"type": "u16"
|
|
3573
|
+
},
|
|
3574
|
+
{
|
|
3575
|
+
"name": "variableFeeControl",
|
|
3576
|
+
"docs": [
|
|
3577
|
+
"Used to scale the variable fee component depending on the dynamic of the market"
|
|
3578
|
+
],
|
|
3579
|
+
"type": "u32"
|
|
3580
|
+
},
|
|
3581
|
+
{
|
|
3582
|
+
"name": "maxVolatilityAccumulator",
|
|
3583
|
+
"docs": [
|
|
3584
|
+
"Maximum number of bin crossed can be accumulated. Used to cap volatile fee rate."
|
|
3585
|
+
],
|
|
3586
|
+
"type": "u32"
|
|
3587
|
+
}
|
|
3588
|
+
]
|
|
3589
|
+
}
|
|
3590
|
+
},
|
|
3472
3591
|
{
|
|
3473
3592
|
"name": "LiquidityParameterByStrategyOneSide",
|
|
3474
3593
|
"type": {
|
|
@@ -3851,6 +3970,13 @@ var IDL = {
|
|
|
3851
3970
|
"option": "u64"
|
|
3852
3971
|
}
|
|
3853
3972
|
},
|
|
3973
|
+
{
|
|
3974
|
+
"name": "creatorPoolOnOffControl",
|
|
3975
|
+
"docs": [
|
|
3976
|
+
"Pool creator have permission to enable/disable pool with restricted program validation. Only applicable for customizable permissionless pool."
|
|
3977
|
+
],
|
|
3978
|
+
"type": "bool"
|
|
3979
|
+
},
|
|
3854
3980
|
{
|
|
3855
3981
|
"name": "padding",
|
|
3856
3982
|
"docs": [
|
|
@@ -3859,7 +3985,7 @@ var IDL = {
|
|
|
3859
3985
|
"type": {
|
|
3860
3986
|
"array": [
|
|
3861
3987
|
"u8",
|
|
3862
|
-
|
|
3988
|
+
63
|
|
3863
3989
|
]
|
|
3864
3990
|
}
|
|
3865
3991
|
}
|
|
@@ -4834,6 +4960,41 @@ var IDL = {
|
|
|
4834
4960
|
}
|
|
4835
4961
|
]
|
|
4836
4962
|
},
|
|
4963
|
+
{
|
|
4964
|
+
"name": "DynamicFeeParameterUpdate",
|
|
4965
|
+
"fields": [
|
|
4966
|
+
{
|
|
4967
|
+
"name": "lbPair",
|
|
4968
|
+
"type": "publicKey",
|
|
4969
|
+
"index": false
|
|
4970
|
+
},
|
|
4971
|
+
{
|
|
4972
|
+
"name": "filterPeriod",
|
|
4973
|
+
"type": "u16",
|
|
4974
|
+
"index": false
|
|
4975
|
+
},
|
|
4976
|
+
{
|
|
4977
|
+
"name": "decayPeriod",
|
|
4978
|
+
"type": "u16",
|
|
4979
|
+
"index": false
|
|
4980
|
+
},
|
|
4981
|
+
{
|
|
4982
|
+
"name": "reductionFactor",
|
|
4983
|
+
"type": "u16",
|
|
4984
|
+
"index": false
|
|
4985
|
+
},
|
|
4986
|
+
{
|
|
4987
|
+
"name": "variableFeeControl",
|
|
4988
|
+
"type": "u32",
|
|
4989
|
+
"index": false
|
|
4990
|
+
},
|
|
4991
|
+
{
|
|
4992
|
+
"name": "maxVolatilityAccumulator",
|
|
4993
|
+
"type": "u32",
|
|
4994
|
+
"index": false
|
|
4995
|
+
}
|
|
4996
|
+
]
|
|
4997
|
+
},
|
|
4837
4998
|
{
|
|
4838
4999
|
"name": "IncreaseObservation",
|
|
4839
5000
|
"fields": [
|
|
@@ -5270,6 +5431,21 @@ var IDL = {
|
|
|
5270
5431
|
"code": 6065,
|
|
5271
5432
|
"name": "AlreadyPassPreActivationSwapPoint",
|
|
5272
5433
|
"msg": "Already pass pre-activation swap point"
|
|
5434
|
+
},
|
|
5435
|
+
{
|
|
5436
|
+
"code": 6066,
|
|
5437
|
+
"name": "InvalidStatus",
|
|
5438
|
+
"msg": "Invalid status"
|
|
5439
|
+
},
|
|
5440
|
+
{
|
|
5441
|
+
"code": 6067,
|
|
5442
|
+
"name": "ExceededMaxOracleLength",
|
|
5443
|
+
"msg": "Exceed max oracle length"
|
|
5444
|
+
},
|
|
5445
|
+
{
|
|
5446
|
+
"code": 6068,
|
|
5447
|
+
"name": "InvalidMinimumLiquidity",
|
|
5448
|
+
"msg": "Invalid minimum liquidity"
|
|
5273
5449
|
}
|
|
5274
5450
|
]
|
|
5275
5451
|
};
|
|
@@ -5303,6 +5479,7 @@ var CONSTANTS = Object.entries(IDL.constants);
|
|
|
5303
5479
|
var MAX_BIN_ARRAY_SIZE = new (0, _anchor.BN)(
|
|
5304
5480
|
_nullishCoalesce(_optionalChain([CONSTANTS, 'access', _2 => _2.find, 'call', _3 => _3(([k, v]) => v.name == "MAX_BIN_PER_ARRAY"), 'optionalAccess', _4 => _4[1], 'access', _5 => _5.value]), () => ( 0))
|
|
5305
5481
|
);
|
|
5482
|
+
console.log("CONSTANTS", CONSTANTS);
|
|
5306
5483
|
var MAX_BIN_PER_POSITION = new (0, _anchor.BN)(
|
|
5307
5484
|
_nullishCoalesce(_optionalChain([CONSTANTS, 'access', _6 => _6.find, 'call', _7 => _7(([k, v]) => v.name == "MAX_BIN_PER_POSITION"), 'optionalAccess', _8 => _8[1], 'access', _9 => _9.value]), () => ( 0))
|
|
5308
5485
|
);
|
|
@@ -5323,6 +5500,7 @@ var MAX_ACTIVE_BIN_SLIPPAGE = 3;
|
|
|
5323
5500
|
var ILM_BASE = new (0, _web3js.PublicKey)(
|
|
5324
5501
|
"MFGQxwAmB91SwuYX36okv2Qmdc9aMuHTwWGUrp4AtB1"
|
|
5325
5502
|
);
|
|
5503
|
+
var MAX_EXTRA_BIN_ARRAYS = 3;
|
|
5326
5504
|
|
|
5327
5505
|
// src/dlmm/error.ts
|
|
5328
5506
|
|
|
@@ -6341,13 +6519,42 @@ function generateBinAmount(amount, binStep, binId, tokenXDecimal, tokenYDecimal,
|
|
|
6341
6519
|
return new (0, _anchor.BN)(c1.sub(c0).floor().toString());
|
|
6342
6520
|
}
|
|
6343
6521
|
|
|
6344
|
-
// src/dlmm/helpers/index.ts
|
|
6345
|
-
var _helpers = require('@solana-developers/helpers');
|
|
6346
|
-
|
|
6347
6522
|
// src/dlmm/helpers/computeUnit.ts
|
|
6523
|
+
|
|
6348
6524
|
var DEFAULT_ADD_LIQUIDITY_CU = 8e5;
|
|
6349
6525
|
var MIN_CU_BUFFER = 5e4;
|
|
6350
6526
|
var MAX_CU_BUFFER = 2e5;
|
|
6527
|
+
var getSimulationComputeUnits = async (connection, instructions, payer, lookupTables, commitment = "confirmed") => {
|
|
6528
|
+
const testInstructions = [
|
|
6529
|
+
// Set an arbitrarily high number in simulation
|
|
6530
|
+
// so we can be sure the transaction will succeed
|
|
6531
|
+
// and get the real compute units used
|
|
6532
|
+
_web3js.ComputeBudgetProgram.setComputeUnitLimit({ units: 14e5 }),
|
|
6533
|
+
...instructions
|
|
6534
|
+
];
|
|
6535
|
+
const testTransaction = new (0, _web3js.VersionedTransaction)(
|
|
6536
|
+
new (0, _web3js.TransactionMessage)({
|
|
6537
|
+
instructions: testInstructions,
|
|
6538
|
+
payerKey: payer,
|
|
6539
|
+
// RecentBlockhash can by any public key during simulation
|
|
6540
|
+
// since 'replaceRecentBlockhash' is set to 'true' below
|
|
6541
|
+
recentBlockhash: _web3js.PublicKey.default.toString()
|
|
6542
|
+
}).compileToV0Message(lookupTables)
|
|
6543
|
+
);
|
|
6544
|
+
const rpcResponse = await connection.simulateTransaction(testTransaction, {
|
|
6545
|
+
replaceRecentBlockhash: true,
|
|
6546
|
+
sigVerify: false,
|
|
6547
|
+
commitment
|
|
6548
|
+
});
|
|
6549
|
+
if (_optionalChain([rpcResponse, 'optionalAccess', _21 => _21.value, 'optionalAccess', _22 => _22.err])) {
|
|
6550
|
+
const logs = _optionalChain([rpcResponse, 'access', _23 => _23.value, 'access', _24 => _24.logs, 'optionalAccess', _25 => _25.join, 'call', _26 => _26("\n \u2022 ")]) || "No logs available";
|
|
6551
|
+
throw new Error(
|
|
6552
|
+
`Transaction simulation failed:
|
|
6553
|
+
\u2022${logs}` + JSON.stringify(_optionalChain([rpcResponse, 'optionalAccess', _27 => _27.value, 'optionalAccess', _28 => _28.err]))
|
|
6554
|
+
);
|
|
6555
|
+
}
|
|
6556
|
+
return rpcResponse.value.unitsConsumed || null;
|
|
6557
|
+
};
|
|
6351
6558
|
|
|
6352
6559
|
// src/dlmm/helpers/derive.ts
|
|
6353
6560
|
|
|
@@ -6437,7 +6644,7 @@ function derivePosition(lbPair, base, lowerBinId, width, programId) {
|
|
|
6437
6644
|
lbPair.toBuffer(),
|
|
6438
6645
|
base.toBuffer(),
|
|
6439
6646
|
lowerBinIdBytes,
|
|
6440
|
-
new Uint8Array(width.
|
|
6647
|
+
new Uint8Array(width.toArrayLike(Buffer, "le", 4))
|
|
6441
6648
|
],
|
|
6442
6649
|
programId
|
|
6443
6650
|
);
|
|
@@ -6484,9 +6691,6 @@ var PairType = /* @__PURE__ */ ((PairType2) => {
|
|
|
6484
6691
|
return PairType2;
|
|
6485
6692
|
})(PairType || {});
|
|
6486
6693
|
var Strategy = {
|
|
6487
|
-
SpotOneSide: { spotOneSide: {} },
|
|
6488
|
-
CurveOneSide: { curveOneSide: {} },
|
|
6489
|
-
BidAskOneSide: { bidAskOneSide: {} },
|
|
6490
6694
|
SpotBalanced: { spotBalanced: {} },
|
|
6491
6695
|
CurveBalanced: { curveBalanced: {} },
|
|
6492
6696
|
BidAskBalanced: { bidAskBalanced: {} },
|
|
@@ -6495,15 +6699,12 @@ var Strategy = {
|
|
|
6495
6699
|
BidAskImBalanced: { bidAskImBalanced: {} }
|
|
6496
6700
|
};
|
|
6497
6701
|
var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
|
|
6498
|
-
StrategyType2[StrategyType2["
|
|
6499
|
-
StrategyType2[StrategyType2["
|
|
6500
|
-
StrategyType2[StrategyType2["
|
|
6501
|
-
StrategyType2[StrategyType2["
|
|
6502
|
-
StrategyType2[StrategyType2["
|
|
6503
|
-
StrategyType2[StrategyType2["
|
|
6504
|
-
StrategyType2[StrategyType2["SpotBalanced"] = 6] = "SpotBalanced";
|
|
6505
|
-
StrategyType2[StrategyType2["CurveBalanced"] = 7] = "CurveBalanced";
|
|
6506
|
-
StrategyType2[StrategyType2["BidAskBalanced"] = 8] = "BidAskBalanced";
|
|
6702
|
+
StrategyType2[StrategyType2["SpotImBalanced"] = 0] = "SpotImBalanced";
|
|
6703
|
+
StrategyType2[StrategyType2["CurveImBalanced"] = 1] = "CurveImBalanced";
|
|
6704
|
+
StrategyType2[StrategyType2["BidAskImBalanced"] = 2] = "BidAskImBalanced";
|
|
6705
|
+
StrategyType2[StrategyType2["SpotBalanced"] = 3] = "SpotBalanced";
|
|
6706
|
+
StrategyType2[StrategyType2["CurveBalanced"] = 4] = "CurveBalanced";
|
|
6707
|
+
StrategyType2[StrategyType2["BidAskBalanced"] = 5] = "BidAskBalanced";
|
|
6507
6708
|
return StrategyType2;
|
|
6508
6709
|
})(StrategyType || {});
|
|
6509
6710
|
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
@@ -7055,53 +7256,10 @@ function toWeightBidAsk(minBinId, maxBinId, activeId) {
|
|
|
7055
7256
|
}
|
|
7056
7257
|
return distributions;
|
|
7057
7258
|
}
|
|
7058
|
-
function toAmountsOneSideByStrategy(activeId, binStep, minBinId, maxBinId, amount, strategyType, depositForY) {
|
|
7059
|
-
let weights = [];
|
|
7060
|
-
switch (strategyType) {
|
|
7061
|
-
case 6 /* SpotBalanced */:
|
|
7062
|
-
case 7 /* CurveBalanced */:
|
|
7063
|
-
case 8 /* BidAskBalanced */:
|
|
7064
|
-
case 3 /* SpotImBalanced */:
|
|
7065
|
-
case 4 /* CurveImBalanced */:
|
|
7066
|
-
case 5 /* BidAskImBalanced */: {
|
|
7067
|
-
throw "Invalid Strategy Parameters";
|
|
7068
|
-
}
|
|
7069
|
-
case 0 /* SpotOneSide */: {
|
|
7070
|
-
weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7071
|
-
break;
|
|
7072
|
-
}
|
|
7073
|
-
case 1 /* CurveOneSide */: {
|
|
7074
|
-
if (depositForY) {
|
|
7075
|
-
weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
7076
|
-
} else {
|
|
7077
|
-
weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
7078
|
-
}
|
|
7079
|
-
break;
|
|
7080
|
-
}
|
|
7081
|
-
case 2 /* BidAskOneSide */: {
|
|
7082
|
-
if (depositForY) {
|
|
7083
|
-
weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
7084
|
-
} else {
|
|
7085
|
-
weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
7086
|
-
}
|
|
7087
|
-
break;
|
|
7088
|
-
}
|
|
7089
|
-
}
|
|
7090
|
-
if (depositForY) {
|
|
7091
|
-
return toAmountBidSide(activeId, amount, weights);
|
|
7092
|
-
} else {
|
|
7093
|
-
return toAmountAskSide(activeId, binStep, amount, weights);
|
|
7094
|
-
}
|
|
7095
|
-
}
|
|
7096
7259
|
function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amountX, amountY, amountXInActiveBin, amountYInActiveBin, strategyType) {
|
|
7097
7260
|
const isSingleSideX = amountY.isZero();
|
|
7098
7261
|
switch (strategyType) {
|
|
7099
|
-
case 0 /*
|
|
7100
|
-
case 1 /* CurveOneSide */:
|
|
7101
|
-
case 2 /* BidAskOneSide */: {
|
|
7102
|
-
throw "Invalid Strategy Parameters";
|
|
7103
|
-
}
|
|
7104
|
-
case 3 /* SpotImBalanced */: {
|
|
7262
|
+
case 0 /* SpotImBalanced */: {
|
|
7105
7263
|
if (activeId < minBinId || activeId > maxBinId) {
|
|
7106
7264
|
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7107
7265
|
return toAmountBothSide(
|
|
@@ -7173,7 +7331,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7173
7331
|
}
|
|
7174
7332
|
return amountsInBin;
|
|
7175
7333
|
}
|
|
7176
|
-
case
|
|
7334
|
+
case 1 /* CurveImBalanced */: {
|
|
7177
7335
|
if (activeId < minBinId) {
|
|
7178
7336
|
let weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
7179
7337
|
return toAmountBothSide(
|
|
@@ -7257,7 +7415,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7257
7415
|
}
|
|
7258
7416
|
return amountsInBin;
|
|
7259
7417
|
}
|
|
7260
|
-
case
|
|
7418
|
+
case 2 /* BidAskImBalanced */: {
|
|
7261
7419
|
if (activeId < minBinId) {
|
|
7262
7420
|
const weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
7263
7421
|
return toAmountBothSide(
|
|
@@ -7341,7 +7499,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7341
7499
|
}
|
|
7342
7500
|
return amountsInBin;
|
|
7343
7501
|
}
|
|
7344
|
-
case
|
|
7502
|
+
case 3 /* SpotBalanced */: {
|
|
7345
7503
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7346
7504
|
return toAmountBothSide(
|
|
7347
7505
|
activeId,
|
|
@@ -7353,7 +7511,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7353
7511
|
weights
|
|
7354
7512
|
);
|
|
7355
7513
|
}
|
|
7356
|
-
case
|
|
7514
|
+
case 4 /* CurveBalanced */: {
|
|
7357
7515
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7358
7516
|
return toAmountBothSide(
|
|
7359
7517
|
activeId,
|
|
@@ -7365,7 +7523,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7365
7523
|
weights
|
|
7366
7524
|
);
|
|
7367
7525
|
}
|
|
7368
|
-
case
|
|
7526
|
+
case 5 /* BidAskBalanced */: {
|
|
7369
7527
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7370
7528
|
return toAmountBothSide(
|
|
7371
7529
|
activeId,
|
|
@@ -7381,15 +7539,12 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7381
7539
|
}
|
|
7382
7540
|
function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
7383
7541
|
switch (strategyType) {
|
|
7384
|
-
case 0 /*
|
|
7385
|
-
case 1 /*
|
|
7386
|
-
case 2 /*
|
|
7387
|
-
case 3 /* SpotImBalanced */:
|
|
7388
|
-
case 4 /* CurveImBalanced */:
|
|
7389
|
-
case 5 /* BidAskImBalanced */: {
|
|
7542
|
+
case 0 /* SpotImBalanced */:
|
|
7543
|
+
case 1 /* CurveImBalanced */:
|
|
7544
|
+
case 2 /* BidAskImBalanced */: {
|
|
7390
7545
|
throw "Invalid Strategy Parameters";
|
|
7391
7546
|
}
|
|
7392
|
-
case
|
|
7547
|
+
case 3 /* SpotBalanced */: {
|
|
7393
7548
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7394
7549
|
return autoFillYByWeight(
|
|
7395
7550
|
activeId,
|
|
@@ -7400,7 +7555,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7400
7555
|
weights
|
|
7401
7556
|
);
|
|
7402
7557
|
}
|
|
7403
|
-
case
|
|
7558
|
+
case 4 /* CurveBalanced */: {
|
|
7404
7559
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7405
7560
|
return autoFillYByWeight(
|
|
7406
7561
|
activeId,
|
|
@@ -7411,7 +7566,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7411
7566
|
weights
|
|
7412
7567
|
);
|
|
7413
7568
|
}
|
|
7414
|
-
case
|
|
7569
|
+
case 5 /* BidAskBalanced */: {
|
|
7415
7570
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7416
7571
|
return autoFillYByWeight(
|
|
7417
7572
|
activeId,
|
|
@@ -7426,15 +7581,12 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7426
7581
|
}
|
|
7427
7582
|
function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
7428
7583
|
switch (strategyType) {
|
|
7429
|
-
case 0 /*
|
|
7430
|
-
case 1 /*
|
|
7431
|
-
case 2 /*
|
|
7432
|
-
case 3 /* SpotImBalanced */:
|
|
7433
|
-
case 4 /* CurveImBalanced */:
|
|
7434
|
-
case 5 /* BidAskImBalanced */: {
|
|
7584
|
+
case 0 /* SpotImBalanced */:
|
|
7585
|
+
case 1 /* CurveImBalanced */:
|
|
7586
|
+
case 2 /* BidAskImBalanced */: {
|
|
7435
7587
|
throw "Invalid Strategy Parameters";
|
|
7436
7588
|
}
|
|
7437
|
-
case
|
|
7589
|
+
case 3 /* SpotBalanced */: {
|
|
7438
7590
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7439
7591
|
return autoFillXByWeight(
|
|
7440
7592
|
activeId,
|
|
@@ -7445,7 +7597,7 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
7445
7597
|
weights
|
|
7446
7598
|
);
|
|
7447
7599
|
}
|
|
7448
|
-
case
|
|
7600
|
+
case 4 /* CurveBalanced */: {
|
|
7449
7601
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7450
7602
|
return autoFillXByWeight(
|
|
7451
7603
|
activeId,
|
|
@@ -7456,7 +7608,7 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
7456
7608
|
weights
|
|
7457
7609
|
);
|
|
7458
7610
|
}
|
|
7459
|
-
case
|
|
7611
|
+
case 5 /* BidAskBalanced */: {
|
|
7460
7612
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7461
7613
|
return autoFillXByWeight(
|
|
7462
7614
|
activeId,
|
|
@@ -7477,31 +7629,7 @@ function toStrategyParameters({
|
|
|
7477
7629
|
}) {
|
|
7478
7630
|
const parameters = [singleSidedX ? 1 : 0, ...new Array(63).fill(0)];
|
|
7479
7631
|
switch (strategyType) {
|
|
7480
|
-
case
|
|
7481
|
-
return {
|
|
7482
|
-
minBinId,
|
|
7483
|
-
maxBinId,
|
|
7484
|
-
strategyType: { spotOneSide: {} },
|
|
7485
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7486
|
-
};
|
|
7487
|
-
}
|
|
7488
|
-
case 1 /* CurveOneSide */: {
|
|
7489
|
-
return {
|
|
7490
|
-
minBinId,
|
|
7491
|
-
maxBinId,
|
|
7492
|
-
strategyType: { curveOneSide: {} },
|
|
7493
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7494
|
-
};
|
|
7495
|
-
}
|
|
7496
|
-
case 2 /* BidAskOneSide */: {
|
|
7497
|
-
return {
|
|
7498
|
-
minBinId,
|
|
7499
|
-
maxBinId,
|
|
7500
|
-
strategyType: { bidAskOneSide: {} },
|
|
7501
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7502
|
-
};
|
|
7503
|
-
}
|
|
7504
|
-
case 6 /* SpotBalanced */: {
|
|
7632
|
+
case 3 /* SpotBalanced */: {
|
|
7505
7633
|
return {
|
|
7506
7634
|
minBinId,
|
|
7507
7635
|
maxBinId,
|
|
@@ -7509,7 +7637,7 @@ function toStrategyParameters({
|
|
|
7509
7637
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7510
7638
|
};
|
|
7511
7639
|
}
|
|
7512
|
-
case
|
|
7640
|
+
case 4 /* CurveBalanced */: {
|
|
7513
7641
|
return {
|
|
7514
7642
|
minBinId,
|
|
7515
7643
|
maxBinId,
|
|
@@ -7517,7 +7645,7 @@ function toStrategyParameters({
|
|
|
7517
7645
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7518
7646
|
};
|
|
7519
7647
|
}
|
|
7520
|
-
case
|
|
7648
|
+
case 5 /* BidAskBalanced */: {
|
|
7521
7649
|
return {
|
|
7522
7650
|
minBinId,
|
|
7523
7651
|
maxBinId,
|
|
@@ -7525,7 +7653,7 @@ function toStrategyParameters({
|
|
|
7525
7653
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7526
7654
|
};
|
|
7527
7655
|
}
|
|
7528
|
-
case
|
|
7656
|
+
case 0 /* SpotImBalanced */: {
|
|
7529
7657
|
return {
|
|
7530
7658
|
minBinId,
|
|
7531
7659
|
maxBinId,
|
|
@@ -7533,7 +7661,7 @@ function toStrategyParameters({
|
|
|
7533
7661
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7534
7662
|
};
|
|
7535
7663
|
}
|
|
7536
|
-
case
|
|
7664
|
+
case 1 /* CurveImBalanced */: {
|
|
7537
7665
|
return {
|
|
7538
7666
|
minBinId,
|
|
7539
7667
|
maxBinId,
|
|
@@ -7541,7 +7669,7 @@ function toStrategyParameters({
|
|
|
7541
7669
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7542
7670
|
};
|
|
7543
7671
|
}
|
|
7544
|
-
case
|
|
7672
|
+
case 2 /* BidAskImBalanced */: {
|
|
7545
7673
|
return {
|
|
7546
7674
|
minBinId,
|
|
7547
7675
|
maxBinId,
|
|
@@ -7563,7 +7691,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
|
|
|
7563
7691
|
);
|
|
7564
7692
|
const program = new (0, _anchor.Program)(
|
|
7565
7693
|
IDL,
|
|
7566
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
7694
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _29 => _29.cluster]), () => ( "mainnet-beta"))],
|
|
7567
7695
|
provider
|
|
7568
7696
|
);
|
|
7569
7697
|
const poolAccount = await program.account.lbPair.fetchNullable(
|
|
@@ -7621,7 +7749,7 @@ var getOrCreateATAInstruction = async (connection, tokenMint, owner, payer = own
|
|
|
7621
7749
|
return { ataPubKey: toAccount, ix: void 0 };
|
|
7622
7750
|
} catch (e) {
|
|
7623
7751
|
if (e instanceof _spltoken.TokenAccountNotFoundError || e instanceof _spltoken.TokenInvalidAccountOwnerError) {
|
|
7624
|
-
const ix = _spltoken.
|
|
7752
|
+
const ix = _spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
7625
7753
|
payer,
|
|
7626
7754
|
toAccount,
|
|
7627
7755
|
owner,
|
|
@@ -7641,7 +7769,7 @@ async function getTokenBalance(conn, tokenAccount) {
|
|
|
7641
7769
|
var parseLogs = (eventParser, logs) => {
|
|
7642
7770
|
if (!logs.length)
|
|
7643
7771
|
throw new Error("No logs found");
|
|
7644
|
-
for (const event of _optionalChain([eventParser, 'optionalAccess',
|
|
7772
|
+
for (const event of _optionalChain([eventParser, 'optionalAccess', _30 => _30.parseLogs, 'call', _31 => _31(logs)])) {
|
|
7645
7773
|
return event.data;
|
|
7646
7774
|
}
|
|
7647
7775
|
throw new Error("No events found");
|
|
@@ -7698,7 +7826,7 @@ var getEstimatedComputeUnitUsageWithBuffer = async (connection, instructions, fe
|
|
|
7698
7826
|
}
|
|
7699
7827
|
buffer = Math.max(0, buffer);
|
|
7700
7828
|
buffer = Math.min(1, buffer);
|
|
7701
|
-
const estimatedComputeUnitUsage = await
|
|
7829
|
+
const estimatedComputeUnitUsage = await getSimulationComputeUnits(
|
|
7702
7830
|
connection,
|
|
7703
7831
|
instructions,
|
|
7704
7832
|
feePayer,
|
|
@@ -7756,13 +7884,13 @@ var DLMM = class {
|
|
|
7756
7884
|
);
|
|
7757
7885
|
const program = new (0, _anchor.Program)(
|
|
7758
7886
|
IDL,
|
|
7759
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
7887
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _32 => _32.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _33 => _33.cluster]), () => ( "mainnet-beta"))])),
|
|
7760
7888
|
provider
|
|
7761
7889
|
);
|
|
7762
7890
|
return program.account.lbPair.all();
|
|
7763
7891
|
}
|
|
7764
7892
|
static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
7765
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
7893
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _34 => _34.cluster]) || "mainnet-beta";
|
|
7766
7894
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7767
7895
|
connection,
|
|
7768
7896
|
{},
|
|
@@ -7770,7 +7898,7 @@ var DLMM = class {
|
|
|
7770
7898
|
);
|
|
7771
7899
|
const program = new (0, _anchor.Program)(
|
|
7772
7900
|
IDL,
|
|
7773
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
7901
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _35 => _35.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
|
|
7774
7902
|
provider
|
|
7775
7903
|
);
|
|
7776
7904
|
try {
|
|
@@ -7809,7 +7937,7 @@ var DLMM = class {
|
|
|
7809
7937
|
* @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
|
|
7810
7938
|
*/
|
|
7811
7939
|
static async create(connection, dlmm, opt) {
|
|
7812
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
7940
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _36 => _36.cluster]) || "mainnet-beta";
|
|
7813
7941
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7814
7942
|
connection,
|
|
7815
7943
|
{},
|
|
@@ -7817,7 +7945,7 @@ var DLMM = class {
|
|
|
7817
7945
|
);
|
|
7818
7946
|
const program = new (0, _anchor.Program)(
|
|
7819
7947
|
IDL,
|
|
7820
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
7948
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _37 => _37.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
|
|
7821
7949
|
provider
|
|
7822
7950
|
);
|
|
7823
7951
|
const binArrayBitMapExtensionPubkey = deriveBinArrayBitmapExtension(
|
|
@@ -7833,14 +7961,14 @@ var DLMM = class {
|
|
|
7833
7961
|
connection,
|
|
7834
7962
|
accountsToFetch
|
|
7835
7963
|
);
|
|
7836
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
7964
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _38 => _38[0], 'optionalAccess', _39 => _39.data]);
|
|
7837
7965
|
if (!lbPairAccountInfoBuffer)
|
|
7838
7966
|
throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
|
|
7839
7967
|
const lbPairAccInfo = program.coder.accounts.decode(
|
|
7840
7968
|
"lbPair",
|
|
7841
7969
|
lbPairAccountInfoBuffer
|
|
7842
7970
|
);
|
|
7843
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
7971
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _40 => _40[1], 'optionalAccess', _41 => _41.data]);
|
|
7844
7972
|
let binArrayBitMapExtensionAccInfo = null;
|
|
7845
7973
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
7846
7974
|
binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
@@ -7848,7 +7976,7 @@ var DLMM = class {
|
|
|
7848
7976
|
binArrayBitMapAccountInfoBuffer
|
|
7849
7977
|
);
|
|
7850
7978
|
}
|
|
7851
|
-
const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
7979
|
+
const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _42 => _42[2], 'optionalAccess', _43 => _43.data]);
|
|
7852
7980
|
if (!clockAccountInfoBuffer)
|
|
7853
7981
|
throw new Error(`Clock account not found`);
|
|
7854
7982
|
const clock = ClockLayout.decode(clockAccountInfoBuffer);
|
|
@@ -7909,7 +8037,7 @@ var DLMM = class {
|
|
|
7909
8037
|
* objects.
|
|
7910
8038
|
*/
|
|
7911
8039
|
static async createMultiple(connection, dlmmList, opt) {
|
|
7912
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
8040
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _44 => _44.cluster]) || "mainnet-beta";
|
|
7913
8041
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7914
8042
|
connection,
|
|
7915
8043
|
{},
|
|
@@ -7917,7 +8045,7 @@ var DLMM = class {
|
|
|
7917
8045
|
);
|
|
7918
8046
|
const program = new (0, _anchor.Program)(
|
|
7919
8047
|
IDL,
|
|
7920
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
8048
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _45 => _45.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
|
|
7921
8049
|
provider
|
|
7922
8050
|
);
|
|
7923
8051
|
const binArrayBitMapExtensions = dlmmList.map(
|
|
@@ -7933,14 +8061,14 @@ var DLMM = class {
|
|
|
7933
8061
|
accountsToFetch
|
|
7934
8062
|
);
|
|
7935
8063
|
const clockAccount = accountsInfo.pop();
|
|
7936
|
-
const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess',
|
|
8064
|
+
const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _46 => _46.data]);
|
|
7937
8065
|
if (!clockAccountInfoBuffer)
|
|
7938
8066
|
throw new Error(`Clock account not found`);
|
|
7939
8067
|
const clock = ClockLayout.decode(clockAccountInfoBuffer);
|
|
7940
8068
|
const lbPairArraysMap = /* @__PURE__ */ new Map();
|
|
7941
8069
|
for (let i = 0; i < dlmmList.length; i++) {
|
|
7942
8070
|
const lbPairPubKey = dlmmList[i];
|
|
7943
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
8071
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _47 => _47[i], 'optionalAccess', _48 => _48.data]);
|
|
7944
8072
|
if (!lbPairAccountInfoBuffer)
|
|
7945
8073
|
throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
|
|
7946
8074
|
const binArrayAccInfo = program.coder.accounts.decode(
|
|
@@ -7953,7 +8081,7 @@ var DLMM = class {
|
|
|
7953
8081
|
for (let i = dlmmList.length; i < accountsInfo.length; i++) {
|
|
7954
8082
|
const index = i - dlmmList.length;
|
|
7955
8083
|
const lbPairPubkey = dlmmList[index];
|
|
7956
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
8084
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _49 => _49[i], 'optionalAccess', _50 => _50.data]);
|
|
7957
8085
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
7958
8086
|
const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
7959
8087
|
"binArrayBitmapExtension",
|
|
@@ -8037,7 +8165,7 @@ var DLMM = class {
|
|
|
8037
8165
|
);
|
|
8038
8166
|
const program = new (0, _anchor.Program)(
|
|
8039
8167
|
IDL,
|
|
8040
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
8168
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _51 => _51.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _52 => _52.cluster]), () => ( "mainnet-beta"))])),
|
|
8041
8169
|
provider
|
|
8042
8170
|
);
|
|
8043
8171
|
const presetParameter = await program.account.presetParameter.all();
|
|
@@ -8055,7 +8183,7 @@ var DLMM = class {
|
|
|
8055
8183
|
* Pair account, and the value is an object of PositionInfo
|
|
8056
8184
|
*/
|
|
8057
8185
|
static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
|
|
8058
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
8186
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _53 => _53.cluster]) || "mainnet-beta";
|
|
8059
8187
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
8060
8188
|
connection,
|
|
8061
8189
|
{},
|
|
@@ -8063,52 +8191,17 @@ var DLMM = class {
|
|
|
8063
8191
|
);
|
|
8064
8192
|
const program = new (0, _anchor.Program)(
|
|
8065
8193
|
IDL,
|
|
8066
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
8194
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _54 => _54.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
|
|
8067
8195
|
provider
|
|
8068
8196
|
);
|
|
8069
|
-
const
|
|
8070
|
-
|
|
8071
|
-
{
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
offset: 8 + 32
|
|
8075
|
-
}
|
|
8076
|
-
}
|
|
8077
|
-
]),
|
|
8078
|
-
program.account.positionV2.all([
|
|
8079
|
-
{
|
|
8080
|
-
memcmp: {
|
|
8081
|
-
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
8082
|
-
offset: 8 + 32
|
|
8083
|
-
}
|
|
8197
|
+
const positionsV2 = await program.account.positionV2.all([
|
|
8198
|
+
{
|
|
8199
|
+
memcmp: {
|
|
8200
|
+
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
8201
|
+
offset: 8 + 32
|
|
8084
8202
|
}
|
|
8085
|
-
|
|
8203
|
+
}
|
|
8086
8204
|
]);
|
|
8087
|
-
const binArrayPubkeySet = /* @__PURE__ */ new Set();
|
|
8088
|
-
const lbPairSet = /* @__PURE__ */ new Set();
|
|
8089
|
-
positions.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
8090
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8091
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
8092
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8093
|
-
lbPair,
|
|
8094
|
-
lowerBinArrayIndex,
|
|
8095
|
-
program.programId
|
|
8096
|
-
);
|
|
8097
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8098
|
-
lbPair,
|
|
8099
|
-
upperBinArrayIndex,
|
|
8100
|
-
program.programId
|
|
8101
|
-
);
|
|
8102
|
-
binArrayPubkeySet.add(lowerBinArrayPubKey.toBase58());
|
|
8103
|
-
binArrayPubkeySet.add(upperBinArrayPubKey.toBase58());
|
|
8104
|
-
lbPairSet.add(lbPair.toBase58());
|
|
8105
|
-
});
|
|
8106
|
-
const binArrayPubkeyArray = Array.from(binArrayPubkeySet).map(
|
|
8107
|
-
(pubkey) => new (0, _web3js.PublicKey)(pubkey)
|
|
8108
|
-
);
|
|
8109
|
-
const lbPairArray = Array.from(lbPairSet).map(
|
|
8110
|
-
(pubkey) => new (0, _web3js.PublicKey)(pubkey)
|
|
8111
|
-
);
|
|
8112
8205
|
const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
|
|
8113
8206
|
const lbPairSetV2 = /* @__PURE__ */ new Set();
|
|
8114
8207
|
positionsV2.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
@@ -8136,70 +8229,34 @@ var DLMM = class {
|
|
|
8136
8229
|
);
|
|
8137
8230
|
const [clockAccInfo, ...binArraysAccInfo] = await chunkedGetMultipleAccountInfos(connection, [
|
|
8138
8231
|
_web3js.SYSVAR_CLOCK_PUBKEY,
|
|
8139
|
-
...binArrayPubkeyArray,
|
|
8140
|
-
...lbPairArray,
|
|
8141
8232
|
...binArrayPubkeyArrayV2,
|
|
8142
8233
|
...lbPairArrayV2
|
|
8143
8234
|
]);
|
|
8144
|
-
const
|
|
8145
|
-
for (let i = 0; i <
|
|
8146
|
-
const binArrayPubkey =
|
|
8147
|
-
const
|
|
8148
|
-
if (
|
|
8149
|
-
|
|
8150
|
-
|
|
8235
|
+
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8236
|
+
for (let i = 0; i < binArrayPubkeyArrayV2.length; i++) {
|
|
8237
|
+
const binArrayPubkey = binArrayPubkeyArrayV2[i];
|
|
8238
|
+
const binArrayAccInfoBufferV2 = binArraysAccInfo[i];
|
|
8239
|
+
if (binArrayAccInfoBufferV2) {
|
|
8240
|
+
const binArrayAccInfo = program.coder.accounts.decode(
|
|
8241
|
+
"binArray",
|
|
8242
|
+
binArrayAccInfoBufferV2.data
|
|
8151
8243
|
);
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
binArrayAccInfoBuffer.data
|
|
8155
|
-
);
|
|
8156
|
-
positionBinArraysMap.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8244
|
+
positionBinArraysMapV2.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8245
|
+
}
|
|
8157
8246
|
}
|
|
8158
|
-
const
|
|
8159
|
-
for (let i =
|
|
8160
|
-
const lbPairPubkey =
|
|
8161
|
-
const
|
|
8162
|
-
if (!
|
|
8247
|
+
const lbPairArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8248
|
+
for (let i = binArrayPubkeyArrayV2.length; i < binArraysAccInfo.length; i++) {
|
|
8249
|
+
const lbPairPubkey = lbPairArrayV2[i - binArrayPubkeyArrayV2.length];
|
|
8250
|
+
const lbPairAccInfoBufferV2 = binArraysAccInfo[i];
|
|
8251
|
+
if (!lbPairAccInfoBufferV2)
|
|
8163
8252
|
throw new Error(`LB Pair account ${lbPairPubkey.toBase58()} not found`);
|
|
8164
8253
|
const lbPairAccInfo = program.coder.accounts.decode(
|
|
8165
8254
|
"lbPair",
|
|
8166
|
-
|
|
8255
|
+
lbPairAccInfoBufferV2.data
|
|
8167
8256
|
);
|
|
8168
|
-
|
|
8257
|
+
lbPairArraysMapV2.set(lbPairPubkey.toBase58(), lbPairAccInfo);
|
|
8169
8258
|
}
|
|
8170
|
-
const
|
|
8171
|
-
reserveX,
|
|
8172
|
-
reserveY,
|
|
8173
|
-
tokenXMint,
|
|
8174
|
-
tokenYMint
|
|
8175
|
-
]).flat();
|
|
8176
|
-
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8177
|
-
for (let i = binArrayPubkeyArray.length + lbPairArray.length; i < binArrayPubkeyArray.length + lbPairArray.length + binArrayPubkeyArrayV2.length; i++) {
|
|
8178
|
-
const binArrayPubkey = binArrayPubkeyArrayV2[i - (binArrayPubkeyArray.length + lbPairArray.length)];
|
|
8179
|
-
const binArrayAccInfoBufferV2 = binArraysAccInfo[i];
|
|
8180
|
-
if (!binArrayAccInfoBufferV2)
|
|
8181
|
-
throw new Error(
|
|
8182
|
-
`Bin Array account ${binArrayPubkey.toBase58()} not found`
|
|
8183
|
-
);
|
|
8184
|
-
const binArrayAccInfo = program.coder.accounts.decode(
|
|
8185
|
-
"binArray",
|
|
8186
|
-
binArrayAccInfoBufferV2.data
|
|
8187
|
-
);
|
|
8188
|
-
positionBinArraysMapV2.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8189
|
-
}
|
|
8190
|
-
const lbPairArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8191
|
-
for (let i = binArrayPubkeyArray.length + lbPairArray.length + binArrayPubkeyArrayV2.length; i < binArraysAccInfo.length; i++) {
|
|
8192
|
-
const lbPairPubkey = lbPairArrayV2[i - (binArrayPubkeyArray.length + lbPairArray.length + binArrayPubkeyArrayV2.length)];
|
|
8193
|
-
const lbPairAccInfoBufferV2 = binArraysAccInfo[i];
|
|
8194
|
-
if (!lbPairAccInfoBufferV2)
|
|
8195
|
-
throw new Error(`LB Pair account ${lbPairPubkey.toBase58()} not found`);
|
|
8196
|
-
const lbPairAccInfo = program.coder.accounts.decode(
|
|
8197
|
-
"lbPair",
|
|
8198
|
-
lbPairAccInfoBufferV2.data
|
|
8199
|
-
);
|
|
8200
|
-
lbPairArraysMapV2.set(lbPairPubkey.toBase58(), lbPairAccInfo);
|
|
8201
|
-
}
|
|
8202
|
-
const reservePublicKeysV2 = Array.from(lbPairArraysMapV2.values()).map(({ reserveX, reserveY, tokenXMint, tokenYMint }) => [
|
|
8259
|
+
const reservePublicKeysV2 = Array.from(lbPairArraysMapV2.values()).map(({ reserveX, reserveY, tokenXMint, tokenYMint }) => [
|
|
8203
8260
|
reserveX,
|
|
8204
8261
|
reserveY,
|
|
8205
8262
|
tokenXMint,
|
|
@@ -8207,43 +8264,14 @@ var DLMM = class {
|
|
|
8207
8264
|
]).flat();
|
|
8208
8265
|
const reserveAccountsInfo = await chunkedGetMultipleAccountInfos(
|
|
8209
8266
|
program.provider.connection,
|
|
8210
|
-
|
|
8267
|
+
reservePublicKeysV2
|
|
8211
8268
|
);
|
|
8212
|
-
const lbPairReserveMap = /* @__PURE__ */ new Map();
|
|
8213
|
-
const lbPairMintMap = /* @__PURE__ */ new Map();
|
|
8214
|
-
lbPairArray.forEach((lbPair, idx) => {
|
|
8215
|
-
const index = idx * 4;
|
|
8216
|
-
const reserveAccBufferX = reserveAccountsInfo[index];
|
|
8217
|
-
const reserveAccBufferY = reserveAccountsInfo[index + 1];
|
|
8218
|
-
if (!reserveAccBufferX || !reserveAccBufferY)
|
|
8219
|
-
throw new Error(
|
|
8220
|
-
`Reserve account for LB Pair ${lbPair.toBase58()} not found`
|
|
8221
|
-
);
|
|
8222
|
-
const reserveAccX = _spltoken.AccountLayout.decode(reserveAccBufferX.data);
|
|
8223
|
-
const reserveAccY = _spltoken.AccountLayout.decode(reserveAccBufferY.data);
|
|
8224
|
-
lbPairReserveMap.set(lbPair.toBase58(), {
|
|
8225
|
-
reserveX: reserveAccX.amount,
|
|
8226
|
-
reserveY: reserveAccY.amount
|
|
8227
|
-
});
|
|
8228
|
-
const mintXBuffer = reserveAccountsInfo[index + 2];
|
|
8229
|
-
const mintYBuffer = reserveAccountsInfo[index + 3];
|
|
8230
|
-
if (!mintXBuffer || !mintYBuffer)
|
|
8231
|
-
throw new Error(
|
|
8232
|
-
`Mint account for LB Pair ${lbPair.toBase58()} not found`
|
|
8233
|
-
);
|
|
8234
|
-
const mintX = _spltoken.MintLayout.decode(mintXBuffer.data);
|
|
8235
|
-
const mintY = _spltoken.MintLayout.decode(mintYBuffer.data);
|
|
8236
|
-
lbPairMintMap.set(lbPair.toBase58(), {
|
|
8237
|
-
mintXDecimal: mintX.decimals,
|
|
8238
|
-
mintYDecimal: mintY.decimals
|
|
8239
|
-
});
|
|
8240
|
-
});
|
|
8241
8269
|
const lbPairReserveMapV2 = /* @__PURE__ */ new Map();
|
|
8242
8270
|
const lbPairMintMapV2 = /* @__PURE__ */ new Map();
|
|
8243
8271
|
lbPairArrayV2.forEach((lbPair, idx) => {
|
|
8244
8272
|
const index = idx * 4;
|
|
8245
|
-
const reserveAccBufferXV2 = reserveAccountsInfo[
|
|
8246
|
-
const reserveAccBufferYV2 = reserveAccountsInfo[
|
|
8273
|
+
const reserveAccBufferXV2 = reserveAccountsInfo[index];
|
|
8274
|
+
const reserveAccBufferYV2 = reserveAccountsInfo[index + 1];
|
|
8247
8275
|
if (!reserveAccBufferXV2 || !reserveAccBufferYV2)
|
|
8248
8276
|
throw new Error(
|
|
8249
8277
|
`Reserve account for LB Pair ${lbPair.toBase58()} not found`
|
|
@@ -8254,8 +8282,8 @@ var DLMM = class {
|
|
|
8254
8282
|
reserveX: reserveAccX.amount,
|
|
8255
8283
|
reserveY: reserveAccY.amount
|
|
8256
8284
|
});
|
|
8257
|
-
const mintXBufferV2 = reserveAccountsInfo[
|
|
8258
|
-
const mintYBufferV2 = reserveAccountsInfo[
|
|
8285
|
+
const mintXBufferV2 = reserveAccountsInfo[index + 2];
|
|
8286
|
+
const mintYBufferV2 = reserveAccountsInfo[index + 3];
|
|
8259
8287
|
if (!mintXBufferV2 || !mintYBufferV2)
|
|
8260
8288
|
throw new Error(
|
|
8261
8289
|
`Mint account for LB Pair ${lbPair.toBase58()} not found`
|
|
@@ -8271,74 +8299,6 @@ var DLMM = class {
|
|
|
8271
8299
|
clockAccInfo.data.readBigInt64LE(32).toString()
|
|
8272
8300
|
).toNumber();
|
|
8273
8301
|
const positionsMap = /* @__PURE__ */ new Map();
|
|
8274
|
-
for (let position of positions) {
|
|
8275
|
-
const { account, publicKey: positionPubKey } = position;
|
|
8276
|
-
const { upperBinId, lowerBinId, lbPair } = account;
|
|
8277
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8278
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
8279
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8280
|
-
lbPair,
|
|
8281
|
-
lowerBinArrayIndex,
|
|
8282
|
-
program.programId
|
|
8283
|
-
);
|
|
8284
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8285
|
-
lbPair,
|
|
8286
|
-
upperBinArrayIndex,
|
|
8287
|
-
program.programId
|
|
8288
|
-
);
|
|
8289
|
-
const lowerBinArray = positionBinArraysMap.get(
|
|
8290
|
-
lowerBinArrayPubKey.toBase58()
|
|
8291
|
-
);
|
|
8292
|
-
const upperBinArray = positionBinArraysMap.get(
|
|
8293
|
-
upperBinArrayPubKey.toBase58()
|
|
8294
|
-
);
|
|
8295
|
-
const lbPairAcc = lbPairArraysMap.get(lbPair.toBase58());
|
|
8296
|
-
const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
|
|
8297
|
-
lbPair.toBase58()
|
|
8298
|
-
);
|
|
8299
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.reserveX]), () => ( BigInt(0)));
|
|
8300
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.reserveY]), () => ( BigInt(0)));
|
|
8301
|
-
const tokenX = {
|
|
8302
|
-
publicKey: lbPairAcc.tokenXMint,
|
|
8303
|
-
reserve: lbPairAcc.reserveX,
|
|
8304
|
-
amount: reserveXBalance,
|
|
8305
|
-
decimal: mintXDecimal
|
|
8306
|
-
};
|
|
8307
|
-
const tokenY = {
|
|
8308
|
-
publicKey: lbPairAcc.tokenYMint,
|
|
8309
|
-
reserve: lbPairAcc.reserveY,
|
|
8310
|
-
amount: reserveYBalance,
|
|
8311
|
-
decimal: mintYDecimal
|
|
8312
|
-
};
|
|
8313
|
-
const positionData = await DLMM.processPosition(
|
|
8314
|
-
program,
|
|
8315
|
-
0 /* V1 */,
|
|
8316
|
-
lbPairAcc,
|
|
8317
|
-
onChainTimestamp,
|
|
8318
|
-
account,
|
|
8319
|
-
mintXDecimal,
|
|
8320
|
-
mintYDecimal,
|
|
8321
|
-
lowerBinArray,
|
|
8322
|
-
upperBinArray,
|
|
8323
|
-
_web3js.PublicKey.default
|
|
8324
|
-
);
|
|
8325
|
-
if (positionData) {
|
|
8326
|
-
positionsMap.set(lbPair.toBase58(), {
|
|
8327
|
-
publicKey: lbPair,
|
|
8328
|
-
lbPair: lbPairAcc,
|
|
8329
|
-
tokenX,
|
|
8330
|
-
tokenY,
|
|
8331
|
-
lbPairPositionsData: [
|
|
8332
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.lbPairPositionsData]), () => ( [])),
|
|
8333
|
-
{
|
|
8334
|
-
publicKey: positionPubKey,
|
|
8335
|
-
positionData,
|
|
8336
|
-
version: 0 /* V1 */
|
|
8337
|
-
}
|
|
8338
|
-
]
|
|
8339
|
-
});
|
|
8340
|
-
}
|
|
8341
|
-
}
|
|
8342
8302
|
for (let position of positionsV2) {
|
|
8343
8303
|
const { account, publicKey: positionPubKey } = position;
|
|
8344
8304
|
const { upperBinId, lowerBinId, lbPair, feeOwner } = account;
|
|
@@ -8365,8 +8325,8 @@ var DLMM = class {
|
|
|
8365
8325
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
|
|
8366
8326
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
|
|
8367
8327
|
]);
|
|
8368
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
8369
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
8328
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _55 => _55.get, 'call', _56 => _56(lbPair.toBase58()), 'optionalAccess', _57 => _57.reserveX]), () => ( BigInt(0)));
|
|
8329
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _58 => _58.get, 'call', _59 => _59(lbPair.toBase58()), 'optionalAccess', _60 => _60.reserveY]), () => ( BigInt(0)));
|
|
8370
8330
|
const tokenX = {
|
|
8371
8331
|
publicKey: lbPairAcc.tokenXMint,
|
|
8372
8332
|
reserve: lbPairAcc.reserveX,
|
|
@@ -8379,7 +8339,7 @@ var DLMM = class {
|
|
|
8379
8339
|
amount: reserveYBalance,
|
|
8380
8340
|
decimal: quoteTokenDecimal
|
|
8381
8341
|
};
|
|
8382
|
-
const positionData = await DLMM.processPosition(
|
|
8342
|
+
const positionData = !!lowerBinArray && !!upperBinArray ? await DLMM.processPosition(
|
|
8383
8343
|
program,
|
|
8384
8344
|
1 /* V2 */,
|
|
8385
8345
|
lbPairAcc,
|
|
@@ -8390,7 +8350,21 @@ var DLMM = class {
|
|
|
8390
8350
|
lowerBinArray,
|
|
8391
8351
|
upperBinArray,
|
|
8392
8352
|
feeOwner
|
|
8393
|
-
)
|
|
8353
|
+
) : {
|
|
8354
|
+
totalXAmount: "0",
|
|
8355
|
+
totalYAmount: "0",
|
|
8356
|
+
positionBinData: [],
|
|
8357
|
+
lastUpdatedAt: new (0, _anchor.BN)(0),
|
|
8358
|
+
upperBinId,
|
|
8359
|
+
lowerBinId,
|
|
8360
|
+
feeX: new (0, _anchor.BN)(0),
|
|
8361
|
+
feeY: new (0, _anchor.BN)(0),
|
|
8362
|
+
rewardOne: new (0, _anchor.BN)(0),
|
|
8363
|
+
rewardTwo: new (0, _anchor.BN)(0),
|
|
8364
|
+
feeOwner,
|
|
8365
|
+
totalClaimedFeeXAmount: new (0, _anchor.BN)(0),
|
|
8366
|
+
totalClaimedFeeYAmount: new (0, _anchor.BN)(0)
|
|
8367
|
+
};
|
|
8394
8368
|
if (positionData) {
|
|
8395
8369
|
positionsMap.set(lbPair.toBase58(), {
|
|
8396
8370
|
publicKey: lbPair,
|
|
@@ -8398,7 +8372,7 @@ var DLMM = class {
|
|
|
8398
8372
|
tokenX,
|
|
8399
8373
|
tokenY,
|
|
8400
8374
|
lbPairPositionsData: [
|
|
8401
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
8375
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _61 => _61.get, 'call', _62 => _62(lbPair.toBase58()), 'optionalAccess', _63 => _63.lbPairPositionsData]), () => ( [])),
|
|
8402
8376
|
{
|
|
8403
8377
|
publicKey: positionPubKey,
|
|
8404
8378
|
positionData,
|
|
@@ -8410,63 +8384,124 @@ var DLMM = class {
|
|
|
8410
8384
|
}
|
|
8411
8385
|
return positionsMap;
|
|
8412
8386
|
}
|
|
8413
|
-
static
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
);
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8387
|
+
static getPricePerLamport(tokenXDecimal, tokenYDecimal, price) {
|
|
8388
|
+
return new (0, _decimaljs2.default)(price).mul(new (0, _decimaljs2.default)(10 ** (tokenYDecimal - tokenXDecimal))).toString();
|
|
8389
|
+
}
|
|
8390
|
+
static getBinIdFromPrice(price, binStep, min) {
|
|
8391
|
+
const binStepNum = new (0, _decimaljs2.default)(binStep).div(new (0, _decimaljs2.default)(BASIS_POINT_MAX));
|
|
8392
|
+
const binId = new (0, _decimaljs2.default)(price).log().dividedBy(new (0, _decimaljs2.default)(1).add(binStepNum).log());
|
|
8393
|
+
return (min ? binId.floor() : binId.ceil()).toNumber();
|
|
8394
|
+
}
|
|
8395
|
+
/**
|
|
8396
|
+
* The function `getLbPairLockInfo` retrieves all pair positions that has locked liquidity.
|
|
8397
|
+
* @param {number} [lockDurationOpt] - An optional value indicating the minimum position lock duration that the function should return.
|
|
8398
|
+
* Depending on the lbPair activationType, the param should be a number of seconds or a number of slots.
|
|
8399
|
+
* @returns The function `getLbPairLockInfo` returns a `Promise` that resolves to a `PairLockInfo`
|
|
8400
|
+
* object. The `PairLockInfo` object contains an array of `PositionLockInfo` objects.
|
|
8401
|
+
*/
|
|
8402
|
+
async getLbPairLockInfo(lockDurationOpt) {
|
|
8403
|
+
const lockDuration = lockDurationOpt | 0;
|
|
8404
|
+
const lbPairPositions = await this.program.account.positionV2.all([
|
|
8405
|
+
{
|
|
8406
|
+
memcmp: {
|
|
8407
|
+
bytes: _bytes.bs58.encode(this.pubkey.toBuffer()),
|
|
8408
|
+
offset: 8
|
|
8409
|
+
}
|
|
8410
|
+
}
|
|
8411
|
+
]);
|
|
8412
|
+
const clockAccInfo = await this.program.provider.connection.getAccountInfo(_web3js.SYSVAR_CLOCK_PUBKEY);
|
|
8413
|
+
const clock = ClockLayout.decode(clockAccInfo.data);
|
|
8414
|
+
const currentPoint = this.lbPair.activationType == 0 /* Slot */ ? clock.slot : clock.unixTimestamp;
|
|
8415
|
+
const minLockReleasePoint = currentPoint.add(new (0, _anchor.BN)(lockDuration));
|
|
8416
|
+
const positionsWithLock = lbPairPositions.filter((p) => p.account.lockReleasePoint.gt(minLockReleasePoint));
|
|
8417
|
+
if (positionsWithLock.length == 0) {
|
|
8418
|
+
return {
|
|
8419
|
+
positions: []
|
|
8420
|
+
};
|
|
8421
|
+
}
|
|
8422
|
+
const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
|
|
8423
|
+
positionsWithLock.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
8424
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8425
|
+
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
8426
|
+
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8427
|
+
this.pubkey,
|
|
8428
|
+
lowerBinArrayIndex,
|
|
8429
|
+
this.program.programId
|
|
8430
|
+
);
|
|
8431
|
+
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8432
|
+
this.pubkey,
|
|
8433
|
+
upperBinArrayIndex,
|
|
8434
|
+
this.program.programId
|
|
8435
|
+
);
|
|
8436
|
+
binArrayPubkeySetV2.add(lowerBinArrayPubKey.toBase58());
|
|
8437
|
+
binArrayPubkeySetV2.add(upperBinArrayPubKey.toBase58());
|
|
8438
|
+
});
|
|
8439
|
+
const binArrayPubkeyArrayV2 = Array.from(binArrayPubkeySetV2).map(
|
|
8440
|
+
(pubkey) => new (0, _web3js.PublicKey)(pubkey)
|
|
8424
8441
|
);
|
|
8425
|
-
const
|
|
8426
|
-
|
|
8442
|
+
const binArraysAccInfo = await chunkedGetMultipleAccountInfos(
|
|
8443
|
+
this.program.provider.connection,
|
|
8444
|
+
binArrayPubkeyArrayV2
|
|
8427
8445
|
);
|
|
8428
|
-
const
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8446
|
+
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8447
|
+
for (let i = 0; i < binArraysAccInfo.length; i++) {
|
|
8448
|
+
const binArrayPubkey = binArrayPubkeyArrayV2[i];
|
|
8449
|
+
const binArrayAccBufferV2 = binArraysAccInfo[i];
|
|
8450
|
+
if (!binArrayAccBufferV2)
|
|
8451
|
+
throw new Error(
|
|
8452
|
+
`Bin Array account ${binArrayPubkey.toBase58()} not found`
|
|
8453
|
+
);
|
|
8454
|
+
const binArrayAccInfo = this.program.coder.accounts.decode(
|
|
8455
|
+
"binArray",
|
|
8456
|
+
binArrayAccBufferV2.data
|
|
8457
|
+
);
|
|
8458
|
+
positionBinArraysMapV2.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8459
|
+
}
|
|
8460
|
+
const positionsLockInfo = await Promise.all(
|
|
8461
|
+
positionsWithLock.map(async ({ publicKey, account }) => {
|
|
8462
|
+
const { lowerBinId, upperBinId, feeOwner } = account;
|
|
8432
8463
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8433
|
-
const upperBinArrayIndex =
|
|
8464
|
+
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
8434
8465
|
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8435
|
-
|
|
8466
|
+
this.pubkey,
|
|
8436
8467
|
lowerBinArrayIndex,
|
|
8437
|
-
program.programId
|
|
8468
|
+
this.program.programId
|
|
8438
8469
|
);
|
|
8439
8470
|
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8440
|
-
|
|
8471
|
+
this.pubkey,
|
|
8441
8472
|
upperBinArrayIndex,
|
|
8442
|
-
program.programId
|
|
8473
|
+
this.program.programId
|
|
8443
8474
|
);
|
|
8444
|
-
const
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
program
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8475
|
+
const lowerBinArray = positionBinArraysMapV2.get(
|
|
8476
|
+
lowerBinArrayPubKey.toBase58()
|
|
8477
|
+
);
|
|
8478
|
+
const upperBinArray = positionBinArraysMapV2.get(
|
|
8479
|
+
upperBinArrayPubKey.toBase58()
|
|
8480
|
+
);
|
|
8481
|
+
const positionData = await DLMM.processPosition(
|
|
8482
|
+
this.program,
|
|
8483
|
+
1 /* V2 */,
|
|
8484
|
+
this.lbPair,
|
|
8485
|
+
clock.unixTimestamp.toNumber(),
|
|
8486
|
+
account,
|
|
8487
|
+
this.tokenX.decimal,
|
|
8488
|
+
this.tokenY.decimal,
|
|
8489
|
+
lowerBinArray,
|
|
8490
|
+
upperBinArray,
|
|
8491
|
+
feeOwner
|
|
8492
|
+
);
|
|
8493
|
+
return {
|
|
8494
|
+
positionAddress: publicKey,
|
|
8495
|
+
owner: account.owner,
|
|
8496
|
+
lockReleasePoint: account.lockReleasePoint.toNumber(),
|
|
8497
|
+
tokenXAmount: positionData.totalXAmount,
|
|
8498
|
+
tokenYAmount: positionData.totalYAmount
|
|
8499
|
+
};
|
|
8460
8500
|
})
|
|
8461
8501
|
);
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
}
|
|
8466
|
-
static getBinIdFromPrice(price, binStep, min) {
|
|
8467
|
-
const binStepNum = new (0, _decimaljs2.default)(binStep).div(new (0, _decimaljs2.default)(BASIS_POINT_MAX));
|
|
8468
|
-
const binId = new (0, _decimaljs2.default)(price).log().dividedBy(new (0, _decimaljs2.default)(1).add(binStepNum).log());
|
|
8469
|
-
return (min ? binId.floor() : binId.ceil()).toNumber();
|
|
8502
|
+
return {
|
|
8503
|
+
positions: positionsLockInfo
|
|
8504
|
+
};
|
|
8470
8505
|
}
|
|
8471
8506
|
/** Public methods */
|
|
8472
8507
|
static async createPermissionLbPair(connection, binStep, tokenX, tokenY, activeId, baseKey, creatorKey, feeBps, activationType, opt) {
|
|
@@ -8477,7 +8512,7 @@ var DLMM = class {
|
|
|
8477
8512
|
);
|
|
8478
8513
|
const program = new (0, _anchor.Program)(
|
|
8479
8514
|
IDL,
|
|
8480
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
8515
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _64 => _64.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
|
|
8481
8516
|
provider
|
|
8482
8517
|
);
|
|
8483
8518
|
const [lbPair] = derivePermissionLbPair(
|
|
@@ -8518,7 +8553,7 @@ var DLMM = class {
|
|
|
8518
8553
|
base: baseKey
|
|
8519
8554
|
}).transaction();
|
|
8520
8555
|
}
|
|
8521
|
-
static async createCustomizablePermissionlessLbPair(connection, binStep, tokenX, tokenY, activeId, feeBps, activationType, hasAlphaVault, creatorKey, activationPoint, opt) {
|
|
8556
|
+
static async createCustomizablePermissionlessLbPair(connection, binStep, tokenX, tokenY, activeId, feeBps, activationType, hasAlphaVault, creatorKey, activationPoint, creatorPoolOnOffControl, opt) {
|
|
8522
8557
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
8523
8558
|
connection,
|
|
8524
8559
|
{},
|
|
@@ -8526,7 +8561,7 @@ var DLMM = class {
|
|
|
8526
8561
|
);
|
|
8527
8562
|
const program = new (0, _anchor.Program)(
|
|
8528
8563
|
IDL,
|
|
8529
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
8564
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _65 => _65.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
|
|
8530
8565
|
provider
|
|
8531
8566
|
);
|
|
8532
8567
|
const [lbPair] = deriveCustomizablePermissionlessLbPair(
|
|
@@ -8548,12 +8583,13 @@ var DLMM = class {
|
|
|
8548
8583
|
activationType,
|
|
8549
8584
|
activationPoint: activationPoint ? activationPoint : null,
|
|
8550
8585
|
hasAlphaVault,
|
|
8551
|
-
|
|
8586
|
+
creatorPoolOnOffControl: creatorPoolOnOffControl ? creatorPoolOnOffControl : false,
|
|
8587
|
+
padding: Array(63).fill(0)
|
|
8552
8588
|
};
|
|
8553
8589
|
const userTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0, tokenX, creatorKey);
|
|
8590
|
+
const userTokenY = _spltoken.getAssociatedTokenAddressSync.call(void 0, tokenY, creatorKey);
|
|
8554
8591
|
return program.methods.initializeCustomizablePermissionlessLbPair(ixData).accounts({
|
|
8555
8592
|
lbPair,
|
|
8556
|
-
rent: _web3js.SYSVAR_RENT_PUBKEY,
|
|
8557
8593
|
reserveX,
|
|
8558
8594
|
reserveY,
|
|
8559
8595
|
binArrayBitmapExtension,
|
|
@@ -8563,6 +8599,7 @@ var DLMM = class {
|
|
|
8563
8599
|
oracle,
|
|
8564
8600
|
systemProgram: _web3js.SystemProgram.programId,
|
|
8565
8601
|
userTokenX,
|
|
8602
|
+
userTokenY,
|
|
8566
8603
|
funder: creatorKey
|
|
8567
8604
|
}).transaction();
|
|
8568
8605
|
}
|
|
@@ -8574,7 +8611,7 @@ var DLMM = class {
|
|
|
8574
8611
|
);
|
|
8575
8612
|
const program = new (0, _anchor.Program)(
|
|
8576
8613
|
IDL,
|
|
8577
|
-
_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
8614
|
+
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _66 => _66.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
|
|
8578
8615
|
provider
|
|
8579
8616
|
);
|
|
8580
8617
|
const existsPool = await this.getPairPubkeyIfExists(
|
|
@@ -8678,6 +8715,26 @@ var DLMM = class {
|
|
|
8678
8715
|
};
|
|
8679
8716
|
this.lbPair = lbPairState;
|
|
8680
8717
|
}
|
|
8718
|
+
/**
|
|
8719
|
+
* Set the status of a permissionless LB pair to either enabled or disabled. This require pool field `creator_pool_on_off_control` to be true and type `CustomizablePermissionless`.
|
|
8720
|
+
* Pool creator can enable/disable the pair anytime before the pool is opened / activated. Once the pool activation time is passed, the pool creator can only enable the pair.
|
|
8721
|
+
* Useful for token launches which do not have fixed activation time.
|
|
8722
|
+
* @param enable If true, the pair will be enabled. If false, the pair will be disabled.
|
|
8723
|
+
* @param creator The public key of the pool creator.
|
|
8724
|
+
* @returns a Promise that resolves to the transaction.
|
|
8725
|
+
*/
|
|
8726
|
+
async setPairStatusPermissionless(enable, creator) {
|
|
8727
|
+
const tx = await this.program.methods.setPairStatusPermissionless(Number(enable)).accounts({
|
|
8728
|
+
lbPair: this.pubkey,
|
|
8729
|
+
creator
|
|
8730
|
+
}).transaction();
|
|
8731
|
+
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
8732
|
+
return new (0, _web3js.Transaction)({
|
|
8733
|
+
feePayer: this.lbPair.creator,
|
|
8734
|
+
blockhash,
|
|
8735
|
+
lastValidBlockHeight
|
|
8736
|
+
}).add(tx);
|
|
8737
|
+
}
|
|
8681
8738
|
/**
|
|
8682
8739
|
* The function `getBinArrays` returns an array of `BinArrayAccount` objects
|
|
8683
8740
|
* @returns a Promise that resolves to an array of BinArrayAccount objects.
|
|
@@ -8710,7 +8767,7 @@ var DLMM = class {
|
|
|
8710
8767
|
swapForY,
|
|
8711
8768
|
new (0, _anchor.BN)(activeIdToLoop),
|
|
8712
8769
|
this.lbPair,
|
|
8713
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
8770
|
+
_nullishCoalesce(_optionalChain([this, 'access', _67 => _67.binArrayBitmapExtension, 'optionalAccess', _68 => _68.account]), () => ( null))
|
|
8714
8771
|
);
|
|
8715
8772
|
if (binArrayIndex === null)
|
|
8716
8773
|
shouldStop = true;
|
|
@@ -8951,20 +9008,6 @@ var DLMM = class {
|
|
|
8951
9008
|
async getPositionsByUserAndLbPair(userPubKey) {
|
|
8952
9009
|
const promiseResults = await Promise.all([
|
|
8953
9010
|
this.getActiveBin(),
|
|
8954
|
-
userPubKey && this.program.account.position.all([
|
|
8955
|
-
{
|
|
8956
|
-
memcmp: {
|
|
8957
|
-
bytes: _bytes.bs58.encode(userPubKey.toBuffer()),
|
|
8958
|
-
offset: 8 + 32
|
|
8959
|
-
}
|
|
8960
|
-
},
|
|
8961
|
-
{
|
|
8962
|
-
memcmp: {
|
|
8963
|
-
bytes: _bytes.bs58.encode(this.pubkey.toBuffer()),
|
|
8964
|
-
offset: 8
|
|
8965
|
-
}
|
|
8966
|
-
}
|
|
8967
|
-
]),
|
|
8968
9011
|
userPubKey && this.program.account.positionV2.all([
|
|
8969
9012
|
{
|
|
8970
9013
|
memcmp: {
|
|
@@ -8980,7 +9023,7 @@ var DLMM = class {
|
|
|
8980
9023
|
}
|
|
8981
9024
|
])
|
|
8982
9025
|
]);
|
|
8983
|
-
const [activeBin,
|
|
9026
|
+
const [activeBin, positionsV2] = promiseResults;
|
|
8984
9027
|
if (!activeBin) {
|
|
8985
9028
|
throw new Error("Error fetching active bin");
|
|
8986
9029
|
}
|
|
@@ -8990,29 +9033,9 @@ var DLMM = class {
|
|
|
8990
9033
|
userPositions: []
|
|
8991
9034
|
};
|
|
8992
9035
|
}
|
|
8993
|
-
if (!
|
|
9036
|
+
if (!positionsV2) {
|
|
8994
9037
|
throw new Error("Error fetching positions");
|
|
8995
9038
|
}
|
|
8996
|
-
const binArrayPubkeySet = /* @__PURE__ */ new Set();
|
|
8997
|
-
positions.forEach(({ account: { upperBinId, lowerBinId } }) => {
|
|
8998
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8999
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
9000
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
9001
|
-
this.pubkey,
|
|
9002
|
-
lowerBinArrayIndex,
|
|
9003
|
-
this.program.programId
|
|
9004
|
-
);
|
|
9005
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
9006
|
-
this.pubkey,
|
|
9007
|
-
upperBinArrayIndex,
|
|
9008
|
-
this.program.programId
|
|
9009
|
-
);
|
|
9010
|
-
binArrayPubkeySet.add(lowerBinArrayPubKey.toBase58());
|
|
9011
|
-
binArrayPubkeySet.add(upperBinArrayPubKey.toBase58());
|
|
9012
|
-
});
|
|
9013
|
-
const binArrayPubkeyArray = Array.from(binArrayPubkeySet).map(
|
|
9014
|
-
(pubkey) => new (0, _web3js.PublicKey)(pubkey)
|
|
9015
|
-
);
|
|
9016
9039
|
const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
|
|
9017
9040
|
positionsV2.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
9018
9041
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
@@ -9038,28 +9061,13 @@ var DLMM = class {
|
|
|
9038
9061
|
[
|
|
9039
9062
|
this.pubkey,
|
|
9040
9063
|
_web3js.SYSVAR_CLOCK_PUBKEY,
|
|
9041
|
-
...binArrayPubkeyArray,
|
|
9042
9064
|
...binArrayPubkeyArrayV2
|
|
9043
9065
|
]
|
|
9044
9066
|
);
|
|
9045
9067
|
const [lbPairAccInfo, clockAccInfo, ...binArraysAccInfo] = lbPairAndBinArrays;
|
|
9046
|
-
const positionBinArraysMap = /* @__PURE__ */ new Map();
|
|
9047
|
-
for (let i = 0; i < binArrayPubkeyArray.length; i++) {
|
|
9048
|
-
const binArrayPubkey = binArrayPubkeyArray[i];
|
|
9049
|
-
const binArrayAccBuffer = binArraysAccInfo[i];
|
|
9050
|
-
if (!binArrayAccBuffer)
|
|
9051
|
-
throw new Error(
|
|
9052
|
-
`Bin Array account ${binArrayPubkey.toBase58()} not found`
|
|
9053
|
-
);
|
|
9054
|
-
const binArrayAccInfo = this.program.coder.accounts.decode(
|
|
9055
|
-
"binArray",
|
|
9056
|
-
binArrayAccBuffer.data
|
|
9057
|
-
);
|
|
9058
|
-
positionBinArraysMap.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
9059
|
-
}
|
|
9060
9068
|
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
9061
|
-
for (let i =
|
|
9062
|
-
const binArrayPubkey = binArrayPubkeyArrayV2[i
|
|
9069
|
+
for (let i = 0; i < binArraysAccInfo.length; i++) {
|
|
9070
|
+
const binArrayPubkey = binArrayPubkeyArrayV2[i];
|
|
9063
9071
|
const binArrayAccBufferV2 = binArraysAccInfo[i];
|
|
9064
9072
|
if (!binArrayAccBufferV2)
|
|
9065
9073
|
throw new Error(
|
|
@@ -9076,45 +9084,6 @@ var DLMM = class {
|
|
|
9076
9084
|
const onChainTimestamp = new (0, _anchor.BN)(
|
|
9077
9085
|
clockAccInfo.data.readBigInt64LE(32).toString()
|
|
9078
9086
|
).toNumber();
|
|
9079
|
-
const userPositions = await Promise.all(
|
|
9080
|
-
positions.map(async ({ publicKey, account }) => {
|
|
9081
|
-
const { lowerBinId, upperBinId } = account;
|
|
9082
|
-
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
9083
|
-
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
9084
|
-
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
9085
|
-
this.pubkey,
|
|
9086
|
-
lowerBinArrayIndex,
|
|
9087
|
-
this.program.programId
|
|
9088
|
-
);
|
|
9089
|
-
const [upperBinArrayPubKey] = deriveBinArray(
|
|
9090
|
-
this.pubkey,
|
|
9091
|
-
upperBinArrayIndex,
|
|
9092
|
-
this.program.programId
|
|
9093
|
-
);
|
|
9094
|
-
const lowerBinArray = positionBinArraysMap.get(
|
|
9095
|
-
lowerBinArrayPubKey.toBase58()
|
|
9096
|
-
);
|
|
9097
|
-
const upperBinArray = positionBinArraysMap.get(
|
|
9098
|
-
upperBinArrayPubKey.toBase58()
|
|
9099
|
-
);
|
|
9100
|
-
return {
|
|
9101
|
-
publicKey,
|
|
9102
|
-
positionData: await DLMM.processPosition(
|
|
9103
|
-
this.program,
|
|
9104
|
-
0 /* V1 */,
|
|
9105
|
-
this.lbPair,
|
|
9106
|
-
onChainTimestamp,
|
|
9107
|
-
account,
|
|
9108
|
-
this.tokenX.decimal,
|
|
9109
|
-
this.tokenY.decimal,
|
|
9110
|
-
lowerBinArray,
|
|
9111
|
-
upperBinArray,
|
|
9112
|
-
_web3js.PublicKey.default
|
|
9113
|
-
),
|
|
9114
|
-
version: 0 /* V1 */
|
|
9115
|
-
};
|
|
9116
|
-
})
|
|
9117
|
-
);
|
|
9118
9087
|
const userPositionsV2 = await Promise.all(
|
|
9119
9088
|
positionsV2.map(async ({ publicKey, account }) => {
|
|
9120
9089
|
const { lowerBinId, upperBinId, feeOwner } = account;
|
|
@@ -9156,7 +9125,7 @@ var DLMM = class {
|
|
|
9156
9125
|
);
|
|
9157
9126
|
return {
|
|
9158
9127
|
activeBin,
|
|
9159
|
-
userPositions:
|
|
9128
|
+
userPositions: userPositionsV2
|
|
9160
9129
|
};
|
|
9161
9130
|
}
|
|
9162
9131
|
async quoteCreatePosition({ strategy }) {
|
|
@@ -9217,6 +9186,93 @@ var DLMM = class {
|
|
|
9217
9186
|
feePayer: user
|
|
9218
9187
|
}).add(setCUIx, ...instructions);
|
|
9219
9188
|
}
|
|
9189
|
+
/**
|
|
9190
|
+
* The function `getPosition` retrieves position information for a given public key and processes it
|
|
9191
|
+
* using various data to return a `LbPosition` object.
|
|
9192
|
+
* @param {PublicKey} positionPubKey - The `getPosition` function you provided is an asynchronous
|
|
9193
|
+
* function that fetches position information based on a given public key. Here's a breakdown of the
|
|
9194
|
+
* parameters used in the function:
|
|
9195
|
+
* @returns The `getPosition` function returns a Promise that resolves to an object of type
|
|
9196
|
+
* `LbPosition`. The object contains the following properties:
|
|
9197
|
+
* - `publicKey`: The public key of the position account
|
|
9198
|
+
* - `positionData`: Position Object
|
|
9199
|
+
* - `version`: The version of the position (in this case, `Position.V2`)
|
|
9200
|
+
*/
|
|
9201
|
+
async getPosition(positionPubKey) {
|
|
9202
|
+
const positionAccountInfo = await this.program.account.positionV2.fetch(positionPubKey);
|
|
9203
|
+
if (!positionAccountInfo) {
|
|
9204
|
+
throw new Error(`Position account ${positionPubKey.toBase58()} not found`);
|
|
9205
|
+
}
|
|
9206
|
+
const { lowerBinId, upperBinId, feeOwner } = positionAccountInfo;
|
|
9207
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
9208
|
+
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
9209
|
+
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
9210
|
+
this.pubkey,
|
|
9211
|
+
lowerBinArrayIndex,
|
|
9212
|
+
this.program.programId
|
|
9213
|
+
);
|
|
9214
|
+
const [upperBinArrayPubKey] = deriveBinArray(
|
|
9215
|
+
this.pubkey,
|
|
9216
|
+
upperBinArrayIndex,
|
|
9217
|
+
this.program.programId
|
|
9218
|
+
);
|
|
9219
|
+
const [clockAccInfo, lowerBinArrayAccInfo, upperBinArrayAccInfo] = await chunkedGetMultipleAccountInfos(
|
|
9220
|
+
this.program.provider.connection,
|
|
9221
|
+
[
|
|
9222
|
+
_web3js.SYSVAR_CLOCK_PUBKEY,
|
|
9223
|
+
lowerBinArrayPubKey,
|
|
9224
|
+
upperBinArrayPubKey
|
|
9225
|
+
]
|
|
9226
|
+
);
|
|
9227
|
+
if (!lowerBinArrayAccInfo || !upperBinArrayAccInfo) {
|
|
9228
|
+
return {
|
|
9229
|
+
publicKey: positionPubKey,
|
|
9230
|
+
positionData: {
|
|
9231
|
+
totalXAmount: "0",
|
|
9232
|
+
totalYAmount: "0",
|
|
9233
|
+
positionBinData: [],
|
|
9234
|
+
lastUpdatedAt: new (0, _anchor.BN)(0),
|
|
9235
|
+
upperBinId,
|
|
9236
|
+
lowerBinId,
|
|
9237
|
+
feeX: new (0, _anchor.BN)(0),
|
|
9238
|
+
feeY: new (0, _anchor.BN)(0),
|
|
9239
|
+
rewardOne: new (0, _anchor.BN)(0),
|
|
9240
|
+
rewardTwo: new (0, _anchor.BN)(0),
|
|
9241
|
+
feeOwner,
|
|
9242
|
+
totalClaimedFeeXAmount: new (0, _anchor.BN)(0),
|
|
9243
|
+
totalClaimedFeeYAmount: new (0, _anchor.BN)(0)
|
|
9244
|
+
},
|
|
9245
|
+
version: 1 /* V2 */
|
|
9246
|
+
};
|
|
9247
|
+
}
|
|
9248
|
+
const onChainTimestamp = new (0, _anchor.BN)(
|
|
9249
|
+
clockAccInfo.data.readBigInt64LE(32).toString()
|
|
9250
|
+
).toNumber();
|
|
9251
|
+
const lowerBinArray = this.program.coder.accounts.decode(
|
|
9252
|
+
"binArray",
|
|
9253
|
+
lowerBinArrayAccInfo.data
|
|
9254
|
+
);
|
|
9255
|
+
const upperBinArray = this.program.coder.accounts.decode(
|
|
9256
|
+
"binArray",
|
|
9257
|
+
upperBinArrayAccInfo.data
|
|
9258
|
+
);
|
|
9259
|
+
return {
|
|
9260
|
+
publicKey: positionPubKey,
|
|
9261
|
+
positionData: await DLMM.processPosition(
|
|
9262
|
+
this.program,
|
|
9263
|
+
1 /* V2 */,
|
|
9264
|
+
this.lbPair,
|
|
9265
|
+
onChainTimestamp,
|
|
9266
|
+
positionAccountInfo,
|
|
9267
|
+
this.tokenX.decimal,
|
|
9268
|
+
this.tokenY.decimal,
|
|
9269
|
+
lowerBinArray,
|
|
9270
|
+
upperBinArray,
|
|
9271
|
+
feeOwner
|
|
9272
|
+
),
|
|
9273
|
+
version: 1 /* V2 */
|
|
9274
|
+
};
|
|
9275
|
+
}
|
|
9220
9276
|
/**
|
|
9221
9277
|
* The function `initializePositionAndAddLiquidityByStrategy` function is used to initializes a position and adds liquidity
|
|
9222
9278
|
* @param {TInitializePositionAndAddLiquidityParamsByStrategy}
|
|
@@ -9940,9 +9996,13 @@ var DLMM = class {
|
|
|
9940
9996
|
bps,
|
|
9941
9997
|
shouldClaimAndClose = false
|
|
9942
9998
|
}) {
|
|
9943
|
-
const
|
|
9944
|
-
const
|
|
9945
|
-
const
|
|
9999
|
+
const lowerBinIdToRemove = Math.min(...binIds);
|
|
10000
|
+
const upperBinIdToRemove = Math.max(...binIds);
|
|
10001
|
+
const { lbPair, owner, feeOwner, lowerBinId: positionLowerBinId, liquidityShares } = await this.program.account.positionV2.fetch(position);
|
|
10002
|
+
if (liquidityShares.every((share) => share.isZero())) {
|
|
10003
|
+
throw new Error("No liquidity to remove");
|
|
10004
|
+
}
|
|
10005
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(positionLowerBinId));
|
|
9946
10006
|
const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(1));
|
|
9947
10007
|
const [binArrayLower] = deriveBinArray(
|
|
9948
10008
|
lbPair,
|
|
@@ -10002,8 +10062,8 @@ var DLMM = class {
|
|
|
10002
10062
|
lbPair: this.pubkey,
|
|
10003
10063
|
sender: user,
|
|
10004
10064
|
position,
|
|
10005
|
-
reserveX,
|
|
10006
|
-
reserveY,
|
|
10065
|
+
reserveX: this.lbPair.reserveX,
|
|
10066
|
+
reserveY: this.lbPair.reserveY,
|
|
10007
10067
|
tokenProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10008
10068
|
tokenXMint: this.tokenX.publicKey,
|
|
10009
10069
|
tokenYMint: this.tokenY.publicKey,
|
|
@@ -10056,21 +10116,19 @@ var DLMM = class {
|
|
|
10056
10116
|
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
10057
10117
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
10058
10118
|
}
|
|
10059
|
-
const
|
|
10060
|
-
const
|
|
10061
|
-
const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
|
|
10062
|
-
const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
|
|
10119
|
+
const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinIdToRemove));
|
|
10120
|
+
const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinIdToRemove));
|
|
10063
10121
|
const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
|
|
10064
10122
|
const binArrayBitmapExtension = useExtension ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
|
|
10065
|
-
const
|
|
10123
|
+
const removeLiquidityTx = await this.program.methods.removeLiquidityByRange(lowerBinIdToRemove, upperBinIdToRemove, bps.toNumber()).accounts({
|
|
10066
10124
|
position,
|
|
10067
10125
|
lbPair,
|
|
10068
10126
|
userTokenX,
|
|
10069
10127
|
userTokenY,
|
|
10070
|
-
reserveX,
|
|
10071
|
-
reserveY,
|
|
10072
|
-
tokenXMint,
|
|
10073
|
-
tokenYMint,
|
|
10128
|
+
reserveX: this.lbPair.reserveX,
|
|
10129
|
+
reserveY: this.lbPair.reserveY,
|
|
10130
|
+
tokenXMint: this.tokenX.publicKey,
|
|
10131
|
+
tokenYMint: this.tokenY.publicKey,
|
|
10074
10132
|
binArrayLower,
|
|
10075
10133
|
binArrayUpper,
|
|
10076
10134
|
binArrayBitmapExtension,
|
|
@@ -10080,7 +10138,7 @@ var DLMM = class {
|
|
|
10080
10138
|
}).instruction();
|
|
10081
10139
|
const instructions = [
|
|
10082
10140
|
...preInstructions,
|
|
10083
|
-
|
|
10141
|
+
removeLiquidityTx,
|
|
10084
10142
|
...postInstructions
|
|
10085
10143
|
];
|
|
10086
10144
|
const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
|
|
@@ -10163,6 +10221,7 @@ var DLMM = class {
|
|
|
10163
10221
|
* - `outAmount`: Amount of lamport to swap out
|
|
10164
10222
|
* - `swapForY`: Swap token X to Y when it is true, else reversed.
|
|
10165
10223
|
* - `allowedSlippage`: Allowed slippage for the swap. Expressed in BPS. To convert from slippage percentage to BPS unit: SLIPPAGE_PERCENTAGE * 100
|
|
10224
|
+
* - `maxExtraBinArrays`: Maximum number of extra binArrays to return
|
|
10166
10225
|
* @returns {SwapQuote}
|
|
10167
10226
|
* - `inAmount`: Amount of lamport to swap in
|
|
10168
10227
|
* - `outAmount`: Amount of lamport to swap out
|
|
@@ -10173,9 +10232,12 @@ var DLMM = class {
|
|
|
10173
10232
|
* @throws {DlmmSdkError}
|
|
10174
10233
|
*
|
|
10175
10234
|
*/
|
|
10176
|
-
swapQuoteExactOut(outAmount, swapForY, allowedSlippage, binArrays) {
|
|
10235
|
+
swapQuoteExactOut(outAmount, swapForY, allowedSlippage, binArrays, maxExtraBinArrays = 0) {
|
|
10177
10236
|
const currentTimestamp = Date.now() / 1e3;
|
|
10178
10237
|
let outAmountLeft = outAmount;
|
|
10238
|
+
if (maxExtraBinArrays < 0 || maxExtraBinArrays > MAX_EXTRA_BIN_ARRAYS) {
|
|
10239
|
+
throw new DlmmSdkError("INVALID_MAX_EXTRA_BIN_ARRAYS", `maxExtraBinArrays must be a value between 0 and ${MAX_EXTRA_BIN_ARRAYS}`);
|
|
10240
|
+
}
|
|
10179
10241
|
let vParameterClone = Object.assign({}, this.lbPair.vParameters);
|
|
10180
10242
|
let activeId = new (0, _anchor.BN)(this.lbPair.activeId);
|
|
10181
10243
|
const binStep = this.lbPair.binStep;
|
|
@@ -10196,7 +10258,7 @@ var DLMM = class {
|
|
|
10196
10258
|
swapForY,
|
|
10197
10259
|
activeId,
|
|
10198
10260
|
this.lbPair,
|
|
10199
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
10261
|
+
_nullishCoalesce(_optionalChain([this, 'access', _69 => _69.binArrayBitmapExtension, 'optionalAccess', _70 => _70.account]), () => ( null)),
|
|
10200
10262
|
binArrays
|
|
10201
10263
|
);
|
|
10202
10264
|
if (binArrayAccountToSwap == null) {
|
|
@@ -10249,6 +10311,41 @@ var DLMM = class {
|
|
|
10249
10311
|
);
|
|
10250
10312
|
const priceImpact = startPrice.sub(endPrice).abs().div(startPrice).mul(new (0, _decimaljs2.default)(100));
|
|
10251
10313
|
const maxInAmount = actualInAmount.mul(new (0, _anchor.BN)(BASIS_POINT_MAX).add(allowedSlippage)).div(new (0, _anchor.BN)(BASIS_POINT_MAX));
|
|
10314
|
+
if (maxExtraBinArrays > 0 && maxExtraBinArrays <= MAX_EXTRA_BIN_ARRAYS) {
|
|
10315
|
+
const extraBinArrays = new Array();
|
|
10316
|
+
while (extraBinArrays.length < maxExtraBinArrays) {
|
|
10317
|
+
let binArrayAccountToSwap = findNextBinArrayWithLiquidity(
|
|
10318
|
+
swapForY,
|
|
10319
|
+
activeId,
|
|
10320
|
+
this.lbPair,
|
|
10321
|
+
_nullishCoalesce(_optionalChain([this, 'access', _71 => _71.binArrayBitmapExtension, 'optionalAccess', _72 => _72.account]), () => ( null)),
|
|
10322
|
+
binArrays
|
|
10323
|
+
);
|
|
10324
|
+
if (binArrayAccountToSwap == null) {
|
|
10325
|
+
break;
|
|
10326
|
+
}
|
|
10327
|
+
const binArrayAccountToSwapExisted = binArraysForSwap.has(binArrayAccountToSwap.publicKey);
|
|
10328
|
+
if (binArrayAccountToSwapExisted) {
|
|
10329
|
+
if (swapForY) {
|
|
10330
|
+
activeId = activeId.sub(new (0, _anchor.BN)(1));
|
|
10331
|
+
} else {
|
|
10332
|
+
activeId = activeId.add(new (0, _anchor.BN)(1));
|
|
10333
|
+
}
|
|
10334
|
+
} else {
|
|
10335
|
+
extraBinArrays.push(binArrayAccountToSwap.publicKey);
|
|
10336
|
+
const [lowerBinId, upperBinId] = getBinArrayLowerUpperBinId(binArrayAccountToSwap.account.index);
|
|
10337
|
+
if (swapForY) {
|
|
10338
|
+
activeId = lowerBinId.sub(new (0, _anchor.BN)(1));
|
|
10339
|
+
} else {
|
|
10340
|
+
activeId = upperBinId.add(new (0, _anchor.BN)(1));
|
|
10341
|
+
}
|
|
10342
|
+
}
|
|
10343
|
+
}
|
|
10344
|
+
extraBinArrays.forEach((binArrayPubkey) => {
|
|
10345
|
+
binArraysForSwap.set(binArrayPubkey, true);
|
|
10346
|
+
});
|
|
10347
|
+
}
|
|
10348
|
+
const binArraysPubkey = Array.from(binArraysForSwap.keys());
|
|
10252
10349
|
return {
|
|
10253
10350
|
inAmount: actualInAmount,
|
|
10254
10351
|
maxInAmount,
|
|
@@ -10256,7 +10353,7 @@ var DLMM = class {
|
|
|
10256
10353
|
priceImpact,
|
|
10257
10354
|
fee: feeAmount,
|
|
10258
10355
|
protocolFee: protocolFeeAmount,
|
|
10259
|
-
binArraysPubkey
|
|
10356
|
+
binArraysPubkey
|
|
10260
10357
|
};
|
|
10261
10358
|
}
|
|
10262
10359
|
/**
|
|
@@ -10267,6 +10364,7 @@ var DLMM = class {
|
|
|
10267
10364
|
* - `allowedSlippage`: Allowed slippage for the swap. Expressed in BPS. To convert from slippage percentage to BPS unit: SLIPPAGE_PERCENTAGE * 100
|
|
10268
10365
|
* - `binArrays`: binArrays for swapQuote.
|
|
10269
10366
|
* - `isPartialFill`: Flag to check whether the the swapQuote is partial fill, default = false.
|
|
10367
|
+
* - `maxExtraBinArrays`: Maximum number of extra binArrays to return
|
|
10270
10368
|
* @returns {SwapQuote}
|
|
10271
10369
|
* - `consumedInAmount`: Amount of lamport to swap in
|
|
10272
10370
|
* - `outAmount`: Amount of lamport to swap out
|
|
@@ -10277,9 +10375,12 @@ var DLMM = class {
|
|
|
10277
10375
|
* - `binArraysPubkey`: Array of bin arrays involved in the swap
|
|
10278
10376
|
* @throws {DlmmSdkError}
|
|
10279
10377
|
*/
|
|
10280
|
-
swapQuote(inAmount, swapForY, allowedSlippage, binArrays, isPartialFill) {
|
|
10378
|
+
swapQuote(inAmount, swapForY, allowedSlippage, binArrays, isPartialFill, maxExtraBinArrays = 0) {
|
|
10281
10379
|
const currentTimestamp = Date.now() / 1e3;
|
|
10282
10380
|
let inAmountLeft = inAmount;
|
|
10381
|
+
if (maxExtraBinArrays < 0 || maxExtraBinArrays > MAX_EXTRA_BIN_ARRAYS) {
|
|
10382
|
+
throw new DlmmSdkError("INVALID_MAX_EXTRA_BIN_ARRAYS", `maxExtraBinArrays must be a value between 0 and ${MAX_EXTRA_BIN_ARRAYS}`);
|
|
10383
|
+
}
|
|
10283
10384
|
let vParameterClone = Object.assign({}, this.lbPair.vParameters);
|
|
10284
10385
|
let activeId = new (0, _anchor.BN)(this.lbPair.activeId);
|
|
10285
10386
|
const binStep = this.lbPair.binStep;
|
|
@@ -10295,12 +10396,13 @@ var DLMM = class {
|
|
|
10295
10396
|
let actualOutAmount = new (0, _anchor.BN)(0);
|
|
10296
10397
|
let feeAmount = new (0, _anchor.BN)(0);
|
|
10297
10398
|
let protocolFeeAmount = new (0, _anchor.BN)(0);
|
|
10399
|
+
let lastFilledActiveBinId = activeId;
|
|
10298
10400
|
while (!inAmountLeft.isZero()) {
|
|
10299
10401
|
let binArrayAccountToSwap = findNextBinArrayWithLiquidity(
|
|
10300
10402
|
swapForY,
|
|
10301
10403
|
activeId,
|
|
10302
10404
|
this.lbPair,
|
|
10303
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
10405
|
+
_nullishCoalesce(_optionalChain([this, 'access', _73 => _73.binArrayBitmapExtension, 'optionalAccess', _74 => _74.account]), () => ( null)),
|
|
10304
10406
|
binArrays
|
|
10305
10407
|
);
|
|
10306
10408
|
if (binArrayAccountToSwap == null) {
|
|
@@ -10340,6 +10442,7 @@ var DLMM = class {
|
|
|
10340
10442
|
if (!startBin) {
|
|
10341
10443
|
startBin = bin;
|
|
10342
10444
|
}
|
|
10445
|
+
lastFilledActiveBinId = activeId;
|
|
10343
10446
|
}
|
|
10344
10447
|
}
|
|
10345
10448
|
if (!inAmountLeft.isZero()) {
|
|
@@ -10367,9 +10470,44 @@ var DLMM = class {
|
|
|
10367
10470
|
const priceImpact = new (0, _decimaljs2.default)(actualOutAmount.toString()).sub(new (0, _decimaljs2.default)(outAmountWithoutSlippage.toString())).div(new (0, _decimaljs2.default)(outAmountWithoutSlippage.toString())).mul(new (0, _decimaljs2.default)(100));
|
|
10368
10471
|
const minOutAmount = actualOutAmount.mul(new (0, _anchor.BN)(BASIS_POINT_MAX).sub(allowedSlippage)).div(new (0, _anchor.BN)(BASIS_POINT_MAX));
|
|
10369
10472
|
const endPrice = getPriceOfBinByBinId(
|
|
10370
|
-
|
|
10473
|
+
lastFilledActiveBinId.toNumber(),
|
|
10371
10474
|
this.lbPair.binStep
|
|
10372
10475
|
);
|
|
10476
|
+
if (maxExtraBinArrays > 0 && maxExtraBinArrays <= MAX_EXTRA_BIN_ARRAYS) {
|
|
10477
|
+
const extraBinArrays = new Array();
|
|
10478
|
+
while (extraBinArrays.length < maxExtraBinArrays) {
|
|
10479
|
+
let binArrayAccountToSwap = findNextBinArrayWithLiquidity(
|
|
10480
|
+
swapForY,
|
|
10481
|
+
activeId,
|
|
10482
|
+
this.lbPair,
|
|
10483
|
+
_nullishCoalesce(_optionalChain([this, 'access', _75 => _75.binArrayBitmapExtension, 'optionalAccess', _76 => _76.account]), () => ( null)),
|
|
10484
|
+
binArrays
|
|
10485
|
+
);
|
|
10486
|
+
if (binArrayAccountToSwap == null) {
|
|
10487
|
+
break;
|
|
10488
|
+
}
|
|
10489
|
+
const binArrayAccountToSwapExisted = binArraysForSwap.has(binArrayAccountToSwap.publicKey);
|
|
10490
|
+
if (binArrayAccountToSwapExisted) {
|
|
10491
|
+
if (swapForY) {
|
|
10492
|
+
activeId = activeId.sub(new (0, _anchor.BN)(1));
|
|
10493
|
+
} else {
|
|
10494
|
+
activeId = activeId.add(new (0, _anchor.BN)(1));
|
|
10495
|
+
}
|
|
10496
|
+
} else {
|
|
10497
|
+
extraBinArrays.push(binArrayAccountToSwap.publicKey);
|
|
10498
|
+
const [lowerBinId, upperBinId] = getBinArrayLowerUpperBinId(binArrayAccountToSwap.account.index);
|
|
10499
|
+
if (swapForY) {
|
|
10500
|
+
activeId = lowerBinId.sub(new (0, _anchor.BN)(1));
|
|
10501
|
+
} else {
|
|
10502
|
+
activeId = upperBinId.add(new (0, _anchor.BN)(1));
|
|
10503
|
+
}
|
|
10504
|
+
}
|
|
10505
|
+
}
|
|
10506
|
+
extraBinArrays.forEach((binArrayPubkey) => {
|
|
10507
|
+
binArraysForSwap.set(binArrayPubkey, true);
|
|
10508
|
+
});
|
|
10509
|
+
}
|
|
10510
|
+
const binArraysPubkey = Array.from(binArraysForSwap.keys());
|
|
10373
10511
|
return {
|
|
10374
10512
|
consumedInAmount: inAmount,
|
|
10375
10513
|
outAmount: actualOutAmount,
|
|
@@ -10377,7 +10515,7 @@ var DLMM = class {
|
|
|
10377
10515
|
protocolFee: protocolFeeAmount,
|
|
10378
10516
|
minOutAmount,
|
|
10379
10517
|
priceImpact,
|
|
10380
|
-
binArraysPubkey
|
|
10518
|
+
binArraysPubkey,
|
|
10381
10519
|
endPrice
|
|
10382
10520
|
};
|
|
10383
10521
|
}
|
|
@@ -10484,7 +10622,6 @@ var DLMM = class {
|
|
|
10484
10622
|
priceImpact,
|
|
10485
10623
|
binArraysPubkey
|
|
10486
10624
|
}) {
|
|
10487
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
|
|
10488
10625
|
const preInstructions = [];
|
|
10489
10626
|
const postInstructions = [];
|
|
10490
10627
|
const [
|
|
@@ -10518,9 +10655,6 @@ var DLMM = class {
|
|
|
10518
10655
|
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
10519
10656
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
10520
10657
|
}
|
|
10521
|
-
let swapForY = true;
|
|
10522
|
-
if (outToken.equals(tokenXMint))
|
|
10523
|
-
swapForY = false;
|
|
10524
10658
|
const binArrays = binArraysPubkey.map((pubkey) => {
|
|
10525
10659
|
return {
|
|
10526
10660
|
isSigner: false,
|
|
@@ -10534,17 +10668,17 @@ var DLMM = class {
|
|
|
10534
10668
|
priceImpact.toNumber()
|
|
10535
10669
|
).accounts({
|
|
10536
10670
|
lbPair,
|
|
10537
|
-
reserveX,
|
|
10538
|
-
reserveY,
|
|
10539
|
-
tokenXMint,
|
|
10540
|
-
tokenYMint,
|
|
10671
|
+
reserveX: this.lbPair.reserveX,
|
|
10672
|
+
reserveY: this.lbPair.reserveY,
|
|
10673
|
+
tokenXMint: this.lbPair.tokenXMint,
|
|
10674
|
+
tokenYMint: this.lbPair.tokenYMint,
|
|
10541
10675
|
tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10542
10676
|
tokenYProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10543
10677
|
user,
|
|
10544
10678
|
userTokenIn,
|
|
10545
10679
|
userTokenOut,
|
|
10546
10680
|
binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
|
|
10547
|
-
oracle,
|
|
10681
|
+
oracle: this.lbPair.oracle,
|
|
10548
10682
|
hostFeeIn: null
|
|
10549
10683
|
}).remainingAccounts(binArrays).instruction();
|
|
10550
10684
|
const instructions = [...preInstructions, swapIx, ...postInstructions];
|
|
@@ -10582,7 +10716,6 @@ var DLMM = class {
|
|
|
10582
10716
|
user,
|
|
10583
10717
|
binArraysPubkey
|
|
10584
10718
|
}) {
|
|
10585
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
|
|
10586
10719
|
const preInstructions = [];
|
|
10587
10720
|
const postInstructions = [];
|
|
10588
10721
|
const [
|
|
@@ -10616,9 +10749,6 @@ var DLMM = class {
|
|
|
10616
10749
|
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
10617
10750
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
10618
10751
|
}
|
|
10619
|
-
let swapForY = true;
|
|
10620
|
-
if (outToken.equals(tokenXMint))
|
|
10621
|
-
swapForY = false;
|
|
10622
10752
|
const binArrays = binArraysPubkey.map((pubkey) => {
|
|
10623
10753
|
return {
|
|
10624
10754
|
isSigner: false,
|
|
@@ -10628,10 +10758,10 @@ var DLMM = class {
|
|
|
10628
10758
|
});
|
|
10629
10759
|
const swapIx = await this.program.methods.swap(inAmount, minOutAmount).accounts({
|
|
10630
10760
|
lbPair,
|
|
10631
|
-
reserveX,
|
|
10632
|
-
reserveY,
|
|
10633
|
-
tokenXMint,
|
|
10634
|
-
tokenYMint,
|
|
10761
|
+
reserveX: this.lbPair.reserveX,
|
|
10762
|
+
reserveY: this.lbPair.reserveY,
|
|
10763
|
+
tokenXMint: this.lbPair.tokenXMint,
|
|
10764
|
+
tokenYMint: this.lbPair.tokenYMint,
|
|
10635
10765
|
tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10636
10766
|
// dont use 2022 first; lack familiarity
|
|
10637
10767
|
tokenYProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
@@ -10640,7 +10770,7 @@ var DLMM = class {
|
|
|
10640
10770
|
userTokenIn,
|
|
10641
10771
|
userTokenOut,
|
|
10642
10772
|
binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
|
|
10643
|
-
oracle,
|
|
10773
|
+
oracle: this.lbPair.oracle,
|
|
10644
10774
|
hostFeeIn: null
|
|
10645
10775
|
}).remainingAccounts(binArrays).instruction();
|
|
10646
10776
|
const instructions = [...preInstructions, swapIx, ...postInstructions];
|
|
@@ -10742,6 +10872,21 @@ var DLMM = class {
|
|
|
10742
10872
|
lastValidBlockHeight
|
|
10743
10873
|
}).add(setActivationPointTx);
|
|
10744
10874
|
}
|
|
10875
|
+
async setPairStatus(enabled) {
|
|
10876
|
+
const pairStatus = enabled ? 0 : 1;
|
|
10877
|
+
const tx = await this.program.methods.setPairStatus(pairStatus).accounts(
|
|
10878
|
+
{
|
|
10879
|
+
lbPair: this.pubkey,
|
|
10880
|
+
admin: this.lbPair.creator
|
|
10881
|
+
}
|
|
10882
|
+
).transaction();
|
|
10883
|
+
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
10884
|
+
return new (0, _web3js.Transaction)({
|
|
10885
|
+
feePayer: this.lbPair.creator,
|
|
10886
|
+
blockhash,
|
|
10887
|
+
lastValidBlockHeight
|
|
10888
|
+
}).add(tx);
|
|
10889
|
+
}
|
|
10745
10890
|
/**
|
|
10746
10891
|
* The function `claimSwapFee` is used to claim swap fees for a specific position owned by a specific owner.
|
|
10747
10892
|
* @param
|
|
@@ -10900,9 +11045,14 @@ var DLMM = class {
|
|
|
10900
11045
|
* - `minPrice`: Start price in UI format
|
|
10901
11046
|
* - `maxPrice`: End price in UI format
|
|
10902
11047
|
* - `base`: Base key
|
|
11048
|
+
* - `txPayer`: Account rental fee payer
|
|
11049
|
+
* - `feeOwner`: Fee owner key. Default to position owner
|
|
11050
|
+
* - `operator`: Operator key
|
|
11051
|
+
* - `lockReleasePoint`: Timelock. Point (slot/timestamp) the position can withdraw the liquidity,
|
|
11052
|
+
* - `shouldSeedPositionOwner` (optional): Whether to send 1 lamport amount of token X to the position owner to prove ownership.
|
|
10903
11053
|
* @returns {Promise<SeedLiquidityResponse>}
|
|
10904
11054
|
*/
|
|
10905
|
-
async seedLiquidity(owner, seedAmount, curvature, minPrice, maxPrice, base) {
|
|
11055
|
+
async seedLiquidity(owner, seedAmount, curvature, minPrice, maxPrice, base, payer, feeOwner, operator, lockReleasePoint, shouldSeedPositionOwner = false) {
|
|
10906
11056
|
const toLamportMultiplier = new (0, _decimaljs2.default)(
|
|
10907
11057
|
10 ** (this.tokenY.decimal - this.tokenX.decimal)
|
|
10908
11058
|
);
|
|
@@ -10947,13 +11097,56 @@ var DLMM = class {
|
|
|
10947
11097
|
);
|
|
10948
11098
|
const positionCount = getPositionCount(minBinId, maxBinId.sub(new (0, _anchor.BN)(1)));
|
|
10949
11099
|
const seederTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
|
|
11100
|
+
this.lbPair.tokenXMint,
|
|
11101
|
+
operator,
|
|
11102
|
+
false
|
|
11103
|
+
);
|
|
11104
|
+
const seederTokenY = _spltoken.getAssociatedTokenAddressSync.call(void 0,
|
|
11105
|
+
this.lbPair.tokenYMint,
|
|
11106
|
+
operator,
|
|
11107
|
+
false
|
|
11108
|
+
);
|
|
11109
|
+
const ownerTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
|
|
10950
11110
|
this.lbPair.tokenXMint,
|
|
10951
11111
|
owner,
|
|
10952
11112
|
false
|
|
10953
11113
|
);
|
|
11114
|
+
const sendPositionOwnerTokenProveIxs = [];
|
|
10954
11115
|
const initializeBinArraysAndPositionIxs = [];
|
|
10955
11116
|
const addLiquidityIxs = [];
|
|
10956
11117
|
const appendedInitBinArrayIx = /* @__PURE__ */ new Set();
|
|
11118
|
+
if (shouldSeedPositionOwner) {
|
|
11119
|
+
const positionOwnerTokenX = await this.program.provider.connection.getAccountInfo(ownerTokenX);
|
|
11120
|
+
let requireTokenProve = false;
|
|
11121
|
+
if (positionOwnerTokenX) {
|
|
11122
|
+
const ownerTokenXState = _spltoken.unpackAccount.call(void 0,
|
|
11123
|
+
ownerTokenX,
|
|
11124
|
+
positionOwnerTokenX,
|
|
11125
|
+
_spltoken.TOKEN_PROGRAM_ID
|
|
11126
|
+
);
|
|
11127
|
+
requireTokenProve = ownerTokenXState.amount == 0n;
|
|
11128
|
+
} else {
|
|
11129
|
+
requireTokenProve = true;
|
|
11130
|
+
}
|
|
11131
|
+
if (requireTokenProve) {
|
|
11132
|
+
const initPositionOwnerTokenX = _spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
11133
|
+
payer,
|
|
11134
|
+
ownerTokenX,
|
|
11135
|
+
owner,
|
|
11136
|
+
this.lbPair.tokenXMint,
|
|
11137
|
+
_spltoken.TOKEN_PROGRAM_ID
|
|
11138
|
+
);
|
|
11139
|
+
sendPositionOwnerTokenProveIxs.push(initPositionOwnerTokenX);
|
|
11140
|
+
sendPositionOwnerTokenProveIxs.push(
|
|
11141
|
+
_spltoken.createTransferInstruction.call(void 0,
|
|
11142
|
+
seederTokenX,
|
|
11143
|
+
ownerTokenX,
|
|
11144
|
+
operator,
|
|
11145
|
+
1n
|
|
11146
|
+
)
|
|
11147
|
+
);
|
|
11148
|
+
}
|
|
11149
|
+
}
|
|
10957
11150
|
for (let i = 0; i < positionCount.toNumber(); i++) {
|
|
10958
11151
|
const lowerBinId = minBinId.add(MAX_BIN_PER_POSITION.mul(new (0, _anchor.BN)(i)));
|
|
10959
11152
|
const upperBinId = lowerBinId.add(MAX_BIN_PER_POSITION).sub(new (0, _anchor.BN)(1));
|
|
@@ -10988,7 +11181,7 @@ var DLMM = class {
|
|
|
10988
11181
|
await this.program.methods.initializeBinArray(lowerBinArrayIndex).accounts({
|
|
10989
11182
|
lbPair: this.pubkey,
|
|
10990
11183
|
binArray: lowerBinArray,
|
|
10991
|
-
funder:
|
|
11184
|
+
funder: payer
|
|
10992
11185
|
}).instruction()
|
|
10993
11186
|
);
|
|
10994
11187
|
appendedInitBinArrayIx.add(lowerBinArray.toBase58());
|
|
@@ -10999,7 +11192,7 @@ var DLMM = class {
|
|
|
10999
11192
|
await this.program.methods.initializeBinArray(upperBinArrayIndex).accounts({
|
|
11000
11193
|
lbPair: this.pubkey,
|
|
11001
11194
|
binArray: upperBinArray,
|
|
11002
|
-
funder:
|
|
11195
|
+
funder: payer
|
|
11003
11196
|
}).instruction()
|
|
11004
11197
|
);
|
|
11005
11198
|
appendedInitBinArrayIx.add(upperBinArray.toBase58());
|
|
@@ -11007,26 +11200,25 @@ var DLMM = class {
|
|
|
11007
11200
|
const positionAccount = accounts[2];
|
|
11008
11201
|
if (!positionAccount) {
|
|
11009
11202
|
instructions.push(
|
|
11010
|
-
await this.program.methods.
|
|
11203
|
+
await this.program.methods.initializePositionByOperator(
|
|
11011
11204
|
lowerBinId.toNumber(),
|
|
11012
|
-
MAX_BIN_PER_POSITION.toNumber()
|
|
11205
|
+
MAX_BIN_PER_POSITION.toNumber(),
|
|
11206
|
+
feeOwner,
|
|
11207
|
+
lockReleasePoint
|
|
11013
11208
|
).accounts({
|
|
11014
11209
|
lbPair: this.pubkey,
|
|
11015
11210
|
position: positionPda,
|
|
11016
11211
|
base,
|
|
11017
11212
|
owner,
|
|
11018
|
-
payer
|
|
11213
|
+
payer,
|
|
11214
|
+
operator,
|
|
11215
|
+
operatorTokenX: seederTokenX,
|
|
11216
|
+
ownerTokenX,
|
|
11217
|
+
systemProgram: _web3js.SystemProgram.programId
|
|
11019
11218
|
}).instruction()
|
|
11020
11219
|
);
|
|
11021
11220
|
}
|
|
11022
11221
|
if (instructions.length > 1) {
|
|
11023
|
-
instructions.push(
|
|
11024
|
-
await getEstimatedComputeUnitIxWithBuffer(
|
|
11025
|
-
this.program.provider.connection,
|
|
11026
|
-
instructions,
|
|
11027
|
-
owner
|
|
11028
|
-
)
|
|
11029
|
-
);
|
|
11030
11222
|
initializeBinArraysAndPositionIxs.push(instructions);
|
|
11031
11223
|
instructions = [];
|
|
11032
11224
|
}
|
|
@@ -11056,7 +11248,7 @@ var DLMM = class {
|
|
|
11056
11248
|
tokenMint: this.lbPair.tokenXMint,
|
|
11057
11249
|
binArrayLower: lowerBinArray,
|
|
11058
11250
|
binArrayUpper: upperBinArray,
|
|
11059
|
-
sender:
|
|
11251
|
+
sender: operator
|
|
11060
11252
|
}).instruction()
|
|
11061
11253
|
);
|
|
11062
11254
|
if (i + 1 >= positionCount.toNumber() && !finalLoss.isZero()) {
|
|
@@ -11080,7 +11272,7 @@ var DLMM = class {
|
|
|
11080
11272
|
tokenMint: this.lbPair.tokenXMint,
|
|
11081
11273
|
binArrayLower: lowerBinArray,
|
|
11082
11274
|
binArrayUpper: upperBinArray,
|
|
11083
|
-
sender:
|
|
11275
|
+
sender: operator
|
|
11084
11276
|
}).instruction()
|
|
11085
11277
|
);
|
|
11086
11278
|
}
|
|
@@ -11092,7 +11284,9 @@ var DLMM = class {
|
|
|
11092
11284
|
]);
|
|
11093
11285
|
}
|
|
11094
11286
|
}
|
|
11287
|
+
console.log("let return");
|
|
11095
11288
|
return {
|
|
11289
|
+
sendPositionOwnerTokenProveIxs,
|
|
11096
11290
|
initializeBinArraysAndPositionIxs,
|
|
11097
11291
|
addLiquidityIxs
|
|
11098
11292
|
};
|
|
@@ -11486,7 +11680,7 @@ var DLMM = class {
|
|
|
11486
11680
|
swapForY,
|
|
11487
11681
|
new (0, _anchor.BN)(activeBinId),
|
|
11488
11682
|
this.lbPair,
|
|
11489
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
11683
|
+
_nullishCoalesce(_optionalChain([this, 'access', _77 => _77.binArrayBitmapExtension, 'optionalAccess', _78 => _78.account]), () => ( null))
|
|
11490
11684
|
);
|
|
11491
11685
|
if (toBinArrayIndex === null)
|
|
11492
11686
|
return true;
|
|
@@ -11523,7 +11717,7 @@ var DLMM = class {
|
|
|
11523
11717
|
swapForY,
|
|
11524
11718
|
new (0, _anchor.BN)(activeBinId),
|
|
11525
11719
|
this.lbPair,
|
|
11526
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
11720
|
+
_nullishCoalesce(_optionalChain([this, 'access', _79 => _79.binArrayBitmapExtension, 'optionalAccess', _80 => _80.account]), () => ( null))
|
|
11527
11721
|
);
|
|
11528
11722
|
const accountsToFetch = [];
|
|
11529
11723
|
const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
|
|
@@ -11554,13 +11748,13 @@ var DLMM = class {
|
|
|
11554
11748
|
let fromBinArray = null;
|
|
11555
11749
|
let toBinArray = null;
|
|
11556
11750
|
let binArrayBitmapExtension = null;
|
|
11557
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
11751
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _81 => _81[0]])) {
|
|
11558
11752
|
binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
|
|
11559
11753
|
}
|
|
11560
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
11754
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _82 => _82[1]])) {
|
|
11561
11755
|
fromBinArray = fromBinArrayPubkey;
|
|
11562
11756
|
}
|
|
11563
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
11757
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _83 => _83[2]]) && !!toBinArrayIndex) {
|
|
11564
11758
|
toBinArray = toBinArrayPubkey;
|
|
11565
11759
|
}
|
|
11566
11760
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
@@ -11885,12 +12079,7 @@ var DLMM = class {
|
|
|
11885
12079
|
let totalYAmount = new (0, _decimaljs2.default)(0);
|
|
11886
12080
|
bins.forEach((bin, idx) => {
|
|
11887
12081
|
const binSupply = new (0, _decimaljs2.default)(bin.supply.toString());
|
|
11888
|
-
|
|
11889
|
-
if (bin.version === 1 && version === 0 /* V1 */) {
|
|
11890
|
-
posShare = new (0, _decimaljs2.default)(posShares[idx].shln(64).toString());
|
|
11891
|
-
} else {
|
|
11892
|
-
posShare = new (0, _decimaljs2.default)(posShares[idx].toString());
|
|
11893
|
-
}
|
|
12082
|
+
const posShare = new (0, _decimaljs2.default)(posShares[idx].toString());
|
|
11894
12083
|
const positionXAmount = binSupply.eq(new (0, _decimaljs2.default)("0")) ? new (0, _decimaljs2.default)("0") : posShare.mul(bin.xAmount.toString()).div(binSupply);
|
|
11895
12084
|
const positionYAmount = binSupply.eq(new (0, _decimaljs2.default)("0")) ? new (0, _decimaljs2.default)("0") : posShare.mul(bin.yAmount.toString()).div(binSupply);
|
|
11896
12085
|
totalXAmount = totalXAmount.add(positionXAmount);
|
|
@@ -12041,7 +12230,7 @@ var DLMM = class {
|
|
|
12041
12230
|
const [lowerBinId2] = getBinArrayLowerUpperBinId(index);
|
|
12042
12231
|
return bins.map((b, i) => [lowerBinId2.toNumber() + i, b]);
|
|
12043
12232
|
}));
|
|
12044
|
-
const version = _nullishCoalesce(_optionalChain([binArrays, 'access',
|
|
12233
|
+
const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _84 => _84.find, 'call', _85 => _85((binArray) => binArray != null), 'optionalAccess', _86 => _86.version]), () => ( 1));
|
|
12045
12234
|
return Array.from(enumerateBins(
|
|
12046
12235
|
binsById,
|
|
12047
12236
|
lowerBinId,
|
|
@@ -12335,5 +12524,5 @@ var src_default = DLMM;
|
|
|
12335
12524
|
|
|
12336
12525
|
|
|
12337
12526
|
|
|
12338
|
-
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.BinLiquidity = BinLiquidity; 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.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.enumerateBins = enumerateBins; 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.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; 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.range = range; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.
|
|
12527
|
+
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.BinLiquidity = BinLiquidity; 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_EXTRA_BIN_ARRAYS = MAX_EXTRA_BIN_ARRAYS; 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.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.enumerateBins = enumerateBins; 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.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; 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.range = range; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
12339
12528
|
//# sourceMappingURL=index.js.map
|