@drift-labs/sdk 0.2.0-master.3 → 0.2.0-master.31
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/README.md +13 -13
- package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/accounts/bulkUserSubscription.js +0 -1
- package/lib/accounts/fetch.d.ts +2 -1
- package/lib/accounts/fetch.js +9 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +16 -16
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +31 -28
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +113 -0
- package/lib/accounts/types.d.ts +22 -11
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +17 -17
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +37 -35
- package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
- package/lib/addresses/marketAddresses.d.ts +1 -3
- package/lib/addresses/pda.d.ts +10 -4
- package/lib/addresses/pda.js +51 -14
- package/lib/admin.d.ts +42 -26
- package/lib/admin.js +228 -81
- package/lib/clearingHouse.d.ts +130 -49
- package/lib/clearingHouse.js +1256 -367
- package/lib/clearingHouseConfig.d.ts +4 -4
- package/lib/clearingHouseUser.d.ts +51 -39
- package/lib/clearingHouseUser.js +408 -191
- package/lib/clearingHouseUserStats.d.ts +18 -0
- package/lib/clearingHouseUserStats.js +49 -0
- package/lib/clearingHouseUserStatsConfig.d.ts +14 -0
- package/lib/clearingHouseUserStatsConfig.js +2 -0
- package/lib/config.d.ts +7 -9
- package/lib/config.js +21 -21
- package/lib/constants/numericConstants.d.ts +25 -12
- package/lib/constants/numericConstants.js +35 -21
- package/lib/constants/perpMarkets.d.ts +18 -0
- package/lib/constants/{markets.js → perpMarkets.js} +7 -7
- package/lib/constants/spotMarkets.d.ts +19 -0
- package/lib/constants/spotMarkets.js +53 -0
- package/lib/dlob/DLOB.d.ts +74 -0
- package/lib/dlob/DLOB.js +595 -0
- package/lib/dlob/DLOBNode.d.ts +54 -0
- package/lib/dlob/DLOBNode.js +85 -0
- package/lib/dlob/NodeList.d.ts +26 -0
- package/lib/dlob/NodeList.js +139 -0
- package/lib/events/eventList.js +3 -0
- package/lib/events/eventSubscriber.d.ts +4 -2
- package/lib/events/eventSubscriber.js +16 -9
- package/lib/events/fetchLogs.d.ts +10 -1
- package/lib/events/fetchLogs.js +27 -7
- package/lib/events/pollingLogProvider.d.ts +2 -1
- package/lib/events/pollingLogProvider.js +6 -2
- package/lib/events/sort.js +8 -11
- package/lib/events/types.d.ts +8 -2
- package/lib/events/types.js +6 -0
- package/lib/examples/makeTradeExample.js +20 -8
- package/lib/factory/bigNum.d.ts +2 -0
- package/lib/factory/bigNum.js +48 -10
- package/lib/idl/clearing_house.json +4889 -1529
- package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/lib/index.d.ts +21 -6
- package/lib/index.js +25 -6
- package/lib/math/amm.d.ts +9 -6
- package/lib/math/amm.js +91 -66
- package/lib/math/auction.js +4 -1
- package/lib/math/conversion.js +1 -1
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +11 -10
- package/lib/math/insurance.d.ts +4 -0
- package/lib/math/insurance.js +27 -0
- package/lib/math/margin.d.ts +11 -0
- package/lib/math/margin.js +77 -0
- package/lib/math/market.d.ts +14 -9
- package/lib/math/market.js +72 -10
- package/lib/math/oracles.d.ts +4 -0
- package/lib/math/oracles.js +36 -8
- package/lib/math/orders.d.ts +6 -2
- package/lib/math/orders.js +78 -3
- package/lib/math/position.d.ts +21 -13
- package/lib/math/position.js +76 -36
- package/lib/math/repeg.js +14 -5
- package/lib/math/spotBalance.d.ts +22 -0
- package/lib/math/spotBalance.js +192 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +6 -0
- package/lib/math/spotPosition.js +23 -0
- package/lib/math/trade.d.ts +10 -10
- package/lib/math/trade.js +32 -39
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/oracles/switchboardClient.js +1 -1
- package/lib/orderParams.d.ts +14 -5
- package/lib/orderParams.js +12 -92
- package/lib/serum/serumSubscriber.d.ts +23 -0
- package/lib/serum/serumSubscriber.js +41 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/serum/types.js +2 -0
- package/lib/slot/SlotSubscriber.d.ts +7 -0
- package/lib/slot/SlotSubscriber.js +3 -0
- package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
- package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +13 -4
- package/lib/tx/types.d.ts +1 -1
- package/lib/tx/utils.js +1 -1
- package/lib/types.d.ts +566 -138
- package/lib/types.js +129 -5
- package/lib/userMap/userMap.d.ts +25 -0
- package/lib/userMap/userMap.js +73 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -0
- package/lib/util/computeUnits.js +1 -1
- package/lib/util/getTokenAddress.d.ts +2 -0
- package/lib/util/getTokenAddress.js +9 -0
- package/package.json +12 -6
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +0 -1
- package/src/accounts/fetch.ts +27 -2
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +46 -42
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +172 -0
- package/src/accounts/types.ts +31 -11
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +64 -59
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
- package/src/addresses/marketAddresses.ts +1 -2
- package/src/addresses/pda.ts +88 -14
- package/src/admin.ts +452 -147
- package/src/assert/assert.js +9 -0
- package/src/clearingHouse.ts +2066 -467
- package/src/clearingHouseConfig.ts +4 -3
- package/src/clearingHouseUser.ts +747 -294
- package/src/clearingHouseUserStats.ts +75 -0
- package/src/clearingHouseUserStatsConfig.ts +18 -0
- package/src/config.ts +30 -31
- package/src/constants/numericConstants.ts +48 -25
- package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
- package/src/constants/spotMarkets.ts +73 -0
- package/src/dlob/DLOB.ts +953 -0
- package/src/dlob/DLOBNode.ts +167 -0
- package/src/dlob/NodeList.ts +189 -0
- package/src/events/eventList.js +77 -0
- package/src/events/eventList.ts +3 -0
- package/src/events/eventSubscriber.ts +20 -12
- package/src/events/fetchLogs.ts +35 -8
- package/src/events/pollingLogProvider.ts +10 -2
- package/src/events/sort.ts +11 -15
- package/src/events/types.ts +19 -1
- package/src/examples/makeTradeExample.js +157 -0
- package/src/examples/makeTradeExample.ts +32 -14
- package/src/factory/bigNum.ts +65 -13
- package/src/idl/clearing_house.json +4889 -1529
- package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/src/index.ts +21 -6
- package/src/math/amm.ts +171 -88
- package/src/math/auction.ts +5 -1
- package/src/math/conversion.ts +2 -2
- package/src/math/funding.ts +20 -18
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +127 -0
- package/src/math/market.ts +145 -14
- package/src/math/oracles.ts +63 -9
- package/src/math/orders.ts +138 -4
- package/src/math/position.ts +119 -58
- package/src/math/repeg.ts +16 -6
- package/src/math/spotBalance.ts +319 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.ts +47 -0
- package/src/math/trade.ts +53 -59
- package/src/oracles/pythClient.ts +2 -2
- package/src/oracles/quoteAssetOracleClient.ts +2 -2
- package/src/oracles/switchboardClient.ts +2 -2
- package/src/orderParams.ts +24 -137
- package/src/serum/serumSubscriber.ts +80 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.ts +11 -1
- package/src/token/index.js +38 -0
- package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
- package/src/tx/retryTxSender.ts +16 -5
- package/src/tx/types.js +2 -0
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +17 -0
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +533 -140
- package/src/userMap/userMap.ts +100 -0
- package/src/userMap/userStatsMap.ts +110 -0
- package/src/util/computeUnits.js +21 -11
- package/src/util/computeUnits.ts +1 -1
- package/src/util/getTokenAddress.js +9 -0
- package/src/util/getTokenAddress.ts +18 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/bn/test.ts +24 -10
- package/tests/dlob/helpers.ts +397 -0
- package/tests/dlob/test.ts +3688 -0
- package/lib/constants/banks.d.ts +0 -16
- package/lib/constants/banks.js +0 -34
- package/lib/constants/markets.d.ts +0 -19
- package/lib/math/bankBalance.d.ts +0 -9
- package/lib/math/bankBalance.js +0 -75
- package/lib/math/state.d.ts +0 -8
- package/lib/math/state.js +0 -15
- package/lib/orders.d.ts +0 -8
- package/lib/orders.js +0 -134
- package/src/constants/banks.ts +0 -43
- package/src/math/bankBalance.ts +0 -112
- package/src/math/state.ts +0 -14
- package/src/math/utils.js +0 -27
- package/src/math/utils.js.map +0 -1
- package/src/orders.ts +0 -244
- package/src/util/computeUnits.js.map +0 -1
package/lib/clearingHouse.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="bn.js" />
|
|
3
3
|
import { AnchorProvider, BN, Program } from '@project-serum/anchor';
|
|
4
|
-
import { StateAccount, IWallet, PositionDirection, UserAccount,
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
4
|
+
import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, SerumV3FulfillmentConfigAccount } from './types';
|
|
5
|
+
import * as anchor from '@project-serum/anchor';
|
|
6
|
+
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta } from '@solana/web3.js';
|
|
7
|
+
import { TokenFaucet } from './tokenFaucet';
|
|
7
8
|
import { EventEmitter } from 'events';
|
|
8
9
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
9
10
|
import { ClearingHouseAccountSubscriber, ClearingHouseAccountEvents, DataAndSlot } from './accounts/types';
|
|
@@ -12,6 +13,15 @@ import { OraclePriceData } from './oracles/types';
|
|
|
12
13
|
import { ClearingHouseConfig } from './clearingHouseConfig';
|
|
13
14
|
import { ClearingHouseUser } from './clearingHouseUser';
|
|
14
15
|
import { ClearingHouseUserAccountSubscriptionConfig } from './clearingHouseUserConfig';
|
|
16
|
+
import { ClearingHouseUserStats } from './clearingHouseUserStats';
|
|
17
|
+
declare type RemainingAccountParams = {
|
|
18
|
+
userAccounts: UserAccount[];
|
|
19
|
+
writablePerpMarketIndexes?: number[];
|
|
20
|
+
writableSpotMarketIndexes?: number[];
|
|
21
|
+
readablePerpMarketIndex?: number;
|
|
22
|
+
readableSpotMarketIndex?: number;
|
|
23
|
+
useMarketLastSlotCache?: boolean;
|
|
24
|
+
};
|
|
15
25
|
/**
|
|
16
26
|
* # ClearingHouse
|
|
17
27
|
* 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.
|
|
@@ -23,6 +33,7 @@ export declare class ClearingHouse {
|
|
|
23
33
|
provider: AnchorProvider;
|
|
24
34
|
opts?: ConfirmOptions;
|
|
25
35
|
users: Map<number, ClearingHouseUser>;
|
|
36
|
+
userStats?: ClearingHouseUserStats;
|
|
26
37
|
activeUserId: number;
|
|
27
38
|
userAccountSubscriptionConfig: ClearingHouseUserAccountSubscriptionConfig;
|
|
28
39
|
accountSubscriber: ClearingHouseAccountSubscriber;
|
|
@@ -30,6 +41,7 @@ export declare class ClearingHouse {
|
|
|
30
41
|
_isSubscribed: boolean;
|
|
31
42
|
txSender: TxSender;
|
|
32
43
|
marketLastSlotCache: Map<number, number>;
|
|
44
|
+
authority: PublicKey;
|
|
33
45
|
get isSubscribed(): boolean;
|
|
34
46
|
set isSubscribed(val: boolean);
|
|
35
47
|
constructor(config: ClearingHouseConfig);
|
|
@@ -45,12 +57,16 @@ export declare class ClearingHouse {
|
|
|
45
57
|
unsubscribeUsers(): Promise<void>[];
|
|
46
58
|
statePublicKey?: PublicKey;
|
|
47
59
|
getStatePublicKey(): Promise<PublicKey>;
|
|
60
|
+
signerPublicKey?: PublicKey;
|
|
61
|
+
getSignerPublicKey(): PublicKey;
|
|
48
62
|
getStateAccount(): StateAccount;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
getPerpMarketAccount(marketIndex: number): PerpMarketAccount | undefined;
|
|
64
|
+
getPerpMarketAccounts(): PerpMarketAccount[];
|
|
65
|
+
getSpotMarketAccount(marketIndex: number): SpotMarketAccount | undefined;
|
|
66
|
+
getSpotMarketAccounts(): SpotMarketAccount[];
|
|
67
|
+
getQuoteSpotMarketAccount(): SpotMarketAccount;
|
|
53
68
|
getOraclePriceDataAndSlot(oraclePublicKey: PublicKey): DataAndSlot<OraclePriceData> | undefined;
|
|
69
|
+
getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>;
|
|
54
70
|
/**
|
|
55
71
|
* Update the wallet to use for clearing house transactions and linked user account
|
|
56
72
|
* @param newWallet
|
|
@@ -60,73 +76,138 @@ export declare class ClearingHouse {
|
|
|
60
76
|
updateWallet(newWallet: IWallet, userIds?: number[], activeUserId?: number): Promise<void>;
|
|
61
77
|
switchActiveUser(userId: number): Promise<void>;
|
|
62
78
|
addUser(userId: number): Promise<void>;
|
|
63
|
-
initializeUserAccount(userId?: number, name?: string): Promise<[TransactionSignature, PublicKey]>;
|
|
64
|
-
getInitializeUserInstructions(userId?: number, name?: string): Promise<[PublicKey, TransactionInstruction]>;
|
|
79
|
+
initializeUserAccount(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
|
|
80
|
+
getInitializeUserInstructions(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
|
|
81
|
+
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
82
|
+
updateUserName(name: string, userId?: number): Promise<TransactionSignature>;
|
|
83
|
+
updateUserCustomMarginRatio(marginRatio: number, userId?: number): Promise<TransactionSignature>;
|
|
84
|
+
updateUserDelegate(delegate: PublicKey, userId?: number): Promise<TransactionSignature>;
|
|
85
|
+
getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
|
|
86
|
+
deleteUser(userId?: number): Promise<TransactionSignature>;
|
|
65
87
|
getUser(userId?: number): ClearingHouseUser;
|
|
66
88
|
getUsers(): ClearingHouseUser[];
|
|
89
|
+
getUserStats(): ClearingHouseUserStats;
|
|
90
|
+
userStatsAccountPublicKey: PublicKey;
|
|
91
|
+
getUserStatsAccountPublicKey(): PublicKey;
|
|
67
92
|
getUserAccountPublicKey(): Promise<PublicKey>;
|
|
68
93
|
getUserAccount(userId?: number): UserAccount | undefined;
|
|
69
94
|
getUserAccountAndSlot(userId?: number): DataAndSlot<UserAccount> | undefined;
|
|
70
|
-
|
|
95
|
+
getSpotPosition(marketIndex: number): SpotPosition | undefined;
|
|
71
96
|
getQuoteAssetTokenAmount(): BN;
|
|
72
|
-
getRemainingAccounts(params:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
getRemainingAccounts(params: RemainingAccountParams): AccountMeta[];
|
|
98
|
+
getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): {
|
|
99
|
+
oracleAccountMap: Map<string, AccountMeta>;
|
|
100
|
+
spotMarketAccountMap: Map<number, AccountMeta>;
|
|
101
|
+
perpMarketAccountMap: Map<number, AccountMeta>;
|
|
102
|
+
};
|
|
103
|
+
getOrder(orderId: number): Order | undefined;
|
|
77
104
|
getOrderByUserId(userOrderId: number): Order | undefined;
|
|
78
|
-
deposit(amount: BN,
|
|
79
|
-
getDepositInstruction(amount: BN,
|
|
105
|
+
deposit(amount: BN, marketIndex: number, collateralAccountPublicKey: PublicKey, userId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
106
|
+
getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, userId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
|
|
107
|
+
private checkIfAccountExists;
|
|
108
|
+
private getWrappedSolAccountCreationIxs;
|
|
109
|
+
getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey): anchor.web3.TransactionInstruction;
|
|
80
110
|
/**
|
|
81
111
|
* Creates the Clearing House User account for a user, and deposits some initial collateral
|
|
82
|
-
* @param userId
|
|
83
|
-
* @param name
|
|
84
112
|
* @param amount
|
|
85
113
|
* @param userTokenAccount
|
|
114
|
+
* @param marketIndex
|
|
115
|
+
* @param userId
|
|
116
|
+
* @param name
|
|
86
117
|
* @param fromUserId
|
|
87
118
|
* @returns
|
|
88
119
|
*/
|
|
89
|
-
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey,
|
|
90
|
-
initializeUserAccountForDevnet(userId: number, name: string,
|
|
91
|
-
withdraw(amount: BN,
|
|
92
|
-
getWithdrawIx(amount: BN,
|
|
93
|
-
transferDeposit(amount: BN,
|
|
94
|
-
getTransferDepositIx(amount: BN,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, userId?: number, name?: string, fromUserId?: number, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
|
|
121
|
+
initializeUserAccountForDevnet(userId: number, name: string, marketIndex: number, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
|
|
122
|
+
withdraw(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
123
|
+
getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
|
|
124
|
+
transferDeposit(amount: BN, marketIndex: number, fromUserId: number, toUserId: number): Promise<TransactionSignature>;
|
|
125
|
+
getTransferDepositIx(amount: BN, marketIndex: number, fromUserId: number, toUserId: number): Promise<TransactionInstruction>;
|
|
126
|
+
updateSpotMarketCumulativeInterest(marketIndex: number): Promise<TransactionSignature>;
|
|
127
|
+
updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
128
|
+
settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise<TransactionSignature>;
|
|
129
|
+
settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise<TransactionInstruction>;
|
|
130
|
+
removeLiquidity(marketIndex: number, sharesToBurn?: BN): Promise<TransactionSignature>;
|
|
131
|
+
getRemoveLiquidityIx(marketIndex: number, sharesToBurn?: BN): Promise<TransactionInstruction>;
|
|
132
|
+
addLiquidity(amount: BN, marketIndex: number): Promise<TransactionSignature>;
|
|
133
|
+
getAddLiquidityIx(amount: BN, marketIndex: number): Promise<TransactionInstruction>;
|
|
134
|
+
openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN): Promise<TransactionSignature>;
|
|
135
|
+
sendSignedTx(tx: Transaction): Promise<TransactionSignature>;
|
|
136
|
+
/**
|
|
137
|
+
* Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
|
|
138
|
+
* @param orderParams
|
|
139
|
+
* @param userAccountPublicKey
|
|
140
|
+
* @param userAccount
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<{
|
|
144
|
+
txSig: TransactionSignature;
|
|
145
|
+
signedFillTx: Transaction;
|
|
146
|
+
}>;
|
|
147
|
+
placeOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
|
|
148
|
+
getOrderParams(optionalOrderParams: OptionalOrderParams, marketType: MarketType): OrderParams;
|
|
149
|
+
getPlaceOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
|
|
150
|
+
updateAMMs(marketIndexes: number[]): Promise<TransactionSignature>;
|
|
151
|
+
getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>;
|
|
152
|
+
settleExpiredMarket(marketIndex: number): Promise<TransactionSignature>;
|
|
153
|
+
getSettleExpiredMarketIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
154
|
+
cancelOrder(orderId?: number): Promise<TransactionSignature>;
|
|
155
|
+
getCancelOrderIx(orderId?: number): Promise<TransactionInstruction>;
|
|
104
156
|
cancelOrderByUserId(userOrderId: number): Promise<TransactionSignature>;
|
|
105
157
|
getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
|
|
106
|
-
fillOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, makerInfo?: MakerInfo): Promise<TransactionSignature>;
|
|
107
|
-
getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, makerInfo?: MakerInfo): Promise<TransactionInstruction>;
|
|
158
|
+
fillOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
159
|
+
getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
160
|
+
placeSpotOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
|
|
161
|
+
getPlaceSpotOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
|
|
162
|
+
fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
163
|
+
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
108
164
|
triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
|
|
109
165
|
getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
|
|
110
|
-
placeAndTake(orderParams:
|
|
111
|
-
getPlaceAndTakeIx(orderParams:
|
|
166
|
+
placeAndTake(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
167
|
+
getPlaceAndTakeIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
168
|
+
placeAndMake(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
169
|
+
getPlaceAndMakeIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
112
170
|
/**
|
|
113
171
|
* Close an entire position. If you want to reduce a position, use the {@link openPosition} method in the opposite direction of the current position.
|
|
114
172
|
* @param marketIndex
|
|
115
173
|
* @returns
|
|
116
174
|
*/
|
|
117
|
-
closePosition(marketIndex: BN): Promise<TransactionSignature>;
|
|
175
|
+
closePosition(marketIndex: number, limitPrice?: BN): Promise<TransactionSignature>;
|
|
118
176
|
settlePNLs(users: {
|
|
119
177
|
settleeUserAccountPublicKey: PublicKey;
|
|
120
178
|
settleeUserAccount: UserAccount;
|
|
121
|
-
}[], marketIndex:
|
|
122
|
-
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex:
|
|
123
|
-
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
179
|
+
}[], marketIndex: number): Promise<TransactionSignature>;
|
|
180
|
+
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionSignature>;
|
|
181
|
+
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
182
|
+
settleExpiredPosition(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionSignature>;
|
|
183
|
+
getSettleExpiredPositionIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
184
|
+
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN): Promise<TransactionSignature>;
|
|
185
|
+
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN): Promise<TransactionInstruction>;
|
|
186
|
+
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
|
|
187
|
+
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
|
|
188
|
+
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
|
|
189
|
+
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
|
|
190
|
+
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN): Promise<TransactionSignature>;
|
|
191
|
+
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN): Promise<TransactionInstruction>;
|
|
192
|
+
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionSignature>;
|
|
193
|
+
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
194
|
+
resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionSignature>;
|
|
195
|
+
getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
196
|
+
updateFundingRate(oracle: PublicKey, marketIndex: number): Promise<TransactionSignature>;
|
|
197
|
+
getUpdateFundingRateIx(oracle: PublicKey, marketIndex: number): Promise<TransactionInstruction>;
|
|
198
|
+
settleFundingPayment(userAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
199
|
+
getSettleFundingPaymentIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
130
200
|
triggerEvent(eventName: keyof ClearingHouseAccountEvents, data?: any): void;
|
|
131
|
-
getOracleDataForMarket(marketIndex:
|
|
201
|
+
getOracleDataForMarket(marketIndex: number): OraclePriceData;
|
|
202
|
+
getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
|
|
203
|
+
initializeInsuranceFundStake(marketIndex: number): Promise<TransactionSignature>;
|
|
204
|
+
getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
205
|
+
addInsuranceFundStake(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
206
|
+
requestRemoveInsuranceFundStake(marketIndex: number, amount: BN): Promise<TransactionSignature>;
|
|
207
|
+
cancelRequestRemoveInsuranceFundStake(marketIndex: number): Promise<TransactionSignature>;
|
|
208
|
+
removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
209
|
+
settleRevenueToInsuranceFund(marketIndex: number): Promise<TransactionSignature>;
|
|
210
|
+
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionSignature>;
|
|
211
|
+
getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
132
212
|
}
|
|
213
|
+
export {};
|