afp-sdk 0.3.0__py3-none-any.whl → 0.5.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.
- afp/__init__.py +12 -7
- afp/afp.py +210 -0
- afp/api/admin.py +1 -14
- afp/api/base.py +82 -29
- afp/api/{clearing.py → margin_account.py} +172 -104
- afp/api/{builder.py → product.py} +103 -41
- afp/api/trading.py +18 -31
- afp/auth.py +66 -0
- afp/bindings/bankruptcy_facet.py +36 -0
- afp/bindings/clearing_facet.py +28 -0
- afp/bindings/facade.py +25 -13
- afp/bindings/margin_account.py +108 -0
- afp/bindings/product_registry.py +1 -48
- afp/bindings/system_viewer.py +1 -7
- afp/config.py +22 -36
- afp/constants.py +52 -0
- afp/decorators.py +3 -1
- afp/exceptions.py +7 -3
- afp/exchange.py +15 -7
- afp/{signing.py → hashing.py} +4 -12
- afp/schemas.py +9 -1
- afp/validators.py +1 -0
- {afp_sdk-0.3.0.dist-info → afp_sdk-0.5.0.dist-info}/METADATA +54 -50
- afp_sdk-0.5.0.dist-info/RECORD +37 -0
- {afp_sdk-0.3.0.dist-info → afp_sdk-0.5.0.dist-info}/WHEEL +1 -1
- afp/api/liquidation.py +0 -167
- afp_sdk-0.3.0.dist-info/RECORD +0 -35
- {afp_sdk-0.3.0.dist-info → afp_sdk-0.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: afp-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Autonomous Futures Protocol Python SDK
|
|
5
5
|
Keywords: autonity,web3,trading,crypto,prediction,forecast,markets
|
|
6
6
|
License-Expression: MIT
|
|
@@ -25,6 +25,10 @@ Description-Content-Type: text/markdown
|
|
|
25
25
|
|
|
26
26
|
# Autonomous Futures Protocol Python SDK
|
|
27
27
|
|
|
28
|
+
Decentralized clearing and creation of Forecast Futures on any timeseries.
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
28
32
|
## Installation
|
|
29
33
|
|
|
30
34
|
This library is published on PyPI as the [afp-sdk](https://pypi.org/project/afp-sdk/)
|
|
@@ -34,6 +38,11 @@ package. It can be installed in a virtualenv with:
|
|
|
34
38
|
pip install afp-sdk
|
|
35
39
|
```
|
|
36
40
|
|
|
41
|
+
## Documentation
|
|
42
|
+
|
|
43
|
+
See [afp.autonity.org](https://afp.autonity.org/) for the Autonomous Futures Protocol
|
|
44
|
+
documentation, including the Python SDK reference.
|
|
45
|
+
|
|
37
46
|
## Overview
|
|
38
47
|
|
|
39
48
|
The `afp` package consists of the following:
|
|
@@ -43,6 +52,13 @@ The `afp` package consists of the following:
|
|
|
43
52
|
- `afp.bindings` submodule: Low-level API that provides typed Python bindings
|
|
44
53
|
for the Clearing System smart contracts.
|
|
45
54
|
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
By default the SDK communicates with the AFP Clearing System contracts on
|
|
58
|
+
Autonity Mainnet, and the AutEx Exchange. Connection parameters can be
|
|
59
|
+
overridden via the `afp.AFP` constructor and environment variables; see the
|
|
60
|
+
documentation of the `afp.AFP` class for the available parameters.
|
|
61
|
+
|
|
46
62
|
## Usage
|
|
47
63
|
|
|
48
64
|
### Preparation
|
|
@@ -53,7 +69,8 @@ In order to trade in the AFP system, traders need to prepare the following:
|
|
|
53
69
|
- The address of the product's collateral token.
|
|
54
70
|
- An Autonity account for managing the margin account. It needs to hold a
|
|
55
71
|
balance in ATN (for paying gas fee) and in the product's collateral token.
|
|
56
|
-
- An Autonity account for signing intents
|
|
72
|
+
- An Autonity account for signing intents and submitting trades to the
|
|
73
|
+
exchange. The two accounts can be the same.
|
|
57
74
|
- The address of an Autonity RPC provider. They can be found on
|
|
58
75
|
[Chainlist](https://chainlist.org/?search=autonity).
|
|
59
76
|
|
|
@@ -64,57 +81,60 @@ import os
|
|
|
64
81
|
|
|
65
82
|
PRODUCT_ID = "0x38d502bb683f53ec7c3d7a14b4aa47ac717659e121426131c0189c15bf4b9460"
|
|
66
83
|
COLLATERAL_ASSET = "0xD1A1e4035a164cF42228A8aAaBC2c0Ac9e49687B"
|
|
67
|
-
|
|
68
|
-
INTENT_ACCOUNT_PRIVATE_KEY = os.environ["INTENT_ACCOUNT_PRIVATE_KEY"]
|
|
84
|
+
PRIVATE_KEY = os.environ["PRIVATE_KEY"]
|
|
69
85
|
AUTONITY_RPC_URL = "https://bakerloo.autonity-apis.com"
|
|
70
86
|
```
|
|
71
87
|
|
|
72
|
-
|
|
88
|
+
### Configuration
|
|
73
89
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
MARGIN_ACCOUNT_ID = Account.from_key(MARGIN_ACCOUNT_PRIVATE_KEY).address
|
|
78
|
-
INTENT_ACCOUNT_ID = Account.from_key(INTENT_ACCOUNT_PRIVATE_KEY).address
|
|
79
|
-
```
|
|
90
|
+
An application instance can be created with the `afp.AFP()` constructor. An instance
|
|
91
|
+
is associated with a trading venue and a margin account.
|
|
80
92
|
|
|
81
|
-
|
|
93
|
+
The required constructor arguments are the RPC provider URL and the authenticator of
|
|
94
|
+
the blockchain account that manages the margin account.
|
|
82
95
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
An "authenticator" is a service that implements the `afp.Authenticator` protocol.
|
|
97
|
+
Available options are `afp.PrivateKeyAuthenticator` that reads the private key
|
|
98
|
+
from a constructor argument, and `afp.KeyfileAuthenticator` that reads the private
|
|
99
|
+
key from an encrypted keyfile.
|
|
86
100
|
|
|
87
101
|
```py
|
|
88
102
|
import afp
|
|
89
103
|
|
|
90
|
-
|
|
104
|
+
app = afp.AFP(
|
|
105
|
+
rpc_url=AUTONITY_RPC_URL,
|
|
106
|
+
authenticator=afp.PrivateKeyAuthenticator(PRIVATE_KEY),
|
|
107
|
+
)
|
|
91
108
|
```
|
|
92
109
|
|
|
93
|
-
|
|
94
|
-
`clearing.deposit_into_margin_account()`.
|
|
110
|
+
### Margin Account API
|
|
95
111
|
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
Margin accounts can be managed via the `MarginAccount` session object. It
|
|
113
|
+
connects to the specified Autonity RPC provider and communicates with the
|
|
114
|
+
Clearing System smart contracts.
|
|
98
115
|
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
```py
|
|
117
|
+
margin_account = app.MarginAccount()
|
|
101
118
|
```
|
|
102
119
|
|
|
103
|
-
|
|
104
|
-
if the intent account and the margin account are different.
|
|
120
|
+
Collateral can be deposited into the margin account with `margin_account.deposit()`.
|
|
105
121
|
|
|
106
122
|
```py
|
|
107
|
-
|
|
123
|
+
from decimal import Decimal
|
|
124
|
+
|
|
125
|
+
margin_account.deposit(COLLATERAL_ASSET, Decimal("100.00"))
|
|
126
|
+
print(margin_account.capital(COLLATERAL_ASSET))
|
|
108
127
|
```
|
|
109
128
|
|
|
110
129
|
### Trading API
|
|
111
130
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
Functions of the trading API can be accessed via the `Trading` session object.
|
|
132
|
+
It communicates with the AutEx exchange and authenticates on creation with the
|
|
133
|
+
intent account's private key. The intent account authenticator is optional, it
|
|
134
|
+
defaults to the authenticator set in the `AFP` constructor.
|
|
115
135
|
|
|
116
136
|
```py
|
|
117
|
-
trading =
|
|
137
|
+
trading = app.Trading()
|
|
118
138
|
```
|
|
119
139
|
|
|
120
140
|
To start trading a product, its parameters shall be retrieved from the server.
|
|
@@ -169,28 +189,12 @@ print(fills)
|
|
|
169
189
|
|
|
170
190
|
See further code examples in the [examples](./examples/) directory.
|
|
171
191
|
|
|
172
|
-
## Configuration
|
|
173
|
-
|
|
174
|
-
By default the SDK communicates with the AFP Clearing System contracts on
|
|
175
|
-
Autonity Mainnet, and the AutEx Exchange. Connection parameters can be
|
|
176
|
-
overridden with the following environment variables:
|
|
177
|
-
|
|
178
|
-
```sh
|
|
179
|
-
AFP_EXCHANGE_URL=
|
|
180
|
-
AFP_CHAIN_ID=
|
|
181
|
-
AFP_CLEARING_DIAMOND_ADDRESS=
|
|
182
|
-
AFP_MARGIN_ACCOUNT_REGISTRY_ADDRESS=
|
|
183
|
-
AFP_ORACLE_PROVIDER_ADDRESS=
|
|
184
|
-
AFP_PRODUCT_REGISTRY_ADDRESS=
|
|
185
|
-
AFP_SYSTEM_VIEWER_ADDRESS=
|
|
186
|
-
```
|
|
187
|
-
|
|
188
192
|
## Development
|
|
189
193
|
|
|
190
194
|
The package uses [`uv`](https://docs.astral.sh/uv/) as project manager.
|
|
191
195
|
|
|
192
|
-
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
-
|
|
196
|
-
-
|
|
196
|
+
- Install dependencies with the `uv sync` command.
|
|
197
|
+
- Execute linters with the `uv run poe lint` command.
|
|
198
|
+
- Run tests with the `uv run poe test` command.
|
|
199
|
+
- Check distributions before release with the `uv run poe check-dist` command.
|
|
200
|
+
- Generate markdown API documentation with the `uv run poe doc-gen` command.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
afp/__init__.py,sha256=tvvXz4miC3QI8wy4vjAAf_LtL-19eEgBRA6dnrh3LA8,349
|
|
2
|
+
afp/afp.py,sha256=1xpocnWjALP6QlA-Hn7G2znttJ-ikcb2WA9sLueY3zc,9107
|
|
3
|
+
afp/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
afp/api/admin.py,sha256=5Q2V6Lde8ERwa0OvNhgez50WW6RcQH0eBA6aHPGwVtY,1243
|
|
5
|
+
afp/api/base.py,sha256=5X1joEwFX4gxYUDCSTvp_hSFCfLZCktnW-UtZFxDquk,4471
|
|
6
|
+
afp/api/margin_account.py,sha256=sC1DF7J3QTHR7cXcRjTG33oZswVy6qr9xnevQbrQ-ew,15256
|
|
7
|
+
afp/api/product.py,sha256=9EGQ5_UZ0m_uIkBIukp99fYVtTIQrqupXxQQ1ATev_E,9100
|
|
8
|
+
afp/api/trading.py,sha256=exQQ3LJA6XCbRAUBuYVjSJ5PHFi4COyqDORxC37LLfQ,10379
|
|
9
|
+
afp/auth.py,sha256=791uNaXrmcRuLbzSzgBsro1k4EOP9N1Ez3VCChX-giw,2054
|
|
10
|
+
afp/bindings/__init__.py,sha256=_n9xoogYi8AAlSx_PE-wjnwP1ujVyDUwoRM0BSm243U,1271
|
|
11
|
+
afp/bindings/auctioneer_facet.py,sha256=4p906zdU2lUsqpWlsiLE3dlxTPrlNpqk8DtjiQUWJ8M,23919
|
|
12
|
+
afp/bindings/bankruptcy_facet.py,sha256=-Kp4Ap5PLAmo_tFrp-1s_yAh0mtHS20z3BC5YIrVjrU,12548
|
|
13
|
+
afp/bindings/clearing_facet.py,sha256=cfyDo-s9_DesbK1Oe-8rfbTCS3HBX9X-L6HbzSydEFk,34898
|
|
14
|
+
afp/bindings/erc20.py,sha256=-jw7ohcEbUL7g3PpK3-a5_7ClUDCDHt1bezm-w7exzo,10822
|
|
15
|
+
afp/bindings/facade.py,sha256=8IehHRqmt9xVe4OJLVAfedprv1fc6mLj7COOjpI_AwA,2588
|
|
16
|
+
afp/bindings/final_settlement_facet.py,sha256=1U5F3WFvf4GUml3gb90YF9RZK_xCwBsX2zRQ8sWSkR0,9470
|
|
17
|
+
afp/bindings/margin_account.py,sha256=hqvHpfM62SAEXSt__NZzAQGu9z7DnIa9LbSgHHkhsKE,45872
|
|
18
|
+
afp/bindings/margin_account_registry.py,sha256=mx9sAU6HuC09d-LAf9bzP57HPLa3M6qXpN7Lj-uiXSc,18800
|
|
19
|
+
afp/bindings/mark_price_tracker_facet.py,sha256=vnVsAmpts_2Sv9Jmx3JlON8X8FJd9D2jOFhqSwXIA7A,2830
|
|
20
|
+
afp/bindings/oracle_provider.py,sha256=CMpVAXdUuTP_W9ZE297B-m9MjuW90yCOhNLMVl3kCf0,15863
|
|
21
|
+
afp/bindings/product_registry.py,sha256=-_h786jzMCsaTqqnoxpmVgBkGf45eCUMthp_PkqrET0,42137
|
|
22
|
+
afp/bindings/system_viewer.py,sha256=0FivdhpfXMrBesXcHkfO9uELyr7GiRmGe36xS5sURGE,41094
|
|
23
|
+
afp/bindings/trading_protocol.py,sha256=ZloF3REbjFq9v0UGVsM0_Lk0EhfWJKdeJ0PzVEnyZo0,39573
|
|
24
|
+
afp/config.py,sha256=_WKywiuty8poE1A0v46uBe1JGpfCzRlxCPamKennfpE,699
|
|
25
|
+
afp/constants.py,sha256=XIph4R0Tx-BPw_NZJgWUtb7NdS9sYzEciFRSStm3VMs,1840
|
|
26
|
+
afp/decorators.py,sha256=SEUQtbgPGc4iVPtBQV2eiCejcDAVImmXcI0uPXFhtJA,2774
|
|
27
|
+
afp/enums.py,sha256=4dglBx4Amcu0GrlJn0cIj-rp9uDHZGfDEP_vMAO02xo,485
|
|
28
|
+
afp/exceptions.py,sha256=frdS-EH84K0fOf92RgRgNkTe3VII2m36XNCS8eyXLLM,390
|
|
29
|
+
afp/exchange.py,sha256=ZhpZzq33jBGAderS9Pl_WZjnYLlECG7nyjYdX24KnRo,5760
|
|
30
|
+
afp/hashing.py,sha256=gBCWN93-ydRPlgnnorSvDQlylcnglrAypRDb-1K-20I,1949
|
|
31
|
+
afp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
afp/schemas.py,sha256=bby8MKc6ALv-v8UaUrhiaKwpkXuQexA6CD8hw6urLUM,5083
|
|
33
|
+
afp/validators.py,sha256=zQvPu3HDu6ADnEE72EJlS5hc1-xfru78Mzd74s1u_EM,1841
|
|
34
|
+
afp_sdk-0.5.0.dist-info/licenses/LICENSE,sha256=ZdaKItgc2ppfqta2OJV0oHpSJiK87PUxmUkUo-_0SB8,1065
|
|
35
|
+
afp_sdk-0.5.0.dist-info/WHEEL,sha256=5h_Q-_6zWQhhADpsAD_Xpw7gFbCRK5WjOOEq0nB806Q,79
|
|
36
|
+
afp_sdk-0.5.0.dist-info/METADATA,sha256=zO6jbifQf9v8abl1bgpTNyuWLxpn1Oz-ch6PH0yms_0,6354
|
|
37
|
+
afp_sdk-0.5.0.dist-info/RECORD,,
|
afp/api/liquidation.py
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
from decimal import Decimal
|
|
2
|
-
from functools import cache
|
|
3
|
-
from typing import Iterable
|
|
4
|
-
|
|
5
|
-
from hexbytes import HexBytes
|
|
6
|
-
from web3 import Web3
|
|
7
|
-
|
|
8
|
-
from .. import validators
|
|
9
|
-
from ..bindings import (
|
|
10
|
-
BidData,
|
|
11
|
-
ClearingDiamond,
|
|
12
|
-
ProductRegistry,
|
|
13
|
-
Side as OnChainOrderSide,
|
|
14
|
-
)
|
|
15
|
-
from ..bindings.facade import CLEARING_DIAMOND_ABI
|
|
16
|
-
from ..bindings.product_registry import ABI as PRODUCT_REGISTRY_ABI
|
|
17
|
-
from ..decorators import convert_web3_error
|
|
18
|
-
from ..enums import OrderSide
|
|
19
|
-
from ..schemas import AuctionData, Bid
|
|
20
|
-
from .base import ClearingSystemAPI
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class Liquidation(ClearingSystemAPI):
|
|
24
|
-
"""API for participating in liquidation auctions.
|
|
25
|
-
|
|
26
|
-
Parameters
|
|
27
|
-
----------
|
|
28
|
-
private_key : str
|
|
29
|
-
The private key of the blockchain account that participates in a liquidation
|
|
30
|
-
auction.
|
|
31
|
-
autonity_rpc_url : str
|
|
32
|
-
The URL of a JSON-RPC provider for Autonity. (HTTPS only.)
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
@staticmethod
|
|
36
|
-
def create_bid(product_id: str, price: Decimal, quantity: int, side: str) -> Bid:
|
|
37
|
-
"""Create a bid to be submitted to a liquidation auction.
|
|
38
|
-
|
|
39
|
-
Parameters
|
|
40
|
-
----------
|
|
41
|
-
product_id : str
|
|
42
|
-
price: Decimal
|
|
43
|
-
quantity: int
|
|
44
|
-
side: str
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
afp.schemas.Bid
|
|
49
|
-
"""
|
|
50
|
-
return Bid(
|
|
51
|
-
product_id=product_id,
|
|
52
|
-
price=price,
|
|
53
|
-
quantity=quantity,
|
|
54
|
-
side=getattr(OrderSide, side.upper()),
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
### Transactions ###
|
|
58
|
-
|
|
59
|
-
@convert_web3_error(CLEARING_DIAMOND_ABI)
|
|
60
|
-
def request_liquidation(self, margin_account_id: str, collateral_asset: str) -> str:
|
|
61
|
-
"""Request a liquidation auction to be started.
|
|
62
|
-
|
|
63
|
-
Parameters
|
|
64
|
-
----------
|
|
65
|
-
margin_account_id : str
|
|
66
|
-
The ID of the margin account to be liquidated.
|
|
67
|
-
collateral_asset : str
|
|
68
|
-
The address of the collateral token that the margin account is trading with.
|
|
69
|
-
|
|
70
|
-
Returns
|
|
71
|
-
-------
|
|
72
|
-
str
|
|
73
|
-
The hash of the transaction.
|
|
74
|
-
"""
|
|
75
|
-
margin_account_id = validators.validate_address(margin_account_id)
|
|
76
|
-
collateral_asset = validators.validate_address(collateral_asset)
|
|
77
|
-
|
|
78
|
-
clearing_contract = ClearingDiamond(self._w3)
|
|
79
|
-
tx_hash = clearing_contract.request_liquidation(
|
|
80
|
-
margin_account_id, collateral_asset
|
|
81
|
-
).transact()
|
|
82
|
-
self._w3.eth.wait_for_transaction_receipt(tx_hash)
|
|
83
|
-
return Web3.to_hex(tx_hash)
|
|
84
|
-
|
|
85
|
-
@convert_web3_error(CLEARING_DIAMOND_ABI, PRODUCT_REGISTRY_ABI)
|
|
86
|
-
def submit_bids(
|
|
87
|
-
self, margin_account_id: str, collateral_asset: str, bids: Iterable[Bid]
|
|
88
|
-
) -> str:
|
|
89
|
-
"""Submit bids to a liquidation auction.
|
|
90
|
-
|
|
91
|
-
Parameters
|
|
92
|
-
----------
|
|
93
|
-
margin_account_id : str
|
|
94
|
-
The ID of the margin account that is being liquidated.
|
|
95
|
-
collateral_asset : str
|
|
96
|
-
The address of the collateral token that the margin account is trading with.
|
|
97
|
-
bids: list of afp.schemas.Bid
|
|
98
|
-
|
|
99
|
-
Returns
|
|
100
|
-
-------
|
|
101
|
-
str
|
|
102
|
-
The hash of the transaction.
|
|
103
|
-
"""
|
|
104
|
-
margin_account_id = validators.validate_address(margin_account_id)
|
|
105
|
-
collateral_asset = validators.validate_address(collateral_asset)
|
|
106
|
-
|
|
107
|
-
converted_bids = [
|
|
108
|
-
BidData(
|
|
109
|
-
product_id=HexBytes(bid.product_id),
|
|
110
|
-
price=int(bid.price * 10 ** self._tick_size(bid.product_id)),
|
|
111
|
-
quantity=bid.quantity,
|
|
112
|
-
side=getattr(OnChainOrderSide, bid.side.name),
|
|
113
|
-
)
|
|
114
|
-
for bid in bids
|
|
115
|
-
]
|
|
116
|
-
|
|
117
|
-
clearing_contract = ClearingDiamond(self._w3)
|
|
118
|
-
tx_hash = clearing_contract.bid_auction(
|
|
119
|
-
margin_account_id, collateral_asset, converted_bids
|
|
120
|
-
).transact()
|
|
121
|
-
self._w3.eth.wait_for_transaction_receipt(tx_hash)
|
|
122
|
-
return Web3.to_hex(tx_hash)
|
|
123
|
-
|
|
124
|
-
### Views ###
|
|
125
|
-
|
|
126
|
-
@convert_web3_error(CLEARING_DIAMOND_ABI)
|
|
127
|
-
def auction_data(
|
|
128
|
-
self, margin_account_id: str, collateral_asset: str
|
|
129
|
-
) -> AuctionData:
|
|
130
|
-
"""Returns information on a liquidation auction.
|
|
131
|
-
|
|
132
|
-
Parameters
|
|
133
|
-
----------
|
|
134
|
-
margin_account_id : str
|
|
135
|
-
The ID of the margin account to be liquidated.
|
|
136
|
-
collateral_asset : str
|
|
137
|
-
The address of the collateral token that the margin account is trading with.
|
|
138
|
-
|
|
139
|
-
Returns
|
|
140
|
-
-------
|
|
141
|
-
str
|
|
142
|
-
The hash of the transaction.
|
|
143
|
-
"""
|
|
144
|
-
margin_account_id = validators.validate_address(margin_account_id)
|
|
145
|
-
collateral_asset = validators.validate_address(collateral_asset)
|
|
146
|
-
|
|
147
|
-
clearing_contract = ClearingDiamond(self._w3)
|
|
148
|
-
data = clearing_contract.auction_data(margin_account_id, collateral_asset)
|
|
149
|
-
divisor = 10 ** self._decimals(collateral_asset)
|
|
150
|
-
return AuctionData(
|
|
151
|
-
start_block=data.start_block,
|
|
152
|
-
margin_account_equity_at_initiation=(
|
|
153
|
-
Decimal(data.mae_at_initiation) / divisor
|
|
154
|
-
),
|
|
155
|
-
maintenance_margin_used_at_initiation=(
|
|
156
|
-
Decimal(data.mmu_at_initiation) / divisor
|
|
157
|
-
),
|
|
158
|
-
margin_account_equity_now=(Decimal(data.mae_now) / divisor),
|
|
159
|
-
maintenance_margin_used_now=(Decimal(data.mmu_now) / divisor),
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
### Internal getters ###
|
|
163
|
-
|
|
164
|
-
@cache
|
|
165
|
-
def _tick_size(self, product_id: str) -> int:
|
|
166
|
-
product_registry_contract = ProductRegistry(self._w3)
|
|
167
|
-
return product_registry_contract.tick_size(HexBytes(product_id))
|
afp_sdk-0.3.0.dist-info/RECORD
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
afp/__init__.py,sha256=LTxZrvSFI5blSuBEsGlyZhFfmrNVV3LpPrdi7aYwiTs,325
|
|
2
|
-
afp/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
afp/api/admin.py,sha256=7ymtCloff4UhyS-MAqA8_cndWlfZanjuGgPgkiV5Jhc,1526
|
|
4
|
-
afp/api/base.py,sha256=iS-sjAc9mME2qOMEvnB6T6x9L_8oeJnHY6h79xrbAOE,2632
|
|
5
|
-
afp/api/builder.py,sha256=mde8XemEMKL76KgEd5rxg7RLBS6lyIfNOEGmE1_iK0M,7114
|
|
6
|
-
afp/api/clearing.py,sha256=nMVjayFkf0XYYP3aKAdgR6NaFSG4Cl_QsEuADRuIO7M,12922
|
|
7
|
-
afp/api/liquidation.py,sha256=CtME5524VVW9mXMMpORyUP205sTVqpLnHIPoTy2MGa8,5439
|
|
8
|
-
afp/api/trading.py,sha256=HjskW4c13CwAB-AwyIsSBcvyXKKEJk7a9768tqcTzUE,10648
|
|
9
|
-
afp/bindings/__init__.py,sha256=_n9xoogYi8AAlSx_PE-wjnwP1ujVyDUwoRM0BSm243U,1271
|
|
10
|
-
afp/bindings/auctioneer_facet.py,sha256=4p906zdU2lUsqpWlsiLE3dlxTPrlNpqk8DtjiQUWJ8M,23919
|
|
11
|
-
afp/bindings/bankruptcy_facet.py,sha256=Yg8sLhDU0crsL1ISSy4eoeQEP5jrAuiWBBlco5MtgPc,11370
|
|
12
|
-
afp/bindings/clearing_facet.py,sha256=DzRzzP9qXQ7kJMcMRwoLwLJ7S-w-2mid_CbF1fOVHaE,34081
|
|
13
|
-
afp/bindings/erc20.py,sha256=-jw7ohcEbUL7g3PpK3-a5_7ClUDCDHt1bezm-w7exzo,10822
|
|
14
|
-
afp/bindings/facade.py,sha256=nZmAp7r26iszxtNyE5imdl_PKbG6vii_3oYJ3Q69iow,2278
|
|
15
|
-
afp/bindings/final_settlement_facet.py,sha256=1U5F3WFvf4GUml3gb90YF9RZK_xCwBsX2zRQ8sWSkR0,9470
|
|
16
|
-
afp/bindings/margin_account.py,sha256=ffkpf5HEXQCxiWuLpgDcHVAiaUVvbKU1Kt0K8tvgZcA,42461
|
|
17
|
-
afp/bindings/margin_account_registry.py,sha256=mx9sAU6HuC09d-LAf9bzP57HPLa3M6qXpN7Lj-uiXSc,18800
|
|
18
|
-
afp/bindings/mark_price_tracker_facet.py,sha256=vnVsAmpts_2Sv9Jmx3JlON8X8FJd9D2jOFhqSwXIA7A,2830
|
|
19
|
-
afp/bindings/oracle_provider.py,sha256=CMpVAXdUuTP_W9ZE297B-m9MjuW90yCOhNLMVl3kCf0,15863
|
|
20
|
-
afp/bindings/product_registry.py,sha256=HFWwbFKvXk0A2dZB6KBa0Ul8-vX9uvvtGj0dhRL9UUw,43701
|
|
21
|
-
afp/bindings/system_viewer.py,sha256=Kwi-Kz2oKh5qWy17N0D2LyrAbkKz_sW9OxeWh6VX_j8,41347
|
|
22
|
-
afp/bindings/trading_protocol.py,sha256=ZloF3REbjFq9v0UGVsM0_Lk0EhfWJKdeJ0PzVEnyZo0,39573
|
|
23
|
-
afp/config.py,sha256=GbfvtsRkRDas4L-s1E-9AB7RitrN9JRQ79R5zfv6Ha0,1190
|
|
24
|
-
afp/decorators.py,sha256=Ustc15RbXGYIEqDb9lXnd-bdhZJ8ZrztN4h_vjkLsG0,2692
|
|
25
|
-
afp/enums.py,sha256=4dglBx4Amcu0GrlJn0cIj-rp9uDHZGfDEP_vMAO02xo,485
|
|
26
|
-
afp/exceptions.py,sha256=RE8IE6akDgbar2PobdpOiBdGZZCYkb4jWf1ozJmdLaI,342
|
|
27
|
-
afp/exchange.py,sha256=K_SkVyRvs7ebW82BGbxND1r5UHzb4_TNRfkOOIG-Dvs,5444
|
|
28
|
-
afp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
-
afp/schemas.py,sha256=8nlNPq6t_jmYEpa_WWhOIr_yvpQv5tj86uvpGTNHWZY,4996
|
|
30
|
-
afp/signing.py,sha256=7fohnAvoiDA4ems_3OcVnr16OmYLSg9NnnCSzDplg6s,2235
|
|
31
|
-
afp/validators.py,sha256=m61ZpP385CxsdDGJavPkXKTXnJAHKLCzedoZ8mL6daI,1818
|
|
32
|
-
afp_sdk-0.3.0.dist-info/licenses/LICENSE,sha256=ZdaKItgc2ppfqta2OJV0oHpSJiK87PUxmUkUo-_0SB8,1065
|
|
33
|
-
afp_sdk-0.3.0.dist-info/WHEEL,sha256=Jb20R3Ili4n9P1fcwuLup21eQ5r9WXhs4_qy7VTrgPI,79
|
|
34
|
-
afp_sdk-0.3.0.dist-info/METADATA,sha256=YJmCZfdcfYbJxL2DTDKNuoiPZW0SEb13aOVgxtRgzoc,6026
|
|
35
|
-
afp_sdk-0.3.0.dist-info/RECORD,,
|
|
File without changes
|