wasabi-solana-ts 1.2.2 → 1.2.4

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 (89) 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/index.d.ts +3 -3
  7. package/dist/instructions/closeLongPosition.d.ts +3 -3
  8. package/dist/instructions/closePosition.d.ts +2 -2
  9. package/dist/instructions/closePositionV2.d.ts +2 -2
  10. package/dist/instructions/closeShortPosition.d.ts +3 -3
  11. package/dist/instructions/donate.d.ts +2 -2
  12. package/dist/instructions/increaseLongPositionSetup.d.ts +2 -2
  13. package/dist/instructions/increaseShortPositionSetup.d.ts +2 -2
  14. package/dist/instructions/initPool.d.ts +2 -2
  15. package/dist/instructions/liquidatePosition.d.ts +3 -3
  16. package/dist/instructions/liquidatePositionV2.d.ts +2 -2
  17. package/dist/instructions/openLongPosition.d.ts +3 -3
  18. package/dist/instructions/openLongPosition.js +1 -1
  19. package/dist/instructions/openShortPosition.d.ts +3 -3
  20. package/dist/instructions/openShortPosition.js +1 -1
  21. package/dist/instructions/stopLoss.d.ts +3 -3
  22. package/dist/instructions/stopLossV2.d.ts +2 -2
  23. package/dist/instructions/takeProfit.d.ts +3 -3
  24. package/dist/instructions/takeProfitV2.d.ts +2 -2
  25. package/dist/utils/index.d.ts +0 -1
  26. package/dist/utils/index.js +0 -1
  27. package/dist/utils/utils.d.ts +10 -11
  28. package/dist/utils/utils.js +37 -65
  29. package/package.json +5 -3
  30. package/dist/instructions/closeWallet.d.ts +0 -20
  31. package/dist/instructions/closeWallet.js +0 -34
  32. package/dist/instructions/collectFees.d.ts +0 -22
  33. package/dist/instructions/collectFees.js +0 -40
  34. package/dist/instructions/generateWallet.d.ts +0 -22
  35. package/dist/instructions/generateWallet.js +0 -36
  36. package/dist/instructions/increaseShortPosition.d.ts +0 -6
  37. package/dist/instructions/increaseShortPosition.js +0 -70
  38. package/dist/instructions/initDebtController.d.ts +0 -24
  39. package/dist/instructions/initDebtController.js +0 -37
  40. package/dist/instructions/initGlobalSettings.d.ts +0 -9
  41. package/dist/instructions/initGlobalSettings.js +0 -32
  42. package/dist/instructions/initOrUpdatePermission.d.ts +0 -22
  43. package/dist/instructions/initOrUpdatePermission.js +0 -48
  44. package/dist/instructions/initStopLossOrder.d.ts +0 -12
  45. package/dist/instructions/initStopLossOrder.js +0 -40
  46. package/dist/instructions/initTakeProfitOrder.d.ts +0 -12
  47. package/dist/instructions/initTakeProfitOrder.js +0 -40
  48. package/dist/instructions/mint.d.ts +0 -8
  49. package/dist/instructions/mint.js +0 -35
  50. package/dist/instructions/removePermission.d.ts +0 -16
  51. package/dist/instructions/removePermission.js +0 -25
  52. package/dist/instructions/repay.d.ts +0 -11
  53. package/dist/instructions/repay.js +0 -44
  54. package/dist/instructions/setLpState.d.ts +0 -11
  55. package/dist/instructions/setLpState.js +0 -28
  56. package/dist/instructions/setMaxApy.d.ts +0 -11
  57. package/dist/instructions/setMaxApy.js +0 -31
  58. package/dist/instructions/setMaxLeverage.d.ts +0 -11
  59. package/dist/instructions/setMaxLeverage.js +0 -31
  60. package/dist/instructions/setSuperAdmin.d.ts +0 -11
  61. package/dist/instructions/setSuperAdmin.js +0 -27
  62. package/dist/instructions/setTradeState.d.ts +0 -11
  63. package/dist/instructions/setTradeState.js +0 -28
  64. package/dist/instructions/swap.d.ts +0 -30
  65. package/dist/instructions/swap.js +0 -91
  66. package/dist/instructions/swapJupiter.d.ts +0 -90
  67. package/dist/instructions/swapJupiter.js +0 -61
  68. package/dist/instructions/swapRaydium.d.ts +0 -38
  69. package/dist/instructions/swapRaydium.js +0 -170
  70. package/dist/instructions/updateLongPosition.d.ts +0 -6
  71. package/dist/instructions/updateLongPosition.js +0 -69
  72. package/dist/instructions/updateLpVaultMaxBorrow.d.ts +0 -12
  73. package/dist/instructions/updateLpVaultMaxBorrow.js +0 -35
  74. package/dist/sender-provider/baseSenderProvider.d.ts +0 -42
  75. package/dist/sender-provider/baseSenderProvider.js +0 -178
  76. package/dist/sender-provider/index.d.ts +0 -5
  77. package/dist/sender-provider/index.js +0 -21
  78. package/dist/sender-provider/jitoBrowser.d.ts +0 -2
  79. package/dist/sender-provider/jitoBrowser.js +0 -32
  80. package/dist/sender-provider/jitoSenderProvider.d.ts +0 -5
  81. package/dist/sender-provider/jitoSenderProvider.js +0 -69
  82. package/dist/sender-provider/jitoServer.d.ts +0 -2
  83. package/dist/sender-provider/jitoServer.js +0 -67
  84. package/dist/sender-provider/jitoTips.d.ts +0 -17
  85. package/dist/sender-provider/jitoTips.js +0 -75
  86. package/dist/sender-provider/jitoTypes.d.ts +0 -12
  87. package/dist/sender-provider/jitoTypes.js +0 -6
  88. package/dist/utils/mintCache.d.ts +0 -10
  89. package/dist/utils/mintCache.js +0 -39
