@drift-labs/sdk 0.1.36-master.5 → 0.2.0-master.0
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/lib/accounts/bulkAccountLoader.d.ts +7 -6
- package/lib/accounts/bulkAccountLoader.js +83 -93
- package/lib/accounts/bulkUserSubscription.js +13 -57
- package/lib/accounts/fetch.d.ts +4 -0
- package/lib/accounts/fetch.js +18 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +34 -38
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +224 -224
- package/lib/accounts/pollingOracleSubscriber.d.ts +3 -3
- package/lib/accounts/pollingOracleSubscriber.js +37 -49
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +3 -3
- package/lib/accounts/pollingTokenAccountSubscriber.js +35 -50
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +7 -13
- package/lib/accounts/pollingUserAccountSubscriber.js +71 -134
- package/lib/accounts/types.d.ts +34 -41
- package/lib/accounts/webSocketAccountSubscriber.d.ts +6 -4
- package/lib/accounts/webSocketAccountSubscriber.js +39 -35
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +33 -28
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +153 -185
- package/lib/accounts/webSocketUserAccountSubscriber.d.ts +5 -11
- package/lib/accounts/webSocketUserAccountSubscriber.js +22 -67
- package/lib/addresses/marketAddresses.d.ts +4 -0
- package/lib/addresses/marketAddresses.js +15 -0
- package/lib/addresses/pda.d.ts +12 -0
- package/lib/addresses/pda.js +83 -0
- package/lib/admin.d.ts +8 -12
- package/lib/admin.js +366 -490
- package/lib/clearingHouse.d.ts +84 -103
- package/lib/clearingHouse.js +779 -810
- package/lib/clearingHouseConfig.d.ts +34 -0
- package/lib/clearingHouseConfig.js +2 -0
- package/lib/clearingHouseUser.d.ts +19 -18
- package/lib/clearingHouseUser.js +157 -115
- package/lib/clearingHouseUserConfig.d.ts +14 -0
- package/lib/clearingHouseUserConfig.js +2 -0
- package/lib/config.d.ts +12 -0
- package/lib/config.js +35 -4
- package/lib/constants/banks.d.ts +16 -0
- package/lib/constants/banks.js +34 -0
- package/lib/constants/markets.d.ts +8 -3
- package/lib/constants/markets.js +13 -206
- package/lib/constants/numericConstants.d.ts +16 -0
- package/lib/constants/numericConstants.js +22 -6
- package/lib/events/eventList.d.ts +22 -0
- package/lib/events/eventList.js +77 -0
- package/lib/events/eventSubscriber.d.ts +34 -0
- package/lib/events/eventSubscriber.js +126 -0
- package/lib/events/fetchLogs.d.ts +13 -0
- package/lib/events/fetchLogs.js +39 -0
- package/lib/events/pollingLogProvider.d.ts +15 -0
- package/lib/events/pollingLogProvider.js +53 -0
- package/lib/events/sort.d.ts +2 -0
- package/lib/events/sort.js +44 -0
- package/lib/events/txEventCache.d.ts +24 -0
- package/lib/events/txEventCache.js +71 -0
- package/lib/events/types.d.ts +49 -0
- package/lib/events/types.js +20 -0
- package/lib/events/webSocketLogProvider.d.ts +12 -0
- package/lib/events/webSocketLogProvider.js +30 -0
- package/lib/examples/makeTradeExample.js +26 -27
- package/lib/factory/bigNum.d.ts +112 -0
- package/lib/factory/bigNum.js +356 -0
- package/lib/factory/oracleClient.d.ts +1 -2
- package/lib/factory/oracleClient.js +6 -2
- package/lib/idl/clearing_house.json +1739 -2287
- package/lib/index.d.ts +13 -4
- package/lib/index.js +13 -4
- package/lib/math/amm.d.ts +19 -29
- package/lib/math/amm.js +129 -179
- package/lib/math/auction.d.ts +5 -0
- package/lib/math/auction.js +39 -0
- package/lib/math/bankBalance.d.ts +9 -0
- package/lib/math/bankBalance.js +75 -0
- package/lib/math/conversion.d.ts +0 -1
- package/lib/math/conversion.js +1 -5
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +158 -175
- package/lib/math/market.d.ts +6 -6
- package/lib/math/market.js +10 -9
- package/lib/math/oracles.d.ts +3 -0
- package/lib/math/oracles.js +26 -0
- package/lib/math/orders.d.ts +5 -0
- package/lib/math/orders.js +31 -1
- package/lib/math/position.d.ts +7 -4
- package/lib/math/position.js +27 -9
- package/lib/math/repeg.d.ts +22 -0
- package/lib/math/repeg.js +128 -0
- package/lib/math/trade.d.ts +13 -8
- package/lib/math/trade.js +85 -22
- package/lib/mockUSDCFaucet.js +87 -116
- package/lib/oracles/oracleClientCache.d.ts +8 -0
- package/lib/oracles/oracleClientCache.js +19 -0
- package/lib/oracles/pythClient.d.ts +3 -5
- package/lib/oracles/pythClient.js +12 -30
- package/lib/oracles/quoteAssetOracleClient.d.ts +9 -0
- package/lib/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/oracles/switchboardClient.d.ts +3 -5
- package/lib/oracles/switchboardClient.js +29 -47
- package/lib/oracles/types.d.ts +7 -1
- package/lib/orders.d.ts +6 -6
- package/lib/orders.js +10 -9
- package/lib/slot/SlotSubscriber.d.ts +12 -0
- package/lib/slot/SlotSubscriber.js +23 -0
- package/lib/tx/retryTxSender.d.ts +2 -2
- package/lib/tx/retryTxSender.js +108 -123
- package/lib/tx/types.d.ts +5 -1
- package/lib/tx/utils.d.ts +1 -1
- package/lib/tx/utils.js +11 -2
- package/lib/types.d.ts +105 -98
- package/lib/types.js +13 -1
- package/lib/userName.d.ts +4 -0
- package/lib/userName.js +20 -0
- package/lib/util/computeUnits.js +10 -21
- package/lib/util/tps.js +11 -22
- package/lib/wallet.js +7 -20
- package/package.json +10 -3
- package/src/accounts/bulkAccountLoader.ts +26 -15
- package/src/accounts/bulkUserSubscription.ts +1 -45
- package/src/accounts/fetch.ts +33 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +249 -214
- package/src/accounts/pollingOracleSubscriber.ts +16 -8
- package/src/accounts/pollingTokenAccountSubscriber.ts +11 -8
- package/src/accounts/pollingUserAccountSubscriber.ts +21 -86
- package/src/accounts/types.ts +41 -70
- package/src/accounts/webSocketAccountSubscriber.ts +33 -16
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +190 -240
- package/src/accounts/webSocketUserAccountSubscriber.ts +11 -71
- package/src/addresses/marketAddresses.ts +18 -0
- package/src/addresses/pda.ts +118 -0
- package/src/admin.ts +209 -267
- package/src/clearingHouse.ts +921 -829
- package/src/clearingHouseConfig.ts +37 -0
- package/src/clearingHouseUser.ts +280 -127
- package/src/clearingHouseUserConfig.ts +18 -0
- package/src/config.ts +54 -1
- package/src/constants/banks.ts +43 -0
- package/src/constants/markets.ts +16 -207
- package/src/constants/numericConstants.ts +33 -5
- package/src/events/eventList.ts +94 -0
- package/src/events/eventSubscriber.ts +194 -0
- package/src/events/fetchLogs.ts +80 -0
- package/src/events/pollingLogProvider.ts +79 -0
- package/src/events/sort.ts +65 -0
- package/src/events/txEventCache.ts +74 -0
- package/src/events/types.ts +98 -0
- package/src/events/webSocketLogProvider.ts +38 -0
- package/src/examples/makeTradeExample.ts +20 -11
- package/src/factory/bigNum.ts +507 -0
- package/src/factory/oracleClient.ts +7 -4
- package/src/idl/clearing_house.json +1739 -2287
- package/src/index.ts +13 -4
- package/src/math/amm.ts +229 -245
- package/src/math/auction.ts +39 -0
- package/src/math/bankBalance.ts +112 -0
- package/src/math/conversion.ts +1 -11
- package/src/math/funding.ts +12 -9
- package/src/math/market.ts +37 -30
- package/src/math/oracles.ts +36 -0
- package/src/math/orders.ts +38 -0
- package/src/math/position.ts +48 -13
- package/src/math/repeg.ts +175 -0
- package/src/math/trade.ts +114 -36
- package/src/math/utils.js +27 -0
- package/src/math/utils.js.map +1 -0
- package/src/oracles/oracleClientCache.ts +20 -0
- package/src/oracles/pythClient.ts +5 -11
- package/src/oracles/quoteAssetOracleClient.ts +25 -0
- package/src/oracles/switchboardClient.ts +16 -24
- package/src/oracles/types.ts +8 -1
- package/src/orders.ts +35 -20
- package/src/slot/SlotSubscriber.ts +32 -0
- package/src/tx/retryTxSender.ts +6 -4
- package/src/tx/types.ts +6 -1
- package/src/tx/utils.ts +22 -3
- package/src/types.ts +108 -110
- package/src/userName.ts +20 -0
- package/src/util/computeUnits.js +17 -0
- package/src/util/computeUnits.js.map +1 -0
- package/tests/bn/test.ts +255 -0
- package/tsconfig.json +12 -12
- package/lib/addresses.d.ts +0 -9
- package/lib/addresses.js +0 -87
- package/lib/constants/accounts.d.ts +0 -15
- package/lib/constants/accounts.js +0 -18
- package/lib/factory/clearingHouse.d.ts +0 -35
- package/lib/factory/clearingHouse.js +0 -81
- package/lib/factory/clearingHouseUser.d.ts +0 -19
- package/lib/factory/clearingHouseUser.js +0 -34
- package/lib/math/insuranceFund.d.ts +0 -15
- package/lib/math/insuranceFund.js +0 -33
- package/lib/tx/defaultTxSender.d.ts +0 -8
- package/lib/tx/defaultTxSender.js +0 -12
- package/src/addresses.ts +0 -71
- package/src/constants/accounts.ts +0 -26
- package/src/factory/clearingHouse.ts +0 -173
- package/src/factory/clearingHouseUser.ts +0 -73
- package/src/math/insuranceFund.ts +0 -29
- package/src/tx/defaultTxSender.ts +0 -24
package/lib/clearingHouse.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="bn.js" />
|
|
3
3
|
import { AnchorProvider, BN, Program } from '@project-serum/anchor';
|
|
4
|
-
import {
|
|
5
|
-
import { Connection, PublicKey, TransactionSignature,
|
|
4
|
+
import { StateAccount, IWallet, PositionDirection, UserAccount, MarketAccount, OrderParams, Order, BankAccount, UserBankBalance, MakerInfo } from './types';
|
|
5
|
+
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, TransactionInstruction, AccountMeta } from '@solana/web3.js';
|
|
6
6
|
import { MockUSDCFaucet } from './mockUSDCFaucet';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
8
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
9
|
-
import { ClearingHouseAccountSubscriber, ClearingHouseAccountEvents,
|
|
9
|
+
import { ClearingHouseAccountSubscriber, ClearingHouseAccountEvents, DataAndSlot } from './accounts/types';
|
|
10
10
|
import { TxSender } from './tx/types';
|
|
11
|
+
import { OraclePriceData } from './oracles/types';
|
|
12
|
+
import { ClearingHouseConfig } from './clearingHouseConfig';
|
|
13
|
+
import { ClearingHouseUser } from './clearingHouseUser';
|
|
14
|
+
import { ClearingHouseUserAccountSubscriptionConfig } from './clearingHouseUserConfig';
|
|
11
15
|
/**
|
|
12
16
|
* # ClearingHouse
|
|
13
17
|
* This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
|
|
14
|
-
*
|
|
15
|
-
* The default way to construct a ClearingHouse instance is using the {@link from} method. This will create an instance using the static {@link WebSocketClearingHouseAccountSubscriber}, which will use a websocket for each state account subscription.
|
|
16
|
-
* Alternatively, if you want to implement your own method of subscribing to the state accounts on the blockchain, you can implement a {@link ClearingHouseAccountSubscriber} and use it in the {@link ClearingHouse.constructor}
|
|
17
18
|
*/
|
|
18
19
|
export declare class ClearingHouse {
|
|
19
20
|
connection: Connection;
|
|
@@ -21,135 +22,115 @@ export declare class ClearingHouse {
|
|
|
21
22
|
program: Program;
|
|
22
23
|
provider: AnchorProvider;
|
|
23
24
|
opts?: ConfirmOptions;
|
|
25
|
+
users: Map<number, ClearingHouseUser>;
|
|
26
|
+
activeUserId: number;
|
|
27
|
+
userAccountSubscriptionConfig: ClearingHouseUserAccountSubscriptionConfig;
|
|
24
28
|
accountSubscriber: ClearingHouseAccountSubscriber;
|
|
25
29
|
eventEmitter: StrictEventEmitter<EventEmitter, ClearingHouseAccountEvents>;
|
|
26
30
|
_isSubscribed: boolean;
|
|
27
31
|
txSender: TxSender;
|
|
32
|
+
marketLastSlotCache: Map<number, number>;
|
|
28
33
|
get isSubscribed(): boolean;
|
|
29
34
|
set isSubscribed(val: boolean);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* @param opts
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
static from(connection: Connection, wallet: IWallet, clearingHouseProgramId: PublicKey, opts?: ConfirmOptions): ClearingHouse;
|
|
39
|
-
constructor(connection: Connection, wallet: IWallet, program: Program, accountSubscriber: ClearingHouseAccountSubscriber, txSender: TxSender, opts: ConfirmOptions);
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param optionalSubscriptions - Optional extra accounts to subcribe to. Always subscribes to base clearing house state and market account state by default. You should only subscribe to optional extra accounts if required, to avoid overloading your RPC.
|
|
43
|
-
* @returns Promise<boolean> : SubscriptionSuccess
|
|
44
|
-
*/
|
|
45
|
-
subscribe(optionalSubscriptions?: ClearingHouseAccountTypes[]): Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
* Shorthand function to subscribe to all available Clearing House State Accounts
|
|
48
|
-
* @returns Promise<boolean> : SubscriptionSuccess
|
|
49
|
-
*/
|
|
50
|
-
subscribeToAll(): Promise<boolean>;
|
|
35
|
+
constructor(config: ClearingHouseConfig);
|
|
36
|
+
createUsers(userIds: number[], accountSubscriptionConfig: ClearingHouseUserAccountSubscriptionConfig): void;
|
|
37
|
+
createUser(userId: number, accountSubscriptionConfig: ClearingHouseUserAccountSubscriptionConfig): ClearingHouseUser;
|
|
38
|
+
subscribe(): Promise<boolean>;
|
|
39
|
+
subscribeUsers(): Promise<boolean>[];
|
|
51
40
|
/**
|
|
52
41
|
* Forces the accountSubscriber to fetch account updates from rpc
|
|
53
42
|
*/
|
|
54
43
|
fetchAccounts(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Unsubscribe from all currently subscribed state accounts
|
|
57
|
-
*/
|
|
58
44
|
unsubscribe(): Promise<void>;
|
|
45
|
+
unsubscribeUsers(): Promise<void>[];
|
|
59
46
|
statePublicKey?: PublicKey;
|
|
60
47
|
getStatePublicKey(): Promise<PublicKey>;
|
|
61
48
|
getStateAccount(): StateAccount;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
getLiquidationHistoryAccount(): LiquidationHistoryAccount;
|
|
68
|
-
getDepositHistoryAccount(): DepositHistoryAccount;
|
|
69
|
-
getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
|
|
70
|
-
getOrderHistoryAccount(): OrderHistoryAccount;
|
|
71
|
-
orderStatePublicKey?: PublicKey;
|
|
72
|
-
getOrderStatePublicKey(): Promise<PublicKey>;
|
|
73
|
-
getOrderStateAccount(): OrderStateAccount;
|
|
49
|
+
getMarketAccount(marketIndex: BN | number): MarketAccount | undefined;
|
|
50
|
+
getMarketAccounts(): MarketAccount[];
|
|
51
|
+
getBankAccount(bankIndex: BN | number): BankAccount | undefined;
|
|
52
|
+
getQuoteAssetBankAccount(): BankAccount;
|
|
53
|
+
getOraclePriceDataAndSlot(oraclePublicKey: PublicKey): DataAndSlot<OraclePriceData> | undefined;
|
|
74
54
|
/**
|
|
75
55
|
* Update the wallet to use for clearing house transactions and linked user account
|
|
76
56
|
* @param newWallet
|
|
57
|
+
* @param userIds
|
|
58
|
+
* @param activeUserId
|
|
77
59
|
*/
|
|
78
|
-
updateWallet(newWallet: IWallet): void
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
]>;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
PublicKey,
|
|
86
|
-
TransactionInstruction,
|
|
87
|
-
TransactionInstruction
|
|
88
|
-
]>;
|
|
89
|
-
getInitializeUserOrdersInstruction(userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
90
|
-
userAccountPublicKey?: PublicKey;
|
|
91
|
-
/**
|
|
92
|
-
* Get the address for the Clearing House User's account. NOT the user's wallet address.
|
|
93
|
-
* @returns
|
|
94
|
-
*/
|
|
60
|
+
updateWallet(newWallet: IWallet, userIds?: number[], activeUserId?: number): Promise<void>;
|
|
61
|
+
switchActiveUser(userId: number): Promise<void>;
|
|
62
|
+
addUser(userId: number): Promise<void>;
|
|
63
|
+
initializeUserAccount(userId?: number, name?: string): Promise<[TransactionSignature, PublicKey]>;
|
|
64
|
+
getInitializeUserInstructions(userId?: number, name?: string): Promise<[PublicKey, TransactionInstruction]>;
|
|
65
|
+
getUser(userId?: number): ClearingHouseUser;
|
|
66
|
+
getUsers(): ClearingHouseUser[];
|
|
95
67
|
getUserAccountPublicKey(): Promise<PublicKey>;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
68
|
+
getUserAccount(userId?: number): UserAccount | undefined;
|
|
69
|
+
getUserAccountAndSlot(userId?: number): DataAndSlot<UserAccount> | undefined;
|
|
70
|
+
getUserBankBalance(bankIndex: number | BN): UserBankBalance | undefined;
|
|
71
|
+
getQuoteAssetTokenAmount(): BN;
|
|
72
|
+
getRemainingAccounts(params: {
|
|
73
|
+
writableMarketIndex?: BN;
|
|
74
|
+
writableBankIndex?: BN;
|
|
75
|
+
}): AccountMeta[];
|
|
76
|
+
getOrder(orderId: BN | number): Order | undefined;
|
|
77
|
+
getOrderByUserId(userOrderId: number): Order | undefined;
|
|
78
|
+
deposit(amount: BN, bankIndex: BN, collateralAccountPublicKey: PublicKey, userId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
79
|
+
getDepositInstruction(amount: BN, bankIndex: BN, userTokenAccount: PublicKey, userId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
|
|
108
80
|
/**
|
|
109
81
|
* Creates the Clearing House User account for a user, and deposits some initial collateral
|
|
82
|
+
* @param userId
|
|
83
|
+
* @param name
|
|
110
84
|
* @param amount
|
|
111
|
-
* @param
|
|
85
|
+
* @param userTokenAccount
|
|
86
|
+
* @param fromUserId
|
|
112
87
|
* @returns
|
|
113
88
|
*/
|
|
114
|
-
initializeUserAccountAndDepositCollateral(amount: BN,
|
|
115
|
-
initializeUserAccountForDevnet(mockUSDCFaucet: MockUSDCFaucet, amount: BN): Promise<[TransactionSignature, PublicKey]>;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
89
|
+
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, bankIndex?: BN, userId?: number, name?: string, fromUserId?: number): Promise<[TransactionSignature, PublicKey]>;
|
|
90
|
+
initializeUserAccountForDevnet(userId: number, name: string, mockUSDCFaucet: MockUSDCFaucet, amount: BN): Promise<[TransactionSignature, PublicKey]>;
|
|
91
|
+
withdraw(amount: BN, bankIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
92
|
+
getWithdrawIx(amount: BN, bankIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
|
|
93
|
+
transferDeposit(amount: BN, bankIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionSignature>;
|
|
94
|
+
getTransferDepositIx(amount: BN, bankIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionInstruction>;
|
|
95
|
+
updateBankCumulativeInterest(bankIndex: BN): Promise<TransactionSignature>;
|
|
96
|
+
updateBankCumulativeInterestIx(bankIndex: BN): Promise<TransactionInstruction>;
|
|
97
|
+
openPosition(direction: PositionDirection, amount: BN, marketIndex: BN, limitPrice?: BN): Promise<TransactionSignature>;
|
|
98
|
+
placeOrder(orderParams: OrderParams): Promise<TransactionSignature>;
|
|
99
|
+
getPlaceOrderIx(orderParams: OrderParams): Promise<TransactionInstruction>;
|
|
100
|
+
expireOrders(userAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
101
|
+
getExpireOrdersIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
102
|
+
updateAMMs(marketIndexes: BN[]): Promise<TransactionSignature>;
|
|
103
|
+
getUpdateAMMsIx(marketIndexes: BN[]): Promise<TransactionInstruction>;
|
|
104
|
+
cancelOrder(orderId: BN): Promise<TransactionSignature>;
|
|
105
|
+
getCancelOrderIx(orderId: BN): Promise<TransactionInstruction>;
|
|
106
|
+
cancelOrderByUserId(userOrderId: number): Promise<TransactionSignature>;
|
|
107
|
+
getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
|
|
108
|
+
cancelAllOrders(bestEffort?: boolean): Promise<TransactionSignature>;
|
|
109
|
+
getCancelAllOrdersIx(bestEffort?: boolean): Promise<TransactionInstruction>;
|
|
110
|
+
cancelOrdersByMarketAndSide(bestEffort?: boolean, marketIndexOnly?: BN, directionOnly?: PositionDirection): Promise<TransactionSignature>;
|
|
111
|
+
getCancelOrdersByMarketAndSideIx(bestEffort?: boolean, marketIndexOnly?: BN, directionOnly?: PositionDirection): Promise<TransactionInstruction>;
|
|
112
|
+
fillOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, makerInfo?: MakerInfo): Promise<TransactionSignature>;
|
|
113
|
+
getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, makerInfo?: MakerInfo): Promise<TransactionInstruction>;
|
|
114
|
+
placeAndTake(orderParams: OrderParams, makerInfo?: MakerInfo): Promise<TransactionSignature>;
|
|
115
|
+
getPlaceAndTakeIx(orderParams: OrderParams, makerInfo?: MakerInfo): Promise<TransactionInstruction>;
|
|
138
116
|
/**
|
|
139
117
|
* Close an entire position. If you want to reduce a position, use the {@link openPosition} method in the opposite direction of the current position.
|
|
140
118
|
* @param marketIndex
|
|
141
|
-
* @param discountToken
|
|
142
|
-
* @param referrer
|
|
143
119
|
* @returns
|
|
144
120
|
*/
|
|
145
|
-
closePosition(marketIndex: BN
|
|
146
|
-
|
|
147
|
-
|
|
121
|
+
closePosition(marketIndex: BN): Promise<TransactionSignature>;
|
|
122
|
+
settlePNLs(users: {
|
|
123
|
+
settleeUserAccountPublicKey: PublicKey;
|
|
124
|
+
settleeUserAccount: UserAccount;
|
|
125
|
+
}[], marketIndex: BN): Promise<TransactionSignature>;
|
|
126
|
+
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
|
|
127
|
+
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
|
|
148
128
|
liquidate(liquidateeUserAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
149
129
|
getLiquidateIx(liquidateeUserAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
150
130
|
updateFundingRate(oracle: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
|
|
151
131
|
getUpdateFundingRateIx(oracle: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
|
|
152
|
-
settleFundingPayment(userAccount: PublicKey
|
|
153
|
-
getSettleFundingPaymentIx(userAccount: PublicKey
|
|
132
|
+
settleFundingPayment(userAccount: PublicKey): Promise<TransactionSignature>;
|
|
133
|
+
getSettleFundingPaymentIx(userAccount: PublicKey): Promise<TransactionInstruction>;
|
|
154
134
|
triggerEvent(eventName: keyof ClearingHouseAccountEvents, data?: any): void;
|
|
135
|
+
getOracleDataForMarket(marketIndex: BN): OraclePriceData;
|
|
155
136
|
}
|