@stabbleorg/mclmm-sdk 0.2.2 → 0.3.1
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/lib/index.js +103 -30
- package/lib/index.mjs +110 -32
- package/lib/position-manager.d.ts +10 -1
- package/lib/position-manager.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -7916,6 +7916,7 @@ var NATIVE_MINT_2022 = new import_web3.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5H
|
|
|
7916
7916
|
// src/position-manager.ts
|
|
7917
7917
|
var import_system = require("@solana-program/system");
|
|
7918
7918
|
var import_decimal4 = __toESM(require("decimal.js"));
|
|
7919
|
+
var TOKEN_ACCOUNT_SIZE = 165n;
|
|
7919
7920
|
var PositionManager = class {
|
|
7920
7921
|
constructor(config) {
|
|
7921
7922
|
this.config = config;
|
|
@@ -7940,17 +7941,8 @@ var PositionManager = class {
|
|
|
7940
7941
|
];
|
|
7941
7942
|
}
|
|
7942
7943
|
buildUnwrapSolInstruction(params) {
|
|
7943
|
-
const {
|
|
7944
|
+
const { owner, destination, ata } = params;
|
|
7944
7945
|
return [
|
|
7945
|
-
// There's a chance user might have deleted the ATA - create it with idempotent just to be sure.
|
|
7946
|
-
(0, import_token4.getCreateAssociatedTokenIdempotentInstruction)({
|
|
7947
|
-
payer,
|
|
7948
|
-
ata,
|
|
7949
|
-
owner,
|
|
7950
|
-
mint: (0, import_kit53.address)(NATIVE_MINT.toString()),
|
|
7951
|
-
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS,
|
|
7952
|
-
systemProgram: SYSTEM_PROGRAM_ID
|
|
7953
|
-
}),
|
|
7954
7946
|
(0, import_token4.getCloseAccountInstruction)({
|
|
7955
7947
|
account: ata,
|
|
7956
7948
|
destination,
|
|
@@ -7958,6 +7950,52 @@ var PositionManager = class {
|
|
|
7958
7950
|
})
|
|
7959
7951
|
];
|
|
7960
7952
|
}
|
|
7953
|
+
/**
|
|
7954
|
+
* Build partial unwrap SOL instructions using a temp account:
|
|
7955
|
+
* 1. Create temp account
|
|
7956
|
+
* 2. Initialize as WSOL token account
|
|
7957
|
+
* 3. Transfer specific amount from source ATA to temp
|
|
7958
|
+
* 4. Close temp account (lamports go to destination)
|
|
7959
|
+
*/
|
|
7960
|
+
async buildPartialUnwrapSolInstructions(params) {
|
|
7961
|
+
const { payer, sourceAta, destination, amount } = params;
|
|
7962
|
+
const rentExemptLamports = await this.config.rpc.getMinimumBalanceForRentExemption(TOKEN_ACCOUNT_SIZE).send();
|
|
7963
|
+
const tempAccount = await (0, import_kit53.generateKeyPairSigner)();
|
|
7964
|
+
const createTempAccountIx = (0, import_system.getCreateAccountInstruction)({
|
|
7965
|
+
payer,
|
|
7966
|
+
newAccount: tempAccount,
|
|
7967
|
+
lamports: rentExemptLamports,
|
|
7968
|
+
space: TOKEN_ACCOUNT_SIZE,
|
|
7969
|
+
programAddress: import_token4.TOKEN_PROGRAM_ADDRESS
|
|
7970
|
+
});
|
|
7971
|
+
const initTempAccountIx = (0, import_token4.getInitializeAccount3Instruction)({
|
|
7972
|
+
account: tempAccount.address,
|
|
7973
|
+
mint: (0, import_kit53.address)(NATIVE_MINT.toString()),
|
|
7974
|
+
owner: destination
|
|
7975
|
+
});
|
|
7976
|
+
const transferIx = (0, import_token4.getTransferCheckedInstruction)({
|
|
7977
|
+
source: sourceAta,
|
|
7978
|
+
mint: (0, import_kit53.address)(NATIVE_MINT.toString()),
|
|
7979
|
+
destination: tempAccount.address,
|
|
7980
|
+
authority: payer,
|
|
7981
|
+
amount,
|
|
7982
|
+
decimals: 9
|
|
7983
|
+
});
|
|
7984
|
+
const closeIx = (0, import_token4.getCloseAccountInstruction)({
|
|
7985
|
+
account: tempAccount.address,
|
|
7986
|
+
destination,
|
|
7987
|
+
owner: destination
|
|
7988
|
+
});
|
|
7989
|
+
return {
|
|
7990
|
+
instructions: [
|
|
7991
|
+
createTempAccountIx,
|
|
7992
|
+
initTempAccountIx,
|
|
7993
|
+
transferIx,
|
|
7994
|
+
closeIx
|
|
7995
|
+
],
|
|
7996
|
+
signers: [tempAccount]
|
|
7997
|
+
};
|
|
7998
|
+
}
|
|
7961
7999
|
/**
|
|
7962
8000
|
* Make open position from liquidity instructions
|
|
7963
8001
|
* Use this when you know the exact liquidity amount you want to provide
|
|
@@ -8255,6 +8293,7 @@ var PositionManager = class {
|
|
|
8255
8293
|
/**
|
|
8256
8294
|
* Make decrease liquidity V2 instructions
|
|
8257
8295
|
* @param params - Decrease liquidity parameters
|
|
8296
|
+
* @param params.isNative - Whether to unwrap WSOL to native SOL after decrease
|
|
8258
8297
|
* @returns Instruction result following Raydium pattern
|
|
8259
8298
|
*/
|
|
8260
8299
|
async makeDecreaseLiquidityV2Instructions(params) {
|
|
@@ -8264,8 +8303,10 @@ var PositionManager = class {
|
|
|
8264
8303
|
ownerInfo,
|
|
8265
8304
|
liquidity,
|
|
8266
8305
|
amountMinA,
|
|
8267
|
-
amountMinB
|
|
8306
|
+
amountMinB,
|
|
8307
|
+
isNative = false
|
|
8268
8308
|
} = params;
|
|
8309
|
+
const signers = [];
|
|
8269
8310
|
const [personalPosition] = await PdaUtils.getPositionStatePda(
|
|
8270
8311
|
ownerPosition.nftMint
|
|
8271
8312
|
);
|
|
@@ -8299,6 +8340,24 @@ var PositionManager = class {
|
|
|
8299
8340
|
);
|
|
8300
8341
|
const extBitmapAccount = isOverflow ? await PdaUtils.getTickArrayBitmapExtensionPda(poolState.address) : void 0;
|
|
8301
8342
|
const remAccounts = extBitmapAccount ? [{ address: extBitmapAccount[0], role: import_kit53.AccountRole.WRITABLE }] : [];
|
|
8343
|
+
const createRecipientAta0Ix = (0, import_token4.getCreateAssociatedTokenIdempotentInstruction)(
|
|
8344
|
+
{
|
|
8345
|
+
payer: ownerInfo.wallet,
|
|
8346
|
+
ata: ownerInfo.tokenAccountA,
|
|
8347
|
+
owner: ownerInfo.wallet.address,
|
|
8348
|
+
mint: poolState.data.tokenMint0,
|
|
8349
|
+
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS
|
|
8350
|
+
}
|
|
8351
|
+
);
|
|
8352
|
+
const createRecipientAta1Ix = (0, import_token4.getCreateAssociatedTokenIdempotentInstruction)(
|
|
8353
|
+
{
|
|
8354
|
+
payer: ownerInfo.wallet,
|
|
8355
|
+
ata: ownerInfo.tokenAccountB,
|
|
8356
|
+
owner: ownerInfo.wallet.address,
|
|
8357
|
+
mint: poolState.data.tokenMint1,
|
|
8358
|
+
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS
|
|
8359
|
+
}
|
|
8360
|
+
);
|
|
8302
8361
|
const instruction = getDecreaseLiquidityV2Instruction({
|
|
8303
8362
|
nftOwner: ownerInfo.wallet,
|
|
8304
8363
|
nftAccount: positionNftAccount,
|
|
@@ -8321,9 +8380,38 @@ var PositionManager = class {
|
|
|
8321
8380
|
...instruction,
|
|
8322
8381
|
accounts: [...instruction.accounts, ...remAccounts]
|
|
8323
8382
|
};
|
|
8383
|
+
const instructions = [
|
|
8384
|
+
createRecipientAta0Ix,
|
|
8385
|
+
createRecipientAta1Ix,
|
|
8386
|
+
ixWithRemAccounts
|
|
8387
|
+
];
|
|
8388
|
+
if (isNative) {
|
|
8389
|
+
const destination = ownerInfo.wallet.address;
|
|
8390
|
+
const isFullWithdrawal = liquidity === ownerPosition.liquidity;
|
|
8391
|
+
const isTokenANative = poolState.data.tokenMint0.toString() === NATIVE_MINT.toString();
|
|
8392
|
+
const wsolAta = isTokenANative ? ownerInfo.tokenAccountA : ownerInfo.tokenAccountB;
|
|
8393
|
+
const amount = isTokenANative ? amountMinA : amountMinB;
|
|
8394
|
+
if (isFullWithdrawal) {
|
|
8395
|
+
const unwrapIxs = this.buildUnwrapSolInstruction({
|
|
8396
|
+
ata: wsolAta,
|
|
8397
|
+
owner: ownerInfo.wallet.address,
|
|
8398
|
+
destination
|
|
8399
|
+
});
|
|
8400
|
+
instructions.push(...unwrapIxs);
|
|
8401
|
+
} else {
|
|
8402
|
+
const { instructions: partialUnwrapIxs, signers: partialSigners } = await this.buildPartialUnwrapSolInstructions({
|
|
8403
|
+
payer: ownerInfo.wallet,
|
|
8404
|
+
sourceAta: wsolAta,
|
|
8405
|
+
destination,
|
|
8406
|
+
amount
|
|
8407
|
+
});
|
|
8408
|
+
instructions.push(...partialUnwrapIxs);
|
|
8409
|
+
signers.push(...partialSigners);
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8324
8412
|
return {
|
|
8325
|
-
instructions
|
|
8326
|
-
signers
|
|
8413
|
+
instructions,
|
|
8414
|
+
signers,
|
|
8327
8415
|
instructionTypes: ["DecreaseLiquidityV2"],
|
|
8328
8416
|
address: {
|
|
8329
8417
|
tickArrayLower,
|
|
@@ -8341,7 +8429,7 @@ var PositionManager = class {
|
|
|
8341
8429
|
* @returns Instruction result following established pattern
|
|
8342
8430
|
*/
|
|
8343
8431
|
async makeClosePositionInstructions(params) {
|
|
8344
|
-
const { ownerPosition, ownerInfo
|
|
8432
|
+
const { ownerPosition, ownerInfo } = params;
|
|
8345
8433
|
const [personalPosition] = await PdaUtils.getPositionStatePda(
|
|
8346
8434
|
ownerPosition.nftMint
|
|
8347
8435
|
);
|
|
@@ -8357,23 +8445,8 @@ var PositionManager = class {
|
|
|
8357
8445
|
personalPosition,
|
|
8358
8446
|
tokenProgram: import_token_20222.TOKEN_2022_PROGRAM_ADDRESS
|
|
8359
8447
|
});
|
|
8360
|
-
let unrwrapWsolInstructions = [];
|
|
8361
|
-
if (isNative) {
|
|
8362
|
-
const ownerWallet = ownerInfo.wallet;
|
|
8363
|
-
const [ata] = await (0, import_token4.findAssociatedTokenPda)({
|
|
8364
|
-
mint: (0, import_kit53.address)(NATIVE_MINT.toString()),
|
|
8365
|
-
owner: ownerWallet.address,
|
|
8366
|
-
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS
|
|
8367
|
-
});
|
|
8368
|
-
unrwrapWsolInstructions = this.buildUnwrapSolInstruction({
|
|
8369
|
-
payer: ownerWallet,
|
|
8370
|
-
ata,
|
|
8371
|
-
owner: ownerWallet.address,
|
|
8372
|
-
destination: ownerWallet.address
|
|
8373
|
-
});
|
|
8374
|
-
}
|
|
8375
8448
|
return {
|
|
8376
|
-
instructions: [instruction
|
|
8449
|
+
instructions: [instruction],
|
|
8377
8450
|
signers: [],
|
|
8378
8451
|
instructionTypes: ["ClosePosition"],
|
|
8379
8452
|
address: { positionNftAccount, personalPosition },
|
package/lib/index.mjs
CHANGED
|
@@ -8474,7 +8474,9 @@ import {
|
|
|
8474
8474
|
findAssociatedTokenPda,
|
|
8475
8475
|
TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS3,
|
|
8476
8476
|
getCreateAssociatedTokenIdempotentInstruction,
|
|
8477
|
-
getCloseAccountInstruction
|
|
8477
|
+
getCloseAccountInstruction,
|
|
8478
|
+
getInitializeAccount3Instruction,
|
|
8479
|
+
getTransferCheckedInstruction
|
|
8478
8480
|
} from "@solana-program/token";
|
|
8479
8481
|
import { TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS2 } from "@solana-program/token-2022";
|
|
8480
8482
|
import BN6 from "bn.js";
|
|
@@ -8488,8 +8490,12 @@ var NATIVE_MINT = new PublicKey("So11111111111111111111111111111111111111112");
|
|
|
8488
8490
|
var NATIVE_MINT_2022 = new PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");
|
|
8489
8491
|
|
|
8490
8492
|
// src/position-manager.ts
|
|
8491
|
-
import {
|
|
8493
|
+
import {
|
|
8494
|
+
getTransferSolInstruction,
|
|
8495
|
+
getCreateAccountInstruction
|
|
8496
|
+
} from "@solana-program/system";
|
|
8492
8497
|
import Decimal4 from "decimal.js";
|
|
8498
|
+
var TOKEN_ACCOUNT_SIZE = 165n;
|
|
8493
8499
|
var PositionManager = class {
|
|
8494
8500
|
constructor(config) {
|
|
8495
8501
|
this.config = config;
|
|
@@ -8514,17 +8520,8 @@ var PositionManager = class {
|
|
|
8514
8520
|
];
|
|
8515
8521
|
}
|
|
8516
8522
|
buildUnwrapSolInstruction(params) {
|
|
8517
|
-
const {
|
|
8523
|
+
const { owner, destination, ata } = params;
|
|
8518
8524
|
return [
|
|
8519
|
-
// There's a chance user might have deleted the ATA - create it with idempotent just to be sure.
|
|
8520
|
-
getCreateAssociatedTokenIdempotentInstruction({
|
|
8521
|
-
payer,
|
|
8522
|
-
ata,
|
|
8523
|
-
owner,
|
|
8524
|
-
mint: address4(NATIVE_MINT.toString()),
|
|
8525
|
-
tokenProgram: TOKEN_PROGRAM_ADDRESS3,
|
|
8526
|
-
systemProgram: SYSTEM_PROGRAM_ID
|
|
8527
|
-
}),
|
|
8528
8525
|
getCloseAccountInstruction({
|
|
8529
8526
|
account: ata,
|
|
8530
8527
|
destination,
|
|
@@ -8532,6 +8529,52 @@ var PositionManager = class {
|
|
|
8532
8529
|
})
|
|
8533
8530
|
];
|
|
8534
8531
|
}
|
|
8532
|
+
/**
|
|
8533
|
+
* Build partial unwrap SOL instructions using a temp account:
|
|
8534
|
+
* 1. Create temp account
|
|
8535
|
+
* 2. Initialize as WSOL token account
|
|
8536
|
+
* 3. Transfer specific amount from source ATA to temp
|
|
8537
|
+
* 4. Close temp account (lamports go to destination)
|
|
8538
|
+
*/
|
|
8539
|
+
async buildPartialUnwrapSolInstructions(params) {
|
|
8540
|
+
const { payer, sourceAta, destination, amount } = params;
|
|
8541
|
+
const rentExemptLamports = await this.config.rpc.getMinimumBalanceForRentExemption(TOKEN_ACCOUNT_SIZE).send();
|
|
8542
|
+
const tempAccount = await generateKeyPairSigner();
|
|
8543
|
+
const createTempAccountIx = getCreateAccountInstruction({
|
|
8544
|
+
payer,
|
|
8545
|
+
newAccount: tempAccount,
|
|
8546
|
+
lamports: rentExemptLamports,
|
|
8547
|
+
space: TOKEN_ACCOUNT_SIZE,
|
|
8548
|
+
programAddress: TOKEN_PROGRAM_ADDRESS3
|
|
8549
|
+
});
|
|
8550
|
+
const initTempAccountIx = getInitializeAccount3Instruction({
|
|
8551
|
+
account: tempAccount.address,
|
|
8552
|
+
mint: address4(NATIVE_MINT.toString()),
|
|
8553
|
+
owner: destination
|
|
8554
|
+
});
|
|
8555
|
+
const transferIx = getTransferCheckedInstruction({
|
|
8556
|
+
source: sourceAta,
|
|
8557
|
+
mint: address4(NATIVE_MINT.toString()),
|
|
8558
|
+
destination: tempAccount.address,
|
|
8559
|
+
authority: payer,
|
|
8560
|
+
amount,
|
|
8561
|
+
decimals: 9
|
|
8562
|
+
});
|
|
8563
|
+
const closeIx = getCloseAccountInstruction({
|
|
8564
|
+
account: tempAccount.address,
|
|
8565
|
+
destination,
|
|
8566
|
+
owner: destination
|
|
8567
|
+
});
|
|
8568
|
+
return {
|
|
8569
|
+
instructions: [
|
|
8570
|
+
createTempAccountIx,
|
|
8571
|
+
initTempAccountIx,
|
|
8572
|
+
transferIx,
|
|
8573
|
+
closeIx
|
|
8574
|
+
],
|
|
8575
|
+
signers: [tempAccount]
|
|
8576
|
+
};
|
|
8577
|
+
}
|
|
8535
8578
|
/**
|
|
8536
8579
|
* Make open position from liquidity instructions
|
|
8537
8580
|
* Use this when you know the exact liquidity amount you want to provide
|
|
@@ -8829,6 +8872,7 @@ var PositionManager = class {
|
|
|
8829
8872
|
/**
|
|
8830
8873
|
* Make decrease liquidity V2 instructions
|
|
8831
8874
|
* @param params - Decrease liquidity parameters
|
|
8875
|
+
* @param params.isNative - Whether to unwrap WSOL to native SOL after decrease
|
|
8832
8876
|
* @returns Instruction result following Raydium pattern
|
|
8833
8877
|
*/
|
|
8834
8878
|
async makeDecreaseLiquidityV2Instructions(params) {
|
|
@@ -8838,8 +8882,10 @@ var PositionManager = class {
|
|
|
8838
8882
|
ownerInfo,
|
|
8839
8883
|
liquidity,
|
|
8840
8884
|
amountMinA,
|
|
8841
|
-
amountMinB
|
|
8885
|
+
amountMinB,
|
|
8886
|
+
isNative = false
|
|
8842
8887
|
} = params;
|
|
8888
|
+
const signers = [];
|
|
8843
8889
|
const [personalPosition] = await PdaUtils.getPositionStatePda(
|
|
8844
8890
|
ownerPosition.nftMint
|
|
8845
8891
|
);
|
|
@@ -8873,6 +8919,24 @@ var PositionManager = class {
|
|
|
8873
8919
|
);
|
|
8874
8920
|
const extBitmapAccount = isOverflow ? await PdaUtils.getTickArrayBitmapExtensionPda(poolState.address) : void 0;
|
|
8875
8921
|
const remAccounts = extBitmapAccount ? [{ address: extBitmapAccount[0], role: AccountRole2.WRITABLE }] : [];
|
|
8922
|
+
const createRecipientAta0Ix = getCreateAssociatedTokenIdempotentInstruction(
|
|
8923
|
+
{
|
|
8924
|
+
payer: ownerInfo.wallet,
|
|
8925
|
+
ata: ownerInfo.tokenAccountA,
|
|
8926
|
+
owner: ownerInfo.wallet.address,
|
|
8927
|
+
mint: poolState.data.tokenMint0,
|
|
8928
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS3
|
|
8929
|
+
}
|
|
8930
|
+
);
|
|
8931
|
+
const createRecipientAta1Ix = getCreateAssociatedTokenIdempotentInstruction(
|
|
8932
|
+
{
|
|
8933
|
+
payer: ownerInfo.wallet,
|
|
8934
|
+
ata: ownerInfo.tokenAccountB,
|
|
8935
|
+
owner: ownerInfo.wallet.address,
|
|
8936
|
+
mint: poolState.data.tokenMint1,
|
|
8937
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS3
|
|
8938
|
+
}
|
|
8939
|
+
);
|
|
8876
8940
|
const instruction = getDecreaseLiquidityV2Instruction({
|
|
8877
8941
|
nftOwner: ownerInfo.wallet,
|
|
8878
8942
|
nftAccount: positionNftAccount,
|
|
@@ -8895,9 +8959,38 @@ var PositionManager = class {
|
|
|
8895
8959
|
...instruction,
|
|
8896
8960
|
accounts: [...instruction.accounts, ...remAccounts]
|
|
8897
8961
|
};
|
|
8962
|
+
const instructions = [
|
|
8963
|
+
createRecipientAta0Ix,
|
|
8964
|
+
createRecipientAta1Ix,
|
|
8965
|
+
ixWithRemAccounts
|
|
8966
|
+
];
|
|
8967
|
+
if (isNative) {
|
|
8968
|
+
const destination = ownerInfo.wallet.address;
|
|
8969
|
+
const isFullWithdrawal = liquidity === ownerPosition.liquidity;
|
|
8970
|
+
const isTokenANative = poolState.data.tokenMint0.toString() === NATIVE_MINT.toString();
|
|
8971
|
+
const wsolAta = isTokenANative ? ownerInfo.tokenAccountA : ownerInfo.tokenAccountB;
|
|
8972
|
+
const amount = isTokenANative ? amountMinA : amountMinB;
|
|
8973
|
+
if (isFullWithdrawal) {
|
|
8974
|
+
const unwrapIxs = this.buildUnwrapSolInstruction({
|
|
8975
|
+
ata: wsolAta,
|
|
8976
|
+
owner: ownerInfo.wallet.address,
|
|
8977
|
+
destination
|
|
8978
|
+
});
|
|
8979
|
+
instructions.push(...unwrapIxs);
|
|
8980
|
+
} else {
|
|
8981
|
+
const { instructions: partialUnwrapIxs, signers: partialSigners } = await this.buildPartialUnwrapSolInstructions({
|
|
8982
|
+
payer: ownerInfo.wallet,
|
|
8983
|
+
sourceAta: wsolAta,
|
|
8984
|
+
destination,
|
|
8985
|
+
amount
|
|
8986
|
+
});
|
|
8987
|
+
instructions.push(...partialUnwrapIxs);
|
|
8988
|
+
signers.push(...partialSigners);
|
|
8989
|
+
}
|
|
8990
|
+
}
|
|
8898
8991
|
return {
|
|
8899
|
-
instructions
|
|
8900
|
-
signers
|
|
8992
|
+
instructions,
|
|
8993
|
+
signers,
|
|
8901
8994
|
instructionTypes: ["DecreaseLiquidityV2"],
|
|
8902
8995
|
address: {
|
|
8903
8996
|
tickArrayLower,
|
|
@@ -8915,7 +9008,7 @@ var PositionManager = class {
|
|
|
8915
9008
|
* @returns Instruction result following established pattern
|
|
8916
9009
|
*/
|
|
8917
9010
|
async makeClosePositionInstructions(params) {
|
|
8918
|
-
const { ownerPosition, ownerInfo
|
|
9011
|
+
const { ownerPosition, ownerInfo } = params;
|
|
8919
9012
|
const [personalPosition] = await PdaUtils.getPositionStatePda(
|
|
8920
9013
|
ownerPosition.nftMint
|
|
8921
9014
|
);
|
|
@@ -8931,23 +9024,8 @@ var PositionManager = class {
|
|
|
8931
9024
|
personalPosition,
|
|
8932
9025
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS2
|
|
8933
9026
|
});
|
|
8934
|
-
let unrwrapWsolInstructions = [];
|
|
8935
|
-
if (isNative) {
|
|
8936
|
-
const ownerWallet = ownerInfo.wallet;
|
|
8937
|
-
const [ata] = await findAssociatedTokenPda({
|
|
8938
|
-
mint: address4(NATIVE_MINT.toString()),
|
|
8939
|
-
owner: ownerWallet.address,
|
|
8940
|
-
tokenProgram: TOKEN_PROGRAM_ADDRESS3
|
|
8941
|
-
});
|
|
8942
|
-
unrwrapWsolInstructions = this.buildUnwrapSolInstruction({
|
|
8943
|
-
payer: ownerWallet,
|
|
8944
|
-
ata,
|
|
8945
|
-
owner: ownerWallet.address,
|
|
8946
|
-
destination: ownerWallet.address
|
|
8947
|
-
});
|
|
8948
|
-
}
|
|
8949
9027
|
return {
|
|
8950
|
-
instructions: [instruction
|
|
9028
|
+
instructions: [instruction],
|
|
8951
9029
|
signers: [],
|
|
8952
9030
|
instructionTypes: ["ClosePosition"],
|
|
8953
9031
|
address: { positionNftAccount, personalPosition },
|
|
@@ -6,6 +6,14 @@ export declare class PositionManager {
|
|
|
6
6
|
constructor(config: ClmmSdkConfig);
|
|
7
7
|
private buildWrapSolInstructions;
|
|
8
8
|
private buildUnwrapSolInstruction;
|
|
9
|
+
/**
|
|
10
|
+
* Build partial unwrap SOL instructions using a temp account:
|
|
11
|
+
* 1. Create temp account
|
|
12
|
+
* 2. Initialize as WSOL token account
|
|
13
|
+
* 3. Transfer specific amount from source ATA to temp
|
|
14
|
+
* 4. Close temp account (lamports go to destination)
|
|
15
|
+
*/
|
|
16
|
+
private buildPartialUnwrapSolInstructions;
|
|
9
17
|
/**
|
|
10
18
|
* Make open position from liquidity instructions
|
|
11
19
|
* Use this when you know the exact liquidity amount you want to provide
|
|
@@ -81,6 +89,7 @@ export declare class PositionManager {
|
|
|
81
89
|
/**
|
|
82
90
|
* Make decrease liquidity V2 instructions
|
|
83
91
|
* @param params - Decrease liquidity parameters
|
|
92
|
+
* @param params.isNative - Whether to unwrap WSOL to native SOL after decrease
|
|
84
93
|
* @returns Instruction result following Raydium pattern
|
|
85
94
|
*/
|
|
86
95
|
makeDecreaseLiquidityV2Instructions(params: {
|
|
@@ -94,6 +103,7 @@ export declare class PositionManager {
|
|
|
94
103
|
liquidity: bigint;
|
|
95
104
|
amountMinA: bigint;
|
|
96
105
|
amountMinB: bigint;
|
|
106
|
+
isNative?: boolean;
|
|
97
107
|
}): Promise<MakeInstructionResult<{}>>;
|
|
98
108
|
/**
|
|
99
109
|
* Make close position instructions
|
|
@@ -105,7 +115,6 @@ export declare class PositionManager {
|
|
|
105
115
|
ownerInfo: {
|
|
106
116
|
wallet: TransactionSigner;
|
|
107
117
|
};
|
|
108
|
-
isNative: boolean;
|
|
109
118
|
}): Promise<MakeInstructionResult<{}>>;
|
|
110
119
|
/**
|
|
111
120
|
* Get position information by NFT mint
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position-manager.d.ts","sourceRoot":"","sources":["../src/position-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,OAAO,EAEZ,KAAK,iBAAiB,EAKvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAOL,qBAAqB,EACrB,SAAS,EACV,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,YAAY,EACb,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"position-manager.d.ts","sourceRoot":"","sources":["../src/position-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,OAAO,EAEZ,KAAK,iBAAiB,EAKvB,MAAM,aAAa,CAAC;AAErB,OAAO,EAOL,qBAAqB,EACrB,SAAS,EACV,MAAM,aAAa,CAAC;AAErB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