@d8x/perpetuals-sdk 0.6.3 → 0.6.5

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.
Files changed (48) hide show
  1. package/dist/cjs/version.d.ts +1 -1
  2. package/dist/cjs/version.js +1 -1
  3. package/dist/esm/version.d.ts +1 -1
  4. package/dist/esm/version.js +1 -1
  5. package/package.json +5 -4
  6. package/src/abi/ERC20.json +288 -0
  7. package/src/abi/IPerpetualManager.json +5888 -0
  8. package/src/abi/LimitOrderBook.json +1062 -0
  9. package/src/abi/LimitOrderBookFactory.json +161 -0
  10. package/src/abi/MockTokenSwap.json +186 -0
  11. package/src/abi/ShareToken.json +428 -0
  12. package/src/accountTrade.ts +428 -0
  13. package/src/brokerTool.ts +555 -0
  14. package/src/config/defaultConfig.json +62 -0
  15. package/src/config/mockSwap.json +6 -0
  16. package/src/config/priceFeedConfig.json +104 -0
  17. package/src/config/symbolList.json +13 -0
  18. package/src/contracts/ERC20.ts +444 -0
  19. package/src/contracts/IPerpetualManager.ts +7227 -0
  20. package/src/contracts/LimitOrderBook.ts +1251 -0
  21. package/src/contracts/LimitOrderBookFactory.ts +348 -0
  22. package/src/contracts/MockTokenSwap.ts +373 -0
  23. package/src/contracts/ShareToken.ts +695 -0
  24. package/src/contracts/common.ts +44 -0
  25. package/src/contracts/factories/ERC20__factory.ts +306 -0
  26. package/src/contracts/factories/IPerpetualManager__factory.ts +5912 -0
  27. package/src/contracts/factories/LimitOrderBookFactory__factory.ts +189 -0
  28. package/src/contracts/factories/LimitOrderBook__factory.ts +1086 -0
  29. package/src/contracts/factories/MockTokenSwap__factory.ts +207 -0
  30. package/src/contracts/factories/ShareToken__factory.ts +449 -0
  31. package/src/contracts/factories/index.ts +9 -0
  32. package/src/contracts/index.ts +16 -0
  33. package/src/d8XMath.ts +376 -0
  34. package/src/index.ts +29 -0
  35. package/src/liquidatorTool.ts +270 -0
  36. package/src/liquidityProviderTool.ts +148 -0
  37. package/src/marketData.ts +1310 -0
  38. package/src/nodeSDKTypes.ts +332 -0
  39. package/src/orderReferrerTool.ts +516 -0
  40. package/src/perpetualDataHandler.ts +1161 -0
  41. package/src/perpetualEventHandler.ts +455 -0
  42. package/src/priceFeeds.ts +382 -0
  43. package/src/traderDigests.ts +86 -0
  44. package/src/traderInterface.ts +172 -0
  45. package/src/triangulator.ts +105 -0
  46. package/src/utils.ts +134 -0
  47. package/src/version.ts +1 -0
  48. package/src/writeAccessHandler.ts +139 -0
