Skip to content

Commit

Permalink
fix: ts test
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithgun committed Dec 31, 2024
1 parent 3b98580 commit 599873c
Show file tree
Hide file tree
Showing 4 changed files with 1,804 additions and 2,426 deletions.
Binary file modified artifacts/lb_clmm.so
Binary file not shown.
2 changes: 1 addition & 1 deletion ts-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"build": "tsup",
"start": "npm run build -- --watch",
"test": "jest 'src/test/(ilm|sdk|position_managed_by_operator|decode|single_bin).test.ts'",
"test": "jest 'src/test/sdk.test.ts'",
"unit-test": "jest src/test/calculate_distribution.test.ts",
"example": "dotenv -e .env npx ts-node src/example.ts",
"start-server": "npx tsc && node dist/src/server/index.js"
Expand Down
19 changes: 12 additions & 7 deletions ts-client/src/dlmm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ export class DLMM {
>();

lbPairKeys.forEach((lbPair, idx) => {
const index = idx * 4;
const index = idx * 6;
const reserveXAccount = accountInfos[index];
const reserveYAccount = accountInfos[index + 1];

Expand Down Expand Up @@ -2897,6 +2897,7 @@ export class DLMM {
sender: user,
tokenXProgram: this.tokenX.owner,
tokenYProgram: this.tokenY.owner,
memoProgram: MEMO_PROGRAM_ID,
};

const { slices, accounts: transferHookAccounts } =
Expand Down Expand Up @@ -2939,7 +2940,7 @@ export class DLMM {
}

/**
* @deprecated Use `addLiquidityByStrategy`
* @deprecated Do not support dynamic position. Use `addLiquidityByStrategy`
* The `addLiquidityByWeight` function is used to add liquidity to existing position
* @param {TInitializePositionAndAddLiquidityParams}
* - `positionPubKey`: The public key of the position account. (usually use `new Keypair()`)
Expand Down Expand Up @@ -3218,26 +3219,29 @@ export class DLMM {
* @param
* - `user`: The public key of the user account.
* - `position`: The public key of the position account.
* - `binIds`: An array of numbers that represent the bin IDs to remove liquidity from.
* - `fromBinId`: The ID of the starting bin to remove liquidity from. Must within position range.
* - `toBinId`: The ID of the ending bin to remove liquidity from. Must within position range.
* - `liquiditiesBpsToRemove`: An array of numbers (percentage) that represent the liquidity to remove from each bin.
* - `shouldClaimAndClose`: A boolean flag that indicates whether to claim rewards and close the position.
* @returns {Promise<Transaction|Transaction[]>}
*/
public async removeLiquidity({
user,
position,
binIds,
fromBinId,
toBinId,
bps,
shouldClaimAndClose = false,
}: {
user: PublicKey;
position: PublicKey;
binIds: number[];
fromBinId: number;
toBinId: number;
bps: BN;
shouldClaimAndClose?: boolean;
}): Promise<Transaction | Transaction[]> {
const lowerBinIdToRemove = Math.min(...binIds);
const upperBinIdToRemove = Math.max(...binIds);
const lowerBinIdToRemove = fromBinId;
const upperBinIdToRemove = toBinId;

const positionAccount =
await this.program.provider.connection.getAccountInfo(position);
Expand Down Expand Up @@ -3627,6 +3631,7 @@ export class DLMM {
const resizePositionIx = await this.program.methods
.increasePositionLength(lengthToAdd.toNumber(), side)
.accounts({
lbPair: this.pubkey,
funder: payer,
position,
owner: positionState.owner,
Expand Down
Loading

0 comments on commit 599873c

Please sign in to comment.