@stabbleorg/mclmm-sdk 0.3.0 → 0.3.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 +31 -39
- package/lib/index.mjs +31 -39
- package/lib/position-manager.d.ts +0 -1
- package/lib/position-manager.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -7940,25 +7940,6 @@ var PositionManager = class {
|
|
|
7940
7940
|
(0, import_token4.getSyncNativeInstruction)({ account: ata })
|
|
7941
7941
|
];
|
|
7942
7942
|
}
|
|
7943
|
-
buildUnwrapSolInstruction(params) {
|
|
7944
|
-
const { payer, owner, destination, ata } = params;
|
|
7945
|
-
return [
|
|
7946
|
-
// There's a chance user might have deleted the ATA - create it with idempotent just to be sure.
|
|
7947
|
-
(0, import_token4.getCreateAssociatedTokenIdempotentInstruction)({
|
|
7948
|
-
payer,
|
|
7949
|
-
ata,
|
|
7950
|
-
owner,
|
|
7951
|
-
mint: (0, import_kit53.address)(NATIVE_MINT.toString()),
|
|
7952
|
-
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS,
|
|
7953
|
-
systemProgram: SYSTEM_PROGRAM_ID
|
|
7954
|
-
}),
|
|
7955
|
-
(0, import_token4.getCloseAccountInstruction)({
|
|
7956
|
-
account: ata,
|
|
7957
|
-
destination,
|
|
7958
|
-
owner
|
|
7959
|
-
})
|
|
7960
|
-
];
|
|
7961
|
-
}
|
|
7962
7943
|
/**
|
|
7963
7944
|
* Build partial unwrap SOL instructions using a temp account:
|
|
7964
7945
|
* 1. Create temp account
|
|
@@ -8349,6 +8330,24 @@ var PositionManager = class {
|
|
|
8349
8330
|
);
|
|
8350
8331
|
const extBitmapAccount = isOverflow ? await PdaUtils.getTickArrayBitmapExtensionPda(poolState.address) : void 0;
|
|
8351
8332
|
const remAccounts = extBitmapAccount ? [{ address: extBitmapAccount[0], role: import_kit53.AccountRole.WRITABLE }] : [];
|
|
8333
|
+
const createRecipientAta0Ix = (0, import_token4.getCreateAssociatedTokenIdempotentInstruction)(
|
|
8334
|
+
{
|
|
8335
|
+
payer: ownerInfo.wallet,
|
|
8336
|
+
ata: ownerInfo.tokenAccountA,
|
|
8337
|
+
owner: ownerInfo.wallet.address,
|
|
8338
|
+
mint: poolState.data.tokenMint0,
|
|
8339
|
+
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS
|
|
8340
|
+
}
|
|
8341
|
+
);
|
|
8342
|
+
const createRecipientAta1Ix = (0, import_token4.getCreateAssociatedTokenIdempotentInstruction)(
|
|
8343
|
+
{
|
|
8344
|
+
payer: ownerInfo.wallet,
|
|
8345
|
+
ata: ownerInfo.tokenAccountB,
|
|
8346
|
+
owner: ownerInfo.wallet.address,
|
|
8347
|
+
mint: poolState.data.tokenMint1,
|
|
8348
|
+
tokenProgram: import_token4.TOKEN_PROGRAM_ADDRESS
|
|
8349
|
+
}
|
|
8350
|
+
);
|
|
8352
8351
|
const instruction = getDecreaseLiquidityV2Instruction({
|
|
8353
8352
|
nftOwner: ownerInfo.wallet,
|
|
8354
8353
|
nftAccount: positionNftAccount,
|
|
@@ -8371,31 +8370,24 @@ var PositionManager = class {
|
|
|
8371
8370
|
...instruction,
|
|
8372
8371
|
accounts: [...instruction.accounts, ...remAccounts]
|
|
8373
8372
|
};
|
|
8374
|
-
const instructions = [
|
|
8373
|
+
const instructions = [
|
|
8374
|
+
createRecipientAta0Ix,
|
|
8375
|
+
createRecipientAta1Ix,
|
|
8376
|
+
ixWithRemAccounts
|
|
8377
|
+
];
|
|
8375
8378
|
if (isNative) {
|
|
8376
8379
|
const destination = ownerInfo.wallet.address;
|
|
8377
|
-
const isFullWithdrawal = liquidity === ownerPosition.liquidity;
|
|
8378
8380
|
const isTokenANative = poolState.data.tokenMint0.toString() === NATIVE_MINT.toString();
|
|
8379
8381
|
const wsolAta = isTokenANative ? ownerInfo.tokenAccountA : ownerInfo.tokenAccountB;
|
|
8380
8382
|
const amount = isTokenANative ? amountMinA : amountMinB;
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
} else {
|
|
8390
|
-
const { instructions: partialUnwrapIxs, signers: partialSigners } = await this.buildPartialUnwrapSolInstructions({
|
|
8391
|
-
payer: ownerInfo.wallet,
|
|
8392
|
-
sourceAta: wsolAta,
|
|
8393
|
-
destination,
|
|
8394
|
-
amount
|
|
8395
|
-
});
|
|
8396
|
-
instructions.push(...partialUnwrapIxs);
|
|
8397
|
-
signers.push(...partialSigners);
|
|
8398
|
-
}
|
|
8383
|
+
const { instructions: unwrapIxs, signers: unwrapSigners } = await this.buildPartialUnwrapSolInstructions({
|
|
8384
|
+
payer: ownerInfo.wallet,
|
|
8385
|
+
sourceAta: wsolAta,
|
|
8386
|
+
destination,
|
|
8387
|
+
amount
|
|
8388
|
+
});
|
|
8389
|
+
instructions.push(...unwrapIxs);
|
|
8390
|
+
signers.push(...unwrapSigners);
|
|
8399
8391
|
}
|
|
8400
8392
|
return {
|
|
8401
8393
|
instructions,
|
package/lib/index.mjs
CHANGED
|
@@ -8519,25 +8519,6 @@ var PositionManager = class {
|
|
|
8519
8519
|
getSyncNativeInstruction({ account: ata })
|
|
8520
8520
|
];
|
|
8521
8521
|
}
|
|
8522
|
-
buildUnwrapSolInstruction(params) {
|
|
8523
|
-
const { payer, owner, destination, ata } = params;
|
|
8524
|
-
return [
|
|
8525
|
-
// There's a chance user might have deleted the ATA - create it with idempotent just to be sure.
|
|
8526
|
-
getCreateAssociatedTokenIdempotentInstruction({
|
|
8527
|
-
payer,
|
|
8528
|
-
ata,
|
|
8529
|
-
owner,
|
|
8530
|
-
mint: address4(NATIVE_MINT.toString()),
|
|
8531
|
-
tokenProgram: TOKEN_PROGRAM_ADDRESS3,
|
|
8532
|
-
systemProgram: SYSTEM_PROGRAM_ID
|
|
8533
|
-
}),
|
|
8534
|
-
getCloseAccountInstruction({
|
|
8535
|
-
account: ata,
|
|
8536
|
-
destination,
|
|
8537
|
-
owner
|
|
8538
|
-
})
|
|
8539
|
-
];
|
|
8540
|
-
}
|
|
8541
8522
|
/**
|
|
8542
8523
|
* Build partial unwrap SOL instructions using a temp account:
|
|
8543
8524
|
* 1. Create temp account
|
|
@@ -8928,6 +8909,24 @@ var PositionManager = class {
|
|
|
8928
8909
|
);
|
|
8929
8910
|
const extBitmapAccount = isOverflow ? await PdaUtils.getTickArrayBitmapExtensionPda(poolState.address) : void 0;
|
|
8930
8911
|
const remAccounts = extBitmapAccount ? [{ address: extBitmapAccount[0], role: AccountRole2.WRITABLE }] : [];
|
|
8912
|
+
const createRecipientAta0Ix = getCreateAssociatedTokenIdempotentInstruction(
|
|
8913
|
+
{
|
|
8914
|
+
payer: ownerInfo.wallet,
|
|
8915
|
+
ata: ownerInfo.tokenAccountA,
|
|
8916
|
+
owner: ownerInfo.wallet.address,
|
|
8917
|
+
mint: poolState.data.tokenMint0,
|
|
8918
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS3
|
|
8919
|
+
}
|
|
8920
|
+
);
|
|
8921
|
+
const createRecipientAta1Ix = getCreateAssociatedTokenIdempotentInstruction(
|
|
8922
|
+
{
|
|
8923
|
+
payer: ownerInfo.wallet,
|
|
8924
|
+
ata: ownerInfo.tokenAccountB,
|
|
8925
|
+
owner: ownerInfo.wallet.address,
|
|
8926
|
+
mint: poolState.data.tokenMint1,
|
|
8927
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS3
|
|
8928
|
+
}
|
|
8929
|
+
);
|
|
8931
8930
|
const instruction = getDecreaseLiquidityV2Instruction({
|
|
8932
8931
|
nftOwner: ownerInfo.wallet,
|
|
8933
8932
|
nftAccount: positionNftAccount,
|
|
@@ -8950,31 +8949,24 @@ var PositionManager = class {
|
|
|
8950
8949
|
...instruction,
|
|
8951
8950
|
accounts: [...instruction.accounts, ...remAccounts]
|
|
8952
8951
|
};
|
|
8953
|
-
const instructions = [
|
|
8952
|
+
const instructions = [
|
|
8953
|
+
createRecipientAta0Ix,
|
|
8954
|
+
createRecipientAta1Ix,
|
|
8955
|
+
ixWithRemAccounts
|
|
8956
|
+
];
|
|
8954
8957
|
if (isNative) {
|
|
8955
8958
|
const destination = ownerInfo.wallet.address;
|
|
8956
|
-
const isFullWithdrawal = liquidity === ownerPosition.liquidity;
|
|
8957
8959
|
const isTokenANative = poolState.data.tokenMint0.toString() === NATIVE_MINT.toString();
|
|
8958
8960
|
const wsolAta = isTokenANative ? ownerInfo.tokenAccountA : ownerInfo.tokenAccountB;
|
|
8959
8961
|
const amount = isTokenANative ? amountMinA : amountMinB;
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
} else {
|
|
8969
|
-
const { instructions: partialUnwrapIxs, signers: partialSigners } = await this.buildPartialUnwrapSolInstructions({
|
|
8970
|
-
payer: ownerInfo.wallet,
|
|
8971
|
-
sourceAta: wsolAta,
|
|
8972
|
-
destination,
|
|
8973
|
-
amount
|
|
8974
|
-
});
|
|
8975
|
-
instructions.push(...partialUnwrapIxs);
|
|
8976
|
-
signers.push(...partialSigners);
|
|
8977
|
-
}
|
|
8962
|
+
const { instructions: unwrapIxs, signers: unwrapSigners } = await this.buildPartialUnwrapSolInstructions({
|
|
8963
|
+
payer: ownerInfo.wallet,
|
|
8964
|
+
sourceAta: wsolAta,
|
|
8965
|
+
destination,
|
|
8966
|
+
amount
|
|
8967
|
+
});
|
|
8968
|
+
instructions.push(...unwrapIxs);
|
|
8969
|
+
signers.push(...unwrapSigners);
|
|
8978
8970
|
}
|
|
8979
8971
|
return {
|
|
8980
8972
|
instructions,
|
|
@@ -5,7 +5,6 @@ export declare class PositionManager {
|
|
|
5
5
|
private readonly config;
|
|
6
6
|
constructor(config: ClmmSdkConfig);
|
|
7
7
|
private buildWrapSolInstructions;
|
|
8
|
-
private buildUnwrapSolInstruction;
|
|
9
8
|
/**
|
|
10
9
|
* Build partial unwrap SOL instructions using a temp account:
|
|
11
10
|
* 1. Create temp account
|
|
@@ -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;AAgCjB,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,OAAO,CAAC,wBAAwB;IAyBhC
|
|
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;AAgCjB,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,OAAO,CAAC,wBAAwB;IAyBhC;;;;;;OAMG;YACW,iCAAiC;IA2D/C;;;;;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,OAA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