@@ -0,0 +1,207 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import { Contract, Signer, utils } from "ethers";
6
+ import type { Provider } from "@ethersproject/providers";
7
+ import type { MockTokenSwap, MockTokenSwapInterface } from "../MockTokenSwap";
8
+
9
+ const _abi = [
10
+ {
11
+ inputs: [
12
+ {
13
+ internalType: "address",
14
+ name: "_mockTokenAddr",
15
+ type: "address",
16
+ },
17
+ {
18
+ internalType: "uint256",
19
+ name: "_d18MaticToMockConversion",
20
+ type: "uint256",
21
+ },
22
+ ],
23
+ stateMutability: "nonpayable",
24
+ type: "constructor",
25
+ },
26
+ {
27
+ anonymous: false,
28
+ inputs: [
29
+ {
30
+ indexed: false,
31
+ internalType: "uint256",
32
+ name: "amount",
33
+ type: "uint256",
34
+ },
35
+ ],
36
+ name: "BalanceWithdrawn",
37
+ type: "event",
38
+ },
39
+ {
40
+ anonymous: false,
41
+ inputs: [
42
+ {
43
+ indexed: false,
44
+ internalType: "uint256",
45
+ name: "amount",
46
+ type: "uint256",
47
+ },
48
+ {
49
+ indexed: false,
50
+ internalType: "address",
51
+ name: "sender",
52
+ type: "address",
53
+ },
54
+ ],
55
+ name: "MockTokensReceived",
56
+ type: "event",
57
+ },
58
+ {
59
+ anonymous: false,
60
+ inputs: [
61
+ {
62
+ indexed: false,
63
+ internalType: "uint256",
64
+ name: "amountIn",
65
+ type: "uint256",
66
+ },
67
+ {
68
+ indexed: false,
69
+ internalType: "uint256",
70
+ name: "amountOut",
71
+ type: "uint256",
72
+ },
73
+ {
74
+ indexed: false,
75
+ internalType: "uint256",
76
+ name: "poolBalance",
77
+ type: "uint256",
78
+ },
79
+ {
80
+ indexed: false,
81
+ internalType: "address",
82
+ name: "sender",
83
+ type: "address",
84
+ },
85
+ ],
86
+ name: "MockTokensSwapped",
87
+ type: "event",
88
+ },
89
+ {
90
+ anonymous: false,
91
+ inputs: [
92
+ {
93
+ indexed: true,
94
+ internalType: "address",
95
+ name: "previousOwner",
96
+ type: "address",
97
+ },
98
+ {
99
+ indexed: true,
100
+ internalType: "address",
101
+ name: "newOwner",
102
+ type: "address",
103
+ },
104
+ ],
105
+ name: "OwnershipTransferred",
106
+ type: "event",
107
+ },
108
+ {
109
+ inputs: [],
110
+ name: "d18MaticToMockConversion",
111
+ outputs: [
112
+ {
113
+ internalType: "uint256",
114
+ name: "",
115
+ type: "uint256",
116
+ },
117
+ ],
118
+ stateMutability: "view",
119
+ type: "function",
120
+ },
121
+ {
122
+ inputs: [
123
+ {
124
+ internalType: "uint256",
125
+ name: "_amount",
126
+ type: "uint256",
127
+ },
128
+ ],
129
+ name: "depositMockToken",
130
+ outputs: [],
131
+ stateMutability: "nonpayable",
132
+ type: "function",
133
+ },
134
+ {
135
+ inputs: [],
136
+ name: "mockTokenAddr",
137
+ outputs: [
138
+ {
139
+ internalType: "address",
140
+ name: "",
141
+ type: "address",
142
+ },
143
+ ],
144
+ stateMutability: "view",
145
+ type: "function",
146
+ },
147
+ {
148
+ inputs: [],
149
+ name: "owner",
150
+ outputs: [
151
+ {
152
+ internalType: "address",
153
+ name: "",
154
+ type: "address",
155
+ },
156
+ ],
157
+ stateMutability: "view",
158
+ type: "function",
159
+ },
160
+ {
161
+ inputs: [],
162
+ name: "renounceOwnership",
163
+ outputs: [],
164
+ stateMutability: "nonpayable",
165
+ type: "function",
166
+ },
167
+ {
168
+ inputs: [],
169
+ name: "swapToMockToken",
170
+ outputs: [],
171
+ stateMutability: "payable",
172
+ type: "function",
173
+ },
174
+ {
175
+ inputs: [
176
+ {
177
+ internalType: "address",
178
+ name: "newOwner",
179
+ type: "address",
180
+ },
181
+ ],
182
+ name: "transferOwnership",
183
+ outputs: [],
184
+ stateMutability: "nonpayable",
185
+ type: "function",
186
+ },
187
+ {
188
+ inputs: [],
189
+ name: "withdraw",
190
+ outputs: [],
191
+ stateMutability: "nonpayable",
192
+ type: "function",
193
+ },
194
+ ] as const;
195
+
196
+ export class MockTokenSwap__factory {
197
+ static readonly abi = _abi;
198
+ static createInterface(): MockTokenSwapInterface {
199
+ return new utils.Interface(_abi) as MockTokenSwapInterface;
200
+ }
201
+ static connect(
202
+ address: string,
203
+ signerOrProvider: Signer | Provider
204
+ ): MockTokenSwap {
205
+ return new Contract(address, _abi, signerOrProvider) as MockTokenSwap;
206
+ }
207
+ }
@@ -0,0 +1,449 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import { Contract, Signer, utils } from "ethers";
6
+ import type { Provider } from "@ethersproject/providers";
7
+ import type { ShareToken, ShareTokenInterface } from "../ShareToken";
8
+
9
+ const _abi = [
10
+ {
11
+ inputs: [
12
+ {
13
+ internalType: "uint8",
14
+ name: "_poolId",
15
+ type: "uint8",
16
+ },
17
+ ],
18
+ stateMutability: "nonpayable",
19
+ type: "constructor",
20
+ },
21
+ {
22
+ anonymous: false,
23
+ inputs: [
24
+ {
25
+ indexed: true,
26
+ internalType: "address",
27
+ name: "owner",
28
+ type: "address",
29
+ },
30
+ {
31
+ indexed: true,
32
+ internalType: "address",
33
+ name: "spender",
34
+ type: "address",
35
+ },
36
+ {
37
+ indexed: false,
38
+ internalType: "uint256",
39
+ name: "value",
40
+ type: "uint256",
41
+ },
42
+ ],
43
+ name: "Approval",
44
+ type: "event",
45
+ },
46
+ {
47
+ anonymous: false,
48
+ inputs: [
49
+ {
50
+ indexed: true,
51
+ internalType: "address",
52
+ name: "previousOwner",
53
+ type: "address",
54
+ },
55
+ {
56
+ indexed: true,
57
+ internalType: "address",
58
+ name: "newOwner",
59
+ type: "address",
60
+ },
61
+ ],
62
+ name: "OwnershipTransferred",
63
+ type: "event",
64
+ },
65
+ {
66
+ anonymous: false,
67
+ inputs: [
68
+ {
69
+ indexed: false,
70
+ internalType: "address",
71
+ name: "from",
72
+ type: "address",
73
+ },
74
+ {
75
+ indexed: false,
76
+ internalType: "address",
77
+ name: "to",
78
+ type: "address",
79
+ },
80
+ {
81
+ indexed: false,
82
+ internalType: "uint256",
83
+ name: "amountD18",
84
+ type: "uint256",
85
+ },
86
+ {
87
+ indexed: false,
88
+ internalType: "uint256",
89
+ name: "priceD18",
90
+ type: "uint256",
91
+ },
92
+ ],
93
+ name: "P2PTransfer",
94
+ type: "event",
95
+ },
96
+ {
97
+ anonymous: false,
98
+ inputs: [
99
+ {
100
+ indexed: true,
101
+ internalType: "address",
102
+ name: "from",
103
+ type: "address",
104
+ },
105
+ {
106
+ indexed: true,
107
+ internalType: "address",
108
+ name: "to",
109
+ type: "address",
110
+ },
111
+ {
112
+ indexed: false,
113
+ internalType: "uint256",
114
+ name: "value",
115
+ type: "uint256",
116
+ },
117
+ ],
118
+ name: "Transfer",
119
+ type: "event",
120
+ },
121
+ {
122
+ inputs: [
123
+ {
124
+ internalType: "address",
125
+ name: "owner",
126
+ type: "address",
127
+ },
128
+ {
129
+ internalType: "address",
130
+ name: "spender",
131
+ type: "address",
132
+ },
133
+ ],
134
+ name: "allowance",
135
+ outputs: [
136
+ {
137
+ internalType: "uint256",
138
+ name: "",
139
+ type: "uint256",
140
+ },
141
+ ],
142
+ stateMutability: "view",
143
+ type: "function",
144
+ },
145
+ {
146
+ inputs: [
147
+ {
148
+ internalType: "address",
149
+ name: "spender",
150
+ type: "address",
151
+ },
152
+ {
153
+ internalType: "uint256",
154
+ name: "amount",
155
+ type: "uint256",
156
+ },
157
+ ],
158
+ name: "approve",
159
+ outputs: [
160
+ {
161
+ internalType: "bool",
162
+ name: "",
163
+ type: "bool",
164
+ },
165
+ ],
166
+ stateMutability: "nonpayable",
167
+ type: "function",
168
+ },
169
+ {
170
+ inputs: [
171
+ {
172
+ internalType: "address",
173
+ name: "account",
174
+ type: "address",
175
+ },
176
+ ],
177
+ name: "balanceOf",
178
+ outputs: [
179
+ {
180
+ internalType: "uint256",
181
+ name: "",
182
+ type: "uint256",
183
+ },
184
+ ],
185
+ stateMutability: "view",
186
+ type: "function",
187
+ },
188
+ {
189
+ inputs: [
190
+ {
191
+ internalType: "address",
192
+ name: "_account",
193
+ type: "address",
194
+ },
195
+ {
196
+ internalType: "uint256",
197
+ name: "_amount",
198
+ type: "uint256",
199
+ },
200
+ ],
201
+ name: "burn",
202
+ outputs: [],
203
+ stateMutability: "nonpayable",
204
+ type: "function",
205
+ },
206
+ {
207
+ inputs: [],
208
+ name: "decimals",
209
+ outputs: [
210
+ {
211
+ internalType: "uint8",
212
+ name: "",
213
+ type: "uint8",
214
+ },
215
+ ],
216
+ stateMutability: "view",
217
+ type: "function",
218
+ },
219
+ {
220
+ inputs: [
221
+ {
222
+ internalType: "address",
223
+ name: "spender",
224
+ type: "address",
225
+ },
226
+ {
227
+ internalType: "uint256",
228
+ name: "subtractedValue",
229
+ type: "uint256",
230
+ },
231
+ ],
232
+ name: "decreaseAllowance",
233
+ outputs: [
234
+ {
235
+ internalType: "bool",
236
+ name: "",
237
+ type: "bool",
238
+ },
239
+ ],
240
+ stateMutability: "nonpayable",
241
+ type: "function",
242
+ },
243
+ {
244
+ inputs: [
245
+ {
246
+ internalType: "address",
247
+ name: "spender",
248
+ type: "address",
249
+ },
250
+ {
251
+ internalType: "uint256",
252
+ name: "addedValue",
253
+ type: "uint256",
254
+ },
255
+ ],
256
+ name: "increaseAllowance",
257
+ outputs: [
258
+ {
259
+ internalType: "bool",
260
+ name: "",
261
+ type: "bool",
262
+ },
263
+ ],
264
+ stateMutability: "nonpayable",
265
+ type: "function",
266
+ },
267
+ {
268
+ inputs: [
269
+ {
270
+ internalType: "address",
271
+ name: "_account",
272
+ type: "address",
273
+ },
274
+ {
275
+ internalType: "uint256",
276
+ name: "_amount",
277
+ type: "uint256",
278
+ },
279
+ ],
280
+ name: "mint",
281
+ outputs: [],
282
+ stateMutability: "nonpayable",
283
+ type: "function",
284
+ },
285
+ {
286
+ inputs: [],
287
+ name: "name",
288
+ outputs: [
289
+ {
290
+ internalType: "string",
291
+ name: "",
292
+ type: "string",
293
+ },
294
+ ],
295
+ stateMutability: "view",
296
+ type: "function",
297
+ },
298
+ {
299
+ inputs: [],
300
+ name: "owner",
301
+ outputs: [
302
+ {
303
+ internalType: "address",
304
+ name: "",
305
+ type: "address",
306
+ },
307
+ ],
308
+ stateMutability: "view",
309
+ type: "function",
310
+ },
311
+ {
312
+ inputs: [],
313
+ name: "poolId",
314
+ outputs: [
315
+ {
316
+ internalType: "uint8",
317
+ name: "",
318
+ type: "uint8",
319
+ },
320
+ ],
321
+ stateMutability: "view",
322
+ type: "function",
323
+ },
324
+ {
325
+ inputs: [],
326
+ name: "renounceOwnership",
327
+ outputs: [],
328
+ stateMutability: "nonpayable",
329
+ type: "function",
330
+ },
331
+ {
332
+ inputs: [
333
+ {
334
+ internalType: "address",
335
+ name: "_account",
336
+ type: "address",
337
+ },
338
+ ],
339
+ name: "setTransferRestricted",
340
+ outputs: [],
341
+ stateMutability: "nonpayable",
342
+ type: "function",
343
+ },
344
+ {
345
+ inputs: [],
346
+ name: "symbol",
347
+ outputs: [
348
+ {
349
+ internalType: "string",
350
+ name: "",
351
+ type: "string",
352
+ },
353
+ ],
354
+ stateMutability: "view",
355
+ type: "function",
356
+ },
357
+ {
358
+ inputs: [],
359
+ name: "totalSupply",
360
+ outputs: [
361
+ {
362
+ internalType: "uint256",
363
+ name: "",
364
+ type: "uint256",
365
+ },
366
+ ],
367
+ stateMutability: "view",
368
+ type: "function",
369
+ },
370
+ {
371
+ inputs: [
372
+ {
373
+ internalType: "address",
374
+ name: "to",
375
+ type: "address",
376
+ },
377
+ {
378
+ internalType: "uint256",
379
+ name: "amount",
380
+ type: "uint256",
381
+ },
382
+ ],
383
+ name: "transfer",
384
+ outputs: [
385
+ {
386
+ internalType: "bool",
387
+ name: "",
388
+ type: "bool",
389
+ },
390
+ ],
391
+ stateMutability: "nonpayable",
392
+ type: "function",
393
+ },
394
+ {
395
+ inputs: [
396
+ {
397
+ internalType: "address",
398
+ name: "from",
399
+ type: "address",
400
+ },
401
+ {
402
+ internalType: "address",
403
+ name: "to",
404
+ type: "address",
405
+ },
406
+ {
407
+ internalType: "uint256",
408
+ name: "amount",
409
+ type: "uint256",
410
+ },
411
+ ],
412
+ name: "transferFrom",
413
+ outputs: [
414
+ {
415
+ internalType: "bool",
416
+ name: "",
417
+ type: "bool",
418
+ },
419
+ ],
420
+ stateMutability: "nonpayable",
421
+ type: "function",
422
+ },
423
+ {
424
+ inputs: [
425
+ {
426
+ internalType: "address",
427
+ name: "newOwner",
428
+ type: "address",
429
+ },
430
+ ],
431
+ name: "transferOwnership",
432
+ outputs: [],
433
+ stateMutability: "nonpayable",
434
+ type: "function",
435
+ },
436
+ ] as const;
437
+
438
+ export class ShareToken__factory {
439
+ static readonly abi = _abi;
440
+ static createInterface(): ShareTokenInterface {
441
+ return new utils.Interface(_abi) as ShareTokenInterface;
442
+ }
443
+ static connect(
444
+ address: string,
445
+ signerOrProvider: Signer | Provider
446
+ ): ShareToken {
447
+ return new Contract(address, _abi, signerOrProvider) as ShareToken;
448
+ }
449
+ }
@@ -0,0 +1,9 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export { ERC20__factory } from "./ERC20__factory";
5
+ export { IPerpetualManager__factory } from "./IPerpetualManager__factory";
6
+ export { LimitOrderBook__factory } from "./LimitOrderBook__factory";
7
+ export { LimitOrderBookFactory__factory } from "./LimitOrderBookFactory__factory";
8
+ export { MockTokenSwap__factory } from "./MockTokenSwap__factory";
9
+ export { ShareToken__factory } from "./ShareToken__factory";
@@ -0,0 +1,16 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export type { ERC20 } from "./ERC20";
5
+ export type { IPerpetualManager } from "./IPerpetualManager";
6
+ export type { LimitOrderBook } from "./LimitOrderBook";
7
+ export type { LimitOrderBookFactory } from "./LimitOrderBookFactory";
8
+ export type { MockTokenSwap } from "./MockTokenSwap";
9
+ export type { ShareToken } from "./ShareToken";
10
+ export * as factories from "./factories";
11
+ export { ERC20__factory } from "./factories/ERC20__factory";
12
+ export { IPerpetualManager__factory } from "./factories/IPerpetualManager__factory";
13
+ export { LimitOrderBook__factory } from "./factories/LimitOrderBook__factory";
14
+ export { LimitOrderBookFactory__factory } from "./factories/LimitOrderBookFactory__factory";
15
+ export { MockTokenSwap__factory } from "./factories/MockTokenSwap__factory";
16
+ export { ShareToken__factory } from "./factories/ShareToken__factory";