@meteora-ag/cp-amm-sdk 1.2.2 → 1.2.4-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.mts +120 -5
- package/dist/index.d.ts +120 -5
- package/dist/index.js +328 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +330 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7952,7 +7952,7 @@ var getSqrtPriceFromPrice = (price, tokenADecimal, tokenBDecimal) => {
|
|
|
7952
7952
|
const sqrtValueQ64 = sqrtValue.mul(_decimaljs2.default.pow(2, 64));
|
|
7953
7953
|
return new (0, _anchor.BN)(sqrtValueQ64.floor().toFixed());
|
|
7954
7954
|
};
|
|
7955
|
-
var
|
|
7955
|
+
var getUnClaimLpFee = (poolState, positionState) => {
|
|
7956
7956
|
const totalPositionLiquidity = positionState.unlockedLiquidity.add(positionState.vestedLiquidity).add(positionState.permanentLockedLiquidity);
|
|
7957
7957
|
const feeAPerTokenStored = new (0, _anchor.BN)(
|
|
7958
7958
|
Buffer.from(poolState.feeAPerLiquidity).reverse()
|
|
@@ -7968,8 +7968,103 @@ var getUnClaimReward = (poolState, positionState) => {
|
|
|
7968
7968
|
rewards: positionState.rewardInfos.length > 0 ? positionState.rewardInfos.map((item) => item.rewardPendings) : []
|
|
7969
7969
|
};
|
|
7970
7970
|
};
|
|
7971
|
+
function getRewardPerTokenStore(poolReward, poolLiquidity, currentTime) {
|
|
7972
|
+
if (poolLiquidity.eq(new (0, _anchor.BN)(0))) {
|
|
7973
|
+
return new (0, _anchor.BN)(0);
|
|
7974
|
+
}
|
|
7975
|
+
const lastTimeRewardApplicable = _anchor.BN.min(
|
|
7976
|
+
currentTime,
|
|
7977
|
+
poolReward.rewardDurationEnd
|
|
7978
|
+
);
|
|
7979
|
+
const timePeriod = lastTimeRewardApplicable.sub(poolReward.lastUpdateTime);
|
|
7980
|
+
const currentTotalReward = timePeriod.mul(poolReward.rewardRate);
|
|
7981
|
+
const rewardPerTokenStore = currentTotalReward.shln(128).div(poolLiquidity);
|
|
7982
|
+
const totalRewardPerTokenStore = new (0, _anchor.BN)(
|
|
7983
|
+
Buffer.from(poolReward.rewardPerTokenStored).reverse()
|
|
7984
|
+
).add(rewardPerTokenStore);
|
|
7985
|
+
return totalRewardPerTokenStore;
|
|
7986
|
+
}
|
|
7987
|
+
function getRewardPerPeriod(poolReward, currentTime, periodTime) {
|
|
7988
|
+
const timeRewardAppicable = currentTime.add(periodTime);
|
|
7989
|
+
const period = timeRewardAppicable <= poolReward.rewardDurationEnd ? periodTime : poolReward.rewardDurationEnd.sub(currentTime);
|
|
7990
|
+
const rewardPerPeriod = poolReward.rewardRate.mul(period);
|
|
7991
|
+
return rewardPerPeriod;
|
|
7992
|
+
}
|
|
7993
|
+
function getRewardInfo(poolState, rewardIndex, periodTime, currentTime) {
|
|
7994
|
+
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
7995
|
+
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
7996
|
+
poolReward,
|
|
7997
|
+
poolState.liquidity,
|
|
7998
|
+
currentTime
|
|
7999
|
+
);
|
|
8000
|
+
const totalRewardDistributed = rewardPerTokenStore.mul(poolState.liquidity).shrn(192);
|
|
8001
|
+
if (poolReward.rewardDurationEnd <= currentTime) {
|
|
8002
|
+
return {
|
|
8003
|
+
rewardPerPeriod: new (0, _anchor.BN)(0),
|
|
8004
|
+
rewardBalance: new (0, _anchor.BN)(0),
|
|
8005
|
+
totalRewardDistributed
|
|
8006
|
+
};
|
|
8007
|
+
}
|
|
8008
|
+
const rewardPerPeriod = getRewardPerPeriod(
|
|
8009
|
+
poolReward,
|
|
8010
|
+
currentTime,
|
|
8011
|
+
periodTime
|
|
8012
|
+
);
|
|
8013
|
+
const remainTime = poolReward.rewardDurationEnd.sub(currentTime);
|
|
8014
|
+
const rewardBalance = poolReward.rewardRate.mul(remainTime).shrn(64);
|
|
8015
|
+
if (poolState.liquidity.eq(new (0, _anchor.BN)(0))) {
|
|
8016
|
+
return {
|
|
8017
|
+
rewardPerPeriod,
|
|
8018
|
+
rewardBalance,
|
|
8019
|
+
totalRewardDistributed: new (0, _anchor.BN)(0)
|
|
8020
|
+
};
|
|
8021
|
+
}
|
|
8022
|
+
return {
|
|
8023
|
+
rewardPerPeriod: rewardPerPeriod.shrn(64),
|
|
8024
|
+
rewardBalance,
|
|
8025
|
+
totalRewardDistributed
|
|
8026
|
+
};
|
|
8027
|
+
}
|
|
8028
|
+
function getUserRewardPending(poolState, positionState, rewardIndex, currentTime, periodTime) {
|
|
8029
|
+
if (poolState.liquidity.eq(new (0, _anchor.BN)(0))) {
|
|
8030
|
+
return {
|
|
8031
|
+
userRewardPerPeriod: new (0, _anchor.BN)(0),
|
|
8032
|
+
userPendingReward: new (0, _anchor.BN)(0)
|
|
8033
|
+
};
|
|
8034
|
+
}
|
|
8035
|
+
const poolReward = poolState.rewardInfos[rewardIndex];
|
|
8036
|
+
const userRewardInfo = positionState.rewardInfos[rewardIndex];
|
|
8037
|
+
const rewardPerTokenStore = getRewardPerTokenStore(
|
|
8038
|
+
poolReward,
|
|
8039
|
+
poolState.liquidity,
|
|
8040
|
+
currentTime
|
|
8041
|
+
);
|
|
8042
|
+
const totalPositionLiquidity = positionState.unlockedLiquidity.add(positionState.vestedLiquidity).add(positionState.permanentLockedLiquidity);
|
|
8043
|
+
const userRewardPerTokenCheckPoint = new (0, _anchor.BN)(
|
|
8044
|
+
Buffer.from(userRewardInfo.rewardPerTokenCheckpoint).reverse()
|
|
8045
|
+
);
|
|
8046
|
+
const newReward = totalPositionLiquidity.mul(rewardPerTokenStore.sub(userRewardPerTokenCheckPoint)).shrn(192);
|
|
8047
|
+
if (poolReward.rewardDurationEnd <= currentTime) {
|
|
8048
|
+
return {
|
|
8049
|
+
userPendingReward: userRewardInfo.rewardPendings.add(newReward),
|
|
8050
|
+
userRewardPerPeriod: new (0, _anchor.BN)(0)
|
|
8051
|
+
};
|
|
8052
|
+
}
|
|
8053
|
+
const rewardPerPeriod = getRewardPerPeriod(
|
|
8054
|
+
poolReward,
|
|
8055
|
+
currentTime,
|
|
8056
|
+
periodTime
|
|
8057
|
+
);
|
|
8058
|
+
const rewardPerTokenStorePerPeriod = rewardPerPeriod.shln(128).div(poolState.liquidity);
|
|
8059
|
+
const userRewardPerPeriod = totalPositionLiquidity.mul(rewardPerTokenStorePerPeriod).shrn(192);
|
|
8060
|
+
return {
|
|
8061
|
+
userPendingReward: userRewardInfo.rewardPendings.add(newReward),
|
|
8062
|
+
userRewardPerPeriod
|
|
8063
|
+
};
|
|
8064
|
+
}
|
|
7971
8065
|
|
|
7972
8066
|
// src/helpers/accountFilters.ts
|
|
8067
|
+
|
|
7973
8068
|
var positionByPoolFilter = (pool) => {
|
|
7974
8069
|
return {
|
|
7975
8070
|
memcmp: {
|
|
@@ -7986,6 +8081,18 @@ var vestingByPositionFilter = (position) => {
|
|
|
7986
8081
|
}
|
|
7987
8082
|
};
|
|
7988
8083
|
};
|
|
8084
|
+
function offsetBasedFilter(value, offset) {
|
|
8085
|
+
const valueKey = typeof value === "string" ? new (0, _web3js.PublicKey)(value) : value;
|
|
8086
|
+
return [
|
|
8087
|
+
{
|
|
8088
|
+
memcmp: {
|
|
8089
|
+
offset,
|
|
8090
|
+
bytes: valueKey.toBase58(),
|
|
8091
|
+
encoding: "base58"
|
|
8092
|
+
}
|
|
8093
|
+
}
|
|
8094
|
+
];
|
|
8095
|
+
}
|
|
7989
8096
|
|
|
7990
8097
|
// src/helpers/token2022.ts
|
|
7991
8098
|
|
|
@@ -10457,6 +10564,18 @@ var CpAmm = class {
|
|
|
10457
10564
|
return poolState;
|
|
10458
10565
|
});
|
|
10459
10566
|
}
|
|
10567
|
+
/**
|
|
10568
|
+
* Fetches all Pool states by tokenAMint.
|
|
10569
|
+
* @param tokenAMint - Public key of the tokenA mint.
|
|
10570
|
+
* @returns Array of matched pool accounts and their state.
|
|
10571
|
+
*/
|
|
10572
|
+
fetchPoolStatesByTokenAMint(tokenAMint) {
|
|
10573
|
+
return __async(this, null, function* () {
|
|
10574
|
+
const filters = offsetBasedFilter(tokenAMint, 168);
|
|
10575
|
+
const pools = yield this._program.account.pool.all(filters);
|
|
10576
|
+
return pools;
|
|
10577
|
+
});
|
|
10578
|
+
}
|
|
10460
10579
|
/**
|
|
10461
10580
|
* Fetches the Position state.
|
|
10462
10581
|
* @param position - Public key of the position.
|
|
@@ -10564,6 +10683,11 @@ var CpAmm = class {
|
|
|
10564
10683
|
return positionResult;
|
|
10565
10684
|
});
|
|
10566
10685
|
}
|
|
10686
|
+
/**
|
|
10687
|
+
* Retrieves all vesting accounts associated with a position.
|
|
10688
|
+
* @param position - Public key of the position.
|
|
10689
|
+
* @returns Array of vesting account public keys and their states.
|
|
10690
|
+
*/
|
|
10567
10691
|
getAllVestingsByPosition(position) {
|
|
10568
10692
|
return __async(this, null, function* () {
|
|
10569
10693
|
const vestings = yield this._program.account.vesting.all([
|
|
@@ -10572,12 +10696,22 @@ var CpAmm = class {
|
|
|
10572
10696
|
return vestings;
|
|
10573
10697
|
});
|
|
10574
10698
|
}
|
|
10699
|
+
/**
|
|
10700
|
+
* Checks if a position has any locked liquidity.
|
|
10701
|
+
* @param position - Position state.
|
|
10702
|
+
* @returns True if the position has locked liquidity, false otherwise.
|
|
10703
|
+
*/
|
|
10575
10704
|
isLockedPosition(position) {
|
|
10576
10705
|
const totalLockedLiquidity = position.vestedLiquidity.add(
|
|
10577
10706
|
position.permanentLockedLiquidity
|
|
10578
10707
|
);
|
|
10579
10708
|
return totalLockedLiquidity.gtn(0);
|
|
10580
10709
|
}
|
|
10710
|
+
/**
|
|
10711
|
+
* Checks if a position is permanently locked.
|
|
10712
|
+
* @param positionState - Position state.
|
|
10713
|
+
* @returns True if the position is permanently locked, false otherwise.
|
|
10714
|
+
*/
|
|
10581
10715
|
isPermanentLockedPosition(positionState) {
|
|
10582
10716
|
return positionState.permanentLockedLiquidity.gtn(0);
|
|
10583
10717
|
}
|
|
@@ -10616,6 +10750,11 @@ var CpAmm = class {
|
|
|
10616
10750
|
}
|
|
10617
10751
|
return { canUnlock: true };
|
|
10618
10752
|
}
|
|
10753
|
+
/**
|
|
10754
|
+
* Checks if a pool exists.
|
|
10755
|
+
* @param pool - Public key of the pool.
|
|
10756
|
+
* @returns True if the pool exists, false otherwise.
|
|
10757
|
+
*/
|
|
10619
10758
|
isPoolExist(pool) {
|
|
10620
10759
|
return __async(this, null, function* () {
|
|
10621
10760
|
const poolState = yield this._program.account.pool.fetchNullable(pool);
|
|
@@ -10691,6 +10830,11 @@ var CpAmm = class {
|
|
|
10691
10830
|
priceImpact: swapResult.priceImpact
|
|
10692
10831
|
};
|
|
10693
10832
|
}
|
|
10833
|
+
/**
|
|
10834
|
+
* Calculates the expected output amount or input amount for a swap depending on the swap mode.
|
|
10835
|
+
* @param params GetQuote2Params
|
|
10836
|
+
* @returns Quote2Result
|
|
10837
|
+
*/
|
|
10694
10838
|
getQuote2(params) {
|
|
10695
10839
|
const {
|
|
10696
10840
|
inputTokenMint,
|
|
@@ -11130,6 +11274,11 @@ var CpAmm = class {
|
|
|
11130
11274
|
return { tx: transaction, pool, position };
|
|
11131
11275
|
});
|
|
11132
11276
|
}
|
|
11277
|
+
/**
|
|
11278
|
+
* Builds a transaction to create a customizable pool with dynamic config.
|
|
11279
|
+
* @param params InitializeCustomizeablePoolWithDynamicConfigParams
|
|
11280
|
+
* @returns Transaction and related addresses.
|
|
11281
|
+
*/
|
|
11133
11282
|
createCustomPoolWithDynamicConfig(params) {
|
|
11134
11283
|
return __async(this, null, function* () {
|
|
11135
11284
|
const {
|
|
@@ -11491,6 +11640,82 @@ var CpAmm = class {
|
|
|
11491
11640
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
11492
11641
|
});
|
|
11493
11642
|
}
|
|
11643
|
+
/**
|
|
11644
|
+
* Builds a transaction to remove liquidity from a position.
|
|
11645
|
+
* @param {RemoveLiquidityParams} params - Parameters for removing liquidity.
|
|
11646
|
+
* @returns Transaction builder.
|
|
11647
|
+
*/
|
|
11648
|
+
removeLiquidity2(params) {
|
|
11649
|
+
return __async(this, null, function* () {
|
|
11650
|
+
const {
|
|
11651
|
+
owner,
|
|
11652
|
+
receiver,
|
|
11653
|
+
feePayer,
|
|
11654
|
+
pool,
|
|
11655
|
+
position,
|
|
11656
|
+
positionNftAccount,
|
|
11657
|
+
liquidityDelta,
|
|
11658
|
+
tokenAAmountThreshold,
|
|
11659
|
+
tokenBAmountThreshold,
|
|
11660
|
+
tokenAMint,
|
|
11661
|
+
tokenBMint,
|
|
11662
|
+
tokenAVault,
|
|
11663
|
+
tokenBVault,
|
|
11664
|
+
tokenAProgram,
|
|
11665
|
+
tokenBProgram,
|
|
11666
|
+
vestings
|
|
11667
|
+
} = params;
|
|
11668
|
+
const {
|
|
11669
|
+
tokenAAta: tokenAAccount,
|
|
11670
|
+
tokenBAta: tokenBAccount,
|
|
11671
|
+
instructions: preInstructions
|
|
11672
|
+
} = yield this.prepareTokenAccounts({
|
|
11673
|
+
payer: feePayer,
|
|
11674
|
+
tokenAOwner: receiver,
|
|
11675
|
+
tokenBOwner: receiver,
|
|
11676
|
+
tokenAMint,
|
|
11677
|
+
tokenBMint,
|
|
11678
|
+
tokenAProgram,
|
|
11679
|
+
tokenBProgram
|
|
11680
|
+
});
|
|
11681
|
+
const postInstructions = [];
|
|
11682
|
+
if ([tokenAMint.toBase58(), tokenBMint.toBase58()].includes(
|
|
11683
|
+
_spltoken.NATIVE_MINT.toBase58()
|
|
11684
|
+
)) {
|
|
11685
|
+
const closeWrappedSOLIx = yield unwrapSOLInstruction(owner);
|
|
11686
|
+
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
11687
|
+
}
|
|
11688
|
+
if (vestings.length > 0) {
|
|
11689
|
+
const refreshVestingInstruction = yield this.buildRefreshVestingInstruction({
|
|
11690
|
+
owner,
|
|
11691
|
+
position,
|
|
11692
|
+
positionNftAccount,
|
|
11693
|
+
pool,
|
|
11694
|
+
vestingAccounts: vestings.map((item) => item.account)
|
|
11695
|
+
});
|
|
11696
|
+
refreshVestingInstruction && preInstructions.push(refreshVestingInstruction);
|
|
11697
|
+
}
|
|
11698
|
+
return yield this._program.methods.removeLiquidity({
|
|
11699
|
+
liquidityDelta,
|
|
11700
|
+
tokenAAmountThreshold,
|
|
11701
|
+
tokenBAmountThreshold
|
|
11702
|
+
}).accountsPartial({
|
|
11703
|
+
poolAuthority: this.poolAuthority,
|
|
11704
|
+
pool,
|
|
11705
|
+
position,
|
|
11706
|
+
positionNftAccount,
|
|
11707
|
+
owner,
|
|
11708
|
+
tokenAAccount,
|
|
11709
|
+
tokenBAccount,
|
|
11710
|
+
tokenAMint,
|
|
11711
|
+
tokenBMint,
|
|
11712
|
+
tokenAVault,
|
|
11713
|
+
tokenBVault,
|
|
11714
|
+
tokenAProgram,
|
|
11715
|
+
tokenBProgram
|
|
11716
|
+
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
11717
|
+
});
|
|
11718
|
+
}
|
|
11494
11719
|
/**
|
|
11495
11720
|
* Builds a transaction to remove liquidity from a position.
|
|
11496
11721
|
* @param {RemoveLiquidityParams} params - Parameters for removing liquidity.
|
|
@@ -11667,6 +11892,11 @@ var CpAmm = class {
|
|
|
11667
11892
|
}).remainingAccounts(remainingAccounts).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
11668
11893
|
});
|
|
11669
11894
|
}
|
|
11895
|
+
/**
|
|
11896
|
+
* Builds a transaction to perform a swap in the pool.
|
|
11897
|
+
* @param params Swap2Params
|
|
11898
|
+
* @returns Transaction builder.
|
|
11899
|
+
*/
|
|
11670
11900
|
swap2(params) {
|
|
11671
11901
|
return __async(this, null, function* () {
|
|
11672
11902
|
const {
|
|
@@ -11835,6 +12065,11 @@ var CpAmm = class {
|
|
|
11835
12065
|
return new (0, _web3js.Transaction)().add(instruction);
|
|
11836
12066
|
});
|
|
11837
12067
|
}
|
|
12068
|
+
/**
|
|
12069
|
+
* Builds a transaction to close a position.
|
|
12070
|
+
* @param params ClosePositionParams
|
|
12071
|
+
* @returns Transaction builder.
|
|
12072
|
+
*/
|
|
11838
12073
|
closePosition(params) {
|
|
11839
12074
|
return __async(this, null, function* () {
|
|
11840
12075
|
const { owner, pool, position, positionNftMint, positionNftAccount } = params;
|
|
@@ -12077,6 +12312,77 @@ var CpAmm = class {
|
|
|
12077
12312
|
return transaction;
|
|
12078
12313
|
});
|
|
12079
12314
|
}
|
|
12315
|
+
/**
|
|
12316
|
+
* Builds a transaction to initialize a reward for a pool.
|
|
12317
|
+
* @param params InitializeRewardParams
|
|
12318
|
+
* @returns Transaction builder.
|
|
12319
|
+
*/
|
|
12320
|
+
initializeReward(params) {
|
|
12321
|
+
return __async(this, null, function* () {
|
|
12322
|
+
const {
|
|
12323
|
+
rewardIndex,
|
|
12324
|
+
rewardDuration,
|
|
12325
|
+
funder,
|
|
12326
|
+
pool,
|
|
12327
|
+
creator,
|
|
12328
|
+
payer,
|
|
12329
|
+
rewardMint,
|
|
12330
|
+
rewardMintProgram
|
|
12331
|
+
} = params;
|
|
12332
|
+
const rewardVault = deriveRewardVaultAddress(pool, rewardIndex);
|
|
12333
|
+
return yield this._program.methods.initializeReward(rewardIndex, rewardDuration, funder).accountsPartial({
|
|
12334
|
+
poolAuthority: this.poolAuthority,
|
|
12335
|
+
pool,
|
|
12336
|
+
rewardVault,
|
|
12337
|
+
rewardMint,
|
|
12338
|
+
signer: creator,
|
|
12339
|
+
payer,
|
|
12340
|
+
tokenProgram: rewardMintProgram
|
|
12341
|
+
}).transaction();
|
|
12342
|
+
});
|
|
12343
|
+
}
|
|
12344
|
+
/**
|
|
12345
|
+
* Builds a transaction to initialize and fund a reward for a pool.
|
|
12346
|
+
* @param params InitializeAndFundReward
|
|
12347
|
+
* @returns Transaction builder.
|
|
12348
|
+
*/
|
|
12349
|
+
initializeAndFundReward(params) {
|
|
12350
|
+
return __async(this, null, function* () {
|
|
12351
|
+
const {
|
|
12352
|
+
rewardIndex,
|
|
12353
|
+
rewardDuration,
|
|
12354
|
+
pool,
|
|
12355
|
+
creator,
|
|
12356
|
+
payer,
|
|
12357
|
+
rewardMint,
|
|
12358
|
+
carryForward,
|
|
12359
|
+
amount,
|
|
12360
|
+
rewardMintProgram
|
|
12361
|
+
} = params;
|
|
12362
|
+
const rewardVault = deriveRewardVaultAddress(pool, rewardIndex);
|
|
12363
|
+
const initializeRewardTx = yield this.initializeReward({
|
|
12364
|
+
rewardIndex,
|
|
12365
|
+
rewardDuration,
|
|
12366
|
+
funder: payer,
|
|
12367
|
+
pool,
|
|
12368
|
+
creator,
|
|
12369
|
+
payer,
|
|
12370
|
+
rewardMint,
|
|
12371
|
+
rewardMintProgram
|
|
12372
|
+
});
|
|
12373
|
+
const fundRewardTx = yield this.fundReward({
|
|
12374
|
+
rewardIndex,
|
|
12375
|
+
carryForward,
|
|
12376
|
+
pool,
|
|
12377
|
+
funder: payer,
|
|
12378
|
+
amount,
|
|
12379
|
+
rewardMint,
|
|
12380
|
+
rewardVault,
|
|
12381
|
+
rewardMintProgram
|
|
12382
|
+
});
|
|
12383
|
+
return new (0, _web3js.Transaction)().add(initializeRewardTx).add(fundRewardTx);
|
|
12384
|
+
});
|
|
12385
|
+
}
|
|
12080
12386
|
/**
|
|
12081
12387
|
* Builds a transaction to update reward duration.
|
|
12082
12388
|
* @param {UpdateRewardDurationParams} params - Parameters including pool and new duration.
|
|
@@ -12084,10 +12390,10 @@ var CpAmm = class {
|
|
|
12084
12390
|
*/
|
|
12085
12391
|
updateRewardDuration(params) {
|
|
12086
12392
|
return __async(this, null, function* () {
|
|
12087
|
-
const { pool,
|
|
12393
|
+
const { pool, signer, rewardIndex, newDuration } = params;
|
|
12088
12394
|
return yield this._program.methods.updateRewardDuration(rewardIndex, newDuration).accountsPartial({
|
|
12089
12395
|
pool,
|
|
12090
|
-
signer
|
|
12396
|
+
signer
|
|
12091
12397
|
}).transaction();
|
|
12092
12398
|
});
|
|
12093
12399
|
}
|
|
@@ -12098,10 +12404,10 @@ var CpAmm = class {
|
|
|
12098
12404
|
*/
|
|
12099
12405
|
updateRewardFunder(params) {
|
|
12100
12406
|
return __async(this, null, function* () {
|
|
12101
|
-
const { pool,
|
|
12407
|
+
const { pool, signer, rewardIndex, newFunder } = params;
|
|
12102
12408
|
return yield this._program.methods.updateRewardFunder(rewardIndex, newFunder).accountsPartial({
|
|
12103
12409
|
pool,
|
|
12104
|
-
signer
|
|
12410
|
+
signer
|
|
12105
12411
|
}).transaction();
|
|
12106
12412
|
});
|
|
12107
12413
|
}
|
|
@@ -12378,9 +12684,9 @@ var CpAmm = class {
|
|
|
12378
12684
|
position,
|
|
12379
12685
|
positionNftAccount,
|
|
12380
12686
|
rewardIndex,
|
|
12381
|
-
skipReward,
|
|
12382
12687
|
poolState,
|
|
12383
|
-
positionState
|
|
12688
|
+
positionState,
|
|
12689
|
+
isSkipReward
|
|
12384
12690
|
} = params;
|
|
12385
12691
|
const rewardInfo = poolState.rewardInfos[rewardIndex];
|
|
12386
12692
|
const tokenProgram = getTokenProgram(rewardInfo.rewardTokenFlag);
|
|
@@ -12399,6 +12705,7 @@ var CpAmm = class {
|
|
|
12399
12705
|
const closeWrappedSOLIx = yield unwrapSOLInstruction(user);
|
|
12400
12706
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
12401
12707
|
}
|
|
12708
|
+
const skipReward = isSkipReward ? 1 : 0;
|
|
12402
12709
|
return yield this._program.methods.claimReward(rewardIndex, skipReward).accountsPartial({
|
|
12403
12710
|
pool: positionState.pool,
|
|
12404
12711
|
positionNftAccount,
|
|
@@ -12412,6 +12719,11 @@ var CpAmm = class {
|
|
|
12412
12719
|
}).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
|
|
12413
12720
|
});
|
|
12414
12721
|
}
|
|
12722
|
+
/**
|
|
12723
|
+
* Builds a transaction to split a position into two positions.
|
|
12724
|
+
* @param params SplitPositionParams
|
|
12725
|
+
* @returns Transaction builder.
|
|
12726
|
+
*/
|
|
12415
12727
|
splitPosition(params) {
|
|
12416
12728
|
return __async(this, null, function* () {
|
|
12417
12729
|
const {
|
|
@@ -12448,6 +12760,11 @@ var CpAmm = class {
|
|
|
12448
12760
|
}).transaction();
|
|
12449
12761
|
});
|
|
12450
12762
|
}
|
|
12763
|
+
/**
|
|
12764
|
+
* Builds a transaction to split a position into two positions.
|
|
12765
|
+
* @param params SplitPosition2Params
|
|
12766
|
+
* @returns Transaction builder.
|
|
12767
|
+
*/
|
|
12451
12768
|
splitPosition2(params) {
|
|
12452
12769
|
return __async(this, null, function* () {
|
|
12453
12770
|
const {
|
|
@@ -12630,5 +12947,8 @@ var CpAmm = class {
|
|
|
12630
12947
|
|
|
12631
12948
|
|
|
12632
12949
|
|
|
12633
|
-
|
|
12950
|
+
|
|
12951
|
+
|
|
12952
|
+
|
|
12953
|
+
exports.ActivationPoint = ActivationPoint; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_STEP_BPS_DEFAULT = BIN_STEP_BPS_DEFAULT; exports.BIN_STEP_BPS_U128_DEFAULT = BIN_STEP_BPS_U128_DEFAULT; exports.BaseFeeMode = BaseFeeMode; exports.CP_AMM_PROGRAM_ID = CP_AMM_PROGRAM_ID; exports.CURRENT_POOL_VERSION = CURRENT_POOL_VERSION; exports.CollectFeeMode = CollectFeeMode; exports.CpAmm = CpAmm; exports.CpAmmIdl = cp_amm_default; exports.DYNAMIC_FEE_DECAY_PERIOD_DEFAULT = DYNAMIC_FEE_DECAY_PERIOD_DEFAULT; exports.DYNAMIC_FEE_FILTER_PERIOD_DEFAULT = DYNAMIC_FEE_FILTER_PERIOD_DEFAULT; exports.DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT = DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT; exports.DYNAMIC_FEE_ROUNDING_OFFSET = DYNAMIC_FEE_ROUNDING_OFFSET; exports.DYNAMIC_FEE_SCALING_FACTOR = DYNAMIC_FEE_SCALING_FACTOR; exports.FEE_DENOMINATOR = FEE_DENOMINATOR; exports.FeeRateLimiter = FeeRateLimiter; exports.FeeScheduler = FeeScheduler; exports.LIQUIDITY_SCALE = LIQUIDITY_SCALE; exports.MAX = MAX; exports.MAX_CU_BUFFER = MAX_CU_BUFFER; exports.MAX_EXPONENTIAL = MAX_EXPONENTIAL; exports.MAX_FEE_BPS_V0 = MAX_FEE_BPS_V0; exports.MAX_FEE_BPS_V1 = MAX_FEE_BPS_V1; exports.MAX_FEE_NUMERATOR_V0 = MAX_FEE_NUMERATOR_V0; exports.MAX_FEE_NUMERATOR_V1 = MAX_FEE_NUMERATOR_V1; exports.MAX_PRICE_CHANGE_BPS_DEFAULT = MAX_PRICE_CHANGE_BPS_DEFAULT; exports.MAX_RATE_LIMITER_DURATION_IN_SECONDS = MAX_RATE_LIMITER_DURATION_IN_SECONDS; exports.MAX_RATE_LIMITER_DURATION_IN_SLOTS = MAX_RATE_LIMITER_DURATION_IN_SLOTS; exports.MAX_SQRT_PRICE = MAX_SQRT_PRICE; exports.MIN_CU_BUFFER = MIN_CU_BUFFER; exports.MIN_FEE_BPS = MIN_FEE_BPS; exports.MIN_FEE_NUMERATOR = MIN_FEE_NUMERATOR; exports.MIN_SQRT_PRICE = MIN_SQRT_PRICE; exports.ONE_Q64 = ONE_Q64; exports.PoolStatus = PoolStatus; exports.PoolVersion = PoolVersion; exports.Rounding = Rounding; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SPLIT_POSITION_DENOMINATOR = SPLIT_POSITION_DENOMINATOR; exports.SwapMode = SwapMode; exports.TradeDirection = TradeDirection; exports.U128_MAX = U128_MAX; exports.U16_MAX = U16_MAX; exports.U64_MAX = U64_MAX; exports.bpsToFeeNumerator = bpsToFeeNumerator; exports.calculateAtoBFromAmountIn = calculateAtoBFromAmountIn; exports.calculateAtoBFromAmountOut = calculateAtoBFromAmountOut; exports.calculateAtoBFromPartialAmountIn = calculateAtoBFromPartialAmountIn; exports.calculateBtoAFromAmountIn = calculateBtoAFromAmountIn; exports.calculateBtoAFromAmountOut = calculateBtoAFromAmountOut; exports.calculateBtoAFromPartialAmountIn = calculateBtoAFromPartialAmountIn; exports.calculateInitSqrtPrice = calculateInitSqrtPrice; exports.calculateTransferFeeExcludedAmount = calculateTransferFeeExcludedAmount; exports.calculateTransferFeeIncludedAmount = calculateTransferFeeIncludedAmount; exports.convertToFeeSchedulerSecondFactor = convertToFeeSchedulerSecondFactor; exports.convertToLamports = convertToLamports; exports.convertToRateLimiterSecondFactor = convertToRateLimiterSecondFactor; exports.decimalToQ64 = decimalToQ64; exports.deriveClaimFeeOperatorAddress = deriveClaimFeeOperatorAddress; exports.deriveConfigAddress = deriveConfigAddress; exports.deriveCustomizablePoolAddress = deriveCustomizablePoolAddress; exports.derivePoolAddress = derivePoolAddress; exports.derivePoolAuthority = derivePoolAuthority; exports.derivePositionAddress = derivePositionAddress; exports.derivePositionNftAccount = derivePositionNftAccount; exports.deriveRewardVaultAddress = deriveRewardVaultAddress; exports.deriveTokenBadgeAddress = deriveTokenBadgeAddress; exports.deriveTokenVaultAddress = deriveTokenVaultAddress; exports.feeNumeratorToBps = feeNumeratorToBps; exports.fromDecimalToBN = fromDecimalToBN; exports.getAllPositionNftAccountByOwner = getAllPositionNftAccountByOwner; exports.getAllUserPositionNftAccount = getAllUserPositionNftAccount; exports.getAmountAFromLiquidityDelta = getAmountAFromLiquidityDelta; exports.getAmountBFromLiquidityDelta = getAmountBFromLiquidityDelta; exports.getAmountWithSlippage = getAmountWithSlippage; exports.getAvailableVestingLiquidity = getAvailableVestingLiquidity; exports.getBaseFeeHandler = getBaseFeeHandler; exports.getBaseFeeNumerator = getBaseFeeNumerator; exports.getBaseFeeNumeratorByPeriod = getBaseFeeNumeratorByPeriod; exports.getBaseFeeParams = getBaseFeeParams; exports.getCheckedAmounts = getCheckedAmounts; exports.getCurrentPoint = getCurrentPoint; exports.getDynamicFeeNumerator = getDynamicFeeNumerator; exports.getDynamicFeeParams = getDynamicFeeParams; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getExcludedFeeAmount = getExcludedFeeAmount; exports.getExcludedFeeAmountFromIncludedFeeAmount = getExcludedFeeAmountFromIncludedFeeAmount; exports.getFeeInPeriod = getFeeInPeriod; exports.getFeeMode = getFeeMode; exports.getFeeNumeratorFromExcludedFeeAmount = getFeeNumeratorFromExcludedFeeAmount; exports.getFeeNumeratorFromIncludedFeeAmount = getFeeNumeratorFromIncludedFeeAmount; exports.getFeeNumeratorOnExponentialFeeScheduler = getFeeNumeratorOnExponentialFeeScheduler; exports.getFeeNumeratorOnLinearFeeScheduler = getFeeNumeratorOnLinearFeeScheduler; exports.getFeeOnAmount = getFeeOnAmount; exports.getFeeSchedulerParams = getFeeSchedulerParams; exports.getFirstKey = getFirstKey; exports.getIncludedFeeAmount = getIncludedFeeAmount; exports.getLiquidityDeltaFromAmountA = getLiquidityDeltaFromAmountA; exports.getLiquidityDeltaFromAmountB = getLiquidityDeltaFromAmountB; exports.getMaxAmountWithSlippage = getMaxAmountWithSlippage; exports.getMaxBaseFeeNumerator = getMaxBaseFeeNumerator; exports.getMaxFeeBps = getMaxFeeBps; exports.getMaxFeeNumerator = getMaxFeeNumerator; exports.getMaxIndex = getMaxIndex; exports.getMinBaseFeeNumerator = getMinBaseFeeNumerator; exports.getNextSqrtPriceFromAmountInARoundingUp = getNextSqrtPriceFromAmountInARoundingUp; exports.getNextSqrtPriceFromAmountInBRoundingDown = getNextSqrtPriceFromAmountInBRoundingDown; exports.getNextSqrtPriceFromAmountOutARoundingUp = getNextSqrtPriceFromAmountOutARoundingUp; exports.getNextSqrtPriceFromAmountOutBRoundingDown = getNextSqrtPriceFromAmountOutBRoundingDown; exports.getNextSqrtPriceFromInput = getNextSqrtPriceFromInput; exports.getNextSqrtPriceFromOutput = getNextSqrtPriceFromOutput; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getPriceChange = getPriceChange; exports.getPriceFromSqrtPrice = getPriceFromSqrtPrice; exports.getPriceImpact = getPriceImpact; exports.getRateLimiterParams = getRateLimiterParams; exports.getRewardInfo = getRewardInfo; exports.getSecondKey = getSecondKey; exports.getSimulationComputeUnits = getSimulationComputeUnits; exports.getSqrtPriceFromPrice = getSqrtPriceFromPrice; exports.getSwapResultFromExactInput = getSwapResultFromExactInput; exports.getSwapResultFromExactOutput = getSwapResultFromExactOutput; exports.getSwapResultFromPartialInput = getSwapResultFromPartialInput; exports.getTokenDecimals = getTokenDecimals; exports.getTokenProgram = getTokenProgram; exports.getTotalFeeNumerator = getTotalFeeNumerator; exports.getTotalLockedLiquidity = getTotalLockedLiquidity; exports.getTotalTradingFeeFromExcludedFeeAmount = getTotalTradingFeeFromExcludedFeeAmount; exports.getTotalTradingFeeFromIncludedFeeAmount = getTotalTradingFeeFromIncludedFeeAmount; exports.getUnClaimLpFee = getUnClaimLpFee; exports.getUserRewardPending = getUserRewardPending; exports.hasPartner = hasPartner; exports.isDynamicFeeEnabled = isDynamicFeeEnabled; exports.isNonZeroRateLimiter = isNonZeroRateLimiter; exports.isRateLimiterApplied = isRateLimiterApplied; exports.isSwapEnabled = isSwapEnabled; exports.isVestingComplete = isVestingComplete; exports.isZeroRateLimiter = isZeroRateLimiter; exports.mulDiv = mulDiv; exports.offsetBasedFilter = offsetBasedFilter; exports.parseFeeSchedulerSecondFactor = parseFeeSchedulerSecondFactor; exports.parseRateLimiterSecondFactor = parseRateLimiterSecondFactor; exports.positionByPoolFilter = positionByPoolFilter; exports.pow = pow; exports.q64ToDecimal = q64ToDecimal; exports.splitFees = splitFees; exports.sqrt = sqrt; exports.swapQuoteExactInput = swapQuoteExactInput; exports.swapQuoteExactOutput = swapQuoteExactOutput; exports.swapQuotePartialInput = swapQuotePartialInput; exports.toNumerator = toNumerator; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.validateFeeFraction = validateFeeFraction; exports.validateFeeRateLimiter = validateFeeRateLimiter; exports.validateFeeScheduler = validateFeeScheduler; exports.vestingByPositionFilter = vestingByPositionFilter; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
12634
12954
|
//# sourceMappingURL=index.js.map
|