afp-sdk 0.1.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.
@@ -0,0 +1,758 @@
1
+ """AuctioneerFacet contract binding and data structures."""
2
+
3
+ # This module has been generated using pyabigen v0.2.16
4
+
5
+ import enum
6
+ import typing
7
+ from dataclasses import dataclass
8
+
9
+ import eth_typing
10
+ import hexbytes
11
+ import web3
12
+ from web3.contract import contract
13
+
14
+
15
+ class Side(enum.IntEnum):
16
+ """Port of `enum Side` on the AuctioneerFacet contract."""
17
+
18
+ BID = 0
19
+ ASK = 1
20
+
21
+
22
+ @dataclass
23
+ class AuctionConfig:
24
+ """Port of `struct AuctionConfig` on the IAuctioneer contract."""
25
+
26
+ restoration_buffer: int
27
+ liquidation_duration: int
28
+
29
+
30
+ @dataclass
31
+ class AuctionData:
32
+ """Port of `struct AuctionData` on the IAuctioneer contract."""
33
+
34
+ start_block: int
35
+ mae_at_initiation: int
36
+ mmu_at_initiation: int
37
+ mae_now: int
38
+ mmu_now: int
39
+
40
+
41
+ @dataclass
42
+ class BidData:
43
+ """Port of `struct BidData` on the IAuctioneer contract."""
44
+
45
+ product_id: hexbytes.HexBytes
46
+ price: int
47
+ quantity: int
48
+ side: Side
49
+
50
+
51
+ class AuctioneerFacet:
52
+ """AuctioneerFacet contract binding.
53
+
54
+ Parameters
55
+ ----------
56
+ w3 : web3.Web3
57
+ address : eth_typing.ChecksumAddress
58
+ The address of a deployed AuctioneerFacet contract.
59
+ """
60
+
61
+ _contract: contract.Contract
62
+
63
+ def __init__(
64
+ self,
65
+ w3: web3.Web3,
66
+ address: eth_typing.ChecksumAddress,
67
+ ):
68
+ self._contract = w3.eth.contract(
69
+ address=address,
70
+ abi=ABI,
71
+ )
72
+
73
+ @property
74
+ def Auctioned(self) -> contract.ContractEvent:
75
+ """Binding for `event Auctioned` on the AuctioneerFacet contract."""
76
+ return self._contract.events.Auctioned
77
+
78
+ @property
79
+ def LiquidationStarted(self) -> contract.ContractEvent:
80
+ """Binding for `event LiquidationStarted` on the AuctioneerFacet contract."""
81
+ return self._contract.events.LiquidationStarted
82
+
83
+ @property
84
+ def LiquidationTerminated(self) -> contract.ContractEvent:
85
+ """Binding for `event LiquidationTerminated` on the AuctioneerFacet contract."""
86
+ return self._contract.events.LiquidationTerminated
87
+
88
+ def auction_config(
89
+ self,
90
+ ) -> AuctionConfig:
91
+ """Binding for `auctionConfig` on the AuctioneerFacet contract.
92
+
93
+ Returns
94
+ -------
95
+ AuctionConfig
96
+ """
97
+ return_value = self._contract.functions.auctionConfig().call()
98
+ return AuctionConfig(int(return_value[0]), int(return_value[1]))
99
+
100
+ def auction_data(
101
+ self,
102
+ margin_account_id: eth_typing.ChecksumAddress,
103
+ collateral: eth_typing.ChecksumAddress,
104
+ ) -> AuctionData:
105
+ """Binding for `auctionData` on the AuctioneerFacet contract.
106
+
107
+ Parameters
108
+ ----------
109
+ margin_account_id : eth_typing.ChecksumAddress
110
+ collateral : eth_typing.ChecksumAddress
111
+
112
+ Returns
113
+ -------
114
+ AuctionData
115
+ """
116
+ return_value = self._contract.functions.auctionData(
117
+ margin_account_id,
118
+ collateral,
119
+ ).call()
120
+ return AuctionData(
121
+ int(return_value[0]),
122
+ int(return_value[1]),
123
+ int(return_value[2]),
124
+ int(return_value[3]),
125
+ int(return_value[4]),
126
+ )
127
+
128
+ def bid_auction(
129
+ self,
130
+ margin_account_id: eth_typing.ChecksumAddress,
131
+ collateral_token: eth_typing.ChecksumAddress,
132
+ bids: typing.List[BidData],
133
+ ) -> contract.ContractFunction:
134
+ """Binding for `bidAuction` on the AuctioneerFacet contract.
135
+
136
+ Parameters
137
+ ----------
138
+ margin_account_id : eth_typing.ChecksumAddress
139
+ collateral_token : eth_typing.ChecksumAddress
140
+ bids : typing.List[BidData]
141
+
142
+ Returns
143
+ -------
144
+ web3.contract.contract.ContractFunction
145
+ A contract function instance to be sent in a transaction.
146
+ """
147
+ return self._contract.functions.bidAuction(
148
+ margin_account_id,
149
+ collateral_token,
150
+ [
151
+ (item.product_id, item.price, item.quantity, int(item.side))
152
+ for item in bids
153
+ ],
154
+ )
155
+
156
+ def can_terminate_auctions(
157
+ self,
158
+ margin_account_id: eth_typing.ChecksumAddress,
159
+ collateral: eth_typing.ChecksumAddress,
160
+ ) -> bool:
161
+ """Binding for `canTerminateAuctions` on the AuctioneerFacet contract.
162
+
163
+ Parameters
164
+ ----------
165
+ margin_account_id : eth_typing.ChecksumAddress
166
+ collateral : eth_typing.ChecksumAddress
167
+
168
+ Returns
169
+ -------
170
+ bool
171
+ """
172
+ return_value = self._contract.functions.canTerminateAuctions(
173
+ margin_account_id,
174
+ collateral,
175
+ ).call()
176
+ return bool(return_value)
177
+
178
+ def is_liquidatable(
179
+ self,
180
+ margin_account_id: eth_typing.ChecksumAddress,
181
+ collateral_token: eth_typing.ChecksumAddress,
182
+ ) -> bool:
183
+ """Binding for `isLiquidatable` on the AuctioneerFacet contract.
184
+
185
+ Parameters
186
+ ----------
187
+ margin_account_id : eth_typing.ChecksumAddress
188
+ collateral_token : eth_typing.ChecksumAddress
189
+
190
+ Returns
191
+ -------
192
+ bool
193
+ """
194
+ return_value = self._contract.functions.isLiquidatable(
195
+ margin_account_id,
196
+ collateral_token,
197
+ ).call()
198
+ return bool(return_value)
199
+
200
+ def is_liquidating(
201
+ self,
202
+ margin_account_id: eth_typing.ChecksumAddress,
203
+ collateral_token: eth_typing.ChecksumAddress,
204
+ ) -> bool:
205
+ """Binding for `isLiquidating` on the AuctioneerFacet contract.
206
+
207
+ Parameters
208
+ ----------
209
+ margin_account_id : eth_typing.ChecksumAddress
210
+ collateral_token : eth_typing.ChecksumAddress
211
+
212
+ Returns
213
+ -------
214
+ bool
215
+ """
216
+ return_value = self._contract.functions.isLiquidating(
217
+ margin_account_id,
218
+ collateral_token,
219
+ ).call()
220
+ return bool(return_value)
221
+
222
+ def mae_check_on_bid(
223
+ self,
224
+ liquidator_margin_account_id: eth_typing.ChecksumAddress,
225
+ liquidating_margin_account_id: eth_typing.ChecksumAddress,
226
+ collateral: eth_typing.ChecksumAddress,
227
+ bids: typing.List[BidData],
228
+ ) -> typing.Tuple[bool, bool]:
229
+ """Binding for `maeCheckOnBid` on the AuctioneerFacet contract.
230
+
231
+ Parameters
232
+ ----------
233
+ liquidator_margin_account_id : eth_typing.ChecksumAddress
234
+ liquidating_margin_account_id : eth_typing.ChecksumAddress
235
+ collateral : eth_typing.ChecksumAddress
236
+ bids : typing.List[BidData]
237
+
238
+ Returns
239
+ -------
240
+ bool
241
+ bool
242
+ """
243
+ return_value = self._contract.functions.maeCheckOnBid(
244
+ liquidator_margin_account_id,
245
+ liquidating_margin_account_id,
246
+ collateral,
247
+ [
248
+ (item.product_id, item.price, item.quantity, int(item.side))
249
+ for item in bids
250
+ ],
251
+ ).call()
252
+ return (
253
+ bool(return_value[0]),
254
+ bool(return_value[1]),
255
+ )
256
+
257
+ def max_mae_offered(
258
+ self,
259
+ margin_account_id: eth_typing.ChecksumAddress,
260
+ collateral: eth_typing.ChecksumAddress,
261
+ mmu_decreased: int,
262
+ ) -> int:
263
+ """Binding for `maxMaeOffered` on the AuctioneerFacet contract.
264
+
265
+ Parameters
266
+ ----------
267
+ margin_account_id : eth_typing.ChecksumAddress
268
+ collateral : eth_typing.ChecksumAddress
269
+ mmu_decreased : int
270
+
271
+ Returns
272
+ -------
273
+ int
274
+ """
275
+ return_value = self._contract.functions.maxMaeOffered(
276
+ margin_account_id,
277
+ collateral,
278
+ mmu_decreased,
279
+ ).call()
280
+ return int(return_value)
281
+
282
+ def request_liquidation(
283
+ self,
284
+ margin_account_id: eth_typing.ChecksumAddress,
285
+ collateral_token: eth_typing.ChecksumAddress,
286
+ ) -> contract.ContractFunction:
287
+ """Binding for `requestLiquidation` on the AuctioneerFacet contract.
288
+
289
+ Parameters
290
+ ----------
291
+ margin_account_id : eth_typing.ChecksumAddress
292
+ collateral_token : eth_typing.ChecksumAddress
293
+
294
+ Returns
295
+ -------
296
+ web3.contract.contract.ContractFunction
297
+ A contract function instance to be sent in a transaction.
298
+ """
299
+ return self._contract.functions.requestLiquidation(
300
+ margin_account_id,
301
+ collateral_token,
302
+ )
303
+
304
+ def terminate_auctions(
305
+ self,
306
+ margin_account_id: eth_typing.ChecksumAddress,
307
+ collateral: eth_typing.ChecksumAddress,
308
+ ) -> contract.ContractFunction:
309
+ """Binding for `terminateAuctions` on the AuctioneerFacet contract.
310
+
311
+ Parameters
312
+ ----------
313
+ margin_account_id : eth_typing.ChecksumAddress
314
+ collateral : eth_typing.ChecksumAddress
315
+
316
+ Returns
317
+ -------
318
+ web3.contract.contract.ContractFunction
319
+ A contract function instance to be sent in a transaction.
320
+ """
321
+ return self._contract.functions.terminateAuctions(
322
+ margin_account_id,
323
+ collateral,
324
+ )
325
+
326
+ def validate_auctions(
327
+ self,
328
+ margin_account_id: eth_typing.ChecksumAddress,
329
+ collateral_token: eth_typing.ChecksumAddress,
330
+ bids: typing.List[BidData],
331
+ ) -> bool:
332
+ """Binding for `validateAuctions` on the AuctioneerFacet contract.
333
+
334
+ Parameters
335
+ ----------
336
+ margin_account_id : eth_typing.ChecksumAddress
337
+ collateral_token : eth_typing.ChecksumAddress
338
+ bids : typing.List[BidData]
339
+
340
+ Returns
341
+ -------
342
+ bool
343
+ """
344
+ return_value = self._contract.functions.validateAuctions(
345
+ margin_account_id,
346
+ collateral_token,
347
+ [
348
+ (item.product_id, item.price, item.quantity, int(item.side))
349
+ for item in bids
350
+ ],
351
+ ).call()
352
+ return bool(return_value)
353
+
354
+
355
+ ABI = typing.cast(
356
+ eth_typing.ABI,
357
+ [
358
+ {"inputs": [], "name": "AuctionBidFailed", "type": "error"},
359
+ {"inputs": [], "name": "AuctionBountyFeeTooHigh", "type": "error"},
360
+ {
361
+ "inputs": [
362
+ {"internalType": "string", "name": "paramName", "type": "string"}
363
+ ],
364
+ "name": "InvalidParameter",
365
+ "type": "error",
366
+ },
367
+ {
368
+ "inputs": [
369
+ {"internalType": "enum ProductState", "name": "state", "type": "uint8"}
370
+ ],
371
+ "name": "InvalidProductState",
372
+ "type": "error",
373
+ },
374
+ {"inputs": [], "name": "Liquidating", "type": "error"},
375
+ {"inputs": [], "name": "LiquidationRequestFailed", "type": "error"},
376
+ {
377
+ "inputs": [
378
+ {"internalType": "address", "name": "marginAccount", "type": "address"}
379
+ ],
380
+ "name": "MAECheckFailed",
381
+ "type": "error",
382
+ },
383
+ {"inputs": [], "name": "MaeOverMmuRateExceeded", "type": "error"},
384
+ {
385
+ "inputs": [
386
+ {"internalType": "bytes32", "name": "productId", "type": "bytes32"}
387
+ ],
388
+ "name": "NoTradeData",
389
+ "type": "error",
390
+ },
391
+ {
392
+ "inputs": [
393
+ {"internalType": "address", "name": "account", "type": "address"}
394
+ ],
395
+ "name": "Unauthorized",
396
+ "type": "error",
397
+ },
398
+ {
399
+ "anonymous": False,
400
+ "inputs": [
401
+ {
402
+ "indexed": True,
403
+ "internalType": "address",
404
+ "name": "liquidatingMarginAccountID",
405
+ "type": "address",
406
+ },
407
+ {
408
+ "indexed": True,
409
+ "internalType": "address",
410
+ "name": "liquidatorMarginAccountID",
411
+ "type": "address",
412
+ },
413
+ {
414
+ "indexed": False,
415
+ "internalType": "bytes32",
416
+ "name": "productId",
417
+ "type": "bytes32",
418
+ },
419
+ {
420
+ "indexed": False,
421
+ "internalType": "int256",
422
+ "name": "quantity",
423
+ "type": "int256",
424
+ },
425
+ {
426
+ "indexed": False,
427
+ "internalType": "uint256",
428
+ "name": "price",
429
+ "type": "uint256",
430
+ },
431
+ ],
432
+ "name": "Auctioned",
433
+ "type": "event",
434
+ },
435
+ {
436
+ "anonymous": False,
437
+ "inputs": [
438
+ {
439
+ "indexed": True,
440
+ "internalType": "address",
441
+ "name": "marginAccountID",
442
+ "type": "address",
443
+ },
444
+ {
445
+ "indexed": True,
446
+ "internalType": "address",
447
+ "name": "collateralToken",
448
+ "type": "address",
449
+ },
450
+ ],
451
+ "name": "LiquidationStarted",
452
+ "type": "event",
453
+ },
454
+ {
455
+ "anonymous": False,
456
+ "inputs": [
457
+ {
458
+ "indexed": True,
459
+ "internalType": "address",
460
+ "name": "marginAccountID",
461
+ "type": "address",
462
+ },
463
+ {
464
+ "indexed": True,
465
+ "internalType": "address",
466
+ "name": "collateralToken",
467
+ "type": "address",
468
+ },
469
+ ],
470
+ "name": "LiquidationTerminated",
471
+ "type": "event",
472
+ },
473
+ {
474
+ "inputs": [],
475
+ "name": "auctionConfig",
476
+ "outputs": [
477
+ {
478
+ "components": [
479
+ {
480
+ "internalType": "uint64",
481
+ "name": "restorationBuffer",
482
+ "type": "uint64",
483
+ },
484
+ {
485
+ "internalType": "uint256",
486
+ "name": "liquidationDuration",
487
+ "type": "uint256",
488
+ },
489
+ ],
490
+ "internalType": "struct IAuctioneer.AuctionConfig",
491
+ "name": "",
492
+ "type": "tuple",
493
+ }
494
+ ],
495
+ "stateMutability": "view",
496
+ "type": "function",
497
+ },
498
+ {
499
+ "inputs": [
500
+ {
501
+ "internalType": "address",
502
+ "name": "marginAccountID",
503
+ "type": "address",
504
+ },
505
+ {"internalType": "address", "name": "collateral", "type": "address"},
506
+ ],
507
+ "name": "auctionData",
508
+ "outputs": [
509
+ {
510
+ "components": [
511
+ {
512
+ "internalType": "uint256",
513
+ "name": "startBlock",
514
+ "type": "uint256",
515
+ },
516
+ {
517
+ "internalType": "uint256",
518
+ "name": "maeAtInitiation",
519
+ "type": "uint256",
520
+ },
521
+ {
522
+ "internalType": "uint256",
523
+ "name": "mmuAtInitiation",
524
+ "type": "uint256",
525
+ },
526
+ {"internalType": "int256", "name": "maeNow", "type": "int256"},
527
+ {
528
+ "internalType": "uint256",
529
+ "name": "mmuNow",
530
+ "type": "uint256",
531
+ },
532
+ ],
533
+ "internalType": "struct IAuctioneer.AuctionData",
534
+ "name": "",
535
+ "type": "tuple",
536
+ }
537
+ ],
538
+ "stateMutability": "view",
539
+ "type": "function",
540
+ },
541
+ {
542
+ "inputs": [
543
+ {
544
+ "internalType": "address",
545
+ "name": "marginAccountID",
546
+ "type": "address",
547
+ },
548
+ {
549
+ "internalType": "address",
550
+ "name": "collateralToken",
551
+ "type": "address",
552
+ },
553
+ {
554
+ "components": [
555
+ {
556
+ "internalType": "bytes32",
557
+ "name": "productID",
558
+ "type": "bytes32",
559
+ },
560
+ {"internalType": "uint256", "name": "price", "type": "uint256"},
561
+ {
562
+ "internalType": "uint256",
563
+ "name": "quantity",
564
+ "type": "uint256",
565
+ },
566
+ {"internalType": "enum Side", "name": "side", "type": "uint8"},
567
+ ],
568
+ "internalType": "struct IAuctioneer.BidData[]",
569
+ "name": "bids",
570
+ "type": "tuple[]",
571
+ },
572
+ ],
573
+ "name": "bidAuction",
574
+ "outputs": [],
575
+ "stateMutability": "nonpayable",
576
+ "type": "function",
577
+ },
578
+ {
579
+ "inputs": [
580
+ {
581
+ "internalType": "address",
582
+ "name": "marginAccountID",
583
+ "type": "address",
584
+ },
585
+ {"internalType": "address", "name": "collateral", "type": "address"},
586
+ ],
587
+ "name": "canTerminateAuctions",
588
+ "outputs": [{"internalType": "bool", "name": "", "type": "bool"}],
589
+ "stateMutability": "view",
590
+ "type": "function",
591
+ },
592
+ {
593
+ "inputs": [
594
+ {
595
+ "internalType": "address",
596
+ "name": "marginAccountID",
597
+ "type": "address",
598
+ },
599
+ {
600
+ "internalType": "address",
601
+ "name": "collateralToken",
602
+ "type": "address",
603
+ },
604
+ ],
605
+ "name": "isLiquidatable",
606
+ "outputs": [{"internalType": "bool", "name": "", "type": "bool"}],
607
+ "stateMutability": "view",
608
+ "type": "function",
609
+ },
610
+ {
611
+ "inputs": [
612
+ {
613
+ "internalType": "address",
614
+ "name": "marginAccountID",
615
+ "type": "address",
616
+ },
617
+ {
618
+ "internalType": "address",
619
+ "name": "collateralToken",
620
+ "type": "address",
621
+ },
622
+ ],
623
+ "name": "isLiquidating",
624
+ "outputs": [{"internalType": "bool", "name": "", "type": "bool"}],
625
+ "stateMutability": "view",
626
+ "type": "function",
627
+ },
628
+ {
629
+ "inputs": [
630
+ {
631
+ "internalType": "address",
632
+ "name": "liquidatorMarginAccountID",
633
+ "type": "address",
634
+ },
635
+ {
636
+ "internalType": "address",
637
+ "name": "liquidatingMarginAccountID",
638
+ "type": "address",
639
+ },
640
+ {"internalType": "address", "name": "collateral", "type": "address"},
641
+ {
642
+ "components": [
643
+ {
644
+ "internalType": "bytes32",
645
+ "name": "productID",
646
+ "type": "bytes32",
647
+ },
648
+ {"internalType": "uint256", "name": "price", "type": "uint256"},
649
+ {
650
+ "internalType": "uint256",
651
+ "name": "quantity",
652
+ "type": "uint256",
653
+ },
654
+ {"internalType": "enum Side", "name": "side", "type": "uint8"},
655
+ ],
656
+ "internalType": "struct IAuctioneer.BidData[]",
657
+ "name": "bids",
658
+ "type": "tuple[]",
659
+ },
660
+ ],
661
+ "name": "maeCheckOnBid",
662
+ "outputs": [
663
+ {"internalType": "bool", "name": "maeCheckFailed", "type": "bool"},
664
+ {
665
+ "internalType": "bool",
666
+ "name": "maeOverMmuRateExceeded",
667
+ "type": "bool",
668
+ },
669
+ ],
670
+ "stateMutability": "view",
671
+ "type": "function",
672
+ },
673
+ {
674
+ "inputs": [
675
+ {
676
+ "internalType": "address",
677
+ "name": "marginAccountID",
678
+ "type": "address",
679
+ },
680
+ {"internalType": "address", "name": "collateral", "type": "address"},
681
+ {"internalType": "uint256", "name": "mmuDecreased", "type": "uint256"},
682
+ ],
683
+ "name": "maxMaeOffered",
684
+ "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
685
+ "stateMutability": "view",
686
+ "type": "function",
687
+ },
688
+ {
689
+ "inputs": [
690
+ {
691
+ "internalType": "address",
692
+ "name": "marginAccountID",
693
+ "type": "address",
694
+ },
695
+ {
696
+ "internalType": "address",
697
+ "name": "collateralToken",
698
+ "type": "address",
699
+ },
700
+ ],
701
+ "name": "requestLiquidation",
702
+ "outputs": [],
703
+ "stateMutability": "nonpayable",
704
+ "type": "function",
705
+ },
706
+ {
707
+ "inputs": [
708
+ {
709
+ "internalType": "address",
710
+ "name": "marginAccountID",
711
+ "type": "address",
712
+ },
713
+ {"internalType": "address", "name": "collateral", "type": "address"},
714
+ ],
715
+ "name": "terminateAuctions",
716
+ "outputs": [],
717
+ "stateMutability": "nonpayable",
718
+ "type": "function",
719
+ },
720
+ {
721
+ "inputs": [
722
+ {
723
+ "internalType": "address",
724
+ "name": "marginAccountID",
725
+ "type": "address",
726
+ },
727
+ {
728
+ "internalType": "address",
729
+ "name": "collateralToken",
730
+ "type": "address",
731
+ },
732
+ {
733
+ "components": [
734
+ {
735
+ "internalType": "bytes32",
736
+ "name": "productID",
737
+ "type": "bytes32",
738
+ },
739
+ {"internalType": "uint256", "name": "price", "type": "uint256"},
740
+ {
741
+ "internalType": "uint256",
742
+ "name": "quantity",
743
+ "type": "uint256",
744
+ },
745
+ {"internalType": "enum Side", "name": "side", "type": "uint8"},
746
+ ],
747
+ "internalType": "struct IAuctioneer.BidData[]",
748
+ "name": "bids",
749
+ "type": "tuple[]",
750
+ },
751
+ ],
752
+ "name": "validateAuctions",
753
+ "outputs": [{"internalType": "bool", "name": "", "type": "bool"}],
754
+ "stateMutability": "view",
755
+ "type": "function",
756
+ },
757
+ ],
758
+ )