@d8x/perpetuals-sdk 0.9.13 → 0.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/config/priceFeedConfig.json +12 -0
- package/dist/cjs/config/symbolList.json +1 -0
- package/dist/cjs/marketData.d.ts +1 -1
- package/dist/cjs/marketData.js +4 -4
- package/dist/cjs/marketData.js.map +1 -1
- package/dist/cjs/orderExecutorTool.js +3 -4
- package/dist/cjs/orderExecutorTool.js.map +1 -1
- package/dist/cjs/perpetualDataHandler.d.ts +1 -0
- package/dist/cjs/perpetualDataHandler.js +8 -1
- package/dist/cjs/perpetualDataHandler.js.map +1 -1
- package/dist/cjs/priceFeeds.d.ts +1 -0
- package/dist/cjs/priceFeeds.js +16 -5
- package/dist/cjs/priceFeeds.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/config/priceFeedConfig.json +12 -0
- package/dist/esm/config/symbolList.json +1 -0
- package/dist/esm/marketData.d.ts +1 -1
- package/dist/esm/marketData.js +4 -4
- package/dist/esm/marketData.js.map +1 -1
- package/dist/esm/orderExecutorTool.js +3 -4
- package/dist/esm/orderExecutorTool.js.map +1 -1
- package/dist/esm/perpetualDataHandler.d.ts +1 -0
- package/dist/esm/perpetualDataHandler.js +8 -1
- package/dist/esm/perpetualDataHandler.js.map +1 -1
- package/dist/esm/priceFeeds.d.ts +1 -0
- package/dist/esm/priceFeeds.js +16 -5
- package/dist/esm/priceFeeds.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
- package/src/config/priceFeedConfig.json +12 -0
- package/src/config/symbolList.json +1 -0
- package/src/marketData.ts +3 -2
- package/src/orderExecutorTool.ts +3 -4
- package/src/perpetualDataHandler.ts +14 -1
- package/src/priceFeeds.ts +15 -5
- package/src/version.ts +1 -1
- package/dist/cjs/orderReferrerTool.d.ts +0 -207
- package/dist/cjs/orderReferrerTool.js +0 -394
- package/dist/cjs/orderReferrerTool.js.map +0 -1
- package/dist/esm/orderReferrerTool.d.ts +0 -207
- package/dist/esm/orderReferrerTool.js +0 -390
- package/dist/esm/orderReferrerTool.js.map +0 -1
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { CallOverrides, ContractTransaction, PayableOverrides } from "@ethersproject/contracts";
|
|
2
|
-
import { BlockTag } from "@ethersproject/providers";
|
|
3
|
-
import { Signer } from "@ethersproject/abstract-signer";
|
|
4
|
-
import { NodeSDKConfig, Order, PerpetualStaticInfo, PriceFeedSubmission, SmartContractOrder } from "./nodeSDKTypes";
|
|
5
|
-
import WriteAccessHandler from "./writeAccessHandler";
|
|
6
|
-
/**
|
|
7
|
-
* Functions to execute existing conditional orders from the limit order book. This class
|
|
8
|
-
* requires a private key and executes smart-contract interactions that require
|
|
9
|
-
* gas-payments.
|
|
10
|
-
* @extends WriteAccessHandler
|
|
11
|
-
*/
|
|
12
|
-
export default class OrderReferrerTool extends WriteAccessHandler {
|
|
13
|
-
static TRADE_DELAY: number;
|
|
14
|
-
/**
|
|
15
|
-
* Constructor.
|
|
16
|
-
* @param {NodeSDKConfig} config Configuration object, see PerpetualDataHandler.readSDKConfig.
|
|
17
|
-
* @example
|
|
18
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
19
|
-
* async function main() {
|
|
20
|
-
* console.log(OrderReferrerTool);
|
|
21
|
-
* // load configuration for testnet
|
|
22
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
23
|
-
* // OrderReferrerTool (authentication required, PK is an environment variable with a private key)
|
|
24
|
-
* const pk: string = <string>process.env.PK;
|
|
25
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
26
|
-
* // Create a proxy instance to access the blockchain
|
|
27
|
-
* await orderTool.createProxyInstance();
|
|
28
|
-
* }
|
|
29
|
-
* main();
|
|
30
|
-
*
|
|
31
|
-
* @param {string | Signer} signer Private key or ethers Signer of the account
|
|
32
|
-
*/
|
|
33
|
-
constructor(config: NodeSDKConfig, signer: string | Signer);
|
|
34
|
-
/**
|
|
35
|
-
* Executes an order by symbol and ID. This action interacts with the blockchain and incurs gas costs.
|
|
36
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
37
|
-
* @param {string} orderId ID of the order to be executed.
|
|
38
|
-
* @param {string=} referrerAddr optional address of the wallet to be credited for executing the order, if different from the one submitting this transaction.
|
|
39
|
-
* @param {number=} nonce optional nonce
|
|
40
|
-
* @param {PriceFeedSubmission=} submission optional signed prices obtained via PriceFeeds::fetchLatestFeedPriceInfoForPerpetual
|
|
41
|
-
* @example
|
|
42
|
-
* import { OrderReferrerTool, PerpetualDataHandler, Order } from "@d8x/perpetuals-sdk";
|
|
43
|
-
* async function main() {
|
|
44
|
-
* console.log(OrderReferrerTool);
|
|
45
|
-
* // Setup (authentication required, PK is an environment variable with a private key)
|
|
46
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
47
|
-
* const pk: string = <string>process.env.PK;
|
|
48
|
-
* const symbol = "ETH-USD-MATIC";
|
|
49
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
50
|
-
* await orderTool.createProxyInstance();
|
|
51
|
-
* // get some open orders
|
|
52
|
-
* const maxOrdersToGet = 5;
|
|
53
|
-
* let [orders, ids]: [Order[], string[]] = await orderTool.pollLimitOrders(symbol, maxOrdersToGet);
|
|
54
|
-
* console.log(`Got ${ids.length} orders`);
|
|
55
|
-
* for (let k = 0; k < ids.length; k++) {
|
|
56
|
-
* // check whether order meets conditions
|
|
57
|
-
* let doExecute = await orderTool.isTradeable(orders[k]);
|
|
58
|
-
* if (doExecute) {
|
|
59
|
-
* // execute
|
|
60
|
-
* let tx = await orderTool.executeOrder(symbol, ids[k]);
|
|
61
|
-
* console.log(`Sent order id ${ids[k]} for execution, tx hash = ${tx.hash}`);
|
|
62
|
-
* }
|
|
63
|
-
* }
|
|
64
|
-
* }
|
|
65
|
-
* main();
|
|
66
|
-
* @returns Transaction object.
|
|
67
|
-
*/
|
|
68
|
-
executeOrder(symbol: string, orderId: string, referrerAddr?: string, submission?: PriceFeedSubmission, overrides?: PayableOverrides): Promise<ContractTransaction>;
|
|
69
|
-
executeOrders(symbol: string, orderIds: string[], referrerAddr?: string, submission?: PriceFeedSubmission, overrides?: PayableOverrides): Promise<ContractTransaction>;
|
|
70
|
-
/**
|
|
71
|
-
* All the orders in the order book for a given symbol that are currently open.
|
|
72
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
73
|
-
* @example
|
|
74
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
75
|
-
* async function main() {
|
|
76
|
-
* console.log(OrderReferrerTool);
|
|
77
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
78
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
79
|
-
* const pk: string = <string>process.env.PK;
|
|
80
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
81
|
-
* await orderTool.createProxyInstance();
|
|
82
|
-
* // get all open orders
|
|
83
|
-
* let openOrders = await orderTool.getAllOpenOrders("ETH-USD-MATIC");
|
|
84
|
-
* console.log(openOrders);
|
|
85
|
-
* }
|
|
86
|
-
* main();
|
|
87
|
-
*
|
|
88
|
-
* @returns Array with all open orders and their IDs.
|
|
89
|
-
*/
|
|
90
|
-
getAllOpenOrders(symbol: string, overrides?: CallOverrides): Promise<[Order[], string[]]>;
|
|
91
|
-
/**
|
|
92
|
-
* Total number of limit orders for this symbol, excluding those that have been cancelled/removed.
|
|
93
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
94
|
-
* @example
|
|
95
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
96
|
-
* async function main() {
|
|
97
|
-
* console.log(OrderReferrerTool);
|
|
98
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
99
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
100
|
-
* const pk: string = <string>process.env.PK;
|
|
101
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
102
|
-
* await orderTool.createProxyInstance();
|
|
103
|
-
* // get all open orders
|
|
104
|
-
* let numberOfOrders = await orderTool.numberOfOpenOrders("ETH-USD-MATIC");
|
|
105
|
-
* console.log(numberOfOrders);
|
|
106
|
-
* }
|
|
107
|
-
* main();
|
|
108
|
-
*
|
|
109
|
-
* @returns {number} Number of open orders.
|
|
110
|
-
*/
|
|
111
|
-
numberOfOpenOrders(symbol: string, overrides?: CallOverrides): Promise<number>;
|
|
112
|
-
/**
|
|
113
|
-
* Get order from the digest (=id)
|
|
114
|
-
* @param symbol symbol of order book, e.g. ETH-USD-MATIC
|
|
115
|
-
* @param digest digest of the order (=order ID)
|
|
116
|
-
* @example
|
|
117
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
118
|
-
* async function main() {
|
|
119
|
-
* console.log(OrderReferrerTool);
|
|
120
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
121
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
122
|
-
* const pk: string = <string>process.env.PK;
|
|
123
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
124
|
-
* await orderTool.createProxyInstance();
|
|
125
|
-
* // get order by ID
|
|
126
|
-
* let myorder = await orderTool.getOrderById("MATIC-USD-MATIC",
|
|
127
|
-
* "0x0091a1d878491479afd09448966c1403e9d8753122e25260d3b2b9688d946eae");
|
|
128
|
-
* console.log(myorder);
|
|
129
|
-
* }
|
|
130
|
-
* main();
|
|
131
|
-
*
|
|
132
|
-
* @returns order or undefined
|
|
133
|
-
*/
|
|
134
|
-
getOrderById(symbol: string, id: string, overrides?: CallOverrides): Promise<Order | undefined>;
|
|
135
|
-
/**
|
|
136
|
-
* Get a list of active conditional orders in the order book.
|
|
137
|
-
* This a read-only action and does not incur in gas costs.
|
|
138
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
139
|
-
* @param {number} numElements Maximum number of orders to poll.
|
|
140
|
-
* @param {string=} startAfter Optional order ID from where to start polling. Defaults to the first order.
|
|
141
|
-
* @example
|
|
142
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
143
|
-
* async function main() {
|
|
144
|
-
* console.log(OrderReferrerTool);
|
|
145
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
146
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
147
|
-
* const pk: string = <string>process.env.PK;
|
|
148
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
149
|
-
* await orderTool.createProxyInstance();
|
|
150
|
-
* // get all open orders
|
|
151
|
-
* let activeOrders = await orderTool.pollLimitOrders("ETH-USD-MATIC", 2);
|
|
152
|
-
* console.log(activeOrders);
|
|
153
|
-
* }
|
|
154
|
-
* main();
|
|
155
|
-
*
|
|
156
|
-
* @returns Array of orders and corresponding order IDs
|
|
157
|
-
*/
|
|
158
|
-
pollLimitOrders(symbol: string, numElements: number, startAfter?: string, overrides?: CallOverrides): Promise<[Order[], string[]]>;
|
|
159
|
-
/**
|
|
160
|
-
* Check if a conditional order can be executed
|
|
161
|
-
* @param order order structure
|
|
162
|
-
* @param indexPrices pair of index prices S2 and S3. S3 set to zero if not required. If undefined
|
|
163
|
-
* the function will fetch the latest prices from the REST API
|
|
164
|
-
* @example
|
|
165
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
166
|
-
* async function main() {
|
|
167
|
-
* console.log(OrderReferrerTool);
|
|
168
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
169
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
170
|
-
* const pk: string = <string>process.env.PK;
|
|
171
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
172
|
-
* await orderTool.createProxyInstance();
|
|
173
|
-
* // check if tradeable
|
|
174
|
-
* let openOrders = await orderTool.getAllOpenOrders("MATIC-USD-MATIC");
|
|
175
|
-
* let check = await orderTool.isTradeable(openOrders[0][0]);
|
|
176
|
-
* console.log(check);
|
|
177
|
-
* }
|
|
178
|
-
* main();
|
|
179
|
-
* @returns true if order can be executed for the current state of the perpetuals
|
|
180
|
-
*/
|
|
181
|
-
isTradeable(order: Order, blockTimestamp?: number, indexPrices?: [number, number], overrides?: CallOverrides): Promise<boolean>;
|
|
182
|
-
/**
|
|
183
|
-
* Check for a batch of orders on the same perpetual whether they can be traded
|
|
184
|
-
* @param orders orders belonging to 1 perpetual
|
|
185
|
-
* @param indexPrice S2,S3-index prices for the given perpetual. Will fetch prices from REST API
|
|
186
|
-
* if not defined.
|
|
187
|
-
* @returns array of tradeable boolean
|
|
188
|
-
*/
|
|
189
|
-
isTradeableBatch(orders: Order[], blockTimestamp?: number, indexPrices?: [number, number, boolean, boolean], overrides?: CallOverrides): Promise<boolean[]>;
|
|
190
|
-
/**
|
|
191
|
-
* Can the order be executed?
|
|
192
|
-
* @param order order struct
|
|
193
|
-
* @param tradePrice "preview" price of this order
|
|
194
|
-
* @param markPrice current mark price
|
|
195
|
-
* @param blockTimestamp last observed block timestamp (hence already in past)
|
|
196
|
-
* @param symbolToPerpInfoMap metadata
|
|
197
|
-
* @returns true if trading conditions met, false otherwise
|
|
198
|
-
*/
|
|
199
|
-
protected _isTradeable(order: Order, tradePrice: number, markPrice: number, blockTimestamp: number, symbolToPerpInfoMap: Map<string, PerpetualStaticInfo>, overrides?: CallOverrides): Promise<boolean>;
|
|
200
|
-
/**
|
|
201
|
-
* Wrapper of static method to use after mappings have been loaded into memory.
|
|
202
|
-
* @param scOrder Perpetual order as received in the proxy events.
|
|
203
|
-
* @returns A user-friendly order struct.
|
|
204
|
-
*/
|
|
205
|
-
smartContractOrderToOrder(scOrder: SmartContractOrder): Order;
|
|
206
|
-
getTransactionCount(blockTag?: BlockTag): Promise<number>;
|
|
207
|
-
}
|
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "@ethersproject/bignumber";
|
|
2
|
-
import { HashZero } from "@ethersproject/constants";
|
|
3
|
-
import { BUY_SIDE, SELL_SIDE, ZERO_ADDRESS, ZERO_ORDER_ID, } from "./nodeSDKTypes";
|
|
4
|
-
import PerpetualDataHandler from "./perpetualDataHandler";
|
|
5
|
-
import WriteAccessHandler from "./writeAccessHandler";
|
|
6
|
-
/**
|
|
7
|
-
* Functions to execute existing conditional orders from the limit order book. This class
|
|
8
|
-
* requires a private key and executes smart-contract interactions that require
|
|
9
|
-
* gas-payments.
|
|
10
|
-
* @extends WriteAccessHandler
|
|
11
|
-
*/
|
|
12
|
-
export default class OrderReferrerTool extends WriteAccessHandler {
|
|
13
|
-
/**
|
|
14
|
-
* Constructor.
|
|
15
|
-
* @param {NodeSDKConfig} config Configuration object, see PerpetualDataHandler.readSDKConfig.
|
|
16
|
-
* @example
|
|
17
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
18
|
-
* async function main() {
|
|
19
|
-
* console.log(OrderReferrerTool);
|
|
20
|
-
* // load configuration for testnet
|
|
21
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
22
|
-
* // OrderReferrerTool (authentication required, PK is an environment variable with a private key)
|
|
23
|
-
* const pk: string = <string>process.env.PK;
|
|
24
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
25
|
-
* // Create a proxy instance to access the blockchain
|
|
26
|
-
* await orderTool.createProxyInstance();
|
|
27
|
-
* }
|
|
28
|
-
* main();
|
|
29
|
-
*
|
|
30
|
-
* @param {string | Signer} signer Private key or ethers Signer of the account
|
|
31
|
-
*/
|
|
32
|
-
constructor(config, signer) {
|
|
33
|
-
super(config, signer);
|
|
34
|
-
// override parent's gas limit with a lower number
|
|
35
|
-
this.gasLimit = 4000000;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Executes an order by symbol and ID. This action interacts with the blockchain and incurs gas costs.
|
|
39
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
40
|
-
* @param {string} orderId ID of the order to be executed.
|
|
41
|
-
* @param {string=} referrerAddr optional address of the wallet to be credited for executing the order, if different from the one submitting this transaction.
|
|
42
|
-
* @param {number=} nonce optional nonce
|
|
43
|
-
* @param {PriceFeedSubmission=} submission optional signed prices obtained via PriceFeeds::fetchLatestFeedPriceInfoForPerpetual
|
|
44
|
-
* @example
|
|
45
|
-
* import { OrderReferrerTool, PerpetualDataHandler, Order } from "@d8x/perpetuals-sdk";
|
|
46
|
-
* async function main() {
|
|
47
|
-
* console.log(OrderReferrerTool);
|
|
48
|
-
* // Setup (authentication required, PK is an environment variable with a private key)
|
|
49
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
50
|
-
* const pk: string = <string>process.env.PK;
|
|
51
|
-
* const symbol = "ETH-USD-MATIC";
|
|
52
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
53
|
-
* await orderTool.createProxyInstance();
|
|
54
|
-
* // get some open orders
|
|
55
|
-
* const maxOrdersToGet = 5;
|
|
56
|
-
* let [orders, ids]: [Order[], string[]] = await orderTool.pollLimitOrders(symbol, maxOrdersToGet);
|
|
57
|
-
* console.log(`Got ${ids.length} orders`);
|
|
58
|
-
* for (let k = 0; k < ids.length; k++) {
|
|
59
|
-
* // check whether order meets conditions
|
|
60
|
-
* let doExecute = await orderTool.isTradeable(orders[k]);
|
|
61
|
-
* if (doExecute) {
|
|
62
|
-
* // execute
|
|
63
|
-
* let tx = await orderTool.executeOrder(symbol, ids[k]);
|
|
64
|
-
* console.log(`Sent order id ${ids[k]} for execution, tx hash = ${tx.hash}`);
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
68
|
-
* main();
|
|
69
|
-
* @returns Transaction object.
|
|
70
|
-
*/
|
|
71
|
-
async executeOrder(symbol, orderId, referrerAddr, submission, overrides) {
|
|
72
|
-
if (this.proxyContract == null || this.signer == null) {
|
|
73
|
-
throw Error("no proxy contract or wallet initialized. Use createProxyInstance().");
|
|
74
|
-
}
|
|
75
|
-
const orderBookSC = this.getOrderBookContract(symbol);
|
|
76
|
-
if (typeof referrerAddr == "undefined") {
|
|
77
|
-
referrerAddr = this.traderAddr;
|
|
78
|
-
}
|
|
79
|
-
if (submission == undefined) {
|
|
80
|
-
submission = await this.priceFeedGetter.fetchLatestFeedPriceInfoForPerpetual(symbol);
|
|
81
|
-
}
|
|
82
|
-
if (!overrides || overrides.value == undefined) {
|
|
83
|
-
overrides = {
|
|
84
|
-
value: submission.timestamps.length * this.PRICE_UPDATE_FEE_GWEI,
|
|
85
|
-
gasLimit: overrides?.gasLimit ?? this.gasLimit,
|
|
86
|
-
...overrides,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return await orderBookSC.executeOrder(orderId, referrerAddr, submission.priceFeedVaas, submission.timestamps, overrides);
|
|
90
|
-
}
|
|
91
|
-
async executeOrders(symbol, orderIds, referrerAddr, submission, overrides) {
|
|
92
|
-
if (this.proxyContract == null || this.signer == null) {
|
|
93
|
-
throw Error("no proxy contract or wallet initialized. Use createProxyInstance().");
|
|
94
|
-
}
|
|
95
|
-
const orderBookSC = this.getOrderBookContract(symbol);
|
|
96
|
-
if (typeof referrerAddr == "undefined") {
|
|
97
|
-
referrerAddr = this.traderAddr;
|
|
98
|
-
}
|
|
99
|
-
if (submission == undefined) {
|
|
100
|
-
submission = await this.priceFeedGetter.fetchLatestFeedPriceInfoForPerpetual(symbol);
|
|
101
|
-
}
|
|
102
|
-
if (!overrides || overrides.value == undefined) {
|
|
103
|
-
overrides = {
|
|
104
|
-
value: submission.timestamps.length * this.PRICE_UPDATE_FEE_GWEI,
|
|
105
|
-
gasLimit: overrides?.gasLimit ?? this.gasLimit,
|
|
106
|
-
...overrides,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return await orderBookSC.executeOrders(orderIds, referrerAddr, submission?.priceFeedVaas, submission?.timestamps, overrides);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* All the orders in the order book for a given symbol that are currently open.
|
|
113
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
114
|
-
* @example
|
|
115
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
116
|
-
* async function main() {
|
|
117
|
-
* console.log(OrderReferrerTool);
|
|
118
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
119
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
120
|
-
* const pk: string = <string>process.env.PK;
|
|
121
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
122
|
-
* await orderTool.createProxyInstance();
|
|
123
|
-
* // get all open orders
|
|
124
|
-
* let openOrders = await orderTool.getAllOpenOrders("ETH-USD-MATIC");
|
|
125
|
-
* console.log(openOrders);
|
|
126
|
-
* }
|
|
127
|
-
* main();
|
|
128
|
-
*
|
|
129
|
-
* @returns Array with all open orders and their IDs.
|
|
130
|
-
*/
|
|
131
|
-
async getAllOpenOrders(symbol, overrides) {
|
|
132
|
-
let totalOrders = await this.numberOfOpenOrders(symbol, overrides);
|
|
133
|
-
return await this.pollLimitOrders(symbol, totalOrders, ZERO_ORDER_ID, overrides);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Total number of limit orders for this symbol, excluding those that have been cancelled/removed.
|
|
137
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
138
|
-
* @example
|
|
139
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
140
|
-
* async function main() {
|
|
141
|
-
* console.log(OrderReferrerTool);
|
|
142
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
143
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
144
|
-
* const pk: string = <string>process.env.PK;
|
|
145
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
146
|
-
* await orderTool.createProxyInstance();
|
|
147
|
-
* // get all open orders
|
|
148
|
-
* let numberOfOrders = await orderTool.numberOfOpenOrders("ETH-USD-MATIC");
|
|
149
|
-
* console.log(numberOfOrders);
|
|
150
|
-
* }
|
|
151
|
-
* main();
|
|
152
|
-
*
|
|
153
|
-
* @returns {number} Number of open orders.
|
|
154
|
-
*/
|
|
155
|
-
async numberOfOpenOrders(symbol, overrides) {
|
|
156
|
-
if (this.proxyContract == null) {
|
|
157
|
-
throw Error("no proxy contract initialized. Use createProxyInstance().");
|
|
158
|
-
}
|
|
159
|
-
const orderBookSC = this.getOrderBookContract(symbol);
|
|
160
|
-
let numOrders = await orderBookSC.numberOfOrderBookDigests(overrides || {});
|
|
161
|
-
return Number(numOrders);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Get order from the digest (=id)
|
|
165
|
-
* @param symbol symbol of order book, e.g. ETH-USD-MATIC
|
|
166
|
-
* @param digest digest of the order (=order ID)
|
|
167
|
-
* @example
|
|
168
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
169
|
-
* async function main() {
|
|
170
|
-
* console.log(OrderReferrerTool);
|
|
171
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
172
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
173
|
-
* const pk: string = <string>process.env.PK;
|
|
174
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
175
|
-
* await orderTool.createProxyInstance();
|
|
176
|
-
* // get order by ID
|
|
177
|
-
* let myorder = await orderTool.getOrderById("MATIC-USD-MATIC",
|
|
178
|
-
* "0x0091a1d878491479afd09448966c1403e9d8753122e25260d3b2b9688d946eae");
|
|
179
|
-
* console.log(myorder);
|
|
180
|
-
* }
|
|
181
|
-
* main();
|
|
182
|
-
*
|
|
183
|
-
* @returns order or undefined
|
|
184
|
-
*/
|
|
185
|
-
async getOrderById(symbol, id, overrides) {
|
|
186
|
-
let ob = await this.getOrderBookContract(symbol);
|
|
187
|
-
let smartContractOrder = await ob.orderOfDigest(id, overrides || {});
|
|
188
|
-
if (smartContractOrder.traderAddr == ZERO_ADDRESS) {
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
let order = OrderReferrerTool.fromSmartContractOrder(smartContractOrder, this.symbolToPerpStaticInfo);
|
|
192
|
-
return order;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Get a list of active conditional orders in the order book.
|
|
196
|
-
* This a read-only action and does not incur in gas costs.
|
|
197
|
-
* @param {string} symbol Symbol of the form ETH-USD-MATIC.
|
|
198
|
-
* @param {number} numElements Maximum number of orders to poll.
|
|
199
|
-
* @param {string=} startAfter Optional order ID from where to start polling. Defaults to the first order.
|
|
200
|
-
* @example
|
|
201
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
202
|
-
* async function main() {
|
|
203
|
-
* console.log(OrderReferrerTool);
|
|
204
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
205
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
206
|
-
* const pk: string = <string>process.env.PK;
|
|
207
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
208
|
-
* await orderTool.createProxyInstance();
|
|
209
|
-
* // get all open orders
|
|
210
|
-
* let activeOrders = await orderTool.pollLimitOrders("ETH-USD-MATIC", 2);
|
|
211
|
-
* console.log(activeOrders);
|
|
212
|
-
* }
|
|
213
|
-
* main();
|
|
214
|
-
*
|
|
215
|
-
* @returns Array of orders and corresponding order IDs
|
|
216
|
-
*/
|
|
217
|
-
async pollLimitOrders(symbol, numElements, startAfter, overrides) {
|
|
218
|
-
if (this.proxyContract == null) {
|
|
219
|
-
throw Error("no proxy contract initialized. Use createProxyInstance().");
|
|
220
|
-
}
|
|
221
|
-
const orderBookSC = this.getOrderBookContract(symbol);
|
|
222
|
-
if (typeof startAfter == "undefined") {
|
|
223
|
-
startAfter = ZERO_ORDER_ID;
|
|
224
|
-
}
|
|
225
|
-
let [orders, orderIds] = await orderBookSC.pollLimitOrders(startAfter, BigNumber.from(numElements), overrides || {});
|
|
226
|
-
let userFriendlyOrders = new Array();
|
|
227
|
-
let orderIdsOut = [];
|
|
228
|
-
let k = 0;
|
|
229
|
-
while (k < numElements && k < orders.length && orders[k].traderAddr != ZERO_ADDRESS) {
|
|
230
|
-
userFriendlyOrders.push(WriteAccessHandler.fromClientOrder(orders[k], this.symbolToPerpStaticInfo));
|
|
231
|
-
orderIdsOut.push(orderIds[k]);
|
|
232
|
-
k++;
|
|
233
|
-
}
|
|
234
|
-
return [userFriendlyOrders, orderIdsOut];
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Check if a conditional order can be executed
|
|
238
|
-
* @param order order structure
|
|
239
|
-
* @param indexPrices pair of index prices S2 and S3. S3 set to zero if not required. If undefined
|
|
240
|
-
* the function will fetch the latest prices from the REST API
|
|
241
|
-
* @example
|
|
242
|
-
* import { OrderReferrerTool, PerpetualDataHandler } from '@d8x/perpetuals-sdk';
|
|
243
|
-
* async function main() {
|
|
244
|
-
* console.log(OrderReferrerTool);
|
|
245
|
-
* // setup (authentication required, PK is an environment variable with a private key)
|
|
246
|
-
* const config = PerpetualDataHandler.readSDKConfig("testnet");
|
|
247
|
-
* const pk: string = <string>process.env.PK;
|
|
248
|
-
* let orderTool = new OrderReferrerTool(config, pk);
|
|
249
|
-
* await orderTool.createProxyInstance();
|
|
250
|
-
* // check if tradeable
|
|
251
|
-
* let openOrders = await orderTool.getAllOpenOrders("MATIC-USD-MATIC");
|
|
252
|
-
* let check = await orderTool.isTradeable(openOrders[0][0]);
|
|
253
|
-
* console.log(check);
|
|
254
|
-
* }
|
|
255
|
-
* main();
|
|
256
|
-
* @returns true if order can be executed for the current state of the perpetuals
|
|
257
|
-
*/
|
|
258
|
-
async isTradeable(order, blockTimestamp, indexPrices, overrides) {
|
|
259
|
-
if (this.proxyContract == null) {
|
|
260
|
-
throw Error("no proxy contract initialized. Use createProxyInstance().");
|
|
261
|
-
}
|
|
262
|
-
if (indexPrices == undefined) {
|
|
263
|
-
let obj = await this.priceFeedGetter.fetchPricesForPerpetual(order.symbol);
|
|
264
|
-
indexPrices = [obj.idxPrices[0], obj.idxPrices[1]];
|
|
265
|
-
}
|
|
266
|
-
let orderPrice = await PerpetualDataHandler._queryPerpetualPrice(order.symbol, order.quantity, this.symbolToPerpStaticInfo, this.proxyContract, indexPrices, overrides);
|
|
267
|
-
let markPrice = await PerpetualDataHandler._queryPerpetualMarkPrice(order.symbol, this.symbolToPerpStaticInfo, this.proxyContract, indexPrices, overrides);
|
|
268
|
-
if (blockTimestamp == undefined) {
|
|
269
|
-
const currentBlock = await this.provider.getBlockNumber();
|
|
270
|
-
blockTimestamp = (await this.provider.getBlock(currentBlock)).timestamp;
|
|
271
|
-
}
|
|
272
|
-
return await this._isTradeable(order, orderPrice, markPrice, blockTimestamp, this.symbolToPerpStaticInfo, overrides);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Check for a batch of orders on the same perpetual whether they can be traded
|
|
276
|
-
* @param orders orders belonging to 1 perpetual
|
|
277
|
-
* @param indexPrice S2,S3-index prices for the given perpetual. Will fetch prices from REST API
|
|
278
|
-
* if not defined.
|
|
279
|
-
* @returns array of tradeable boolean
|
|
280
|
-
*/
|
|
281
|
-
async isTradeableBatch(orders, blockTimestamp, indexPrices, overrides) {
|
|
282
|
-
if (orders.length == 0) {
|
|
283
|
-
return [];
|
|
284
|
-
}
|
|
285
|
-
if (this.proxyContract == null) {
|
|
286
|
-
throw Error("no proxy contract initialized. Use createProxyInstance().");
|
|
287
|
-
}
|
|
288
|
-
if (orders.filter((o) => o.symbol == orders[0].symbol).length < orders.length) {
|
|
289
|
-
throw Error("all orders in a batch must have the same symbol");
|
|
290
|
-
}
|
|
291
|
-
if (indexPrices == undefined) {
|
|
292
|
-
let obj = await this.priceFeedGetter.fetchPricesForPerpetual(orders[0].symbol);
|
|
293
|
-
indexPrices = [obj.idxPrices[0], obj.idxPrices[1], obj.mktClosed[0], obj.mktClosed[1]];
|
|
294
|
-
}
|
|
295
|
-
if (indexPrices[2] || indexPrices[3]) {
|
|
296
|
-
// market closed
|
|
297
|
-
return orders.map(() => false);
|
|
298
|
-
}
|
|
299
|
-
let orderPrice = await Promise.all(orders.map((o) => PerpetualDataHandler._queryPerpetualPrice(o.symbol, o.quantity, this.symbolToPerpStaticInfo, this.proxyContract, [indexPrices[0], indexPrices[1]], overrides)));
|
|
300
|
-
let markPrice = await PerpetualDataHandler._queryPerpetualMarkPrice(orders[0].symbol, this.symbolToPerpStaticInfo, this.proxyContract, [indexPrices[0], indexPrices[1]], overrides);
|
|
301
|
-
if (blockTimestamp == undefined) {
|
|
302
|
-
const currentBlock = await this.provider.getBlockNumber();
|
|
303
|
-
blockTimestamp = (await this.provider.getBlock(currentBlock)).timestamp;
|
|
304
|
-
}
|
|
305
|
-
return await Promise.all(orders.map((o, idx) => this._isTradeable(o, orderPrice[idx], markPrice, blockTimestamp, this.symbolToPerpStaticInfo, overrides)));
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Can the order be executed?
|
|
309
|
-
* @param order order struct
|
|
310
|
-
* @param tradePrice "preview" price of this order
|
|
311
|
-
* @param markPrice current mark price
|
|
312
|
-
* @param blockTimestamp last observed block timestamp (hence already in past)
|
|
313
|
-
* @param symbolToPerpInfoMap metadata
|
|
314
|
-
* @returns true if trading conditions met, false otherwise
|
|
315
|
-
*/
|
|
316
|
-
async _isTradeable(order, tradePrice, markPrice, blockTimestamp, symbolToPerpInfoMap, overrides) {
|
|
317
|
-
// check expiration date
|
|
318
|
-
if (order.deadline != undefined && order.deadline < Date.now() / 1000) {
|
|
319
|
-
console.log("order expired");
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
const nextBlockTimestamp = blockTimestamp + 2;
|
|
323
|
-
// TODO: replace 2 by a chain-dependent constant - 1 for zkEVM
|
|
324
|
-
if (nextBlockTimestamp < order.executionTimestamp) {
|
|
325
|
-
console.log(`execution deferred to ${order.executionTimestamp - nextBlockTimestamp} more seconds`);
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
if (order.submittedTimestamp != undefined &&
|
|
329
|
-
nextBlockTimestamp < order.submittedTimestamp + OrderReferrerTool.TRADE_DELAY) {
|
|
330
|
-
// next block should be in ~2 seconds, so + 2
|
|
331
|
-
console.log(`on hold for ${OrderReferrerTool.TRADE_DELAY + order.submittedTimestamp - nextBlockTimestamp} more seconds`);
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
// check order size
|
|
335
|
-
const lotSize = PerpetualDataHandler._getLotSize(order.symbol, symbolToPerpInfoMap);
|
|
336
|
-
if (order.quantity < lotSize) {
|
|
337
|
-
// console.log(`order size too small: ${order.quantity} < ${lotSize}`);
|
|
338
|
-
return false;
|
|
339
|
-
}
|
|
340
|
-
// check limit price: fromSmartContractOrder will set it to undefined when not tradeable
|
|
341
|
-
if (order.limitPrice == undefined) {
|
|
342
|
-
// console.log("limit price undefined");
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
let limitPrice = order.limitPrice;
|
|
346
|
-
if ((order.side == BUY_SIDE && tradePrice > limitPrice) || (order.side == SELL_SIDE && tradePrice < limitPrice)) {
|
|
347
|
-
// console.log(`limit price not met: ${limitPrice} ${order.side} @ ${tradePrice}`);
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
// check stop price
|
|
351
|
-
if (order.stopPrice != undefined &&
|
|
352
|
-
((order.side == BUY_SIDE && markPrice < order.stopPrice) ||
|
|
353
|
-
(order.side == SELL_SIDE && markPrice > order.stopPrice))) {
|
|
354
|
-
// console.log("stop price not met");
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
//check dependency
|
|
358
|
-
if (order.parentChildOrderIds != undefined &&
|
|
359
|
-
order.parentChildOrderIds[0] == HashZero &&
|
|
360
|
-
order.parentChildOrderIds[1] != HashZero) {
|
|
361
|
-
// order has a parent
|
|
362
|
-
const orderBookContract = this.getOrderBookContract(order.symbol);
|
|
363
|
-
const parentStatus = await orderBookContract.getOrderStatus(order.parentChildOrderIds[1], overrides || {});
|
|
364
|
-
if (parentStatus == 2 || parentStatus == 3) {
|
|
365
|
-
// console.log("parent not executed/cancelled");
|
|
366
|
-
// parent is open or unknown
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
// all checks passed -> order is tradeable
|
|
372
|
-
return true;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Wrapper of static method to use after mappings have been loaded into memory.
|
|
376
|
-
* @param scOrder Perpetual order as received in the proxy events.
|
|
377
|
-
* @returns A user-friendly order struct.
|
|
378
|
-
*/
|
|
379
|
-
smartContractOrderToOrder(scOrder) {
|
|
380
|
-
return PerpetualDataHandler.fromSmartContractOrder(scOrder, this.symbolToPerpStaticInfo);
|
|
381
|
-
}
|
|
382
|
-
async getTransactionCount(blockTag) {
|
|
383
|
-
if (this.signer == null) {
|
|
384
|
-
throw Error("no wallet initialized. Use createProxyInstance().");
|
|
385
|
-
}
|
|
386
|
-
return await this.signer.getTransactionCount(blockTag);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
OrderReferrerTool.TRADE_DELAY = 4;
|
|
390
|
-
//# sourceMappingURL=orderReferrerTool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orderReferrerTool.js","sourceRoot":"","sources":["../../src/orderReferrerTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIpD,OAAO,EACL,QAAQ,EAMR,SAAS,EAET,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,MAAM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