@drift-labs/sdk 0.1.18-master.7 → 0.1.18-orders.2
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 +32 -0
- package/lib/accounts/bulkAccountLoader.js +156 -0
- package/lib/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserSubscription.js +28 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +49 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +228 -0
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +25 -0
- package/lib/accounts/pollingTokenAccountSubscriber.js +79 -0
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/accounts/pollingUserAccountSubscriber.js +133 -0
- package/lib/accounts/types.d.ts +34 -3
- package/lib/accounts/utils.d.ts +1 -0
- package/lib/accounts/utils.js +7 -0
- package/lib/accounts/webSocketAccountSubscriber.d.ts +0 -1
- package/lib/accounts/{defaultClearingHouseAccountSubscriber.d.ts → webSocketClearingHouseAccountSubscriber.d.ts} +8 -3
- package/lib/accounts/{defaultClearingHouseAccountSubscriber.js → webSocketClearingHouseAccountSubscriber.js} +30 -4
- package/lib/accounts/{defaultUserAccountSubscriber.d.ts → webSocketUserAccountSubscriber.d.ts} +6 -3
- package/lib/accounts/{defaultUserAccountSubscriber.js → webSocketUserAccountSubscriber.js} +16 -4
- package/lib/addresses.d.ts +4 -1
- package/lib/addresses.js +28 -1
- package/lib/admin.d.ts +11 -4
- package/lib/admin.js +71 -17
- package/lib/assert/assert.d.ts +0 -1
- package/lib/clearingHouse.d.ts +35 -4
- package/lib/clearingHouse.js +294 -23
- package/lib/clearingHouseUser.d.ts +19 -18
- package/lib/clearingHouseUser.js +129 -101
- package/lib/config.d.ts +0 -1
- package/lib/config.js +1 -1
- package/lib/constants/markets.d.ts +0 -1
- package/lib/constants/markets.js +13 -5
- package/lib/constants/numericConstants.d.ts +0 -1
- package/lib/examples/makeTradeExample.d.ts +0 -1
- package/lib/examples/makeTradeExample.js +6 -6
- package/lib/factory/clearingHouse.d.ts +25 -0
- package/lib/factory/clearingHouse.js +64 -0
- package/lib/factory/clearingHouseUser.d.ts +19 -0
- package/lib/factory/clearingHouseUser.js +34 -0
- package/lib/idl/clearing_house.json +1077 -54
- package/lib/index.d.ts +12 -4
- package/lib/index.js +17 -4
- package/lib/math/amm.d.ts +1 -1
- package/lib/math/amm.js +38 -15
- package/lib/math/conversion.d.ts +0 -1
- package/lib/math/conversion.js +1 -1
- package/lib/math/funding.d.ts +0 -1
- package/lib/math/funding.js +1 -1
- package/lib/math/insuranceFund.d.ts +0 -1
- package/lib/math/market.d.ts +2 -2
- package/lib/math/market.js +12 -2
- package/lib/math/orders.d.ts +3 -0
- package/lib/math/orders.js +30 -0
- package/lib/math/position.d.ts +4 -2
- package/lib/math/position.js +19 -5
- package/lib/math/trade.d.ts +0 -1
- package/lib/math/trade.js +16 -16
- package/lib/math/utils.d.ts +2 -3
- package/lib/math/utils.js +6 -3
- package/lib/mockUSDCFaucet.d.ts +0 -1
- package/lib/orderParams.d.ts +7 -0
- package/lib/orderParams.js +108 -0
- package/lib/orders.d.ts +5 -0
- package/lib/orders.js +136 -0
- package/lib/pythClient.d.ts +0 -1
- package/lib/pythClient.js +1 -1
- package/lib/token/index.d.ts +3 -0
- package/lib/token/index.js +38 -0
- package/lib/tx/defaultTxSender.d.ts +0 -1
- package/lib/tx/types.d.ts +0 -1
- package/lib/tx/utils.d.ts +0 -1
- package/lib/types.d.ts +144 -2
- package/lib/types.js +36 -1
- package/lib/util/computeUnits.d.ts +0 -1
- package/lib/util/tps.d.ts +0 -1
- package/lib/wallet.d.ts +0 -1
- package/package.json +3 -3
- package/src/accounts/bulkAccountLoader.ts +195 -0
- package/src/accounts/bulkUserSubscription.ts +28 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +326 -0
- package/src/accounts/pollingTokenAccountSubscriber.ts +99 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +186 -0
- package/src/accounts/types.ts +43 -1
- package/src/accounts/utils.ts +3 -0
- package/src/accounts/{defaultClearingHouseAccountSubscriber.ts → webSocketClearingHouseAccountSubscriber.ts} +51 -1
- package/src/accounts/{defaultUserAccountSubscriber.ts → webSocketUserAccountSubscriber.ts} +33 -3
- package/src/addresses.ts +37 -0
- package/src/admin.ts +111 -24
- package/src/clearingHouse.ts +399 -22
- package/src/clearingHouseUser.ts +179 -107
- package/src/config.ts +1 -1
- package/src/constants/markets.ts +13 -5
- package/src/factory/clearingHouse.ts +125 -0
- package/src/factory/clearingHouseUser.ts +73 -0
- package/src/idl/clearing_house.json +1077 -54
- package/src/index.ts +12 -3
- package/src/math/amm.ts +47 -14
- package/src/math/market.ts +28 -2
- package/src/math/orders.ts +39 -0
- package/src/math/position.ts +23 -3
- package/src/math/utils.ts +1 -1
- package/src/orderParams.ts +151 -0
- package/src/orders.ts +230 -0
- package/src/token/index.ts +37 -0
- package/src/types.ts +128 -1
- package/tsconfig.json +0 -1
- package/lib/accounts/defaultClearingHouseAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/defaultUserAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/types.d.ts.map +0 -1
- package/lib/accounts/webSocketAccountSubscriber.d.ts.map +0 -1
- package/lib/addresses.d.ts.map +0 -1
- package/lib/admin.d.ts.map +0 -1
- package/lib/assert/assert.d.ts.map +0 -1
- package/lib/clearingHouse.d.ts.map +0 -1
- package/lib/clearingHouseUser.d.ts.map +0 -1
- package/lib/config.d.ts.map +0 -1
- package/lib/constants/markets.d.ts.map +0 -1
- package/lib/constants/numericConstants.d.ts.map +0 -1
- package/lib/examples/makeTradeExample.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/math/amm.d.ts.map +0 -1
- package/lib/math/conversion.d.ts.map +0 -1
- package/lib/math/funding.d.ts.map +0 -1
- package/lib/math/insuranceFund.d.ts.map +0 -1
- package/lib/math/market.d.ts.map +0 -1
- package/lib/math/position.d.ts.map +0 -1
- package/lib/math/trade.d.ts.map +0 -1
- package/lib/math/utils.d.ts.map +0 -1
- package/lib/mockUSDCFaucet.d.ts.map +0 -1
- package/lib/pythClient.d.ts.map +0 -1
- package/lib/tx/defaultTxSender.d.ts.map +0 -1
- package/lib/tx/types.d.ts.map +0 -1
- package/lib/tx/utils.d.ts.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/util/computeUnits.d.ts.map +0 -1
- package/lib/util/tps.d.ts.map +0 -1
- package/lib/wallet.d.ts.map +0 -1
package/lib/admin.js
CHANGED
|
@@ -27,9 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
31
|
exports.Admin = void 0;
|
|
35
32
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -39,18 +36,13 @@ const addresses_1 = require("./addresses");
|
|
|
39
36
|
const spl_token_1 = require("@solana/spl-token");
|
|
40
37
|
const clearingHouse_1 = require("./clearingHouse");
|
|
41
38
|
const numericConstants_1 = require("./constants/numericConstants");
|
|
42
|
-
const clearing_house_json_1 = __importDefault(require("./idl/clearing_house.json"));
|
|
43
|
-
const defaultClearingHouseAccountSubscriber_1 = require("./accounts/defaultClearingHouseAccountSubscriber");
|
|
44
|
-
const defaultTxSender_1 = require("./tx/defaultTxSender");
|
|
45
39
|
const trade_1 = require("./math/trade");
|
|
46
40
|
const amm_1 = require("./math/amm");
|
|
41
|
+
const clearingHouse_2 = require("./factory/clearingHouse");
|
|
47
42
|
class Admin extends clearingHouse_1.ClearingHouse {
|
|
48
43
|
static from(connection, wallet, clearingHouseProgramId, opts = anchor_1.Provider.defaultOptions()) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const accountSubscriber = new defaultClearingHouseAccountSubscriber_1.DefaultClearingHouseAccountSubscriber(program);
|
|
52
|
-
const txSender = new defaultTxSender_1.DefaultTxSender(provider);
|
|
53
|
-
return new Admin(connection, wallet, program, accountSubscriber, txSender, opts);
|
|
44
|
+
const config = clearingHouse_2.getWebSocketClearingHouseConfig(connection, wallet, clearingHouseProgramId, opts);
|
|
45
|
+
return clearingHouse_2.getAdmin(config);
|
|
54
46
|
}
|
|
55
47
|
initialize(usdcMint, adminControlsPrices) {
|
|
56
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -69,7 +61,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
69
61
|
const tradeHistory = anchor.web3.Keypair.generate();
|
|
70
62
|
const liquidationHistory = anchor.web3.Keypair.generate();
|
|
71
63
|
const curveHistory = anchor.web3.Keypair.generate();
|
|
72
|
-
const [clearingHouseStatePublicKey, clearingHouseNonce] = yield
|
|
64
|
+
const [clearingHouseStatePublicKey, clearingHouseNonce] = yield addresses_1.getClearingHouseStateAccountPublicKeyAndNonce(this.program.programId);
|
|
73
65
|
const initializeTx = yield this.program.transaction.initialize(clearingHouseNonce, collateralVaultNonce, insuranceVaultNonce, adminControlsPrices, {
|
|
74
66
|
accounts: {
|
|
75
67
|
admin: this.wallet.publicKey,
|
|
@@ -119,7 +111,29 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
119
111
|
fundingRateHistory,
|
|
120
112
|
curveHistory,
|
|
121
113
|
], this.opts);
|
|
122
|
-
|
|
114
|
+
const initializeOrderStateTxSig = yield this.initializeOrderState();
|
|
115
|
+
return [initializeTxSig, initializeHistoryTxSig, initializeOrderStateTxSig];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
initializeOrderState() {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const orderHistory = anchor.web3.Keypair.generate();
|
|
121
|
+
const [orderStatePublicKey, orderStateNonce] = yield addresses_1.getOrderStateAccountPublicKeyAndNonce(this.program.programId);
|
|
122
|
+
const clearingHouseStatePublicKey = yield addresses_1.getClearingHouseStateAccountPublicKey(this.program.programId);
|
|
123
|
+
const initializeOrderStateTx = yield this.program.transaction.initializeOrderState(orderStateNonce, {
|
|
124
|
+
accounts: {
|
|
125
|
+
admin: this.wallet.publicKey,
|
|
126
|
+
state: clearingHouseStatePublicKey,
|
|
127
|
+
orderHistory: orderHistory.publicKey,
|
|
128
|
+
orderState: orderStatePublicKey,
|
|
129
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
130
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
131
|
+
},
|
|
132
|
+
instructions: [
|
|
133
|
+
yield this.program.account.orderHistory.createInstruction(orderHistory),
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
return yield this.txSender.send(initializeOrderStateTx, [orderHistory], this.opts);
|
|
123
137
|
});
|
|
124
138
|
}
|
|
125
139
|
initializeMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION) {
|
|
@@ -188,8 +202,8 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
188
202
|
moveAmmToPrice(marketIndex, targetPrice) {
|
|
189
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
190
204
|
const market = this.getMarket(marketIndex);
|
|
191
|
-
const [direction, tradeSize, _] =
|
|
192
|
-
const [newQuoteAssetAmount, newBaseAssetAmount] =
|
|
205
|
+
const [direction, tradeSize, _] = trade_1.calculateTargetPriceTrade(market, targetPrice);
|
|
206
|
+
const [newQuoteAssetAmount, newBaseAssetAmount] = amm_1.calculateAmmReservesAfterSwap(market.amm, 'quote', tradeSize, amm_1.getSwapDirection('quote', direction));
|
|
193
207
|
const state = this.getStateAccount();
|
|
194
208
|
return yield this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, marketIndex, {
|
|
195
209
|
accounts: {
|
|
@@ -234,6 +248,23 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
234
248
|
});
|
|
235
249
|
});
|
|
236
250
|
}
|
|
251
|
+
resetAmmOracleTwap(marketIndex) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
const state = this.getStateAccount();
|
|
254
|
+
const markets = this.getMarketsAccount();
|
|
255
|
+
const marketData = markets.markets[marketIndex.toNumber()];
|
|
256
|
+
const ammData = marketData.amm;
|
|
257
|
+
return yield this.program.rpc.resetAmmOracleTwap(marketIndex, {
|
|
258
|
+
accounts: {
|
|
259
|
+
state: yield this.getStatePublicKey(),
|
|
260
|
+
admin: this.wallet.publicKey,
|
|
261
|
+
oracle: ammData.oracle,
|
|
262
|
+
markets: state.markets,
|
|
263
|
+
curveHistory: state.extendedCurveHistory,
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
237
268
|
withdrawFromInsuranceVault(amount, recipient) {
|
|
238
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
270
|
const state = yield this.getStateAccount();
|
|
@@ -351,6 +382,17 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
351
382
|
});
|
|
352
383
|
});
|
|
353
384
|
}
|
|
385
|
+
updateOrderFillerRewardStructure(orderFillerRewardStructure) {
|
|
386
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
387
|
+
return yield this.program.rpc.updateOrderFillerRewardStructure(orderFillerRewardStructure, {
|
|
388
|
+
accounts: {
|
|
389
|
+
admin: this.wallet.publicKey,
|
|
390
|
+
state: yield this.getStatePublicKey(),
|
|
391
|
+
orderState: yield this.getOrderStatePublicKey(),
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
|
354
396
|
updateFee(fees) {
|
|
355
397
|
return __awaiter(this, void 0, void 0, function* () {
|
|
356
398
|
return yield this.program.rpc.updateFee(fees, {
|
|
@@ -383,10 +425,22 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
383
425
|
});
|
|
384
426
|
});
|
|
385
427
|
}
|
|
386
|
-
|
|
428
|
+
updateMarketMinimumQuoteAssetTradeSize(marketIndex, minimumTradeSize) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
+
const state = this.getStateAccount();
|
|
431
|
+
return yield this.program.rpc.updateMarketMinimumQuoteAssetTradeSize(marketIndex, minimumTradeSize, {
|
|
432
|
+
accounts: {
|
|
433
|
+
admin: this.wallet.publicKey,
|
|
434
|
+
state: yield this.getStatePublicKey(),
|
|
435
|
+
markets: state.markets,
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
updateMarketMinimumBaseAssetTradeSize(marketIndex, minimumTradeSize) {
|
|
387
441
|
return __awaiter(this, void 0, void 0, function* () {
|
|
388
442
|
const state = this.getStateAccount();
|
|
389
|
-
return yield this.program.rpc.
|
|
443
|
+
return yield this.program.rpc.updateMarketMinimumBaseAssetTradeSize(marketIndex, minimumTradeSize, {
|
|
390
444
|
accounts: {
|
|
391
445
|
admin: this.wallet.publicKey,
|
|
392
446
|
state: yield this.getStatePublicKey(),
|
package/lib/assert/assert.d.ts
CHANGED
package/lib/clearingHouse.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="bn.js" />
|
|
3
3
|
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
4
|
-
import { MarketsAccount, StateAccount, DepositHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, IWallet, LiquidationHistoryAccount, PositionDirection, TradeHistoryAccount, UserAccount, Market, ExtendedCurveHistoryAccount } from './types';
|
|
4
|
+
import { MarketsAccount, StateAccount, DepositHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, IWallet, LiquidationHistoryAccount, PositionDirection, TradeHistoryAccount, UserAccount, Market, OrderHistoryAccount, OrderStateAccount, OrderParams, Order, ExtendedCurveHistoryAccount } from './types';
|
|
5
5
|
import { Connection, PublicKey, TransactionSignature, Keypair, ConfirmOptions, TransactionInstruction } from '@solana/web3.js';
|
|
6
6
|
import { MockUSDCFaucet } from './mockUSDCFaucet';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
@@ -12,7 +12,7 @@ import { TxSender } from './tx/types';
|
|
|
12
12
|
* # ClearingHouse
|
|
13
13
|
* 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
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
|
|
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
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
17
|
*/
|
|
18
18
|
export declare class ClearingHouse {
|
|
@@ -23,8 +23,18 @@ export declare class ClearingHouse {
|
|
|
23
23
|
opts?: ConfirmOptions;
|
|
24
24
|
accountSubscriber: ClearingHouseAccountSubscriber;
|
|
25
25
|
eventEmitter: StrictEventEmitter<EventEmitter, ClearingHouseAccountEvents>;
|
|
26
|
-
|
|
26
|
+
_isSubscribed: boolean;
|
|
27
27
|
txSender: TxSender;
|
|
28
|
+
get isSubscribed(): boolean;
|
|
29
|
+
set isSubscribed(val: boolean);
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated You should use the getClearingHouse factory method instead
|
|
32
|
+
* @param connection
|
|
33
|
+
* @param wallet
|
|
34
|
+
* @param clearingHouseProgramId
|
|
35
|
+
* @param opts
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
28
38
|
static from(connection: Connection, wallet: IWallet, clearingHouseProgramId: PublicKey, opts?: ConfirmOptions): ClearingHouse;
|
|
29
39
|
constructor(connection: Connection, wallet: IWallet, program: Program, accountSubscriber: ClearingHouseAccountSubscriber, txSender: TxSender, opts: ConfirmOptions);
|
|
30
40
|
/**
|
|
@@ -57,6 +67,10 @@ export declare class ClearingHouse {
|
|
|
57
67
|
getLiquidationHistoryAccount(): LiquidationHistoryAccount;
|
|
58
68
|
getDepositHistoryAccount(): DepositHistoryAccount;
|
|
59
69
|
getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
|
|
70
|
+
getOrderHistoryAccount(): OrderHistoryAccount;
|
|
71
|
+
orderStatePublicKey?: PublicKey;
|
|
72
|
+
getOrderStatePublicKey(): Promise<PublicKey>;
|
|
73
|
+
getOrderStateAccount(): OrderStateAccount;
|
|
60
74
|
/**
|
|
61
75
|
* Update the wallet to use for clearing house transactions and linked user account
|
|
62
76
|
* @param newWallet
|
|
@@ -69,8 +83,10 @@ export declare class ClearingHouse {
|
|
|
69
83
|
getInitializeUserInstructions(): Promise<[
|
|
70
84
|
Keypair,
|
|
71
85
|
PublicKey,
|
|
86
|
+
TransactionInstruction,
|
|
72
87
|
TransactionInstruction
|
|
73
88
|
]>;
|
|
89
|
+
getInitializeUserOrdersInstruction(userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
74
90
|
userAccountPublicKey?: PublicKey;
|
|
75
91
|
/**
|
|
76
92
|
* Get the address for the Clearing House User's account. NOT the user's wallet address.
|
|
@@ -79,6 +95,12 @@ export declare class ClearingHouse {
|
|
|
79
95
|
getUserAccountPublicKey(): Promise<PublicKey>;
|
|
80
96
|
userAccount?: UserAccount;
|
|
81
97
|
getUserAccount(): Promise<UserAccount>;
|
|
98
|
+
userOrdersAccountPublicKey?: PublicKey;
|
|
99
|
+
/**
|
|
100
|
+
* Get the address for the Clearing House User Order's account. NOT the user's wallet address.
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
getUserOrdersAccountPublicKey(): Promise<PublicKey>;
|
|
82
104
|
depositCollateral(amount: BN, collateralAccountPublicKey: PublicKey, userPositionsAccountPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
83
105
|
getDepositCollateralInstruction(amount: BN, collateralAccountPublicKey: PublicKey, userPositionsAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
84
106
|
/**
|
|
@@ -94,6 +116,16 @@ export declare class ClearingHouse {
|
|
|
94
116
|
getWithdrawCollateralIx(amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
95
117
|
openPosition(direction: PositionDirection, amount: BN, marketIndex: BN, limitPrice?: BN, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionSignature>;
|
|
96
118
|
getOpenPositionIx(direction: PositionDirection, amount: BN, marketIndex: BN, limitPrice?: BN, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionInstruction>;
|
|
119
|
+
placeOrder(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionSignature>;
|
|
120
|
+
getPlaceOrderIx(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionInstruction>;
|
|
121
|
+
cancelOrder(orderId: BN): Promise<TransactionSignature>;
|
|
122
|
+
getCancelOrderIx(orderId: BN): Promise<TransactionInstruction>;
|
|
123
|
+
cancelOrderByUserId(userOrderId: number): Promise<TransactionSignature>;
|
|
124
|
+
getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
|
|
125
|
+
fillOrder(userAccountPublicKey: PublicKey, userOrdersAccountPublicKey: PublicKey, order: Order): Promise<TransactionSignature>;
|
|
126
|
+
getFillOrderIx(userAccountPublicKey: PublicKey, userOrdersAccountPublicKey: PublicKey, order: Order): Promise<TransactionInstruction>;
|
|
127
|
+
placeAndFillOrder(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionSignature>;
|
|
128
|
+
getPlaceAndFillOrderIx(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionInstruction>;
|
|
97
129
|
/**
|
|
98
130
|
* Close an entire position. If you want to reduce a position, use the {@link openPosition} method in the opposite direction of the current position.
|
|
99
131
|
* @param marketIndex
|
|
@@ -111,4 +143,3 @@ export declare class ClearingHouse {
|
|
|
111
143
|
getSettleFundingPaymentIx(userAccount: PublicKey, userPositionsAccount: PublicKey): Promise<TransactionInstruction>;
|
|
112
144
|
triggerEvent(eventName: keyof ClearingHouseAccountEvents, data?: any): void;
|
|
113
145
|
}
|
|
114
|
-
//# sourceMappingURL=clearingHouse.d.ts.map
|