wasabi-solana-ts 1.2.3 → 1.2.5

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.
Files changed (91) hide show
  1. package/dist/base/base.d.ts +2 -2
  2. package/dist/cache/BaseAccountCache.d.ts +44 -0
  3. package/dist/cache/BaseAccountCache.js +80 -0
  4. package/dist/cache/TokenMintCache.d.ts +14 -0
  5. package/dist/cache/TokenMintCache.js +25 -0
  6. package/dist/cache/index.d.ts +2 -0
  7. package/dist/{sender-provider → cache}/index.js +2 -5
  8. package/dist/index.d.ts +4 -3
  9. package/dist/index.js +1 -0
  10. package/dist/instructions/closeLongPosition.d.ts +3 -3
  11. package/dist/instructions/closePosition.d.ts +2 -2
  12. package/dist/instructions/closePositionV2.d.ts +2 -2
  13. package/dist/instructions/closeShortPosition.d.ts +3 -3
  14. package/dist/instructions/donate.d.ts +2 -2
  15. package/dist/instructions/increaseLongPositionSetup.d.ts +2 -2
  16. package/dist/instructions/increaseShortPositionSetup.d.ts +2 -2
  17. package/dist/instructions/initPool.d.ts +2 -2
  18. package/dist/instructions/liquidatePosition.d.ts +3 -3
  19. package/dist/instructions/liquidatePositionV2.d.ts +2 -2
  20. package/dist/instructions/openLongPosition.d.ts +3 -3
  21. package/dist/instructions/openLongPosition.js +1 -1
  22. package/dist/instructions/openShortPosition.d.ts +3 -3
  23. package/dist/instructions/openShortPosition.js +1 -1
  24. package/dist/instructions/stopLoss.d.ts +3 -3
  25. package/dist/instructions/stopLossV2.d.ts +2 -2
  26. package/dist/instructions/takeProfit.d.ts +3 -3
  27. package/dist/instructions/takeProfitV2.d.ts +2 -2
  28. package/dist/utils/index.d.ts +0 -1
  29. package/dist/utils/index.js +0 -1
  30. package/dist/utils/utils.d.ts +10 -11
  31. package/dist/utils/utils.js +36 -64
  32. package/package.json +5 -3
  33. package/dist/instructions/closeWallet.d.ts +0 -20
  34. package/dist/instructions/closeWallet.js +0 -34
  35. package/dist/instructions/collectFees.d.ts +0 -22
  36. package/dist/instructions/collectFees.js +0 -40
  37. package/dist/instructions/generateWallet.d.ts +0 -22
  38. package/dist/instructions/generateWallet.js +0 -36
  39. package/dist/instructions/increaseShortPosition.d.ts +0 -6
  40. package/dist/instructions/increaseShortPosition.js +0 -70
  41. package/dist/instructions/initDebtController.d.ts +0 -24
  42. package/dist/instructions/initDebtController.js +0 -37
  43. package/dist/instructions/initGlobalSettings.d.ts +0 -9
  44. package/dist/instructions/initGlobalSettings.js +0 -32
  45. package/dist/instructions/initOrUpdatePermission.d.ts +0 -22
  46. package/dist/instructions/initOrUpdatePermission.js +0 -48
  47. package/dist/instructions/initStopLossOrder.d.ts +0 -12
  48. package/dist/instructions/initStopLossOrder.js +0 -40
  49. package/dist/instructions/initTakeProfitOrder.d.ts +0 -12
  50. package/dist/instructions/initTakeProfitOrder.js +0 -40
  51. package/dist/instructions/mint.d.ts +0 -8
  52. package/dist/instructions/mint.js +0 -35
  53. package/dist/instructions/removePermission.d.ts +0 -16
  54. package/dist/instructions/removePermission.js +0 -25
  55. package/dist/instructions/repay.d.ts +0 -11
  56. package/dist/instructions/repay.js +0 -44
  57. package/dist/instructions/setLpState.d.ts +0 -11
  58. package/dist/instructions/setLpState.js +0 -28
  59. package/dist/instructions/setMaxApy.d.ts +0 -11
  60. package/dist/instructions/setMaxApy.js +0 -31
  61. package/dist/instructions/setMaxLeverage.d.ts +0 -11
  62. package/dist/instructions/setMaxLeverage.js +0 -31
  63. package/dist/instructions/setSuperAdmin.d.ts +0 -11
  64. package/dist/instructions/setSuperAdmin.js +0 -27
  65. package/dist/instructions/setTradeState.d.ts +0 -11
  66. package/dist/instructions/setTradeState.js +0 -28
  67. package/dist/instructions/swap.d.ts +0 -30
  68. package/dist/instructions/swap.js +0 -91
  69. package/dist/instructions/swapJupiter.d.ts +0 -90
  70. package/dist/instructions/swapJupiter.js +0 -61
  71. package/dist/instructions/swapRaydium.d.ts +0 -38
  72. package/dist/instructions/swapRaydium.js +0 -170
  73. package/dist/instructions/updateLongPosition.d.ts +0 -6
  74. package/dist/instructions/updateLongPosition.js +0 -69
  75. package/dist/instructions/updateLpVaultMaxBorrow.d.ts +0 -12
  76. package/dist/instructions/updateLpVaultMaxBorrow.js +0 -35
  77. package/dist/sender-provider/baseSenderProvider.d.ts +0 -42
  78. package/dist/sender-provider/baseSenderProvider.js +0 -178
  79. package/dist/sender-provider/index.d.ts +0 -5
  80. package/dist/sender-provider/jitoBrowser.d.ts +0 -2
  81. package/dist/sender-provider/jitoBrowser.js +0 -32
  82. package/dist/sender-provider/jitoSenderProvider.d.ts +0 -5
  83. package/dist/sender-provider/jitoSenderProvider.js +0 -69
  84. package/dist/sender-provider/jitoServer.d.ts +0 -2
  85. package/dist/sender-provider/jitoServer.js +0 -67
  86. package/dist/sender-provider/jitoTips.d.ts +0 -17
  87. package/dist/sender-provider/jitoTips.js +0 -75
  88. package/dist/sender-provider/jitoTypes.d.ts +0 -12
  89. package/dist/sender-provider/jitoTypes.js +0 -6
  90. package/dist/utils/mintCache.d.ts +0 -10
  91. package/dist/utils/mintCache.js +0 -39
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInitStopLossInstruction = createInitStopLossInstruction;
4
- exports.initStopLoss = initStopLoss;
5
- const anchor_1 = require("@coral-xyz/anchor");
6
- const web3_js_1 = require("@solana/web3.js");
7
- const base_1 = require("../base");
8
- const utils_1 = require("../utils");
9
- const initStopLossConfig = {
10
- process: async (config) => {
11
- const trader = await config.program.account.position
12
- .fetch(config.accounts.position)
13
- .then((pos) => pos.trader);
14
- const allAccounts = {
15
- trader,
16
- position: config.accounts.position,
17
- stopLossOrder: utils_1.PDA.getStopLossOrder(config.accounts.position),
18
- systemProgram: web3_js_1.SystemProgram.programId
19
- };
20
- return {
21
- accounts: config.strict
22
- ? allAccounts
23
- : {
24
- trader,
25
- position: allAccounts.position
26
- },
27
- args: {
28
- makerAmount: new anchor_1.BN(config.args.makerAmount),
29
- takerAmount: new anchor_1.BN(config.args.takerAmount)
30
- }
31
- };
32
- },
33
- getMethod: (program) => (args) => program.methods.initStopLossOrder(args.makerAmount, args.takerAmount)
34
- };
35
- function createInitStopLossInstruction(program, args, accounts, strict = true, increaseCompute = false) {
36
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initStopLossConfig, 'instruction', strict, increaseCompute, args));
37
- }
38
- function initStopLoss(program, args, accounts, strict = true, increaseCompute = false) {
39
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initStopLossConfig, 'transaction', strict, increaseCompute, args));
40
- }
@@ -1,12 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionSignature, TransactionInstruction, PublicKey } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type InitTakeProfitArgs = {
5
- makerAmount: number;
6
- takerAmount: number;
7
- };
8
- export type InitTakeProfitAccounts = {
9
- position: PublicKey;
10
- };
11
- export declare function createInitTakeProfitInstruction(program: Program<WasabiSolana>, args: InitTakeProfitArgs, accounts: InitTakeProfitAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
12
- export declare function initTakeProfit(program: Program<WasabiSolana>, args: InitTakeProfitArgs, accounts: InitTakeProfitAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInitTakeProfitInstruction = createInitTakeProfitInstruction;
4
- exports.initTakeProfit = initTakeProfit;
5
- const anchor_1 = require("@coral-xyz/anchor");
6
- const web3_js_1 = require("@solana/web3.js");
7
- const base_1 = require("../base");
8
- const utils_1 = require("../utils");
9
- const initTakeProfitConfig = {
10
- process: async (config) => {
11
- const trader = await config.program.account.position
12
- .fetch(config.accounts.position)
13
- .then((pos) => pos.trader);
14
- const allAccounts = {
15
- trader,
16
- position: config.accounts.position,
17
- stopLossOrder: utils_1.PDA.getTakeProfitOrder(config.accounts.position),
18
- systemProgram: web3_js_1.SystemProgram.programId
19
- };
20
- return {
21
- accounts: config.strict
22
- ? allAccounts
23
- : {
24
- trader,
25
- position: allAccounts.position
26
- },
27
- args: {
28
- makerAmount: new anchor_1.BN(config.args.makerAmount),
29
- takerAmount: new anchor_1.BN(config.args.takerAmount)
30
- }
31
- };
32
- },
33
- getMethod: (program) => (args) => program.methods.initTakeProfitOrder(args.makerAmount, args.takerAmount)
34
- };
35
- function createInitTakeProfitInstruction(program, args, accounts, strict = true, increaseCompute = false) {
36
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initTakeProfitConfig, 'instruction', strict, increaseCompute, args));
37
- }
38
- function initTakeProfit(program, args, accounts, strict = true, increaseCompute = false) {
39
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initTakeProfitConfig, 'transaction', strict, increaseCompute, args));
40
- }
@@ -1,8 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionSignature, TransactionInstruction } from '@solana/web3.js';
3
- import { BaseMethodConfig } from '../base';
4
- import { MintArgs, MintAccounts, TokenInstructionAccounts, TokenInstructionAccountsStrict } from './tokenAccounts';
5
- import { WasabiSolana } from '../idl/wasabi_solana';
6
- export declare const mintConfig: BaseMethodConfig<MintArgs, MintAccounts, TokenInstructionAccounts | TokenInstructionAccountsStrict>;
7
- export declare function createMintInstruction(program: Program<WasabiSolana>, args: MintArgs, accounts: MintAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
8
- export declare function mint(program: Program<WasabiSolana>, args: MintArgs, accounts: MintAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mintConfig = void 0;
4
- exports.createMintInstruction = createMintInstruction;
5
- exports.mint = mint;
6
- const anchor_1 = require("@coral-xyz/anchor");
7
- const base_1 = require("../base");
8
- const tokenAccounts_1 = require("./tokenAccounts");
9
- const utils_1 = require("../utils");
10
- exports.mintConfig = {
11
- process: async (config) => {
12
- const { mint, tokenProgram, setupIx, cleanupIx, } = await (0, utils_1.handleMint)(config.program.provider.connection, config.accounts.assetMint, config.program.provider.publicKey, 'wrap', config.args.amount);
13
- const allAccounts = await (0, tokenAccounts_1.getTokenInstructionAccounts)(config.program, mint, tokenProgram);
14
- return {
15
- accounts: config.strict
16
- ? allAccounts
17
- : {
18
- owner: config.program.provider.publicKey,
19
- lpVault: allAccounts.lpVault,
20
- assetMint: mint,
21
- assetTokenProgram: tokenProgram,
22
- },
23
- args: config.args ? new anchor_1.BN(config.args.amount.toString()) : undefined,
24
- setup: setupIx,
25
- cleanup: cleanupIx,
26
- };
27
- },
28
- getMethod: (program) => (args) => program.methods.mint(args)
29
- };
30
- async function createMintInstruction(program, args, accounts, strict = true, increaseCompute = false) {
31
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.mintConfig, 'instruction', strict, increaseCompute, args));
32
- }
33
- async function mint(program, args, accounts, strict = true, increaseCompute = false) {
34
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.mintConfig, 'transaction', strict, increaseCompute, args));
35
- }
@@ -1,16 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionInstruction, TransactionSignature, PublicKey } from '@solana/web3.js';
3
- import { BaseMethodConfig } from '../base';
4
- import { WasabiSolana } from '../idl/wasabi_solana';
5
- export type RemovePermissionAccounts = {
6
- permission: PublicKey;
7
- };
8
- type RemovePermissionInstructionAccounts = {
9
- authority: PublicKey;
10
- superAdminPermission: PublicKey;
11
- permission: PublicKey;
12
- };
13
- export declare const removePermissionConfig: BaseMethodConfig<null, RemovePermissionAccounts, RemovePermissionInstructionAccounts | null>;
14
- export declare function createRemovePermissionInstruction(program: Program<WasabiSolana>, accounts: RemovePermissionAccounts, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
15
- export declare function removePermission(program: Program<WasabiSolana>, accounts: RemovePermissionAccounts, increaseCompute?: boolean): Promise<TransactionSignature>;
16
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removePermissionConfig = void 0;
4
- exports.createRemovePermissionInstruction = createRemovePermissionInstruction;
5
- exports.removePermission = removePermission;
6
- const base_1 = require("../base");
7
- const utils_1 = require("../utils");
8
- exports.removePermissionConfig = {
9
- process: async (config) => {
10
- return {
11
- accounts: {
12
- authority: config.program.provider.publicKey,
13
- superAdminPermission: utils_1.PDA.getSuperAdmin(),
14
- permission: config.accounts.permission,
15
- },
16
- };
17
- },
18
- getMethod: (program) => () => program.methods.removePermission()
19
- };
20
- async function createRemovePermissionInstruction(program, accounts, increaseCompute = false) {
21
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.removePermissionConfig, 'INSTRUCTION', null, increaseCompute));
22
- }
23
- async function removePermission(program, accounts, increaseCompute = false) {
24
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.removePermissionConfig, 'INSTRUCTION', null, increaseCompute));
25
- }
@@ -1,11 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionSignature, TransactionInstruction, PublicKey } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type RepayArgs = {
5
- amount: number | bigint;
6
- };
7
- export type RepayAccounts = {
8
- mint: PublicKey;
9
- };
10
- export declare function createRepayInstruction(program: Program<WasabiSolana>, args: RepayArgs, accounts: RepayAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
11
- export declare function repay(program: Program<WasabiSolana>, args: RepayArgs, accounts: RepayAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRepayInstruction = createRepayInstruction;
4
- exports.repay = repay;
5
- const anchor_1 = require("@coral-xyz/anchor");
6
- const spl_token_1 = require("@solana/spl-token");
7
- const base_1 = require("../base");
8
- const utils_1 = require("../utils");
9
- const repayConfig = {
10
- process: async (config) => {
11
- const { mint, tokenProgram, setupIx, cleanupIx, } = await (0, utils_1.handleMint)(config.program.provider.connection, config.accounts.mint, config.program.provider.publicKey, 'wrap');
12
- const lpVault = utils_1.PDA.getLpVault(mint);
13
- const lpVaultInfo = await config.program.account.lpVault.fetch(lpVault);
14
- const allAccounts = {
15
- payer: config.program.provider.publicKey,
16
- mint,
17
- source: (0, spl_token_1.getAssociatedTokenAddressSync)(mint, config.program.provider.publicKey, false, tokenProgram),
18
- lpVault,
19
- vault: (0, spl_token_1.getAssociatedTokenAddressSync)(mint, lpVault, true, tokenProgram),
20
- tokenProgram
21
- };
22
- return {
23
- accounts: config.strict
24
- ? allAccounts
25
- : {
26
- payer: allAccounts.payer,
27
- mint: allAccounts.mint,
28
- source: allAccounts.source,
29
- lpVault,
30
- tokenProgram
31
- },
32
- args: lpVaultInfo.totalBorrowed.add(new anchor_1.BN(config.args.amount.toString())),
33
- setup: setupIx,
34
- cleanup: cleanupIx,
35
- };
36
- },
37
- getMethod: (program) => (args) => program.methods.repay(args)
38
- };
39
- async function createRepayInstruction(program, args, accounts, strict = true, increaseCompute = false) {
40
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, repayConfig, 'instruction', strict, increaseCompute, args));
41
- }
42
- async function repay(program, args, accounts, strict = true, increaseCompute = false) {
43
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, repayConfig, 'transaction', strict, increaseCompute, args));
44
- }
@@ -1,11 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { PublicKey, TransactionSignature, TransactionInstruction } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type LpStateArgs = {
5
- allow_trading: boolean;
6
- };
7
- export type LpStateAccounts = {
8
- authority: PublicKey;
9
- };
10
- export declare function createSetLpStateInstruction(program: Program<WasabiSolana>, args: LpStateArgs, accounts: LpStateAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
11
- export declare function setLpState(program: Program<WasabiSolana>, args: LpStateArgs, accounts: LpStateAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSetLpStateInstruction = createSetLpStateInstruction;
4
- exports.setLpState = setLpState;
5
- const base_1 = require("../base");
6
- const utils_1 = require("../utils");
7
- const tradeStateConfig = {
8
- process: async (config) => {
9
- const allAccounts = {
10
- authority: config.accounts.authority,
11
- globalSettings: utils_1.PDA.getGlobalSettings(),
12
- superAdmin: utils_1.PDA.getSuperAdmin()
13
- };
14
- return {
15
- accounts: config.strict ? allAccounts : {
16
- authority: allAccounts.authority,
17
- },
18
- args: config.args.allow_trading
19
- };
20
- },
21
- getMethod: (program) => (args) => program.methods.setLpState(args),
22
- };
23
- async function createSetLpStateInstruction(program, args, accounts, strict = true, increaseCompute = false) {
24
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, tradeStateConfig, 'INSTRUCTION', strict, increaseCompute, args));
25
- }
26
- async function setLpState(program, args, accounts, strict = true, increaseCompute = false) {
27
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, tradeStateConfig, 'TRANSACTION', strict, increaseCompute, args));
28
- }
@@ -1,11 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionSignature, TransactionInstruction, PublicKey } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type SetMaxApyArgs = {
5
- maxApy: number;
6
- };
7
- export type SetMaxApyAccounts = {
8
- authority: PublicKey;
9
- };
10
- export declare function createSetMaxApyInstruction(program: Program<WasabiSolana>, args: SetMaxApyArgs, accounts: SetMaxApyAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
11
- export declare function setMaxApy(program: Program<WasabiSolana>, args: SetMaxApyArgs, accounts: SetMaxApyAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSetMaxApyInstruction = createSetMaxApyInstruction;
4
- exports.setMaxApy = setMaxApy;
5
- const anchor_1 = require("@coral-xyz/anchor");
6
- const base_1 = require("../base");
7
- const utils_1 = require("../utils");
8
- const setMaxApyConfig = {
9
- process: async (config) => {
10
- const allAccounts = {
11
- authority: config.accounts.authority,
12
- superAdminPermission: utils_1.PDA.getSuperAdmin(),
13
- debtController: utils_1.PDA.getDebtController()
14
- };
15
- return {
16
- accounts: config.strict
17
- ? allAccounts
18
- : {
19
- authority: config.accounts.authority
20
- },
21
- args: config.args ? new anchor_1.BN(config.args.maxApy) : undefined
22
- };
23
- },
24
- getMethod: (program) => (args) => program.methods.setMaxApy(args)
25
- };
26
- async function createSetMaxApyInstruction(program, args, accounts, strict = true, increaseCompute = false) {
27
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, setMaxApyConfig, 'INSTRUCTION', strict, increaseCompute, args));
28
- }
29
- async function setMaxApy(program, args, accounts, strict = true, increaseCompute = false) {
30
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, setMaxApyConfig, 'TRANSACTION', strict, increaseCompute, args));
31
- }
@@ -1,11 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionInstruction, TransactionSignature, PublicKey } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type SetMaxLeverageArgs = {
5
- maxLeverage: number;
6
- };
7
- export type SetMaxLeverageAccounts = {
8
- authority: PublicKey;
9
- };
10
- export declare function createSetMaxLeverageInstruction(program: Program<WasabiSolana>, args: SetMaxLeverageArgs, accounts: SetMaxLeverageAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
11
- export declare function setMaxLeverage(program: Program<WasabiSolana>, args: SetMaxLeverageArgs, accounts: SetMaxLeverageAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSetMaxLeverageInstruction = createSetMaxLeverageInstruction;
4
- exports.setMaxLeverage = setMaxLeverage;
5
- const anchor_1 = require("@coral-xyz/anchor");
6
- const base_1 = require("../base");
7
- const utils_1 = require("../utils");
8
- const setMaxLeverageConfig = {
9
- process: async (config) => {
10
- const allAccounts = {
11
- authority: config.accounts.authority,
12
- superAdminPermission: utils_1.PDA.getSuperAdmin(),
13
- debtController: utils_1.PDA.getDebtController()
14
- };
15
- return {
16
- accounts: config.strict
17
- ? allAccounts
18
- : {
19
- authority: config.accounts.authority
20
- },
21
- args: config.args ? new anchor_1.BN(config.args.maxLeverage) : undefined
22
- };
23
- },
24
- getMethod: (program) => (args) => program.methods.setMaxLeverage(args)
25
- };
26
- async function createSetMaxLeverageInstruction(program, args, accounts, strict = true, increaseCompute = false) {
27
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, setMaxLeverageConfig, 'INSTRUCTION', strict, increaseCompute, args));
28
- }
29
- async function setMaxLeverage(program, args, accounts, strict = true, increaseCompute = false) {
30
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, setMaxLeverageConfig, 'TRANSACTION', strict, increaseCompute, args));
31
- }
@@ -1,11 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { PublicKey, TransactionSignature, TransactionInstruction } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type SuperAdminArgs = {
5
- allow_trading: boolean;
6
- };
7
- export type SuperAdminAccounts = {
8
- authority: PublicKey;
9
- };
10
- export declare function createSetSuperAdminInstruction(program: Program<WasabiSolana>, args: SuperAdminArgs, accounts: SuperAdminAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
11
- export declare function setSuperAdmin(program: Program<WasabiSolana>, args: SuperAdminArgs, accounts: SuperAdminAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSetSuperAdminInstruction = createSetSuperAdminInstruction;
4
- exports.setSuperAdmin = setSuperAdmin;
5
- const base_1 = require("../base");
6
- const utils_1 = require("../utils");
7
- const tradeStateConfig = {
8
- process: async (config) => {
9
- const allAccounts = {
10
- authority: config.accounts.authority,
11
- superAdmin: utils_1.PDA.getSuperAdmin()
12
- };
13
- return {
14
- accounts: config.strict ? allAccounts : {
15
- authority: allAccounts.authority,
16
- },
17
- args: config.args.allow_trading
18
- };
19
- },
20
- getMethod: (program) => (args) => program.methods.setSuperAdmin(args),
21
- };
22
- async function createSetSuperAdminInstruction(program, args, accounts, strict = true, increaseCompute = false) {
23
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, tradeStateConfig, 'INSTRUCTION', strict, increaseCompute, args));
24
- }
25
- async function setSuperAdmin(program, args, accounts, strict = true, increaseCompute = false) {
26
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, tradeStateConfig, 'TRANSACTION', strict, increaseCompute, args));
27
- }
@@ -1,11 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { PublicKey, TransactionSignature, TransactionInstruction } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type TradeStateArgs = {
5
- allow_trading: boolean;
6
- };
7
- export type TradeStateAccounts = {
8
- authority: PublicKey;
9
- };
10
- export declare function createSetTradeStateInstruction(program: Program<WasabiSolana>, args: TradeStateArgs, accounts: TradeStateAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
11
- export declare function setTradeState(program: Program<WasabiSolana>, args: TradeStateArgs, accounts: TradeStateAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSetTradeStateInstruction = createSetTradeStateInstruction;
4
- exports.setTradeState = setTradeState;
5
- const base_1 = require("../base");
6
- const utils_1 = require("../utils");
7
- const tradeStateConfig = {
8
- process: async (config) => {
9
- const allAccounts = {
10
- authority: config.accounts.authority,
11
- globalSettings: utils_1.PDA.getGlobalSettings(),
12
- superAdmin: utils_1.PDA.getSuperAdmin()
13
- };
14
- return {
15
- accounts: config.strict ? allAccounts : {
16
- authority: allAccounts.authority,
17
- },
18
- args: config.args.allow_trading
19
- };
20
- },
21
- getMethod: (program) => (args) => program.methods.setTradingState(args),
22
- };
23
- async function createSetTradeStateInstruction(program, args, accounts, strict = true, increaseCompute = false) {
24
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, tradeStateConfig, 'INSTRUCTION', strict, increaseCompute, args));
25
- }
26
- async function setTradeState(program, args, accounts, strict = true, increaseCompute = false) {
27
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, tradeStateConfig, 'TRANSACTION', strict, increaseCompute, args));
28
- }
@@ -1,30 +0,0 @@
1
- import { TransactionInstruction, PublicKey, Connection } from '@solana/web3.js';
2
- export type SwapMode = 'EXACT_IN' | 'EXACT_OUT';
3
- export type SwapProvider = 'jupiter' | 'raydium';
4
- export type SwapInstructionGroup = {
5
- computeBudgetInstructions?: TransactionInstruction[];
6
- setupInstructions: TransactionInstruction[];
7
- swapInstructions: TransactionInstruction[];
8
- cleanupInstructions: TransactionInstruction[];
9
- addressLookupTableAddresses?: string[];
10
- };
11
- export type CreateSwapInstructionArgs = {
12
- connection: Connection;
13
- inputMint: PublicKey;
14
- outputMint: PublicKey;
15
- amount: number;
16
- slippageBps: number;
17
- ownerPubkey: PublicKey;
18
- authorityPubkey?: PublicKey;
19
- swapMode?: SwapMode;
20
- preferredProvider?: SwapProvider;
21
- options?: {
22
- raydiumPoolIds?: string[];
23
- jupiterOptions?: {
24
- onlyDirectRoutes?: boolean;
25
- asLegacyTransaction?: boolean;
26
- maxAccounts?: number;
27
- };
28
- };
29
- };
30
- export declare function createSwapInstructionGroup({ connection, inputMint, outputMint, amount, slippageBps, ownerPubkey, authorityPubkey, swapMode, preferredProvider, options }: CreateSwapInstructionArgs): Promise<SwapInstructionGroup>;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSwapInstructionGroup = createSwapInstructionGroup;
4
- const swapJupiter_1 = require("./swapJupiter");
5
- const swapRaydium_1 = require("./swapRaydium");
6
- async function createSwapInstructionGroup({ connection, inputMint, outputMint, amount, slippageBps, ownerPubkey, authorityPubkey, swapMode = 'EXACT_IN', preferredProvider = 'jupiter', options = {} }) {
7
- try {
8
- return await createProviderSwapInstructions(preferredProvider, {
9
- connection,
10
- inputMint,
11
- outputMint,
12
- amount,
13
- slippageBps,
14
- ownerPubkey,
15
- authorityPubkey,
16
- swapMode,
17
- options
18
- });
19
- }
20
- catch (error) {
21
- console.error(`${preferredProvider} swap failed:`, error);
22
- const fallbackProvider = preferredProvider === 'jupiter' ? 'raydium' : 'jupiter';
23
- try {
24
- return await createProviderSwapInstructions(fallbackProvider, {
25
- connection,
26
- inputMint,
27
- outputMint,
28
- amount,
29
- slippageBps,
30
- ownerPubkey,
31
- authorityPubkey,
32
- swapMode,
33
- options
34
- });
35
- }
36
- catch (fallbackError) {
37
- console.error(`${fallbackProvider} fallback failed:`, fallbackError);
38
- throw new Error('All swap providers failed');
39
- }
40
- }
41
- }
42
- async function createProviderSwapInstructions(provider, params) {
43
- if (provider === 'jupiter') {
44
- return constructJupiterSwapInstructions(params);
45
- }
46
- else {
47
- return constructRaydiumSwapInstructions(params);
48
- }
49
- }
50
- async function constructJupiterSwapInstructions({ inputMint, outputMint, amount, slippageBps, ownerPubkey, authorityPubkey, swapMode, options }) {
51
- const quoteResponse = await (0, swapJupiter_1.getJupiterQuote)(inputMint, outputMint, amount, slippageBps, swapMode, options?.jupiterOptions);
52
- const jupiterInstructions = await (0, swapJupiter_1.createJupiterSwapInstructions)({
53
- quoteResponse,
54
- ownerPubkey: ownerPubkey,
55
- wrapUnwrapSOL: true
56
- });
57
- return {
58
- computeBudgetInstructions: jupiterInstructions.computeBudgetInstructions,
59
- setupInstructions: [
60
- ...(jupiterInstructions.setupInstructions || []),
61
- ...(jupiterInstructions.tokenLedgerInstruction
62
- ? [jupiterInstructions.tokenLedgerInstruction]
63
- : [])
64
- ],
65
- swapInstructions: [jupiterInstructions.swapInstruction],
66
- cleanupInstructions: [
67
- ...(jupiterInstructions.cleanupInstruction
68
- ? [jupiterInstructions.cleanupInstruction]
69
- : [])
70
- ],
71
- addressLookupTableAddresses: jupiterInstructions.addressLookupTableAddresses
72
- };
73
- }
74
- async function constructRaydiumSwapInstructions({ connection, inputMint, outputMint, amount, slippageBps, ownerPubkey, authorityPubkey, swapMode, options }) {
75
- if (!options?.raydiumPoolId) {
76
- throw new Error('Raydium pool ID is required');
77
- }
78
- const quoteResponse = await (0, swapRaydium_1.getRaydiumRouteQuote)(inputMint, outputMint, amount, slippageBps, [options.raydiumPoolId], swapMode, connection);
79
- const raydiumInstructions = await (0, swapRaydium_1.createRaydiumRouteSwapInstructions)({
80
- quoteResponse,
81
- ownerPubkey,
82
- authorityPubkey
83
- });
84
- return {
85
- computeBudgetInstructions: raydiumInstructions.computeBudgetInstructions,
86
- setupInstructions: raydiumInstructions.setupInstructions,
87
- swapInstructions: raydiumInstructions.swapInstructions,
88
- cleanupInstructions: raydiumInstructions.cleanupInstructions,
89
- addressLookupTableAddresses: raydiumInstructions.addressLookupTableAddresses
90
- };
91
- }