@meteora-ag/dlmm 1.0.32 → 1.0.34-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 +26 -37
- package/dist/index.js +116 -78
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1768,39 +1768,6 @@ 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
|
-
},
|
|
1804
1771
|
{
|
|
1805
1772
|
name: "closePresetParameter";
|
|
1806
1773
|
accounts: [
|
|
@@ -2540,10 +2507,20 @@ type LbClmm = {
|
|
|
2540
2507
|
docs: ["Status of the pair. Check PairStatus enum."];
|
|
2541
2508
|
type: "u8";
|
|
2542
2509
|
},
|
|
2510
|
+
{
|
|
2511
|
+
name: "requireBaseFactorSeed";
|
|
2512
|
+
type: "u8";
|
|
2513
|
+
},
|
|
2514
|
+
{
|
|
2515
|
+
name: "baseFactorSeed";
|
|
2516
|
+
type: {
|
|
2517
|
+
array: ["u8", 2];
|
|
2518
|
+
};
|
|
2519
|
+
},
|
|
2543
2520
|
{
|
|
2544
2521
|
name: "padding1";
|
|
2545
2522
|
type: {
|
|
2546
|
-
array: ["u8",
|
|
2523
|
+
array: ["u8", 2];
|
|
2547
2524
|
};
|
|
2548
2525
|
},
|
|
2549
2526
|
{
|
|
@@ -4870,6 +4847,7 @@ declare class DLMM {
|
|
|
4870
4847
|
* `LbPairAccount` objects.
|
|
4871
4848
|
*/
|
|
4872
4849
|
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>;
|
|
4873
4851
|
/**
|
|
4874
4852
|
* The `create` function is a static method that creates a new instance of the `DLMM` class
|
|
4875
4853
|
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
@@ -4919,7 +4897,7 @@ declare class DLMM {
|
|
|
4919
4897
|
static getBinIdFromPrice(price: string | number | Decimal, binStep: number, min: boolean): number;
|
|
4920
4898
|
/** Public methods */
|
|
4921
4899
|
static createPermissionLbPair(connection: Connection, binStep: BN, tokenX: PublicKey, tokenY: PublicKey, activeId: BN, baseKey: PublicKey, creatorKey: PublicKey, feeBps: BN, lockDurationInSlot: BN, opt?: Opt): Promise<Transaction>;
|
|
4922
|
-
static createLbPair(connection: Connection, funder: PublicKey, tokenX: PublicKey, tokenY: PublicKey, presetParameter: PublicKey, activeId: BN, opt?: Opt): Promise<Transaction>;
|
|
4900
|
+
static createLbPair(connection: Connection, funder: PublicKey, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, presetParameter: PublicKey, activeId: BN, opt?: Opt): Promise<Transaction>;
|
|
4923
4901
|
/**
|
|
4924
4902
|
* The function `refetchStates` retrieves and updates various states and data related to bin arrays
|
|
4925
4903
|
* and lb pairs.
|
|
@@ -5294,9 +5272,18 @@ declare class DLMM {
|
|
|
5294
5272
|
}
|
|
5295
5273
|
|
|
5296
5274
|
/** private */
|
|
5275
|
+
/**
|
|
5276
|
+
*
|
|
5277
|
+
* @deprecated Use derivePresetParameter2
|
|
5278
|
+
*/
|
|
5297
5279
|
declare function derivePresetParameter(binStep: BN, programId: PublicKey): [PublicKey, number];
|
|
5280
|
+
declare function derivePresetParameter2(binStep: BN, baseFactor: BN, programId: PublicKey): [PublicKey, number];
|
|
5281
|
+
declare function deriveLbPair2(tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, programId: PublicKey): [PublicKey, number];
|
|
5282
|
+
/**
|
|
5283
|
+
*
|
|
5284
|
+
* @deprecated Use deriveLbPair2
|
|
5285
|
+
*/
|
|
5298
5286
|
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>;
|
|
5300
5287
|
declare function derivePermissionLbPair(baseKey: PublicKey, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): [PublicKey, number];
|
|
5301
5288
|
declare function deriveOracle(lbPair: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
5302
5289
|
declare function derivePosition(mint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
@@ -5581,6 +5568,8 @@ declare function chunkedFetchMultiplePoolAccount(program: ClmmProgram, pks: Publ
|
|
|
5581
5568
|
activeId: number;
|
|
5582
5569
|
binStep: number;
|
|
5583
5570
|
status: number;
|
|
5571
|
+
requireBaseFactorSeed: number;
|
|
5572
|
+
baseFactorSeed: number[];
|
|
5584
5573
|
padding1: number[];
|
|
5585
5574
|
tokenXMint: PublicKey;
|
|
5586
5575
|
tokenYMint: PublicKey;
|
|
@@ -5669,4 +5658,4 @@ declare const MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = 26;
|
|
|
5669
5658
|
declare const MAX_BIN_PER_TX = 69;
|
|
5670
5659
|
declare const MAX_ACTIVE_BIN_SLIPPAGE = 3;
|
|
5671
5660
|
|
|
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,
|
|
5661
|
+
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, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, 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,39 +1772,6 @@ 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
|
-
},
|
|
1808
1775
|
{
|
|
1809
1776
|
name: "closePresetParameter",
|
|
1810
1777
|
accounts: [
|
|
@@ -2544,10 +2511,20 @@ var IDL = {
|
|
|
2544
2511
|
docs: ["Status of the pair. Check PairStatus enum."],
|
|
2545
2512
|
type: "u8"
|
|
2546
2513
|
},
|
|
2514
|
+
{
|
|
2515
|
+
name: "requireBaseFactorSeed",
|
|
2516
|
+
type: "u8"
|
|
2517
|
+
},
|
|
2518
|
+
{
|
|
2519
|
+
name: "baseFactorSeed",
|
|
2520
|
+
type: {
|
|
2521
|
+
array: ["u8", 2]
|
|
2522
|
+
}
|
|
2523
|
+
},
|
|
2547
2524
|
{
|
|
2548
2525
|
name: "padding1",
|
|
2549
2526
|
type: {
|
|
2550
|
-
array: ["u8",
|
|
2527
|
+
array: ["u8", 2]
|
|
2551
2528
|
}
|
|
2552
2529
|
},
|
|
2553
2530
|
{
|
|
@@ -4928,6 +4905,28 @@ function derivePresetParameter(binStep, programId) {
|
|
|
4928
4905
|
programId
|
|
4929
4906
|
);
|
|
4930
4907
|
}
|
|
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
|
+
}
|
|
4931
4930
|
function deriveLbPair(tokenX, tokenY, binStep, programId) {
|
|
4932
4931
|
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
4933
4932
|
return _web3js.PublicKey.findProgramAddressSync(
|
|
@@ -4939,19 +4938,15 @@ function deriveLbPair(tokenX, tokenY, binStep, programId) {
|
|
|
4939
4938
|
programId
|
|
4940
4939
|
);
|
|
4941
4940
|
}
|
|
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
|
-
}
|
|
4951
4941
|
function derivePermissionLbPair(baseKey, tokenX, tokenY, binStep, programId) {
|
|
4952
4942
|
const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
|
|
4953
4943
|
return _web3js.PublicKey.findProgramAddressSync(
|
|
4954
|
-
[
|
|
4944
|
+
[
|
|
4945
|
+
baseKey.toBuffer(),
|
|
4946
|
+
minKey.toBuffer(),
|
|
4947
|
+
maxKey.toBuffer(),
|
|
4948
|
+
new Uint8Array(binStep.toArrayLike(Buffer, "le", 2))
|
|
4949
|
+
],
|
|
4955
4950
|
programId
|
|
4956
4951
|
);
|
|
4957
4952
|
}
|
|
@@ -6523,6 +6518,28 @@ var DLMM = class {
|
|
|
6523
6518
|
);
|
|
6524
6519
|
return program.account.lbPair.all();
|
|
6525
6520
|
}
|
|
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
|
+
}
|
|
6526
6543
|
/**
|
|
6527
6544
|
* The `create` function is a static method that creates a new instance of the `DLMM` class
|
|
6528
6545
|
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
@@ -6533,7 +6550,7 @@ var DLMM = class {
|
|
|
6533
6550
|
* @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
|
|
6534
6551
|
*/
|
|
6535
6552
|
static async create(connection, dlmm, opt) {
|
|
6536
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6553
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _22 => _22.cluster]) || "mainnet-beta";
|
|
6537
6554
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6538
6555
|
connection,
|
|
6539
6556
|
{},
|
|
@@ -6549,14 +6566,14 @@ var DLMM = class {
|
|
|
6549
6566
|
connection,
|
|
6550
6567
|
accountsToFetch
|
|
6551
6568
|
);
|
|
6552
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6569
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _23 => _23[0], 'optionalAccess', _24 => _24.data]);
|
|
6553
6570
|
if (!lbPairAccountInfoBuffer)
|
|
6554
6571
|
throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
|
|
6555
6572
|
const lbPairAccInfo = program.coder.accounts.decode(
|
|
6556
6573
|
"lbPair",
|
|
6557
6574
|
lbPairAccountInfoBuffer
|
|
6558
6575
|
);
|
|
6559
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6576
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _25 => _25[1], 'optionalAccess', _26 => _26.data]);
|
|
6560
6577
|
let binArrayBitMapExtensionAccInfo = null;
|
|
6561
6578
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6562
6579
|
binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
@@ -6620,7 +6637,7 @@ var DLMM = class {
|
|
|
6620
6637
|
* objects.
|
|
6621
6638
|
*/
|
|
6622
6639
|
static async createMultiple(connection, dlmmList, opt) {
|
|
6623
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6640
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _27 => _27.cluster]) || "mainnet-beta";
|
|
6624
6641
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6625
6642
|
connection,
|
|
6626
6643
|
{},
|
|
@@ -6638,7 +6655,7 @@ var DLMM = class {
|
|
|
6638
6655
|
const lbPairArraysMap = /* @__PURE__ */ new Map();
|
|
6639
6656
|
for (let i = 0; i < dlmmList.length; i++) {
|
|
6640
6657
|
const lbPairPubKey = dlmmList[i];
|
|
6641
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6658
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _28 => _28[i], 'optionalAccess', _29 => _29.data]);
|
|
6642
6659
|
if (!lbPairAccountInfoBuffer)
|
|
6643
6660
|
throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
|
|
6644
6661
|
const binArrayAccInfo = program.coder.accounts.decode(
|
|
@@ -6651,7 +6668,7 @@ var DLMM = class {
|
|
|
6651
6668
|
for (let i = dlmmList.length; i < accountsInfo.length; i++) {
|
|
6652
6669
|
const index = i - dlmmList.length;
|
|
6653
6670
|
const lbPairPubkey = dlmmList[index];
|
|
6654
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6671
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _30 => _30[i], 'optionalAccess', _31 => _31.data]);
|
|
6655
6672
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6656
6673
|
const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
6657
6674
|
"binArrayBitmapExtension",
|
|
@@ -6734,7 +6751,7 @@ var DLMM = class {
|
|
|
6734
6751
|
);
|
|
6735
6752
|
const program = new (0, _anchor.Program)(
|
|
6736
6753
|
IDL,
|
|
6737
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6754
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _32 => _32.cluster]), () => ( "mainnet-beta"))],
|
|
6738
6755
|
provider
|
|
6739
6756
|
);
|
|
6740
6757
|
const presetParameter = await program.account.presetParameter.all();
|
|
@@ -6752,7 +6769,7 @@ var DLMM = class {
|
|
|
6752
6769
|
* Pair account, and the value is an object of PositionInfo
|
|
6753
6770
|
*/
|
|
6754
6771
|
static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
|
|
6755
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6772
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _33 => _33.cluster]) || "mainnet-beta";
|
|
6756
6773
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6757
6774
|
connection,
|
|
6758
6775
|
{},
|
|
@@ -6987,8 +7004,8 @@ var DLMM = class {
|
|
|
6987
7004
|
const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
|
|
6988
7005
|
lbPair.toBase58()
|
|
6989
7006
|
);
|
|
6990
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
6991
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
7007
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _34 => _34.get, 'call', _35 => _35(lbPair.toBase58()), 'optionalAccess', _36 => _36.reserveX]), () => ( BigInt(0)));
|
|
7008
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _37 => _37.get, 'call', _38 => _38(lbPair.toBase58()), 'optionalAccess', _39 => _39.reserveY]), () => ( BigInt(0)));
|
|
6992
7009
|
const tokenX = {
|
|
6993
7010
|
publicKey: lbPairAcc.tokenXMint,
|
|
6994
7011
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7020,7 +7037,7 @@ var DLMM = class {
|
|
|
7020
7037
|
tokenX,
|
|
7021
7038
|
tokenY,
|
|
7022
7039
|
lbPairPositionsData: [
|
|
7023
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7040
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _40 => _40.get, 'call', _41 => _41(lbPair.toBase58()), 'optionalAccess', _42 => _42.lbPairPositionsData]), () => ( [])),
|
|
7024
7041
|
{
|
|
7025
7042
|
publicKey: positionPubKey,
|
|
7026
7043
|
positionData,
|
|
@@ -7056,8 +7073,8 @@ var DLMM = class {
|
|
|
7056
7073
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
|
|
7057
7074
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
|
|
7058
7075
|
]);
|
|
7059
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7060
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7076
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _43 => _43.get, 'call', _44 => _44(lbPair.toBase58()), 'optionalAccess', _45 => _45.reserveX]), () => ( BigInt(0)));
|
|
7077
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _46 => _46.get, 'call', _47 => _47(lbPair.toBase58()), 'optionalAccess', _48 => _48.reserveY]), () => ( BigInt(0)));
|
|
7061
7078
|
const tokenX = {
|
|
7062
7079
|
publicKey: lbPairAcc.tokenXMint,
|
|
7063
7080
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7089,7 +7106,7 @@ var DLMM = class {
|
|
|
7089
7106
|
tokenX,
|
|
7090
7107
|
tokenY,
|
|
7091
7108
|
lbPairPositionsData: [
|
|
7092
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7109
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _49 => _49.get, 'call', _50 => _50(lbPair.toBase58()), 'optionalAccess', _51 => _51.lbPairPositionsData]), () => ( [])),
|
|
7093
7110
|
{
|
|
7094
7111
|
publicKey: positionPubKey,
|
|
7095
7112
|
positionData,
|
|
@@ -7102,7 +7119,7 @@ var DLMM = class {
|
|
|
7102
7119
|
return positionsMap;
|
|
7103
7120
|
}
|
|
7104
7121
|
static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
|
|
7105
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
7122
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _52 => _52.cluster]) || "mainnet-beta";
|
|
7106
7123
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7107
7124
|
connection,
|
|
7108
7125
|
{},
|
|
@@ -7201,18 +7218,20 @@ var DLMM = class {
|
|
|
7201
7218
|
base: baseKey
|
|
7202
7219
|
}).transaction();
|
|
7203
7220
|
}
|
|
7204
|
-
static async createLbPair(connection, funder, tokenX, tokenY, presetParameter, activeId, opt) {
|
|
7221
|
+
static async createLbPair(connection, funder, tokenX, tokenY, binStep, baseFactor, presetParameter, activeId, opt) {
|
|
7205
7222
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7206
7223
|
connection,
|
|
7207
7224
|
{},
|
|
7208
7225
|
_anchor.AnchorProvider.defaultOptions()
|
|
7209
7226
|
);
|
|
7210
7227
|
const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
|
|
7211
|
-
const
|
|
7212
|
-
|
|
7228
|
+
const [lbPair] = deriveLbPair2(
|
|
7229
|
+
tokenX,
|
|
7230
|
+
tokenY,
|
|
7231
|
+
binStep,
|
|
7232
|
+
baseFactor,
|
|
7233
|
+
program.programId
|
|
7213
7234
|
);
|
|
7214
|
-
const binStep = new (0, _anchor.BN)(presetParameterState.binStep);
|
|
7215
|
-
const [lbPair] = deriveLbPair(tokenX, tokenY, binStep, program.programId);
|
|
7216
7235
|
const [reserveX] = deriveReserve(tokenX, lbPair, program.programId);
|
|
7217
7236
|
const [reserveY] = deriveReserve(tokenY, lbPair, program.programId);
|
|
7218
7237
|
const [oracle] = deriveOracle(lbPair, program.programId);
|
|
@@ -7329,7 +7348,7 @@ var DLMM = class {
|
|
|
7329
7348
|
swapForY,
|
|
7330
7349
|
new (0, _anchor.BN)(activeIdToLoop),
|
|
7331
7350
|
this.lbPair,
|
|
7332
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
7351
|
+
_nullishCoalesce(_optionalChain([this, 'access', _53 => _53.binArrayBitmapExtension, 'optionalAccess', _54 => _54.account]), () => ( null))
|
|
7333
7352
|
);
|
|
7334
7353
|
if (binArrayIndex === null)
|
|
7335
7354
|
shouldStop = true;
|
|
@@ -8524,7 +8543,7 @@ var DLMM = class {
|
|
|
8524
8543
|
bps,
|
|
8525
8544
|
shouldClaimAndClose = false
|
|
8526
8545
|
}) {
|
|
8527
|
-
const { lbPair, lowerBinId, feeOwner } = await this.program.account.positionV2.fetch(position);
|
|
8546
|
+
const { lbPair, lowerBinId, owner, feeOwner } = await this.program.account.positionV2.fetch(position);
|
|
8528
8547
|
const { reserveX, reserveY, tokenXMint, tokenYMint } = await this.program.account.lbPair.fetch(lbPair);
|
|
8529
8548
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8530
8549
|
const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(1));
|
|
@@ -8544,8 +8563,22 @@ var DLMM = class {
|
|
|
8544
8563
|
const walletToReceiveFee = feeOwner.equals(_web3js.PublicKey.default) ? user : feeOwner;
|
|
8545
8564
|
const [
|
|
8546
8565
|
{ ataPubKey: userTokenX, ix: createPayerTokenXIx },
|
|
8547
|
-
{ ataPubKey: userTokenY, ix: createPayerTokenYIx }
|
|
8566
|
+
{ ataPubKey: userTokenY, ix: createPayerTokenYIx },
|
|
8567
|
+
{ ataPubKey: feeOwnerTokenX, ix: createFeeOwnerTokenXIx },
|
|
8568
|
+
{ ataPubKey: feeOwnerTokenY, ix: createFeeOwnerTokenYIx }
|
|
8548
8569
|
] = await Promise.all([
|
|
8570
|
+
getOrCreateATAInstruction(
|
|
8571
|
+
this.program.provider.connection,
|
|
8572
|
+
this.tokenX.publicKey,
|
|
8573
|
+
owner,
|
|
8574
|
+
user
|
|
8575
|
+
),
|
|
8576
|
+
getOrCreateATAInstruction(
|
|
8577
|
+
this.program.provider.connection,
|
|
8578
|
+
this.tokenY.publicKey,
|
|
8579
|
+
owner,
|
|
8580
|
+
user
|
|
8581
|
+
),
|
|
8549
8582
|
getOrCreateATAInstruction(
|
|
8550
8583
|
this.program.provider.connection,
|
|
8551
8584
|
this.tokenX.publicKey,
|
|
@@ -8561,6 +8594,10 @@ var DLMM = class {
|
|
|
8561
8594
|
]);
|
|
8562
8595
|
createPayerTokenXIx && preInstructions.push(createPayerTokenXIx);
|
|
8563
8596
|
createPayerTokenYIx && preInstructions.push(createPayerTokenYIx);
|
|
8597
|
+
if (!walletToReceiveFee.equals(owner)) {
|
|
8598
|
+
createFeeOwnerTokenXIx && preInstructions.push(createFeeOwnerTokenXIx);
|
|
8599
|
+
createFeeOwnerTokenYIx && preInstructions.push(createFeeOwnerTokenYIx);
|
|
8600
|
+
}
|
|
8564
8601
|
const secondTransactionsIx = [];
|
|
8565
8602
|
const postInstructions = [];
|
|
8566
8603
|
if (shouldClaimAndClose) {
|
|
@@ -8575,8 +8612,8 @@ var DLMM = class {
|
|
|
8575
8612
|
tokenProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
8576
8613
|
tokenXMint: this.tokenX.publicKey,
|
|
8577
8614
|
tokenYMint: this.tokenY.publicKey,
|
|
8578
|
-
userTokenX,
|
|
8579
|
-
userTokenY
|
|
8615
|
+
userTokenX: feeOwnerTokenX,
|
|
8616
|
+
userTokenY: feeOwnerTokenY
|
|
8580
8617
|
}).instruction();
|
|
8581
8618
|
postInstructions.push(claimSwapFeeIx);
|
|
8582
8619
|
for (let i = 0; i < 2; i++) {
|
|
@@ -8746,7 +8783,7 @@ var DLMM = class {
|
|
|
8746
8783
|
swapForY,
|
|
8747
8784
|
activeId,
|
|
8748
8785
|
this.lbPair,
|
|
8749
|
-
_optionalChain([this, 'access',
|
|
8786
|
+
_optionalChain([this, 'access', _55 => _55.binArrayBitmapExtension, 'optionalAccess', _56 => _56.account]),
|
|
8750
8787
|
binArrays
|
|
8751
8788
|
);
|
|
8752
8789
|
if (binArrayAccountToSwap == null) {
|
|
@@ -8853,7 +8890,7 @@ var DLMM = class {
|
|
|
8853
8890
|
swapForY,
|
|
8854
8891
|
activeId,
|
|
8855
8892
|
this.lbPair,
|
|
8856
|
-
_optionalChain([this, 'access',
|
|
8893
|
+
_optionalChain([this, 'access', _57 => _57.binArrayBitmapExtension, 'optionalAccess', _58 => _58.account]),
|
|
8857
8894
|
binArrays
|
|
8858
8895
|
);
|
|
8859
8896
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9342,7 +9379,7 @@ var DLMM = class {
|
|
|
9342
9379
|
swapForY,
|
|
9343
9380
|
new (0, _anchor.BN)(activeBinId),
|
|
9344
9381
|
this.lbPair,
|
|
9345
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9382
|
+
_nullishCoalesce(_optionalChain([this, 'access', _59 => _59.binArrayBitmapExtension, 'optionalAccess', _60 => _60.account]), () => ( null))
|
|
9346
9383
|
);
|
|
9347
9384
|
if (toBinArrayIndex === null)
|
|
9348
9385
|
return true;
|
|
@@ -9379,7 +9416,7 @@ var DLMM = class {
|
|
|
9379
9416
|
swapForY,
|
|
9380
9417
|
new (0, _anchor.BN)(activeBinId),
|
|
9381
9418
|
this.lbPair,
|
|
9382
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9419
|
+
_nullishCoalesce(_optionalChain([this, 'access', _61 => _61.binArrayBitmapExtension, 'optionalAccess', _62 => _62.account]), () => ( null))
|
|
9383
9420
|
);
|
|
9384
9421
|
const accountsToFetch = [];
|
|
9385
9422
|
const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
|
|
@@ -9410,13 +9447,13 @@ var DLMM = class {
|
|
|
9410
9447
|
let fromBinArray = null;
|
|
9411
9448
|
let toBinArray = null;
|
|
9412
9449
|
let binArrayBitmapExtension = null;
|
|
9413
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9450
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _63 => _63[0]])) {
|
|
9414
9451
|
binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
|
|
9415
9452
|
}
|
|
9416
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9453
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _64 => _64[1]])) {
|
|
9417
9454
|
fromBinArray = fromBinArrayPubkey;
|
|
9418
9455
|
}
|
|
9419
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9456
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _65 => _65[2]]) && !!toBinArrayIndex) {
|
|
9420
9457
|
toBinArray = toBinArrayPubkey;
|
|
9421
9458
|
}
|
|
9422
9459
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
@@ -10028,7 +10065,7 @@ var DLMMError = class extends Error {
|
|
|
10028
10065
|
const anchorError = _anchor.AnchorError.parse(
|
|
10029
10066
|
JSON.parse(JSON.stringify(error)).logs
|
|
10030
10067
|
);
|
|
10031
|
-
if (_optionalChain([anchorError, 'optionalAccess',
|
|
10068
|
+
if (_optionalChain([anchorError, 'optionalAccess', _66 => _66.program, 'access', _67 => _67.toBase58, 'call', _68 => _68()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
|
|
10032
10069
|
_errorCode = anchorError.error.errorCode.number;
|
|
10033
10070
|
_errorName = anchorError.error.errorCode.code;
|
|
10034
10071
|
_errorMessage = anchorError.error.errorMessage;
|
|
@@ -10132,5 +10169,6 @@ var src_default = DLMM;
|
|
|
10132
10169
|
|
|
10133
10170
|
|
|
10134
10171
|
|
|
10135
|
-
|
|
10172
|
+
|
|
10173
|
+
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;
|
|
10136
10174
|
//# sourceMappingURL=index.js.map
|