afp-sdk 0.5.3__py3-none-any.whl → 0.6.0__py3-none-any.whl

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 (49) hide show
  1. afp/__init__.py +4 -1
  2. afp/afp.py +11 -0
  3. afp/api/admin.py +1 -1
  4. afp/api/base.py +11 -2
  5. afp/api/margin_account.py +12 -148
  6. afp/api/product.py +302 -148
  7. afp/api/trading.py +19 -22
  8. afp/auth.py +14 -0
  9. afp/bindings/__init__.py +30 -16
  10. afp/bindings/admin_facet.py +890 -0
  11. afp/bindings/clearing_facet.py +356 -773
  12. afp/bindings/facade.py +9 -6
  13. afp/bindings/final_settlement_facet.py +258 -99
  14. afp/bindings/margin_account.py +524 -839
  15. afp/bindings/margin_account_facet.py +722 -0
  16. afp/bindings/margin_account_registry.py +184 -310
  17. afp/bindings/mark_price_tracker_facet.py +74 -16
  18. afp/bindings/product_registry.py +1577 -541
  19. afp/bindings/product_registry_facet.py +1467 -0
  20. afp/bindings/system_viewer.py +592 -369
  21. afp/bindings/types.py +223 -0
  22. afp/config.py +4 -0
  23. afp/constants.py +49 -6
  24. afp/decorators.py +25 -3
  25. afp/dtos.py +142 -0
  26. afp/exceptions.py +14 -0
  27. afp/exchange.py +13 -8
  28. afp/hashing.py +7 -5
  29. afp/ipfs.py +245 -0
  30. afp/json-schemas/bafyreiaw34o6l3rmatabzbds2i2myazdw2yolevcpsoyd2i2g3ms7wa2eq.json +1 -0
  31. afp/json-schemas/bafyreibnfg6nq74dvpkre5rakkccij7iadp5rxpim7omsatjnrpmj3y7v4.json +1 -0
  32. afp/json-schemas/bafyreicgr6dfo5yduixjkcifghiulskfegwojvuwodtouvivl362zndhxe.json +1 -0
  33. afp/json-schemas/bafyreicheoypx6synljushh7mq2572iyhlolf4nake2p5dwobgnj3r5eua.json +1 -0
  34. afp/json-schemas/bafyreid35a67db4sqh4fs6boddyt2xvscbqy6nqvsp5jjur56qhkw4ixre.json +1 -0
  35. afp/json-schemas/bafyreidzs7okcpqiss6ztftltyptqwnw5e5opsy5yntospekjha4kpykaa.json +1 -0
  36. afp/json-schemas/bafyreifcec2km7hxwq6oqzjlspni2mgipetjb7pqtaewh2efislzoctboi.json +1 -0
  37. afp/json-schemas/bafyreihn3oiaxffe4e2w7pwtreadpw3obfd7gqlogbcxm56jc2hzfvco74.json +1 -0
  38. afp/json-schemas/bafyreihur3dzwhja6uxsbcw6eeoj3xmmc4e3zkmyzpot5v5dleevxe5zam.json +1 -0
  39. afp/schemas.py +228 -176
  40. afp/types.py +169 -0
  41. afp/validators.py +218 -8
  42. {afp_sdk-0.5.3.dist-info → afp_sdk-0.6.0.dist-info}/METADATA +73 -10
  43. afp_sdk-0.6.0.dist-info/RECORD +50 -0
  44. afp/bindings/auctioneer_facet.py +0 -752
  45. afp/bindings/bankruptcy_facet.py +0 -391
  46. afp/bindings/trading_protocol.py +0 -1158
  47. afp_sdk-0.5.3.dist-info/RECORD +0 -37
  48. {afp_sdk-0.5.3.dist-info → afp_sdk-0.6.0.dist-info}/WHEEL +0 -0
  49. {afp_sdk-0.5.3.dist-info → afp_sdk-0.6.0.dist-info}/licenses/LICENSE +0 -0
@@ -2,79 +2,16 @@
2
2
 
3
3
  # This module has been generated using pyabigen v0.2.16
4
4
 
5
- import enum
6
5
  import typing
7
- from dataclasses import dataclass
8
6
 
9
7
  import eth_typing
10
8
  import hexbytes
11
9
  import web3
10
+ from web3 import types
12
11
  from web3.contract import contract
13
12
 
14
- if typing.TYPE_CHECKING:
15
- from .auctioneer_facet import AuctionConfig
16
13
 
17
-
18
- class Side(enum.IntEnum):
19
- """Port of `enum Side` on the ClearingFacet contract."""
20
-
21
- BID = 0
22
- ASK = 1
23
-
24
-
25
- @dataclass
26
- class ClearingConfig:
27
- """Port of `struct ClearingConfig` on the IClearing contract."""
28
-
29
- clearing_fee_rate: int
30
-
31
-
32
- @dataclass
33
- class Config:
34
- """Port of `struct Config` on the IClearing contract."""
35
-
36
- auction_config: "AuctionConfig"
37
- clearing_config: ClearingConfig
38
-
39
-
40
- @dataclass
41
- class IntentData:
42
- """Port of `struct IntentData` on the IClearing contract."""
43
-
44
- nonce: int
45
- trading_protocol_id: eth_typing.ChecksumAddress
46
- product_id: hexbytes.HexBytes
47
- limit_price: int
48
- quantity: int
49
- max_trading_fee_rate: int
50
- good_until: int
51
- side: Side
52
-
53
-
54
- @dataclass
55
- class Intent:
56
- """Port of `struct Intent` on the IClearing contract."""
57
-
58
- margin_account_id: eth_typing.ChecksumAddress
59
- intent_account_id: eth_typing.ChecksumAddress
60
- hash: hexbytes.HexBytes
61
- data: IntentData
62
- signature: hexbytes.HexBytes
63
-
64
-
65
- @dataclass
66
- class Trade:
67
- """Port of `struct Trade` on the IClearing contract."""
68
-
69
- product_id: hexbytes.HexBytes
70
- protocol_id: eth_typing.ChecksumAddress
71
- trade_id: int
72
- price: int
73
- timestamp: int
74
- accounts: typing.List[eth_typing.ChecksumAddress]
75
- quantities: typing.List[int]
76
- fee_rates: typing.List[int]
77
- intents: typing.List[Intent]
14
+ from .types import Trade
78
15
 
