@drift-labs/sdk 0.1.26 → 0.1.29-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.js +8 -3
- package/lib/accounts/pollingOracleSubscriber.d.ts +26 -0
- package/lib/accounts/pollingOracleSubscriber.js +79 -0
- package/lib/accounts/types.d.ts +14 -1
- package/lib/clearingHouse.d.ts +6 -4
- package/lib/clearingHouse.js +56 -7
- package/lib/constants/markets.d.ts +2 -2
- package/lib/constants/markets.js +50 -28
- package/lib/idl/clearing_house.json +60 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/math/market.d.ts +2 -0
- package/lib/math/market.js +6 -1
- package/lib/orderParams.d.ts +1 -1
- package/lib/orderParams.js +2 -2
- package/lib/orders.d.ts +3 -2
- package/lib/orders.js +11 -4
- package/lib/types.d.ts +3 -0
- package/lib/types.js +1 -0
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.ts +10 -4
- package/src/accounts/bulkUserSubscription.js +56 -0
- package/src/accounts/bulkUserSubscription.js.map +1 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.js +210 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.js.map +1 -0
- package/src/accounts/pollingOracleSubscriber.js +65 -0
- package/src/accounts/pollingOracleSubscriber.js.map +1 -0
- package/src/accounts/pollingOracleSubscriber.ts +103 -0
- package/src/accounts/pollingTokenAccountSubscriber.js +65 -0
- package/src/accounts/pollingTokenAccountSubscriber.js.map +1 -0
- package/src/accounts/pollingUserAccountSubscriber.js +139 -0
- package/src/accounts/pollingUserAccountSubscriber.js.map +1 -0
- package/src/accounts/types.js +1 -0
- package/src/accounts/types.js.map +1 -0
- package/src/accounts/types.ts +22 -1
- package/src/accounts/utils.js +1 -0
- package/src/accounts/utils.js.map +1 -0
- package/src/accounts/webSocketAccountSubscriber.js +15 -27
- package/src/accounts/webSocketAccountSubscriber.js.map +1 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js +212 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js.map +1 -0
- package/src/accounts/webSocketUserAccountSubscriber.js +78 -0
- package/src/accounts/webSocketUserAccountSubscriber.js.map +1 -0
- package/src/addresses.js +20 -44
- package/src/addresses.js.map +1 -0
- package/src/admin.js +443 -0
- package/src/admin.js.map +1 -0
- package/src/assert/assert.js +10 -0
- package/src/assert/assert.js.map +1 -0
- package/src/clearingHouse.ts +85 -7
- package/src/clearingHouseUser.js +581 -0
- package/src/clearingHouseUser.js.map +1 -0
- package/src/config.js +37 -0
- package/src/config.js.map +1 -0
- package/src/constants/markets.js +167 -0
- package/src/constants/markets.js.map +1 -0
- package/src/constants/markets.ts +52 -30
- package/src/constants/numericConstants.js +22 -0
- package/src/constants/numericConstants.js.map +1 -0
- package/src/factory/clearingHouse.js +65 -0
- package/src/factory/clearingHouse.js.map +1 -0
- package/src/factory/clearingHouseUser.js +35 -0
- package/src/factory/clearingHouseUser.js.map +1 -0
- package/src/factory/oracleClient.js +17 -0
- package/src/factory/oracleClient.js.map +1 -0
- package/src/idl/clearing_house.json +60 -1
- package/src/index.js +56 -0
- package/src/index.js.map +1 -0
- package/src/index.ts +1 -0
- package/src/math/amm.js +285 -0
- package/src/math/amm.js.map +1 -0
- package/src/math/conversion.js +16 -0
- package/src/math/conversion.js.map +1 -0
- package/src/math/funding.js +223 -0
- package/src/math/funding.js.map +1 -0
- package/src/math/insuranceFund.js +23 -0
- package/src/math/insuranceFund.js.map +1 -0
- package/src/math/market.js +30 -0
- package/src/math/market.js.map +1 -0
- package/src/math/market.ts +9 -0
- package/src/math/orders.js +73 -0
- package/src/math/orders.js.map +1 -0
- package/src/math/position.js +121 -0
- package/src/math/position.js.map +1 -0
- package/src/math/trade.js +182 -0
- package/src/math/trade.js.map +1 -0
- package/src/math/utils.js +27 -0
- package/src/math/utils.js.map +1 -0
- package/src/mockUSDCFaucet.js +88 -116
- package/src/mockUSDCFaucet.js.map +1 -0
- package/src/oracles/pythClient.js +39 -0
- package/src/oracles/pythClient.js.map +1 -0
- package/src/oracles/switchboardClient.js +60 -0
- package/src/oracles/switchboardClient.js.map +1 -0
- package/src/oracles/types.js +3 -0
- package/src/oracles/types.js.map +1 -0
- package/src/orderParams.js +109 -0
- package/src/orderParams.js.map +1 -0
- package/src/orderParams.ts +3 -2
- package/src/orders.js +172 -0
- package/src/orders.js.map +1 -0
- package/src/orders.ts +17 -4
- package/src/token/index.js +39 -0
- package/src/token/index.js.map +1 -0
- package/src/tx/defaultTxSender.js +13 -0
- package/src/tx/defaultTxSender.js.map +1 -0
- package/src/tx/retryTxSender.js +137 -0
- package/src/tx/retryTxSender.js.map +1 -0
- package/src/tx/types.js +3 -0
- package/src/tx/types.js.map +1 -0
- package/src/tx/utils.js +9 -0
- package/src/tx/utils.js.map +1 -0
- package/src/types.js +1 -0
- package/src/types.js.map +1 -0
- package/src/types.ts +1 -0
- package/src/util/computeUnits.js +17 -0
- package/src/util/computeUnits.js.map +1 -0
- package/src/util/tps.js +17 -0
- package/src/util/tps.js.map +1 -0
- package/src/wallet.js +23 -0
- package/src/wallet.js.map +1 -0
|
@@ -13,6 +13,7 @@ exports.BulkAccountLoader = void 0;
|
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const uuid_1 = require("uuid");
|
|
15
15
|
const GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
|
|
16
|
+
const oneMinute = 60 * 1000;
|
|
16
17
|
const fiveMinutes = 5 * 60 * 1000;
|
|
17
18
|
class BulkAccountLoader {
|
|
18
19
|
constructor(connection, commitment, pollingFrequency) {
|
|
@@ -82,9 +83,6 @@ class BulkAccountLoader {
|
|
|
82
83
|
this.loadPromise = new Promise((resolver) => {
|
|
83
84
|
this.loadPromiseResolver = resolver;
|
|
84
85
|
});
|
|
85
|
-
if (this.loggingEnabled) {
|
|
86
|
-
console.log('Loading accounts');
|
|
87
|
-
}
|
|
88
86
|
try {
|
|
89
87
|
const chunks = this.chunks(Array.from(this.accountsToLoad.values()), GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE);
|
|
90
88
|
yield Promise.all(chunks.map((chunk) => {
|
|
@@ -126,6 +124,10 @@ class BulkAccountLoader {
|
|
|
126
124
|
];
|
|
127
125
|
// @ts-ignore
|
|
128
126
|
const rpcResponse = yield this.connection._rpcRequest('getMultipleAccounts', args);
|
|
127
|
+
const oneMinuteSinceLastUpdate = Date.now() - this.lastUpdate > oneMinute;
|
|
128
|
+
if (this.loggingEnabled && oneMinuteSinceLastUpdate) {
|
|
129
|
+
console.log('rpcResponse', JSON.stringify(rpcResponse));
|
|
130
|
+
}
|
|
129
131
|
const newSlot = rpcResponse.result.context.slot;
|
|
130
132
|
for (const i in accountsToLoad) {
|
|
131
133
|
const accountToLoad = accountsToLoad[i];
|
|
@@ -137,6 +139,9 @@ class BulkAccountLoader {
|
|
|
137
139
|
const dataType = rpcResponse.result.value[i].data[1];
|
|
138
140
|
newBuffer = Buffer.from(raw, dataType);
|
|
139
141
|
}
|
|
142
|
+
if (this.loggingEnabled && oneMinuteSinceLastUpdate) {
|
|
143
|
+
console.log('oldRPCResponse', oldRPCResponse);
|
|
144
|
+
}
|
|
140
145
|
if (!oldRPCResponse) {
|
|
141
146
|
this.accountData.set(key, {
|
|
142
147
|
slot: newSlot,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { OracleEvents, OracleSubscriber } from './types';
|
|
3
|
+
import { Program } from '@project-serum/anchor';
|
|
4
|
+
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { PublicKey } from '@solana/web3.js';
|
|
7
|
+
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
8
|
+
import { OracleClient, OraclePriceData } from '../oracles/types';
|
|
9
|
+
export declare class PollingOracleSubscriber implements OracleSubscriber {
|
|
10
|
+
isSubscribed: boolean;
|
|
11
|
+
program: Program;
|
|
12
|
+
eventEmitter: StrictEventEmitter<EventEmitter, OracleEvents>;
|
|
13
|
+
publicKey: PublicKey;
|
|
14
|
+
accountLoader: BulkAccountLoader;
|
|
15
|
+
oracleClient: OracleClient;
|
|
16
|
+
callbackId?: string;
|
|
17
|
+
errorCallbackId?: string;
|
|
18
|
+
oraclePriceData?: OraclePriceData;
|
|
19
|
+
constructor(publicKey: PublicKey, oracleClient: OracleClient, accountLoader: BulkAccountLoader);
|
|
20
|
+
subscribe(): Promise<boolean>;
|
|
21
|
+
addToAccountLoader(): void;
|
|
22
|
+
fetch(): Promise<void>;
|
|
23
|
+
unsubscribe(): Promise<void>;
|
|
24
|
+
assertIsSubscribed(): void;
|
|
25
|
+
getOraclePriceData(): OraclePriceData;
|
|
26
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PollingOracleSubscriber = void 0;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
const events_1 = require("events");
|
|
15
|
+
class PollingOracleSubscriber {
|
|
16
|
+
constructor(publicKey, oracleClient, accountLoader) {
|
|
17
|
+
this.isSubscribed = false;
|
|
18
|
+
this.publicKey = publicKey;
|
|
19
|
+
this.oracleClient = oracleClient;
|
|
20
|
+
this.accountLoader = accountLoader;
|
|
21
|
+
this.eventEmitter = new events_1.EventEmitter();
|
|
22
|
+
}
|
|
23
|
+
subscribe() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (this.isSubscribed) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
this.addToAccountLoader();
|
|
29
|
+
yield this.fetch();
|
|
30
|
+
this.eventEmitter.emit('update');
|
|
31
|
+
this.isSubscribed = true;
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
addToAccountLoader() {
|
|
36
|
+
if (this.callbackId) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.callbackId = this.accountLoader.addAccount(this.publicKey, (buffer) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const oraclePriceData = yield this.oracleClient.getOraclePriceDataFromBuffer(buffer);
|
|
41
|
+
this.oraclePriceData = oraclePriceData;
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
this.eventEmitter.emit('oracleUpdate', oraclePriceData);
|
|
44
|
+
this.eventEmitter.emit('update');
|
|
45
|
+
}));
|
|
46
|
+
this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
|
|
47
|
+
this.eventEmitter.emit('error', error);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
fetch() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
yield this.accountLoader.load();
|
|
53
|
+
const buffer = this.accountLoader.getAccountData(this.publicKey);
|
|
54
|
+
this.oraclePriceData = yield this.oracleClient.getOraclePriceDataFromBuffer(buffer);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
unsubscribe() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (!this.isSubscribed) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.accountLoader.removeAccount(this.publicKey, this.callbackId);
|
|
63
|
+
this.callbackId = undefined;
|
|
64
|
+
this.accountLoader.removeErrorCallbacks(this.errorCallbackId);
|
|
65
|
+
this.errorCallbackId = undefined;
|
|
66
|
+
this.isSubscribed = false;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
assertIsSubscribed() {
|
|
70
|
+
if (!this.isSubscribed) {
|
|
71
|
+
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
getOraclePriceData() {
|
|
75
|
+
this.assertIsSubscribed();
|
|
76
|
+
return this.oraclePriceData;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.PollingOracleSubscriber = PollingOracleSubscriber;
|
package/lib/accounts/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import StrictEventEmitter from 'strict-event-emitter-types';
|
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import { PublicKey } from '@solana/web3.js';
|
|
6
6
|
import { AccountInfo } from '@solana/spl-token';
|
|
7
|
-
import { ClearingHouseConfigType, ClearingHouseUserConfigType } from '..';
|
|
7
|
+
import { ClearingHouseConfigType, ClearingHouseUserConfigType, OraclePriceData } from '..';
|
|
8
8
|
export interface AccountSubscriber<T> {
|
|
9
9
|
data?: T;
|
|
10
10
|
subscribe(onChange: (data: T) => void): Promise<void>;
|
|
@@ -84,6 +84,19 @@ export interface TokenAccountSubscriber {
|
|
|
84
84
|
unsubscribe(): Promise<void>;
|
|
85
85
|
getTokenAccount(): AccountInfo;
|
|
86
86
|
}
|
|
87
|
+
export interface OracleEvents {
|
|
88
|
+
oracleUpdate: (payload: OraclePriceData) => void;
|
|
89
|
+
update: void;
|
|
90
|
+
error: (e: Error) => void;
|
|
91
|
+
}
|
|
92
|
+
export interface OracleSubscriber {
|
|
93
|
+
eventEmitter: StrictEventEmitter<EventEmitter, OracleEvents>;
|
|
94
|
+
isSubscribed: boolean;
|
|
95
|
+
subscribe(): Promise<boolean>;
|
|
96
|
+
fetch(): Promise<void>;
|
|
97
|
+
unsubscribe(): Promise<void>;
|
|
98
|
+
getOraclePriceData(): OraclePriceData;
|
|
99
|
+
}
|
|
87
100
|
export declare type AccountToPoll = {
|
|
88
101
|
key: string;
|
|
89
102
|
publicKey: PublicKey;
|
package/lib/clearingHouse.d.ts
CHANGED
|
@@ -121,10 +121,12 @@ export declare class ClearingHouse {
|
|
|
121
121
|
initializeUserOrdersThenPlaceOrder(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionSignature>;
|
|
122
122
|
placeOrder(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionSignature>;
|
|
123
123
|
getPlaceOrderIx(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionInstruction>;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
expireOrders(userAccountPublicKey: PublicKey, userOrdersAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
125
|
+
getExpireOrdersIx(userAccountPublicKey: PublicKey, userOrdersAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
126
|
+
cancelOrder(orderId: BN, oracle?: PublicKey): Promise<TransactionSignature>;
|
|
127
|
+
getCancelOrderIx(orderId: BN, oracle?: PublicKey): Promise<TransactionInstruction>;
|
|
128
|
+
cancelOrderByUserId(userOrderId: number, oracle?: PublicKey): Promise<TransactionSignature>;
|
|
129
|
+
getCancelOrderByUserIdIx(userOrderId: number, oracle?: PublicKey): Promise<TransactionInstruction>;
|
|
128
130
|
fillOrder(userAccountPublicKey: PublicKey, userOrdersAccountPublicKey: PublicKey, order: Order): Promise<TransactionSignature>;
|
|
129
131
|
getFillOrderIx(userAccountPublicKey: PublicKey, userOrdersAccountPublicKey: PublicKey, order: Order): Promise<TransactionInstruction>;
|
|
130
132
|
initializeUserOrdersThenPlaceAndFillOrder(orderParams: OrderParams, discountToken?: PublicKey, referrer?: PublicKey): Promise<TransactionSignature>;
|
package/lib/clearingHouse.js
CHANGED
|
@@ -44,6 +44,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
44
44
|
const addresses_1 = require("./addresses");
|
|
45
45
|
const utils_1 = require("./tx/utils");
|
|
46
46
|
const clearingHouse_1 = require("./factory/clearingHouse");
|
|
47
|
+
const numericConstants_1 = require("./constants/numericConstants");
|
|
47
48
|
/**
|
|
48
49
|
* # ClearingHouse
|
|
49
50
|
* 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.
|
|
@@ -511,6 +512,13 @@ class ClearingHouse {
|
|
|
511
512
|
isSigner: false,
|
|
512
513
|
});
|
|
513
514
|
}
|
|
515
|
+
if (!orderParams.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
|
|
516
|
+
remainingAccounts.push({
|
|
517
|
+
pubkey: priceOracle,
|
|
518
|
+
isWritable: false,
|
|
519
|
+
isSigner: false,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
514
522
|
const state = this.getStateAccount();
|
|
515
523
|
const orderState = this.getOrderStateAccount();
|
|
516
524
|
return yield this.program.instruction.placeOrder(orderParams, {
|
|
@@ -525,23 +533,54 @@ class ClearingHouse {
|
|
|
525
533
|
fundingRateHistory: state.fundingRateHistory,
|
|
526
534
|
orderState: yield this.getOrderStatePublicKey(),
|
|
527
535
|
orderHistory: orderState.orderHistory,
|
|
528
|
-
oracle: priceOracle,
|
|
529
536
|
},
|
|
530
537
|
remainingAccounts,
|
|
531
538
|
});
|
|
532
539
|
});
|
|
533
540
|
}
|
|
534
|
-
|
|
541
|
+
expireOrders(userAccountPublicKey, userOrdersAccountPublicKey) {
|
|
542
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
543
|
+
return yield this.txSender.send((0, utils_1.wrapInTx)(yield this.getExpireOrdersIx(userAccountPublicKey, userOrdersAccountPublicKey)), [], this.opts);
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
getExpireOrdersIx(userAccountPublicKey, userOrdersAccountPublicKey) {
|
|
547
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
548
|
+
const fillerPublicKey = yield this.getUserAccountPublicKey();
|
|
549
|
+
const userAccount = yield this.program.account.user.fetch(userAccountPublicKey);
|
|
550
|
+
const orderState = this.getOrderStateAccount();
|
|
551
|
+
return yield this.program.instruction.expireOrders({
|
|
552
|
+
accounts: {
|
|
553
|
+
state: yield this.getStatePublicKey(),
|
|
554
|
+
filler: fillerPublicKey,
|
|
555
|
+
user: userAccountPublicKey,
|
|
556
|
+
authority: this.wallet.publicKey,
|
|
557
|
+
userPositions: userAccount.positions,
|
|
558
|
+
userOrders: userOrdersAccountPublicKey,
|
|
559
|
+
orderState: yield this.getOrderStatePublicKey(),
|
|
560
|
+
orderHistory: orderState.orderHistory,
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
cancelOrder(orderId, oracle) {
|
|
535
566
|
return __awaiter(this, void 0, void 0, function* () {
|
|
536
|
-
return yield this.txSender.send((0, utils_1.wrapInTx)(yield this.getCancelOrderIx(orderId)), [], this.opts);
|
|
567
|
+
return yield this.txSender.send((0, utils_1.wrapInTx)(yield this.getCancelOrderIx(orderId, oracle)), [], this.opts);
|
|
537
568
|
});
|
|
538
569
|
}
|
|
539
|
-
getCancelOrderIx(orderId) {
|
|
570
|
+
getCancelOrderIx(orderId, oracle) {
|
|
540
571
|
return __awaiter(this, void 0, void 0, function* () {
|
|
541
572
|
const userAccountPublicKey = yield this.getUserAccountPublicKey();
|
|
542
573
|
const userAccount = yield this.getUserAccount();
|
|
543
574
|
const state = this.getStateAccount();
|
|
544
575
|
const orderState = this.getOrderStateAccount();
|
|
576
|
+
const remainingAccounts = [];
|
|
577
|
+
if (oracle) {
|
|
578
|
+
remainingAccounts.push({
|
|
579
|
+
pubkey: oracle,
|
|
580
|
+
isWritable: false,
|
|
581
|
+
isSigner: false,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
545
584
|
return yield this.program.instruction.cancelOrder(orderId, {
|
|
546
585
|
accounts: {
|
|
547
586
|
state: yield this.getStatePublicKey(),
|
|
@@ -555,20 +594,29 @@ class ClearingHouse {
|
|
|
555
594
|
orderState: yield this.getOrderStatePublicKey(),
|
|
556
595
|
orderHistory: orderState.orderHistory,
|
|
557
596
|
},
|
|
597
|
+
remainingAccounts,
|
|
558
598
|
});
|
|
559
599
|
});
|
|
560
600
|
}
|
|
561
|
-
cancelOrderByUserId(userOrderId) {
|
|
601
|
+
cancelOrderByUserId(userOrderId, oracle) {
|
|
562
602
|
return __awaiter(this, void 0, void 0, function* () {
|
|
563
|
-
return yield this.txSender.send((0, utils_1.wrapInTx)(yield this.getCancelOrderByUserIdIx(userOrderId)), [], this.opts);
|
|
603
|
+
return yield this.txSender.send((0, utils_1.wrapInTx)(yield this.getCancelOrderByUserIdIx(userOrderId, oracle)), [], this.opts);
|
|
564
604
|
});
|
|
565
605
|
}
|
|
566
|
-
getCancelOrderByUserIdIx(userOrderId) {
|
|
606
|
+
getCancelOrderByUserIdIx(userOrderId, oracle) {
|
|
567
607
|
return __awaiter(this, void 0, void 0, function* () {
|
|
568
608
|
const userAccountPublicKey = yield this.getUserAccountPublicKey();
|
|
569
609
|
const userAccount = yield this.getUserAccount();
|
|
570
610
|
const state = this.getStateAccount();
|
|
571
611
|
const orderState = this.getOrderStateAccount();
|
|
612
|
+
const remainingAccounts = [];
|
|
613
|
+
if (oracle) {
|
|
614
|
+
remainingAccounts.push({
|
|
615
|
+
pubkey: oracle,
|
|
616
|
+
isWritable: false,
|
|
617
|
+
isSigner: false,
|
|
618
|
+
});
|
|
619
|
+
}
|
|
572
620
|
return yield this.program.instruction.cancelOrderByUserId(userOrderId, {
|
|
573
621
|
accounts: {
|
|
574
622
|
state: yield this.getStatePublicKey(),
|
|
@@ -582,6 +630,7 @@ class ClearingHouse {
|
|
|
582
630
|
orderState: yield this.getOrderStatePublicKey(),
|
|
583
631
|
orderHistory: orderState.orderHistory,
|
|
584
632
|
},
|
|
633
|
+
remainingAccounts,
|
|
585
634
|
});
|
|
586
635
|
});
|
|
587
636
|
}
|
|
@@ -6,8 +6,8 @@ export declare type MarketConfig = {
|
|
|
6
6
|
symbol: string;
|
|
7
7
|
baseAssetSymbol: string;
|
|
8
8
|
marketIndex: BN;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
devnetPublicKey: string;
|
|
10
|
+
mainnetPublicKey: string;
|
|
11
11
|
launchTs: number;
|
|
12
12
|
oracleSource: OracleSource;
|
|
13
13
|
};
|
package/lib/constants/markets.js
CHANGED
|
@@ -9,8 +9,8 @@ exports.Markets = [
|
|
|
9
9
|
symbol: 'SOL-PERP',
|
|
10
10
|
baseAssetSymbol: 'SOL',
|
|
11
11
|
marketIndex: new __1.BN(0),
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
devnetPublicKey: 'J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix',
|
|
13
|
+
mainnetPublicKey: 'H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG',
|
|
14
14
|
launchTs: 1635209696886,
|
|
15
15
|
oracleSource: __1.OracleSource.PYTH,
|
|
16
16
|
},
|
|
@@ -20,8 +20,8 @@ exports.Markets = [
|
|
|
20
20
|
symbol: 'BTC-PERP',
|
|
21
21
|
baseAssetSymbol: 'BTC',
|
|
22
22
|
marketIndex: new __1.BN(1),
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
devnetPublicKey: 'HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J',
|
|
24
|
+
mainnetPublicKey: 'GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU',
|
|
25
25
|
launchTs: 1637691088868,
|
|
26
26
|
oracleSource: __1.OracleSource.PYTH,
|
|
27
27
|
},
|
|
@@ -31,8 +31,8 @@ exports.Markets = [
|
|
|
31
31
|
symbol: 'ETH-PERP',
|
|
32
32
|
baseAssetSymbol: 'ETH',
|
|
33
33
|
marketIndex: new __1.BN(2),
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
devnetPublicKey: 'EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw',
|
|
35
|
+
mainnetPublicKey: 'JBu1AL4obBcCMqKBBxhpWCNUt136ijcuMZLFvTP7iWdB',
|
|
36
36
|
launchTs: 1637691133472,
|
|
37
37
|
oracleSource: __1.OracleSource.PYTH,
|
|
38
38
|
},
|
|
@@ -42,8 +42,8 @@ exports.Markets = [
|
|
|
42
42
|
symbol: 'LUNA-PERP',
|
|
43
43
|
baseAssetSymbol: 'LUNA',
|
|
44
44
|
marketIndex: new __1.BN(3),
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
devnetPublicKey: '8PugCXTAHLM9kfLSQWe2njE5pzAgUdpPk3Nx5zSm7BD3',
|
|
46
|
+
mainnetPublicKey: '5bmWuR1dgP4avtGYMNKLuxumZTVKGgoN2BCMXWDNL9nY',
|
|
47
47
|
launchTs: 1638821738525,
|
|
48
48
|
oracleSource: __1.OracleSource.PYTH,
|
|
49
49
|
},
|
|
@@ -52,8 +52,8 @@ exports.Markets = [
|
|
|
52
52
|
category: ['L1', 'Infra'],
|
|
53
53
|
baseAssetSymbol: 'AVAX',
|
|
54
54
|
marketIndex: new __1.BN(4),
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
devnetPublicKey: 'FVb5h1VmHPfVb1RfqZckchq18GxRv4iKt8T4eVTQAqdz',
|
|
56
|
+
mainnetPublicKey: 'Ax9ujW5B9oqcv59N8m6f1BpTBq2rGeGaBcpKjC5UYsXU',
|
|
57
57
|
launchTs: 1639092501080,
|
|
58
58
|
oracleSource: __1.OracleSource.PYTH,
|
|
59
59
|
},
|
|
@@ -63,8 +63,8 @@ exports.Markets = [
|
|
|
63
63
|
category: ['L1', 'Exchange'],
|
|
64
64
|
baseAssetSymbol: 'BNB',
|
|
65
65
|
marketIndex: new __1.BN(5),
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
devnetPublicKey: 'GwzBgrXb4PG59zjce24SF2b9JXbLEjJJTBkmytuEZj1b',
|
|
67
|
+
mainnetPublicKey: '4CkQJBxhU8EZ2UjhigbtdaPbpTe6mqf811fipYBFbSYN',
|
|
68
68
|
launchTs: 1639523193012,
|
|
69
69
|
oracleSource: __1.OracleSource.PYTH,
|
|
70
70
|
},
|
|
@@ -74,8 +74,8 @@ exports.Markets = [
|
|
|
74
74
|
symbol: 'MATIC-PERP',
|
|
75
75
|
baseAssetSymbol: 'MATIC',
|
|
76
76
|
marketIndex: new __1.BN(6),
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
devnetPublicKey: 'FBirwuDFuRAu4iSGc7RGxN5koHB7EJM1wbCmyPuQoGur',
|
|
78
|
+
mainnetPublicKey: '7KVswB9vkCgeM3SHP7aGDijvdRAHK8P5wi9JXViCrtYh',
|
|
79
79
|
launchTs: 1641488603564,
|
|
80
80
|
oracleSource: __1.OracleSource.PYTH,
|
|
81
81
|
},
|
|
@@ -85,8 +85,8 @@ exports.Markets = [
|
|
|
85
85
|
symbol: 'ATOM-PERP',
|
|
86
86
|
baseAssetSymbol: 'ATOM',
|
|
87
87
|
marketIndex: new __1.BN(7),
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
devnetPublicKey: '7YAze8qFUMkBnyLVdKT4TFUUFui99EwS5gfRArMcrvFk',
|
|
89
|
+
mainnetPublicKey: 'CrCpTerNqtZvqLcKqz1k13oVeXV9WkMD2zA9hBKXrsbN',
|
|
90
90
|
launchTs: 1641920238195,
|
|
91
91
|
oracleSource: __1.OracleSource.PYTH,
|
|
92
92
|
},
|
|
@@ -95,8 +95,8 @@ exports.Markets = [
|
|
|
95
95
|
symbol: 'DOT-PERP',
|
|
96
96
|
baseAssetSymbol: 'DOT',
|
|
97
97
|
marketIndex: new __1.BN(8),
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
devnetPublicKey: '4dqq5VBpN4EwYb7wyywjjfknvMKu7m78j9mKZRXTj462',
|
|
99
|
+
mainnetPublicKey: 'EcV1X1gY2yb4KXxjVQtTHTbioum2gvmPnFk4zYAt7zne',
|
|
100
100
|
launchTs: 1642629253786,
|
|
101
101
|
oracleSource: __1.OracleSource.PYTH,
|
|
102
102
|
},
|
|
@@ -106,8 +106,8 @@ exports.Markets = [
|
|
|
106
106
|
symbol: 'ADA-PERP',
|
|
107
107
|
baseAssetSymbol: 'ADA',
|
|
108
108
|
marketIndex: new __1.BN(9),
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
devnetPublicKey: '8oGTURNmSQkrBS1AQ5NjB2p8qY34UVmMA9ojrw8vnHus',
|
|
110
|
+
mainnetPublicKey: '3pyn4svBbxJ9Wnn3RVeafyLWfzie6yC5eTig2S62v9SC',
|
|
111
111
|
launchTs: 1643084413000,
|
|
112
112
|
oracleSource: __1.OracleSource.PYTH,
|
|
113
113
|
},
|
|
@@ -117,8 +117,8 @@ exports.Markets = [
|
|
|
117
117
|
symbol: 'ALGO-PERP',
|
|
118
118
|
baseAssetSymbol: 'ALGO',
|
|
119
119
|
marketIndex: new __1.BN(10),
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
devnetPublicKey: 'c1A946dY5NHuVda77C8XXtXytyR3wK1SCP3eA9VRfC3',
|
|
121
|
+
mainnetPublicKey: 'HqFyq1wh1xKvL7KDqqT7NJeSPdAqsDqnmBisUC2XdXAX',
|
|
122
122
|
launchTs: 1643686767000,
|
|
123
123
|
oracleSource: __1.OracleSource.PYTH,
|
|
124
124
|
},
|
|
@@ -128,8 +128,8 @@ exports.Markets = [
|
|
|
128
128
|
symbol: 'FTT-PERP',
|
|
129
129
|
baseAssetSymbol: 'FTT',
|
|
130
130
|
marketIndex: new __1.BN(11),
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
devnetPublicKey: '6vivTRs5ZPeeXbjo7dfburfaYDWoXjBtdtuYgQRuGfu',
|
|
132
|
+
mainnetPublicKey: '8JPJJkmDScpcNmBRKGZuPuG2GYAveQgP3t5gFuMymwvF',
|
|
133
133
|
launchTs: 1644382122000,
|
|
134
134
|
oracleSource: __1.OracleSource.PYTH,
|
|
135
135
|
},
|
|
@@ -139,8 +139,8 @@ exports.Markets = [
|
|
|
139
139
|
symbol: 'LTC-PERP',
|
|
140
140
|
baseAssetSymbol: 'LTC',
|
|
141
141
|
marketIndex: new __1.BN(12),
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
devnetPublicKey: 'BLArYBCUYhdWiY8PCUTpvFE21iaJq85dvxLk9bYMobcU',
|
|
143
|
+
mainnetPublicKey: '8RMnV1eD55iqUFJLMguPkYBkq8DCtx81XcmAja93LvRR',
|
|
144
144
|
launchTs: 1645027429000,
|
|
145
145
|
oracleSource: __1.OracleSource.PYTH,
|
|
146
146
|
},
|
|
@@ -150,11 +150,33 @@ exports.Markets = [
|
|
|
150
150
|
symbol: 'XRP-PERP',
|
|
151
151
|
baseAssetSymbol: 'XRP',
|
|
152
152
|
marketIndex: new __1.BN(13),
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
devnetPublicKey: 'WMW5xc3HypXwTnPesyUT49uLsyHwNURsWAEk39onKuk',
|
|
154
|
+
mainnetPublicKey: 'WMW5xc3HypXwTnPesyUT49uLsyHwNURsWAEk39onKuk',
|
|
155
155
|
launchTs: 1647543166000,
|
|
156
156
|
oracleSource: __1.OracleSource.SWITCHBOARD,
|
|
157
157
|
},
|
|
158
|
+
{
|
|
159
|
+
fullName: 'ApeCoin',
|
|
160
|
+
category: ['NFT'],
|
|
161
|
+
symbol: 'APE-PERP',
|
|
162
|
+
baseAssetSymbol: 'APE',
|
|
163
|
+
marketIndex: new __1.BN(14),
|
|
164
|
+
devnetPublicKey: 'AwH6kBrJbkL9JTeqRd7Q59EdWh6UjPtoqoA5M4x4K2fA',
|
|
165
|
+
mainnetPublicKey: '74zeQpprjNtEghGiC3VEPsR9y4kR2GTd4Rq9YVk9tnjz',
|
|
166
|
+
launchTs: 1648475932000,
|
|
167
|
+
oracleSource: __1.OracleSource.SWITCHBOARD,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
fullName: 'DogeCoin',
|
|
171
|
+
category: ['Meme', 'NFT'],
|
|
172
|
+
symbol: 'DOGE-PERP',
|
|
173
|
+
baseAssetSymbol: 'DOGE',
|
|
174
|
+
marketIndex: new __1.BN(15),
|
|
175
|
+
devnetPublicKey: '4L6YhY8VvUgmqG5MvJkUJATtzB2rFqdrJwQCmFLv4Jzy',
|
|
176
|
+
mainnetPublicKey: 'FsSM3s38PX9K7Dn6eGzuE29S2Dsk1Sss1baytTQdCaQj',
|
|
177
|
+
launchTs: 1648607439000,
|
|
178
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
179
|
+
},
|
|
158
180
|
// {
|
|
159
181
|
// symbol: 'mSOL-PERP',
|
|
160
182
|
// baseAssetSymbol: 'mSOL',
|
|
@@ -677,6 +677,52 @@
|
|
|
677
677
|
}
|
|
678
678
|
]
|
|
679
679
|
},
|
|
680
|
+
{
|
|
681
|
+
"name": "expireOrders",
|
|
682
|
+
"accounts": [
|
|
683
|
+
{
|
|
684
|
+
"name": "state",
|
|
685
|
+
"isMut": false,
|
|
686
|
+
"isSigner": false
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"name": "orderState",
|
|
690
|
+
"isMut": false,
|
|
691
|
+
"isSigner": false
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
"name": "authority",
|
|
695
|
+
"isMut": false,
|
|
696
|
+
"isSigner": true
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"name": "filler",
|
|
700
|
+
"isMut": true,
|
|
701
|
+
"isSigner": false
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"name": "user",
|
|
705
|
+
"isMut": true,
|
|
706
|
+
"isSigner": false
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"name": "userPositions",
|
|
710
|
+
"isMut": true,
|
|
711
|
+
"isSigner": false
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
"name": "userOrders",
|
|
715
|
+
"isMut": true,
|
|
716
|
+
"isSigner": false
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"name": "orderHistory",
|
|
720
|
+
"isMut": true,
|
|
721
|
+
"isSigner": false
|
|
722
|
+
}
|
|
723
|
+
],
|
|
724
|
+
"args": []
|
|
725
|
+
},
|
|
680
726
|
{
|
|
681
727
|
"name": "fillOrder",
|
|
682
728
|
"accounts": [
|
|
@@ -2616,7 +2662,7 @@
|
|
|
2616
2662
|
},
|
|
2617
2663
|
{
|
|
2618
2664
|
"name": "oraclePriceOffset",
|
|
2619
|
-
"type": "
|
|
2665
|
+
"type": "i128"
|
|
2620
2666
|
},
|
|
2621
2667
|
{
|
|
2622
2668
|
"name": "padding0",
|
|
@@ -3800,6 +3846,9 @@
|
|
|
3800
3846
|
},
|
|
3801
3847
|
{
|
|
3802
3848
|
"name": "Fill"
|
|
3849
|
+
},
|
|
3850
|
+
{
|
|
3851
|
+
"name": "Expire"
|
|
3803
3852
|
}
|
|
3804
3853
|
]
|
|
3805
3854
|
}
|
|
@@ -4185,6 +4234,16 @@
|
|
|
4185
4234
|
"code": 6058,
|
|
4186
4235
|
"name": "CantCancelPostOnlyOrder",
|
|
4187
4236
|
"msg": "Cant Cancel Post Only Order"
|
|
4237
|
+
},
|
|
4238
|
+
{
|
|
4239
|
+
"code": 6059,
|
|
4240
|
+
"name": "InvalidOracleOffset",
|
|
4241
|
+
"msg": "InvalidOracleOffset"
|
|
4242
|
+
},
|
|
4243
|
+
{
|
|
4244
|
+
"code": 6060,
|
|
4245
|
+
"name": "CantExpireOrders",
|
|
4246
|
+
"msg": "CantExpireOrders"
|
|
4188
4247
|
}
|
|
4189
4248
|
]
|
|
4190
4249
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './accounts/webSocketClearingHouseAccountSubscriber';
|
|
|
10
10
|
export * from './accounts/bulkAccountLoader';
|
|
11
11
|
export * from './accounts/bulkUserSubscription';
|
|
12
12
|
export * from './accounts/pollingClearingHouseAccountSubscriber';
|
|
13
|
+
export * from './accounts/pollingOracleSubscriber';
|
|
13
14
|
export * from './accounts/pollingTokenAccountSubscriber';
|
|
14
15
|
export * from './accounts/types';
|
|
15
16
|
export * from './addresses';
|
package/lib/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __exportStar(require("./accounts/webSocketClearingHouseAccountSubscriber"), expo
|
|
|
29
29
|
__exportStar(require("./accounts/bulkAccountLoader"), exports);
|
|
30
30
|
__exportStar(require("./accounts/bulkUserSubscription"), exports);
|
|
31
31
|
__exportStar(require("./accounts/pollingClearingHouseAccountSubscriber"), exports);
|
|
32
|
+
__exportStar(require("./accounts/pollingOracleSubscriber"), exports);
|
|
32
33
|
__exportStar(require("./accounts/pollingTokenAccountSubscriber"), exports);
|
|
33
34
|
__exportStar(require("./accounts/types"), exports);
|
|
34
35
|
__exportStar(require("./addresses"), exports);
|
package/lib/math/market.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { BN } from '@project-serum/anchor';
|
|
3
3
|
import { Market, PositionDirection } from '../types';
|
|
4
|
+
import { OraclePriceData } from '../oracles/types';
|
|
4
5
|
/**
|
|
5
6
|
* Calculates market mark price
|
|
6
7
|
*
|
|
@@ -9,3 +10,4 @@ import { Market, PositionDirection } from '../types';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare function calculateMarkPrice(market: Market): BN;
|
|
11
12
|
export declare function calculateNewMarketAfterTrade(baseAssetAmount: BN, direction: PositionDirection, market: Market): Market;
|
|
13
|
+
export declare function calculateMarkOracleSpread(market: Market, oraclePriceData: OraclePriceData): BN;
|
package/lib/math/market.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateNewMarketAfterTrade = exports.calculateMarkPrice = void 0;
|
|
3
|
+
exports.calculateMarkOracleSpread = exports.calculateNewMarketAfterTrade = exports.calculateMarkPrice = void 0;
|
|
4
4
|
const amm_1 = require("./amm");
|
|
5
5
|
/**
|
|
6
6
|
* Calculates market mark price
|
|
@@ -22,3 +22,8 @@ function calculateNewMarketAfterTrade(baseAssetAmount, direction, market) {
|
|
|
22
22
|
return newMarket;
|
|
23
23
|
}
|
|
24
24
|
exports.calculateNewMarketAfterTrade = calculateNewMarketAfterTrade;
|
|
25
|
+
function calculateMarkOracleSpread(market, oraclePriceData) {
|
|
26
|
+
const markPrice = calculateMarkPrice(market);
|
|
27
|
+
return markPrice.sub(oraclePriceData.price);
|
|
28
|
+
}
|
|
29
|
+
exports.calculateMarkOracleSpread = calculateMarkOracleSpread;
|
package/lib/orderParams.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { OrderParams, OrderTriggerCondition, PositionDirection } from './types';
|
|
3
3
|
import { BN } from '@project-serum/anchor';
|
|
4
|
-
export declare function getLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number, postOnly?: boolean): OrderParams;
|
|
4
|
+
export declare function getLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number, postOnly?: boolean, oraclePriceOffset?: BN): OrderParams;
|
|
5
5
|
export declare function getTriggerMarketOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, triggerPrice: BN, triggerCondition: OrderTriggerCondition, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number): OrderParams;
|
|
6
6
|
export declare function getTriggerLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, triggerPrice: BN, triggerCondition: OrderTriggerCondition, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number): OrderParams;
|
|
7
7
|
export declare function getMarketOrderParams(marketIndex: BN, direction: PositionDirection, quoteAssetAmount: BN, baseAssetAmount: BN, reduceOnly: boolean, price?: BN, discountToken?: boolean, referrer?: boolean): OrderParams;
|