@meteora-ag/dlmm 1.0.44-rc.2 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +76 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4898,6 +4898,26 @@ function toAmountAskSide(activeId, binStep, totalAmount, distributions) {
|
|
|
4898
4898
|
});
|
|
4899
4899
|
}
|
|
4900
4900
|
function toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, distributions) {
|
|
4901
|
+
if (activeId > distributions[distributions.length - 1].binId) {
|
|
4902
|
+
let amounts = toAmountBidSide(activeId, amountY, distributions);
|
|
4903
|
+
return amounts.map((bin) => {
|
|
4904
|
+
return {
|
|
4905
|
+
binId: bin.binId,
|
|
4906
|
+
amountX: new (0, _anchor.BN)(0),
|
|
4907
|
+
amountY: bin.amount
|
|
4908
|
+
};
|
|
4909
|
+
});
|
|
4910
|
+
}
|
|
4911
|
+
if (activeId < distributions[0].binId) {
|
|
4912
|
+
let amounts = toAmountAskSide(activeId, binStep, amountX, distributions);
|
|
4913
|
+
return amounts.map((bin) => {
|
|
4914
|
+
return {
|
|
4915
|
+
binId: bin.binId,
|
|
4916
|
+
amountX: bin.amount,
|
|
4917
|
+
amountY: new (0, _anchor.BN)(0)
|
|
4918
|
+
};
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4901
4921
|
const activeBins = distributions.filter((element) => {
|
|
4902
4922
|
return element.binId === activeId;
|
|
4903
4923
|
});
|
|
@@ -6280,6 +6300,10 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
6280
6300
|
throw "Invalid Strategy Parameters";
|
|
6281
6301
|
}
|
|
6282
6302
|
case 3 /* SpotImBalanced */: {
|
|
6303
|
+
if (activeId < minBinId || activeId > maxBinId) {
|
|
6304
|
+
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
6305
|
+
return toAmountBothSide(activeId, binStep, amountX, amountY, amountXInActiveBin, amountYInActiveBin, weights);
|
|
6306
|
+
}
|
|
6283
6307
|
let amountsInBin = [];
|
|
6284
6308
|
if (minBinId <= activeId) {
|
|
6285
6309
|
let weights = toWeightSpotBalanced(minBinId, activeId);
|
|
@@ -6306,6 +6330,30 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
6306
6330
|
return amountsInBin;
|
|
6307
6331
|
}
|
|
6308
6332
|
case 4 /* CurveImBalanced */: {
|
|
6333
|
+
if (activeId < minBinId) {
|
|
6334
|
+
let weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
6335
|
+
return toAmountBothSide(
|
|
6336
|
+
activeId,
|
|
6337
|
+
binStep,
|
|
6338
|
+
amountX,
|
|
6339
|
+
amountY,
|
|
6340
|
+
amountXInActiveBin,
|
|
6341
|
+
amountYInActiveBin,
|
|
6342
|
+
weights
|
|
6343
|
+
);
|
|
6344
|
+
}
|
|
6345
|
+
if (activeId > maxBinId) {
|
|
6346
|
+
let weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
6347
|
+
return toAmountBothSide(
|
|
6348
|
+
activeId,
|
|
6349
|
+
binStep,
|
|
6350
|
+
amountX,
|
|
6351
|
+
amountY,
|
|
6352
|
+
amountXInActiveBin,
|
|
6353
|
+
amountYInActiveBin,
|
|
6354
|
+
weights
|
|
6355
|
+
);
|
|
6356
|
+
}
|
|
6309
6357
|
let amountsInBin = [];
|
|
6310
6358
|
if (minBinId <= activeId) {
|
|
6311
6359
|
let weights = toWeightAscendingOrder(minBinId, activeId);
|
|
@@ -6332,6 +6380,30 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
6332
6380
|
return amountsInBin;
|
|
6333
6381
|
}
|
|
6334
6382
|
case 5 /* BidAskImBalanced */: {
|
|
6383
|
+
if (activeId < minBinId) {
|
|
6384
|
+
let weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
6385
|
+
return toAmountBothSide(
|
|
6386
|
+
activeId,
|
|
6387
|
+
binStep,
|
|
6388
|
+
amountX,
|
|
6389
|
+
amountY,
|
|
6390
|
+
amountXInActiveBin,
|
|
6391
|
+
amountYInActiveBin,
|
|
6392
|
+
weights
|
|
6393
|
+
);
|
|
6394
|
+
}
|
|
6395
|
+
if (activeId > maxBinId) {
|
|
6396
|
+
let weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
6397
|
+
return toAmountBothSide(
|
|
6398
|
+
activeId,
|
|
6399
|
+
binStep,
|
|
6400
|
+
amountX,
|
|
6401
|
+
amountY,
|
|
6402
|
+
amountXInActiveBin,
|
|
6403
|
+
amountYInActiveBin,
|
|
6404
|
+
weights
|
|
6405
|
+
);
|
|
6406
|
+
}
|
|
6335
6407
|
let amountsInBin = [];
|
|
6336
6408
|
if (minBinId <= activeId) {
|
|
6337
6409
|
let weights = toWeightDecendingOrder(minBinId, activeId);
|
|
@@ -8164,31 +8236,8 @@ var DLMM = class {
|
|
|
8164
8236
|
tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
8165
8237
|
tokenYProgram: _spltoken.TOKEN_PROGRAM_ID
|
|
8166
8238
|
};
|
|
8167
|
-
const
|
|
8168
|
-
|
|
8169
|
-
activeId,
|
|
8170
|
-
maxActiveBinSlippage,
|
|
8171
|
-
strategyParameters
|
|
8172
|
-
};
|
|
8173
|
-
const oneSideAddLiquidityAccounts = {
|
|
8174
|
-
binArrayLower,
|
|
8175
|
-
binArrayUpper,
|
|
8176
|
-
lbPair: this.pubkey,
|
|
8177
|
-
binArrayBitmapExtension: null,
|
|
8178
|
-
sender: user,
|
|
8179
|
-
position: positionPubKey,
|
|
8180
|
-
reserve: totalXAmount.isZero() ? this.lbPair.reserveY : this.lbPair.reserveX,
|
|
8181
|
-
tokenMint: totalXAmount.isZero() ? this.lbPair.tokenYMint : this.lbPair.tokenXMint,
|
|
8182
|
-
tokenProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
8183
|
-
userToken: totalXAmount.isZero() ? userTokenY : userTokenX
|
|
8184
|
-
};
|
|
8185
|
-
const isOneSideDeposit = totalXAmount.isZero() || totalYAmount.isZero();
|
|
8186
|
-
const programMethod = isOneSideDeposit ? this.program.methods.addLiquidityByStrategyOneSide(
|
|
8187
|
-
oneSideLiquidityParams
|
|
8188
|
-
) : this.program.methods.addLiquidityByStrategy(liquidityParams);
|
|
8189
|
-
const createPositionTx = await programMethod.accounts(
|
|
8190
|
-
isOneSideDeposit ? oneSideAddLiquidityAccounts : addLiquidityAccounts
|
|
8191
|
-
).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8239
|
+
const programMethod = this.program.methods.addLiquidityByStrategy(liquidityParams);
|
|
8240
|
+
const createPositionTx = await programMethod.accounts(addLiquidityAccounts).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8192
8241
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
8193
8242
|
return new (0, _web3js.Transaction)({
|
|
8194
8243
|
blockhash,
|
|
@@ -8513,31 +8562,8 @@ var DLMM = class {
|
|
|
8513
8562
|
tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
8514
8563
|
tokenYProgram: _spltoken.TOKEN_PROGRAM_ID
|
|
8515
8564
|
};
|
|
8516
|
-
const
|
|
8517
|
-
|
|
8518
|
-
activeId,
|
|
8519
|
-
maxActiveBinSlippage,
|
|
8520
|
-
strategyParameters
|
|
8521
|
-
};
|
|
8522
|
-
const oneSideAddLiquidityAccounts = {
|
|
8523
|
-
binArrayLower,
|
|
8524
|
-
binArrayUpper,
|
|
8525
|
-
lbPair: this.pubkey,
|
|
8526
|
-
binArrayBitmapExtension: null,
|
|
8527
|
-
sender: user,
|
|
8528
|
-
position: positionPubKey,
|
|
8529
|
-
reserve: totalXAmount.isZero() ? this.lbPair.reserveY : this.lbPair.reserveX,
|
|
8530
|
-
tokenMint: totalXAmount.isZero() ? this.lbPair.tokenYMint : this.lbPair.tokenXMint,
|
|
8531
|
-
tokenProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
8532
|
-
userToken: totalXAmount.isZero() ? userTokenY : userTokenX
|
|
8533
|
-
};
|
|
8534
|
-
const isOneSideDeposit = totalXAmount.isZero() || totalYAmount.isZero();
|
|
8535
|
-
const programMethod = isOneSideDeposit ? this.program.methods.addLiquidityByStrategyOneSide(
|
|
8536
|
-
oneSideLiquidityParams
|
|
8537
|
-
) : this.program.methods.addLiquidityByStrategy(liquidityParams);
|
|
8538
|
-
const createPositionTx = await programMethod.accounts(
|
|
8539
|
-
isOneSideDeposit ? oneSideAddLiquidityAccounts : addLiquidityAccounts
|
|
8540
|
-
).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8565
|
+
const programMethod = this.program.methods.addLiquidityByStrategy(liquidityParams);
|
|
8566
|
+
const createPositionTx = await programMethod.accounts(addLiquidityAccounts).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8541
8567
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
8542
8568
|
return new (0, _web3js.Transaction)({
|
|
8543
8569
|
blockhash,
|