@picon-finance/dlmm-sdk 1.11.0 → 1.13.0
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/dist/entities/dlmm_program.d.ts +5 -13
- package/dist/entities/dlmm_program.d.ts.map +1 -1
- package/dist/entities/dlmm_program.js +0 -4
- package/dist/entities/pool.d.ts +10 -15
- package/dist/entities/pool.d.ts.map +1 -1
- package/dist/entities/pool.js +101 -38
- package/dist/entities/position.d.ts.map +1 -1
- package/dist/entities/position.js +73 -3
- package/dist/generated/instructions/claimFee.d.ts +8 -4
- package/dist/generated/instructions/claimFee.d.ts.map +1 -1
- package/dist/generated/instructions/claimFee.js +10 -1
- package/dist/generated/instructions/claimProtocolFee.d.ts +11 -5
- package/dist/generated/instructions/claimProtocolFee.d.ts.map +1 -1
- package/dist/generated/instructions/claimProtocolFee.js +19 -4
- package/dist/generated/instructions/depositByWeight.d.ts +5 -2
- package/dist/generated/instructions/depositByWeight.d.ts.map +1 -1
- package/dist/generated/instructions/depositByWeight.js +10 -2
- package/dist/generated/instructions/withdraw.d.ts +8 -4
- package/dist/generated/instructions/withdraw.d.ts.map +1 -1
- package/dist/generated/instructions/withdraw.js +10 -1
- package/dist/generated/types/accountKind.d.ts +3 -1
- package/dist/generated/types/accountKind.d.ts.map +1 -1
- package/dist/generated/types/accountKind.js +2 -0
- package/dist/picon_dlmm.json +49 -2
- package/dist/quote/wasm-node/picon_dlmm_quote.d.ts +2 -0
- package/dist/quote/wasm-node/picon_dlmm_quote_bg.wasm +0 -0
- package/dist/quote/wasm-web/picon_dlmm_quote.d.ts +2 -0
- package/dist/quote/wasm-web/picon_dlmm_quote_bg.wasm +0 -0
- package/dist/utils/assert.d.ts +0 -1
- package/dist/utils/assert.d.ts.map +1 -1
- package/dist/utils/assert.js +0 -5
- package/dist/utils/constants.d.ts +0 -1
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +0 -5
- package/dist/utils/transfer_hook.d.ts +5 -1
- package/dist/utils/transfer_hook.d.ts.map +1 -1
- package/dist/utils/transfer_hook.js +26 -8
- package/package.json +1 -1
- package/src/entities/dlmm_program.ts +3 -13
- package/src/entities/pool.ts +138 -64
- package/src/entities/position.ts +86 -3
- package/src/generated/instructions/claimFee.ts +27 -6
- package/src/generated/instructions/claimProtocolFee.ts +45 -10
- package/src/generated/instructions/depositByWeight.ts +19 -0
- package/src/generated/instructions/withdraw.ts +27 -6
- package/src/generated/types/accountKind.ts +2 -0
- package/src/picon_dlmm.json +49 -2
- package/src/quote/wasm-node/picon_dlmm_quote.d.ts +2 -0
- package/src/quote/wasm-node/picon_dlmm_quote_bg.wasm +0 -0
- package/src/quote/wasm-web/picon_dlmm_quote.d.ts +2 -0
- package/src/quote/wasm-web/picon_dlmm_quote_bg.wasm +0 -0
- package/src/utils/assert.ts +0 -6
- package/src/utils/constants.ts +0 -6
- package/src/utils/transfer_hook.ts +28 -7
|
@@ -19,26 +19,18 @@ export declare class DlmmProgram {
|
|
|
19
19
|
tokenProgramY: Address;
|
|
20
20
|
}): Promise<Instruction>;
|
|
21
21
|
swap(user: TransactionSigner, poolAddress: Address, params: {
|
|
22
|
-
xToY: boolean;
|
|
23
|
-
amountIn: bigint;
|
|
24
|
-
minAmountOut: bigint;
|
|
25
|
-
binArrayCount?: number;
|
|
26
|
-
}, config?: FetchAccountConfig): Promise<Instruction[]>;
|
|
27
|
-
quote(poolAddress: Address, params: {
|
|
28
|
-
xToY: boolean;
|
|
29
|
-
amountIn: bigint;
|
|
30
|
-
slippageToleranceBps: number;
|
|
31
|
-
binArrayCount?: number;
|
|
32
|
-
}, config?: FetchAccountConfig): Promise<QuoteOutput>;
|
|
33
|
-
quoteAndSwap(user: TransactionSigner, poolAddress: Address, params: {
|
|
34
22
|
xToY: boolean;
|
|
35
23
|
amountIn: bigint;
|
|
36
24
|
slippageToleranceBps: number;
|
|
37
|
-
binArrayCount?: number;
|
|
38
25
|
}, config?: FetchAccountConfig): Promise<{
|
|
39
26
|
quoteOutput: QuoteOutput;
|
|
40
27
|
instructions: Instruction[];
|
|
41
28
|
}>;
|
|
29
|
+
quote(poolAddress: Address, params: {
|
|
30
|
+
xToY: boolean;
|
|
31
|
+
amountIn: bigint;
|
|
32
|
+
slippageToleranceBps: number;
|
|
33
|
+
}, config?: FetchAccountConfig): Promise<QuoteOutput>;
|
|
42
34
|
getAllPositionMintsByOwner(owner: Address, config?: FetchAccountsConfig): Promise<Map<Address, Address[]>>;
|
|
43
35
|
createAdminConfig(deployer: TransactionSigner): Promise<Instruction>;
|
|
44
36
|
resetAdminAuthority(deployer: TransactionSigner): Promise<Instruction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dlmm_program.d.ts","sourceRoot":"","sources":["../../src/entities/dlmm_program.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EAGzB,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EACL,IAAI,EAEL,MAAM,QAAQ,CAAC;AAYhB,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,qBAAa,WAAW;;IAItB,YACE,GAAG,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,EACvC,cAAc,GAAE,OAAiC,EAIlD;IAED,IAAW,GAAG,+5nBAAwB;IACtC,IAAW,cAAc,YAAmC;IAE/C,OAAO,CAClB,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAEf;IAEY,UAAU,CACrB,SAAS,EAAE,iBAAiB,EAC5B,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAA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AAO,GAC/B,OAAO,CAAC,WAAW,CAAC,CAKtB;IAEY,cAAc,CACzB,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAKzC;IAEY,mBAAmB,CAC9B,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAKlB;CACF"}
|
|
@@ -28,10 +28,6 @@ export class DlmmProgram {
|
|
|
28
28
|
const pool = await this.getPool(poolAddress, config);
|
|
29
29
|
return await pool.quote(params);
|
|
30
30
|
}
|
|
31
|
-
async quoteAndSwap(user, poolAddress, params, config) {
|
|
32
|
-
const pool = await this.getPool(poolAddress, config);
|
|
33
|
-
return await pool.quoteAndSwap(user, params);
|
|
34
|
-
}
|
|
35
31
|
async getAllPositionMintsByOwner(owner, config) {
|
|
36
32
|
const { commitment, minContextSlot, abortSignal } = config ?? {};
|
|
37
33
|
const { value: tokenAccounts } = await this.#rpc
|
package/dist/entities/pool.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSolanaRpc, type Address, type Account, type Instruction, type TransactionSigner, type FetchAccountConfig, type FetchAccountsConfig } from "@solana/kit";
|
|
2
2
|
import { generated } from "..";
|
|
3
3
|
import { type FeeRates, type QuoteOutput, type TransferFee } from "../quote";
|
|
4
|
+
import { type ExtraAccount, type TransferAccounts as TransferHookAccounts } from "../utils/transfer_hook";
|
|
4
5
|
import { Position } from "./position";
|
|
5
6
|
import { type ProgramConfig } from "./types";
|
|
6
7
|
export declare class Pool {
|
|
@@ -34,28 +35,22 @@ export declare class Pool {
|
|
|
34
35
|
upperBinId: number;
|
|
35
36
|
}): Promise<Instruction[]>;
|
|
36
37
|
closePosition(owner: TransactionSigner, positionMint: Address): Promise<Instruction>;
|
|
37
|
-
swap(user: TransactionSigner, { xToY, amountIn,
|
|
38
|
-
xToY: boolean;
|
|
39
|
-
amountIn: bigint;
|
|
40
|
-
minAmountOut: bigint;
|
|
41
|
-
binArrayCount?: number;
|
|
42
|
-
}): Promise<Instruction[]>;
|
|
43
|
-
quote({ xToY, amountIn, slippageToleranceBps, binArrayCount, }: {
|
|
38
|
+
swap(user: TransactionSigner, { xToY, amountIn, slippageToleranceBps, }: {
|
|
44
39
|
xToY: boolean;
|
|
45
40
|
amountIn: bigint;
|
|
46
41
|
slippageToleranceBps: number;
|
|
47
|
-
binArrayCount?: number;
|
|
48
|
-
}): Promise<QuoteOutput>;
|
|
49
|
-
quoteAndSwap(user: TransactionSigner, { xToY, amountIn, slippageToleranceBps, binArrayCount, }: {
|
|
50
|
-
xToY: boolean;
|
|
51
|
-
amountIn: bigint;
|
|
52
|
-
slippageToleranceBps: number;
|
|
53
|
-
binArrayCount?: number;
|
|
54
42
|
}): Promise<{
|
|
55
43
|
quoteOutput: QuoteOutput;
|
|
56
44
|
instructions: Instruction[];
|
|
57
45
|
}>;
|
|
58
|
-
|
|
46
|
+
resolveTransferHookAccountsX(transferAccounts: TransferHookAccounts): Promise<ExtraAccount[]>;
|
|
47
|
+
resolveTransferHookAccountsY(transferAccounts: TransferHookAccounts): Promise<ExtraAccount[]>;
|
|
48
|
+
quote(params: {
|
|
49
|
+
xToY: boolean;
|
|
50
|
+
amountIn: bigint;
|
|
51
|
+
slippageToleranceBps: number;
|
|
52
|
+
}): Promise<QuoteOutput>;
|
|
53
|
+
sync(user: TransactionSigner, desiredBinId: number): Promise<Instruction[]>;
|
|
59
54
|
setDynamicFeeConfig(authority: TransactionSigner, dynamicFeeConfig: generated.DynamicFeeConfig): Promise<Instruction>;
|
|
60
55
|
setProtocolShare(authority: TransactionSigner, protocolShare: number): Promise<Instruction>;
|
|
61
56
|
claimProtocolFee(authority: TransactionSigner): Promise<Instruction[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/entities/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,KAAK,OAAO,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a,GACpB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,UAAU,CAC9B,EACE,SAAS,EACT,OAAO,EACP,OAAO,EACP,aAAa,EACb,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,GACd,EAAE;IACD,SAAS,EAAE,iBAAiB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB,EACD,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,WAAW,CAAC,CAkBtB"}
|
package/dist/entities/pool.js
CHANGED
|
@@ -3,12 +3,12 @@ import { fetchAllMint, } from "@solana-program/token-2022";
|
|
|
3
3
|
import { generated } from "..";
|
|
4
4
|
import { quote, getPoolFeeRates, } from "../quote";
|
|
5
5
|
import { isAccount } from "../utils/type_guards";
|
|
6
|
-
import { assertInRange } from "../utils/assert";
|
|
7
6
|
import { resolveAdminConfigAddress } from "./admin_config";
|
|
8
7
|
import { processAssociatedTokenAccountPair } from "../utils/ata";
|
|
9
|
-
import { generateBinArrayIndicesForSwap, generateBinArrayIndicesForSync, } from "../utils/bin_location";
|
|
8
|
+
import { getBinArrayIndex, generateBinArrayIndicesForSwap, generateBinArrayIndicesForSync, } from "../utils/bin_location";
|
|
10
9
|
import { resolveTransferFee } from "../utils/transfer_fee";
|
|
11
|
-
import {
|
|
10
|
+
import { resolveTransferHookProgram, resolveTransferHookExtraAccounts, toRemainingAccountMeta, } from "../utils/transfer_hook";
|
|
11
|
+
import { MAX_BIN_ARRAYS_PER_TRAVERSAL } from "../utils/constants";
|
|
12
12
|
import { Position, openPosition, closePosition, findPositionAddress, findAllPositionAddresses, } from "./position";
|
|
13
13
|
import { findAllBinArrayAddresses } from "./bin_array";
|
|
14
14
|
export class Pool {
|
|
@@ -70,24 +70,42 @@ export class Pool {
|
|
|
70
70
|
async closePosition(owner, positionMint) {
|
|
71
71
|
return await closePosition({ owner, positionMint }, { programAddress: this.#programAddress });
|
|
72
72
|
}
|
|
73
|
-
async swap(user, { xToY, amountIn,
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
async swap(user, { xToY, amountIn, slippageToleranceBps, }) {
|
|
74
|
+
const { quoteOutput, binArrayAddresses } = await this.#quote({ xToY, amountIn, slippageToleranceBps });
|
|
75
|
+
const { ataX: tokenUserAccountX, ataY: tokenUserAccountY, preInstructions, postInstructions, } = await processAssociatedTokenAccountPair({
|
|
76
|
+
owner: user,
|
|
77
|
+
tokenMintX: this.tokenMintX,
|
|
78
|
+
tokenMintY: this.tokenMintY,
|
|
79
|
+
tokenProgramX: this.tokenProgramX,
|
|
80
|
+
tokenProgramY: this.tokenProgramY,
|
|
81
|
+
amountX: xToY ? amountIn : undefined,
|
|
82
|
+
amountY: xToY ? undefined : amountIn,
|
|
83
|
+
});
|
|
84
|
+
// Each mint's hook accounts are resolved against whichever role it plays in this swap —
|
|
85
|
+
// input (user -> vault, owner = user) or output (vault -> user, owner = pool PDA).
|
|
86
|
+
const xTransferAccounts = xToY
|
|
87
|
+
? { source: tokenUserAccountX, mint: this.tokenMintX, destination: this.tokenVaultX, owner: user.address }
|
|
88
|
+
: { source: this.tokenVaultX, mint: this.tokenMintX, destination: tokenUserAccountX, owner: this.address };
|
|
89
|
+
const yTransferAccounts = xToY
|
|
90
|
+
? { source: this.tokenVaultY, mint: this.tokenMintY, destination: tokenUserAccountY, owner: this.address }
|
|
91
|
+
: { source: tokenUserAccountY, mint: this.tokenMintY, destination: this.tokenVaultY, owner: user.address };
|
|
92
|
+
const [transferHookXAccounts, transferHookYAccounts] = await Promise.all([
|
|
93
|
+
this.resolveTransferHookAccountsX(xTransferAccounts),
|
|
94
|
+
this.resolveTransferHookAccountsY(yTransferAccounts),
|
|
87
95
|
]);
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
const groups = [
|
|
97
|
+
{ kind: generated.AccountKind.BinArray, count: binArrayAddresses.length },
|
|
98
|
+
];
|
|
99
|
+
const remainingAccounts = binArrayAddresses.map(address => ({ address, role: AccountRole.WRITABLE }));
|
|
100
|
+
if (transferHookXAccounts.length > 0) {
|
|
101
|
+
groups.push({ kind: generated.AccountKind.TransferHookX, count: transferHookXAccounts.length });
|
|
102
|
+
remainingAccounts.push(...transferHookXAccounts.map(toRemainingAccountMeta));
|
|
103
|
+
}
|
|
104
|
+
if (transferHookYAccounts.length > 0) {
|
|
105
|
+
groups.push({ kind: generated.AccountKind.TransferHookY, count: transferHookYAccounts.length });
|
|
106
|
+
remainingAccounts.push(...transferHookYAccounts.map(toRemainingAccountMeta));
|
|
107
|
+
}
|
|
108
|
+
const remainingAccountsScheme = { groups };
|
|
91
109
|
const swapIx = generated.getSwapInstruction({
|
|
92
110
|
user,
|
|
93
111
|
pool: this.address,
|
|
@@ -100,24 +118,43 @@ export class Pool {
|
|
|
100
118
|
tokenProgramX: this.tokenProgramX,
|
|
101
119
|
tokenProgramY: this.tokenProgramY,
|
|
102
120
|
amountIn,
|
|
103
|
-
minAmountOut,
|
|
121
|
+
minAmountOut: quoteOutput.minAmountOut,
|
|
104
122
|
xToY,
|
|
105
123
|
remainingAccountsScheme,
|
|
106
124
|
}, { programAddress: this.#programAddress });
|
|
107
|
-
const remainingAccounts = binArrayAddresses.map(address => ({ address, role: AccountRole.WRITABLE }));
|
|
108
125
|
const swapIxWithBinArrays = { ...swapIx, accounts: [...swapIx.accounts, ...remainingAccounts] };
|
|
109
|
-
|
|
126
|
+
const instructions = [...preInstructions, swapIxWithBinArrays, ...postInstructions];
|
|
127
|
+
return { quoteOutput, instructions };
|
|
110
128
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
// Public so Position (which only holds a reference to this Pool, not its private mint data)
|
|
130
|
+
// can resolve hook accounts for its own deposit/withdraw/claimFee instructions without ever
|
|
131
|
+
// needing a Mint account itself — empty when that mint has no active transfer hook, in which
|
|
132
|
+
// case the caller should add no group to the scheme for it.
|
|
133
|
+
async resolveTransferHookAccountsX(transferAccounts) {
|
|
134
|
+
return await this.#resolveTransferHookAccounts(this.#mintX, transferAccounts);
|
|
135
|
+
}
|
|
136
|
+
async resolveTransferHookAccountsY(transferAccounts) {
|
|
137
|
+
return await this.#resolveTransferHookAccounts(this.#mintY, transferAccounts);
|
|
138
|
+
}
|
|
139
|
+
async #resolveTransferHookAccounts(mint, transferAccounts) {
|
|
140
|
+
const hookProgram = resolveTransferHookProgram(mint.data);
|
|
141
|
+
if (!hookProgram)
|
|
142
|
+
return [];
|
|
143
|
+
return await resolveTransferHookExtraAccounts(this.#rpc, hookProgram, transferAccounts);
|
|
144
|
+
}
|
|
145
|
+
async quote(params) {
|
|
146
|
+
const { quoteOutput } = await this.#quote(params);
|
|
147
|
+
return quoteOutput;
|
|
148
|
+
}
|
|
149
|
+
async #quote({ xToY, amountIn, slippageToleranceBps, }) {
|
|
150
|
+
const indices = generateBinArrayIndicesForSwap(this.activeBinId, xToY, MAX_BIN_ARRAYS_PER_TRAVERSAL);
|
|
151
|
+
const maxBinArrayAddresses = await findAllBinArrayAddresses({ pool: this.address, indices }, { programAddress: this.#programAddress });
|
|
115
152
|
const [maybeBinArrays, { transferFeeX, transferFeeY }] = await Promise.all([
|
|
116
|
-
generated.fetchAllMaybeBinArray(this.#rpc,
|
|
153
|
+
generated.fetchAllMaybeBinArray(this.#rpc, maxBinArrayAddresses),
|
|
117
154
|
this.getTransferFees(),
|
|
118
155
|
]);
|
|
119
156
|
const binArrays = maybeBinArrays.map(maybeBinArray => maybeBinArray.exists ? maybeBinArray.data : undefined);
|
|
120
|
-
|
|
157
|
+
const quoteOutput = await quote({
|
|
121
158
|
amountIn,
|
|
122
159
|
xToY,
|
|
123
160
|
slippageToleranceBps,
|
|
@@ -127,15 +164,16 @@ export class Pool {
|
|
|
127
164
|
outputTransferFee: xToY ? transferFeeY : transferFeeX,
|
|
128
165
|
binArrays,
|
|
129
166
|
});
|
|
167
|
+
const safeOffset = xToY ? -1 : 1;
|
|
168
|
+
const targetBinArrayIndex = getBinArrayIndex(quoteOutput.postActiveBinId) + safeOffset;
|
|
169
|
+
const localTargetBinArrayIndex = targetBinArrayIndex - indices[0];
|
|
170
|
+
const binArrayAddresses = xToY
|
|
171
|
+
? maxBinArrayAddresses.slice(Math.max(0, localTargetBinArrayIndex))
|
|
172
|
+
: maxBinArrayAddresses.slice(0, localTargetBinArrayIndex + 1);
|
|
173
|
+
return { quoteOutput, binArrayAddresses };
|
|
130
174
|
}
|
|
131
|
-
async
|
|
132
|
-
const
|
|
133
|
-
const instructions = await this.swap(user, { xToY, amountIn, minAmountOut: quoteOutput.minAmountOut, binArrayCount });
|
|
134
|
-
return { quoteOutput, instructions };
|
|
135
|
-
}
|
|
136
|
-
async sync(user, desiredBinId, binArrayCount = MAX_BIN_ARRAYS_PER_TRAVERSAL) {
|
|
137
|
-
assertInRange(binArrayCount, MIN_BIN_ARRAYS_PER_TRAVERSAL, MAX_BIN_ARRAYS_PER_TRAVERSAL, "binArrayCount");
|
|
138
|
-
const indices = generateBinArrayIndicesForSync(this.activeBinId, desiredBinId, binArrayCount);
|
|
175
|
+
async sync(user, desiredBinId) {
|
|
176
|
+
const indices = generateBinArrayIndicesForSync(this.activeBinId, desiredBinId, MAX_BIN_ARRAYS_PER_TRAVERSAL);
|
|
139
177
|
const binArrayAddresses = await findAllBinArrayAddresses({ pool: this.address, indices }, { programAddress: this.#programAddress });
|
|
140
178
|
const remainingAccountsScheme = {
|
|
141
179
|
groups: [{ kind: generated.AccountKind.BinArray, count: binArrayAddresses.length }],
|
|
@@ -163,6 +201,26 @@ export class Pool {
|
|
|
163
201
|
tokenProgramY: this.tokenProgramY,
|
|
164
202
|
}),
|
|
165
203
|
]);
|
|
204
|
+
// Both legs move vault -> admin, signed by the pool PDA (not the authority signer, which
|
|
205
|
+
// only gates the on-chain permission check).
|
|
206
|
+
const [transferHookXAccounts, transferHookYAccounts] = await Promise.all([
|
|
207
|
+
this.resolveTransferHookAccountsX({
|
|
208
|
+
source: this.tokenVaultX, mint: this.tokenMintX, destination: tokenAdminAccountX, owner: this.address,
|
|
209
|
+
}),
|
|
210
|
+
this.resolveTransferHookAccountsY({
|
|
211
|
+
source: this.tokenVaultY, mint: this.tokenMintY, destination: tokenAdminAccountY, owner: this.address,
|
|
212
|
+
}),
|
|
213
|
+
]);
|
|
214
|
+
const groups = [];
|
|
215
|
+
const remainingAccounts = [];
|
|
216
|
+
if (transferHookXAccounts.length > 0) {
|
|
217
|
+
groups.push({ kind: generated.AccountKind.TransferHookX, count: transferHookXAccounts.length });
|
|
218
|
+
remainingAccounts.push(...transferHookXAccounts.map(toRemainingAccountMeta));
|
|
219
|
+
}
|
|
220
|
+
if (transferHookYAccounts.length > 0) {
|
|
221
|
+
groups.push({ kind: generated.AccountKind.TransferHookY, count: transferHookYAccounts.length });
|
|
222
|
+
remainingAccounts.push(...transferHookYAccounts.map(toRemainingAccountMeta));
|
|
223
|
+
}
|
|
166
224
|
const claimProtocolFeeIx = await generated.getClaimProtocolFeeInstructionAsync({
|
|
167
225
|
authority,
|
|
168
226
|
pool: this.address,
|
|
@@ -173,10 +231,15 @@ export class Pool {
|
|
|
173
231
|
tokenVaultY: this.tokenVaultY,
|
|
174
232
|
tokenAdminAccountX,
|
|
175
233
|
tokenAdminAccountY,
|
|
234
|
+
remainingAccountsScheme: { groups },
|
|
176
235
|
tokenProgramX: this.tokenProgramX,
|
|
177
236
|
tokenProgramY: this.tokenProgramY,
|
|
178
237
|
}, { programAddress: this.#programAddress });
|
|
179
|
-
|
|
238
|
+
const claimProtocolFeeIxWithHookAccounts = {
|
|
239
|
+
...claimProtocolFeeIx,
|
|
240
|
+
accounts: [...claimProtocolFeeIx.accounts, ...remainingAccounts],
|
|
241
|
+
};
|
|
242
|
+
return [...preInstructions, claimProtocolFeeIxWithHookAccounts, ...postInstructions];
|
|
180
243
|
}
|
|
181
244
|
static async load(rpc, address, programAddress, config) {
|
|
182
245
|
const pool = await generated.fetchPool(rpc, address, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/entities/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/entities/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAIf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAO/B,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,uBAAuB,CAAC;AAgB/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EACL,QAAQ,EAIT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,SAAS,CAAC;AAEjB,qBAAa,QAAQ;;IAKnB,OAAO,eAQN;IAED,IAAW,OAAO,oBAAoC;IACtD,IAAW,IAAI,uBAAiC;IAChD,IAAW,YAAY,YAAqC;IAC5D,IAAW,SAAS,IAAI,SAAS,QAAQ,EAAE,CAA4B;IAEvE,IAAW,iBAAiB,IAAI;QAAE,aAAa,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;KAAE,CAI9F;IAEM,WAA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,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,EACD,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,WAAW,CAAC,CAWtB"}
|
|
@@ -2,6 +2,7 @@ import { decodeAccount, assertAccountExists, fetchEncodedAccounts, } from "@sola
|
|
|
2
2
|
import { generated } from "..";
|
|
3
3
|
import { applyTransferFee } from "../quote";
|
|
4
4
|
import { findPositionTokenAccount, processAssociatedTokenAccountPair, } from "../utils/ata";
|
|
5
|
+
import { toRemainingAccountMeta } from "../utils/transfer_hook";
|
|
5
6
|
import { getBinIndex, getBinArrayIndex, getPositionBinArrayIndices, } from "../utils/bin_location";
|
|
6
7
|
import { assertRangeWithinRange, assertPositionBelongsToPool, } from "../utils/assert";
|
|
7
8
|
import { isUndefined } from "../utils/type_guards";
|
|
@@ -113,6 +114,25 @@ export class Position {
|
|
|
113
114
|
amountY,
|
|
114
115
|
}),
|
|
115
116
|
]);
|
|
117
|
+
// Both legs move owner -> vault (deposit), signed by owner itself.
|
|
118
|
+
const [transferHookXAccounts, transferHookYAccounts] = await Promise.all([
|
|
119
|
+
this.#pool.resolveTransferHookAccountsX({
|
|
120
|
+
source: tokenOwnerAccountX, mint: this.#pool.tokenMintX, destination: this.#pool.tokenVaultX, owner: owner.address,
|
|
121
|
+
}),
|
|
122
|
+
this.#pool.resolveTransferHookAccountsY({
|
|
123
|
+
source: tokenOwnerAccountY, mint: this.#pool.tokenMintY, destination: this.#pool.tokenVaultY, owner: owner.address,
|
|
124
|
+
}),
|
|
125
|
+
]);
|
|
126
|
+
const groups = [];
|
|
127
|
+
const remainingAccounts = [];
|
|
128
|
+
if (transferHookXAccounts.length > 0) {
|
|
129
|
+
groups.push({ kind: generated.AccountKind.TransferHookX, count: transferHookXAccounts.length });
|
|
130
|
+
remainingAccounts.push(...transferHookXAccounts.map(toRemainingAccountMeta));
|
|
131
|
+
}
|
|
132
|
+
if (transferHookYAccounts.length > 0) {
|
|
133
|
+
groups.push({ kind: generated.AccountKind.TransferHookY, count: transferHookYAccounts.length });
|
|
134
|
+
remainingAccounts.push(...transferHookYAccounts.map(toRemainingAccountMeta));
|
|
135
|
+
}
|
|
116
136
|
const { lowerBinArray, upperBinArray } = this.binArrayAddresses;
|
|
117
137
|
const depositByWeightIx = generated.getDepositByWeightInstruction({
|
|
118
138
|
owner,
|
|
@@ -136,16 +156,40 @@ export class Position {
|
|
|
136
156
|
distributionMode,
|
|
137
157
|
lowerBinId,
|
|
138
158
|
binWeights,
|
|
159
|
+
remainingAccountsScheme: { groups },
|
|
139
160
|
}, {
|
|
140
161
|
programAddress: this.#pool.programAddress
|
|
141
162
|
});
|
|
142
|
-
|
|
163
|
+
const depositByWeightIxWithHookAccounts = {
|
|
164
|
+
...depositByWeightIx,
|
|
165
|
+
accounts: [...depositByWeightIx.accounts, ...remainingAccounts],
|
|
166
|
+
};
|
|
167
|
+
return [...preInstructions, depositByWeightIxWithHookAccounts, ...postInstructions];
|
|
143
168
|
}
|
|
144
169
|
async #buildClaimFeeInstruction(owner, positionTokenAccount, tokenOwnerAccountX, tokenOwnerAccountY, range) {
|
|
145
170
|
const { lowerBinId, upperBinId } = range ?? this.data;
|
|
146
171
|
assertRangeWithinRange({ lowerBinId, upperBinId }, this.data);
|
|
172
|
+
// Both legs move vault -> owner (fee claim), signed by the pool PDA.
|
|
173
|
+
const [transferHookXAccounts, transferHookYAccounts] = await Promise.all([
|
|
174
|
+
this.#pool.resolveTransferHookAccountsX({
|
|
175
|
+
source: this.#pool.tokenVaultX, mint: this.#pool.tokenMintX, destination: tokenOwnerAccountX, owner: this.#pool.address,
|
|
176
|
+
}),
|
|
177
|
+
this.#pool.resolveTransferHookAccountsY({
|
|
178
|
+
source: this.#pool.tokenVaultY, mint: this.#pool.tokenMintY, destination: tokenOwnerAccountY, owner: this.#pool.address,
|
|
179
|
+
}),
|
|
180
|
+
]);
|
|
181
|
+
const groups = [];
|
|
182
|
+
const remainingAccounts = [];
|
|
183
|
+
if (transferHookXAccounts.length > 0) {
|
|
184
|
+
groups.push({ kind: generated.AccountKind.TransferHookX, count: transferHookXAccounts.length });
|
|
185
|
+
remainingAccounts.push(...transferHookXAccounts.map(toRemainingAccountMeta));
|
|
186
|
+
}
|
|
187
|
+
if (transferHookYAccounts.length > 0) {
|
|
188
|
+
groups.push({ kind: generated.AccountKind.TransferHookY, count: transferHookYAccounts.length });
|
|
189
|
+
remainingAccounts.push(...transferHookYAccounts.map(toRemainingAccountMeta));
|
|
190
|
+
}
|
|
147
191
|
const { lowerBinArray, upperBinArray } = this.binArrayAddresses;
|
|
148
|
-
|
|
192
|
+
const claimFeeIx = generated.getClaimFeeInstruction({
|
|
149
193
|
owner,
|
|
150
194
|
pool: this.#pool.address,
|
|
151
195
|
position: this.address,
|
|
@@ -162,9 +206,11 @@ export class Position {
|
|
|
162
206
|
upperBinArray,
|
|
163
207
|
lowerBinId,
|
|
164
208
|
upperBinId,
|
|
209
|
+
remainingAccountsScheme: { groups },
|
|
165
210
|
}, {
|
|
166
211
|
programAddress: this.#pool.programAddress
|
|
167
212
|
});
|
|
213
|
+
return { ...claimFeeIx, accounts: [...claimFeeIx.accounts, ...remainingAccounts] };
|
|
168
214
|
}
|
|
169
215
|
async claimFee(owner, range) {
|
|
170
216
|
const [positionTokenAccount, { ataX: tokenOwnerAccountX, ataY: tokenOwnerAccountY, preInstructions, postInstructions }] = await Promise.all([
|
|
@@ -193,6 +239,25 @@ export class Position {
|
|
|
193
239
|
tokenProgramY: this.#pool.tokenProgramY,
|
|
194
240
|
}),
|
|
195
241
|
]);
|
|
242
|
+
// Both legs move vault -> owner (withdraw), signed by the pool PDA.
|
|
243
|
+
const [transferHookXAccounts, transferHookYAccounts] = await Promise.all([
|
|
244
|
+
this.#pool.resolveTransferHookAccountsX({
|
|
245
|
+
source: this.#pool.tokenVaultX, mint: this.#pool.tokenMintX, destination: tokenOwnerAccountX, owner: this.#pool.address,
|
|
246
|
+
}),
|
|
247
|
+
this.#pool.resolveTransferHookAccountsY({
|
|
248
|
+
source: this.#pool.tokenVaultY, mint: this.#pool.tokenMintY, destination: tokenOwnerAccountY, owner: this.#pool.address,
|
|
249
|
+
}),
|
|
250
|
+
]);
|
|
251
|
+
const groups = [];
|
|
252
|
+
const remainingAccounts = [];
|
|
253
|
+
if (transferHookXAccounts.length > 0) {
|
|
254
|
+
groups.push({ kind: generated.AccountKind.TransferHookX, count: transferHookXAccounts.length });
|
|
255
|
+
remainingAccounts.push(...transferHookXAccounts.map(toRemainingAccountMeta));
|
|
256
|
+
}
|
|
257
|
+
if (transferHookYAccounts.length > 0) {
|
|
258
|
+
groups.push({ kind: generated.AccountKind.TransferHookY, count: transferHookYAccounts.length });
|
|
259
|
+
remainingAccounts.push(...transferHookYAccounts.map(toRemainingAccountMeta));
|
|
260
|
+
}
|
|
196
261
|
const { lowerBinArray, upperBinArray } = this.binArrayAddresses;
|
|
197
262
|
const withdrawIx = generated.getWithdrawInstruction({
|
|
198
263
|
owner,
|
|
@@ -212,10 +277,15 @@ export class Position {
|
|
|
212
277
|
lowerBinId,
|
|
213
278
|
upperBinId,
|
|
214
279
|
bpsToRemove,
|
|
280
|
+
remainingAccountsScheme: { groups },
|
|
215
281
|
}, {
|
|
216
282
|
programAddress: this.#pool.programAddress
|
|
217
283
|
});
|
|
218
|
-
|
|
284
|
+
const withdrawIxWithHookAccounts = {
|
|
285
|
+
...withdrawIx,
|
|
286
|
+
accounts: [...withdrawIx.accounts, ...remainingAccounts],
|
|
287
|
+
};
|
|
288
|
+
return [...preInstructions, withdrawIxWithHookAccounts, ...postInstructions];
|
|
219
289
|
}
|
|
220
290
|
async close(owner) {
|
|
221
291
|
return await closePosition({ owner, positionMint: this.data.positionMint, position: this.address }, { programAddress: this.#pool.programAddress });
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
|
-
import { type AccountMeta, type AccountSignerMeta, type Address, type
|
|
8
|
+
import { type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type Option, type OptionOrNullable, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from "@solana/kit";
|
|
9
9
|
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
10
|
+
import { type RemainingAccountsScheme, type RemainingAccountsSchemeArgs } from "../types";
|
|
10
11
|
export declare const CLAIM_FEE_DISCRIMINATOR: ReadonlyUint8Array;
|
|
11
12
|
export declare function getClaimFeeDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
13
|
export type ClaimFeeInstruction<TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS, TAccountOwner extends string | AccountMeta<string> = string, TAccountPool extends string | AccountMeta<string> = string, TAccountPosition extends string | AccountMeta<string> = string, TAccountPositionTokenAccount extends string | AccountMeta<string> = string, TAccountTokenMintX extends string | AccountMeta<string> = string, TAccountTokenMintY extends string | AccountMeta<string> = string, TAccountTokenOwnerAccountX extends string | AccountMeta<string> = string, TAccountTokenOwnerAccountY extends string | AccountMeta<string> = string, TAccountTokenVaultX extends string | AccountMeta<string> = string, TAccountTokenVaultY extends string | AccountMeta<string> = string, TAccountTokenProgramX extends string | AccountMeta<string> = string, TAccountTokenProgramY extends string | AccountMeta<string> = string, TAccountLowerBinArray extends string | AccountMeta<string> = string, TAccountUpperBinArray extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
|
|
@@ -30,14 +31,16 @@ export type ClaimFeeInstructionData = {
|
|
|
30
31
|
discriminator: ReadonlyUint8Array;
|
|
31
32
|
lowerBinId: number;
|
|
32
33
|
upperBinId: number;
|
|
34
|
+
remainingAccountsScheme: Option<RemainingAccountsScheme>;
|
|
33
35
|
};
|
|
34
36
|
export type ClaimFeeInstructionDataArgs = {
|
|
35
37
|
lowerBinId: number;
|
|
36
38
|
upperBinId: number;
|
|
39
|
+
remainingAccountsScheme: OptionOrNullable<RemainingAccountsSchemeArgs>;
|
|
37
40
|
};
|
|
38
|
-
export declare function getClaimFeeInstructionDataEncoder():
|
|
39
|
-
export declare function getClaimFeeInstructionDataDecoder():
|
|
40
|
-
export declare function getClaimFeeInstructionDataCodec():
|
|
41
|
+
export declare function getClaimFeeInstructionDataEncoder(): Encoder<ClaimFeeInstructionDataArgs>;
|
|
42
|
+
export declare function getClaimFeeInstructionDataDecoder(): Decoder<ClaimFeeInstructionData>;
|
|
43
|
+
export declare function getClaimFeeInstructionDataCodec(): Codec<ClaimFeeInstructionDataArgs, ClaimFeeInstructionData>;
|
|
41
44
|
export type ClaimFeeInput<TAccountOwner extends string = string, TAccountPool extends string = string, TAccountPosition extends string = string, TAccountPositionTokenAccount extends string = string, TAccountTokenMintX extends string = string, TAccountTokenMintY extends string = string, TAccountTokenOwnerAccountX extends string = string, TAccountTokenOwnerAccountY extends string = string, TAccountTokenVaultX extends string = string, TAccountTokenVaultY extends string = string, TAccountTokenProgramX extends string = string, TAccountTokenProgramY extends string = string, TAccountLowerBinArray extends string = string, TAccountUpperBinArray extends string = string> = {
|
|
42
45
|
owner: TransactionSigner<TAccountOwner>;
|
|
43
46
|
pool: Address<TAccountPool>;
|
|
@@ -55,6 +58,7 @@ export type ClaimFeeInput<TAccountOwner extends string = string, TAccountPool ex
|
|
|
55
58
|
upperBinArray?: Address<TAccountUpperBinArray>;
|
|
56
59
|
lowerBinId: ClaimFeeInstructionDataArgs["lowerBinId"];
|
|
57
60
|
upperBinId: ClaimFeeInstructionDataArgs["upperBinId"];
|
|
61
|
+
remainingAccountsScheme: ClaimFeeInstructionDataArgs["remainingAccountsScheme"];
|
|
58
62
|
};
|
|
59
63
|
export declare function getClaimFeeInstruction<TAccountOwner extends string, TAccountPool extends string, TAccountPosition extends string, TAccountPositionTokenAccount extends string, TAccountTokenMintX extends string, TAccountTokenMintY extends string, TAccountTokenOwnerAccountX extends string, TAccountTokenOwnerAccountY extends string, TAccountTokenVaultX extends string, TAccountTokenVaultY extends string, TAccountTokenProgramX extends string, TAccountTokenProgramY extends string, TAccountLowerBinArray extends string, TAccountUpperBinArray extends string, TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS>(input: ClaimFeeInput<TAccountOwner, TAccountPool, TAccountPosition, TAccountPositionTokenAccount, TAccountTokenMintX, TAccountTokenMintY, TAccountTokenOwnerAccountX, TAccountTokenOwnerAccountY, TAccountTokenVaultX, TAccountTokenVaultY, TAccountTokenProgramX, TAccountTokenProgramY, TAccountLowerBinArray, TAccountUpperBinArray>, config?: {
|
|
60
64
|
programAddress?: TProgramAddress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claimFee.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/claimFee.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"claimFee.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/claimFee.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAeL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EACjC,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,uBAAuB,EAAE,kBAEpC,CAAC;AAEH,wBAAgB,6BAA6B,IAAI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EAAE,aAAa,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;KAC/C,CAAC;IACF,IAAI,EAAE,uBAAuB,CAAC;CAC/B,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,QAAQ,SAAS,MAAM,EACvB,aAAa,SAAS,SAAS,WAAW,EAAE,EAE5C,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,GAChC,uBAAuB,CAAC,aAAa,CAAC,GACtC,mBAAmB,CAAC,kBAAkB,CAAC,GACxC,yBAAyB,CAAC,QAAQ,EAAE,aAAa,CAAC,CA0CpD"}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
|
-
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getI32Decoder, getI32Encoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, } from "@solana/kit";
|
|
8
|
+
import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getI32Decoder, getI32Encoder, getOptionDecoder, getOptionEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, } from "@solana/kit";
|
|
9
9
|
import { getAccountMetaFactory, } from "@solana/program-client-core";
|
|
10
10
|
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
11
|
+
import { getRemainingAccountsSchemeDecoder, getRemainingAccountsSchemeEncoder, } from "../types";
|
|
11
12
|
export const CLAIM_FEE_DISCRIMINATOR = new Uint8Array([
|
|
12
13
|
169, 32, 79, 137, 136, 232, 70, 137,
|
|
13
14
|
]);
|
|
@@ -19,6 +20,10 @@ export function getClaimFeeInstructionDataEncoder() {
|
|
|
19
20
|
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
20
21
|
["lowerBinId", getI32Encoder()],
|
|
21
22
|
["upperBinId", getI32Encoder()],
|
|
23
|
+
[
|
|
24
|
+
"remainingAccountsScheme",
|
|
25
|
+
getOptionEncoder(getRemainingAccountsSchemeEncoder()),
|
|
26
|
+
],
|
|
22
27
|
]), (value) => ({ ...value, discriminator: CLAIM_FEE_DISCRIMINATOR }));
|
|
23
28
|
}
|
|
24
29
|
export function getClaimFeeInstructionDataDecoder() {
|
|
@@ -26,6 +31,10 @@ export function getClaimFeeInstructionDataDecoder() {
|
|
|
26
31
|
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
27
32
|
["lowerBinId", getI32Decoder()],
|
|
28
33
|
["upperBinId", getI32Decoder()],
|
|
34
|
+
[
|
|
35
|
+
"remainingAccountsScheme",
|
|
36
|
+
getOptionDecoder(getRemainingAccountsSchemeDecoder()),
|
|
37
|
+
],
|
|
29
38
|
]);
|
|
30
39
|
}
|
|
31
40
|
export function getClaimFeeInstructionDataCodec() {
|