79
16
 
80
17
  class ClearingFacet:
@@ -100,48 +37,24 @@ class ClearingFacet:
100
37
  )
101
38
 
102
39
  @property
103
- def TradeExecuted(self) -> contract.ContractEvent:
104
- """Binding for `event TradeExecuted` on the ClearingFacet contract."""
105
- return self._contract.events.TradeExecuted
106
-
107
- def max_trading_fee_rate(
108
- self,
109
- ) -> int:
110
- """Binding for `MAX_TRADING_FEE_RATE` on the ClearingFacet contract.
111
-
112
- Returns
113
- -------
114
- int
115
- """
116
- return_value = self._contract.functions.MAX_TRADING_FEE_RATE().call()
117
- return int(return_value)
118
-
119
- def clearing_fee_rate(
120
- self,
121
- ) -> int:
122
- """Binding for `clearingFeeRate` on the ClearingFacet contract.
40
+ def FeeCollected(self) -> contract.ContractEvent:
41
+ """Binding for `event FeeCollected` on the ClearingFacet contract."""
42
+ return self._contract.events.FeeCollected
123
43
 
124
- Returns
125
- -------
126
- int
127
- """
128
- return_value = self._contract.functions.clearingFeeRate().call()
129
- return int(return_value)
44
+ @property
45
+ def FeeDispersed(self) -> contract.ContractEvent:
46
+ """Binding for `event FeeDispersed` on the ClearingFacet contract."""
47
+ return self._contract.events.FeeDispersed
130
48
 
131
- def config(
132
- self,
133
- ) -> Config:
134
- """Binding for `config` on the ClearingFacet contract.
49
+ @property
50
+ def PositionUpdated(self) -> contract.ContractEvent:
51
+ """Binding for `event PositionUpdated` on the ClearingFacet contract."""
52
+ return self._contract.events.PositionUpdated
135
53
 
136
- Returns
137
- -------
138
- Config
139
- """
140
- return_value = self._contract.functions.config().call()
141
- return Config(
142
- AuctionConfig(int(return_value[0][0]), int(return_value[0][1])),
143
- ClearingConfig(int(return_value[1][0])),
144
- )
54
+ @property
55
+ def TradeExecuted(self) -> contract.ContractEvent:
56
+ """Binding for `event TradeExecuted` on the ClearingFacet contract."""
57
+ return self._contract.events.TradeExecuted
145
58
 
146
59
  def estimate_fees(
147
60
  self,
@@ -149,6 +62,7 @@ class ClearingFacet:
149
62
  price: int,
150
63
  quantity: int,
151
64
  trading_fee_rate: int,
65
+ block_identifier: types.BlockIdentifier = "latest",
152
66
  ) -> typing.Tuple[int, int]:
