wasabi-solana-ts 1.2.3 → 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 +36 -64
  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
@@ -1,90 +0,0 @@
1
- import { TransactionInstruction, PublicKey } from '@solana/web3.js';
2
- import { SwapMode } from './swap';
3
- type MarketInfo = {
4
- id: string;
5
- label: string;
6
- inputMint: string;
7
- outputMint: string;
8
- notEnoughLiquidity: boolean;
9
- inAmount: string;
10
- outAmount: string;
11
- lpFee: {
12
- amount: string;
13
- mint: string;
14
- pct: number;
15
- };
16
- platformFee: {
17
- amount: string;
18
- mint: string;
19
- pct: number;
20
- };
21
- priceImpactPc: number;
22
- };
23
- type Route = {
24
- inAmount: string;
25
- outAmount: string;
26
- priceImpactPc: number;
27
- marketInfos: MarketInfo[];
28
- amount: string;
29
- slippageBps: number;
30
- otherAmountThreshold: string;
31
- swapMode: SwapMode;
32
- fees: {
33
- signatureFee: number;
34
- openOrdersDeposits: number[];
35
- ataDeposits: number[];
36
- totalFeeAndDeposits: number;
37
- minimumSOLForTransaction: number;
38
- };
39
- accountMetas: {
40
- pubkey: string;
41
- isSigner: boolean;
42
- isWritable: boolean;
43
- }[];
44
- };
45
- type TokenInfo = {
46
- address: string;
47
- chainId: number;
48
- decimals: number;
49
- name: string;
50
- symbol: string;
51
- logoURI?: string;
52
- tags?: string[];
53
- };
54
- type QuoteResponse = {
55
- inputMint: string;
56
- outputMint: string;
57
- amount: string;
58
- swapMode: SwapMode;
59
- slippageBps: number;
60
- otherAmountThreshold: string;
61
- routes: Route[];
62
- contextSlot: number;
63
- timeTaken: number;
64
- priceImpactPct: number;
65
- inputTokenInfo: TokenInfo;
66
- outputTokenInfo: TokenInfo;
67
- };
68
- type JupiterInstructionResponse = {
69
- tokenLedgerInstruction?: TransactionInstruction;
70
- computeBudgetInstructions?: TransactionInstruction[];
71
- setupInstructions?: TransactionInstruction[];
72
- swapInstruction: TransactionInstruction;
73
- cleanupInstruction?: TransactionInstruction;
74
- addressLookupTableAddresses?: string[];
75
- };
76
- type CreateSwapInstructionArgs = {
77
- quoteResponse: QuoteResponse;
78
- ownerPubkey: PublicKey;
79
- authorityPubkey?: PublicKey;
80
- wrapUnwrapSOL?: boolean;
81
- computeUnitPriceMicroLamports?: number;
82
- computeUnitsLimit?: number;
83
- };
84
- export declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: number, slippageBps: number, swapMode: SwapMode, options?: {
85
- onlyDirectRoutes?: boolean;
86
- asLegacyTransaction?: boolean;
87
- maxAccounts?: number;
88
- }): Promise<QuoteResponse>;
89
- export declare function createJupiterSwapInstructions({ quoteResponse, ownerPubkey, authorityPubkey, wrapUnwrapSOL, computeUnitPriceMicroLamports, computeUnitsLimit }: CreateSwapInstructionArgs): Promise<JupiterInstructionResponse>;
90
- export {};
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getJupiterQuote = getJupiterQuote;
7
- exports.createJupiterSwapInstructions = createJupiterSwapInstructions;
8
- const cross_fetch_1 = __importDefault(require("cross-fetch"));
9
- async function getJupiterQuote(inputMint, outputMint, amount, slippageBps, swapMode, options) {
10
- const url = new URL('https://quote-api.jup.ag/v6/quote');
11
- const args = {
12
- inputMint: inputMint.toString(),
13
- outputMint: outputMint.toString(),
14
- amount: amount.toString(),
15
- slippageBps: slippageBps.toString()
16
- };
17
- if (swapMode === 'EXACT_OUT') {
18
- args.swapMode = 'ExactOut';
19
- }
20
- if (options) {
21
- if (options.onlyDirectRoutes) {
22
- args.onlyDirectRoutes = 'true';
23
- }
24
- if (options.asLegacyTransaction) {
25
- args.asLegacyTransaction = 'true';
26
- }
27
- if (options.maxAccounts) {
28
- args.maxAccounts = options.maxAccounts.toString();
29
- }
30
- }
31
- url.search = new URLSearchParams(args).toString();
32
- const response = await (0, cross_fetch_1.default)(url.toString());
33
- if (!response.ok) {
34
- throw new Error(`Jupiter API error: ${response.status} - ${response.statusText}`);
35
- }
36
- return response.json();
37
- }
38
- async function createJupiterSwapInstructions({ quoteResponse, ownerPubkey, authorityPubkey, wrapUnwrapSOL = true, computeUnitPriceMicroLamports, computeUnitsLimit }) {
39
- const body = {
40
- quoteResponse,
41
- userPubkey: ownerPubkey.toString(),
42
- wrapUnwrapSOL,
43
- computeUnitPriceMicroLamports,
44
- computeUnitsLimit
45
- };
46
- if (authorityPubkey) {
47
- body.delegateWallet = authorityPubkey.toString();
48
- body.useDelegate = true;
49
- }
50
- const response = await (0, cross_fetch_1.default)('https://quote-api.jup.ag/v6/swap-instructions', {
51
- method: 'POST',
52
- headers: {
53
- 'Content-Type': 'application/json'
54
- },
55
- body: JSON.stringify(body)
56
- });
57
- if (!response.ok) {
58
- throw new Error(`Swap instruction API error: ${response.status} - ${response.statusText}`);
59
- }
60
- return response.json();
61
- }
@@ -1,38 +0,0 @@
1
- import { AmmRpcData, AmmV4Keys } from '@raydium-io/raydium-sdk-v2';
2
- import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
3
- import { SwapMode } from './swap';
4
- type RouteHop = {
5
- poolId: string;
6
- inputMint: string;
7
- outputMint: string;
8
- quotedInAmount: string;
9
- quotedOutAmount: string;
10
- priceImpactPct: number;
11
- poolKeys?: AmmV4Keys;
12
- poolRpcData?: AmmRpcData;
13
- };
14
- export type RouteQuoteResponse = {
15
- inputMint: string;
16
- outputMint: string;
17
- inAmount: string;
18
- outAmount: string;
19
- priceImpactPct: number;
20
- route: RouteHop[];
21
- swapMode: SwapMode;
22
- slippageBps: number;
23
- };
24
- export type RaydiumInstructionResponse = {
25
- computeBudgetInstructions?: TransactionInstruction[];
26
- setupInstructions: TransactionInstruction[];
27
- swapInstructions: TransactionInstruction[];
28
- cleanupInstructions: TransactionInstruction[];
29
- addressLookupTableAddresses?: string[];
30
- };
31
- export declare function getRaydiumRouteQuote(inputMint: PublicKey, outputMint: PublicKey, amount: number, slippageBps: number, poolIds: string[], swapMode: SwapMode, connection: Connection): Promise<RouteQuoteResponse>;
32
- export declare function createRaydiumRouteSwapInstructions({ quoteResponse, ownerPubkey, authorityPubkey, }: {
33
- quoteResponse: RouteQuoteResponse;
34
- ownerPubkey: PublicKey;
35
- authorityPubkey?: PublicKey;
36
- }): Promise<RaydiumInstructionResponse>;
37
- export declare function calculatePriceImpact(amountIn: string | number, amountOut: string | number, reserveIn: string | number, reserveOut: string | number): number;
38
- export {};
@@ -1,170 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRaydiumRouteQuote = getRaydiumRouteQuote;
4
- exports.createRaydiumRouteSwapInstructions = createRaydiumRouteSwapInstructions;
5
- exports.calculatePriceImpact = calculatePriceImpact;
6
- const raydium_sdk_v2_1 = require("@raydium-io/raydium-sdk-v2");
7
- const anchor_1 = require("@coral-xyz/anchor");
8
- const web3_js_1 = require("@solana/web3.js");
9
- const spl_token_1 = require("@solana/spl-token");
10
- async function getRaydiumRouteQuote(inputMint, outputMint, amount, slippageBps, poolIds, swapMode = 'EXACT_IN', connection) {
11
- const raydium = await raydium_sdk_v2_1.Raydium.load({
12
- owner: inputMint,
13
- connection,
14
- disableFeatureCheck: true,
15
- disableLoadToken: true, // TODO: investigate if we need
16
- blockhashCommitment: 'confirmed'
17
- });
18
- const poolDataPromises = poolIds.map(poolId => raydium.liquidity.getPoolInfoFromRpc({ poolId }));
19
- const poolsData = await Promise.all(poolDataPromises);
20
- const poolDataMap = new Map();
21
- poolIds.forEach((poolId, index) => {
22
- poolDataMap.set(poolId, poolsData[index]);
23
- });
24
- let currentAmount = new anchor_1.BN(amount);
25
- const route = [];
26
- let totalPriceImpact = 0;
27
- if (swapMode === 'EXACT_OUT') {
28
- let currentOutputMint = outputMint;
29
- for (let i = poolIds.length - 1; i >= 0; i--) {
30
- const poolId = poolIds[i];
31
- const poolData = poolDataMap.get(poolId);
32
- const { poolInfo, poolKeys, poolRpcData } = poolData;
33
- const currentInputMint = i === 0
34
- ? inputMint
35
- : determineOutputMint(new web3_js_1.PublicKey(poolDataMap.get(poolIds[i - 1]).poolKeys.mintA.address), poolKeys);
36
- const computeResult = raydium.liquidity.computeAmountIn({
37
- poolInfo: {
38
- ...poolInfo,
39
- baseReserve: poolRpcData.baseReserve,
40
- quoteReserve: poolRpcData.quoteReserve,
41
- status: poolRpcData.status.toNumber(),
42
- version: 4
43
- },
44
- amountOut: currentAmount,
45
- mintIn: currentInputMint,
46
- mintOut: currentOutputMint,
47
- slippage: slippageBps / 10000
48
- });
49
- const priceImpact = calculatePriceImpact(computeResult.amountIn.toString(), currentAmount.toString(), poolRpcData.baseReserve.toString(), poolRpcData.quoteReserve.toString());
50
- route.unshift({
51
- poolId,
52
- inputMint: currentInputMint.toString(),
53
- outputMint: currentOutputMint.toString(),
54
- quotedInAmount: computeResult.maxAmountIn.toString(),
55
- quotedOutAmount: currentAmount.toString(),
56
- priceImpactPct: priceImpact,
57
- poolKeys,
58
- poolRpcData
59
- });
60
- currentAmount = computeResult.maxAmountIn;
61
- currentOutputMint = currentInputMint;
62
- totalPriceImpact += priceImpact;
63
- }
64
- return {
65
- inputMint: inputMint.toString(),
66
- outputMint: outputMint.toString(),
67
- inAmount: route[0].quotedInAmount,
68
- outAmount: amount.toString(),
69
- priceImpactPct: totalPriceImpact,
70
- route,
71
- swapMode,
72
- slippageBps
73
- };
74
- }
75
- else {
76
- let currentInputMint = inputMint;
77
- for (let i = 0; i < poolIds.length; i++) {
78
- const poolId = poolIds[i];
79
- const poolData = poolDataMap.get(poolId);
80
- const { poolInfo, poolKeys, poolRpcData } = poolData;
81
- const currentOutputMint = i === poolIds.length - 1
82
- ? outputMint
83
- : determineOutputMint(currentInputMint, poolDataMap.get(poolIds[i + 1]).poolKeys);
84
- const computeResult = raydium.liquidity.computeAmountOut({
85
- poolInfo: {
86
- ...poolInfo,
87
- baseReserve: poolRpcData.baseReserve,
88
- quoteReserve: poolRpcData.quoteReserve,
89
- status: poolRpcData.status.toNumber(),
90
- version: 4
91
- },
92
- amountIn: currentAmount,
93
- mintIn: currentInputMint,
94
- mintOut: currentOutputMint,
95
- slippage: slippageBps / 10000
96
- });
97
- const priceImpact = calculatePriceImpact(currentAmount.toString(), computeResult.amountOut.toString(), poolRpcData.baseReserve.toString(), poolRpcData.quoteReserve.toString());
98
- route.push({
99
- poolId,
100
- inputMint: currentInputMint.toString(),
101
- outputMint: currentOutputMint.toString(),
102
- quotedInAmount: currentAmount.toString(),
103
- quotedOutAmount: computeResult.amountOut.toString(),
104
- priceImpactPct: priceImpact,
105
- poolKeys,
106
- poolRpcData
107
- });
108
- currentAmount = computeResult.amountOut;
109
- currentInputMint = currentOutputMint;
110
- totalPriceImpact += priceImpact;
111
- }
112
- return {
113
- inputMint: inputMint.toString(),
114
- outputMint: outputMint.toString(),
115
- inAmount: amount.toString(),
116
- outAmount: route[route.length - 1].quotedOutAmount,
117
- priceImpactPct: totalPriceImpact,
118
- route,
119
- swapMode,
120
- slippageBps
121
- };
122
- }
123
- }
124
- function determineOutputMint(currentInputMint, nextPoolKeys) {
125
- const mintA = new web3_js_1.PublicKey(nextPoolKeys.mintA.address);
126
- return currentInputMint.equals(mintA)
127
- ? new web3_js_1.PublicKey(nextPoolKeys.mintB.address)
128
- : mintA;
129
- }
130
- async function createRaydiumRouteSwapInstructions({ quoteResponse, ownerPubkey, authorityPubkey, }) {
131
- const swapInstructions = [];
132
- for (let i = 0; i < quoteResponse.route.length; i++) {
133
- const hop = quoteResponse.route[i];
134
- if (!hop.poolKeys || !hop.poolRpcData) {
135
- throw new Error(`Hop ${i} missing required pool information`);
136
- }
137
- const inputMint = new web3_js_1.PublicKey(hop.inputMint);
138
- const outputMint = new web3_js_1.PublicKey(hop.outputMint);
139
- const tokenAccountIn = (0, spl_token_1.getAssociatedTokenAddressSync)(inputMint, ownerPubkey, true);
140
- const tokenAccountOut = (0, spl_token_1.getAssociatedTokenAddressSync)(outputMint, ownerPubkey, true);
141
- const instructionParams = {
142
- version: 4,
143
- poolKeys: hop.poolKeys,
144
- userKeys: {
145
- tokenAccountIn,
146
- tokenAccountOut,
147
- owner: authorityPubkey ? authorityPubkey : ownerPubkey
148
- },
149
- amountIn: new anchor_1.BN(hop.quotedInAmount),
150
- amountOut: new anchor_1.BN(hop.quotedOutAmount),
151
- fixedSide: quoteResponse.swapMode === 'EXACT_IN' ? 'in' : 'out'
152
- };
153
- const swapInstruction = (0, raydium_sdk_v2_1.makeAMMSwapInstruction)(instructionParams);
154
- swapInstructions.push(swapInstruction);
155
- }
156
- return {
157
- setupInstructions: [],
158
- swapInstructions,
159
- cleanupInstructions: []
160
- };
161
- }
162
- function calculatePriceImpact(amountIn, amountOut, reserveIn, reserveOut) {
163
- const in_bn = new anchor_1.BN(amountIn.toString()).toNumber() / 10 ** 6;
164
- const out_bn = new anchor_1.BN(amountOut.toString()).toNumber() / 10 ** 6;
165
- const reserveIn_bn = new anchor_1.BN(reserveIn.toString()).toNumber() / 10 ** 6;
166
- const reserveOut_bn = new anchor_1.BN(reserveOut.toString()).toNumber() / 10 ** 6;
167
- const priceBefore = reserveOut_bn / reserveIn_bn;
168
- const priceAfter = (reserveOut_bn - out_bn) / (reserveIn_bn + in_bn);
169
- return (priceBefore - priceAfter) * 100 / priceBefore;
170
- }
@@ -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 createUpdateLongPositionInstruction(program: Program<WasabiSolana>, args: OpenPositionArgs, accounts: OpenPositionAccounts, mintCache?: MintCache): Promise<TransactionInstruction[]>;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createUpdateLongPositionInstruction = createUpdateLongPositionInstruction;
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 updateLongPositionConfig = {
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.getLongPool(config.accounts.collateral, config.accounts.currency);
15
- if (!config.args.positionId) {
16
- throw new Error('positionId is required for `UpdateLongPosition`');
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: true,
26
- currency: config.accounts.currency,
27
- collateral: config.accounts.collateral
28
- });
29
- return {
30
- accounts: {
31
- owner: config.accounts.owner,
32
- ownerCurrencyAccount: 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
- tokenProgram: currencyTokenProgram,
45
- debtController: utils_1.PDA.getDebtController(),
46
- globalSettings: utils_1.PDA.getGlobalSettings(),
47
- systemProgram: web3_js_1.SystemProgram.programId
48
- },
49
- args: {
50
- ...config.args,
51
- hops,
52
- data
53
- },
54
- setup: setupIx,
55
- cleanup: cleanupIx,
56
- remainingAccounts
57
- };
58
- },
59
- getMethod: (program) => (args) => program.methods.updateLongPosition(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)
60
- };
61
- async function createUpdateLongPositionInstruction(program, args, accounts, mintCache) {
62
- return (0, base_1.handleMethodCall)({
63
- program,
64
- accounts,
65
- config: updateLongPositionConfig,
66
- args,
67
- mintCache
68
- });
69
- }
@@ -1,12 +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 UpdateVaultMaxBorrowArgs = {
5
- maxBorrow: number;
6
- };
7
- export type UpdateVaultMaxBorrowAccounts = {
8
- authority: PublicKey;
9
- assetMint: PublicKey;
10
- };
11
- export declare function createUpdateVaultMaxBorrowInstruction(program: Program<WasabiSolana>, args: UpdateVaultMaxBorrowArgs, accounts: UpdateVaultMaxBorrowAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionInstruction[]>;
12
- export declare function updateVaultMaxBorrow(program: Program<WasabiSolana>, args: UpdateVaultMaxBorrowArgs, accounts: UpdateVaultMaxBorrowAccounts, strict?: boolean, increaseCompute?: boolean): Promise<TransactionSignature>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createUpdateVaultMaxBorrowInstruction = createUpdateVaultMaxBorrowInstruction;
4
- exports.updateVaultMaxBorrow = updateVaultMaxBorrow;
5
- const anchor_1 = require("@coral-xyz/anchor");
6
- const base_1 = require("../base");
7
- const utils_1 = require("../utils");
8
- const updateVaultMaxBorrowConfig = {
9
- process: async (config) => {
10
- const admin = utils_1.PDA.getAdmin(config.accounts.authority);
11
- const allAccounts = {
12
- payer: config.program.provider.publicKey,
13
- authority: config.accounts.authority,
14
- permission: await (0, utils_1.getPermission)(config.program, admin),
15
- lpVault: utils_1.PDA.getLpVault(config.accounts.assetMint)
16
- };
17
- return {
18
- accounts: config.strict
19
- ? allAccounts
20
- : {
21
- payer: allAccounts.payer,
22
- permission: allAccounts.permission,
23
- lpVault: allAccounts.lpVault
24
- },
25
- args: config.args ? new anchor_1.BN(config.args.maxBorrow) : undefined
26
- };
27
- },
28
- getMethod: (program) => (args) => program.methods.updateLpVaultMaxBorrow(args)
29
- };
30
- async function createUpdateVaultMaxBorrowInstruction(program, args, accounts, strict = true, increaseCompute = false) {
31
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, updateVaultMaxBorrowConfig, 'INSTRUCTION', strict, increaseCompute, args));
32
- }
33
- async function updateVaultMaxBorrow(program, args, accounts, strict = true, increaseCompute = false) {
34
- return (0, base_1.handleMethodCall)((0, base_1.constructMethodCallArgs)(program, accounts, updateVaultMaxBorrowConfig, 'TRANSACTION', strict, increaseCompute, args));
35
- }
@@ -1,42 +0,0 @@
1
- import { Connection, VersionedTransaction, Keypair, PublicKey, Transaction, Signer } from '@solana/web3.js';
2
- import { JitoClient } from './jitoTypes';
3
- export interface Sender {
4
- transactions: VersionedTransaction[];
5
- send: () => Promise<string>;
6
- }
7
- export interface ProviderOptions {
8
- tipAmount?: number;
9
- transactionLimit?: number;
10
- }
11
- export type TransactionSigner = {
12
- signTransaction?: ((transaction: VersionedTransaction) => Promise<VersionedTransaction>) | (<T extends Transaction | VersionedTransaction>(transaction: T) => Promise<T>);
13
- signAllTransactions?: ((transactions: VersionedTransaction[]) => Promise<VersionedTransaction[]>) | (<T extends Transaction | VersionedTransaction>(transactions: T[]) => Promise<T>);
14
- } | Keypair | Signer;
15
- export declare const baseSender: (connection: Connection, confirm?: boolean) => (transactions: VersionedTransaction[]) => Promise<Sender>;
16
- export declare class ProviderBuilder {
17
- private connection;
18
- private payer;
19
- private simulateTransaction;
20
- private confirmTransaction;
21
- private providerClient?;
22
- private options;
23
- private transactions;
24
- setConnection(connection: Connection): this;
25
- setPayer(payer: PublicKey): this;
26
- setSimulateTransaction(simulateTransaction: boolean): this;
27
- setConfirmTransaction(confirmTransaction: boolean): this;
28
- setProviderClient(providerClient: JitoClient): this;
29
- setOptions(options: ProviderOptions): this;
30
- addTransactions(...transactions: VersionedTransaction[]): this;
31
- setTransactions(transactions: VersionedTransaction[]): this;
32
- addSerializedTransactions(...transaction: string[]): this;
33
- setSerializedTransactions(transactions: string[]): this;
34
- setProviderOptions(options: ProviderOptions): this;
35
- getTransactions(): VersionedTransaction[];
36
- private getSender;
37
- sign(transactions: VersionedTransaction[], signer: TransactionSigner): Promise<this>;
38
- private simulate;
39
- private validateSignatures;
40
- private validateSignedTransactions;
41
- build(signer: TransactionSigner): Promise<Sender>;
42
- }