@thru/programs 0.3.15 → 0.3.17
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/amm/index.cjs +235 -28
- package/dist/amm/index.cjs.map +1 -1
- package/dist/amm/index.d.cts +34 -6
- package/dist/amm/index.d.ts +34 -6
- package/dist/amm/index.js +235 -28
- package/dist/amm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/amm/abi/thru/program/amm/types.ts +282 -23
- package/src/amm/index.test.ts +93 -3
- package/src/amm/index.ts +18 -1
package/dist/amm/index.d.cts
CHANGED
|
@@ -128,6 +128,10 @@ declare class AmmAddLiquidityInstruction {
|
|
|
128
128
|
set_max_amount_mint_two(value: bigint): void;
|
|
129
129
|
get max_amount_mint_two(): bigint;
|
|
130
130
|
set max_amount_mint_two(value: bigint);
|
|
131
|
+
get_min_lp_out(): bigint;
|
|
132
|
+
set_min_lp_out(value: bigint): void;
|
|
133
|
+
get min_lp_out(): bigint;
|
|
134
|
+
set min_lp_out(value: bigint);
|
|
131
135
|
private static __tnFootprintInternal;
|
|
132
136
|
private static __tnValidateInternal;
|
|
133
137
|
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
|
|
@@ -141,7 +145,7 @@ declare class AmmAddLiquidityInstruction {
|
|
|
141
145
|
code?: string;
|
|
142
146
|
consumed?: number;
|
|
143
147
|
};
|
|
144
|
-
static new(pool_account_idx: number, depositor_account_idx: number, depositor_token_one_account_idx: number, depositor_token_two_account_idx: number, depositor_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, max_amount_mint_one: bigint, max_amount_mint_two: bigint): AmmAddLiquidityInstruction;
|
|
148
|
+
static new(pool_account_idx: number, depositor_account_idx: number, depositor_token_one_account_idx: number, depositor_token_two_account_idx: number, depositor_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, max_amount_mint_one: bigint, max_amount_mint_two: bigint, min_lp_out: bigint): AmmAddLiquidityInstruction;
|
|
145
149
|
static from_array(buffer: Uint8Array): AmmAddLiquidityInstruction | null;
|
|
146
150
|
}
|
|
147
151
|
declare class AmmAddLiquidityInstructionBuilder {
|
|
@@ -159,6 +163,7 @@ declare class AmmAddLiquidityInstructionBuilder {
|
|
|
159
163
|
set_token_program_account_idx(value: number): this;
|
|
160
164
|
set_max_amount_mint_one(value: bigint): this;
|
|
161
165
|
set_max_amount_mint_two(value: bigint): this;
|
|
166
|
+
set_min_lp_out(value: bigint): this;
|
|
162
167
|
build(): Uint8Array;
|
|
163
168
|
buildInto(target: Uint8Array, offset?: number): Uint8Array;
|
|
164
169
|
finish(): AmmAddLiquidityInstruction;
|
|
@@ -246,6 +251,10 @@ declare class AmmSwapInstruction {
|
|
|
246
251
|
set_amount_in(value: bigint): void;
|
|
247
252
|
get amount_in(): bigint;
|
|
248
253
|
set amount_in(value: bigint);
|
|
254
|
+
get_min_amount_out(): bigint;
|
|
255
|
+
set_min_amount_out(value: bigint): void;
|
|
256
|
+
get min_amount_out(): bigint;
|
|
257
|
+
set min_amount_out(value: bigint);
|
|
249
258
|
private static __tnFootprintInternal;
|
|
250
259
|
private static __tnValidateInternal;
|
|
251
260
|
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
|
|
@@ -259,7 +268,7 @@ declare class AmmSwapInstruction {
|
|
|
259
268
|
code?: string;
|
|
260
269
|
consumed?: number;
|
|
261
270
|
};
|
|
262
|
-
static new(pool_account_idx: number, user_transfer_authority_idx: number, user_input_account_idx: number, user_output_account_idx: number, vault_input_account_idx: number, vault_output_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, amount_in: bigint): AmmSwapInstruction;
|
|
271
|
+
static new(pool_account_idx: number, user_transfer_authority_idx: number, user_input_account_idx: number, user_output_account_idx: number, vault_input_account_idx: number, vault_output_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, amount_in: bigint, min_amount_out: bigint): AmmSwapInstruction;
|
|
263
272
|
static from_array(buffer: Uint8Array): AmmSwapInstruction | null;
|
|
264
273
|
}
|
|
265
274
|
declare class AmmSwapInstructionBuilder {
|
|
@@ -275,6 +284,7 @@ declare class AmmSwapInstructionBuilder {
|
|
|
275
284
|
set_lp_mint_account_idx(value: number): this;
|
|
276
285
|
set_token_program_account_idx(value: number): this;
|
|
277
286
|
set_amount_in(value: bigint): this;
|
|
287
|
+
set_min_amount_out(value: bigint): this;
|
|
278
288
|
build(): Uint8Array;
|
|
279
289
|
buildInto(target: Uint8Array, offset?: number): Uint8Array;
|
|
280
290
|
finish(): AmmSwapInstruction;
|
|
@@ -328,6 +338,14 @@ declare class AmmWithdrawLiquidityInstruction {
|
|
|
328
338
|
set_lp_amount(value: bigint): void;
|
|
329
339
|
get lp_amount(): bigint;
|
|
330
340
|
set lp_amount(value: bigint);
|
|
341
|
+
get_min_amount_one_out(): bigint;
|
|
342
|
+
set_min_amount_one_out(value: bigint): void;
|
|
343
|
+
get min_amount_one_out(): bigint;
|
|
344
|
+
set min_amount_one_out(value: bigint);
|
|
345
|
+
get_min_amount_two_out(): bigint;
|
|
346
|
+
set_min_amount_two_out(value: bigint): void;
|
|
347
|
+
get min_amount_two_out(): bigint;
|
|
348
|
+
set min_amount_two_out(value: bigint);
|
|
331
349
|
private static __tnFootprintInternal;
|
|
332
350
|
private static __tnValidateInternal;
|
|
333
351
|
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
|
|
@@ -341,7 +359,7 @@ declare class AmmWithdrawLiquidityInstruction {
|
|
|
341
359
|
code?: string;
|
|
342
360
|
consumed?: number;
|
|
343
361
|
};
|
|
344
|
-
static new(pool_account_idx: number, withdrawer_account_idx: number, withdrawer_token_one_account_idx: number, withdrawer_token_two_account_idx: number, withdrawer_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, lp_amount: bigint): AmmWithdrawLiquidityInstruction;
|
|
362
|
+
static new(pool_account_idx: number, withdrawer_account_idx: number, withdrawer_token_one_account_idx: number, withdrawer_token_two_account_idx: number, withdrawer_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, lp_amount: bigint, min_amount_one_out: bigint, min_amount_two_out: bigint): AmmWithdrawLiquidityInstruction;
|
|
345
363
|
static from_array(buffer: Uint8Array): AmmWithdrawLiquidityInstruction | null;
|
|
346
364
|
}
|
|
347
365
|
declare class AmmWithdrawLiquidityInstructionBuilder {
|
|
@@ -358,6 +376,8 @@ declare class AmmWithdrawLiquidityInstructionBuilder {
|
|
|
358
376
|
set_lp_mint_account_idx(value: number): this;
|
|
359
377
|
set_token_program_account_idx(value: number): this;
|
|
360
378
|
set_lp_amount(value: bigint): this;
|
|
379
|
+
set_min_amount_one_out(value: bigint): this;
|
|
380
|
+
set_min_amount_two_out(value: bigint): this;
|
|
361
381
|
build(): Uint8Array;
|
|
362
382
|
buildInto(target: Uint8Array, offset?: number): Uint8Array;
|
|
363
383
|
finish(): AmmWithdrawLiquidityInstruction;
|
|
@@ -775,19 +795,19 @@ declare class AmmInstruction {
|
|
|
775
795
|
}, {
|
|
776
796
|
readonly name: "add_liquidity";
|
|
777
797
|
readonly tag: 1;
|
|
778
|
-
readonly payloadSize:
|
|
798
|
+
readonly payloadSize: 42;
|
|
779
799
|
readonly payloadType: "AmmInstruction::payload::add_liquidity";
|
|
780
800
|
readonly createPayloadBuilder: () => unknown;
|
|
781
801
|
}, {
|
|
782
802
|
readonly name: "withdraw_liquidity";
|
|
783
803
|
readonly tag: 2;
|
|
784
|
-
readonly payloadSize:
|
|
804
|
+
readonly payloadSize: 42;
|
|
785
805
|
readonly payloadType: "AmmInstruction::payload::withdraw_liquidity";
|
|
786
806
|
readonly createPayloadBuilder: () => unknown;
|
|
787
807
|
}, {
|
|
788
808
|
readonly name: "swap";
|
|
789
809
|
readonly tag: 3;
|
|
790
|
-
readonly payloadSize:
|
|
810
|
+
readonly payloadSize: 32;
|
|
791
811
|
readonly payloadType: "AmmInstruction::payload::swap";
|
|
792
812
|
readonly createPayloadBuilder: () => unknown;
|
|
793
813
|
}];
|
|
@@ -1377,6 +1397,8 @@ interface AddLiquidityArgs {
|
|
|
1377
1397
|
tokenProgramAccountBytes: Uint8Array;
|
|
1378
1398
|
maxAmountMintOne: bigint;
|
|
1379
1399
|
maxAmountMintTwo: bigint;
|
|
1400
|
+
/** Inclusive minimum LP output; zero explicitly disables this bound. */
|
|
1401
|
+
minLpOut: bigint;
|
|
1380
1402
|
}
|
|
1381
1403
|
interface WithdrawLiquidityArgs {
|
|
1382
1404
|
poolAccountBytes: Uint8Array;
|
|
@@ -1389,6 +1411,10 @@ interface WithdrawLiquidityArgs {
|
|
|
1389
1411
|
lpMintAccountBytes: Uint8Array;
|
|
1390
1412
|
tokenProgramAccountBytes: Uint8Array;
|
|
1391
1413
|
lpAmount: bigint;
|
|
1414
|
+
/** Inclusive minimum token-one output; zero explicitly disables this bound. */
|
|
1415
|
+
minAmountOneOut: bigint;
|
|
1416
|
+
/** Inclusive minimum token-two output; zero explicitly disables this bound. */
|
|
1417
|
+
minAmountTwoOut: bigint;
|
|
1392
1418
|
}
|
|
1393
1419
|
interface SwapArgs {
|
|
1394
1420
|
poolAccountBytes: Uint8Array;
|
|
@@ -1400,6 +1426,8 @@ interface SwapArgs {
|
|
|
1400
1426
|
lpMintAccountBytes: Uint8Array;
|
|
1401
1427
|
tokenProgramAccountBytes: Uint8Array;
|
|
1402
1428
|
amountIn: bigint;
|
|
1429
|
+
/** Inclusive minimum swap output; zero explicitly disables this bound. */
|
|
1430
|
+
minAmountOut: bigint;
|
|
1403
1431
|
}
|
|
1404
1432
|
declare function sortAmmMints(mintA: Uint8Array | string, mintB: Uint8Array | string): SortedAmmMints;
|
|
1405
1433
|
declare function deriveAmmLpMintSeed(thru: Thru, poolBytes: Uint8Array | string): Uint8Array;
|
package/dist/amm/index.d.ts
CHANGED
|
@@ -128,6 +128,10 @@ declare class AmmAddLiquidityInstruction {
|
|
|
128
128
|
set_max_amount_mint_two(value: bigint): void;
|
|
129
129
|
get max_amount_mint_two(): bigint;
|
|
130
130
|
set max_amount_mint_two(value: bigint);
|
|
131
|
+
get_min_lp_out(): bigint;
|
|
132
|
+
set_min_lp_out(value: bigint): void;
|
|
133
|
+
get min_lp_out(): bigint;
|
|
134
|
+
set min_lp_out(value: bigint);
|
|
131
135
|
private static __tnFootprintInternal;
|
|
132
136
|
private static __tnValidateInternal;
|
|
133
137
|
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
|
|
@@ -141,7 +145,7 @@ declare class AmmAddLiquidityInstruction {
|
|
|
141
145
|
code?: string;
|
|
142
146
|
consumed?: number;
|
|
143
147
|
};
|
|
144
|
-
static new(pool_account_idx: number, depositor_account_idx: number, depositor_token_one_account_idx: number, depositor_token_two_account_idx: number, depositor_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, max_amount_mint_one: bigint, max_amount_mint_two: bigint): AmmAddLiquidityInstruction;
|
|
148
|
+
static new(pool_account_idx: number, depositor_account_idx: number, depositor_token_one_account_idx: number, depositor_token_two_account_idx: number, depositor_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, max_amount_mint_one: bigint, max_amount_mint_two: bigint, min_lp_out: bigint): AmmAddLiquidityInstruction;
|
|
145
149
|
static from_array(buffer: Uint8Array): AmmAddLiquidityInstruction | null;
|
|
146
150
|
}
|
|
147
151
|
declare class AmmAddLiquidityInstructionBuilder {
|
|
@@ -159,6 +163,7 @@ declare class AmmAddLiquidityInstructionBuilder {
|
|
|
159
163
|
set_token_program_account_idx(value: number): this;
|
|
160
164
|
set_max_amount_mint_one(value: bigint): this;
|
|
161
165
|
set_max_amount_mint_two(value: bigint): this;
|
|
166
|
+
set_min_lp_out(value: bigint): this;
|
|
162
167
|
build(): Uint8Array;
|
|
163
168
|
buildInto(target: Uint8Array, offset?: number): Uint8Array;
|
|
164
169
|
finish(): AmmAddLiquidityInstruction;
|
|
@@ -246,6 +251,10 @@ declare class AmmSwapInstruction {
|
|
|
246
251
|
set_amount_in(value: bigint): void;
|
|
247
252
|
get amount_in(): bigint;
|
|
248
253
|
set amount_in(value: bigint);
|
|
254
|
+
get_min_amount_out(): bigint;
|
|
255
|
+
set_min_amount_out(value: bigint): void;
|
|
256
|
+
get min_amount_out(): bigint;
|
|
257
|
+
set min_amount_out(value: bigint);
|
|
249
258
|
private static __tnFootprintInternal;
|
|
250
259
|
private static __tnValidateInternal;
|
|
251
260
|
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
|
|
@@ -259,7 +268,7 @@ declare class AmmSwapInstruction {
|
|
|
259
268
|
code?: string;
|
|
260
269
|
consumed?: number;
|
|
261
270
|
};
|
|
262
|
-
static new(pool_account_idx: number, user_transfer_authority_idx: number, user_input_account_idx: number, user_output_account_idx: number, vault_input_account_idx: number, vault_output_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, amount_in: bigint): AmmSwapInstruction;
|
|
271
|
+
static new(pool_account_idx: number, user_transfer_authority_idx: number, user_input_account_idx: number, user_output_account_idx: number, vault_input_account_idx: number, vault_output_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, amount_in: bigint, min_amount_out: bigint): AmmSwapInstruction;
|
|
263
272
|
static from_array(buffer: Uint8Array): AmmSwapInstruction | null;
|
|
264
273
|
}
|
|
265
274
|
declare class AmmSwapInstructionBuilder {
|
|
@@ -275,6 +284,7 @@ declare class AmmSwapInstructionBuilder {
|
|
|
275
284
|
set_lp_mint_account_idx(value: number): this;
|
|
276
285
|
set_token_program_account_idx(value: number): this;
|
|
277
286
|
set_amount_in(value: bigint): this;
|
|
287
|
+
set_min_amount_out(value: bigint): this;
|
|
278
288
|
build(): Uint8Array;
|
|
279
289
|
buildInto(target: Uint8Array, offset?: number): Uint8Array;
|
|
280
290
|
finish(): AmmSwapInstruction;
|
|
@@ -328,6 +338,14 @@ declare class AmmWithdrawLiquidityInstruction {
|
|
|
328
338
|
set_lp_amount(value: bigint): void;
|
|
329
339
|
get lp_amount(): bigint;
|
|
330
340
|
set lp_amount(value: bigint);
|
|
341
|
+
get_min_amount_one_out(): bigint;
|
|
342
|
+
set_min_amount_one_out(value: bigint): void;
|
|
343
|
+
get min_amount_one_out(): bigint;
|
|
344
|
+
set min_amount_one_out(value: bigint);
|
|
345
|
+
get_min_amount_two_out(): bigint;
|
|
346
|
+
set_min_amount_two_out(value: bigint): void;
|
|
347
|
+
get min_amount_two_out(): bigint;
|
|
348
|
+
set min_amount_two_out(value: bigint);
|
|
331
349
|
private static __tnFootprintInternal;
|
|
332
350
|
private static __tnValidateInternal;
|
|
333
351
|
static __tnInvokeFootprint(__tnParams: Record<string, bigint>): bigint;
|
|
@@ -341,7 +359,7 @@ declare class AmmWithdrawLiquidityInstruction {
|
|
|
341
359
|
code?: string;
|
|
342
360
|
consumed?: number;
|
|
343
361
|
};
|
|
344
|
-
static new(pool_account_idx: number, withdrawer_account_idx: number, withdrawer_token_one_account_idx: number, withdrawer_token_two_account_idx: number, withdrawer_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, lp_amount: bigint): AmmWithdrawLiquidityInstruction;
|
|
362
|
+
static new(pool_account_idx: number, withdrawer_account_idx: number, withdrawer_token_one_account_idx: number, withdrawer_token_two_account_idx: number, withdrawer_lp_account_idx: number, vault_one_account_idx: number, vault_two_account_idx: number, lp_mint_account_idx: number, token_program_account_idx: number, lp_amount: bigint, min_amount_one_out: bigint, min_amount_two_out: bigint): AmmWithdrawLiquidityInstruction;
|
|
345
363
|
static from_array(buffer: Uint8Array): AmmWithdrawLiquidityInstruction | null;
|
|
346
364
|
}
|
|
347
365
|
declare class AmmWithdrawLiquidityInstructionBuilder {
|
|
@@ -358,6 +376,8 @@ declare class AmmWithdrawLiquidityInstructionBuilder {
|
|
|
358
376
|
set_lp_mint_account_idx(value: number): this;
|
|
359
377
|
set_token_program_account_idx(value: number): this;
|
|
360
378
|
set_lp_amount(value: bigint): this;
|
|
379
|
+
set_min_amount_one_out(value: bigint): this;
|
|
380
|
+
set_min_amount_two_out(value: bigint): this;
|
|
361
381
|
build(): Uint8Array;
|
|
362
382
|
buildInto(target: Uint8Array, offset?: number): Uint8Array;
|
|
363
383
|
finish(): AmmWithdrawLiquidityInstruction;
|
|
@@ -775,19 +795,19 @@ declare class AmmInstruction {
|
|
|
775
795
|
}, {
|
|
776
796
|
readonly name: "add_liquidity";
|
|
777
797
|
readonly tag: 1;
|
|
778
|
-
readonly payloadSize:
|
|
798
|
+
readonly payloadSize: 42;
|
|
779
799
|
readonly payloadType: "AmmInstruction::payload::add_liquidity";
|
|
780
800
|
readonly createPayloadBuilder: () => unknown;
|
|
781
801
|
}, {
|
|
782
802
|
readonly name: "withdraw_liquidity";
|
|
783
803
|
readonly tag: 2;
|
|
784
|
-
readonly payloadSize:
|
|
804
|
+
readonly payloadSize: 42;
|
|
785
805
|
readonly payloadType: "AmmInstruction::payload::withdraw_liquidity";
|
|
786
806
|
readonly createPayloadBuilder: () => unknown;
|
|
787
807
|
}, {
|
|
788
808
|
readonly name: "swap";
|
|
789
809
|
readonly tag: 3;
|
|
790
|
-
readonly payloadSize:
|
|
810
|
+
readonly payloadSize: 32;
|
|
791
811
|
readonly payloadType: "AmmInstruction::payload::swap";
|
|
792
812
|
readonly createPayloadBuilder: () => unknown;
|
|
793
813
|
}];
|
|
@@ -1377,6 +1397,8 @@ interface AddLiquidityArgs {
|
|
|
1377
1397
|
tokenProgramAccountBytes: Uint8Array;
|
|
1378
1398
|
maxAmountMintOne: bigint;
|
|
1379
1399
|
maxAmountMintTwo: bigint;
|
|
1400
|
+
/** Inclusive minimum LP output; zero explicitly disables this bound. */
|
|
1401
|
+
minLpOut: bigint;
|
|
1380
1402
|
}
|
|
1381
1403
|
interface WithdrawLiquidityArgs {
|
|
1382
1404
|
poolAccountBytes: Uint8Array;
|
|
@@ -1389,6 +1411,10 @@ interface WithdrawLiquidityArgs {
|
|
|
1389
1411
|
lpMintAccountBytes: Uint8Array;
|
|
1390
1412
|
tokenProgramAccountBytes: Uint8Array;
|
|
1391
1413
|
lpAmount: bigint;
|
|
1414
|
+
/** Inclusive minimum token-one output; zero explicitly disables this bound. */
|
|
1415
|
+
minAmountOneOut: bigint;
|
|
1416
|
+
/** Inclusive minimum token-two output; zero explicitly disables this bound. */
|
|
1417
|
+
minAmountTwoOut: bigint;
|
|
1392
1418
|
}
|
|
1393
1419
|
interface SwapArgs {
|
|
1394
1420
|
poolAccountBytes: Uint8Array;
|
|
@@ -1400,6 +1426,8 @@ interface SwapArgs {
|
|
|
1400
1426
|
lpMintAccountBytes: Uint8Array;
|
|
1401
1427
|
tokenProgramAccountBytes: Uint8Array;
|
|
1402
1428
|
amountIn: bigint;
|
|
1429
|
+
/** Inclusive minimum swap output; zero explicitly disables this bound. */
|
|
1430
|
+
minAmountOut: bigint;
|
|
1403
1431
|
}
|
|
1404
1432
|
declare function sortAmmMints(mintA: Uint8Array | string, mintB: Uint8Array | string): SortedAmmMints;
|
|
1405
1433
|
declare function deriveAmmLpMintSeed(thru: Thru, poolBytes: Uint8Array | string): Uint8Array;
|