afp-sdk 0.5.4__py3-none-any.whl → 0.6.1__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.
- afp/__init__.py +4 -1
- afp/afp.py +11 -0
- afp/api/admin.py +1 -1
- afp/api/base.py +11 -2
- afp/api/margin_account.py +12 -148
- afp/api/product.py +302 -148
- afp/api/trading.py +10 -19
- afp/auth.py +14 -0
- afp/bindings/__init__.py +30 -16
- afp/bindings/admin_facet.py +890 -0
- afp/bindings/clearing_facet.py +356 -773
- afp/bindings/facade.py +9 -6
- afp/bindings/final_settlement_facet.py +258 -99
- afp/bindings/margin_account.py +524 -839
- afp/bindings/margin_account_facet.py +722 -0
- afp/bindings/margin_account_registry.py +184 -310
- afp/bindings/mark_price_tracker_facet.py +74 -16
- afp/bindings/product_registry.py +1577 -541
- afp/bindings/product_registry_facet.py +1467 -0
- afp/bindings/system_viewer.py +592 -369
- afp/bindings/types.py +223 -0
- afp/config.py +4 -0
- afp/constants.py +49 -6
- afp/decorators.py +25 -3
- afp/dtos.py +142 -0
- afp/exceptions.py +10 -0
- afp/exchange.py +10 -8
- afp/hashing.py +7 -5
- afp/ipfs.py +245 -0
- afp/json-schemas/bafyreiaw34o6l3rmatabzbds2i2myazdw2yolevcpsoyd2i2g3ms7wa2eq.json +1 -0
- afp/json-schemas/bafyreibnfg6nq74dvpkre5rakkccij7iadp5rxpim7omsatjnrpmj3y7v4.json +1 -0
- afp/json-schemas/bafyreicgr6dfo5yduixjkcifghiulskfegwojvuwodtouvivl362zndhxe.json +1 -0
- afp/json-schemas/bafyreicheoypx6synljushh7mq2572iyhlolf4nake2p5dwobgnj3r5eua.json +1 -0
- afp/json-schemas/bafyreid35a67db4sqh4fs6boddyt2xvscbqy6nqvsp5jjur56qhkw4ixre.json +1 -0
- afp/json-schemas/bafyreidzs7okcpqiss6ztftltyptqwnw5e5opsy5yntospekjha4kpykaa.json +1 -0
- afp/json-schemas/bafyreifcec2km7hxwq6oqzjlspni2mgipetjb7pqtaewh2efislzoctboi.json +1 -0
- afp/json-schemas/bafyreihn3oiaxffe4e2w7pwtreadpw3obfd7gqlogbcxm56jc2hzfvco74.json +1 -0
- afp/json-schemas/bafyreihur3dzwhja6uxsbcw6eeoj3xmmc4e3zkmyzpot5v5dleevxe5zam.json +1 -0
- afp/schemas.py +236 -177
- afp/types.py +169 -0
- afp/validators.py +218 -8
- {afp_sdk-0.5.4.dist-info → afp_sdk-0.6.1.dist-info}/METADATA +76 -11
- afp_sdk-0.6.1.dist-info/RECORD +50 -0
- afp/bindings/auctioneer_facet.py +0 -752
- afp/bindings/bankruptcy_facet.py +0 -391
- afp/bindings/trading_protocol.py +0 -1158
- afp_sdk-0.5.4.dist-info/RECORD +0 -37
- {afp_sdk-0.5.4.dist-info → afp_sdk-0.6.1.dist-info}/WHEEL +0 -0
- {afp_sdk-0.5.4.dist-info → afp_sdk-0.6.1.dist-info}/licenses/LICENSE +0 -0
afp/bindings/bankruptcy_facet.py
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
"""BankruptcyFacet contract binding and data structures."""
|
|
2
|
-
|
|
3
|
-
# This module has been generated using pyabigen v0.2.16
|
|
4
|
-
|
|
5
|
-
import typing
|
|
6
|
-
from dataclasses import dataclass
|
|
7
|
-
|
|
8
|
-
import eth_typing
|
|
9
|
-
import hexbytes
|
|
10
|
-
import web3
|
|
11
|
-
from web3.contract import contract
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@dataclass
|
|
15
|
-
class LAAData:
|
|
16
|
-
"""Port of `struct LAAData` on the IBankruptcy contract."""
|
|
17
|
-
|
|
18
|
-
owner: eth_typing.ChecksumAddress
|
|
19
|
-
quantity: int
|
|
20
|
-
last_traded_timestamp: int
|
|
21
|
-
position_age: int
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@dataclass
|
|
25
|
-
class PositionLossData:
|
|
26
|
-
"""Port of `struct PositionLossData` on the IBankruptcy contract."""
|
|
27
|
-
|
|
28
|
-
position_id: hexbytes.HexBytes
|
|
29
|
-
bankrupt_account_u_pn_l: int
|
|
30
|
-
bankrupt_account_quantity: int
|
|
31
|
-
mark_price: int
|
|
32
|
-
point_value: int
|
|
33
|
-
tick_size: int
|
|
34
|
-
laa_data: typing.List[LAAData]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class BankruptcyFacet:
|
|
38
|
-
"""BankruptcyFacet contract binding.
|
|
39
|
-
|
|
40
|
-
Parameters
|
|
41
|
-
----------
|
|
42
|
-
w3 : web3.Web3
|
|
43
|
-
address : eth_typing.ChecksumAddress
|
|
44
|
-
The address of a deployed BankruptcyFacet contract.
|
|
45
|
-
"""
|
|
46
|
-
|
|
47
|
-
_contract: contract.Contract
|
|
48
|
-
|
|
49
|
-
def __init__(
|
|
50
|
-
self,
|
|
51
|
-
w3: web3.Web3,
|
|
52
|
-
address: eth_typing.ChecksumAddress,
|
|
53
|
-
):
|
|
54
|
-
self._contract = w3.eth.contract(
|
|
55
|
-
address=address,
|
|
56
|
-
abi=ABI,
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
@property
|
|
60
|
-
def LossMutualized(self) -> contract.ContractEvent:
|
|
61
|
-
"""Binding for `event LossMutualized` on the BankruptcyFacet contract."""
|
|
62
|
-
return self._contract.events.LossMutualized
|
|
63
|
-
|
|
64
|
-
def last_traded_timestamp(
|
|
65
|
-
self,
|
|
66
|
-
product_id: hexbytes.HexBytes,
|
|
67
|
-
trader: eth_typing.ChecksumAddress,
|
|
68
|
-
) -> int:
|
|
69
|
-
"""Binding for `lastTradedTimestamp` on the BankruptcyFacet contract.
|
|
70
|
-
|
|
71
|
-
Parameters
|
|
72
|
-
----------
|
|
73
|
-
product_id : hexbytes.HexBytes
|
|
74
|
-
trader : eth_typing.ChecksumAddress
|
|
75
|
-
|
|
76
|
-
Returns
|
|
77
|
-
-------
|
|
78
|
-
int
|
|
79
|
-
"""
|
|
80
|
-
return_value = self._contract.functions.lastTradedTimestamp(
|
|
81
|
-
product_id,
|
|
82
|
-
trader,
|
|
83
|
-
).call()
|
|
84
|
-
return int(return_value)
|
|
85
|
-
|
|
86
|
-
def mutualize_losses(
|
|
87
|
-
self,
|
|
88
|
-
bankrupt_account_id: eth_typing.ChecksumAddress,
|
|
89
|
-
collateral_token: eth_typing.ChecksumAddress,
|
|
90
|
-
product_ids: typing.List[hexbytes.HexBytes],
|
|
91
|
-
laas: typing.List[typing.List[eth_typing.ChecksumAddress]],
|
|
92
|
-
) -> contract.ContractFunction:
|
|
93
|
-
"""Binding for `mutualizeLosses` on the BankruptcyFacet contract.
|
|
94
|
-
|
|
95
|
-
Parameters
|
|
96
|
-
----------
|
|
97
|
-
bankrupt_account_id : eth_typing.ChecksumAddress
|
|
98
|
-
collateral_token : eth_typing.ChecksumAddress
|
|
99
|
-
product_ids : typing.List[hexbytes.HexBytes]
|
|
100
|
-
laas : typing.List[typing.List[eth_typing.ChecksumAddress]]
|
|
101
|
-
|
|
102
|
-
Returns
|
|
103
|
-
-------
|
|
104
|
-
web3.contract.contract.ContractFunction
|
|
105
|
-
A contract function instance to be sent in a transaction.
|
|
106
|
-
"""
|
|
107
|
-
return self._contract.functions.mutualizeLosses(
|
|
108
|
-
bankrupt_account_id,
|
|
109
|
-
collateral_token,
|
|
110
|
-
product_ids,
|
|
111
|
-
laas,
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
def unique_trader_count(
|
|
115
|
-
self,
|
|
116
|
-
product_id: hexbytes.HexBytes,
|
|
117
|
-
) -> int:
|
|
118
|
-
"""Binding for `uniqueTraderCount` on the BankruptcyFacet contract.
|
|
119
|
-
|
|
120
|
-
Parameters
|
|
121
|
-
----------
|
|
122
|
-
product_id : hexbytes.HexBytes
|
|
123
|
-
|
|
124
|
-
Returns
|
|
125
|
-
-------
|
|
126
|
-
int
|
|
127
|
-
"""
|
|
128
|
-
return_value = self._contract.functions.uniqueTraderCount(
|
|
129
|
-
product_id,
|
|
130
|
-
).call()
|
|
131
|
-
return int(return_value)
|
|
132
|
-
|
|
133
|
-
def validate_la_as(
|
|
134
|
-
self,
|
|
135
|
-
margin_account: eth_typing.ChecksumAddress,
|
|
136
|
-
bankrupt_account: eth_typing.ChecksumAddress,
|
|
137
|
-
product_id: hexbytes.HexBytes,
|
|
138
|
-
product_owners: typing.List[eth_typing.ChecksumAddress],
|
|
139
|
-
) -> PositionLossData:
|
|
140
|
-
"""Binding for `validateLAAs` on the BankruptcyFacet contract.
|
|
141
|
-
|
|
142
|
-
Parameters
|
|
143
|
-
----------
|
|
144
|
-
margin_account : eth_typing.ChecksumAddress
|
|
145
|
-
bankrupt_account : eth_typing.ChecksumAddress
|
|
146
|
-
product_id : hexbytes.HexBytes
|
|
147
|
-
product_owners : typing.List[eth_typing.ChecksumAddress]
|
|
148
|
-
|
|
149
|
-
Returns
|
|
150
|
-
-------
|
|
151
|
-
PositionLossData
|
|
152
|
-
"""
|
|
153
|
-
return_value = self._contract.functions.validateLAAs(
|
|
154
|
-
margin_account,
|
|
155
|
-
bankrupt_account,
|
|
156
|
-
product_id,
|
|
157
|
-
product_owners,
|
|
158
|
-
).call()
|
|
159
|
-
return PositionLossData(
|
|
160
|
-
hexbytes.HexBytes(return_value[0]),
|
|
161
|
-
int(return_value[1]),
|
|
162
|
-
int(return_value[2]),
|
|
163
|
-
int(return_value[3]),
|
|
164
|
-
int(return_value[4]),
|
|
165
|
-
int(return_value[5]),
|
|
166
|
-
[
|
|
167
|
-
LAAData(
|
|
168
|
-
eth_typing.ChecksumAddress(return_value6_elem[0]),
|
|
169
|
-
int(return_value6_elem[1]),
|
|
170
|
-
int(return_value6_elem[2]),
|
|
171
|
-
int(return_value6_elem[3]),
|
|
172
|
-
)
|
|
173
|
-
for return_value6_elem in return_value[6]
|
|
174
|
-
],
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
ABI = typing.cast(
|
|
179
|
-
eth_typing.ABI,
|
|
180
|
-
[
|
|
181
|
-
{
|
|
182
|
-
"inputs": [
|
|
183
|
-
{"internalType": "address", "name": "account", "type": "address"}
|
|
184
|
-
],
|
|
185
|
-
"name": "AccountNotBankrupt",
|
|
186
|
-
"type": "error",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
"inputs": [
|
|
190
|
-
{"internalType": "string", "name": "paramName", "type": "string"}
|
|
191
|
-
],
|
|
192
|
-
"name": "InvalidParameter",
|
|
193
|
-
"type": "error",
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
"inputs": [
|
|
197
|
-
{"internalType": "int256", "name": "neededQuantity", "type": "int256"},
|
|
198
|
-
{
|
|
199
|
-
"internalType": "int256",
|
|
200
|
-
"name": "totalLAAQuantity",
|
|
201
|
-
"type": "int256",
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
"name": "LAAQuantityMismatch",
|
|
205
|
-
"type": "error",
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"inputs": [
|
|
209
|
-
{"internalType": "uint256", "name": "neededCount", "type": "uint256"},
|
|
210
|
-
{
|
|
211
|
-
"internalType": "uint256",
|
|
212
|
-
"name": "totalLAASetCount",
|
|
213
|
-
"type": "uint256",
|
|
214
|
-
},
|
|
215
|
-
],
|
|
216
|
-
"name": "LAASetIncomplete",
|
|
217
|
-
"type": "error",
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
"inputs": [
|
|
221
|
-
{"internalType": "bytes32", "name": "productId", "type": "bytes32"}
|
|
222
|
-
],
|
|
223
|
-
"name": "NoTradeData",
|
|
224
|
-
"type": "error",
|
|
225
|
-
},
|
|
226
|
-
{"inputs": [], "name": "QueueIsEmpty", "type": "error"},
|
|
227
|
-
{
|
|
228
|
-
"anonymous": False,
|
|
229
|
-
"inputs": [
|
|
230
|
-
{
|
|
231
|
-
"indexed": True,
|
|
232
|
-
"internalType": "address",
|
|
233
|
-
"name": "bankruptAccount",
|
|
234
|
-
"type": "address",
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"indexed": True,
|
|
238
|
-
"internalType": "address",
|
|
239
|
-
"name": "collateralToken",
|
|
240
|
-
"type": "address",
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
"indexed": False,
|
|
244
|
-
"internalType": "address",
|
|
245
|
-
"name": "caller",
|
|
246
|
-
"type": "address",
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
"indexed": False,
|
|
250
|
-
"internalType": "int256",
|
|
251
|
-
"name": "lossAmount",
|
|
252
|
-
"type": "int256",
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
"name": "LossMutualized",
|
|
256
|
-
"type": "event",
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
"inputs": [
|
|
260
|
-
{"internalType": "bytes32", "name": "productId", "type": "bytes32"},
|
|
261
|
-
{"internalType": "address", "name": "trader", "type": "address"},
|
|
262
|
-
],
|
|
263
|
-
"name": "lastTradedTimestamp",
|
|
264
|
-
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
|
|
265
|
-
"stateMutability": "view",
|
|
266
|
-
"type": "function",
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
"inputs": [
|
|
270
|
-
{
|
|
271
|
-
"internalType": "address",
|
|
272
|
-
"name": "bankruptAccountId",
|
|
273
|
-
"type": "address",
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
"internalType": "address",
|
|
277
|
-
"name": "collateralToken",
|
|
278
|
-
"type": "address",
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
"internalType": "bytes32[]",
|
|
282
|
-
"name": "productIds",
|
|
283
|
-
"type": "bytes32[]",
|
|
284
|
-
},
|
|
285
|
-
{"internalType": "address[][]", "name": "laas", "type": "address[][]"},
|
|
286
|
-
],
|
|
287
|
-
"name": "mutualizeLosses",
|
|
288
|
-
"outputs": [],
|
|
289
|
-
"stateMutability": "nonpayable",
|
|
290
|
-
"type": "function",
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
"inputs": [
|
|
294
|
-
{"internalType": "bytes32", "name": "productId", "type": "bytes32"}
|
|
295
|
-
],
|
|
296
|
-
"name": "uniqueTraderCount",
|
|
297
|
-
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
|
|
298
|
-
"stateMutability": "view",
|
|
299
|
-
"type": "function",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
"inputs": [
|
|
303
|
-
{
|
|
304
|
-
"internalType": "contract IMarginAccount",
|
|
305
|
-
"name": "marginAccount",
|
|
306
|
-
"type": "address",
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
"internalType": "address",
|
|
310
|
-
"name": "bankruptAccount",
|
|
311
|
-
"type": "address",
|
|
312
|
-
},
|
|
313
|
-
{"internalType": "bytes32", "name": "productId", "type": "bytes32"},
|
|
314
|
-
{
|
|
315
|
-
"internalType": "address[]",
|
|
316
|
-
"name": "productOwners",
|
|
317
|
-
"type": "address[]",
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
"name": "validateLAAs",
|
|
321
|
-
"outputs": [
|
|
322
|
-
{
|
|
323
|
-
"components": [
|
|
324
|
-
{
|
|
325
|
-
"internalType": "bytes32",
|
|
326
|
-
"name": "positionId",
|
|
327
|
-
"type": "bytes32",
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
"internalType": "int256",
|
|
331
|
-
"name": "bankruptAccountUPnL",
|
|
332
|
-
"type": "int256",
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
"internalType": "int256",
|
|
336
|
-
"name": "bankruptAccountQuantity",
|
|
337
|
-
"type": "int256",
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
"internalType": "uint256",
|
|
341
|
-
"name": "markPrice",
|
|
342
|
-
"type": "uint256",
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
"internalType": "uint256",
|
|
346
|
-
"name": "pointValue",
|
|
347
|
-
"type": "uint256",
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
"internalType": "uint256",
|
|
351
|
-
"name": "tickSize",
|
|
352
|
-
"type": "uint256",
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
"components": [
|
|
356
|
-
{
|
|
357
|
-
"internalType": "address",
|
|
358
|
-
"name": "owner",
|
|
359
|
-
"type": "address",
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
"internalType": "int256",
|
|
363
|
-
"name": "quantity",
|
|
364
|
-
"type": "int256",
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"internalType": "uint256",
|
|
368
|
-
"name": "lastTradedTimestamp",
|
|
369
|
-
"type": "uint256",
|
|
370
|
-
},
|
|
371
|
-
{
|
|
372
|
-
"internalType": "uint256",
|
|
373
|
-
"name": "positionAge",
|
|
374
|
-
"type": "uint256",
|
|
375
|
-
},
|
|
376
|
-
],
|
|
377
|
-
"internalType": "struct IBankruptcy.LAAData[]",
|
|
378
|
-
"name": "laaData",
|
|
379
|
-
"type": "tuple[]",
|
|
380
|
-
},
|
|
381
|
-
],
|
|
382
|
-
"internalType": "struct IBankruptcy.PositionLossData",
|
|
383
|
-
"name": "",
|
|
384
|
-
"type": "tuple",
|
|
385
|
-
}
|
|
386
|
-
],
|
|
387
|
-
"stateMutability": "view",
|
|
388
|
-
"type": "function",
|
|
389
|
-
},
|
|
390
|
-
],
|
|
391
|
-
)
|