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.
- package/dist/base/base.d.ts +2 -2
- package/dist/cache/BaseAccountCache.d.ts +44 -0
- package/dist/cache/BaseAccountCache.js +80 -0
- package/dist/cache/TokenMintCache.d.ts +14 -0
- package/dist/cache/TokenMintCache.js +25 -0
- package/dist/index.d.ts +3 -3
- package/dist/instructions/closeLongPosition.d.ts +3 -3
- package/dist/instructions/closePosition.d.ts +2 -2
- package/dist/instructions/closePositionV2.d.ts +2 -2
- package/dist/instructions/closeShortPosition.d.ts +3 -3
- package/dist/instructions/donate.d.ts +2 -2
- package/dist/instructions/increaseLongPositionSetup.d.ts +2 -2
- package/dist/instructions/increaseShortPositionSetup.d.ts +2 -2
- package/dist/instructions/initPool.d.ts +2 -2
- package/dist/instructions/liquidatePosition.d.ts +3 -3
- package/dist/instructions/liquidatePositionV2.d.ts +2 -2
- package/dist/instructions/openLongPosition.d.ts +3 -3
- package/dist/instructions/openLongPosition.js +1 -1
- package/dist/instructions/openShortPosition.d.ts +3 -3
- package/dist/instructions/openShortPosition.js +1 -1
- package/dist/instructions/stopLoss.d.ts +3 -3
- package/dist/instructions/stopLossV2.d.ts +2 -2
- package/dist/instructions/takeProfit.d.ts +3 -3
- package/dist/instructions/takeProfitV2.d.ts +2 -2
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/utils.d.ts +10 -11
- package/dist/utils/utils.js +36 -64
- package/package.json +5 -3
- package/dist/instructions/closeWallet.d.ts +0 -20
- package/dist/instructions/closeWallet.js +0 -34
- package/dist/instructions/collectFees.d.ts +0 -22
- package/dist/instructions/collectFees.js +0 -40
- package/dist/instructions/generateWallet.d.ts +0 -22
- package/dist/instructions/generateWallet.js +0 -36
- package/dist/instructions/increaseShortPosition.d.ts +0 -6
- package/dist/instructions/increaseShortPosition.js +0 -70
- package/dist/instructions/initDebtController.d.ts +0 -24
- package/dist/instructions/initDebtController.js +0 -37
- package/dist/instructions/initGlobalSettings.d.ts +0 -9
- package/dist/instructions/initGlobalSettings.js +0 -32
- package/dist/instructions/initOrUpdatePermission.d.ts +0 -22
- package/dist/instructions/initOrUpdatePermission.js +0 -48
- package/dist/instructions/initStopLossOrder.d.ts +0 -12
- package/dist/instructions/initStopLossOrder.js +0 -40
- package/dist/instructions/initTakeProfitOrder.d.ts +0 -12
- package/dist/instructions/initTakeProfitOrder.js +0 -40
- package/dist/instructions/mint.d.ts +0 -8
- package/dist/instructions/mint.js +0 -35
- package/dist/instructions/removePermission.d.ts +0 -16
- package/dist/instructions/removePermission.js +0 -25
- package/dist/instructions/repay.d.ts +0 -11
- package/dist/instructions/repay.js +0 -44
- package/dist/instructions/setLpState.d.ts +0 -11
- package/dist/instructions/setLpState.js +0 -28
- package/dist/instructions/setMaxApy.d.ts +0 -11
- package/dist/instructions/setMaxApy.js +0 -31
- package/dist/instructions/setMaxLeverage.d.ts +0 -11
- package/dist/instructions/setMaxLeverage.js +0 -31
- package/dist/instructions/setSuperAdmin.d.ts +0 -11
- package/dist/instructions/setSuperAdmin.js +0 -27
- package/dist/instructions/setTradeState.d.ts +0 -11
- package/dist/instructions/setTradeState.js +0 -28
- package/dist/instructions/swap.d.ts +0 -30
- package/dist/instructions/swap.js +0 -91
- package/dist/instructions/swapJupiter.d.ts +0 -90
- package/dist/instructions/swapJupiter.js +0 -61
- package/dist/instructions/swapRaydium.d.ts +0 -38
- package/dist/instructions/swapRaydium.js +0 -170
- package/dist/instructions/updateLongPosition.d.ts +0 -6
- package/dist/instructions/updateLongPosition.js +0 -69
- package/dist/instructions/updateLpVaultMaxBorrow.d.ts +0 -12
- package/dist/instructions/updateLpVaultMaxBorrow.js +0 -35
- package/dist/sender-provider/baseSenderProvider.d.ts +0 -42
- package/dist/sender-provider/baseSenderProvider.js +0 -178
- package/dist/sender-provider/index.d.ts +0 -5
- package/dist/sender-provider/index.js +0 -21
- package/dist/sender-provider/jitoBrowser.d.ts +0 -2
- package/dist/sender-provider/jitoBrowser.js +0 -32
- package/dist/sender-provider/jitoSenderProvider.d.ts +0 -5
- package/dist/sender-provider/jitoSenderProvider.js +0 -69
- package/dist/sender-provider/jitoServer.d.ts +0 -2
- package/dist/sender-provider/jitoServer.js +0 -67
- package/dist/sender-provider/jitoTips.d.ts +0 -17
- package/dist/sender-provider/jitoTips.js +0 -75
- package/dist/sender-provider/jitoTypes.d.ts +0 -12
- package/dist/sender-provider/jitoTypes.js +0 -6
- package/dist/utils/mintCache.d.ts +0 -10
- package/dist/utils/mintCache.js +0 -39
package/dist/base/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { TransactionInstruction, TransactionSignature, PublicKey, AccountMeta } from '@solana/web3.js';
|
|
3
3
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
4
|
-
import {
|
|
4
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
5
5
|
export type ProcessResult<T> = {
|
|
6
6
|
accounts: T;
|
|
7
7
|
args?: any;
|
|
@@ -13,7 +13,7 @@ export type ConfigArgs<TArgs, TAccounts> = {
|
|
|
13
13
|
program: Program<WasabiSolana>;
|
|
14
14
|
accounts: TAccounts;
|
|
15
15
|
args?: TArgs;
|
|
16
|
-
mintCache?:
|
|
16
|
+
mintCache?: TokenMintCache;
|
|
17
17
|
};
|
|
18
18
|
export type MethodCallArgs<TArgs, TAccounts, TProgramAccounts> = {
|
|
19
19
|
config: BaseMethodConfig<TArgs, TAccounts, TProgramAccounts>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AccountInfo, Connection, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import NodeCache from 'node-cache';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for account caches
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the parsed accounts
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class BaseAccountCache<T> {
|
|
9
|
+
protected readonly connection: Connection;
|
|
10
|
+
protected readonly cache: NodeCache;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new account cache
|
|
13
|
+
*
|
|
14
|
+
* @param connection - The connection to use
|
|
15
|
+
* @param options - The options for the cache
|
|
16
|
+
*/
|
|
17
|
+
constructor(connection: Connection, options?: NodeCache.Options);
|
|
18
|
+
/**
|
|
19
|
+
* Get multiple accounts from the cache or the connection and parse them
|
|
20
|
+
*
|
|
21
|
+
* @param addresses - The addresses of the accounts to get
|
|
22
|
+
* @returns A map of the addresses to the parsed accounts
|
|
23
|
+
*/
|
|
24
|
+
getAccountsStr(addresses: string[]): Promise<Map<string, T>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get multiple accounts from the cache or the connection and parse them
|
|
27
|
+
*
|
|
28
|
+
* @param addresses - The addresses of the accounts to get
|
|
29
|
+
* @returns A map of the addresses to the parsed accounts
|
|
30
|
+
*/
|
|
31
|
+
getAccounts(addresses: PublicKey[]): Promise<Map<string, T>>;
|
|
32
|
+
/**
|
|
33
|
+
* Get a single account from the cache or the connection and parse it
|
|
34
|
+
*
|
|
35
|
+
* @param address - The address of the account to get
|
|
36
|
+
* @returns The parsed account
|
|
37
|
+
*/
|
|
38
|
+
getAccount(address: PublicKey): Promise<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Parse an account from its raw data
|
|
41
|
+
* @param account - The raw account data
|
|
42
|
+
*/
|
|
43
|
+
protected abstract parseAccount(account: AccountInfo<Buffer>): T;
|
|
44
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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.BaseAccountCache = void 0;
|
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
9
|
+
/**
|
|
10
|
+
* Base class for account caches
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type of the parsed accounts
|
|
13
|
+
*/
|
|
14
|
+
class BaseAccountCache {
|
|
15
|
+
connection;
|
|
16
|
+
cache;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new account cache
|
|
19
|
+
*
|
|
20
|
+
* @param connection - The connection to use
|
|
21
|
+
* @param options - The options for the cache
|
|
22
|
+
*/
|
|
23
|
+
constructor(connection, options) {
|
|
24
|
+
this.connection = connection;
|
|
25
|
+
this.cache = new node_cache_1.default(options);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get multiple accounts from the cache or the connection and parse them
|
|
29
|
+
*
|
|
30
|
+
* @param addresses - The addresses of the accounts to get
|
|
31
|
+
* @returns A map of the addresses to the parsed accounts
|
|
32
|
+
*/
|
|
33
|
+
async getAccountsStr(addresses) {
|
|
34
|
+
return this.getAccounts(addresses.map(addr => new web3_js_1.PublicKey(addr)));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get multiple accounts from the cache or the connection and parse them
|
|
38
|
+
*
|
|
39
|
+
* @param addresses - The addresses of the accounts to get
|
|
40
|
+
* @returns A map of the addresses to the parsed accounts
|
|
41
|
+
*/
|
|
42
|
+
async getAccounts(addresses) {
|
|
43
|
+
const result = new Map();
|
|
44
|
+
const missingAddresses = new Set();
|
|
45
|
+
for (const address of addresses) {
|
|
46
|
+
const cachedAccount = this.cache.get(address.toString());
|
|
47
|
+
if (cachedAccount) {
|
|
48
|
+
result.set(address.toString(), cachedAccount);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
missingAddresses.add(address);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (missingAddresses.size > 0) {
|
|
55
|
+
const missingAddressesArray = Array.from(missingAddresses);
|
|
56
|
+
const accounts = await this.connection.getMultipleAccountsInfo(missingAddressesArray);
|
|
57
|
+
for (let i = 0; i < accounts.length; i++) {
|
|
58
|
+
const account = accounts[i];
|
|
59
|
+
const address = missingAddressesArray[i];
|
|
60
|
+
if (account) {
|
|
61
|
+
const parsedAccount = this.parseAccount(account);
|
|
62
|
+
result.set(address.toString(), parsedAccount);
|
|
63
|
+
this.cache.set(address.toString(), parsedAccount);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get a single account from the cache or the connection and parse it
|
|
71
|
+
*
|
|
72
|
+
* @param address - The address of the account to get
|
|
73
|
+
* @returns The parsed account
|
|
74
|
+
*/
|
|
75
|
+
async getAccount(address) {
|
|
76
|
+
const result = await this.getAccounts([address]);
|
|
77
|
+
return result.get(address.toString());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.BaseAccountCache = BaseAccountCache;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AccountInfo, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { BaseAccountCache } from './BaseAccountCache';
|
|
3
|
+
import { RawMint } from '@solana/spl-token';
|
|
4
|
+
export type TokenMintData = {
|
|
5
|
+
program: PublicKey;
|
|
6
|
+
mintData: RawMint;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A class that caches token mint account data
|
|
10
|
+
*/
|
|
11
|
+
export declare class TokenMintCache extends BaseAccountCache<TokenMintData> {
|
|
12
|
+
protected parseAccount(account: AccountInfo<Buffer>): TokenMintData;
|
|
13
|
+
getMintToDecimals(mints: PublicKey[]): Promise<Map<string, number>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenMintCache = void 0;
|
|
4
|
+
const BaseAccountCache_1 = require("./BaseAccountCache");
|
|
5
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
6
|
+
/**
|
|
7
|
+
* A class that caches token mint account data
|
|
8
|
+
*/
|
|
9
|
+
class TokenMintCache extends BaseAccountCache_1.BaseAccountCache {
|
|
10
|
+
parseAccount(account) {
|
|
11
|
+
return {
|
|
12
|
+
program: account.owner,
|
|
13
|
+
mintData: spl_token_1.MintLayout.decode(account.data),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async getMintToDecimals(mints) {
|
|
17
|
+
const m = await this.getAccounts(mints);
|
|
18
|
+
const mintMap = new Map();
|
|
19
|
+
m.forEach((value, key) => {
|
|
20
|
+
mintMap.set(key, value.mintData.decimals);
|
|
21
|
+
});
|
|
22
|
+
return mintMap;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.TokenMintCache = TokenMintCache;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,15 +13,15 @@ import { WasabiSolana } from './idl/wasabi_solana.js';
|
|
|
13
13
|
import * as idl from './idl/wasabi_solana.json';
|
|
14
14
|
export { idl };
|
|
15
15
|
import { Program } from '@coral-xyz/anchor';
|
|
16
|
-
import { MintCache } from './utils/mintCache.js';
|
|
17
16
|
import { OpenPositionCleanupAccounts, OpenPositionSetupAccounts, OpenPositionSetupArgs } from './instructions/openPosition.js';
|
|
18
17
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
19
18
|
import { ClosePositionCleanupAccounts, ClosePositionSetupAccounts, ClosePositionSetupArgs } from './instructions/closePosition.js';
|
|
20
19
|
import { OpenPositionArgs, OpenPositionAccounts } from './instructions';
|
|
20
|
+
import { TokenMintCache } from "./cache/TokenMintCache";
|
|
21
21
|
export declare class Wasabi {
|
|
22
22
|
program: Program<WasabiSolana>;
|
|
23
|
-
mintCache:
|
|
24
|
-
constructor(program: Program<WasabiSolana>, mintCache:
|
|
23
|
+
mintCache: TokenMintCache;
|
|
24
|
+
constructor(program: Program<WasabiSolana>, mintCache: TokenMintCache);
|
|
25
25
|
createOpenLongPositionInstruction(args: OpenPositionArgs, accounts: OpenPositionAccounts): Promise<TransactionInstruction[]>;
|
|
26
26
|
createOpenLongWithSharesInstruction(args: OpenPositionArgs, accounts: OpenPositionAccounts): Promise<TransactionInstruction[]>;
|
|
27
27
|
createOpenShortPositionInstruction(args: OpenPositionArgs, accounts: OpenPositionAccounts): Promise<TransactionInstruction[]>;
|
|
@@ -2,6 +2,6 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { ClosePositionSetupArgs, ClosePositionSetupAccounts, ClosePositionCleanupAccounts } from './closePosition';
|
|
4
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
5
|
-
import {
|
|
6
|
-
export declare function createCloseLongPositionSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?:
|
|
7
|
-
export declare function createCloseLongPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?:
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createCloseLongPositionSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
7
|
+
export declare function createCloseLongPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Program, BN } from '@coral-xyz/anchor';
|
|
2
2
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
4
|
-
import {
|
|
4
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
5
5
|
export type CloseType = 'MARKET' | 'LIQUIDATION' | 'TAKE_PROFIT' | 'STOP_LOSS';
|
|
6
6
|
export type ExitOrderSetupInstructionAccounts = {
|
|
7
7
|
closePositionSetup: ClosePositionSetupInstructionAccounts;
|
|
@@ -99,7 +99,7 @@ export declare function transformArgs(args: ClosePositionSetupArgs): {
|
|
|
99
99
|
executionFee: BN;
|
|
100
100
|
expiration: BN;
|
|
101
101
|
};
|
|
102
|
-
export declare function getClosePositionSetupInstructionAccounts(program: Program<WasabiSolana>, accounts: ClosePositionSetupAccounts, closeType?: CloseType, mintCache?:
|
|
102
|
+
export declare function getClosePositionSetupInstructionAccounts(program: Program<WasabiSolana>, accounts: ClosePositionSetupAccounts, closeType?: CloseType, mintCache?: TokenMintCache, amount?: number): Promise<CpsuAndIx>;
|
|
103
103
|
export declare function handleOrdersCheck(program: Program<WasabiSolana>, positionAddress: PublicKey, closeType?: CloseType, amount?: number): Promise<TransactionInstruction[]>;
|
|
104
104
|
export declare function getClosePositionCleanupInstructionAccounts(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, isTriggeredByAuthority?: boolean): Promise<CpcuAndIx>;
|
|
105
105
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
import { WasabiSolana } from '../idl';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
|
-
import {
|
|
4
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
5
5
|
export type ClosePositionArgs = {
|
|
6
6
|
amount: number | bigint;
|
|
7
7
|
minTargetAmount: number | bigint;
|
|
@@ -43,4 +43,4 @@ export type ClosePositionInternalInstructionAccounts = {
|
|
|
43
43
|
collateralTokenProgram: PublicKey;
|
|
44
44
|
systemProgram: PublicKey;
|
|
45
45
|
};
|
|
46
|
-
export declare function createClosePositionInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?:
|
|
46
|
+
export declare function createClosePositionInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -2,6 +2,6 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { ClosePositionSetupArgs, ClosePositionSetupAccounts, ClosePositionCleanupAccounts } from './closePosition';
|
|
4
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
5
|
-
import {
|
|
6
|
-
export declare function createCloseShortPositionSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?:
|
|
7
|
-
export declare function createCloseShortPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?:
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createCloseShortPositionSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
7
|
+
export declare function createCloseShortPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { TransactionInstruction, PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { MintCache } from '../utils';
|
|
4
3
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
4
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
5
5
|
export type DonateArgs = {
|
|
6
6
|
amount: bigint;
|
|
7
7
|
};
|
|
8
8
|
export type DonateAccounts = {
|
|
9
9
|
currency: PublicKey;
|
|
10
10
|
};
|
|
11
|
-
export declare function createDonateInstruction(program: Program<WasabiSolana>, args: DonateArgs, accounts: DonateAccounts, mintCache?:
|
|
11
|
+
export declare function createDonateInstruction(program: Program<WasabiSolana>, args: DonateArgs, accounts: DonateAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenPositionSetupAccounts, OpenPositionSetupArgs } from './openPosition';
|
|
2
|
-
import { MintCache } from '../utils';
|
|
3
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
4
3
|
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
6
|
-
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createIncreaseLongPositionSetupInstruction(program: Program<WasabiSolana>, args: OpenPositionSetupArgs, accounts: OpenPositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenPositionSetupAccounts, OpenPositionSetupArgs } from './openPosition';
|
|
2
|
-
import { MintCache } from '../utils';
|
|
3
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
4
3
|
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
6
|
-
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createIncreaseShortPositionSetupInstruction(program: Program<WasabiSolana>, args: OpenPositionSetupArgs, accounts: OpenPositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
4
|
-
import {
|
|
4
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
5
5
|
export type InitPoolAccounts = {
|
|
6
6
|
currency: PublicKey;
|
|
7
7
|
collateral: PublicKey;
|
|
@@ -21,4 +21,4 @@ export type InitPoolInstructionAccounts = {
|
|
|
21
21
|
associatedTokenProgram: PublicKey;
|
|
22
22
|
systemProgram: PublicKey;
|
|
23
23
|
};
|
|
24
|
-
export declare function getInitPoolInstructionAccounts(program: Program<WasabiSolana>, accounts: InitPoolAccounts, pool_type: 'long' | 'short', mintCache?:
|
|
24
|
+
export declare function getInitPoolInstructionAccounts(program: Program<WasabiSolana>, accounts: InitPoolAccounts, pool_type: 'long' | 'short', mintCache?: TokenMintCache): Promise<InitPoolInstructionAccounts>;
|
|
@@ -2,6 +2,6 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { ClosePositionSetupArgs, ClosePositionSetupAccounts, ClosePositionCleanupAccounts } from './closePosition';
|
|
4
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
5
|
-
import {
|
|
6
|
-
export declare function createLiquidatePositionSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?:
|
|
7
|
-
export declare function createLiquidatePositionCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?:
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createLiquidatePositionSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
7
|
+
export declare function createLiquidatePositionCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -2,5 +2,5 @@ import { ClosePositionAccounts, ClosePositionArgs } from './closePositionV2';
|
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
4
|
import { WasabiSolana } from '../idl';
|
|
5
|
-
import {
|
|
6
|
-
export declare function createLiquidatePositionInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?:
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createLiquidatePositionInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -2,12 +2,12 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
2
2
|
import { TransactionInstruction, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { OpenPositionSetupArgs, OpenPositionSetupAccounts, OpenPositionCleanupAccounts, OpenPositionSetupInstructionBaseAccounts } from './openPosition';
|
|
4
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
5
|
-
import {
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
6
|
export type OpenLongPositionSetupInstructionAccounts = {
|
|
7
7
|
ownerCollateralAccount: PublicKey;
|
|
8
8
|
openPositionRequest: PublicKey;
|
|
9
9
|
debtController: PublicKey;
|
|
10
10
|
tokenProgram: PublicKey;
|
|
11
11
|
} & OpenPositionSetupInstructionBaseAccounts;
|
|
12
|
-
export declare function createOpenLongPositionSetupInstruction(program: Program<WasabiSolana>, args: OpenPositionSetupArgs, accounts: OpenPositionSetupAccounts, mintCache?:
|
|
13
|
-
export declare function createOpenLongPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: OpenPositionCleanupAccounts, mintCache?:
|
|
12
|
+
export declare function createOpenLongPositionSetupInstruction(program: Program<WasabiSolana>, args: OpenPositionSetupArgs, accounts: OpenPositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
13
|
+
export declare function createOpenLongPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: OpenPositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -59,7 +59,7 @@ const openLongPositionSetupConfig = {
|
|
|
59
59
|
};
|
|
60
60
|
const openLongPositionCleanupConfig = {
|
|
61
61
|
process: async (config) => {
|
|
62
|
-
const { currencyMint, collateralMint, currencyTokenProgram, collateralTokenProgram } = await (0, utils_1.handleMintsAndTokenProgram)(config.program.provider.connection, config.accounts.currency, config.accounts.collateral, {
|
|
62
|
+
const { currencyMint, collateralMint, currencyTokenProgram, collateralTokenProgram } = await (0, utils_1.handleMintsAndTokenProgram)(config.program.provider.connection, config.accounts.currency, config.accounts.collateral, { mintCache: config.mintCache });
|
|
63
63
|
return {
|
|
64
64
|
accounts: {
|
|
65
65
|
owner: config.accounts.owner,
|
|
@@ -2,7 +2,7 @@ import { Program } from '@coral-xyz/anchor';
|
|
|
2
2
|
import { TransactionInstruction, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { OpenPositionSetupArgs, OpenPositionSetupAccounts, OpenPositionCleanupAccounts } from './openPosition';
|
|
4
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
5
|
-
import {
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
6
|
export type OpenShortPositionSetupInstructionAccounts = {
|
|
7
7
|
owner: PublicKey;
|
|
8
8
|
ownerCurrencyAccount: PublicKey;
|
|
@@ -40,5 +40,5 @@ export type OpenShortPositionCleanupInstructionAccounts = {
|
|
|
40
40
|
debtController: PublicKey;
|
|
41
41
|
tokenProgram: PublicKey;
|
|
42
42
|
};
|
|
43
|
-
export declare function createOpenShortPositionSetupInstruction(program: Program<WasabiSolana>, args: OpenPositionSetupArgs, accounts: OpenPositionSetupAccounts, mintCache?:
|
|
44
|
-
export declare function createOpenShortPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: OpenPositionCleanupAccounts, mintCache?:
|
|
43
|
+
export declare function createOpenShortPositionSetupInstruction(program: Program<WasabiSolana>, args: OpenPositionSetupArgs, accounts: OpenPositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
44
|
+
export declare function createOpenShortPositionCleanupInstruction(program: Program<WasabiSolana>, accounts: OpenPositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -58,7 +58,7 @@ const openShortPositionSetupConfig = {
|
|
|
58
58
|
};
|
|
59
59
|
const openShortPositionCleanupConfig = {
|
|
60
60
|
process: async (config) => {
|
|
61
|
-
const { currencyMint, collateralMint, currencyTokenProgram, collateralTokenProgram } = await (0, utils_1.handleMintsAndTokenProgram)(config.program.provider.connection, config.accounts.currency, config.accounts.collateral, {
|
|
61
|
+
const { currencyMint, collateralMint, currencyTokenProgram, collateralTokenProgram } = await (0, utils_1.handleMintsAndTokenProgram)(config.program.provider.connection, config.accounts.currency, config.accounts.collateral, { mintCache: config.mintCache });
|
|
62
62
|
const lpVault = utils_1.PDA.getLpVault(config.accounts.currency);
|
|
63
63
|
return {
|
|
64
64
|
accounts: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { ClosePositionSetupArgs, ClosePositionSetupAccounts, ClosePositionCleanupAccounts } from './closePosition';
|
|
4
|
-
import { MintCache } from '../utils';
|
|
5
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
6
|
-
|
|
7
|
-
export declare function
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createStopLossSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
7
|
+
export declare function createStopLossCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -2,5 +2,5 @@ import { ClosePositionAccounts, ClosePositionArgs } from './closePositionV2';
|
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { WasabiSolana } from '../idl';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
|
-
import {
|
|
6
|
-
export declare function createStopLossInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?:
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createStopLossInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { ClosePositionSetupArgs, ClosePositionSetupAccounts, ClosePositionCleanupAccounts } from './closePosition';
|
|
4
|
-
import { MintCache } from '../utils';
|
|
5
4
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
6
|
-
|
|
7
|
-
export declare function
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createTakeProfitSetupInstruction(program: Program<WasabiSolana>, args: ClosePositionSetupArgs, accounts: ClosePositionSetupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
7
|
+
export declare function createTakeProfitCleanupInstruction(program: Program<WasabiSolana>, accounts: ClosePositionCleanupAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
|
@@ -2,5 +2,5 @@ import { ClosePositionAccounts, ClosePositionArgs } from './closePositionV2';
|
|
|
2
2
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
4
|
import { WasabiSolana } from '../idl';
|
|
5
|
-
import {
|
|
6
|
-
export declare function createTakeProfitInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?:
|
|
5
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
6
|
+
export declare function createTakeProfitInstruction(program: Program<WasabiSolana>, args: ClosePositionArgs, accounts: ClosePositionAccounts, mintCache?: TokenMintCache): Promise<TransactionInstruction[]>;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PublicKey, Connection, TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
import { Program, BN, IdlAccounts } from '@coral-xyz/anchor';
|
|
3
3
|
import { WasabiSolana } from '../idl/wasabi_solana';
|
|
4
|
-
import {
|
|
4
|
+
import { TokenMintCache } from "../cache/TokenMintCache";
|
|
5
5
|
export declare const SOL_MINT: PublicKey;
|
|
6
6
|
export declare const WASABI_PROGRAM_ID: PublicKey;
|
|
7
7
|
export declare const METADATA_PROGRAM_ID: PublicKey;
|
|
@@ -25,7 +25,7 @@ export declare const SEED_PREFIX: {
|
|
|
25
25
|
export declare function getPermission(program: Program<WasabiSolana>, admin: PublicKey): Promise<PublicKey>;
|
|
26
26
|
export declare function uiAmountToAmount(uiAmount: number, decimals: number): BN;
|
|
27
27
|
export declare function amountToUiAmount(amount: BN, decimals: number): number;
|
|
28
|
-
export declare function getTokenProgram(connection: Connection, mint: PublicKey, mintCache?:
|
|
28
|
+
export declare function getTokenProgram(connection: Connection, mint: PublicKey, mintCache?: TokenMintCache): Promise<PublicKey | null>;
|
|
29
29
|
export declare function getTokenProgramAndDecimals(connection: Connection, mint: PublicKey): Promise<[PublicKey, number] | null>;
|
|
30
30
|
export declare const PDA: {
|
|
31
31
|
getLongPool(collateral: PublicKey, currency: PublicKey): PublicKey;
|
|
@@ -107,21 +107,20 @@ export declare function handleMint(connection: Connection, mint: PublicKey, opti
|
|
|
107
107
|
owner?: PublicKey;
|
|
108
108
|
wrapMode?: WrapMode;
|
|
109
109
|
amount?: number | bigint;
|
|
110
|
-
mintCache?:
|
|
110
|
+
mintCache?: TokenMintCache;
|
|
111
111
|
}): Promise<MintResult>;
|
|
112
112
|
export declare function handleMintsAndTokenProgram(connection: Connection, currency: PublicKey, collateral: PublicKey, options: {
|
|
113
|
-
|
|
114
|
-
mintCache?: MintCache;
|
|
113
|
+
mintCache?: TokenMintCache;
|
|
115
114
|
}): Promise<TokenProgramsResult>;
|
|
116
|
-
export declare function handleMintsAndTokenProgramWithSetupAndCleanup(connection: Connection, owner: PublicKey, currency: PublicKey, collateral: PublicKey, wrapMode: WrapMode, amount?: number | bigint, mintCache?:
|
|
117
|
-
export declare function handlePaymentTokenMint(connection: Connection, owner: PublicKey, paymentToken: PublicKey, currency: PublicKey, collateral: PublicKey, wrapMode: WrapMode, amount?: number | bigint, mintCache?:
|
|
118
|
-
export declare function handlePaymentTokenMintWithAuthority(connection: Connection, authority: PublicKey, owner: PublicKey, paymentToken: PublicKey, currency: PublicKey, collateral: PublicKey, wrapMode: WrapMode, amount?: number | bigint, mintCache?:
|
|
115
|
+
export declare function handleMintsAndTokenProgramWithSetupAndCleanup(connection: Connection, owner: PublicKey, currency: PublicKey, collateral: PublicKey, wrapMode: WrapMode, amount?: number | bigint, mintCache?: TokenMintCache): Promise<TokenProgramsWithSetupResult>;
|
|
116
|
+
export declare function handlePaymentTokenMint(connection: Connection, owner: PublicKey, paymentToken: PublicKey, currency: PublicKey, collateral: PublicKey, wrapMode: WrapMode, amount?: number | bigint, mintCache?: TokenMintCache): Promise<TokenProgramsWithSetupResult>;
|
|
117
|
+
export declare function handlePaymentTokenMintWithAuthority(connection: Connection, authority: PublicKey, owner: PublicKey, paymentToken: PublicKey, currency: PublicKey, collateral: PublicKey, wrapMode: WrapMode, amount?: number | bigint, mintCache?: TokenMintCache): Promise<TokenProgramsWithSetupResult>;
|
|
119
118
|
type OpenTokenAccountArgs = {
|
|
120
119
|
program: Program<WasabiSolana>;
|
|
121
120
|
owner: PublicKey;
|
|
122
121
|
downPayment: number | bigint;
|
|
123
122
|
fee: number | bigint;
|
|
124
|
-
mintCache?:
|
|
123
|
+
mintCache?: TokenMintCache;
|
|
125
124
|
isLongPool: boolean;
|
|
126
125
|
currency: PublicKey;
|
|
127
126
|
collateral: PublicKey;
|
|
@@ -149,7 +148,7 @@ export type CloseTokenAccounts = {
|
|
|
149
148
|
export declare function handleCloseTokenAccounts(config: {
|
|
150
149
|
program: Program<WasabiSolana>;
|
|
151
150
|
owner: PublicKey;
|
|
152
|
-
mintCache:
|
|
151
|
+
mintCache: TokenMintCache;
|
|
153
152
|
authority?: PublicKey;
|
|
154
153
|
}, poolAccount: {
|
|
155
154
|
isLongPool: boolean;
|
|
@@ -158,5 +157,5 @@ export declare function handleCloseTokenAccounts(config: {
|
|
|
158
157
|
}): Promise<CloseTokenAccounts>;
|
|
159
158
|
export declare function validateArgs<T>(args: T): NonNullable<T>;
|
|
160
159
|
export declare function validateProviderPubkey(payer: PublicKey | undefined): NonNullable<PublicKey>;
|
|
161
|
-
export declare function validateMintCache(mintCache:
|
|
160
|
+
export declare function validateMintCache(mintCache: TokenMintCache | undefined): NonNullable<TokenMintCache>;
|
|
162
161
|
export {};
|