Skip to content

Commit

Permalink
fix: add in unwrap sol in post instructions for withdraw single side (M…
Browse files Browse the repository at this point in the history
  • Loading branch information
dongnguyen9186 authored Aug 29, 2024
1 parent fde6bfc commit e4fd899
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security

## @meteora-ag/dlmm [1.1.4] - PR #106

### Fixed

- `removeLiquiditySingleSide`. Add in unwrap sol in post instructions

## @meteora-ag/dlmm [1.1.2] - PR #104

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion ts-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meteora-ag/dlmm",
"version": "1.1.3",
"version": "1.1.4",
"description": "",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
13 changes: 7 additions & 6 deletions ts-client/src/dlmm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3023,12 +3023,12 @@ export class DLMM {
createPayerTokenIx && preInstructions.push(createPayerTokenIx);

const postInstructions: Array<TransactionInstruction> = [];
if (
[
this.tokenX.publicKey.toBase58(),
this.tokenY.publicKey.toBase58(),
].includes(NATIVE_MINT.toBase58())
) {

const shouldUnwrapSOL =
(removeLiquidityForY && this.tokenY.publicKey.equals(NATIVE_MINT)) ||
(!removeLiquidityForY && this.tokenX.publicKey.equals(NATIVE_MINT));

if (shouldUnwrapSOL) {
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
}
Expand Down Expand Up @@ -3065,6 +3065,7 @@ export class DLMM {
tokenProgram: TOKEN_PROGRAM_ID,
})
.preInstructions(preInstructions)
.postInstructions(postInstructions)
.transaction();

const { blockhash, lastValidBlockHeight } =
Expand Down

0 comments on commit e4fd899

Please sign in to comment.