afp-sdk 0.5.0__py3-none-any.whl → 0.5.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/api/admin.py +34 -7
- afp/api/product.py +35 -7
- afp/auth.py +1 -1
- afp/enums.py +6 -0
- afp/exchange.py +15 -6
- afp/schemas.py +14 -3
- {afp_sdk-0.5.0.dist-info → afp_sdk-0.5.1.dist-info}/METADATA +1 -1
- {afp_sdk-0.5.0.dist-info → afp_sdk-0.5.1.dist-info}/RECORD +10 -10
- {afp_sdk-0.5.0.dist-info → afp_sdk-0.5.1.dist-info}/WHEEL +1 -1
- {afp_sdk-0.5.0.dist-info → afp_sdk-0.5.1.dist-info}/licenses/LICENSE +0 -0
afp/api/admin.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .. import validators
|
|
2
2
|
from ..decorators import refresh_token_on_expiry
|
|
3
|
-
from ..
|
|
3
|
+
from ..enums import ListingState
|
|
4
|
+
from ..schemas import ExchangeProductListingSubmission, ExchangeProductUpdateSubmission
|
|
4
5
|
from .base import ExchangeAPI
|
|
5
6
|
|
|
6
7
|
|
|
@@ -8,8 +9,26 @@ class Admin(ExchangeAPI):
|
|
|
8
9
|
"""API for AutEx administration, restricted to AutEx admins."""
|
|
9
10
|
|
|
10
11
|
@refresh_token_on_expiry
|
|
11
|
-
def
|
|
12
|
-
"""
|
|
12
|
+
def list_product(self, product_id: str) -> None:
|
|
13
|
+
"""Lists a product on the exchange.
|
|
14
|
+
|
|
15
|
+
The product is in private state after listing until it is revealed to the public.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
product_id : str
|
|
20
|
+
|
|
21
|
+
Raises
|
|
22
|
+
------
|
|
23
|
+
afp.exceptions.AuthorizationError
|
|
24
|
+
If the configured account is not an exchange administrator.
|
|
25
|
+
"""
|
|
26
|
+
product_listing = ExchangeProductListingSubmission(id=product_id)
|
|
27
|
+
self._exchange.list_product(product_listing)
|
|
28
|
+
|
|
29
|
+
@refresh_token_on_expiry
|
|
30
|
+
def reveal_product(self, product_id: str) -> None:
|
|
31
|
+
"""Makes a product publicly available for trading on the exchange.
|
|
13
32
|
|
|
14
33
|
Parameters
|
|
15
34
|
----------
|
|
@@ -20,8 +39,12 @@ class Admin(ExchangeAPI):
|
|
|
20
39
|
afp.exceptions.AuthorizationError
|
|
21
40
|
If the configured account is not an exchange administrator.
|
|
22
41
|
"""
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
product_update = ExchangeProductUpdateSubmission(
|
|
43
|
+
listing_state=ListingState.PUBLIC
|
|
44
|
+
)
|
|
45
|
+
self._exchange.update_product_listing(
|
|
46
|
+
validators.validate_hexstr32(product_id), product_update
|
|
47
|
+
)
|
|
25
48
|
|
|
26
49
|
@refresh_token_on_expiry
|
|
27
50
|
def delist_product(self, product_id: str) -> None:
|
|
@@ -38,5 +61,9 @@ class Admin(ExchangeAPI):
|
|
|
38
61
|
afp.exceptions.AuthorizationError
|
|
39
62
|
If the configured account is not an exchange administrator.
|
|
40
63
|
"""
|
|
41
|
-
|
|
42
|
-
|
|
64
|
+
product_update = ExchangeProductUpdateSubmission(
|
|
65
|
+
listing_state=ListingState.DELISTED
|
|
66
|
+
)
|
|
67
|
+
self._exchange.update_product_listing(
|
|
68
|
+
validators.validate_hexstr32(product_id), product_update
|
|
69
|
+
)
|
afp/api/product.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from datetime import datetime
|
|
2
3
|
from decimal import Decimal
|
|
3
|
-
from typing import cast
|
|
4
|
+
from typing import Any, cast
|
|
4
5
|
|
|
5
6
|
from eth_typing.evm import ChecksumAddress
|
|
6
7
|
from hexbytes import HexBytes
|
|
@@ -29,7 +30,7 @@ class Product(ClearingSystemAPI):
|
|
|
29
30
|
### Factories ###
|
|
30
31
|
|
|
31
32
|
@convert_web3_error()
|
|
32
|
-
def
|
|
33
|
+
def create(
|
|
33
34
|
self,
|
|
34
35
|
*,
|
|
35
36
|
symbol: str,
|
|
@@ -117,15 +118,24 @@ class Product(ClearingSystemAPI):
|
|
|
117
118
|
extended_metadata=extended_metadata,
|
|
118
119
|
)
|
|
119
120
|
|
|
121
|
+
def create_product(self, **kwargs: Any) -> ProductSpecification:
|
|
122
|
+
"""Deprecated alias of `Product.create`."""
|
|
123
|
+
warnings.warn(
|
|
124
|
+
"Product.create_product() is deprecated. Use Product.create() instead.",
|
|
125
|
+
DeprecationWarning,
|
|
126
|
+
stacklevel=2,
|
|
127
|
+
)
|
|
128
|
+
return self.create(**kwargs)
|
|
129
|
+
|
|
120
130
|
### Transactions ###
|
|
121
131
|
|
|
122
132
|
@convert_web3_error(PRODUCT_REGISTRY_ABI)
|
|
123
|
-
def
|
|
133
|
+
def register(self, product_specification: ProductSpecification) -> Transaction:
|
|
124
134
|
"""Submits a product specification to the clearing system.
|
|
125
135
|
|
|
126
136
|
Parameters
|
|
127
137
|
----------
|
|
128
|
-
|
|
138
|
+
product_specification : afp.schemas.ProductSpecification
|
|
129
139
|
|
|
130
140
|
Returns
|
|
131
141
|
-------
|
|
@@ -133,7 +143,7 @@ class Product(ClearingSystemAPI):
|
|
|
133
143
|
Transaction parameters.
|
|
134
144
|
"""
|
|
135
145
|
erc20_contract = ERC20(
|
|
136
|
-
self._w3, cast(ChecksumAddress,
|
|
146
|
+
self._w3, cast(ChecksumAddress, product_specification.collateral_asset)
|
|
137
147
|
)
|
|
138
148
|
decimals = erc20_contract.decimals()
|
|
139
149
|
|
|
@@ -142,10 +152,19 @@ class Product(ClearingSystemAPI):
|
|
|
142
152
|
)
|
|
143
153
|
return self._transact(
|
|
144
154
|
product_registry_contract.register(
|
|
145
|
-
self._convert_product_specification(
|
|
155
|
+
self._convert_product_specification(product_specification, decimals)
|
|
146
156
|
)
|
|
147
157
|
)
|
|
148
158
|
|
|
159
|
+
def register_product(self, product: ProductSpecification) -> Transaction:
|
|
160
|
+
"""Deprecated alias of `Product.register`."""
|
|
161
|
+
warnings.warn(
|
|
162
|
+
"Product.register_product() is deprecated. Use Product.register() instead.",
|
|
163
|
+
DeprecationWarning,
|
|
164
|
+
stacklevel=2,
|
|
165
|
+
)
|
|
166
|
+
return self.register(product)
|
|
167
|
+
|
|
149
168
|
@convert_web3_error(CLEARING_DIAMOND_ABI)
|
|
150
169
|
def initiate_final_settlement(
|
|
151
170
|
self, product_id: str, accounts: list[str]
|
|
@@ -181,7 +200,7 @@ class Product(ClearingSystemAPI):
|
|
|
181
200
|
### Views ###
|
|
182
201
|
|
|
183
202
|
@convert_web3_error(PRODUCT_REGISTRY_ABI)
|
|
184
|
-
def
|
|
203
|
+
def state(self, product_id: str) -> str:
|
|
185
204
|
"""Returns the current state of a product.
|
|
186
205
|
|
|
187
206
|
Parameters
|
|
@@ -200,6 +219,15 @@ class Product(ClearingSystemAPI):
|
|
|
200
219
|
state = product_registry_contract.state(HexBytes(product_id))
|
|
201
220
|
return state.name
|
|
202
221
|
|
|
222
|
+
def product_state(self, product_id: str) -> str:
|
|
223
|
+
"""Deprecated alias of `Product.state`."""
|
|
224
|
+
warnings.warn(
|
|
225
|
+
"Product.product_state() is deprecated. Use Product.state() instead.",
|
|
226
|
+
DeprecationWarning,
|
|
227
|
+
stacklevel=2,
|
|
228
|
+
)
|
|
229
|
+
return self.state(product_id)
|
|
230
|
+
|
|
203
231
|
@convert_web3_error(PRODUCT_REGISTRY_ABI)
|
|
204
232
|
def collateral_asset(self, product_id: str) -> str:
|
|
205
233
|
"""Returns the collateral asset of a product.
|
afp/auth.py
CHANGED
afp/enums.py
CHANGED
afp/exchange.py
CHANGED
|
@@ -16,7 +16,8 @@ from .exceptions import (
|
|
|
16
16
|
from .schemas import (
|
|
17
17
|
ExchangeParameters,
|
|
18
18
|
ExchangeProduct,
|
|
19
|
-
|
|
19
|
+
ExchangeProductListingSubmission,
|
|
20
|
+
ExchangeProductUpdateSubmission,
|
|
20
21
|
LoginSubmission,
|
|
21
22
|
MarketDepthData,
|
|
22
23
|
Order,
|
|
@@ -60,14 +61,22 @@ class ExchangeClient:
|
|
|
60
61
|
return ExchangeProduct(**response.json())
|
|
61
62
|
|
|
62
63
|
# POST /products
|
|
63
|
-
def
|
|
64
|
+
def list_product(
|
|
65
|
+
self, listing_submission: ExchangeProductListingSubmission
|
|
66
|
+
) -> None:
|
|
64
67
|
self._send_request(
|
|
65
|
-
"POST", "/products", data=
|
|
68
|
+
"POST", "/products", data=listing_submission.model_dump_json()
|
|
66
69
|
)
|
|
67
70
|
|
|
68
|
-
#
|
|
69
|
-
def
|
|
70
|
-
self
|
|
71
|
+
# PATCH /products
|
|
72
|
+
def update_product_listing(
|
|
73
|
+
self, product_id: str, update_submission: ExchangeProductUpdateSubmission
|
|
74
|
+
) -> None:
|
|
75
|
+
self._send_request(
|
|
76
|
+
"PATCH",
|
|
77
|
+
f"/products/{product_id}",
|
|
78
|
+
data=update_submission.model_dump_json(),
|
|
79
|
+
)
|
|
71
80
|
|
|
72
81
|
# POST /orders
|
|
73
82
|
def submit_order(self, order_submission: OrderSubmission) -> Order:
|
afp/schemas.py
CHANGED
|
@@ -15,7 +15,7 @@ from pydantic import (
|
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
from . import validators
|
|
18
|
-
from .enums import OrderSide, OrderState, OrderType, TradeState
|
|
18
|
+
from .enums import ListingState, OrderSide, OrderState, OrderType, TradeState
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
# Use datetime internally but UNIX timestamp in client-server communication
|
|
@@ -53,18 +53,26 @@ class ExchangeParameters(Model):
|
|
|
53
53
|
trading_fee_rate: Decimal
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
#
|
|
56
|
+
# Admin API
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
class
|
|
59
|
+
class ExchangeProductListingSubmission(Model):
|
|
60
60
|
id: Annotated[str, AfterValidator(validators.validate_hexstr32)]
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
class ExchangeProductUpdateSubmission(Model):
|
|
64
|
+
listing_state: ListingState
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# Trading API
|
|
68
|
+
|
|
69
|
+
|
|
63
70
|
class ExchangeProduct(Model):
|
|
64
71
|
id: str
|
|
65
72
|
symbol: str
|
|
66
73
|
tick_size: int
|
|
67
74
|
collateral_asset: str
|
|
75
|
+
listing_state: ListingState
|
|
68
76
|
|
|
69
77
|
def __str__(self) -> str:
|
|
70
78
|
return self.id
|
|
@@ -197,6 +205,9 @@ class ProductSpecification(Model):
|
|
|
197
205
|
tradeout_interval: Annotated[int, Field(ge=0)]
|
|
198
206
|
extended_metadata: str
|
|
199
207
|
|
|
208
|
+
def __str__(self) -> str:
|
|
209
|
+
return self.id
|
|
210
|
+
|
|
200
211
|
|
|
201
212
|
# Liquidation API
|
|
202
213
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
afp/__init__.py,sha256=tvvXz4miC3QI8wy4vjAAf_LtL-19eEgBRA6dnrh3LA8,349
|
|
2
2
|
afp/afp.py,sha256=1xpocnWjALP6QlA-Hn7G2znttJ-ikcb2WA9sLueY3zc,9107
|
|
3
3
|
afp/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
afp/api/admin.py,sha256=
|
|
4
|
+
afp/api/admin.py,sha256=6TiWCo0SB41CtXYTkTYYGQY7MrdB6OMTyU3-0J0V_7o,2170
|
|
5
5
|
afp/api/base.py,sha256=5X1joEwFX4gxYUDCSTvp_hSFCfLZCktnW-UtZFxDquk,4471
|
|
6
6
|
afp/api/margin_account.py,sha256=sC1DF7J3QTHR7cXcRjTG33oZswVy6qr9xnevQbrQ-ew,15256
|
|
7
|
-
afp/api/product.py,sha256=
|
|
7
|
+
afp/api/product.py,sha256=2N4bPBahuw19GcBbBL20oQ5RFRuUxa5LOZzmN7hs39U,10156
|
|
8
8
|
afp/api/trading.py,sha256=exQQ3LJA6XCbRAUBuYVjSJ5PHFi4COyqDORxC37LLfQ,10379
|
|
9
|
-
afp/auth.py,sha256=
|
|
9
|
+
afp/auth.py,sha256=sV_9E6CgRWV1xYoppc4IdrnqNo5ZNDBIp6QF3fQbMWE,2055
|
|
10
10
|
afp/bindings/__init__.py,sha256=_n9xoogYi8AAlSx_PE-wjnwP1ujVyDUwoRM0BSm243U,1271
|
|
11
11
|
afp/bindings/auctioneer_facet.py,sha256=4p906zdU2lUsqpWlsiLE3dlxTPrlNpqk8DtjiQUWJ8M,23919
|
|
12
12
|
afp/bindings/bankruptcy_facet.py,sha256=-Kp4Ap5PLAmo_tFrp-1s_yAh0mtHS20z3BC5YIrVjrU,12548
|
|
@@ -24,14 +24,14 @@ afp/bindings/trading_protocol.py,sha256=ZloF3REbjFq9v0UGVsM0_Lk0EhfWJKdeJ0PzVEny
|
|
|
24
24
|
afp/config.py,sha256=_WKywiuty8poE1A0v46uBe1JGpfCzRlxCPamKennfpE,699
|
|
25
25
|
afp/constants.py,sha256=XIph4R0Tx-BPw_NZJgWUtb7NdS9sYzEciFRSStm3VMs,1840
|
|
26
26
|
afp/decorators.py,sha256=SEUQtbgPGc4iVPtBQV2eiCejcDAVImmXcI0uPXFhtJA,2774
|
|
27
|
-
afp/enums.py,sha256=
|
|
27
|
+
afp/enums.py,sha256=U5b_3RteMiVJozp4WYAKzUfPXI1RdJLEK19jAg-LN8Q,588
|
|
28
28
|
afp/exceptions.py,sha256=frdS-EH84K0fOf92RgRgNkTe3VII2m36XNCS8eyXLLM,390
|
|
29
|
-
afp/exchange.py,sha256=
|
|
29
|
+
afp/exchange.py,sha256=MXQ-RhcI76l6bA9_IDTUq0RQGfwxBisrRhl6eC_yH4I,5983
|
|
30
30
|
afp/hashing.py,sha256=gBCWN93-ydRPlgnnorSvDQlylcnglrAypRDb-1K-20I,1949
|
|
31
31
|
afp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
afp/schemas.py,sha256=
|
|
32
|
+
afp/schemas.py,sha256=M6qr0GhCeT7KevzOso5dIhydYzaYx78Rs66IWdadJO8,5284
|
|
33
33
|
afp/validators.py,sha256=zQvPu3HDu6ADnEE72EJlS5hc1-xfru78Mzd74s1u_EM,1841
|
|
34
|
-
afp_sdk-0.5.
|
|
35
|
-
afp_sdk-0.5.
|
|
36
|
-
afp_sdk-0.5.
|
|
37
|
-
afp_sdk-0.5.
|
|
34
|
+
afp_sdk-0.5.1.dist-info/licenses/LICENSE,sha256=ZdaKItgc2ppfqta2OJV0oHpSJiK87PUxmUkUo-_0SB8,1065
|
|
35
|
+
afp_sdk-0.5.1.dist-info/WHEEL,sha256=lh7MMMfiuFQLQaR9J7pNBODdWf-aa5UOeuuDAol3xps,79
|
|
36
|
+
afp_sdk-0.5.1.dist-info/METADATA,sha256=RM6EyQq2W_ZlrkRtYcGf85pZg7S15poSNJq7CUEHz0w,6354
|
|
37
|
+
afp_sdk-0.5.1.dist-info/RECORD,,
|
|
File without changes
|