@reyaxyz/common 0.155.0 → 0.155.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/README.md +1 -1
- package/dist/transactions/abis/ConditionalOrdersGateway.json +477 -0
- package/dist/transactions/contractAddresses.js +3 -0
- package/dist/transactions/contractAddresses.js.map +1 -1
- package/dist/transactions/index.js +4 -1
- package/dist/transactions/index.js.map +1 -1
- package/dist/transactions/permissions.js +17 -0
- package/dist/transactions/permissions.js.map +1 -0
- package/dist/transactions/sign.js +83 -1
- package/dist/transactions/sign.js.map +1 -1
- package/dist/types/transactions/contractAddresses.d.ts +2 -1
- package/dist/types/transactions/contractAddresses.d.ts.map +1 -1
- package/dist/types/transactions/index.d.ts +2 -0
- package/dist/types/transactions/index.d.ts.map +1 -1
- package/dist/types/transactions/permissions.d.ts +9 -0
- package/dist/types/transactions/permissions.d.ts.map +1 -0
- package/dist/types/transactions/sign.d.ts +2 -0
- package/dist/types/transactions/sign.d.ts.map +1 -1
- package/dist/types/types.d.ts +22 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types.js +8 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/transactions/abis/ConditionalOrdersGateway.json +478 -0
- package/src/transactions/contractAddresses.ts +3 -0
- package/src/transactions/index.ts +2 -0
- package/src/transactions/permissions.ts +15 -0
- package/src/transactions/sign.ts +80 -0
- package/src/types.ts +24 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
{
|
|
2
|
+
"abi":
|
|
3
|
+
[
|
|
4
|
+
{
|
|
5
|
+
"type": "function",
|
|
6
|
+
"name": "batchExecute",
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"name": "orders",
|
|
10
|
+
"type": "tuple[]",
|
|
11
|
+
"internalType": "struct ConditionalOrderDetails[]",
|
|
12
|
+
"components": [
|
|
13
|
+
{
|
|
14
|
+
"name": "accountId",
|
|
15
|
+
"type": "uint128",
|
|
16
|
+
"internalType": "uint128"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "marketId",
|
|
20
|
+
"type": "uint128",
|
|
21
|
+
"internalType": "uint128"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "exchangeId",
|
|
25
|
+
"type": "uint128",
|
|
26
|
+
"internalType": "uint128"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "counterpartyAccountIds",
|
|
30
|
+
"type": "uint128[]",
|
|
31
|
+
"internalType": "uint128[]"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "orderType",
|
|
35
|
+
"type": "uint8",
|
|
36
|
+
"internalType": "enum OrderType"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "inputs",
|
|
40
|
+
"type": "bytes",
|
|
41
|
+
"internalType": "bytes"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "signer",
|
|
45
|
+
"type": "address",
|
|
46
|
+
"internalType": "address"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "nonce",
|
|
50
|
+
"type": "uint256",
|
|
51
|
+
"internalType": "uint256"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "signatures",
|
|
57
|
+
"type": "bytes[]",
|
|
58
|
+
"internalType": "bytes[]"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"outputs": [
|
|
62
|
+
{
|
|
63
|
+
"name": "outputs",
|
|
64
|
+
"type": "bytes[]",
|
|
65
|
+
"internalType": "bytes[]"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"stateMutability": "nonpayable"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"type": "function",
|
|
72
|
+
"name": "canExecute",
|
|
73
|
+
"inputs": [
|
|
74
|
+
{
|
|
75
|
+
"name": "order",
|
|
76
|
+
"type": "tuple",
|
|
77
|
+
"internalType": "struct ConditionalOrderDetails",
|
|
78
|
+
"components": [
|
|
79
|
+
{
|
|
80
|
+
"name": "accountId",
|
|
81
|
+
"type": "uint128",
|
|
82
|
+
"internalType": "uint128"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "marketId",
|
|
86
|
+
"type": "uint128",
|
|
87
|
+
"internalType": "uint128"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "exchangeId",
|
|
91
|
+
"type": "uint128",
|
|
92
|
+
"internalType": "uint128"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "counterpartyAccountIds",
|
|
96
|
+
"type": "uint128[]",
|
|
97
|
+
"internalType": "uint128[]"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "orderType",
|
|
101
|
+
"type": "uint8",
|
|
102
|
+
"internalType": "enum OrderType"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "inputs",
|
|
106
|
+
"type": "bytes",
|
|
107
|
+
"internalType": "bytes"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "signer",
|
|
111
|
+
"type": "address",
|
|
112
|
+
"internalType": "address"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "nonce",
|
|
116
|
+
"type": "uint256",
|
|
117
|
+
"internalType": "uint256"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "signature",
|
|
123
|
+
"type": "bytes",
|
|
124
|
+
"internalType": "bytes"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"outputs": [
|
|
128
|
+
{
|
|
129
|
+
"name": "",
|
|
130
|
+
"type": "bool",
|
|
131
|
+
"internalType": "bool"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"stateMutability": "view"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"type": "function",
|
|
138
|
+
"name": "execute",
|
|
139
|
+
"inputs": [
|
|
140
|
+
{
|
|
141
|
+
"name": "order",
|
|
142
|
+
"type": "tuple",
|
|
143
|
+
"internalType": "struct ConditionalOrderDetails",
|
|
144
|
+
"components": [
|
|
145
|
+
{
|
|
146
|
+
"name": "accountId",
|
|
147
|
+
"type": "uint128",
|
|
148
|
+
"internalType": "uint128"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "marketId",
|
|
152
|
+
"type": "uint128",
|
|
153
|
+
"internalType": "uint128"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "exchangeId",
|
|
157
|
+
"type": "uint128",
|
|
158
|
+
"internalType": "uint128"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "counterpartyAccountIds",
|
|
162
|
+
"type": "uint128[]",
|
|
163
|
+
"internalType": "uint128[]"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "orderType",
|
|
167
|
+
"type": "uint8",
|
|
168
|
+
"internalType": "enum OrderType"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "inputs",
|
|
172
|
+
"type": "bytes",
|
|
173
|
+
"internalType": "bytes"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "signer",
|
|
177
|
+
"type": "address",
|
|
178
|
+
"internalType": "address"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "nonce",
|
|
182
|
+
"type": "uint256",
|
|
183
|
+
"internalType": "uint256"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "signature",
|
|
189
|
+
"type": "bytes",
|
|
190
|
+
"internalType": "bytes"
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"outputs": [
|
|
194
|
+
{
|
|
195
|
+
"name": "output",
|
|
196
|
+
"type": "bytes",
|
|
197
|
+
"internalType": "bytes"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"stateMutability": "nonpayable"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "function",
|
|
204
|
+
"name": "hasUnorderedNonceBeenUsed",
|
|
205
|
+
"inputs": [
|
|
206
|
+
{
|
|
207
|
+
"name": "accountId",
|
|
208
|
+
"type": "uint128",
|
|
209
|
+
"internalType": "uint128"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"name": "nonce",
|
|
213
|
+
"type": "uint256",
|
|
214
|
+
"internalType": "uint256"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"outputs": [
|
|
218
|
+
{
|
|
219
|
+
"name": "",
|
|
220
|
+
"type": "bool",
|
|
221
|
+
"internalType": "bool"
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
"stateMutability": "view"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"type": "function",
|
|
228
|
+
"name": "verifySignature",
|
|
229
|
+
"inputs": [
|
|
230
|
+
{
|
|
231
|
+
"name": "order",
|
|
232
|
+
"type": "tuple",
|
|
233
|
+
"internalType": "struct ConditionalOrderDetails",
|
|
234
|
+
"components": [
|
|
235
|
+
{
|
|
236
|
+
"name": "accountId",
|
|
237
|
+
"type": "uint128",
|
|
238
|
+
"internalType": "uint128"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"name": "marketId",
|
|
242
|
+
"type": "uint128",
|
|
243
|
+
"internalType": "uint128"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"name": "exchangeId",
|
|
247
|
+
"type": "uint128",
|
|
248
|
+
"internalType": "uint128"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"name": "counterpartyAccountIds",
|
|
252
|
+
"type": "uint128[]",
|
|
253
|
+
"internalType": "uint128[]"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"name": "orderType",
|
|
257
|
+
"type": "uint8",
|
|
258
|
+
"internalType": "enum OrderType"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "inputs",
|
|
262
|
+
"type": "bytes",
|
|
263
|
+
"internalType": "bytes"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"name": "signer",
|
|
267
|
+
"type": "address",
|
|
268
|
+
"internalType": "address"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "nonce",
|
|
272
|
+
"type": "uint256",
|
|
273
|
+
"internalType": "uint256"
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "signature",
|
|
279
|
+
"type": "bytes",
|
|
280
|
+
"internalType": "bytes"
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"outputs": [
|
|
284
|
+
{
|
|
285
|
+
"name": "",
|
|
286
|
+
"type": "bool",
|
|
287
|
+
"internalType": "bool"
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
"stateMutability": "view"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"type": "function",
|
|
294
|
+
"name": "verifySigner",
|
|
295
|
+
"inputs": [
|
|
296
|
+
{
|
|
297
|
+
"name": "accountId",
|
|
298
|
+
"type": "uint128",
|
|
299
|
+
"internalType": "uint128"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"name": "signer",
|
|
303
|
+
"type": "address",
|
|
304
|
+
"internalType": "address"
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
"outputs": [
|
|
308
|
+
{
|
|
309
|
+
"name": "",
|
|
310
|
+
"type": "bool",
|
|
311
|
+
"internalType": "bool"
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
"stateMutability": "view"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"type": "error",
|
|
318
|
+
"name": "CannotExecuteConditionalOrder",
|
|
319
|
+
"inputs": [
|
|
320
|
+
{
|
|
321
|
+
"name": "order",
|
|
322
|
+
"type": "tuple",
|
|
323
|
+
"internalType": "struct ConditionalOrderDetails",
|
|
324
|
+
"components": [
|
|
325
|
+
{
|
|
326
|
+
"name": "accountId",
|
|
327
|
+
"type": "uint128",
|
|
328
|
+
"internalType": "uint128"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "marketId",
|
|
332
|
+
"type": "uint128",
|
|
333
|
+
"internalType": "uint128"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"name": "exchangeId",
|
|
337
|
+
"type": "uint128",
|
|
338
|
+
"internalType": "uint128"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "counterpartyAccountIds",
|
|
342
|
+
"type": "uint128[]",
|
|
343
|
+
"internalType": "uint128[]"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"name": "orderType",
|
|
347
|
+
"type": "uint8",
|
|
348
|
+
"internalType": "enum OrderType"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"name": "inputs",
|
|
352
|
+
"type": "bytes",
|
|
353
|
+
"internalType": "bytes"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "signer",
|
|
357
|
+
"type": "address",
|
|
358
|
+
"internalType": "address"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "nonce",
|
|
362
|
+
"type": "uint256",
|
|
363
|
+
"internalType": "uint256"
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"name": "signature",
|
|
369
|
+
"type": "bytes",
|
|
370
|
+
"internalType": "bytes"
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"type": "error",
|
|
376
|
+
"name": "FeatureUnavailable",
|
|
377
|
+
"inputs": [
|
|
378
|
+
{
|
|
379
|
+
"name": "which",
|
|
380
|
+
"type": "bytes32",
|
|
381
|
+
"internalType": "bytes32"
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"type": "error",
|
|
387
|
+
"name": "HigherExecutionPrice",
|
|
388
|
+
"inputs": [
|
|
389
|
+
{
|
|
390
|
+
"name": "executionPrice",
|
|
391
|
+
"type": "uint256",
|
|
392
|
+
"internalType": "UD60x18"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "priceLimit",
|
|
396
|
+
"type": "uint256",
|
|
397
|
+
"internalType": "UD60x18"
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"type": "error",
|
|
403
|
+
"name": "LowerExecutionPrice",
|
|
404
|
+
"inputs": [
|
|
405
|
+
{
|
|
406
|
+
"name": "executionPrice",
|
|
407
|
+
"type": "uint256",
|
|
408
|
+
"internalType": "UD60x18"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "priceLimit",
|
|
412
|
+
"type": "uint256",
|
|
413
|
+
"internalType": "UD60x18"
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"type": "error",
|
|
419
|
+
"name": "MatchOrderOutputsLengthMismatch",
|
|
420
|
+
"inputs": [
|
|
421
|
+
{
|
|
422
|
+
"name": "outputsLength",
|
|
423
|
+
"type": "uint256",
|
|
424
|
+
"internalType": "uint256"
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"type": "error",
|
|
430
|
+
"name": "OrderTypeNotFound",
|
|
431
|
+
"inputs": [
|
|
432
|
+
{
|
|
433
|
+
"name": "orderType",
|
|
434
|
+
"type": "uint8",
|
|
435
|
+
"internalType": "enum OrderType"
|
|
436
|
+
}
|
|
437
|
+
]
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"type": "error",
|
|
441
|
+
"name": "ZeroStopLossOrderSize",
|
|
442
|
+
"inputs": [
|
|
443
|
+
{
|
|
444
|
+
"name": "stopLossOrder",
|
|
445
|
+
"type": "tuple",
|
|
446
|
+
"internalType": "struct StopLossOrderDetails",
|
|
447
|
+
"components": [
|
|
448
|
+
{
|
|
449
|
+
"name": "accountId",
|
|
450
|
+
"type": "uint128",
|
|
451
|
+
"internalType": "uint128"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"name": "marketId",
|
|
455
|
+
"type": "uint128",
|
|
456
|
+
"internalType": "uint128"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"name": "exchangeId",
|
|
460
|
+
"type": "uint128",
|
|
461
|
+
"internalType": "uint128"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"name": "triggerPrice",
|
|
465
|
+
"type": "uint256",
|
|
466
|
+
"internalType": "UD60x18"
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
"name": "priceLimit",
|
|
470
|
+
"type": "uint256",
|
|
471
|
+
"internalType": "UD60x18"
|
|
472
|
+
}
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
]
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
}
|
|
@@ -4,6 +4,7 @@ export enum ContractType {
|
|
|
4
4
|
CORE_PROXY = 'core_proxy',
|
|
5
5
|
PASSIVE_POOL_PROXY = 'passive_pool_proxy',
|
|
6
6
|
PERIPHERY_PROXY = 'periphery_proxy',
|
|
7
|
+
CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
@@ -13,6 +14,7 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
13
14
|
'0x9afc30bed29d636e566fd9d7dd89d51773724be6',
|
|
14
15
|
[ContractType.PERIPHERY_PROXY]:
|
|
15
16
|
'0xa45d0566144956b6012d461ad509dad2bacacaaf',
|
|
17
|
+
[ContractType.CONDITIONAL_ORDERS_PROXY]: '',
|
|
16
18
|
},
|
|
17
19
|
[ReyaChainId.reyaNetwork]: {
|
|
18
20
|
[ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
|
|
@@ -20,6 +22,7 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
20
22
|
'0xb4b77d6180cc14472a9a7bdff01cc2459368d413',
|
|
21
23
|
[ContractType.PERIPHERY_PROXY]:
|
|
22
24
|
'0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',
|
|
25
|
+
[ContractType.CONDITIONAL_ORDERS_PROXY]: '',
|
|
23
26
|
},
|
|
24
27
|
};
|
|
25
28
|
export const getAddress = (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './action';
|
|
2
2
|
export { abi as CoreAbi } from './abis/CoreProxy.json';
|
|
3
3
|
export { abi as PeripheryAbi } from './abis/Periphery.json';
|
|
4
|
+
export { abi as ConditionalOrdersAbi } from './abis/ConditionalOrdersGateway.json';
|
|
4
5
|
export { abi as Socket_VaultWithPayloadAbi } from './abis/socket/VaultWithPayload.json';
|
|
5
6
|
export * from './contractAddresses';
|
|
6
7
|
export * from './routerCommands';
|
|
@@ -9,3 +10,4 @@ export * from './trade';
|
|
|
9
10
|
export * from './txHelpers';
|
|
10
11
|
export * from './consts';
|
|
11
12
|
export * from './executeTransaction';
|
|
13
|
+
export * from './permissions';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
export enum CoreAccountPermissionTypes {
|
|
4
|
+
ADMIN = 'ADMIN',
|
|
5
|
+
WITHDRAW = 'WITHDRAW',
|
|
6
|
+
TRANSFER = 'TRANSFER',
|
|
7
|
+
DUTCH_LIQUIDATION = 'DUTCH_LIQUIDATION',
|
|
8
|
+
MATCH_ORDER = 'MATCH_ORDER',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getPermission = (
|
|
12
|
+
permissionName: CoreAccountPermissionTypes,
|
|
13
|
+
): string => {
|
|
14
|
+
return ethers.keccak256(ethers.toUtf8Bytes(permissionName));
|
|
15
|
+
};
|
package/src/transactions/sign.ts
CHANGED
|
@@ -133,3 +133,83 @@ async function signReyaTypedData(
|
|
|
133
133
|
|
|
134
134
|
return Signature.from(signatureString);
|
|
135
135
|
}
|
|
136
|
+
|
|
137
|
+
export async function signConditionalOrder(
|
|
138
|
+
signer: Signer | JsonRpcSigner,
|
|
139
|
+
reyaChainId: ReyaChainId,
|
|
140
|
+
accountId: number,
|
|
141
|
+
marketId: number,
|
|
142
|
+
exchangeId: number,
|
|
143
|
+
counterpartyAccountIds: number[],
|
|
144
|
+
orderType: number,
|
|
145
|
+
inputs: string,
|
|
146
|
+
nonce: number,
|
|
147
|
+
deadline: number,
|
|
148
|
+
): Promise<EIP712Signature> {
|
|
149
|
+
// todo: add deadline to encoded sig
|
|
150
|
+
const signature = await signReyaTypedData(
|
|
151
|
+
signer,
|
|
152
|
+
getAddress(reyaChainId, ContractType.CONDITIONAL_ORDERS_PROXY),
|
|
153
|
+
{
|
|
154
|
+
ConditionalOrderDetails: [
|
|
155
|
+
{ name: 'accountId', type: 'uint128' },
|
|
156
|
+
{ name: 'marketId', type: 'uint128' },
|
|
157
|
+
{ name: 'exchangeId', type: 'uint128' },
|
|
158
|
+
{ name: 'counterpartyAccountIds', type: 'uint128[]' },
|
|
159
|
+
{ name: 'orderType', type: 'uint8' },
|
|
160
|
+
{ name: 'inputs', type: 'bytes' },
|
|
161
|
+
{ name: 'signer', type: 'address' },
|
|
162
|
+
{ name: 'nonce', type: 'uint256' },
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
accountId: accountId,
|
|
167
|
+
marketId: marketId,
|
|
168
|
+
exchangeId: exchangeId,
|
|
169
|
+
counterpartyAccountIds: counterpartyAccountIds,
|
|
170
|
+
orderType: orderType,
|
|
171
|
+
inputs: inputs,
|
|
172
|
+
signer: await signer.getAddress(),
|
|
173
|
+
nonce: nonce,
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return convertEthersSignatureToEIP712Signature(signature, deadline);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export async function signGrantPermission(
|
|
181
|
+
signer: Signer | JsonRpcSigner,
|
|
182
|
+
reyaChainId: ReyaChainId,
|
|
183
|
+
accountId: number,
|
|
184
|
+
permission: string,
|
|
185
|
+
user: string,
|
|
186
|
+
nonce: number,
|
|
187
|
+
deadline: number,
|
|
188
|
+
): Promise<EIP712Signature> {
|
|
189
|
+
const signature = await signReyaTypedData(
|
|
190
|
+
signer,
|
|
191
|
+
getAddress(reyaChainId, ContractType.CORE_PROXY),
|
|
192
|
+
{
|
|
193
|
+
GrantAccountPermissionBySig: [
|
|
194
|
+
{ name: 'verifyingChainId', type: 'uint256' },
|
|
195
|
+
{ name: 'caller', type: 'address' },
|
|
196
|
+
{ name: 'accountId', type: 'uint128' },
|
|
197
|
+
{ name: 'permission', type: 'bytes32' },
|
|
198
|
+
{ name: 'user', type: 'address' },
|
|
199
|
+
{ name: 'nonce', type: 'uint256' },
|
|
200
|
+
{ name: 'deadline', type: 'uint256' },
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
verifyingChainId: reyaChainId,
|
|
205
|
+
caller: await signer.getAddress(),
|
|
206
|
+
accountId: accountId,
|
|
207
|
+
permission: permission,
|
|
208
|
+
user: user,
|
|
209
|
+
nonce: nonce,
|
|
210
|
+
deadline: deadline,
|
|
211
|
+
},
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
return convertEthersSignatureToEIP712Signature(signature, deadline);
|
|
215
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -832,6 +832,10 @@ export type TransactionExecutionOutput = {
|
|
|
832
832
|
xpNftAwarded?: boolean;
|
|
833
833
|
xpEarned?: number;
|
|
834
834
|
};
|
|
835
|
+
tradeDetails?: {
|
|
836
|
+
executionPrice?: number;
|
|
837
|
+
base?: number;
|
|
838
|
+
};
|
|
835
839
|
};
|
|
836
840
|
|
|
837
841
|
export type BurnNFTParams = {
|
|
@@ -855,3 +859,23 @@ type ReadyWithdrawalStatus = {
|
|
|
855
859
|
export type PendingWithdrawal = {
|
|
856
860
|
tokenAmount: number;
|
|
857
861
|
} & (PendingWithdrawalStatus | ReadyWithdrawalStatus);
|
|
862
|
+
|
|
863
|
+
export enum StopLossOrderStatus {
|
|
864
|
+
NEW = 'new',
|
|
865
|
+
FILLED = 'filled',
|
|
866
|
+
CANCELLED = 'cancelled',
|
|
867
|
+
REJECTED = 'rejected',
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
export type StopLossOrder = {
|
|
871
|
+
orderId: number;
|
|
872
|
+
accountId: number;
|
|
873
|
+
marketId: number;
|
|
874
|
+
isLong: boolean;
|
|
875
|
+
stopPrice: number;
|
|
876
|
+
signerWallet: string;
|
|
877
|
+
nonce: number;
|
|
878
|
+
signature: string;
|
|
879
|
+
status: StopLossOrderStatus;
|
|
880
|
+
timestampMs: number;
|
|
881
|
+
};
|