@stabbleorg/mclmm-sdk 0.2.1 → 0.2.2
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 +36 -2
- package/lib/index.mjs +38 -3
- package/lib/position-manager.d.ts +2 -0
- package/lib/position-manager.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -7939,6 +7939,25 @@ var PositionManager = class {
|
|
|
7939
7939
|
(0, import_token4.getSyncNativeInstruction)({ account: ata })
|
|
7940
7940
|
];
|
|
7941
7941
|
}
|
|
7942
|
+
buildUnwrapSolInstruction(params) {
|
|
7943
|
+
const { payer, owner, destination, ata } = params;
|
|
7944
|
+
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
|
+
(0, import_token4.getCloseAccountInstruction)({
|
|
7955
|
+
account: ata,
|
|
7956
|
+
destination,
|
|
7957
|
+
owner
|
|
7958
|
+
})
|
|
7959
|
+
];
|
|
7960
|
+
}
|
|
7942
7961
|
/**
|
|
7943
7962
|
* Make open position from liquidity instructions
|
|
7944
7963
|
* Use this when you know the exact liquidity amount you want to provide
|
|
@@ -8322,7 +8341,7 @@ var PositionManager = class {
|
|
|
8322
8341
|
* @returns Instruction result following established pattern
|
|
8323
8342
|
*/
|
|
8324
8343
|
async makeClosePositionInstructions(params) {
|
|
8325
|
-
const { ownerPosition, ownerInfo } = params;
|
|
8344
|
+
const { ownerPosition, ownerInfo, isNative } = params;
|
|
8326
8345
|
const [personalPosition] = await PdaUtils.getPositionStatePda(
|
|
8327
8346
|
ownerPosition.nftMint
|
|
8328
8347
|
);
|
|
@@ -8338,8 +8357,23 @@ var PositionManager = class {
|
|
|
8338
8357
|
personalPosition,
|
|
8339
8358
|
tokenProgram: import_token_20222.TOKEN_2022_PROGRAM_ADDRESS
|
|
8340
8359
|
});
|
|
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
|
+
}
|
|
8341
8375
|
return {
|
|
8342
|
-
instructions: [instruction],
|
|
8376
|
+
instructions: [instruction, ...unrwrapWsolInstructions],
|
|
8343
8377
|
signers: [],
|
|
8344
8378
|
instructionTypes: ["ClosePosition"],
|
|
8345
8379
|
address: { positionNftAccount, personalPosition },
|
package/lib/index.mjs
CHANGED
|
@@ -8473,7 +8473,8 @@ import {
|
|
|
8473
8473
|
getSyncNativeInstruction,
|
|
8474
8474
|
findAssociatedTokenPda,
|
|
8475
8475
|
TOKEN_PROGRAM_ADDRESS as TOKEN_PROGRAM_ADDRESS3,
|
|
8476
|
-
getCreateAssociatedTokenIdempotentInstruction
|
|
8476
|
+
getCreateAssociatedTokenIdempotentInstruction,
|
|
8477
|
+
getCloseAccountInstruction
|
|
8477
8478
|
} from "@solana-program/token";
|
|
8478
8479
|
import { TOKEN_2022_PROGRAM_ADDRESS as TOKEN_2022_PROGRAM_ADDRESS2 } from "@solana-program/token-2022";
|
|
8479
8480
|
import BN6 from "bn.js";
|
|
@@ -8512,6 +8513,25 @@ var PositionManager = class {
|
|
|
8512
8513
|
getSyncNativeInstruction({ account: ata })
|
|
8513
8514
|
];
|
|
8514
8515
|
}
|
|
8516
|
+
buildUnwrapSolInstruction(params) {
|
|
8517
|
+
const { payer, owner, destination, ata } = params;
|
|
8518
|
+
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
|
+
getCloseAccountInstruction({
|
|
8529
|
+
account: ata,
|
|
8530
|
+
destination,
|
|
8531
|
+
owner
|
|
8532
|
+
})
|
|
8533
|
+
];
|
|
8534
|
+
}
|
|
8515
8535
|
/**
|
|
8516
8536
|
* Make open position from liquidity instructions
|
|
8517
8537
|
* Use this when you know the exact liquidity amount you want to provide
|
|
@@ -8895,7 +8915,7 @@ var PositionManager = class {
|
|
|
8895
8915
|
* @returns Instruction result following established pattern
|
|
8896
8916
|
*/
|
|
8897
8917
|
async makeClosePositionInstructions(params) {
|
|
8898
|
-
const { ownerPosition, ownerInfo } = params;
|
|
8918
|
+
const { ownerPosition, ownerInfo, isNative } = params;
|
|
8899
8919
|
const [personalPosition] = await PdaUtils.getPositionStatePda(
|
|
8900
8920
|
ownerPosition.nftMint
|
|
8901
8921
|
);
|
|
@@ -8911,8 +8931,23 @@ var PositionManager = class {
|
|
|
8911
8931
|
personalPosition,
|
|
8912
8932
|
tokenProgram: TOKEN_2022_PROGRAM_ADDRESS2
|
|
8913
8933
|
});
|
|
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
|
+
}
|
|
8914
8949
|
return {
|
|
8915
|
-
instructions: [instruction],
|
|
8950
|
+
instructions: [instruction, ...unrwrapWsolInstructions],
|
|
8916
8951
|
signers: [],
|
|
8917
8952
|
instructionTypes: ["ClosePosition"],
|
|
8918
8953
|
address: { positionNftAccount, personalPosition },
|
|
@@ -5,6 +5,7 @@ export declare class PositionManager {
|
|
|
5
5
|
private readonly config;
|
|
6
6
|
constructor(config: ClmmSdkConfig);
|
|
7
7
|
private buildWrapSolInstructions;
|
|
8
|
+
private buildUnwrapSolInstruction;
|
|
8
9
|
/**
|
|
9
10
|
* Make open position from liquidity instructions
|
|
10
11
|
* Use this when you know the exact liquidity amount you want to provide
|
|
@@ -104,6 +105,7 @@ export declare class PositionManager {
|
|
|
104
105
|
ownerInfo: {
|
|
105
106
|
wallet: TransactionSigner;
|
|
106
107
|
};
|
|
108
|
+
isNative: boolean;
|
|
107
109
|
}): Promise<MakeInstructionResult<{}>>;
|
|
108
110
|
/**
|
|
109
111
|
* 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,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,YAAY,EACb,MAAM,SAAS,CAAC;AAwBjB,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,OAAO,CAAC,wBAAwB;IAyBhC,OAAO,CAAC,yBAAyB;IA0BjC;;;;;OAKG;IACG,yCAAyC,CAAC,MAAM,EAAE;QACtD,WAAW,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACzC,SAAS,EAAE;YACT,QAAQ,EAAE,iBAAiB,CAAC;YAC5B,MAAM,EAAE,OAAO,CAAC;YAChB,aAAa,EAAE,OAAO,CAAC;YACvB,aAAa,EAAE,OAAO,CAAC;YACvB,aAAa,CAAC,EAAE,OAAO,CAAC;SACzB,CAAC;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,mBAAmB,CAAC,EAAE,MAAM,iBAAiB,EAAE,CAAC;KACjD,GAAG,OAAO,CACT,qBAAqB,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;QACzB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE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