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.
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 +10 -19
  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 +10 -0
  27. afp/exchange.py +10 -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 +236 -177
  40. afp/types.py +169 -0
  41. afp/validators.py +218 -8
  42. {afp_sdk-0.5.4.dist-info → afp_sdk-0.6.1.dist-info}/METADATA +76 -11
  43. afp_sdk-0.6.1.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.4.dist-info/RECORD +0 -37
  48. {afp_sdk-0.5.4.dist-info → afp_sdk-0.6.1.dist-info}/WHEEL +0 -0
  49. {afp_sdk-0.5.4.dist-info → afp_sdk-0.6.1.dist-info}/licenses/LICENSE +0 -0
@@ -7,6 +7,7 @@ import typing
7
7
  import eth_typing
8
8
  import hexbytes
9
9
  import web3
10
+ from web3 import types
10
11
  from web3.contract import contract
11
12
 
12
13
 
@@ -35,12 +36,15 @@ class MarkPriceTrackerFacet:
35
36
  def valuation(
36
37
  self,
37
38
  product_id: hexbytes.HexBytes,
39
+ block_identifier: types.BlockIdentifier = "latest",
38
40
  ) -> int:
39
41
  """Binding for `valuation` on the MarkPriceTrackerFacet contract.
40
42
 
41
43
  Parameters
42
44
  ----------
43
45
  product_id : hexbytes.HexBytes
46
+ block_identifier : web3.types.BlockIdentifier
47
+ The block identifier, defaults to the latest block.
44
48
 
45
49
  Returns
46
50
  -------
@@ -48,7 +52,7 @@ class MarkPriceTrackerFacet:
48
52
  """
49
53
  return_value = self._contract.functions.valuation(
50
54
  product_id,
51
- ).call()
55
+ ).call(block_identifier=block_identifier)
52
56
  return int(return_value)
53
57
 
54
58
  def valuation_after_trade(
@@ -56,6 +60,7 @@ class MarkPriceTrackerFacet:
56
60
  product_id: hexbytes.HexBytes,
57
61
  price: int,
58
62
  quantity: int,
63
+ block_identifier: types.BlockIdentifier = "latest",
59
64
  ) -> int:
60
65
  """Binding for `valuationAfterTrade` on the MarkPriceTrackerFacet contract.
61
66
 
@@ -64,6 +69,8 @@ class MarkPriceTrackerFacet:
64
69
  product_id : hexbytes.HexBytes
65
70
  price : int
66
71
  quantity : int
72
+ block_identifier : web3.types.BlockIdentifier
73
+ The block identifier, defaults to the latest block.
67
74
 
68
75
  Returns
69
76
  -------
@@ -73,7 +80,7 @@ class MarkPriceTrackerFacet:
73
80
  product_id,
74
81
  price,
75
82
  quantity,
76
- ).call()
83
+ ).call(block_identifier=block_identifier)
77
84
  return int(return_value)
78
85
 
79
86
 
@@ -81,31 +88,82 @@ ABI = typing.cast(
81
88
  eth_typing.ABI,
82
89
  [
83
90
  {
91
+ "type": "function",
92
+ "name": "valuation",
84
93
  "inputs": [
85
- {"internalType": "bytes32", "name": "productId", "type": "bytes32"}
94
+ {"name": "productId", "type": "bytes32", "internalType": "bytes32"}
86
95
  ],
87
- "name": "NoTradeData",
88
- "type": "error",
96
+ "outputs": [{"name": "", "type": "int256", "internalType": "int256"}],
97
+ "stateMutability": "view",
89
98
  },
90
99
  {
100
+ "type": "function",
101
+ "name": "valuationAfterTrade",
91
102
  "inputs": [
92
- {"internalType": "bytes32", "name": "productId", "type": "bytes32"}
103
+ {"name": "productId", "type": "bytes32", "internalType": "bytes32"},
104
+ {"name": "price", "type": "int256", "internalType": "int256"},
105
+ {"name": "quantity", "type": "uint256", "internalType": "uint256"},
93
106
  ],
94
- "name": "valuation",
95
- "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
107
+ "outputs": [{"name": "", "type": "int256", "internalType": "int256"}],
96
108
  "stateMutability": "view",
97
- "type": "function",
98
109
  },
110
+ {"type": "error", "name": "EVWMA_NotInitialized", "inputs": []},
99
111
  {
112
+ "type": "error",
113
+ "name": "InvalidFieldAccess",
100
114
  "inputs": [
101
- {"internalType": "bytes32", "name": "productId", "type": "bytes32"},
102
- {"internalType": "uint256", "name": "price", "type": "uint256"},
103
- {"internalType": "uint256", "name": "quantity", "type": "uint256"},
115
+ {
116
+ "name": "productType",
117
+ "type": "uint8",
118
+ "internalType": "enum ProductType",
119
+ },
120
+ {"name": "field", "type": "string", "internalType": "string"},
121
+ ],
122
+ },
123
+ {
124
+ "type": "error",
125
+ "name": "PRBMath_MulDiv18_Overflow",
126
+ "inputs": [
127
+ {"name": "x", "type": "uint256", "internalType": "uint256"},
128
+ {"name": "y", "type": "uint256", "internalType": "uint256"},
129
+ ],
130
+ },
131
+ {
132
+ "type": "error",
133
+ "name": "PRBMath_MulDiv_Overflow",
134
+ "inputs": [
135
+ {"name": "x", "type": "uint256", "internalType": "uint256"},
136
+ {"name": "y", "type": "uint256", "internalType": "uint256"},
137
+ {"name": "denominator", "type": "uint256", "internalType": "uint256"},
138
+ ],
139
+ },
140
+ {"type": "error", "name": "PRBMath_SD59x18_Div_InputTooSmall", "inputs": []},
141
+ {
142
+ "type": "error",
143
+ "name": "PRBMath_SD59x18_Div_Overflow",
144
+ "inputs": [
145
+ {"name": "x", "type": "int256", "internalType": "SD59x18"},
146
+ {"name": "y", "type": "int256", "internalType": "SD59x18"},
147
+ ],
148
+ },
149
+ {
150
+ "type": "error",
151
+ "name": "PRBMath_SD59x18_Exp2_InputTooBig",
152
+ "inputs": [{"name": "x", "type": "int256", "internalType": "SD59x18"}],
153
+ },
154
+ {
155
+ "type": "error",
156
+ "name": "PRBMath_SD59x18_Exp_InputTooBig",
157
+ "inputs": [{"name": "x", "type": "int256", "internalType": "SD59x18"}],
158
+ },
159
+ {"type": "error", "name": "PRBMath_SD59x18_Mul_InputTooSmall", "inputs": []},
160
+ {
161
+ "type": "error",
162
+ "name": "PRBMath_SD59x18_Mul_Overflow",
163
+ "inputs": [
164
+ {"name": "x", "type": "int256", "internalType": "SD59x18"},
165
+ {"name": "y", "type": "int256", "internalType": "SD59x18"},
104
166
  ],
105
- "name": "valuationAfterTrade",
106
- "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
107
- "stateMutability": "view",
108
- "type": "function",
109
167
  },
110
168
  ],
111
169
  )