@@ -36,6 +36,7 @@ const web3_js_1 = require("@solana/web3.js");
36
36
  const anchor_1 = require("@coral-xyz/anchor");
37
37
  const spl_token_1 = require("@solana/spl-token");
38
38
  const js_1 = require("@metaplex-foundation/js");
39
+ const TokenMintCache_1 = require("../cache/TokenMintCache");
39
40
  exports.SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111111');
40
41
  exports.WASABI_PROGRAM_ID = new web3_js_1.PublicKey('spicyTHtbmarmUxwFSHYpA8G4uP2nRNq38RReMpoZ9c');
41
42
  exports.METADATA_PROGRAM_ID = new web3_js_1.PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
@@ -79,25 +80,11 @@ function amountToUiAmount(amount, decimals) {
79
80
  return amount.toNumber() / 10 ** decimals;
80
81
  }
81
82
  async function getTokenProgram(connection, mint, mintCache) {
82
- if (mintCache) {
83
- const mintInfo = await mintCache.getMintInfos([mint]);
84
- if (mintInfo) {
85
- const mintAccount = mintInfo.get(mint);
86
- if (mintAccount) {
87
- return mintAccount.owner;
88
- }
89
- }
90
- }
91
- const mintInfo = await connection.getAccountInfo(mint);
92
- if (!mintInfo) {
93
- return null;
94
- }
95
- if (mintInfo.owner.equals(spl_token_1.TOKEN_PROGRAM_ID) || mintInfo.owner.equals(spl_token_1.TOKEN_2022_PROGRAM_ID)) {
96
- return mintInfo.owner;
97
- }
98
- else {
99
- return null;
83
+ if (mintCache === undefined) {
84
+ mintCache = new TokenMintCache_1.TokenMintCache(connection);
100
85
  }
86
+ const mintInfo = await mintCache.getAccount(mint);
87
+ return mintInfo.program;
101
88
  }
102
89
  async function getTokenProgramAndDecimals(connection, mint) {
103
90
  const mintInfo = await connection.getAccountInfo(mint);
@@ -429,15 +416,15 @@ async function handleMintsAndTokenProgram(connection, currency, collateral, opti
429
416
  if (currency.equals(collateral)) {
430
417
  throw new Error('Mints cannot be the same');
431
418
  }
432
- const [currencyResult, collateralResult] = await Promise.all([
433
- handleMint(connection, currency, { owner: options.owner, mintCache: options.mintCache }),
434
- handleMint(connection, collateral, { owner: options.owner, mintCache: options.mintCache })
435
- ]);
419
+ const mintCache = options.mintCache || new TokenMintCache_1.TokenMintCache(connection);
420
+ const mints = await mintCache.getAccounts([currency, collateral]);
421
+ const currencyTokenProgram = mints.get(currency.toString()).program;
422
+ const collateralTokenProgram = mints.get(collateral.toString()).program;
436
423
  return {
437
- currencyMint: currencyResult.mint,
438
- collateralMint: collateralResult.mint,
439
- currencyTokenProgram: currencyResult.tokenProgram,
440
- collateralTokenProgram: collateralResult.tokenProgram
424
+ currencyMint: new web3_js_1.PublicKey(currency),
425
+ collateralMint: new web3_js_1.PublicKey(collateral),
426
+ currencyTokenProgram,
427
+ collateralTokenProgram
441
428
  };
442
429
  }
443
430
  async function handleMintsAndTokenProgramWithSetupAndCleanup(connection, owner, currency, collateral, wrapMode, amount, mintCache) {
@@ -472,10 +459,12 @@ async function handlePaymentTokenMintWithAuthority(connection, authority, owner,
472
459
  ? await createWrapSolInstruction(connection, owner, amount, false)
473
460
  : await createUnwrapSolInstructionWithPayer(connection, authority, owner);
474
461
  }
475
- const [currencyTokenProgram, collateralTokenProgram] = await Promise.all([
476
- getTokenProgram(connection, currency, mintCache),
477
- getTokenProgram(connection, collateral, mintCache)
478
- ]);
462
+ if (mintCache === undefined) {
463
+ mintCache = new TokenMintCache_1.TokenMintCache(connection);
464
+ }
465
+ const mints = await mintCache.getAccounts([currency, collateral]);
466
+ const currencyTokenProgram = mints.get(currency.toString()).program;
467
+ const collateralTokenProgram = mints.get(collateral.toString()).program;
479
468
  if (!currencyTokenProgram || !collateralTokenProgram) {
480
469
  throw new Error('Token program not found');
481
470
  }
@@ -491,29 +480,16 @@ async function handlePaymentTokenMintWithAuthority(connection, authority, owner,
491
480
  async function handleOpenTokenAccounts({ program, owner, downPayment, fee, mintCache, isLongPool, currency, collateral, useShares }) {
492
481
  let setupIx = [];
493
482
  const cleanupIx = [];
494
- let mintInfos;
495
- if (mintCache !== undefined) {
496
- mintInfos = await mintCache.getMintInfos([currency, collateral]);
497
- }
498
- else {
499
- const result = await program.provider.connection.getMultipleAccountsInfo([
500
- currency,
501
- collateral
502
- ]);
503
- if (!result) {
504
- throw new Error('Could not get mint info');
505
- }
506
- mintInfos = new Map();
507
- if (result[0])
508
- mintInfos.set(currency, result[0]);
509
- if (result[1])
510
- mintInfos.set(collateral, result[1]);
511
- }
512
- const currencyInfo = mintInfos.get(currency);
513
- const collateralInfo = mintInfos.get(collateral);
514
- const paymentMintInfo = isLongPool ? currencyInfo : collateralInfo;
483
+ let currencyTokenProgram;
484
+ let collateralTokenProgram;
485
+ if (mintCache === undefined) {
486
+ mintCache = new TokenMintCache_1.TokenMintCache(program.provider.connection);
487
+ }
488
+ const mints = await mintCache.getAccounts([currency, collateral]);
489
+ currencyTokenProgram = mints.get(currency.toString()).program;
490
+ collateralTokenProgram = mints.get(collateral.toString()).program;
515
491
  const paymentMint = isLongPool ? currency : collateral;
516
- const paymentTokenProgram = paymentMintInfo.owner;
492
+ const paymentTokenProgram = isLongPool ? currencyTokenProgram : collateralTokenProgram;
517
493
  const paymentIsSol = paymentMint.equals(spl_token_1.NATIVE_MINT);
518
494
  const ownerPaymentAta = (0, spl_token_1.getAssociatedTokenAddressSync)(paymentMint, owner, false, paymentTokenProgram);
519
495
  if (paymentIsSol && !useShares) {
@@ -532,29 +508,25 @@ async function handleOpenTokenAccounts({ program, owner, downPayment, fee, mintC
532
508
  ...setupIx
533
509
  ];
534
510
  }
535
- if (!currencyInfo || !collateralInfo) {
536
- throw new Error('Could not get mint info');
537
- }
538
511
  return {
539
512
  paymentMint,
540
513
  paymentIsSol,
541
514
  ownerPaymentAta,
542
- currencyTokenProgram: currencyInfo.owner,
543
- collateralTokenProgram: collateralInfo.owner,
515
+ currencyTokenProgram,
516
+ collateralTokenProgram,
544
517
  setupIx,
545
518
  cleanupIx
546
519
  };
547
520
  }
548
521
  async function handleCloseTokenAccounts(config, poolAccount) {
549
- const minInfos = await config.mintCache.getMintInfos([
522
+ const mints = await config.mintCache.getAccounts([
550
523
  poolAccount.currency,
551
524
  poolAccount.collateral
552
525
  ]);
553
- const currencyInfo = minInfos.get(poolAccount.currency);
554
- const collateralInfo = minInfos.get(poolAccount.collateral);
555
- const payoutMintInfo = poolAccount.isLongPool ? currencyInfo : collateralInfo;
556
- const payoutMint = payoutMintInfo[0];
557
- const payoutTokenProgram = payoutMintInfo[1].owner;
526
+ const currencyTokenProgram = mints.get(poolAccount.currency.toString()).program;
527
+ const collateralTokenProgram = mints.get(poolAccount.collateral.toString()).program;
528
+ const payoutMint = poolAccount.isLongPool ? poolAccount.currency : poolAccount.collateral;
529
+ const payoutTokenProgram = poolAccount.isLongPool ? currencyTokenProgram : collateralTokenProgram;
558
530
  const payoutIsSol = payoutMint.equals(spl_token_1.NATIVE_MINT);
559
531
  const ownerPayoutAta = (0, spl_token_1.getAssociatedTokenAddressSync)(payoutMint, config.owner, false, payoutTokenProgram);
560
532
  const ownerPayoutAtaInfo = await config.program.provider.connection.getAccountInfo(ownerPayoutAta);
@@ -572,8 +544,8 @@ async function handleCloseTokenAccounts(config, poolAccount) {
572
544
  ownerPayoutAta,
573
545
  setupIx,
574
546
  cleanupIx,
575
- currencyTokenProgram: currencyInfo[1].owner,
576
- collateralTokenProgram: collateralInfo[1].owner
547
+ currencyTokenProgram,
548
+ collateralTokenProgram
577
549
  };
578
550
  }
579
551
  function validateArgs(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasabi-solana-ts",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Typescript library for the Wasabi program",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,8 @@
39
39
  "bn.js": "5.2.1",
40
40
  "decimal.js": "10.4.3",
41
41
  "jito-js-rpc": "^0.1.0",
42
- "jito-ts": "4.2.0"
42
+ "jito-ts": "4.2.0",
43
+ "node-cache": "5.1.2"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/chai": "4.3.11",
@@ -53,6 +54,7 @@
53
54
  "mocha": "10.2.0",
54
55
  "prettier": "3.0.0",
55
56
  "ts-node": "10.9.2",
56
- "typescript": "5.6.3"
57
+ "typescript": "5.6.3",
58
+ "@types/node-cache": "4.1.3"
57
59
  }
58
60
  }
@@ -1,20 +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 CloseWalletAccounts = {
6
- protocolWallet: PublicKey;
7
- };
8
- type CloseWalletInstructionAccounts = {
9
- authority: PublicKey;
10
- permission: PublicKey;
11
- protocolWallet: PublicKey;
12
- };
13
- type CloseWalletInstructionAccountsStrict = CloseWalletInstructionAccounts & {
14
- globalSettings: PublicKey;
15
- systemProgram: PublicKey;
16
- };
17
- export declare const closeWalletConfig: BaseMethodConfig<null, CloseWalletAccounts, CloseWalletInstructionAccounts | CloseWalletInstructionAccountsStrict>;
18
- export declare function createCloseWalletInstruction(program: Program<WasabiSolana>, accounts: CloseWalletAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
19
- export declare function closeWallet(program: Program<WasabiSolana>, accounts: CloseWalletAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
20
- export {};
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.closeWalletConfig = void 0;
4
- exports.createCloseWalletInstruction = createCloseWalletInstruction;
5
- exports.closeWallet = closeWallet;
6
- const web3_js_1 = require("@solana/web3.js");
7
- const base_1 = require("../base");
8
- const utils_1 = require("../utils");
9
- exports.closeWalletConfig = {
10
- process: async (config) => {
11
- const allAccounts = {
12
- authority: config.program.provider.publicKey,
13
- permission: await (0, utils_1.getPermission)(config.program, config.program.provider.publicKey),
14
- protocolWallet: config.accounts.protocolWallet,
15
- globalSettings: utils_1.PDA.getGlobalSettings(),
16
- systemProgram: web3_js_1.SystemProgram.programId,
17
- };
18
- return {
19
- accounts: config.strict ? allAccounts
20
- : {
21
- authority: allAccounts.authority,
22
- permission: allAccounts.permission,
23
- protocolWallet: allAccounts.protocolWallet,
24
- },
25
- };
26
- },
27
- getMethod: (program) => () => program.methods.closeWallet()
28
- };
29
- async function createCloseWalletInstruction(program, accounts, strict = true, increaseCompute = false) {
30
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.closeWalletConfig, 'INSTRUCTION', strict, increaseCompute));
31
- }
32
- async function closeWallet(program, accounts, strict = true, increaseCompute = false) {
33
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.closeWalletConfig, 'INSTRUCTION', strict, increaseCompute));
34
- }
@@ -1,22 +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 CollectFeesAccounts = {
6
- protocolWallet: PublicKey;
7
- asset: PublicKey;
8
- };
9
- type CollectFeesInstructionAccounts = {
10
- authority: PublicKey;
11
- permission: PublicKey;
12
- protocolWallet: PublicKey;
13
- asset: PublicKey;
14
- };
15
- type CollectFeesInstructionAccountsStrict = CollectFeesInstructionAccounts & {
16
- globalSettings: PublicKey;
17
- systemProgram: PublicKey;
18
- };
19
- export declare const collectFeesConfig: BaseMethodConfig<null, CollectFeesAccounts, CollectFeesInstructionAccounts | CollectFeesInstructionAccountsStrict>;
20
- export declare function createCollectFeesInstruction(program: Program<WasabiSolana>, accounts: CollectFeesAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
21
- export declare function collectFees(program: Program<WasabiSolana>, accounts: CollectFeesAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
22
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collectFeesConfig = void 0;
4
- exports.createCollectFeesInstruction = createCollectFeesInstruction;
5
- exports.collectFees = collectFees;
6
- const web3_js_1 = require("@solana/web3.js");
7
- const spl_token_1 = require("@solana/spl-token");
8
- const base_1 = require("../base");
9
- const utils_1 = require("../utils");
10
- exports.collectFeesConfig = {
11
- process: async (config) => {
12
- const tokenProgram = await (0, utils_1.getTokenProgram)(config.program.provider.connection, config.accounts.asset);
13
- const allAccounts = {
14
- authority: config.program.provider.publicKey,
15
- authorityAta: (0, spl_token_1.getAssociatedTokenAddressSync)(config.accounts.asset, config.program.provider.publicKey, false, tokenProgram),
16
- asset: config.accounts.asset,
17
- permission: await (0, utils_1.getPermission)(config.program, config.program.provider.publicKey),
18
- protocolWallet: config.accounts.protocolWallet,
19
- protocolWalletAta: (0, spl_token_1.getAssociatedTokenAddressSync)(config.accounts.asset, config.accounts.protocolWallet, true, tokenProgram),
20
- globalSettings: utils_1.PDA.getGlobalSettings(),
21
- systemProgram: web3_js_1.SystemProgram.programId,
22
- };
23
- return {
24
- accounts: config.strict ? allAccounts
25
- : {
26
- authority: allAccounts.authority,
27
- asset: allAccounts.asset,
28
- permission: allAccounts.permission,
29
- protocolWallet: allAccounts.protocolWallet,
30
- },
31
- };
32
- },
33
- getMethod: (program) => () => program.methods.collectFees()
34
- };
35
- async function createCollectFeesInstruction(program, accounts, strict = true, increaseCompute = false) {
36
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.collectFeesConfig, 'INSTRUCTION', strict, increaseCompute));
37
- }
38
- async function collectFees(program, accounts, strict = true, increaseCompute = false) {
39
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.collectFeesConfig, 'INSTRUCTION', strict, increaseCompute));
40
- }
@@ -1,22 +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 { WalletType } from '../utils';
5
- import { WasabiSolana } from '../idl/wasabi_solana';
6
- export type GenerateWalletArgs = {
7
- walletType: WalletType;
8
- nonce: number;
9
- };
10
- type GenerateWalletInstructionAccounts = {
11
- authority: PublicKey;
12
- permission: PublicKey;
13
- };
14
- type GenerateWalletInstructionAccountsStrict = GenerateWalletInstructionAccounts & {
15
- protocolWallet: PublicKey;
16
- globalSettings: PublicKey;
17
- systemProgram: PublicKey;
18
- };
19
- export declare const generateWalletConfig: BaseMethodConfig<GenerateWalletArgs, null, GenerateWalletInstructionAccounts | GenerateWalletInstructionAccountsStrict>;
20
- export declare function createGenerateWalletInstruction(program: Program<WasabiSolana>, args: GenerateWalletArgs, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
21
- export declare function generateWallet(program: Program<WasabiSolana>, args: GenerateWalletArgs, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
22
- export {};
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateWalletConfig = void 0;
4
- exports.createGenerateWalletInstruction = createGenerateWalletInstruction;
5
- exports.generateWallet = generateWallet;
6
- const web3_js_1 = require("@solana/web3.js");
7
- const base_1 = require("../base");
8
- const utils_1 = require("../utils");
9
- exports.generateWalletConfig = {
10
- process: async (config) => {
11
- const allAccounts = {
12
- authority: config.program.provider.publicKey,
13
- protocolWallet: config.args.walletType === 'FEE'
14
- ? utils_1.PDA.getFeeWallet(config.args.nonce)
15
- : utils_1.PDA.getLiquidationWallet(config.args.nonce),
16
- permission: await (0, utils_1.getPermission)(config.program, config.program.provider.publicKey),
17
- globalSettings: utils_1.PDA.getGlobalSettings(),
18
- systemProgram: web3_js_1.SystemProgram.programId,
19
- };
20
- return {
21
- accounts: config.strict ? allAccounts
22
- : {
23
- authority: allAccounts.authority,
24
- permission: allAccounts.permission,
25
- },
26
- args: config.args,
27
- };
28
- },
29
- getMethod: (program) => (args) => program.methods.generateWallet(args.walletType, args.nonce)
30
- };
31
- async function createGenerateWalletInstruction(program, args, strict = true, increaseCompute = false) {
32
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, null, exports.generateWalletConfig, 'INSTRUCTION', strict, increaseCompute, args));
33
- }
34
- async function generateWallet(program, args, strict = true, increaseCompute = false) {
35
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, null, exports.generateWalletConfig, 'INSTRUCTION', strict, increaseCompute, args));
36
- }
@@ -1,6 +0,0 @@
1
- import { TransactionInstruction } from '@solana/web3.js';
2
- import { OpenPositionAccounts, OpenPositionArgs } from './openPosition';
3
- import { MintCache } from '../utils';
4
- import { Program } from '@coral-xyz/anchor';
5
- import { WasabiSolana } from '../idl';
6
- export declare function createIncreaseShortPositionInstruction(program: Program<WasabiSolana>, args: OpenPositionArgs, accounts: OpenPositionAccounts, mintCache?: MintCache): Promise<TransactionInstruction[]>;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createIncreaseShortPositionInstruction = createIncreaseShortPositionInstruction;
4
- const web3_js_1 = require("@solana/web3.js");
5
- const base_1 = require("../base");
6
- const shared_1 = require("./shared");
7
- const utils_1 = require("../utils");
8
- const spl_token_1 = require("@solana/spl-token");
9
- const anchor_1 = require("@coral-xyz/anchor");
10
- const increaseShortPositionConfig = {
11
- process: async (config) => {
12
- const { hops, data, remainingAccounts } = (0, shared_1.extractInstructionData)(config.args.instructions);
13
- const lpVault = utils_1.PDA.getLpVault(config.accounts.currency);
14
- const pool = utils_1.PDA.getShortPool(config.accounts.collateral, config.accounts.currency);
15
- if (!config.args.positionId) {
16
- throw new Error('positionId is required for `IncreaseShortPosition`');
17
- }
18
- const position = new web3_js_1.PublicKey(config.args.positionId);
19
- const { ownerPaymentAta, currencyTokenProgram, collateralTokenProgram, setupIx, cleanupIx } = await (0, utils_1.handleOpenTokenAccounts)({
20
- program: config.program,
21
- owner: config.accounts.owner,
22
- downPayment: config.args.downPayment,
23
- fee: config.args.fee,
24
- mintCache: config.mintCache,
25
- isLongPool: false,
26
- currency: config.accounts.currency,
27
- collateral: config.accounts.collateral
28
- });
29
- return {
30
- accounts: {
31
- owner: config.accounts.owner,
32
- ownerTargetCurrencyAccount: ownerPaymentAta,
33
- lpVault,
34
- vault: (0, spl_token_1.getAssociatedTokenAddressSync)(config.accounts.currency, lpVault, true, currencyTokenProgram),
35
- pool,
36
- currencyVault: (0, spl_token_1.getAssociatedTokenAddressSync)(config.accounts.currency, pool, true, currencyTokenProgram),
37
- collateralVault: (0, spl_token_1.getAssociatedTokenAddressSync)(config.accounts.collateral, pool, true, collateralTokenProgram),
38
- currency: config.accounts.currency,
39
- collateral: config.accounts.collateral,
40
- position,
41
- authority: config.accounts.authority,
42
- permission: utils_1.PDA.getAdmin(config.accounts.authority),
43
- feeWallet: config.accounts.feeWallet,
44
- debtController: utils_1.PDA.getDebtController(),
45
- globalSettings: utils_1.PDA.getGlobalSettings(),
46
- currencyTokenProgram,
47
- collateralTokenProgram,
48
- systemProgram: web3_js_1.SystemProgram.programId
49
- },
50
- args: {
51
- ...config.args,
52
- hops,
53
- data
54
- },
55
- setup: setupIx,
56
- cleanup: cleanupIx,
57
- remainingAccounts
58
- };
59
- },
60
- getMethod: (program) => (args) => program.methods.increaseShortPosition(new anchor_1.BN(args.minTargetAmount), new anchor_1.BN(args.downPayment), new anchor_1.BN(args.principal), new anchor_1.BN(args.fee), new anchor_1.BN(args.expiration), { hops: args.hops }, args.data)
61
- };
62
- async function createIncreaseShortPositionInstruction(program, args, accounts, mintCache) {
63
- return (0, base_1.handleMethodCall)({
64
- program,
65
- accounts,
66
- config: increaseShortPositionConfig,
67
- args,
68
- mintCache
69
- });
70
- }
@@ -1,24 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionInstruction, PublicKey } from '@solana/web3.js';
3
- import { BaseMethodConfig } from '../base';
4
- import { WasabiSolana } from '../idl/wasabi_solana';
5
- export type InitDebtControllerArgs = {
6
- maxApy: number;
7
- maxLeverage: number;
8
- liquidationFee: number;
9
- };
10
- export type InitDebtControllerAccounts = {
11
- authority: PublicKey;
12
- };
13
- type InitDebtControllerInstructionAccounts = {
14
- superAdmin: PublicKey;
15
- };
16
- type InitDebtControllerInstructionAccountsStrict = {
17
- authority: PublicKey;
18
- debtController: PublicKey;
19
- systemProgram: PublicKey;
20
- } & InitDebtControllerInstructionAccounts;
21
- export declare const initDebtControllerConfig: BaseMethodConfig<InitDebtControllerArgs, InitDebtControllerAccounts, InitDebtControllerInstructionAccounts | InitDebtControllerInstructionAccountsStrict>;
22
- export declare function createInitDebtControllerInstruction(program: Program<WasabiSolana>, args: InitDebtControllerArgs, accounts: InitDebtControllerAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
23
- export declare function initDebtController(program: Program<WasabiSolana>, args: InitDebtControllerArgs, accounts: InitDebtControllerAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
24
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initDebtControllerConfig = void 0;
4
- exports.createInitDebtControllerInstruction = createInitDebtControllerInstruction;
5
- exports.initDebtController = initDebtController;
6
- const anchor_1 = require("@coral-xyz/anchor");
7
- const web3_js_1 = require("@solana/web3.js");
8
- const base_1 = require("../base");
9
- const utils_1 = require("../utils");
10
- exports.initDebtControllerConfig = {
11
- process: async (config) => {
12
- const allAccounts = {
13
- authority: config.accounts.authority,
14
- superAdmin: await (0, utils_1.getPermission)(config.program, config.accounts.authority),
15
- debtController: utils_1.PDA.getDebtController(),
16
- systemProgram: web3_js_1.SystemProgram.programId
17
- };
18
- return {
19
- accounts: config.strict
20
- ? allAccounts
21
- : {
22
- superAdmin: allAccounts.superAdmin
23
- },
24
- args: {
25
- maxApy: new anchor_1.BN(config.args.maxApy),
26
- maxLeverage: new anchor_1.BN(config.args.maxLeverage)
27
- }
28
- };
29
- },
30
- getMethod: (program) => (args) => program.methods.initDebtController(new anchor_1.BN(args.maxApy), new anchor_1.BN(args.maxLeverage), args.liquidationFee)
31
- };
32
- async function createInitDebtControllerInstruction(program, args, accounts, strict = true, increaseCompute = false) {
33
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.initDebtControllerConfig, 'INSTRUCTION', strict, increaseCompute, args));
34
- }
35
- async function initDebtController(program, args, accounts, strict = true, increaseCompute = false) {
36
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, exports.initDebtControllerConfig, 'TRANSACTION', strict, increaseCompute, args));
37
- }
@@ -1,9 +0,0 @@
1
- import { Program } from '@coral-xyz/anchor';
2
- import { TransactionInstruction, PublicKey } from '@solana/web3.js';
3
- import { WasabiSolana } from '../idl/wasabi_solana';
4
- export type InitGlobalSettingsArgs = {
5
- superAdmin: PublicKey;
6
- statuses: number;
7
- };
8
- export declare function createInitGlobalSettingsInstruction(program: Program<WasabiSolana>, args: InitGlobalSettingsArgs, accounts: void, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
9
- export declare function initGlobalSettings(program: Program<WasabiSolana>, args: InitGlobalSettingsArgs, accounts: void, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createInitGlobalSettingsInstruction = createInitGlobalSettingsInstruction;
4
- exports.initGlobalSettings = initGlobalSettings;
5
- const web3_js_1 = require("@solana/web3.js");
6
- const base_1 = require("../base");
7
- const utils_1 = require("../utils");
8
- const initGlobalSettingsConfig = {
9
- process: async (config) => {
10
- const allAccounts = {
11
- payer: config.program.provider.publicKey,
12
- globalSettings: utils_1.PDA.getGlobalSettings(),
13
- superAdminPermission: utils_1.PDA.getSuperAdmin(),
14
- systemProgram: web3_js_1.SystemProgram.programId
15
- };
16
- return {
17
- accounts: config.strict
18
- ? allAccounts
19
- : {
20
- payer: allAccounts.payer
21
- },
22
- args: config.args
23
- };
24
- },
25
- getMethod: (program) => (args) => program.methods.initGlobalSettings(args)
26
- };
27
- async function createInitGlobalSettingsInstruction(program, args, accounts, strict = true, increaseCompute = false) {
28
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initGlobalSettingsConfig, 'INSTRUCTION', strict, increaseCompute, args));
29
- }
30
- async function initGlobalSettings(program, args, accounts, strict = true, increaseCompute = false) {
31
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initGlobalSettingsConfig, 'TRANSACTION', strict, increaseCompute, args));
32
- }
@@ -1,22 +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 InitOrUpdatePermissionArgs = {
5
- status: AuthorityStatus;
6
- canInitVaults: boolean;
7
- canLiquidate: boolean;
8
- canCosignSwaps: boolean;
9
- canBorrowFromVaults: boolean;
10
- canInitPools: boolean;
11
- canManageWallets: boolean;
12
- };
13
- export type InitOrUpdatePermissionAccounts = {
14
- payer: PublicKey;
15
- newAuthority: PublicKey;
16
- };
17
- export declare enum AuthorityStatus {
18
- Inactive = 0,
19
- Active = 1
20
- }
21
- export declare function createInitOrUpdatePermissionInstruction(program: Program<WasabiSolana>, args: InitOrUpdatePermissionArgs, accounts: InitOrUpdatePermissionAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
22
- export declare function initOrUpdatePermission(program: Program<WasabiSolana>, args: InitOrUpdatePermissionArgs, accounts: InitOrUpdatePermissionAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthorityStatus = void 0;
4
- exports.createInitOrUpdatePermissionInstruction = createInitOrUpdatePermissionInstruction;
5
- exports.initOrUpdatePermission = initOrUpdatePermission;
6
- const web3_js_1 = require("@solana/web3.js");
7
- const base_1 = require("../base");
8
- const utils_1 = require("../utils");
9
- var AuthorityStatus;
10
- (function (AuthorityStatus) {
11
- AuthorityStatus[AuthorityStatus["Inactive"] = 0] = "Inactive";
12
- AuthorityStatus[AuthorityStatus["Active"] = 1] = "Active";
13
- })(AuthorityStatus || (exports.AuthorityStatus = AuthorityStatus = {}));
14
- const initOrUpdatePermissionConfig = {
15
- process: async (config) => {
16
- const allAccounts = {
17
- payer: config.accounts.payer,
18
- authority: config.program.provider.publicKey,
19
- superAdminPermission: utils_1.PDA.getSuperAdmin(),
20
- newAuthority: config.accounts.newAuthority,
21
- permission: utils_1.PDA.getAdmin(config.accounts.newAuthority),
22
- systemProgram: web3_js_1.SystemProgram.programId
23
- };
24
- return {
25
- accounts: config.strict
26
- ? allAccounts
27
- : {
28
- payer: allAccounts.payer,
29
- newAuthority: allAccounts.newAuthority
30
- },
31
- args: {
32
- canCosignSwaps: config.args.canCosignSwaps,
33
- canInitVaults: config.args.canInitVaults,
34
- canLiquidate: config.args.canLiquidate,
35
- canBorrowFromVaults: config.args.canBorrowFromVaults,
36
- canInitPools: config.args.canInitPools,
37
- status: { active: {} }
38
- }
39
- };
40
- },
41
- getMethod: (program) => (args) => program.methods.initOrUpdatePermission(args)
42
- };
43
- async function createInitOrUpdatePermissionInstruction(program, args, accounts, strict = true, increaseCompute = false) {
44
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initOrUpdatePermissionConfig, 'INSTRUCTION', strict, increaseCompute, args));
45
- }
46
- async function initOrUpdatePermission(program, args, accounts, strict = true, increaseCompute = false) {
47
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, initOrUpdatePermissionConfig, 'TRANSACTION', strict, increaseCompute, args));
48
- }
@@ -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 InitStopLossArgs = {
5
- makerAmount: number;
6
- takerAmount: number;
7
- };
8
- export type InitStopLossAccounts = {
9
- position: PublicKey;
10
- };
11
- export declare function createInitStopLossInstruction(program: Program<WasabiSolana>, args: InitStopLossArgs, accounts: InitStopLossAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
12
- export declare function initStopLoss(program: Program<WasabiSolana>, args: InitStopLossArgs, accounts: InitStopLossAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;