153
67
  """Binding for `estimateFees` on the ClearingFacet contract.
154
68
 
@@ -158,6 +72,8 @@ class ClearingFacet:
158
72
  price : int
159
73
  quantity : int
160
74
  trading_fee_rate : int
75
+ block_identifier : web3.types.BlockIdentifier
76
+ The block identifier, defaults to the latest block.
161
77
 
162
78
  Returns
163
79
  -------
@@ -169,7 +85,7 @@ class ClearingFacet:
169
85
  price,
170
86
  quantity,
171
87
  trading_fee_rate,
172
- ).call()
88
+ ).call(block_identifier=block_identifier)
173
89
  return (
174
90
  int(return_value[0]),
175
91
  int(return_value[1]),
@@ -199,6 +115,7 @@ class ClearingFacet:
199
115
  trade.trade_id,
200
116
  trade.price,
201
117
  trade.timestamp,
118
+ trade.quantity,
202
119
  trade.accounts,
203
120
  trade.quantities,
204
121
  trade.fee_rates,
@@ -216,6 +133,7 @@ class ClearingFacet:
216
133
  trade_item.data.max_trading_fee_rate,
217
134
  trade_item.data.good_until,
218
135
  int(trade_item.data.side),
136
+ trade_item.data.referral,
219
137
  ),
220
138
  trade_item.signature,
221
139
  )
@@ -225,818 +143,483 @@ class ClearingFacet:
225
143
  fallback_on_failure,
226
144
  )
227
145
 
228
- def finalize_initialization(
229
- self,
230
- margin_account_registry: eth_typing.ChecksumAddress,
231
- ) -> contract.ContractFunction:
232
- """Binding for `finalizeInitialization` on the ClearingFacet contract.
233
-
234
- Parameters
235
- ----------
236
- margin_account_registry : eth_typing.ChecksumAddress
237
-
238
- Returns
239
- -------
240
- web3.contract.contract.ContractFunction
241
- A contract function instance to be sent in a transaction.
242
- """
243
- return self._contract.functions.finalizeInitialization(
244
- margin_account_registry,
245
- )
246
-
247
- def get_admin(
248
- self,
249
- ) -> eth_typing.ChecksumAddress:
250
- """Binding for `getAdmin` on the ClearingFacet contract.
251
-
252
- Returns
253
- -------
254
- eth_typing.ChecksumAddress
255
- """
256
- return_value = self._contract.functions.getAdmin().call()
257
- return eth_typing.ChecksumAddress(return_value)
258
-
259
- def get_margin_account_registry(
260
- self,
261
- ) -> eth_typing.ChecksumAddress:
262
- """Binding for `getMarginAccountRegistry` on the ClearingFacet contract.
263
-
264
- Returns
265
- -------
266
- eth_typing.ChecksumAddress
267
- """
268
- return_value = self._contract.functions.getMarginAccountRegistry().call()
269
- return eth_typing.ChecksumAddress(return_value)
270
-
271
- def get_product_registry(
272
- self,
273
- ) -> eth_typing.ChecksumAddress:
274
- """Binding for `getProductRegistry` on the ClearingFacet contract.
275
-
276
- Returns
277
- -------
278
- eth_typing.ChecksumAddress
279
- """
280
- return_value = self._contract.functions.getProductRegistry().call()
281
- return eth_typing.ChecksumAddress(return_value)
282
-
283
- def get_treasury(
284
- self,
285
- ) -> eth_typing.ChecksumAddress:
286
- """Binding for `getTreasury` on the ClearingFacet contract.
287
-
288
- Returns
289
- -------
290
- eth_typing.ChecksumAddress
291
- """
292
- return_value = self._contract.functions.getTreasury().call()
293
- return eth_typing.ChecksumAddress(return_value)
294
-
295
- def hash_intent(
296
- self,
297
- intent: Intent,
298
- ) -> hexbytes.HexBytes:
299
- """Binding for `hashIntent` on the ClearingFacet contract.
300
-
301
- Parameters
302
- ----------
303
- intent : Intent
304
-
305
- Returns
306
- -------
307
- hexbytes.HexBytes
308
- """
309
- return_value = self._contract.functions.hashIntent(
310
- (
311
- intent.margin_account_id,
312
- intent.intent_account_id,
313
- intent.hash,
314
- (
315
- intent.data.nonce,
316
- intent.data.trading_protocol_id,
317
- intent.data.product_id,
318
- intent.data.limit_price,
319
- intent.data.quantity,
320
- intent.data.max_trading_fee_rate,
321
- intent.data.good_until,
322
- int(intent.data.side),
323
- ),
324
- intent.signature,
325
- ),
326
- ).call()
327
- return hexbytes.HexBytes(return_value)
328
-
329
- def initialize(
330
- self,
331
- _product_registry: eth_typing.ChecksumAddress,
332
- _treasury: eth_typing.ChecksumAddress,
333
- ) -> contract.ContractFunction:
334
- """Binding for `initialize` on the ClearingFacet contract.
335
-
336
- Parameters
337
- ----------
338
- _product_registry : eth_typing.ChecksumAddress
339
- _treasury : eth_typing.ChecksumAddress
340
-
341
- Returns
342
- -------
343
- web3.contract.contract.ContractFunction
344
- A contract function instance to be sent in a transaction.
345
- """
346
- return self._contract.functions.initialize(
347
- _product_registry,
348
- _treasury,
349
- )
350
-
351
- def is_admin_active(
352
- self,
353
- ) -> bool:
354
- """Binding for `isAdminActive` on the ClearingFacet contract.
355
-
356
- Returns
357
- -------
358
- bool
359
- """
360
- return_value = self._contract.functions.isAdminActive().call()
361
- return bool(return_value)
362
-
363
- def set_active(
364
- self,
365
- active: bool,
366
- ) -> contract.ContractFunction:
367
- """Binding for `setActive` on the ClearingFacet contract.
368
-
369
- Parameters
370
- ----------
371
- active : bool
372
-
373
- Returns
374
- -------
375
- web3.contract.contract.ContractFunction
376
- A contract function instance to be sent in a transaction.
377
- """
378
- return self._contract.functions.setActive(
379
- active,
380
- )
381
-
382
- def set_admin(
383
- self,
384
- new_admin: eth_typing.ChecksumAddress,
385
- ) -> contract.ContractFunction:
386
- """Binding for `setAdmin` on the ClearingFacet contract.
387
-
388
- Parameters
389
- ----------
390
- new_admin : eth_typing.ChecksumAddress
391
-
392
- Returns
393
- -------
394
- web3.contract.contract.ContractFunction
395
- A contract function instance to be sent in a transaction.
396
- """
397
- return self._contract.functions.setAdmin(
398
- new_admin,
399
- )
400
-
401
- def set_config(
402
- self,
403
- _config: Config,
404
- ) -> contract.ContractFunction:
405
- """Binding for `setConfig` on the ClearingFacet contract.
406
-
407
- Parameters
408
- ----------
409
- _config : Config
410
-
411
- Returns
412
- -------
413
- web3.contract.contract.ContractFunction
414
- A contract function instance to be sent in a transaction.
415
- """
416
- return self._contract.functions.setConfig(
417
- (
418
- (
419
- _config.auction_config.restoration_buffer,
420
- _config.auction_config.liquidation_duration,
421
- ),
422
- (_config.clearing_config.clearing_fee_rate),
423
- ),
424
- )
425
-
426
- def set_treasury(
427
- self,
428
- new_treasury: eth_typing.ChecksumAddress,
429
- ) -> contract.ContractFunction:
430
- """Binding for `setTreasury` on the ClearingFacet contract.
431
-
432
- Parameters
433
- ----------
434
- new_treasury : eth_typing.ChecksumAddress
435
-
436
- Returns
437
- -------
438
- web3.contract.contract.ContractFunction
439
- A contract function instance to be sent in a transaction.
440
- """
441
- return self._contract.functions.setTreasury(
442
- new_treasury,
443
- )
444
-
445
- def version(
446
- self,
447
- ) -> str:
448
- """Binding for `version` on the ClearingFacet contract.
449
-
450
- Returns
451
- -------
452
- str
453
- """
454
- return_value = self._contract.functions.version().call()
455
- return str(return_value)
456
-
457
146
 
458
147
  ABI = typing.cast(
459
148
  eth_typing.ABI,
460
149
  [
461
150
  {
151
+ "type": "function",
152
+ "name": "estimateFees",
462
153
  "inputs": [
463
- {"internalType": "bytes4", "name": "selector", "type": "bytes4"},
464
- {"internalType": "address", "name": "sender", "type": "address"},
465
- ],
466
- "name": "AdminControlledNotAuthorized",
467
- "type": "error",
468
- },
469
- {"inputs": [], "name": "AlreadyInitialized", "type": "error"},
470
- {
471
- "inputs": [
472
- {"internalType": "address", "name": "marginAccount", "type": "address"}
473
- ],
474
- "name": "DuplicateMarginAccount",
475
- "type": "error",
476
- },
477
- {"inputs": [], "name": "ECDSAInvalidSignature", "type": "error"},
478
- {
479
- "inputs": [
480
- {"internalType": "uint256", "name": "length", "type": "uint256"}
481
- ],
482
- "name": "ECDSAInvalidSignatureLength",
483
- "type": "error",
484
- },
485
- {
486
- "inputs": [{"internalType": "bytes32", "name": "s", "type": "bytes32"}],
487
- "name": "ECDSAInvalidSignatureS",
488
- "type": "error",
489
- },
490
- {
491
- "inputs": [
492
- {"internalType": "address", "name": "intentAccount", "type": "address"}
493
- ],
494
- "name": "IntentFullySpent",
495
- "type": "error",
496
- },
497
- {
498
- "inputs": [{"internalType": "int256", "name": "feeSum", "type": "int256"}],
499
- "name": "InvalidFeeSum",
500
- "type": "error",
501
- },
502
- {
503
- "inputs": [
504
- {"internalType": "string", "name": "parameter", "type": "string"}
505
- ],
506
- "name": "InvalidIntent",
507
- "type": "error",
508
- },
509
- {
510
- "inputs": [
511
- {"internalType": "string", "name": "paramName", "type": "string"}
154
+ {"name": "productID", "type": "bytes32", "internalType": "bytes32"},
155
+ {"name": "price", "type": "int256", "internalType": "int256"},
156
+ {"name": "quantity", "type": "uint256", "internalType": "uint256"},
157
+ {"name": "tradingFeeRate", "type": "int256", "internalType": "int256"},
512
158
  ],
513
- "name": "InvalidParameter",
514
- "type": "error",
515
- },
516
- {
517
- "inputs": [
518
- {"internalType": "enum ProductState", "name": "state", "type": "uint8"}
159
+ "outputs": [
160
+ {"name": "", "type": "uint256", "internalType": "uint256"},
161
+ {"name": "", "type": "int256", "internalType": "int256"},
519
162
  ],
520
- "name": "InvalidProductState",
521
- "type": "error",
163
+ "stateMutability": "view",
522
164
  },
523
165
  {
166
+ "type": "function",
167
+ "name": "execute",
524
168
  "inputs": [
525
- {"internalType": "address", "name": "signer", "type": "address"},
526
169
  {
527
- "internalType": "address",
528
- "name": "expectedSigner",
529
- "type": "address",
530
- },
531
- ],
532
- "name": "InvalidSignature",
533
- "type": "error",
534
- },
535
- {
536
- "inputs": [
537
- {"internalType": "uint256", "name": "length", "type": "uint256"}
538
- ],
539
- "name": "InvalidTradeIntents",
540
- "type": "error",
541
- },
542
- {
543
- "inputs": [
544
- {"internalType": "address", "name": "marginAccount", "type": "address"}
545
- ],
546
- "name": "MAECheckFailed",
547
- "type": "error",
548
- },
549
- {
550
- "inputs": [
551
- {"internalType": "int256", "name": "feeRate", "type": "int256"},
552
- {"internalType": "uint256", "name": "maxFeeRate", "type": "uint256"},
553
- ],
554
- "name": "MaxFeeRateExceeded",
555
- "type": "error",
556
- },
557
- {
558
- "inputs": [
559
- {"internalType": "uint256", "name": "buySide", "type": "uint256"},
560
- {"internalType": "uint256", "name": "sellSide", "type": "uint256"},
561
- ],
562
- "name": "MismatchedTrade",
563
- "type": "error",
564
- },
565
- {"inputs": [], "name": "QueueIsEmpty", "type": "error"},
566
- {
567
- "inputs": [
568
- {"internalType": "address", "name": "account", "type": "address"}
569
- ],
570
- "name": "Unauthorized",
571
- "type": "error",
572
- },
573
- {
574
- "inputs": [
575
- {"internalType": "address", "name": "needed", "type": "address"},
576
- {"internalType": "address", "name": "got", "type": "address"},
577
- ],
578
- "name": "UnauthorizedTradeSubmitter",
579
- "type": "error",
580
- },
581
- {
582
- "anonymous": False,
583
- "inputs": [
584
- {
585
- "indexed": True,
586
- "internalType": "bytes32",
587
- "name": "productID",
588
- "type": "bytes32",
589
- },
590
- {
591
- "indexed": True,
592
- "internalType": "address",
593
- "name": "protocolID",
594
- "type": "address",
595
- },
596
- {
597
- "indexed": True,
598
- "internalType": "address",
599
- "name": "marginAccount",
600
- "type": "address",
601
- },
602
- {
603
- "indexed": False,
604
- "internalType": "uint256",
605
- "name": "price",
606
- "type": "uint256",
607
- },
608
- {
609
- "indexed": False,
610
- "internalType": "uint256",
611
- "name": "quantity",
612
- "type": "uint256",
613
- },
614
- ],
615
- "name": "TradeExecuted",
616
- "type": "event",
617
- },
618
- {
619
- "inputs": [],
620
- "name": "MAX_TRADING_FEE_RATE",
621
- "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
622
- "stateMutability": "pure",
623
- "type": "function",
624
- },
625
- {
626
- "inputs": [],
627
- "name": "clearingFeeRate",
628
- "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
629
- "stateMutability": "view",
630
- "type": "function",
631
- },
632
- {
633
- "inputs": [],
634
- "name": "config",
635
- "outputs": [
636
- {
637
- "components": [
638
- {
639
- "components": [
640
- {
641
- "internalType": "uint64",
642
- "name": "restorationBuffer",
643
- "type": "uint64",
644
- },
645
- {
646
- "internalType": "uint256",
647
- "name": "liquidationDuration",
648
- "type": "uint256",
649
- },
650
- ],
651
- "internalType": "struct IAuctioneer.AuctionConfig",
652
- "name": "auctionConfig",
653
- "type": "tuple",
654
- },
655
- {
656
- "components": [
657
- {
658
- "internalType": "uint32",
659
- "name": "clearingFeeRate",
660
- "type": "uint32",
661
- }
662
- ],
663
- "internalType": "struct IClearing.ClearingConfig",
664
- "name": "clearingConfig",
665
- "type": "tuple",
666
- },
667
- ],
668
- "internalType": "struct IClearing.Config",
669
- "name": "",
170
+ "name": "trade",
670
171
  "type": "tuple",
671
- }
672
- ],
673
- "stateMutability": "view",
674
- "type": "function",
675
- },
676
- {
677
- "inputs": [
678
- {"internalType": "bytes32", "name": "productID", "type": "bytes32"},
679
- {"internalType": "uint256", "name": "price", "type": "uint256"},
680
- {"internalType": "uint256", "name": "quantity", "type": "uint256"},
681
- {"internalType": "int256", "name": "tradingFeeRate", "type": "int256"},
682
- ],
683
- "name": "estimateFees",
684
- "outputs": [
685
- {"internalType": "uint256", "name": "clearingFee", "type": "uint256"},
686
- {"internalType": "int256", "name": "tradingFee", "type": "int256"},
687
- ],
688
- "stateMutability": "view",
689
- "type": "function",
690
- },
691
- {
692
- "inputs": [
693
- {
172
+ "internalType": "struct Trade",
694
173
  "components": [
695
174
  {
696
- "internalType": "bytes32",
697
- "name": "productID",
175
+ "name": "productId",
698
176
  "type": "bytes32",
177
+ "internalType": "bytes32",
699
178
  },
700
179
  {
701
- "internalType": "address",
702
- "name": "protocolID",
180
+ "name": "protocolId",
703
181
  "type": "address",
182
+ "internalType": "address",
704
183
  },
705
184
  {
706
- "internalType": "uint256",
707
- "name": "tradeID",
185
+ "name": "tradeId",
708
186
  "type": "uint256",
187
+ "internalType": "uint256",
709
188
  },
710
- {"internalType": "uint256", "name": "price", "type": "uint256"},
189
+ {"name": "price", "type": "int256", "internalType": "int256"},
711
190
  {
712
- "internalType": "uint256",
713
191
  "name": "timestamp",
714
192
  "type": "uint256",
193
+ "internalType": "uint256",
194
+ },
195
+ {
196
+ "name": "quantity",
197
+ "type": "uint256",
198
+ "internalType": "uint256",
715
199
  },
716
200
  {
717
- "internalType": "address[]",
718
201
  "name": "accounts",
719
202
  "type": "address[]",
203
+ "internalType": "address[]",
720
204
  },
721
205
  {
722
- "internalType": "uint256[]",
723
206
  "name": "quantities",
724
207
  "type": "uint256[]",
208
+ "internalType": "uint256[]",
725
209
  },
726
210
  {
727
- "internalType": "int256[]",
728
211
  "name": "feeRates",
729
- "type": "int256[]",
212
+ "type": "int32[]",
213
+ "internalType": "int32[]",
730
214
  },
731
215
  {
216
+ "name": "intents",
217
+ "type": "tuple[]",
218
+ "internalType": "struct Intent[]",
732
219
  "components": [
733
220
  {
734
- "internalType": "address",
735
- "name": "marginAccountID",
221
+ "name": "marginAccountId",
736
222
  "type": "address",
223
+ "internalType": "address",
737
224
  },
738
225
  {
739
- "internalType": "address",
740
- "name": "intentAccountID",
226
+ "name": "intentAccountId",
741
227
  "type": "address",
228
+ "internalType": "address",
742
229
  },
743
230
  {
744
- "internalType": "bytes32",
745
231
  "name": "hash",
746
232
  "type": "bytes32",
233
+ "internalType": "bytes32",
747
234
  },
748
235
  {
236
+ "name": "data",
237
+ "type": "tuple",
238
+ "internalType": "struct IntentData",
749
239
  "components": [
750
240
  {
751
- "internalType": "uint256",
752
241
  "name": "nonce",
753
242
  "type": "uint256",
243
+ "internalType": "uint256",
754
244
  },
755
245
  {
756
- "internalType": "address",
757
- "name": "tradingProtocolID",
246
+ "name": "tradingProtocolId",
758
247
  "type": "address",
248
+ "internalType": "address",
759
249
  },
760
250
  {
761
- "internalType": "bytes32",
762
- "name": "productID",
251
+ "name": "productId",
763
252
  "type": "bytes32",
253
+ "internalType": "bytes32",
764
254
  },
765
255
  {
766
- "internalType": "uint256",
767
256
  "name": "limitPrice",
768
- "type": "uint256",
257
+ "type": "int256",
258
+ "internalType": "int256",
769
259
  },
770
260
  {
771
- "internalType": "uint256",
772
261
  "name": "quantity",
773
262
  "type": "uint256",
263
+ "internalType": "uint256",
774
264
  },
775
265
  {
776
- "internalType": "uint256",
777
266
  "name": "maxTradingFeeRate",
778
- "type": "uint256",
267
+ "type": "uint32",
268
+ "internalType": "uint32",
779
269
  },
780
270
  {
781
- "internalType": "uint256",
782
271
  "name": "goodUntil",
783
272
  "type": "uint256",
273
+ "internalType": "uint256",
784
274
  },
785
275
  {
786
- "internalType": "enum Side",
787
276
  "name": "side",
788
277
  "type": "uint8",
278
+ "internalType": "enum Side",
279
+ },
280
+ {
281
+ "name": "referral",
282
+ "type": "address",
283
+ "internalType": "address",
789
284
  },
790
285
  ],
791
- "internalType": "struct IClearing.IntentData",
792
- "name": "data",
793
- "type": "tuple",
794
286
  },
795
287
  {
796
- "internalType": "bytes",
797
288
  "name": "signature",
798
289
  "type": "bytes",
290
+ "internalType": "bytes",
799
291
  },
800
292
  ],
801
- "internalType": "struct IClearing.Intent[]",
802
- "name": "intents",
803
- "type": "tuple[]",
804
293
  },
805
294
  ],
806
- "internalType": "struct IClearing.Trade",
807
- "name": "trade",
808
- "type": "tuple",
809
295
  },
810
- {"internalType": "bool", "name": "fallbackOnFailure", "type": "bool"},
296
+ {"name": "fallbackOnFailure", "type": "bool", "internalType": "bool"},
811
297
  ],
812
- "name": "execute",
813
298
  "outputs": [],
814
299
  "stateMutability": "nonpayable",
815
- "type": "function",
816
300
  },
817
301
  {
302
+ "type": "event",
303
+ "name": "FeeCollected",
818
304
  "inputs": [
819
305
  {
306
+ "name": "marginAccountId",
307
+ "type": "address",
308
+ "indexed": True,
820
309
  "internalType": "address",
821
- "name": "marginAccountRegistry",
310
+ },
311
+ {
312
+ "name": "collateralAsset",
822
313
  "type": "address",
823
- }
314
+ "indexed": True,
315
+ "internalType": "address",
316
+ },
317
+ {
318
+ "name": "capitalAmount",
319
+ "type": "int256",
320
+ "indexed": False,
321
+ "internalType": "int256",
322
+ },
323
+ {
324
+ "name": "id",
325
+ "type": "uint256",
326
+ "indexed": False,
327
+ "internalType": "uint256",
328
+ },
824
329
  ],
825
- "name": "finalizeInitialization",
826
- "outputs": [],
827
- "stateMutability": "nonpayable",
828
- "type": "function",
330
+ "anonymous": False,
829
331
  },
830
332
  {
831
- "inputs": [],
832
- "name": "getAdmin",
833
- "outputs": [{"internalType": "address", "name": "", "type": "address"}],
834
- "stateMutability": "view",
835
- "type": "function",
333
+ "type": "event",
334
+ "name": "FeeDispersed",
335
+ "inputs": [
336
+ {
337
+ "name": "recipient",
338
+ "type": "address",
339
+ "indexed": True,
340
+ "internalType": "address",
341
+ },
342
+ {
343
+ "name": "collateralAsset",
344
+ "type": "address",
345
+ "indexed": True,
346
+ "internalType": "address",
347
+ },
348
+ {
349
+ "name": "capitalAmount",
350
+ "type": "int256",
351
+ "indexed": False,
352
+ "internalType": "int256",
353
+ },
354
+ {
355
+ "name": "id",
356
+ "type": "uint256",
357
+ "indexed": False,
358
+ "internalType": "uint256",
359
+ },
360
+ ],
361
+ "anonymous": False,
836
362
  },
837
363
  {
838
- "inputs": [],
839
- "name": "getMarginAccountRegistry",
840
- "outputs": [
364
+ "type": "event",
365
+ "name": "PositionUpdated",
366
+ "inputs": [
841
367
  {
842
- "internalType": "contract IMarginAccountRegistry",
843
- "name": "",
368
+ "name": "marginAccountId",
844
369
  "type": "address",
845
- }
370
+ "indexed": True,
371
+ "internalType": "address",
372
+ },
373
+ {
374
+ "name": "productId",
375
+ "type": "bytes32",
376
+ "indexed": True,
377
+ "internalType": "bytes32",
378
+ },
379
+ {
380
+ "name": "costBasis",
381
+ "type": "int256",
382
+ "indexed": False,
383
+ "internalType": "int256",
384
+ },
385
+ {
386
+ "name": "price",
387
+ "type": "int256",
388
+ "indexed": False,
389
+ "internalType": "int256",
390
+ },
391
+ {
392
+ "name": "quantity",
393
+ "type": "int256",
394
+ "indexed": False,
395
+ "internalType": "int256",
396
+ },
397
+ {
398
+ "name": "id",
399
+ "type": "uint256",
400
+ "indexed": False,
401
+ "internalType": "uint256",
402
+ },
846
403
  ],
847
- "stateMutability": "view",
848
- "type": "function",
404
+ "anonymous": False,
849
405
  },
850
406
  {
851
- "inputs": [],
852
- "name": "getProductRegistry",
853
- "outputs": [
407
+ "type": "event",
408
+ "name": "TradeExecuted",
409
+ "inputs": [
410
+ {
411
+ "name": "productId",
412
+ "type": "bytes32",
413
+ "indexed": True,
414
+ "internalType": "bytes32",
415
+ },
854
416
  {
855
- "internalType": "contract IProductRegistry",
856
- "name": "",
417
+ "name": "protocolId",
857
418
  "type": "address",
858
- }
419
+ "indexed": True,
420
+ "internalType": "address",
421
+ },
422
+ {
423
+ "name": "id",
424
+ "type": "uint256",
425
+ "indexed": False,
426
+ "internalType": "uint256",
427
+ },
428
+ {
429
+ "name": "price",
430
+ "type": "int256",
431
+ "indexed": False,
432
+ "internalType": "int256",
433
+ },
434
+ {
435
+ "name": "quantity",
436
+ "type": "uint256",
437
+ "indexed": False,
438
+ "internalType": "uint256",
439
+ },
859
440
  ],
860
- "stateMutability": "view",
861
- "type": "function",
441
+ "anonymous": False,
862
442
  },
863
443
  {
864
- "inputs": [],
865
- "name": "getTreasury",
866
- "outputs": [{"internalType": "address", "name": "", "type": "address"}],
867
- "stateMutability": "view",
868
- "type": "function",
444
+ "type": "error",
445
+ "name": "DuplicateMarginAccount",
446
+ "inputs": [
447
+ {"name": "marginAccount", "type": "address", "internalType": "address"}
448
+ ],
449
+ },
450
+ {"type": "error", "name": "ECDSAInvalidSignature", "inputs": []},
451
+ {
452
+ "type": "error",
453
+ "name": "ECDSAInvalidSignatureLength",
454
+ "inputs": [
455
+ {"name": "length", "type": "uint256", "internalType": "uint256"}
456
+ ],
869
457
  },
870
458
  {
459
+ "type": "error",
460
+ "name": "ECDSAInvalidSignatureS",
461
+ "inputs": [{"name": "s", "type": "bytes32", "internalType": "bytes32"}],
462
+ },
463
+ {
464
+ "type": "error",
465
+ "name": "IntentFullySpent",
466
+ "inputs": [
467
+ {"name": "intentAccount", "type": "address", "internalType": "address"}
468
+ ],
469
+ },
470
+ {
471
+ "type": "error",
472
+ "name": "InvalidFeeSum",
473
+ "inputs": [{"name": "feeSum", "type": "int256", "internalType": "int256"}],
474
+ },
475
+ {
476
+ "type": "error",
477
+ "name": "InvalidFieldAccess",
871
478
  "inputs": [
872
479
  {
873
- "components": [
874
- {
875
- "internalType": "address",
876
- "name": "marginAccountID",
877
- "type": "address",
878
- },
879
- {
880
- "internalType": "address",
881
- "name": "intentAccountID",
882
- "type": "address",
883
- },
884
- {"internalType": "bytes32", "name": "hash", "type": "bytes32"},
885
- {
886
- "components": [
887
- {
888
- "internalType": "uint256",
889
- "name": "nonce",
890
- "type": "uint256",
891
- },
892
- {
893
- "internalType": "address",
894
- "name": "tradingProtocolID",
895
- "type": "address",
896
- },
897
- {
898
- "internalType": "bytes32",
899
- "name": "productID",
900
- "type": "bytes32",
901
- },
902
- {
903
- "internalType": "uint256",
904
- "name": "limitPrice",
905
- "type": "uint256",
906
- },
907
- {
908
- "internalType": "uint256",
909
- "name": "quantity",
910
- "type": "uint256",
911
- },
912
- {
913
- "internalType": "uint256",
914
- "name": "maxTradingFeeRate",
915
- "type": "uint256",
916
- },
917
- {
918
- "internalType": "uint256",
919
- "name": "goodUntil",
920
- "type": "uint256",
921
- },
922
- {
923
- "internalType": "enum Side",
924
- "name": "side",
925
- "type": "uint8",
926
- },
927
- ],
928
- "internalType": "struct IClearing.IntentData",
929
- "name": "data",
930
- "type": "tuple",
931
- },
932
- {"internalType": "bytes", "name": "signature", "type": "bytes"},
933
- ],
934
- "internalType": "struct IClearing.Intent",
935
- "name": "intent",
936
- "type": "tuple",
937
- }
480
+ "name": "productType",
481
+ "type": "uint8",
482
+ "internalType": "enum ProductType",
483
+ },
484
+ {"name": "field", "type": "string", "internalType": "string"},
938
485
  ],
939
- "name": "hashIntent",
940
- "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}],
941
- "stateMutability": "pure",
942
- "type": "function",
943
486
  },
944
487
  {
488
+ "type": "error",
489
+ "name": "InvalidIntent",
945
490
  "inputs": [
491
+ {"name": "parameter", "type": "string", "internalType": "string"}
492
+ ],
493
+ },
494
+ {
495
+ "type": "error",
496
+ "name": "InvalidParameter",
497
+ "inputs": [
498
+ {"name": "paramName", "type": "string", "internalType": "string"}
499
+ ],
500
+ },
501
+ {
502
+ "type": "error",
503
+ "name": "InvalidProductState",
504
+ "inputs": [
505
+ {"name": "state", "type": "uint8", "internalType": "enum ProductState"}
506
+ ],
507
+ },
508
+ {
509
+ "type": "error",
510
+ "name": "InvalidSignature",
511
+ "inputs": [
512
+ {"name": "signer", "type": "address", "internalType": "address"},
946
513
  {
947
- "internalType": "address",
948
- "name": "_productRegistry",
514
+ "name": "expectedSigner",
949
515
  "type": "address",
516
+ "internalType": "address",
950
517
  },
951
- {"internalType": "address", "name": "_treasury", "type": "address"},
952
518
  ],
953
- "name": "initialize",
954
- "outputs": [],
955
- "stateMutability": "nonpayable",
956
- "type": "function",
957
519
  },
958
520
  {
959
- "inputs": [],
960
- "name": "isAdminActive",
961
- "outputs": [{"internalType": "bool", "name": "", "type": "bool"}],
962
- "stateMutability": "view",
963
- "type": "function",
521
+ "type": "error",
522
+ "name": "InvalidTradeIntents",
523
+ "inputs": [
524
+ {"name": "length", "type": "uint256", "internalType": "uint256"}
525
+ ],
964
526
  },
965
527
  {
966
- "inputs": [{"internalType": "bool", "name": "active", "type": "bool"}],
967
- "name": "setActive",
968
- "outputs": [],
969
- "stateMutability": "nonpayable",
970
- "type": "function",
528
+ "type": "error",
529
+ "name": "InvalidTradePrice",
530
+ "inputs": [{"name": "price", "type": "int256", "internalType": "int256"}],
971
531
  },
972
532
  {
533
+ "type": "error",
534
+ "name": "MAECheckFailed",
973
535
  "inputs": [
974
- {"internalType": "address", "name": "newAdmin", "type": "address"}
536
+ {"name": "marginAccount", "type": "address", "internalType": "address"}
975
537
  ],
976
- "name": "setAdmin",
977
- "outputs": [],
978
- "stateMutability": "nonpayable",
979
- "type": "function",
980
538
  },
981
539
  {
540
+ "type": "error",
541
+ "name": "MismatchedTrade",
982
542
  "inputs": [
983
- {
984
- "components": [
985
- {
986
- "components": [
987
- {
988
- "internalType": "uint64",
989
- "name": "restorationBuffer",
990
- "type": "uint64",
991
- },
992
- {
993
- "internalType": "uint256",
994
- "name": "liquidationDuration",
995
- "type": "uint256",
996
- },
997
- ],
998
- "internalType": "struct IAuctioneer.AuctionConfig",
999
- "name": "auctionConfig",
1000
- "type": "tuple",
1001
- },
1002
- {
1003
- "components": [
1004
- {
1005
- "internalType": "uint32",
1006
- "name": "clearingFeeRate",
1007
- "type": "uint32",
1008
- }
1009
- ],
1010
- "internalType": "struct IClearing.ClearingConfig",
1011
- "name": "clearingConfig",
1012
- "type": "tuple",
1013
- },
1014
- ],
1015
- "internalType": "struct IClearing.Config",
1016
- "name": "_config",
1017
- "type": "tuple",
1018
- }
543
+ {"name": "buySide", "type": "uint256", "internalType": "uint256"},
544
+ {"name": "sellSide", "type": "uint256", "internalType": "uint256"},
1019
545
  ],
1020
- "name": "setConfig",
1021
- "outputs": [],
1022
- "stateMutability": "nonpayable",
1023
- "type": "function",
1024
546
  },
1025
547
  {
548
+ "type": "error",
549
+ "name": "NotFound",
1026
550
  "inputs": [
1027
- {"internalType": "address", "name": "newTreasury", "type": "address"}
551
+ {"name": "parameter", "type": "string", "internalType": "string"}
1028
552
  ],
1029
- "name": "setTreasury",
1030
- "outputs": [],
1031
- "stateMutability": "nonpayable",
1032
- "type": "function",
1033
553
  },
1034
554
  {
1035
- "inputs": [],
1036
- "name": "version",
1037
- "outputs": [{"internalType": "string", "name": "", "type": "string"}],
1038
- "stateMutability": "pure",
1039
- "type": "function",
555
+ "type": "error",
556
+ "name": "NotImplemented",
557
+ "inputs": [{"name": "feature", "type": "string", "internalType": "string"}],
558
+ },
559
+ {
560
+ "type": "error",
561
+ "name": "PRBMath_MulDiv18_Overflow",
562
+ "inputs": [
563
+ {"name": "x", "type": "uint256", "internalType": "uint256"},
564
+ {"name": "y", "type": "uint256", "internalType": "uint256"},
565
+ ],
566
+ },
567
+ {
568
+ "type": "error",
569
+ "name": "PRBMath_MulDiv_Overflow",
570
+ "inputs": [
571
+ {"name": "x", "type": "uint256", "internalType": "uint256"},
572
+ {"name": "y", "type": "uint256", "internalType": "uint256"},
573
+ {"name": "denominator", "type": "uint256", "internalType": "uint256"},
574
+ ],
575
+ },
576
+ {"type": "error", "name": "PRBMath_SD59x18_Div_InputTooSmall", "inputs": []},
577
+ {
578
+ "type": "error",
579
+ "name": "PRBMath_SD59x18_Div_Overflow",
580
+ "inputs": [
581
+ {"name": "x", "type": "int256", "internalType": "SD59x18"},
582
+ {"name": "y", "type": "int256", "internalType": "SD59x18"},
583
+ ],
584
+ },
585
+ {
586
+ "type": "error",
587
+ "name": "PRBMath_SD59x18_Exp2_InputTooBig",
588
+ "inputs": [{"name": "x", "type": "int256", "internalType": "SD59x18"}],
589
+ },
590
+ {
591
+ "type": "error",
592
+ "name": "PRBMath_SD59x18_Exp_InputTooBig",
593
+ "inputs": [{"name": "x", "type": "int256", "internalType": "SD59x18"}],
594
+ },
595
+ {"type": "error", "name": "PRBMath_SD59x18_Mul_InputTooSmall", "inputs": []},
596
+ {
597
+ "type": "error",
598
+ "name": "PRBMath_SD59x18_Mul_Overflow",
599
+ "inputs": [
600
+ {"name": "x", "type": "int256", "internalType": "SD59x18"},
601
+ {"name": "y", "type": "int256", "internalType": "SD59x18"},
602
+ ],
603
+ },
604
+ {
605
+ "type": "error",
606
+ "name": "SafeCastOverflowedUintToInt",
607
+ "inputs": [{"name": "value", "type": "uint256", "internalType": "uint256"}],
608
+ },
609
+ {
610
+ "type": "error",
611
+ "name": "Unauthorized",
612
+ "inputs": [
613
+ {"name": "account", "type": "address", "internalType": "address"}
614
+ ],
615
+ },
616
+ {
617
+ "type": "error",
618
+ "name": "UnauthorizedTradeSubmitter",
619
+ "inputs": [
620
+ {"name": "needed", "type": "address", "internalType": "address"},
621
+ {"name": "got", "type": "address", "internalType": "address"},
622
+ ],
1040
623
  },
1041
624
  ],
1042
625
  )