@meteora-ag/cp-amm-sdk 1.0.1-rc.25 → 1.0.1-rc.27
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.mts +223 -2
- package/dist/index.d.ts +223 -2
- package/dist/index.js +765 -313
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +766 -314
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6352,6 +6352,7 @@ var cp_amm_default = {
|
|
|
6352
6352
|
// src/CpAmm.ts
|
|
6353
6353
|
|
|
6354
6354
|
|
|
6355
|
+
|
|
6355
6356
|
var _web3js = require('@solana/web3.js');
|
|
6356
6357
|
|
|
6357
6358
|
// src/constants.ts
|
|
@@ -6371,6 +6372,38 @@ var MAX_SQRT_PRICE = new (0, _anchor.BN)("79226673521066979257578248091");
|
|
|
6371
6372
|
var MIN_CU_BUFFER = 5e4;
|
|
6372
6373
|
var MAX_CU_BUFFER = 2e5;
|
|
6373
6374
|
|
|
6375
|
+
// src/types.ts
|
|
6376
|
+
var Rounding = /* @__PURE__ */ ((Rounding2) => {
|
|
6377
|
+
Rounding2[Rounding2["Up"] = 0] = "Up";
|
|
6378
|
+
Rounding2[Rounding2["Down"] = 1] = "Down";
|
|
6379
|
+
return Rounding2;
|
|
6380
|
+
})(Rounding || {});
|
|
6381
|
+
var ActivationPoint = /* @__PURE__ */ ((ActivationPoint2) => {
|
|
6382
|
+
ActivationPoint2[ActivationPoint2["Timestamp"] = 0] = "Timestamp";
|
|
6383
|
+
ActivationPoint2[ActivationPoint2["Slot"] = 1] = "Slot";
|
|
6384
|
+
return ActivationPoint2;
|
|
6385
|
+
})(ActivationPoint || {});
|
|
6386
|
+
var FeeSchedulerMode = /* @__PURE__ */ ((FeeSchedulerMode2) => {
|
|
6387
|
+
FeeSchedulerMode2[FeeSchedulerMode2["Linear"] = 0] = "Linear";
|
|
6388
|
+
FeeSchedulerMode2[FeeSchedulerMode2["Exponential"] = 1] = "Exponential";
|
|
6389
|
+
return FeeSchedulerMode2;
|
|
6390
|
+
})(FeeSchedulerMode || {});
|
|
6391
|
+
var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
|
|
6392
|
+
CollectFeeMode3[CollectFeeMode3["BothToken"] = 0] = "BothToken";
|
|
6393
|
+
CollectFeeMode3[CollectFeeMode3["OnlyB"] = 1] = "OnlyB";
|
|
6394
|
+
return CollectFeeMode3;
|
|
6395
|
+
})(CollectFeeMode || {});
|
|
6396
|
+
var TradeDirection = /* @__PURE__ */ ((TradeDirection2) => {
|
|
6397
|
+
TradeDirection2[TradeDirection2["AtoB"] = 0] = "AtoB";
|
|
6398
|
+
TradeDirection2[TradeDirection2["BtoA"] = 1] = "BtoA";
|
|
6399
|
+
return TradeDirection2;
|
|
6400
|
+
})(TradeDirection || {});
|
|
6401
|
+
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
6402
|
+
ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
|
|
6403
|
+
ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
|
|
6404
|
+
return ActivationType2;
|
|
6405
|
+
})(ActivationType || {});
|
|
6406
|
+
|
|
6374
6407
|
// src/pda.ts
|
|
6375
6408
|
|
|
6376
6409
|
function getFirstKey(key1, key2) {
|
|
@@ -6589,38 +6622,6 @@ function getAllNftByUser(_0, _1) {
|
|
|
6589
6622
|
// src/helpers/fee.ts
|
|
6590
6623
|
|
|
6591
6624
|
|
|
6592
|
-
// src/types.ts
|
|
6593
|
-
var Rounding = /* @__PURE__ */ ((Rounding2) => {
|
|
6594
|
-
Rounding2[Rounding2["Up"] = 0] = "Up";
|
|
6595
|
-
Rounding2[Rounding2["Down"] = 1] = "Down";
|
|
6596
|
-
return Rounding2;
|
|
6597
|
-
})(Rounding || {});
|
|
6598
|
-
var ActivationPoint = /* @__PURE__ */ ((ActivationPoint2) => {
|
|
6599
|
-
ActivationPoint2[ActivationPoint2["Timestamp"] = 0] = "Timestamp";
|
|
6600
|
-
ActivationPoint2[ActivationPoint2["Slot"] = 1] = "Slot";
|
|
6601
|
-
return ActivationPoint2;
|
|
6602
|
-
})(ActivationPoint || {});
|
|
6603
|
-
var FeeSchedulerMode = /* @__PURE__ */ ((FeeSchedulerMode2) => {
|
|
6604
|
-
FeeSchedulerMode2[FeeSchedulerMode2["Linear"] = 0] = "Linear";
|
|
6605
|
-
FeeSchedulerMode2[FeeSchedulerMode2["Exponential"] = 1] = "Exponential";
|
|
6606
|
-
return FeeSchedulerMode2;
|
|
6607
|
-
})(FeeSchedulerMode || {});
|
|
6608
|
-
var CollectFeeMode = /* @__PURE__ */ ((CollectFeeMode3) => {
|
|
6609
|
-
CollectFeeMode3[CollectFeeMode3["BothToken"] = 0] = "BothToken";
|
|
6610
|
-
CollectFeeMode3[CollectFeeMode3["OnlyB"] = 1] = "OnlyB";
|
|
6611
|
-
return CollectFeeMode3;
|
|
6612
|
-
})(CollectFeeMode || {});
|
|
6613
|
-
var TradeDirection = /* @__PURE__ */ ((TradeDirection2) => {
|
|
6614
|
-
TradeDirection2[TradeDirection2["AtoB"] = 0] = "AtoB";
|
|
6615
|
-
TradeDirection2[TradeDirection2["BtoA"] = 1] = "BtoA";
|
|
6616
|
-
return TradeDirection2;
|
|
6617
|
-
})(TradeDirection || {});
|
|
6618
|
-
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
6619
|
-
ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
|
|
6620
|
-
ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
|
|
6621
|
-
return ActivationType2;
|
|
6622
|
-
})(ActivationType || {});
|
|
6623
|
-
|
|
6624
6625
|
// src/math/feeMath.ts
|
|
6625
6626
|
|
|
6626
6627
|
var MAX_EXPONENTIAL = new (0, _anchor.BN)(524288);
|
|
@@ -7210,6 +7211,46 @@ var CpAmm = class {
|
|
|
7210
7211
|
};
|
|
7211
7212
|
});
|
|
7212
7213
|
}
|
|
7214
|
+
/**
|
|
7215
|
+
* Prepares token accounts for a transaction by retrieving or creating associated token accounts.
|
|
7216
|
+
* @private
|
|
7217
|
+
* @param {PublicKey} owner - The owner of the token accounts
|
|
7218
|
+
* @param {PublicKey} tokenAMint - Mint address of token A
|
|
7219
|
+
* @param {PublicKey} tokenBMint - Mint address of token B
|
|
7220
|
+
* @param {PublicKey} tokenAProgram - Program ID for token A (Token or Token2022)
|
|
7221
|
+
* @param {PublicKey} tokenBProgram - Program ID for token B (Token or Token2022)
|
|
7222
|
+
* @returns {Promise<{tokenAAta: PublicKey, tokenBAta: PublicKey, instructions: TransactionInstruction[]}>}
|
|
7223
|
+
* The token account addresses and any instructions needed to create them
|
|
7224
|
+
*/
|
|
7225
|
+
prepareTokenAccounts(owner, tokenAMint, tokenBMint, tokenAProgram, tokenBProgram) {
|
|
7226
|
+
return __async(this, null, function* () {
|
|
7227
|
+
const instructions = [];
|
|
7228
|
+
const [
|
|
7229
|
+
{ ataPubkey: tokenAAta, ix: createInputTokenAccountIx },
|
|
7230
|
+
{ ataPubkey: tokenBAta, ix: createOutputTokenAccountIx }
|
|
7231
|
+
] = yield Promise.all([
|
|
7232
|
+
getOrCreateATAInstruction(
|
|
7233
|
+
this._program.provider.connection,
|
|
7234
|
+
tokenAMint,
|
|
7235
|
+
owner,
|
|
7236
|
+
owner,
|
|
7237
|
+
true,
|
|
7238
|
+
tokenAProgram
|
|
7239
|
+
),
|
|
7240
|
+
getOrCreateATAInstruction(
|
|
7241
|
+
this._program.provider.connection,
|
|
7242
|
+
tokenBMint,
|
|
7243
|
+
owner,
|
|
7244
|
+
owner,
|
|
7245
|
+
true,
|
|
7246
|
+
tokenBProgram
|
|
7247
|
+
)
|
|
7248
|
+
]);
|
|
7249
|
+
createInputTokenAccountIx && instructions.push(createInputTokenAccountIx);
|
|
7250
|
+
createOutputTokenAccountIx && instructions.push(createOutputTokenAccountIx);
|
|
7251
|
+
return { tokenAAta, tokenBAta, instructions };
|
|
7252
|
+
});
|
|
7253
|
+
}
|
|
7213
7254
|
/**
|
|
7214
7255
|
* Derives token badge account metadata
|
|
7215
7256
|
* @param tokenAMint - Public key of token A mint
|
|
@@ -7230,6 +7271,161 @@ var CpAmm = class {
|
|
|
7230
7271
|
}
|
|
7231
7272
|
];
|
|
7232
7273
|
}
|
|
7274
|
+
/**
|
|
7275
|
+
* Builds an instruction to add liquidity to a position.
|
|
7276
|
+
* @private
|
|
7277
|
+
* @param {BuildAddLiquidityParams} params - Parameters for adding liquidity
|
|
7278
|
+
* @returns {Promise<TransactionInstruction>} Instruction to add liquidity
|
|
7279
|
+
*/
|
|
7280
|
+
buildAddLiquidityInstruction(params) {
|
|
7281
|
+
return __async(this, null, function* () {
|
|
7282
|
+
const {
|
|
7283
|
+
pool,
|
|
7284
|
+
position,
|
|
7285
|
+
positionNftAccount,
|
|
7286
|
+
owner,
|
|
7287
|
+
tokenAAccount,
|
|
7288
|
+
tokenBAccount,
|
|
7289
|
+
tokenAMint,
|
|
7290
|
+
tokenBMint,
|
|
7291
|
+
tokenAVault,
|
|
7292
|
+
tokenBVault,
|
|
7293
|
+
tokenAProgram,
|
|
7294
|
+
tokenBProgram,
|
|
7295
|
+
liquidityDelta,
|
|
7296
|
+
tokenAAmountThreshold,
|
|
7297
|
+
tokenBAmountThreshold
|
|
7298
|
+
} = params;
|
|
7299
|
+
return yield this._program.methods.addLiquidity({
|
|
7300
|
+
liquidityDelta,
|
|
7301
|
+
tokenAAmountThreshold,
|
|
7302
|
+
tokenBAmountThreshold
|
|
7303
|
+
}).accountsPartial({
|
|
7304
|
+
pool,
|
|
7305
|
+
position,
|
|
7306
|
+
positionNftAccount,
|
|
7307
|
+
owner,
|
|
7308
|
+
tokenAAccount,
|
|
7309
|
+
tokenBAccount,
|
|
7310
|
+
tokenAMint,
|
|
7311
|
+
tokenBMint,
|
|
7312
|
+
tokenAVault,
|
|
7313
|
+
tokenBVault,
|
|
7314
|
+
tokenAProgram,
|
|
7315
|
+
tokenBProgram
|
|
7316
|
+
}).instruction();
|
|
7317
|
+
});
|
|
7318
|
+
}
|
|
7319
|
+
/**
|
|
7320
|
+
* Builds an instruction to remove all liquidity from a position.
|
|
7321
|
+
* @private
|
|
7322
|
+
* @param {BuildRemoveAllLiquidityInstructionParams} params - Parameters for removing all liquidity
|
|
7323
|
+
* @returns {Promise<TransactionInstruction>} Instruction to remove all liquidity
|
|
7324
|
+
*/
|
|
7325
|
+
buildRemoveAllLiquidityInstruction(params) {
|
|
7326
|
+
return __async(this, null, function* () {
|
|
7327
|
+
const {
|
|
7328
|
+
poolAuthority,
|
|
7329
|
+
owner,
|
|
7330
|
+
pool,
|
|
7331
|
+
position,
|
|
7332
|
+
positionNftAccount,
|
|
7333
|
+
tokenAAccount,
|
|
7334
|
+
tokenBAccount,
|
|
7335
|
+
tokenAAmountThreshold,
|
|
7336
|
+
tokenBAmountThreshold,
|
|
7337
|
+
tokenAMint,
|
|
7338
|
+
tokenBMint,
|
|
7339
|
+
tokenAVault,
|
|
7340
|
+
tokenBVault,
|
|
7341
|
+
tokenAProgram,
|
|
7342
|
+
tokenBProgram
|
|
7343
|
+
} = params;
|
|
7344
|
+
return yield this._program.methods.removeAllLiquidity(tokenAAmountThreshold, tokenBAmountThreshold).accountsPartial({
|
|
7345
|
+
poolAuthority,
|
|
7346
|
+
pool,
|
|
7347
|
+
position,
|
|
7348
|
+
positionNftAccount,
|
|
7349
|
+
owner,
|
|
7350
|
+
tokenAAccount,
|
|
7351
|
+
tokenBAccount,
|
|
7352
|
+
tokenAMint,
|
|
7353
|
+
tokenBMint,
|
|
7354
|
+
tokenAVault,
|
|
7355
|
+
tokenBVault,
|
|
7356
|
+
tokenAProgram,
|
|
7357
|
+
tokenBProgram
|
|
7358
|
+
}).instruction();
|
|
7359
|
+
});
|
|
7360
|
+
}
|
|
7361
|
+
/**
|
|
7362
|
+
* Builds an instruction to claim fees accumulated by a position.
|
|
7363
|
+
* @private
|
|
7364
|
+
* @param {ClaimPositionFeeInstructionParams} params - Parameters for claiming position fees
|
|
7365
|
+
* @returns {Promise<TransactionInstruction>} Instruction to claim position fees
|
|
7366
|
+
*/
|
|
7367
|
+
buildClaimPositionFeeInstruction(params) {
|
|
7368
|
+
return __async(this, null, function* () {
|
|
7369
|
+
const {
|
|
7370
|
+
owner,
|
|
7371
|
+
poolAuthority,
|
|
7372
|
+
pool,
|
|
7373
|
+
position,
|
|
7374
|
+
positionNftAccount,
|
|
7375
|
+
tokenAAccount,
|
|
7376
|
+
tokenBAccount,
|
|
7377
|
+
tokenAVault,
|
|
7378
|
+
tokenBVault,
|
|
7379
|
+
tokenAMint,
|
|
7380
|
+
tokenBMint,
|
|
7381
|
+
tokenAProgram,
|
|
7382
|
+
tokenBProgram
|
|
7383
|
+
} = params;
|
|
7384
|
+
return yield this._program.methods.claimPositionFee().accountsPartial({
|
|
7385
|
+
poolAuthority,
|
|
7386
|
+
owner,
|
|
7387
|
+
pool,
|
|
7388
|
+
position,
|
|
7389
|
+
positionNftAccount,
|
|
7390
|
+
tokenAAccount,
|
|
7391
|
+
tokenBAccount,
|
|
7392
|
+
tokenAVault,
|
|
7393
|
+
tokenBVault,
|
|
7394
|
+
tokenAMint,
|
|
7395
|
+
tokenBMint,
|
|
7396
|
+
tokenAProgram,
|
|
7397
|
+
tokenBProgram
|
|
7398
|
+
}).instruction();
|
|
7399
|
+
});
|
|
7400
|
+
}
|
|
7401
|
+
/**
|
|
7402
|
+
* Builds an instruction to close a position.
|
|
7403
|
+
* @private
|
|
7404
|
+
* @param {ClosePositionInstructionParams} params - Parameters for closing a position
|
|
7405
|
+
* @returns {Promise<TransactionInstruction>} Instruction to close the position
|
|
7406
|
+
*/
|
|
7407
|
+
buildClosePositionInstruction(params) {
|
|
7408
|
+
return __async(this, null, function* () {
|
|
7409
|
+
const {
|
|
7410
|
+
owner,
|
|
7411
|
+
poolAuthority,
|
|
7412
|
+
pool,
|
|
7413
|
+
position,
|
|
7414
|
+
positionNftAccount,
|
|
7415
|
+
positionNftMint
|
|
7416
|
+
} = params;
|
|
7417
|
+
return yield this._program.methods.closePosition().accountsPartial({
|
|
7418
|
+
positionNftMint,
|
|
7419
|
+
positionNftAccount,
|
|
7420
|
+
pool,
|
|
7421
|
+
position,
|
|
7422
|
+
poolAuthority,
|
|
7423
|
+
rentReceiver: owner,
|
|
7424
|
+
owner,
|
|
7425
|
+
tokenProgram: _spltoken.TOKEN_2022_PROGRAM_ID
|
|
7426
|
+
}).instruction();
|
|
7427
|
+
});
|
|
7428
|
+
}
|
|
7233
7429
|
/**
|
|
7234
7430
|
* Fetches the Config state of the program.
|
|
7235
7431
|
* @param config - Public key of the config account.
|
|
@@ -7359,6 +7555,18 @@ var CpAmm = class {
|
|
|
7359
7555
|
return vestings;
|
|
7360
7556
|
});
|
|
7361
7557
|
}
|
|
7558
|
+
isLockedPosition(position) {
|
|
7559
|
+
const totalLockedLiquidity = position.vestedLiquidity.add(
|
|
7560
|
+
position.permanentLockedLiquidity
|
|
7561
|
+
);
|
|
7562
|
+
return totalLockedLiquidity.gtn(0);
|
|
7563
|
+
}
|
|
7564
|
+
isPoolExist(pool) {
|
|
7565
|
+
return __async(this, null, function* () {
|
|
7566
|
+
const poolState = yield this._program.account.pool.fetchNullable(pool);
|
|
7567
|
+
return poolState !== null;
|
|
7568
|
+
});
|
|
7569
|
+
}
|
|
7362
7570
|
/**
|
|
7363
7571
|
* Calculates swap quote based on input amount and pool state.
|
|
7364
7572
|
* @param params - Swap parameters including input amount, pool state, slippage, etc.
|
|
@@ -7445,34 +7653,151 @@ var CpAmm = class {
|
|
|
7445
7653
|
});
|
|
7446
7654
|
}
|
|
7447
7655
|
/**
|
|
7448
|
-
*
|
|
7656
|
+
* Calculates the deposit quote for liquidity pool.
|
|
7449
7657
|
*
|
|
7450
|
-
* @param {
|
|
7451
|
-
*
|
|
7658
|
+
* @param {GetDepositQuoteParams} params - The parameters for calculating the deposit quote.
|
|
7659
|
+
*
|
|
7660
|
+
* @returns {Promise<Object>} Deposit quote results
|
|
7661
|
+
* @returns {BN} returns.actualInputAmount - The actual amount used as input (after deducting transfer fees).
|
|
7662
|
+
* @returns {BN} returns.outputAmount - The calculated corresponding amount of the other token.
|
|
7663
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be added to the pool.
|
|
7452
7664
|
*/
|
|
7453
|
-
|
|
7665
|
+
getDepositQuote(params) {
|
|
7454
7666
|
return __async(this, null, function* () {
|
|
7455
7667
|
const {
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7668
|
+
inAmount,
|
|
7669
|
+
isTokenA,
|
|
7670
|
+
inputTokenInfo,
|
|
7671
|
+
outputTokenInfo,
|
|
7672
|
+
minSqrtPrice,
|
|
7673
|
+
maxSqrtPrice,
|
|
7674
|
+
sqrtPrice
|
|
7463
7675
|
} = params;
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7676
|
+
const actualAmountIn = inputTokenInfo ? inAmount.sub(
|
|
7677
|
+
calculateTransferFeeIncludedAmount(
|
|
7678
|
+
inAmount,
|
|
7679
|
+
inputTokenInfo.mint,
|
|
7680
|
+
inputTokenInfo.currentEpoch
|
|
7681
|
+
).transferFee
|
|
7682
|
+
) : inAmount;
|
|
7683
|
+
const { liquidityDelta, rawAmount } = isTokenA ? {
|
|
7684
|
+
liquidityDelta: getLiquidityDeltaFromAmountA(
|
|
7685
|
+
actualAmountIn,
|
|
7686
|
+
sqrtPrice,
|
|
7687
|
+
maxSqrtPrice
|
|
7688
|
+
),
|
|
7689
|
+
rawAmount: (delta) => getAmountBFromLiquidityDelta(
|
|
7690
|
+
delta,
|
|
7691
|
+
sqrtPrice,
|
|
7692
|
+
minSqrtPrice,
|
|
7693
|
+
0 /* Up */
|
|
7694
|
+
)
|
|
7695
|
+
} : {
|
|
7696
|
+
liquidityDelta: getLiquidityDeltaFromAmountB(
|
|
7697
|
+
actualAmountIn,
|
|
7698
|
+
minSqrtPrice,
|
|
7699
|
+
sqrtPrice
|
|
7700
|
+
),
|
|
7701
|
+
rawAmount: (delta) => getAmountAFromLiquidityDelta(
|
|
7702
|
+
delta,
|
|
7703
|
+
sqrtPrice,
|
|
7704
|
+
maxSqrtPrice,
|
|
7705
|
+
0 /* Up */
|
|
7706
|
+
)
|
|
7707
|
+
};
|
|
7708
|
+
const rawOutputAmount = new (0, _anchor.BN)(rawAmount(liquidityDelta));
|
|
7709
|
+
const outputAmount = outputTokenInfo ? calculateTransferFeeIncludedAmount(
|
|
7710
|
+
rawOutputAmount,
|
|
7711
|
+
outputTokenInfo.mint,
|
|
7712
|
+
outputTokenInfo.currentEpoch
|
|
7713
|
+
).amount : rawOutputAmount;
|
|
7714
|
+
return {
|
|
7715
|
+
actualInputAmount: actualAmountIn,
|
|
7716
|
+
consumedInputAmount: inAmount,
|
|
7717
|
+
liquidityDelta,
|
|
7718
|
+
outputAmount
|
|
7719
|
+
};
|
|
7720
|
+
});
|
|
7721
|
+
}
|
|
7722
|
+
/**
|
|
7723
|
+
* Calculates the withdrawal quote for removing liquidity from a concentrated liquidity pool.
|
|
7724
|
+
*
|
|
7725
|
+
* @param {GetWithdrawQuoteParams} params - The parameters for calculating the withdraw quote
|
|
7726
|
+
*
|
|
7727
|
+
* @param {Object|null} params.tokenATokenInfo - must provide if token a is token2022
|
|
7728
|
+
* @param {Object|null} params.tokenBTokenInfo - must provide if token b is token2022
|
|
7729
|
+
*
|
|
7730
|
+
* @returns {Promise<Object>} Withdrawal quote results
|
|
7731
|
+
* @returns {BN} returns.liquidityDelta - The amount of liquidity that will be removed from the pool
|
|
7732
|
+
* @returns {BN} returns.outAmountA - The calculated amount of token A to be received (after deducting transfer fees)
|
|
7733
|
+
* @returns {BN} returns.outAmountB - The calculated amount of token B to be received (after deducting transfer fees)
|
|
7734
|
+
*/
|
|
7735
|
+
getWithdrawQuote(params) {
|
|
7736
|
+
return __async(this, null, function* () {
|
|
7737
|
+
const {
|
|
7738
|
+
liquidityDelta,
|
|
7739
|
+
sqrtPrice,
|
|
7740
|
+
maxSqrtPrice,
|
|
7741
|
+
minSqrtPrice,
|
|
7742
|
+
tokenATokenInfo,
|
|
7743
|
+
tokenBTokenInfo
|
|
7744
|
+
} = params;
|
|
7745
|
+
const amountA = getAmountAFromLiquidityDelta(
|
|
7746
|
+
liquidityDelta,
|
|
7747
|
+
sqrtPrice,
|
|
7748
|
+
maxSqrtPrice,
|
|
7749
|
+
1 /* Down */
|
|
7750
|
+
);
|
|
7751
|
+
const amountB = getAmountBFromLiquidityDelta(
|
|
7752
|
+
liquidityDelta,
|
|
7753
|
+
sqrtPrice,
|
|
7754
|
+
minSqrtPrice,
|
|
7755
|
+
1 /* Down */
|
|
7756
|
+
);
|
|
7757
|
+
return {
|
|
7758
|
+
liquidityDelta,
|
|
7759
|
+
outAmountA: tokenATokenInfo ? calculateTransferFeeExcludedAmount(
|
|
7760
|
+
new (0, _anchor.BN)(amountA),
|
|
7761
|
+
tokenATokenInfo.mint,
|
|
7762
|
+
tokenATokenInfo.currentEpoch
|
|
7763
|
+
).amount : new (0, _anchor.BN)(amountA),
|
|
7764
|
+
outAmountB: tokenBTokenInfo ? calculateTransferFeeExcludedAmount(
|
|
7765
|
+
new (0, _anchor.BN)(amountB),
|
|
7766
|
+
tokenBTokenInfo.mint,
|
|
7767
|
+
tokenBTokenInfo.currentEpoch
|
|
7768
|
+
).amount : new (0, _anchor.BN)(amountB)
|
|
7769
|
+
};
|
|
7770
|
+
});
|
|
7771
|
+
}
|
|
7772
|
+
/**
|
|
7773
|
+
* Computes the liquidity delta based on the provided token amounts and pool state.
|
|
7774
|
+
*
|
|
7775
|
+
* @param {LiquidityDeltaParams} params - The parameters for liquidity calculation
|
|
7776
|
+
* @returns {Promise<BN>} - The computed liquidity delta in Q64 value.
|
|
7777
|
+
*/
|
|
7778
|
+
getLiquidityDelta(params) {
|
|
7779
|
+
return __async(this, null, function* () {
|
|
7780
|
+
const {
|
|
7781
|
+
maxAmountTokenA,
|
|
7782
|
+
maxAmountTokenB,
|
|
7783
|
+
sqrtMaxPrice,
|
|
7784
|
+
sqrtMinPrice,
|
|
7785
|
+
sqrtPrice,
|
|
7786
|
+
tokenAInfo,
|
|
7787
|
+
tokenBInfo
|
|
7788
|
+
} = params;
|
|
7789
|
+
let actualMaxAmountTokenA = maxAmountTokenA;
|
|
7790
|
+
let actualMaxAmountTokenB = maxAmountTokenB;
|
|
7791
|
+
if (tokenAInfo) {
|
|
7792
|
+
actualMaxAmountTokenA = calculateTransferFeeExcludedAmount(
|
|
7793
|
+
maxAmountTokenA,
|
|
7794
|
+
tokenAInfo.mint,
|
|
7795
|
+
tokenAInfo.currentEpoch
|
|
7796
|
+
).amount;
|
|
7797
|
+
}
|
|
7798
|
+
if (tokenBInfo) {
|
|
7799
|
+
actualMaxAmountTokenB = calculateTransferFeeExcludedAmount(
|
|
7800
|
+
maxAmountTokenB,
|
|
7476
7801
|
tokenBInfo.mint,
|
|
7477
7802
|
tokenBInfo.currentEpoch
|
|
7478
7803
|
).amount;
|
|
@@ -7549,30 +7874,17 @@ var CpAmm = class {
|
|
|
7549
7874
|
pool,
|
|
7550
7875
|
this._program.programId
|
|
7551
7876
|
);
|
|
7552
|
-
const
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
tokenAProgram
|
|
7564
|
-
),
|
|
7565
|
-
getOrCreateATAInstruction(
|
|
7566
|
-
this._program.provider.connection,
|
|
7567
|
-
tokenBMint,
|
|
7568
|
-
payer,
|
|
7569
|
-
payer,
|
|
7570
|
-
true,
|
|
7571
|
-
tokenBProgram
|
|
7572
|
-
)
|
|
7573
|
-
]);
|
|
7574
|
-
createTokenATokenAccountIx && preInstructions.push(createTokenATokenAccountIx);
|
|
7575
|
-
createTokenBTokenAccountIx && preInstructions.push(createTokenBTokenAccountIx);
|
|
7877
|
+
const {
|
|
7878
|
+
tokenAAta: payerTokenA,
|
|
7879
|
+
tokenBAta: payerTokenB,
|
|
7880
|
+
instructions: preInstructions
|
|
7881
|
+
} = yield this.prepareTokenAccounts(
|
|
7882
|
+
payer,
|
|
7883
|
+
tokenAMint,
|
|
7884
|
+
tokenBMint,
|
|
7885
|
+
tokenAProgram,
|
|
7886
|
+
tokenBProgram
|
|
7887
|
+
);
|
|
7576
7888
|
if (tokenAMint.equals(_spltoken.NATIVE_MINT)) {
|
|
7577
7889
|
const wrapSOLIx = wrapSOLInstruction(
|
|
7578
7890
|
payer,
|
|
@@ -7681,30 +7993,17 @@ var CpAmm = class {
|
|
|
7681
7993
|
pool,
|
|
7682
7994
|
this._program.programId
|
|
7683
7995
|
);
|
|
7684
|
-
const
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
tokenAProgram
|
|
7696
|
-
),
|
|
7697
|
-
getOrCreateATAInstruction(
|
|
7698
|
-
this._program.provider.connection,
|
|
7699
|
-
tokenBMint,
|
|
7700
|
-
payer,
|
|
7701
|
-
payer,
|
|
7702
|
-
true,
|
|
7703
|
-
tokenBProgram
|
|
7704
|
-
)
|
|
7705
|
-
]);
|
|
7706
|
-
createTokenATokenAccountIx && preInstructions.push(createTokenATokenAccountIx);
|
|
7707
|
-
createTokenBTokenAccountIx && preInstructions.push(createTokenBTokenAccountIx);
|
|
7996
|
+
const {
|
|
7997
|
+
tokenAAta: payerTokenA,
|
|
7998
|
+
tokenBAta: payerTokenB,
|
|
7999
|
+
instructions: preInstructions
|
|
8000
|
+
} = yield this.prepareTokenAccounts(
|
|
8001
|
+
payer,
|
|
8002
|
+
tokenAMint,
|
|
8003
|
+
tokenBMint,
|
|
8004
|
+
tokenAProgram,
|
|
8005
|
+
tokenBProgram
|
|
8006
|
+
);
|
|
7708
8007
|
if (tokenAMint.equals(_spltoken.NATIVE_MINT)) {
|
|
7709
8008
|
const wrapSOLIx = wrapSOLInstruction(
|
|
7710
8009
|
payer,
|
|
@@ -7774,7 +8073,7 @@ var CpAmm = class {
|
|
|
7774
8073
|
positionNft,
|
|
7775
8074
|
this._program.programId
|
|
7776
8075
|
);
|
|
7777
|
-
return yield this._program.methods.createPosition().
|
|
8076
|
+
return yield this._program.methods.createPosition().accountsPartial({
|
|
7778
8077
|
owner,
|
|
7779
8078
|
positionNftMint: positionNft,
|
|
7780
8079
|
poolAuthority,
|
|
@@ -7783,9 +8082,7 @@ var CpAmm = class {
|
|
|
7783
8082
|
pool,
|
|
7784
8083
|
position,
|
|
7785
8084
|
tokenProgram: _spltoken.TOKEN_2022_PROGRAM_ID,
|
|
7786
|
-
systemProgram: _web3js.SystemProgram.programId
|
|
7787
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
7788
|
-
program: this._program.programId
|
|
8085
|
+
systemProgram: _web3js.SystemProgram.programId
|
|
7789
8086
|
}).transaction();
|
|
7790
8087
|
});
|
|
7791
8088
|
}
|
|
@@ -7817,30 +8114,17 @@ var CpAmm = class {
|
|
|
7817
8114
|
positionNftMint,
|
|
7818
8115
|
this._program.programId
|
|
7819
8116
|
);
|
|
7820
|
-
const
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
tokenAProgram
|
|
7832
|
-
),
|
|
7833
|
-
getOrCreateATAInstruction(
|
|
7834
|
-
this._program.provider.connection,
|
|
7835
|
-
tokenBMint,
|
|
7836
|
-
owner,
|
|
7837
|
-
owner,
|
|
7838
|
-
true,
|
|
7839
|
-
tokenBProgram
|
|
7840
|
-
)
|
|
7841
|
-
]);
|
|
7842
|
-
createTokenATokenAccountIx && preInstructions.push(createTokenATokenAccountIx);
|
|
7843
|
-
createTokenBTokenAccountIx && preInstructions.push(createTokenBTokenAccountIx);
|
|
8117
|
+
const {
|
|
8118
|
+
tokenAAta: tokenAAccount,
|
|
8119
|
+
tokenBAta: tokenBAccount,
|
|
8120
|
+
instructions: preInstructions
|
|
8121
|
+
} = yield this.prepareTokenAccounts(
|
|
8122
|
+
owner,
|
|
8123
|
+
tokenAMint,
|
|
8124
|
+
tokenBMint,
|
|
8125
|
+
tokenAProgram,
|
|
8126
|
+
tokenBProgram
|
|
8127
|
+
);
|
|
7844
8128
|
if (tokenAMint.equals(_spltoken.NATIVE_MINT)) {
|
|
7845
8129
|
const wrapSOLIx = wrapSOLInstruction(
|
|
7846
8130
|
owner,
|
|
@@ -7864,11 +8148,7 @@ var CpAmm = class {
|
|
|
7864
8148
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
7865
8149
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
7866
8150
|
}
|
|
7867
|
-
|
|
7868
|
-
liquidityDelta: liquidityDeltaQ64,
|
|
7869
|
-
tokenAAmountThreshold,
|
|
7870
|
-
tokenBAmountThreshold
|
|
7871
|
-
}).accountsStrict({
|
|
8151
|
+
const addLiquidityInstruction = yield this.buildAddLiquidityInstruction({
|
|
7872
8152
|
pool,
|
|
7873
8153
|
position,
|
|
7874
8154
|
positionNftAccount,
|
|
@@ -7881,9 +8161,17 @@ var CpAmm = class {
|
|
|
7881
8161
|
tokenBVault,
|
|
7882
8162
|
tokenAProgram,
|
|
7883
8163
|
tokenBProgram,
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
8164
|
+
liquidityDelta: liquidityDeltaQ64,
|
|
8165
|
+
tokenAAmountThreshold,
|
|
8166
|
+
tokenBAmountThreshold
|
|
8167
|
+
});
|
|
8168
|
+
const transaction = new (0, _web3js.Transaction)();
|
|
8169
|
+
transaction.add(
|
|
8170
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
8171
|
+
addLiquidityInstruction,
|
|
8172
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
8173
|
+
);
|
|
8174
|
+
return transaction;
|
|
7887
8175
|
});
|
|
7888
8176
|
}
|
|
7889
8177
|
/**
|
|
@@ -7913,30 +8201,17 @@ var CpAmm = class {
|
|
|
7913
8201
|
this._program.programId
|
|
7914
8202
|
);
|
|
7915
8203
|
const poolAuthority = derivePoolAuthority(this._program.programId);
|
|
7916
|
-
const
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
tokenAProgram
|
|
7928
|
-
),
|
|
7929
|
-
getOrCreateATAInstruction(
|
|
7930
|
-
this._program.provider.connection,
|
|
7931
|
-
tokenBMint,
|
|
7932
|
-
owner,
|
|
7933
|
-
owner,
|
|
7934
|
-
true,
|
|
7935
|
-
tokenBProgram
|
|
7936
|
-
)
|
|
7937
|
-
]);
|
|
7938
|
-
createTokenAAccountIx && preInstructions.push(createTokenAAccountIx);
|
|
7939
|
-
createTokenBAccountIx && preInstructions.push(createTokenBAccountIx);
|
|
8204
|
+
const {
|
|
8205
|
+
tokenAAta: tokenAAccount,
|
|
8206
|
+
tokenBAta: tokenBAccount,
|
|
8207
|
+
instructions: preInstructions
|
|
8208
|
+
} = yield this.prepareTokenAccounts(
|
|
8209
|
+
owner,
|
|
8210
|
+
tokenAMint,
|
|
8211
|
+
tokenBMint,
|
|
8212
|
+
tokenAProgram,
|
|
8213
|
+
tokenBProgram
|
|
8214
|
+
);
|
|
7940
8215
|
const postInstructions = [];
|
|
7941
8216
|
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
7942
8217
|
_spltoken.NATIVE_MINT.toBase58()
|
|
@@ -7948,7 +8223,7 @@ var CpAmm = class {
|
|
|
7948
8223
|
liquidityDelta: liquidityDeltaQ64,
|
|
7949
8224
|
tokenAAmountThreshold,
|
|
7950
8225
|
tokenBAmountThreshold
|
|
7951
|
-
}).
|
|
8226
|
+
}).accountsPartial({
|
|
7952
8227
|
poolAuthority,
|
|
7953
8228
|
pool,
|
|
7954
8229
|
position,
|
|
@@ -7961,9 +8236,7 @@ var CpAmm = class {
|
|
|
7961
8236
|
tokenAVault,
|
|
7962
8237
|
tokenBVault,
|
|
7963
8238
|
tokenAProgram,
|
|
7964
|
-
tokenBProgram
|
|
7965
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
7966
|
-
program: this._program.programId
|
|
8239
|
+
tokenBProgram
|
|
7967
8240
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
7968
8241
|
});
|
|
7969
8242
|
}
|
|
@@ -7993,30 +8266,17 @@ var CpAmm = class {
|
|
|
7993
8266
|
this._program.programId
|
|
7994
8267
|
);
|
|
7995
8268
|
const poolAuthority = derivePoolAuthority(this._program.programId);
|
|
7996
|
-
const
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
tokenAProgram
|
|
8008
|
-
),
|
|
8009
|
-
getOrCreateATAInstruction(
|
|
8010
|
-
this._program.provider.connection,
|
|
8011
|
-
tokenBMint,
|
|
8012
|
-
owner,
|
|
8013
|
-
owner,
|
|
8014
|
-
true,
|
|
8015
|
-
tokenBProgram
|
|
8016
|
-
)
|
|
8017
|
-
]);
|
|
8018
|
-
createTokenAAccountIx && preInstructions.push(createTokenAAccountIx);
|
|
8019
|
-
createTokenBAccountIx && preInstructions.push(createTokenBAccountIx);
|
|
8269
|
+
const {
|
|
8270
|
+
tokenAAta: tokenAAccount,
|
|
8271
|
+
tokenBAta: tokenBAccount,
|
|
8272
|
+
instructions: preInstructions
|
|
8273
|
+
} = yield this.prepareTokenAccounts(
|
|
8274
|
+
owner,
|
|
8275
|
+
tokenAMint,
|
|
8276
|
+
tokenBMint,
|
|
8277
|
+
tokenAProgram,
|
|
8278
|
+
tokenBProgram
|
|
8279
|
+
);
|
|
8020
8280
|
const postInstructions = [];
|
|
8021
8281
|
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8022
8282
|
_spltoken.NATIVE_MINT.toBase58()
|
|
@@ -8024,21 +8284,30 @@ var CpAmm = class {
|
|
|
8024
8284
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
8025
8285
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8026
8286
|
}
|
|
8027
|
-
|
|
8287
|
+
const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
|
|
8028
8288
|
poolAuthority,
|
|
8289
|
+
owner,
|
|
8029
8290
|
pool,
|
|
8030
8291
|
position,
|
|
8031
8292
|
positionNftAccount,
|
|
8032
|
-
owner,
|
|
8033
8293
|
tokenAAccount,
|
|
8034
8294
|
tokenBAccount,
|
|
8295
|
+
tokenAAmountThreshold,
|
|
8296
|
+
tokenBAmountThreshold,
|
|
8035
8297
|
tokenAMint,
|
|
8036
8298
|
tokenBMint,
|
|
8037
8299
|
tokenAVault,
|
|
8038
8300
|
tokenBVault,
|
|
8039
8301
|
tokenAProgram,
|
|
8040
8302
|
tokenBProgram
|
|
8041
|
-
})
|
|
8303
|
+
});
|
|
8304
|
+
const transaction = new (0, _web3js.Transaction)();
|
|
8305
|
+
transaction.add(
|
|
8306
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
8307
|
+
removeAllLiquidityInstruction,
|
|
8308
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
8309
|
+
);
|
|
8310
|
+
return transaction;
|
|
8042
8311
|
});
|
|
8043
8312
|
}
|
|
8044
8313
|
/**
|
|
@@ -8067,30 +8336,17 @@ var CpAmm = class {
|
|
|
8067
8336
|
const [inputTokenProgram, outputTokenProgram] = inputTokenMint.equals(
|
|
8068
8337
|
tokenAMint
|
|
8069
8338
|
) ? [tokenAProgram, tokenBProgram] : [tokenBProgram, tokenAProgram];
|
|
8070
|
-
const
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
inputTokenProgram
|
|
8082
|
-
),
|
|
8083
|
-
getOrCreateATAInstruction(
|
|
8084
|
-
this._program.provider.connection,
|
|
8085
|
-
outputTokenMint,
|
|
8086
|
-
payer,
|
|
8087
|
-
payer,
|
|
8088
|
-
true,
|
|
8089
|
-
outputTokenProgram
|
|
8090
|
-
)
|
|
8091
|
-
]);
|
|
8092
|
-
createInputTokenAccountIx && preInstructions.push(createInputTokenAccountIx);
|
|
8093
|
-
createOutputTokenAccountIx && preInstructions.push(createOutputTokenAccountIx);
|
|
8339
|
+
const {
|
|
8340
|
+
tokenAAta: inputTokenAccount,
|
|
8341
|
+
tokenBAta: outputTokenAccount,
|
|
8342
|
+
instructions: preInstructions
|
|
8343
|
+
} = yield this.prepareTokenAccounts(
|
|
8344
|
+
payer,
|
|
8345
|
+
inputTokenMint,
|
|
8346
|
+
outputTokenMint,
|
|
8347
|
+
inputTokenProgram,
|
|
8348
|
+
outputTokenProgram
|
|
8349
|
+
);
|
|
8094
8350
|
if (inputTokenMint.equals(_spltoken.NATIVE_MINT)) {
|
|
8095
8351
|
const wrapSOLIx = wrapSOLInstruction(
|
|
8096
8352
|
payer,
|
|
@@ -8109,7 +8365,7 @@ var CpAmm = class {
|
|
|
8109
8365
|
return yield this._program.methods.swap({
|
|
8110
8366
|
amountIn,
|
|
8111
8367
|
minimumAmountOut
|
|
8112
|
-
}).
|
|
8368
|
+
}).accountsPartial({
|
|
8113
8369
|
poolAuthority,
|
|
8114
8370
|
pool,
|
|
8115
8371
|
payer,
|
|
@@ -8121,9 +8377,7 @@ var CpAmm = class {
|
|
|
8121
8377
|
tokenBMint,
|
|
8122
8378
|
tokenAProgram,
|
|
8123
8379
|
tokenBProgram,
|
|
8124
|
-
referralTokenAccount
|
|
8125
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8126
|
-
program: this._program.programId
|
|
8380
|
+
referralTokenAccount
|
|
8127
8381
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8128
8382
|
});
|
|
8129
8383
|
}
|
|
@@ -8158,16 +8412,14 @@ var CpAmm = class {
|
|
|
8158
8412
|
liquidityPerPeriod,
|
|
8159
8413
|
numberOfPeriod
|
|
8160
8414
|
};
|
|
8161
|
-
return yield this._program.methods.lockPosition(lockPositionParams).
|
|
8415
|
+
return yield this._program.methods.lockPosition(lockPositionParams).accountsPartial({
|
|
8162
8416
|
position,
|
|
8163
8417
|
positionNftAccount,
|
|
8164
8418
|
vesting: vestingAccount,
|
|
8165
8419
|
pool,
|
|
8166
8420
|
owner,
|
|
8167
8421
|
payer,
|
|
8168
|
-
systemProgram: _web3js.SystemProgram.programId
|
|
8169
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8170
|
-
program: this._program.programId
|
|
8422
|
+
systemProgram: _web3js.SystemProgram.programId
|
|
8171
8423
|
}).transaction();
|
|
8172
8424
|
});
|
|
8173
8425
|
}
|
|
@@ -8183,13 +8435,11 @@ var CpAmm = class {
|
|
|
8183
8435
|
positionNftMint,
|
|
8184
8436
|
this._program.programId
|
|
8185
8437
|
);
|
|
8186
|
-
return yield this._program.methods.permanentLockPosition(unlockedLiquidity).
|
|
8438
|
+
return yield this._program.methods.permanentLockPosition(unlockedLiquidity).accountsPartial({
|
|
8187
8439
|
position,
|
|
8188
8440
|
positionNftAccount,
|
|
8189
8441
|
pool,
|
|
8190
|
-
owner
|
|
8191
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8192
|
-
program: this._program.programId
|
|
8442
|
+
owner
|
|
8193
8443
|
}).transaction();
|
|
8194
8444
|
});
|
|
8195
8445
|
}
|
|
@@ -8205,7 +8455,7 @@ var CpAmm = class {
|
|
|
8205
8455
|
positionNftMint,
|
|
8206
8456
|
this._program.programId
|
|
8207
8457
|
);
|
|
8208
|
-
return yield this._program.methods.refreshVesting().
|
|
8458
|
+
return yield this._program.methods.refreshVesting().accountsPartial({
|
|
8209
8459
|
position,
|
|
8210
8460
|
positionNftAccount,
|
|
8211
8461
|
pool,
|
|
@@ -8245,30 +8495,17 @@ var CpAmm = class {
|
|
|
8245
8495
|
this._program.programId
|
|
8246
8496
|
);
|
|
8247
8497
|
const poolAuthority = derivePoolAuthority(this._program.programId);
|
|
8248
|
-
const
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
tokenAProgram
|
|
8260
|
-
),
|
|
8261
|
-
getOrCreateATAInstruction(
|
|
8262
|
-
this._program.provider.connection,
|
|
8263
|
-
tokenBMint,
|
|
8264
|
-
owner,
|
|
8265
|
-
owner,
|
|
8266
|
-
true,
|
|
8267
|
-
tokenBProgram
|
|
8268
|
-
)
|
|
8269
|
-
]);
|
|
8270
|
-
createTokenAAccountIx && preInstructions.push(createTokenAAccountIx);
|
|
8271
|
-
createTokenBAccountIx && preInstructions.push(createTokenBAccountIx);
|
|
8498
|
+
const {
|
|
8499
|
+
tokenAAta: tokenAAccount,
|
|
8500
|
+
tokenBAta: tokenBAccount,
|
|
8501
|
+
instructions: preInstructions
|
|
8502
|
+
} = yield this.prepareTokenAccounts(
|
|
8503
|
+
owner,
|
|
8504
|
+
tokenAMint,
|
|
8505
|
+
tokenBMint,
|
|
8506
|
+
tokenAProgram,
|
|
8507
|
+
tokenBProgram
|
|
8508
|
+
);
|
|
8272
8509
|
const postInstructions = [];
|
|
8273
8510
|
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8274
8511
|
_spltoken.NATIVE_MINT.toBase58()
|
|
@@ -8276,9 +8513,9 @@ var CpAmm = class {
|
|
|
8276
8513
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
8277
8514
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8278
8515
|
}
|
|
8279
|
-
|
|
8280
|
-
poolAuthority,
|
|
8516
|
+
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
8281
8517
|
owner,
|
|
8518
|
+
poolAuthority,
|
|
8282
8519
|
pool,
|
|
8283
8520
|
position,
|
|
8284
8521
|
positionNftAccount,
|
|
@@ -8289,10 +8526,15 @@ var CpAmm = class {
|
|
|
8289
8526
|
tokenAMint,
|
|
8290
8527
|
tokenBMint,
|
|
8291
8528
|
tokenAProgram,
|
|
8292
|
-
tokenBProgram
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8529
|
+
tokenBProgram
|
|
8530
|
+
});
|
|
8531
|
+
const transaction = new (0, _web3js.Transaction)();
|
|
8532
|
+
transaction.add(
|
|
8533
|
+
...preInstructions.length > 0 ? preInstructions : [],
|
|
8534
|
+
claimPositionFeeInstruction,
|
|
8535
|
+
...postInstructions.length > 0 ? postInstructions : []
|
|
8536
|
+
);
|
|
8537
|
+
return transaction;
|
|
8296
8538
|
});
|
|
8297
8539
|
}
|
|
8298
8540
|
closePosition(params) {
|
|
@@ -8303,16 +8545,251 @@ var CpAmm = class {
|
|
|
8303
8545
|
positionNftMint,
|
|
8304
8546
|
this._program.programId
|
|
8305
8547
|
);
|
|
8306
|
-
|
|
8548
|
+
const instruction = yield this.buildClosePositionInstruction({
|
|
8549
|
+
owner,
|
|
8550
|
+
poolAuthority,
|
|
8551
|
+
pool,
|
|
8552
|
+
position,
|
|
8553
|
+
positionNftMint,
|
|
8554
|
+
positionNftAccount
|
|
8555
|
+
});
|
|
8556
|
+
return new (0, _web3js.Transaction)().add(instruction);
|
|
8557
|
+
});
|
|
8558
|
+
}
|
|
8559
|
+
/**
|
|
8560
|
+
* Builds a transaction to remove all liquidity from a position and close it.
|
|
8561
|
+
* This combines several operations in a single transaction:
|
|
8562
|
+
* 1. Claims any accumulated fees
|
|
8563
|
+
* 2. Removes all liquidity
|
|
8564
|
+
* 3. Closes the position
|
|
8565
|
+
*
|
|
8566
|
+
* @param {RemoveAllLiquidityAndClosePositionParams} params - Combined parameters
|
|
8567
|
+
* @returns {TxBuilder} Transaction builder with all required instructions
|
|
8568
|
+
* @throws {Error} If the position is locked or cannot be closed
|
|
8569
|
+
*/
|
|
8570
|
+
removeAllLiquidityAndClosePosition(params) {
|
|
8571
|
+
return __async(this, null, function* () {
|
|
8572
|
+
const {
|
|
8573
|
+
owner,
|
|
8574
|
+
position,
|
|
8575
|
+
positionState,
|
|
8576
|
+
poolState,
|
|
8577
|
+
tokenAAmountThreshold,
|
|
8578
|
+
tokenBAmountThreshold
|
|
8579
|
+
} = params;
|
|
8580
|
+
const { nftMint: positionNftMint, pool } = positionState;
|
|
8581
|
+
const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState;
|
|
8582
|
+
const isLockedPosition = this.isLockedPosition(positionState);
|
|
8583
|
+
if (isLockedPosition) {
|
|
8584
|
+
throw Error("position must be unlocked");
|
|
8585
|
+
}
|
|
8586
|
+
const positionNftAccount = derivePositionNftAccount(
|
|
8307
8587
|
positionNftMint,
|
|
8588
|
+
this._program.programId
|
|
8589
|
+
);
|
|
8590
|
+
const poolAuthority = derivePoolAuthority(this._program.programId);
|
|
8591
|
+
const tokenAProgram = getTokenProgram(poolState.tokenAFlag);
|
|
8592
|
+
const tokenBProgram = getTokenProgram(poolState.tokenBFlag);
|
|
8593
|
+
const {
|
|
8594
|
+
tokenAAta: tokenAAccount,
|
|
8595
|
+
tokenBAta: tokenBAccount,
|
|
8596
|
+
instructions: preInstructions
|
|
8597
|
+
} = yield this.prepareTokenAccounts(
|
|
8598
|
+
owner,
|
|
8599
|
+
tokenAMint,
|
|
8600
|
+
tokenBMint,
|
|
8601
|
+
tokenAProgram,
|
|
8602
|
+
tokenBProgram
|
|
8603
|
+
);
|
|
8604
|
+
const postInstructions = [];
|
|
8605
|
+
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8606
|
+
_spltoken.NATIVE_MINT.toBase58()
|
|
8607
|
+
)) {
|
|
8608
|
+
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
8609
|
+
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8610
|
+
}
|
|
8611
|
+
const transaction = new (0, _web3js.Transaction)();
|
|
8612
|
+
if (preInstructions.length > 0) {
|
|
8613
|
+
transaction.add(...preInstructions);
|
|
8614
|
+
}
|
|
8615
|
+
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
8616
|
+
owner,
|
|
8617
|
+
poolAuthority,
|
|
8618
|
+
pool,
|
|
8619
|
+
position,
|
|
8308
8620
|
positionNftAccount,
|
|
8621
|
+
tokenAAccount,
|
|
8622
|
+
tokenBAccount,
|
|
8623
|
+
tokenAVault,
|
|
8624
|
+
tokenBVault,
|
|
8625
|
+
tokenAMint,
|
|
8626
|
+
tokenBMint,
|
|
8627
|
+
tokenAProgram,
|
|
8628
|
+
tokenBProgram
|
|
8629
|
+
});
|
|
8630
|
+
transaction.add(claimPositionFeeInstruction);
|
|
8631
|
+
const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
|
|
8632
|
+
poolAuthority,
|
|
8633
|
+
owner,
|
|
8634
|
+
pool,
|
|
8635
|
+
position,
|
|
8636
|
+
positionNftAccount,
|
|
8637
|
+
tokenAAccount,
|
|
8638
|
+
tokenBAccount,
|
|
8639
|
+
tokenAAmountThreshold,
|
|
8640
|
+
tokenBAmountThreshold,
|
|
8641
|
+
tokenAMint,
|
|
8642
|
+
tokenBMint,
|
|
8643
|
+
tokenAVault,
|
|
8644
|
+
tokenBVault,
|
|
8645
|
+
tokenAProgram,
|
|
8646
|
+
tokenBProgram
|
|
8647
|
+
});
|
|
8648
|
+
transaction.add(removeAllLiquidityInstruction);
|
|
8649
|
+
const closePositionInstruction = yield this.buildClosePositionInstruction({
|
|
8650
|
+
owner,
|
|
8651
|
+
poolAuthority,
|
|
8309
8652
|
pool,
|
|
8310
8653
|
position,
|
|
8654
|
+
positionNftMint,
|
|
8655
|
+
positionNftAccount
|
|
8656
|
+
});
|
|
8657
|
+
transaction.add(closePositionInstruction);
|
|
8658
|
+
if (postInstructions.length > 0) {
|
|
8659
|
+
transaction.add(...postInstructions);
|
|
8660
|
+
}
|
|
8661
|
+
return transaction;
|
|
8662
|
+
});
|
|
8663
|
+
}
|
|
8664
|
+
/**
|
|
8665
|
+
* Builds a transaction to merge liquidity from one position into another.
|
|
8666
|
+
* This process:
|
|
8667
|
+
* 1. Claims fees from the source position
|
|
8668
|
+
* 2. Removes all liquidity from the source position
|
|
8669
|
+
* 3. Adds that liquidity to the target position
|
|
8670
|
+
* 4. Closes the source position
|
|
8671
|
+
*
|
|
8672
|
+
* @param {MergePositionParams} params - Parameters for merging positions
|
|
8673
|
+
* @returns {TxBuilder} Transaction builder with all required instructions
|
|
8674
|
+
* @throws {Error} If either position is locked or incompatible
|
|
8675
|
+
*/
|
|
8676
|
+
mergePosition(params) {
|
|
8677
|
+
return __async(this, null, function* () {
|
|
8678
|
+
const {
|
|
8679
|
+
owner,
|
|
8680
|
+
positionA,
|
|
8681
|
+
positionB,
|
|
8682
|
+
positionBState,
|
|
8683
|
+
positionAState,
|
|
8684
|
+
poolState,
|
|
8685
|
+
tokenAAmountThreshold,
|
|
8686
|
+
tokenBAmountThreshold
|
|
8687
|
+
} = params;
|
|
8688
|
+
const isLockedPosition = this.isLockedPosition(positionBState);
|
|
8689
|
+
if (isLockedPosition) {
|
|
8690
|
+
throw Error("position must be unlocked");
|
|
8691
|
+
}
|
|
8692
|
+
const postionBLiquidityDelta = positionBState.unlockedLiquidity;
|
|
8693
|
+
const pool = positionBState.pool;
|
|
8694
|
+
const { tokenAMint, tokenBMint, tokenAVault, tokenBVault } = poolState;
|
|
8695
|
+
const positionBNftAccount = derivePositionNftAccount(
|
|
8696
|
+
positionBState.nftMint,
|
|
8697
|
+
this._program.programId
|
|
8698
|
+
);
|
|
8699
|
+
const positionANftAccount = derivePositionNftAccount(
|
|
8700
|
+
positionAState.nftMint,
|
|
8701
|
+
this._program.programId
|
|
8702
|
+
);
|
|
8703
|
+
const poolAuthority = derivePoolAuthority(this._program.programId);
|
|
8704
|
+
const tokenAProgram = getTokenProgram(poolState.tokenAFlag);
|
|
8705
|
+
const tokenBProgram = getTokenProgram(poolState.tokenBFlag);
|
|
8706
|
+
const {
|
|
8707
|
+
tokenAAta: tokenAAccount,
|
|
8708
|
+
tokenBAta: tokenBAccount,
|
|
8709
|
+
instructions: preInstructions
|
|
8710
|
+
} = yield this.prepareTokenAccounts(
|
|
8711
|
+
owner,
|
|
8712
|
+
tokenAMint,
|
|
8713
|
+
tokenBMint,
|
|
8714
|
+
tokenAProgram,
|
|
8715
|
+
tokenBProgram
|
|
8716
|
+
);
|
|
8717
|
+
const postInstructions = [];
|
|
8718
|
+
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
8719
|
+
_spltoken.NATIVE_MINT.toBase58()
|
|
8720
|
+
)) {
|
|
8721
|
+
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
8722
|
+
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8723
|
+
}
|
|
8724
|
+
const transaction = new (0, _web3js.Transaction)();
|
|
8725
|
+
if (preInstructions.length > 0) {
|
|
8726
|
+
transaction.add(...preInstructions);
|
|
8727
|
+
}
|
|
8728
|
+
const claimPositionFeeInstruction = yield this.buildClaimPositionFeeInstruction({
|
|
8729
|
+
owner,
|
|
8730
|
+
poolAuthority,
|
|
8731
|
+
pool,
|
|
8732
|
+
position: positionB,
|
|
8733
|
+
positionNftAccount: positionBNftAccount,
|
|
8734
|
+
tokenAAccount,
|
|
8735
|
+
tokenBAccount,
|
|
8736
|
+
tokenAVault,
|
|
8737
|
+
tokenBVault,
|
|
8738
|
+
tokenAMint,
|
|
8739
|
+
tokenBMint,
|
|
8740
|
+
tokenAProgram,
|
|
8741
|
+
tokenBProgram
|
|
8742
|
+
});
|
|
8743
|
+
transaction.add(claimPositionFeeInstruction);
|
|
8744
|
+
const removeAllLiquidityInstruction = yield this.buildRemoveAllLiquidityInstruction({
|
|
8311
8745
|
poolAuthority,
|
|
8312
|
-
rentReceiver: owner,
|
|
8313
8746
|
owner,
|
|
8314
|
-
|
|
8315
|
-
|
|
8747
|
+
pool,
|
|
8748
|
+
position: positionB,
|
|
8749
|
+
positionNftAccount: positionBNftAccount,
|
|
8750
|
+
tokenAAccount,
|
|
8751
|
+
tokenBAccount,
|
|
8752
|
+
tokenAAmountThreshold,
|
|
8753
|
+
tokenBAmountThreshold,
|
|
8754
|
+
tokenAMint,
|
|
8755
|
+
tokenBMint,
|
|
8756
|
+
tokenAVault,
|
|
8757
|
+
tokenBVault,
|
|
8758
|
+
tokenAProgram,
|
|
8759
|
+
tokenBProgram
|
|
8760
|
+
});
|
|
8761
|
+
transaction.add(removeAllLiquidityInstruction);
|
|
8762
|
+
const addLiquidityInstruction = yield this.buildAddLiquidityInstruction({
|
|
8763
|
+
pool,
|
|
8764
|
+
position: positionA,
|
|
8765
|
+
positionNftAccount: positionANftAccount,
|
|
8766
|
+
owner,
|
|
8767
|
+
tokenAAccount,
|
|
8768
|
+
tokenBAccount,
|
|
8769
|
+
tokenAMint,
|
|
8770
|
+
tokenBMint,
|
|
8771
|
+
tokenAVault,
|
|
8772
|
+
tokenBVault,
|
|
8773
|
+
tokenAProgram,
|
|
8774
|
+
tokenBProgram,
|
|
8775
|
+
liquidityDelta: postionBLiquidityDelta,
|
|
8776
|
+
tokenAAmountThreshold,
|
|
8777
|
+
tokenBAmountThreshold
|
|
8778
|
+
});
|
|
8779
|
+
transaction.add(addLiquidityInstruction);
|
|
8780
|
+
const closePositionInstruction = yield this.buildClosePositionInstruction({
|
|
8781
|
+
owner,
|
|
8782
|
+
poolAuthority,
|
|
8783
|
+
pool: positionBState.pool,
|
|
8784
|
+
position: positionB,
|
|
8785
|
+
positionNftMint: positionBState.nftMint,
|
|
8786
|
+
positionNftAccount: positionBNftAccount
|
|
8787
|
+
});
|
|
8788
|
+
transaction.add(closePositionInstruction);
|
|
8789
|
+
if (postInstructions.length > 0) {
|
|
8790
|
+
transaction.add(...postInstructions);
|
|
8791
|
+
}
|
|
8792
|
+
return transaction;
|
|
8316
8793
|
});
|
|
8317
8794
|
}
|
|
8318
8795
|
/**
|
|
@@ -8323,11 +8800,9 @@ var CpAmm = class {
|
|
|
8323
8800
|
updateRewardDuration(params) {
|
|
8324
8801
|
return __async(this, null, function* () {
|
|
8325
8802
|
const { pool, admin, rewardIndex, newDuration } = params;
|
|
8326
|
-
return yield this._program.methods.updateRewardDuration(rewardIndex, newDuration).
|
|
8803
|
+
return yield this._program.methods.updateRewardDuration(rewardIndex, newDuration).accountsPartial({
|
|
8327
8804
|
pool,
|
|
8328
|
-
admin
|
|
8329
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8330
|
-
program: this._program.programId
|
|
8805
|
+
admin
|
|
8331
8806
|
}).transaction();
|
|
8332
8807
|
});
|
|
8333
8808
|
}
|
|
@@ -8339,11 +8814,9 @@ var CpAmm = class {
|
|
|
8339
8814
|
updateRewardFunder(params) {
|
|
8340
8815
|
return __async(this, null, function* () {
|
|
8341
8816
|
const { pool, admin, rewardIndex, newFunder } = params;
|
|
8342
|
-
return yield this._program.methods.updateRewardFunder(rewardIndex, newFunder).
|
|
8817
|
+
return yield this._program.methods.updateRewardFunder(rewardIndex, newFunder).accountsPartial({
|
|
8343
8818
|
pool,
|
|
8344
|
-
admin
|
|
8345
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8346
|
-
program: this._program.programId
|
|
8819
|
+
admin
|
|
8347
8820
|
}).transaction();
|
|
8348
8821
|
});
|
|
8349
8822
|
}
|
|
@@ -8377,15 +8850,13 @@ var CpAmm = class {
|
|
|
8377
8850
|
);
|
|
8378
8851
|
preInstructions.push(...wrapSOLIx);
|
|
8379
8852
|
}
|
|
8380
|
-
return yield this._program.methods.fundReward(rewardIndex, amount, carryForward).
|
|
8853
|
+
return yield this._program.methods.fundReward(rewardIndex, amount, carryForward).accountsPartial({
|
|
8381
8854
|
pool,
|
|
8382
8855
|
rewardVault: vault,
|
|
8383
8856
|
rewardMint: mint,
|
|
8384
8857
|
funderTokenAccount,
|
|
8385
8858
|
funder,
|
|
8386
|
-
tokenProgram
|
|
8387
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8388
|
-
program: this._program.programId
|
|
8859
|
+
tokenProgram
|
|
8389
8860
|
}).transaction();
|
|
8390
8861
|
});
|
|
8391
8862
|
}
|
|
@@ -8417,16 +8888,14 @@ var CpAmm = class {
|
|
|
8417
8888
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(funder);
|
|
8418
8889
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8419
8890
|
}
|
|
8420
|
-
return yield this._program.methods.withdrawIneligibleReward(rewardIndex).
|
|
8891
|
+
return yield this._program.methods.withdrawIneligibleReward(rewardIndex).accountsPartial({
|
|
8421
8892
|
pool,
|
|
8422
8893
|
rewardVault: vault,
|
|
8423
8894
|
rewardMint: mint,
|
|
8424
8895
|
poolAuthority,
|
|
8425
8896
|
funderTokenAccount,
|
|
8426
8897
|
funder,
|
|
8427
|
-
tokenProgram
|
|
8428
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8429
|
-
program: this._program.programId
|
|
8898
|
+
tokenProgram
|
|
8430
8899
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8431
8900
|
});
|
|
8432
8901
|
}
|
|
@@ -8450,30 +8919,17 @@ var CpAmm = class {
|
|
|
8450
8919
|
const poolAuthority = derivePoolAuthority(this._program.programId);
|
|
8451
8920
|
const tokenAProgram = getTokenProgram(tokenAFlag);
|
|
8452
8921
|
const tokenBProgram = getTokenProgram(tokenBFlag);
|
|
8453
|
-
const
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
tokenAProgram
|
|
8465
|
-
),
|
|
8466
|
-
getOrCreateATAInstruction(
|
|
8467
|
-
this._program.provider.connection,
|
|
8468
|
-
poolState.tokenBMint,
|
|
8469
|
-
partner,
|
|
8470
|
-
partner,
|
|
8471
|
-
true,
|
|
8472
|
-
tokenBProgram
|
|
8473
|
-
)
|
|
8474
|
-
]);
|
|
8475
|
-
createTokenAAccountIx && preInstructions.push(createTokenAAccountIx);
|
|
8476
|
-
createTokenBAccountIx && preInstructions.push(createTokenBAccountIx);
|
|
8922
|
+
const {
|
|
8923
|
+
tokenAAta: tokenAAccount,
|
|
8924
|
+
tokenBAta: tokenBAccount,
|
|
8925
|
+
instructions: preInstructions
|
|
8926
|
+
} = yield this.prepareTokenAccounts(
|
|
8927
|
+
partner,
|
|
8928
|
+
tokenAMint,
|
|
8929
|
+
tokenBMint,
|
|
8930
|
+
tokenAProgram,
|
|
8931
|
+
tokenBProgram
|
|
8932
|
+
);
|
|
8477
8933
|
const postInstructions = [];
|
|
8478
8934
|
if ([
|
|
8479
8935
|
poolState.tokenAMint.toBase58(),
|
|
@@ -8482,7 +8938,7 @@ var CpAmm = class {
|
|
|
8482
8938
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(partner);
|
|
8483
8939
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8484
8940
|
}
|
|
8485
|
-
return yield this._program.methods.claimPartnerFee(maxAmountA, maxAmountB).
|
|
8941
|
+
return yield this._program.methods.claimPartnerFee(maxAmountA, maxAmountB).accountsPartial({
|
|
8486
8942
|
poolAuthority,
|
|
8487
8943
|
pool,
|
|
8488
8944
|
tokenAAccount,
|
|
@@ -8493,9 +8949,7 @@ var CpAmm = class {
|
|
|
8493
8949
|
tokenBMint,
|
|
8494
8950
|
partner,
|
|
8495
8951
|
tokenAProgram,
|
|
8496
|
-
tokenBProgram
|
|
8497
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8498
|
-
program: this._program.programId
|
|
8952
|
+
tokenBProgram
|
|
8499
8953
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8500
8954
|
});
|
|
8501
8955
|
}
|
|
@@ -8531,7 +8985,7 @@ var CpAmm = class {
|
|
|
8531
8985
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(user);
|
|
8532
8986
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
8533
8987
|
}
|
|
8534
|
-
return yield this._program.methods.claimReward(rewardIndex).
|
|
8988
|
+
return yield this._program.methods.claimReward(rewardIndex).accountsPartial({
|
|
8535
8989
|
pool: positionState.pool,
|
|
8536
8990
|
positionNftAccount,
|
|
8537
8991
|
rewardVault: rewardInfo.vault,
|
|
@@ -8540,9 +8994,7 @@ var CpAmm = class {
|
|
|
8540
8994
|
position,
|
|
8541
8995
|
userTokenAccount,
|
|
8542
8996
|
owner: user,
|
|
8543
|
-
tokenProgram
|
|
8544
|
-
eventAuthority: deriveEventAuthority(this._program.programId)[0],
|
|
8545
|
-
program: this._program.programId
|
|
8997
|
+
tokenProgram
|
|
8546
8998
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
8547
8999
|
});
|
|
8548
9000
|
}
|