@meteora-ag/dlmm 1.0.32-rcc.4 → 1.0.32
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/README.md +1 -0
- package/dist/index.d.ts +46 -26
- package/dist/index.js +185 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -231,6 +231,7 @@ try {
|
|
|
231
231
|
| `claimSwapFee` | Claim swap fees for a specific position owned by a specific owner | `Promise<Transaction>` |
|
|
232
232
|
| `claimAllSwapFee` | Claim swap fees for multiple positions owned by a specific owner | `Promise<Transaction>` |
|
|
233
233
|
| `claimAllRewards` | Claim swap fees and LM rewards for multiple positions owned by a specific owner | `Promise<Transaction[]>` |
|
|
234
|
+
| `syncWithMarketPrice` | Sync the pool current active bin to match nearest market price bin | `Promise<Transaction>` |
|
|
234
235
|
|
|
235
236
|
```
|
|
236
237
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1768,6 +1768,39 @@ type LbClmm = {
|
|
|
1768
1768
|
}
|
|
1769
1769
|
];
|
|
1770
1770
|
},
|
|
1771
|
+
{
|
|
1772
|
+
name: "initializePresetParameterV2";
|
|
1773
|
+
accounts: [
|
|
1774
|
+
{
|
|
1775
|
+
name: "presetParameter";
|
|
1776
|
+
isMut: true;
|
|
1777
|
+
isSigner: false;
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
name: "admin";
|
|
1781
|
+
isMut: true;
|
|
1782
|
+
isSigner: true;
|
|
1783
|
+
},
|
|
1784
|
+
{
|
|
1785
|
+
name: "systemProgram";
|
|
1786
|
+
isMut: false;
|
|
1787
|
+
isSigner: false;
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
name: "rent";
|
|
1791
|
+
isMut: false;
|
|
1792
|
+
isSigner: false;
|
|
1793
|
+
}
|
|
1794
|
+
];
|
|
1795
|
+
args: [
|
|
1796
|
+
{
|
|
1797
|
+
name: "ix";
|
|
1798
|
+
type: {
|
|
1799
|
+
defined: "InitPresetParametersIx";
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
];
|
|
1803
|
+
},
|
|
1771
1804
|
{
|
|
1772
1805
|
name: "closePresetParameter";
|
|
1773
1806
|
accounts: [
|
|
@@ -2507,20 +2540,10 @@ type LbClmm = {
|
|
|
2507
2540
|
docs: ["Status of the pair. Check PairStatus enum."];
|
|
2508
2541
|
type: "u8";
|
|
2509
2542
|
},
|
|
2510
|
-
{
|
|
2511
|
-
name: "requireBaseFactorSeed";
|
|
2512
|
-
type: "u8";
|
|
2513
|
-
},
|
|
2514
|
-
{
|
|
2515
|
-
name: "baseFactorSeed";
|
|
2516
|
-
type: {
|
|
2517
|
-
array: ["u8", 2];
|
|
2518
|
-
};
|
|
2519
|
-
},
|
|
2520
2543
|
{
|
|
2521
2544
|
name: "padding1";
|
|
2522
2545
|
type: {
|
|
2523
|
-
array: ["u8",
|
|
2546
|
+
array: ["u8", 5];
|
|
2524
2547
|
};
|
|
2525
2548
|
},
|
|
2526
2549
|
{
|
|
@@ -4847,7 +4870,6 @@ declare class DLMM {
|
|
|
4847
4870
|
* `LbPairAccount` objects.
|
|
4848
4871
|
*/
|
|
4849
4872
|
static getLbPairs(connection: Connection, opt?: Opt): Promise<LbPairAccount[]>;
|
|
4850
|
-
static checkPoolExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, opt?: Opt): Promise<boolean>;
|
|
4851
4873
|
/**
|
|
4852
4874
|
* The `create` function is a static method that creates a new instance of the `DLMM` class
|
|
4853
4875
|
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
@@ -4897,7 +4919,7 @@ declare class DLMM {
|
|
|
4897
4919
|
static getBinIdFromPrice(price: string | number | Decimal, binStep: number, min: boolean): number;
|
|
4898
4920
|
/** Public methods */
|
|
4899
4921
|
static createPermissionLbPair(connection: Connection, binStep: BN, tokenX: PublicKey, tokenY: PublicKey, activeId: BN, baseKey: PublicKey, creatorKey: PublicKey, feeBps: BN, lockDurationInSlot: BN, opt?: Opt): Promise<Transaction>;
|
|
4900
|
-
static createLbPair(connection: Connection, funder: PublicKey, tokenX: PublicKey, tokenY: PublicKey,
|
|
4922
|
+
static createLbPair(connection: Connection, funder: PublicKey, tokenX: PublicKey, tokenY: PublicKey, presetParameter: PublicKey, activeId: BN, opt?: Opt): Promise<Transaction>;
|
|
4901
4923
|
/**
|
|
4902
4924
|
* The function `refetchStates` retrieves and updates various states and data related to bin arrays
|
|
4903
4925
|
* and lb pairs.
|
|
@@ -5244,6 +5266,15 @@ declare class DLMM {
|
|
|
5244
5266
|
owner: PublicKey;
|
|
5245
5267
|
positions: LbPosition[];
|
|
5246
5268
|
}): Promise<Transaction[]>;
|
|
5269
|
+
canSyncWithMarketPrice(marketPrice: number, activeBinId: number): boolean;
|
|
5270
|
+
/**
|
|
5271
|
+
* The `syncWithMarketPrice` function is used to sync the liquidity pool with the market price.
|
|
5272
|
+
* @param
|
|
5273
|
+
* - `marketPrice`: The market price to sync with.
|
|
5274
|
+
* - `owner`: The public key of the owner of the liquidity pool.
|
|
5275
|
+
* @returns {Promise<Transaction>}
|
|
5276
|
+
*/
|
|
5277
|
+
syncWithMarketPrice(marketPrice: number, owner: PublicKey): Promise<Transaction>;
|
|
5247
5278
|
/** Private static method */
|
|
5248
5279
|
private static getBinArrays;
|
|
5249
5280
|
private static getClaimableLMReward;
|
|
@@ -5263,18 +5294,9 @@ declare class DLMM {
|
|
|
5263
5294
|
}
|
|
5264
5295
|
|
|
5265
5296
|
/** private */
|
|
5266
|
-
/**
|
|
5267
|
-
*
|
|
5268
|
-
* @deprecated Use derivePresetParameter2
|
|
5269
|
-
*/
|
|
5270
5297
|
declare function derivePresetParameter(binStep: BN, programId: PublicKey): [PublicKey, number];
|
|
5271
|
-
declare function derivePresetParameter2(binStep: BN, baseFactor: BN, programId: PublicKey): [PublicKey, number];
|
|
5272
|
-
declare function deriveLbPair2(tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, programId: PublicKey): [PublicKey, number];
|
|
5273
|
-
/**
|
|
5274
|
-
*
|
|
5275
|
-
* @deprecated Use deriveLbPair2
|
|
5276
|
-
*/
|
|
5277
5298
|
declare function deriveLbPair(tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): [PublicKey, number];
|
|
5299
|
+
declare function checkPoolExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): Promise<PublicKey | false>;
|
|
5278
5300
|
declare function derivePermissionLbPair(baseKey: PublicKey, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): [PublicKey, number];
|
|
5279
5301
|
declare function deriveOracle(lbPair: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
5280
5302
|
declare function derivePosition(mint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
@@ -5559,8 +5581,6 @@ declare function chunkedFetchMultiplePoolAccount(program: ClmmProgram, pks: Publ
|
|
|
5559
5581
|
activeId: number;
|
|
5560
5582
|
binStep: number;
|
|
5561
5583
|
status: number;
|
|
5562
|
-
requireBaseFactorSeed: number;
|
|
5563
|
-
baseFactorSeed: number[];
|
|
5564
5584
|
padding1: number[];
|
|
5565
5585
|
tokenXMint: PublicKey;
|
|
5566
5586
|
tokenYMint: PublicKey;
|
|
@@ -5649,4 +5669,4 @@ declare const MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = 26;
|
|
|
5649
5669
|
declare const MAX_BIN_PER_TX = 69;
|
|
5650
5670
|
declare const MAX_ACTIVE_BIN_SLIPPAGE = 3;
|
|
5651
5671
|
|
|
5652
|
-
export { ADMIN, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, DLMMError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_POSITION, MAX_BIN_PER_TX, MAX_CLAIM_ALL_ALLOWED, MAX_FEE_RATE, Network, POSITION_FEE, PRECISION, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, Strategy, StrategyParameters, StrategyType, SwapFee, SwapParams, SwapQuote, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TQuoteCreatePositionParams, TokenReserve, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binIdToBinArrayIndex, calculateBidAskDistribution, calculateNormalDistribution, calculateSpotDistribution, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeBudgetIx, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveLbPair,
|
|
5672
|
+
export { ADMIN, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, DLMMError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_POSITION, MAX_BIN_PER_TX, MAX_CLAIM_ALL_ALLOWED, MAX_FEE_RATE, Network, POSITION_FEE, PRECISION, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, Strategy, StrategyParameters, StrategyType, SwapFee, SwapParams, SwapQuote, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TQuoteCreatePositionParams, TokenReserve, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binIdToBinArrayIndex, calculateBidAskDistribution, calculateNormalDistribution, calculateSpotDistribution, checkPoolExists, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeBudgetIx, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveLbPair, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapQuoteAtBin, swapQuoteAtBinWithCap, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -1772,6 +1772,39 @@ var IDL = {
|
|
|
1772
1772
|
}
|
|
1773
1773
|
]
|
|
1774
1774
|
},
|
|
1775
|
+
{
|
|
1776
|
+
name: "initializePresetParameterV2",
|
|
1777
|
+
accounts: [
|
|
1778
|
+
{
|
|
1779
|
+
name: "presetParameter",
|
|
1780
|
+
isMut: true,
|
|
1781
|
+
isSigner: false
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
name: "admin",
|
|
1785
|
+
isMut: true,
|
|
1786
|
+
isSigner: true
|
|
1787
|
+
},
|
|
1788
|
+
{
|
|
1789
|
+
name: "systemProgram",
|
|
1790
|
+
isMut: false,
|
|
1791
|
+
isSigner: false
|
|
1792
|
+
},
|
|
1793
|
+
{
|
|
1794
|
+
name: "rent",
|
|
1795
|
+
isMut: false,
|
|
1796
|
+
isSigner: false
|
|
1797
|
+
}
|
|
1798
|
+
],
|
|
1799
|
+
args: [
|
|
1800
|
+
{
|
|
1801
|
+
name: "ix",
|
|
1802
|
+
type: {
|
|
1803
|
+
defined: "InitPresetParametersIx"
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
]
|
|
1807
|
+
},
|
|
1775
1808
|
{
|
|
1776
1809
|
name: "closePresetParameter",
|
|
1777
1810
|
accounts: [
|
|
@@ -2511,20 +2544,10 @@ var IDL = {
|
|
|
2511
2544
|
docs: ["Status of the pair. Check PairStatus enum."],
|
|
2512
2545
|
type: "u8"
|
|
2513
2546
|
},
|
|
2514
|
-
{
|
|
2515
|
-
name: "requireBaseFactorSeed",
|
|
2516
|
-
type: "u8"
|
|
2517
|
-
},
|
|
2518
|
-
{
|
|
2519
|
-
name: "baseFactorSeed",
|
|
2520
|
-
type: {
|
|
2521
|
-
array: ["u8", 2]
|
|
2522
|
-
}
|
|
2523
|
-
},
|
|
2524
2547
|
{
|
|
2525
2548
|
name: "padding1",
|
|
2526
2549
|
type: {
|
|
2527
|
-
array: ["u8",
|
|
2550
|
+
array: ["u8", 5]
|
|
2528
2551
|
}
|
|
2529
2552
|
},
|
|
2530
2553
|
{
|
|
@@ -4905,28 +4928,6 @@ function derivePresetParameter(binStep, programId) {
|
|
|
4905
4928
|
programId
|
|
4906
4929
|
);
|
|
4907
4930
|
}
|
|
4908
|
-
function derivePresetParameter2(binStep, baseFactor, programId) {
|
|
4909
|
-
return _web3js.PublicKey.findProgramAddressSync(
|
|
4910
|
-
[
|
|
4911
|
-
Buffer.from("preset_parameter"),
|
|
4912
|
-
new Uint8Array(binStep.toArrayLike(Buffer, "le", 2)),
|
|
4913
|
-
new Uint8Array(baseFactor.toArrayLike(Buffer, "le", 2))
|
|
4914
|
-
],
|
|
4915
|
-
programId
|
|
4916
|
-
);
|
|
4917
|
-
}
|
|
4918
|
-
function deriveLbPair2(tokenX, tokenY, binStep, baseFactor, programId) {
|
|
4919
|
-
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
4920
|
-
return _web3js.PublicKey.findProgramAddressSync(
|
|
4921
|
-
[
|
|
4922
|
-
minKey.toBuffer(),
|
|
4923
|
-
maxKey.toBuffer(),
|
|
4924
|
-
new Uint8Array(binStep.toArrayLike(Buffer, "le", 2)),
|
|
4925
|
-
new Uint8Array(baseFactor.toArrayLike(Buffer, "le", 2))
|
|
4926
|
-
],
|
|
4927
|
-
programId
|
|
4928
|
-
);
|
|
4929
|
-
}
|
|
4930
4931
|
function deriveLbPair(tokenX, tokenY, binStep, programId) {
|
|
4931
4932
|
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
4932
4933
|
return _web3js.PublicKey.findProgramAddressSync(
|
|
@@ -4938,15 +4939,19 @@ function deriveLbPair(tokenX, tokenY, binStep, programId) {
|
|
|
4938
4939
|
programId
|
|
4939
4940
|
);
|
|
4940
4941
|
}
|
|
4942
|
+
async function checkPoolExists(connection, tokenX, tokenY, binStep, programId) {
|
|
4943
|
+
try {
|
|
4944
|
+
const [lbPairKey] = deriveLbPair(tokenX, tokenY, binStep, programId);
|
|
4945
|
+
await DLMM.create(connection, lbPairKey);
|
|
4946
|
+
return lbPairKey;
|
|
4947
|
+
} catch (e2) {
|
|
4948
|
+
return false;
|
|
4949
|
+
}
|
|
4950
|
+
}
|
|
4941
4951
|
function derivePermissionLbPair(baseKey, tokenX, tokenY, binStep, programId) {
|
|
4942
4952
|
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
4943
4953
|
return _web3js.PublicKey.findProgramAddressSync(
|
|
4944
|
-
[
|
|
4945
|
-
baseKey.toBuffer(),
|
|
4946
|
-
minKey.toBuffer(),
|
|
4947
|
-
maxKey.toBuffer(),
|
|
4948
|
-
new Uint8Array(binStep.toArrayLike(Buffer, "le", 2))
|
|
4949
|
-
],
|
|
4954
|
+
[baseKey.toBuffer(), minKey.toBuffer(), maxKey.toBuffer(), new Uint8Array(binStep.toArrayLike(Buffer, "le", 2))],
|
|
4950
4955
|
programId
|
|
4951
4956
|
);
|
|
4952
4957
|
}
|
|
@@ -5114,7 +5119,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5114
5119
|
let startBinArrayIndex = binIdToBinArrayIndex(activeId);
|
|
5115
5120
|
while (true) {
|
|
5116
5121
|
if (isOverflowDefaultBinArrayBitmap(startBinArrayIndex)) {
|
|
5117
|
-
if (binArrayBitmapExtension
|
|
5122
|
+
if (binArrayBitmapExtension === null) {
|
|
5118
5123
|
return null;
|
|
5119
5124
|
}
|
|
5120
5125
|
const [minBinArrayIndex, maxBinArrayIndex] = extensionBitmapRange();
|
|
@@ -5125,7 +5130,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5125
5130
|
minBinArrayIndex.toNumber(),
|
|
5126
5131
|
binArrayBitmapExtension
|
|
5127
5132
|
);
|
|
5128
|
-
if (binArrayIndex
|
|
5133
|
+
if (binArrayIndex !== null) {
|
|
5129
5134
|
return new (0, _anchor.BN)(binArrayIndex);
|
|
5130
5135
|
} else {
|
|
5131
5136
|
return null;
|
|
@@ -5136,7 +5141,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5136
5141
|
BIN_ARRAY_BITMAP_SIZE.neg().sub(new (0, _anchor.BN)(1)).toNumber(),
|
|
5137
5142
|
binArrayBitmapExtension
|
|
5138
5143
|
);
|
|
5139
|
-
if (binArrayIndex
|
|
5144
|
+
if (binArrayIndex !== null) {
|
|
5140
5145
|
return new (0, _anchor.BN)(binArrayIndex);
|
|
5141
5146
|
} else {
|
|
5142
5147
|
startBinArrayIndex = BIN_ARRAY_BITMAP_SIZE.neg();
|
|
@@ -5149,7 +5154,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5149
5154
|
BIN_ARRAY_BITMAP_SIZE.toNumber(),
|
|
5150
5155
|
binArrayBitmapExtension
|
|
5151
5156
|
);
|
|
5152
|
-
if (binArrayIndex
|
|
5157
|
+
if (binArrayIndex !== null) {
|
|
5153
5158
|
return new (0, _anchor.BN)(binArrayIndex);
|
|
5154
5159
|
} else {
|
|
5155
5160
|
startBinArrayIndex = BIN_ARRAY_BITMAP_SIZE;
|
|
@@ -5160,7 +5165,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5160
5165
|
maxBinArrayIndex.toNumber(),
|
|
5161
5166
|
binArrayBitmapExtension
|
|
5162
5167
|
);
|
|
5163
|
-
if (binArrayIndex
|
|
5168
|
+
if (binArrayIndex !== null) {
|
|
5164
5169
|
return new (0, _anchor.BN)(binArrayIndex);
|
|
5165
5170
|
} else {
|
|
5166
5171
|
return null;
|
|
@@ -5179,7 +5184,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5179
5184
|
const upperBitRange = new (0, _anchor.BN)(bitmapDetail.bits - 1).sub(offset);
|
|
5180
5185
|
const croppedBitmap = bitmap.shln(upperBitRange.toNumber());
|
|
5181
5186
|
const msb = mostSignificantBit(croppedBitmap, bitmapDetail.bits);
|
|
5182
|
-
if (msb
|
|
5187
|
+
if (msb !== null) {
|
|
5183
5188
|
return startBinArrayIndex.sub(new (0, _anchor.BN)(msb));
|
|
5184
5189
|
} else {
|
|
5185
5190
|
startBinArrayIndex = lowerBinArrayIndex.sub(new (0, _anchor.BN)(1));
|
|
@@ -5188,7 +5193,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5188
5193
|
const lowerBitRange = offset;
|
|
5189
5194
|
const croppedBitmap = bitmap.shrn(lowerBitRange.toNumber());
|
|
5190
5195
|
const lsb = leastSignificantBit(croppedBitmap, bitmapDetail.bits);
|
|
5191
|
-
if (lsb
|
|
5196
|
+
if (lsb !== null) {
|
|
5192
5197
|
return startBinArrayIndex.add(new (0, _anchor.BN)(lsb));
|
|
5193
5198
|
} else {
|
|
5194
5199
|
startBinArrayIndex = upperBinArrayIndex.add(new (0, _anchor.BN)(1));
|
|
@@ -6518,28 +6523,6 @@ var DLMM = class {
|
|
|
6518
6523
|
);
|
|
6519
6524
|
return program.account.lbPair.all();
|
|
6520
6525
|
}
|
|
6521
|
-
static async checkPoolExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
6522
|
-
const cluster = _optionalChain([opt, 'optionalAccess', _21 => _21.cluster]) || "mainnet-beta";
|
|
6523
|
-
const provider = new (0, _anchor.AnchorProvider)(
|
|
6524
|
-
connection,
|
|
6525
|
-
{},
|
|
6526
|
-
_anchor.AnchorProvider.defaultOptions()
|
|
6527
|
-
);
|
|
6528
|
-
const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
|
|
6529
|
-
try {
|
|
6530
|
-
const [lbPairKey] = deriveLbPair2(
|
|
6531
|
-
tokenX,
|
|
6532
|
-
tokenY,
|
|
6533
|
-
binStep,
|
|
6534
|
-
baseFactor,
|
|
6535
|
-
program.programId
|
|
6536
|
-
);
|
|
6537
|
-
await program.account.lbPair.fetch(lbPairKey);
|
|
6538
|
-
return true;
|
|
6539
|
-
} catch (e2) {
|
|
6540
|
-
return false;
|
|
6541
|
-
}
|
|
6542
|
-
}
|
|
6543
6526
|
/**
|
|
6544
6527
|
* The `create` function is a static method that creates a new instance of the `DLMM` class
|
|
6545
6528
|
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
@@ -6550,7 +6533,7 @@ var DLMM = class {
|
|
|
6550
6533
|
* @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
|
|
6551
6534
|
*/
|
|
6552
6535
|
static async create(connection, dlmm, opt) {
|
|
6553
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6536
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _21 => _21.cluster]) || "mainnet-beta";
|
|
6554
6537
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6555
6538
|
connection,
|
|
6556
6539
|
{},
|
|
@@ -6566,14 +6549,14 @@ var DLMM = class {
|
|
|
6566
6549
|
connection,
|
|
6567
6550
|
accountsToFetch
|
|
6568
6551
|
);
|
|
6569
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6552
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.data]);
|
|
6570
6553
|
if (!lbPairAccountInfoBuffer)
|
|
6571
6554
|
throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
|
|
6572
6555
|
const lbPairAccInfo = program.coder.accounts.decode(
|
|
6573
6556
|
"lbPair",
|
|
6574
6557
|
lbPairAccountInfoBuffer
|
|
6575
6558
|
);
|
|
6576
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6559
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _24 => _24[1], 'optionalAccess', _25 => _25.data]);
|
|
6577
6560
|
let binArrayBitMapExtensionAccInfo = null;
|
|
6578
6561
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6579
6562
|
binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
@@ -6637,7 +6620,7 @@ var DLMM = class {
|
|
|
6637
6620
|
* objects.
|
|
6638
6621
|
*/
|
|
6639
6622
|
static async createMultiple(connection, dlmmList, opt) {
|
|
6640
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6623
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _26 => _26.cluster]) || "mainnet-beta";
|
|
6641
6624
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6642
6625
|
connection,
|
|
6643
6626
|
{},
|
|
@@ -6655,7 +6638,7 @@ var DLMM = class {
|
|
|
6655
6638
|
const lbPairArraysMap = /* @__PURE__ */ new Map();
|
|
6656
6639
|
for (let i = 0; i < dlmmList.length; i++) {
|
|
6657
6640
|
const lbPairPubKey = dlmmList[i];
|
|
6658
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6641
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _27 => _27[i], 'optionalAccess', _28 => _28.data]);
|
|
6659
6642
|
if (!lbPairAccountInfoBuffer)
|
|
6660
6643
|
throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
|
|
6661
6644
|
const binArrayAccInfo = program.coder.accounts.decode(
|
|
@@ -6668,7 +6651,7 @@ var DLMM = class {
|
|
|
6668
6651
|
for (let i = dlmmList.length; i < accountsInfo.length; i++) {
|
|
6669
6652
|
const index = i - dlmmList.length;
|
|
6670
6653
|
const lbPairPubkey = dlmmList[index];
|
|
6671
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6654
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _29 => _29[i], 'optionalAccess', _30 => _30.data]);
|
|
6672
6655
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6673
6656
|
const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
6674
6657
|
"binArrayBitmapExtension",
|
|
@@ -6751,7 +6734,7 @@ var DLMM = class {
|
|
|
6751
6734
|
);
|
|
6752
6735
|
const program = new (0, _anchor.Program)(
|
|
6753
6736
|
IDL,
|
|
6754
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6737
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _31 => _31.cluster]), () => ( "mainnet-beta"))],
|
|
6755
6738
|
provider
|
|
6756
6739
|
);
|
|
6757
6740
|
const presetParameter = await program.account.presetParameter.all();
|
|
@@ -6769,7 +6752,7 @@ var DLMM = class {
|
|
|
6769
6752
|
* Pair account, and the value is an object of PositionInfo
|
|
6770
6753
|
*/
|
|
6771
6754
|
static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
|
|
6772
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6755
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _32 => _32.cluster]) || "mainnet-beta";
|
|
6773
6756
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6774
6757
|
connection,
|
|
6775
6758
|
{},
|
|
@@ -7004,8 +6987,8 @@ var DLMM = class {
|
|
|
7004
6987
|
const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
|
|
7005
6988
|
lbPair.toBase58()
|
|
7006
6989
|
);
|
|
7007
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
7008
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
6990
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _33 => _33.get, 'call', _34 => _34(lbPair.toBase58()), 'optionalAccess', _35 => _35.reserveX]), () => ( BigInt(0)));
|
|
6991
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _36 => _36.get, 'call', _37 => _37(lbPair.toBase58()), 'optionalAccess', _38 => _38.reserveY]), () => ( BigInt(0)));
|
|
7009
6992
|
const tokenX = {
|
|
7010
6993
|
publicKey: lbPairAcc.tokenXMint,
|
|
7011
6994
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7037,7 +7020,7 @@ var DLMM = class {
|
|
|
7037
7020
|
tokenX,
|
|
7038
7021
|
tokenY,
|
|
7039
7022
|
lbPairPositionsData: [
|
|
7040
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7023
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _39 => _39.get, 'call', _40 => _40(lbPair.toBase58()), 'optionalAccess', _41 => _41.lbPairPositionsData]), () => ( [])),
|
|
7041
7024
|
{
|
|
7042
7025
|
publicKey: positionPubKey,
|
|
7043
7026
|
positionData,
|
|
@@ -7073,8 +7056,8 @@ var DLMM = class {
|
|
|
7073
7056
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
|
|
7074
7057
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
|
|
7075
7058
|
]);
|
|
7076
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7077
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7059
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _42 => _42.get, 'call', _43 => _43(lbPair.toBase58()), 'optionalAccess', _44 => _44.reserveX]), () => ( BigInt(0)));
|
|
7060
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _45 => _45.get, 'call', _46 => _46(lbPair.toBase58()), 'optionalAccess', _47 => _47.reserveY]), () => ( BigInt(0)));
|
|
7078
7061
|
const tokenX = {
|
|
7079
7062
|
publicKey: lbPairAcc.tokenXMint,
|
|
7080
7063
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7106,7 +7089,7 @@ var DLMM = class {
|
|
|
7106
7089
|
tokenX,
|
|
7107
7090
|
tokenY,
|
|
7108
7091
|
lbPairPositionsData: [
|
|
7109
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7092
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _48 => _48.get, 'call', _49 => _49(lbPair.toBase58()), 'optionalAccess', _50 => _50.lbPairPositionsData]), () => ( [])),
|
|
7110
7093
|
{
|
|
7111
7094
|
publicKey: positionPubKey,
|
|
7112
7095
|
positionData,
|
|
@@ -7119,7 +7102,7 @@ var DLMM = class {
|
|
|
7119
7102
|
return positionsMap;
|
|
7120
7103
|
}
|
|
7121
7104
|
static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
|
|
7122
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
7105
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _51 => _51.cluster]) || "mainnet-beta";
|
|
7123
7106
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7124
7107
|
connection,
|
|
7125
7108
|
{},
|
|
@@ -7218,20 +7201,18 @@ var DLMM = class {
|
|
|
7218
7201
|
base: baseKey
|
|
7219
7202
|
}).transaction();
|
|
7220
7203
|
}
|
|
7221
|
-
static async createLbPair(connection, funder, tokenX, tokenY,
|
|
7204
|
+
static async createLbPair(connection, funder, tokenX, tokenY, presetParameter, activeId, opt) {
|
|
7222
7205
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7223
7206
|
connection,
|
|
7224
7207
|
{},
|
|
7225
7208
|
_anchor.AnchorProvider.defaultOptions()
|
|
7226
7209
|
);
|
|
7227
7210
|
const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
|
|
7228
|
-
const
|
|
7229
|
-
|
|
7230
|
-
tokenY,
|
|
7231
|
-
binStep,
|
|
7232
|
-
baseFactor,
|
|
7233
|
-
program.programId
|
|
7211
|
+
const presetParameterState = await program.account.presetParameter.fetch(
|
|
7212
|
+
presetParameter
|
|
7234
7213
|
);
|
|
7214
|
+
const binStep = new (0, _anchor.BN)(presetParameterState.binStep);
|
|
7215
|
+
const [lbPair] = deriveLbPair(tokenX, tokenY, binStep, program.programId);
|
|
7235
7216
|
const [reserveX] = deriveReserve(tokenX, lbPair, program.programId);
|
|
7236
7217
|
const [reserveY] = deriveReserve(tokenY, lbPair, program.programId);
|
|
7237
7218
|
const [oracle] = deriveOracle(lbPair, program.programId);
|
|
@@ -7348,7 +7329,7 @@ var DLMM = class {
|
|
|
7348
7329
|
swapForY,
|
|
7349
7330
|
new (0, _anchor.BN)(activeIdToLoop),
|
|
7350
7331
|
this.lbPair,
|
|
7351
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
7332
|
+
_nullishCoalesce(_optionalChain([this, 'access', _52 => _52.binArrayBitmapExtension, 'optionalAccess', _53 => _53.account]), () => ( null))
|
|
7352
7333
|
);
|
|
7353
7334
|
if (binArrayIndex === null)
|
|
7354
7335
|
shouldStop = true;
|
|
@@ -8765,7 +8746,7 @@ var DLMM = class {
|
|
|
8765
8746
|
swapForY,
|
|
8766
8747
|
activeId,
|
|
8767
8748
|
this.lbPair,
|
|
8768
|
-
_optionalChain([this, 'access',
|
|
8749
|
+
_optionalChain([this, 'access', _54 => _54.binArrayBitmapExtension, 'optionalAccess', _55 => _55.account]),
|
|
8769
8750
|
binArrays
|
|
8770
8751
|
);
|
|
8771
8752
|
if (binArrayAccountToSwap == null) {
|
|
@@ -8872,7 +8853,7 @@ var DLMM = class {
|
|
|
8872
8853
|
swapForY,
|
|
8873
8854
|
activeId,
|
|
8874
8855
|
this.lbPair,
|
|
8875
|
-
_optionalChain([this, 'access',
|
|
8856
|
+
_optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]),
|
|
8876
8857
|
binArrays
|
|
8877
8858
|
);
|
|
8878
8859
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9342,6 +9323,115 @@ var DLMM = class {
|
|
|
9342
9323
|
})
|
|
9343
9324
|
);
|
|
9344
9325
|
}
|
|
9326
|
+
canSyncWithMarketPrice(marketPrice, activeBinId) {
|
|
9327
|
+
const marketPriceBinId = this.getBinIdFromPrice(
|
|
9328
|
+
Number(
|
|
9329
|
+
DLMM.getPricePerLamport(
|
|
9330
|
+
this.tokenX.decimal,
|
|
9331
|
+
this.tokenY.decimal,
|
|
9332
|
+
marketPrice
|
|
9333
|
+
)
|
|
9334
|
+
),
|
|
9335
|
+
false
|
|
9336
|
+
);
|
|
9337
|
+
const marketPriceBinArrayIndex = binIdToBinArrayIndex(
|
|
9338
|
+
new (0, _anchor.BN)(marketPriceBinId)
|
|
9339
|
+
);
|
|
9340
|
+
const swapForY = marketPriceBinId < activeBinId;
|
|
9341
|
+
const toBinArrayIndex = findNextBinArrayIndexWithLiquidity(
|
|
9342
|
+
swapForY,
|
|
9343
|
+
new (0, _anchor.BN)(activeBinId),
|
|
9344
|
+
this.lbPair,
|
|
9345
|
+
_nullishCoalesce(_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]), () => ( null))
|
|
9346
|
+
);
|
|
9347
|
+
if (toBinArrayIndex === null)
|
|
9348
|
+
return true;
|
|
9349
|
+
return swapForY ? marketPriceBinArrayIndex.gt(toBinArrayIndex) : marketPriceBinArrayIndex.lt(toBinArrayIndex);
|
|
9350
|
+
}
|
|
9351
|
+
/**
|
|
9352
|
+
* The `syncWithMarketPrice` function is used to sync the liquidity pool with the market price.
|
|
9353
|
+
* @param
|
|
9354
|
+
* - `marketPrice`: The market price to sync with.
|
|
9355
|
+
* - `owner`: The public key of the owner of the liquidity pool.
|
|
9356
|
+
* @returns {Promise<Transaction>}
|
|
9357
|
+
*/
|
|
9358
|
+
async syncWithMarketPrice(marketPrice, owner) {
|
|
9359
|
+
const marketPriceBinId = this.getBinIdFromPrice(
|
|
9360
|
+
Number(
|
|
9361
|
+
DLMM.getPricePerLamport(
|
|
9362
|
+
this.tokenX.decimal,
|
|
9363
|
+
this.tokenY.decimal,
|
|
9364
|
+
marketPrice
|
|
9365
|
+
)
|
|
9366
|
+
),
|
|
9367
|
+
false
|
|
9368
|
+
);
|
|
9369
|
+
const activeBin = await this.getActiveBin();
|
|
9370
|
+
const activeBinId = activeBin.binId;
|
|
9371
|
+
if (!this.canSyncWithMarketPrice(marketPrice, activeBinId)) {
|
|
9372
|
+
throw new Error(
|
|
9373
|
+
"Unable to sync with market price due to bin with liquidity between current and market price bin"
|
|
9374
|
+
);
|
|
9375
|
+
}
|
|
9376
|
+
const fromBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(activeBinId));
|
|
9377
|
+
const swapForY = marketPriceBinId < activeBinId;
|
|
9378
|
+
const toBinArrayIndex = findNextBinArrayIndexWithLiquidity(
|
|
9379
|
+
swapForY,
|
|
9380
|
+
new (0, _anchor.BN)(activeBinId),
|
|
9381
|
+
this.lbPair,
|
|
9382
|
+
_nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null))
|
|
9383
|
+
);
|
|
9384
|
+
const accountsToFetch = [];
|
|
9385
|
+
const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
|
|
9386
|
+
this.pubkey,
|
|
9387
|
+
this.program.programId
|
|
9388
|
+
);
|
|
9389
|
+
accountsToFetch.push(binArrayBitMapExtensionPubkey);
|
|
9390
|
+
const [fromBinArrayPubkey] = deriveBinArray(
|
|
9391
|
+
this.pubkey,
|
|
9392
|
+
fromBinArrayIndex,
|
|
9393
|
+
this.program.programId
|
|
9394
|
+
);
|
|
9395
|
+
accountsToFetch.push(fromBinArrayPubkey);
|
|
9396
|
+
const toBinArrayPubkey = (() => {
|
|
9397
|
+
if (!toBinArrayIndex)
|
|
9398
|
+
return null;
|
|
9399
|
+
const [toBinArrayPubkey2] = deriveBinArray(
|
|
9400
|
+
this.pubkey,
|
|
9401
|
+
toBinArrayIndex,
|
|
9402
|
+
this.program.programId
|
|
9403
|
+
);
|
|
9404
|
+
accountsToFetch.push(toBinArrayPubkey2);
|
|
9405
|
+
return toBinArrayPubkey2;
|
|
9406
|
+
})();
|
|
9407
|
+
const binArrayAccounts = await this.program.provider.connection.getMultipleAccountsInfo(
|
|
9408
|
+
accountsToFetch
|
|
9409
|
+
);
|
|
9410
|
+
let fromBinArray = null;
|
|
9411
|
+
let toBinArray = null;
|
|
9412
|
+
let binArrayBitmapExtension = null;
|
|
9413
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _62 => _62[0]])) {
|
|
9414
|
+
binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
|
|
9415
|
+
}
|
|
9416
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _63 => _63[1]])) {
|
|
9417
|
+
fromBinArray = fromBinArrayPubkey;
|
|
9418
|
+
}
|
|
9419
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _64 => _64[2]]) && !!toBinArrayIndex) {
|
|
9420
|
+
toBinArray = toBinArrayPubkey;
|
|
9421
|
+
}
|
|
9422
|
+
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
9423
|
+
const syncWithMarketPriceTx = await this.program.methods.goToABin(marketPriceBinId).accounts({
|
|
9424
|
+
lbPair: this.pubkey,
|
|
9425
|
+
binArrayBitmapExtension,
|
|
9426
|
+
fromBinArray,
|
|
9427
|
+
toBinArray
|
|
9428
|
+
}).transaction();
|
|
9429
|
+
return new (0, _web3js.Transaction)({
|
|
9430
|
+
feePayer: owner,
|
|
9431
|
+
blockhash,
|
|
9432
|
+
lastValidBlockHeight
|
|
9433
|
+
}).add(syncWithMarketPriceTx);
|
|
9434
|
+
}
|
|
9345
9435
|
/** Private static method */
|
|
9346
9436
|
static async getBinArrays(program, lbPairPubkey) {
|
|
9347
9437
|
return program.account.binArray.all([
|
|
@@ -9938,7 +10028,7 @@ var DLMMError = class extends Error {
|
|
|
9938
10028
|
const anchorError = _anchor.AnchorError.parse(
|
|
9939
10029
|
JSON.parse(JSON.stringify(error)).logs
|
|
9940
10030
|
);
|
|
9941
|
-
if (_optionalChain([anchorError, 'optionalAccess',
|
|
10031
|
+
if (_optionalChain([anchorError, 'optionalAccess', _65 => _65.program, 'access', _66 => _66.toBase58, 'call', _67 => _67()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
|
|
9942
10032
|
_errorCode = anchorError.error.errorCode.number;
|
|
9943
10033
|
_errorName = anchorError.error.errorCode.code;
|
|
9944
10034
|
_errorMessage = anchorError.error.errorMessage;
|
|
@@ -10042,6 +10132,5 @@ var src_default = DLMM;
|
|
|
10042
10132
|
|
|
10043
10133
|
|
|
10044
10134
|
|
|
10045
|
-
|
|
10046
|
-
exports.ADMIN = ADMIN; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BitmapType = BitmapType; exports.DLMMError = DLMMError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.PairType = PairType; exports.PositionVersion = PositionVersion; exports.SCALE = SCALE; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SIMULATION_USER = SIMULATION_USER; exports.Strategy = Strategy; exports.StrategyType = StrategyType; exports.autoFillXByStrategy = autoFillXByStrategy; exports.autoFillXByWeight = autoFillXByWeight; exports.autoFillYByStrategy = autoFillYByStrategy; exports.autoFillYByWeight = autoFillYByWeight; exports.binIdToBinArrayIndex = binIdToBinArrayIndex; exports.calculateBidAskDistribution = calculateBidAskDistribution; exports.calculateNormalDistribution = calculateNormalDistribution; exports.calculateSpotDistribution = calculateSpotDistribution; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeBudgetIx = computeBudgetIx; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveLbPair = deriveLbPair; exports.deriveLbPair2 = deriveLbPair2; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.derivePresetParameter2 = derivePresetParameter2; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapQuoteAtBin = swapQuoteAtBin; exports.swapQuoteAtBinWithCap = swapQuoteAtBinWithCap; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
10135
|
+
exports.ADMIN = ADMIN; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BitmapType = BitmapType; exports.DLMMError = DLMMError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.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.checkPoolExists = checkPoolExists; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeBudgetIx = computeBudgetIx; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveLbPair = deriveLbPair; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapQuoteAtBin = swapQuoteAtBin; exports.swapQuoteAtBinWithCap = swapQuoteAtBinWithCap; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
10047
10136
|
//# sourceMappingURL=index.js.map
|