ddx-python 1.0.5__cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.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 (104) hide show
  1. ddx/.gitignore +1 -0
  2. ddx/__init__.py +58 -0
  3. ddx/_rust/__init__.pyi +2009 -0
  4. ddx/_rust/common/__init__.pyi +17 -0
  5. ddx/_rust/common/accounting.pyi +6 -0
  6. ddx/_rust/common/enums.pyi +3 -0
  7. ddx/_rust/common/requests/__init__.pyi +21 -0
  8. ddx/_rust/common/requests/intents.pyi +19 -0
  9. ddx/_rust/common/specs.pyi +17 -0
  10. ddx/_rust/common/state/__init__.pyi +41 -0
  11. ddx/_rust/common/state/keys.pyi +29 -0
  12. ddx/_rust/common/transactions.pyi +7 -0
  13. ddx/_rust/decimal.pyi +3 -0
  14. ddx/_rust/h256.pyi +3 -0
  15. ddx/_rust.abi3.so +0 -0
  16. ddx/app_config/ethereum/addresses.json +541 -0
  17. ddx/auditor/README.md +32 -0
  18. ddx/auditor/__init__.py +0 -0
  19. ddx/auditor/auditor_driver.py +1034 -0
  20. ddx/auditor/websocket_message.py +54 -0
  21. ddx/common/__init__.py +0 -0
  22. ddx/common/epoch_params.py +28 -0
  23. ddx/common/fill_context.py +144 -0
  24. ddx/common/item_utils.py +38 -0
  25. ddx/common/logging.py +184 -0
  26. ddx/common/market_specs.py +64 -0
  27. ddx/common/trade_mining_params.py +19 -0
  28. ddx/common/transaction_utils.py +85 -0
  29. ddx/common/transactions/__init__.py +0 -0
  30. ddx/common/transactions/advance_epoch.py +91 -0
  31. ddx/common/transactions/advance_settlement_epoch.py +63 -0
  32. ddx/common/transactions/all_price_checkpoints.py +84 -0
  33. ddx/common/transactions/cancel.py +76 -0
  34. ddx/common/transactions/cancel_all.py +88 -0
  35. ddx/common/transactions/complete_fill.py +103 -0
  36. ddx/common/transactions/disaster_recovery.py +97 -0
  37. ddx/common/transactions/event.py +48 -0
  38. ddx/common/transactions/fee_distribution.py +119 -0
  39. ddx/common/transactions/funding.py +294 -0
  40. ddx/common/transactions/futures_expiry.py +123 -0
  41. ddx/common/transactions/genesis.py +108 -0
  42. ddx/common/transactions/inner/__init__.py +0 -0
  43. ddx/common/transactions/inner/adl_outcome.py +25 -0
  44. ddx/common/transactions/inner/fill.py +227 -0
  45. ddx/common/transactions/inner/liquidated_position.py +41 -0
  46. ddx/common/transactions/inner/liquidation_entry.py +41 -0
  47. ddx/common/transactions/inner/liquidation_fill.py +118 -0
  48. ddx/common/transactions/inner/outcome.py +32 -0
  49. ddx/common/transactions/inner/trade_fill.py +125 -0
  50. ddx/common/transactions/insurance_fund_update.py +142 -0
  51. ddx/common/transactions/insurance_fund_withdraw.py +99 -0
  52. ddx/common/transactions/liquidation.py +357 -0
  53. ddx/common/transactions/partial_fill.py +125 -0
  54. ddx/common/transactions/pnl_realization.py +122 -0
  55. ddx/common/transactions/post.py +72 -0
  56. ddx/common/transactions/post_order.py +95 -0
  57. ddx/common/transactions/price_checkpoint.py +96 -0
  58. ddx/common/transactions/signer_registered.py +62 -0
  59. ddx/common/transactions/specs_update.py +61 -0
  60. ddx/common/transactions/strategy_update.py +156 -0
  61. ddx/common/transactions/tradable_product_update.py +98 -0
  62. ddx/common/transactions/trade_mining.py +147 -0
  63. ddx/common/transactions/trader_update.py +105 -0
  64. ddx/common/transactions/withdraw.py +91 -0
  65. ddx/common/transactions/withdraw_ddx.py +74 -0
  66. ddx/common/utils.py +176 -0
  67. ddx/config.py +17 -0
  68. ddx/derivadex_client.py +254 -0
  69. ddx/py.typed +0 -0
  70. ddx/realtime_client/__init__.py +2 -0
  71. ddx/realtime_client/config.py +2 -0
  72. ddx/realtime_client/logs/pytest.log +0 -0
  73. ddx/realtime_client/models/__init__.py +683 -0
  74. ddx/realtime_client/realtime_client.py +567 -0
  75. ddx/rest_client/__init__.py +0 -0
  76. ddx/rest_client/clients/__init__.py +0 -0
  77. ddx/rest_client/clients/base_client.py +60 -0
  78. ddx/rest_client/clients/market_client.py +1241 -0
  79. ddx/rest_client/clients/on_chain_client.py +432 -0
  80. ddx/rest_client/clients/signed_client.py +301 -0
  81. ddx/rest_client/clients/system_client.py +843 -0
  82. ddx/rest_client/clients/trade_client.py +335 -0
  83. ddx/rest_client/constants/__init__.py +0 -0
  84. ddx/rest_client/constants/endpoints.py +67 -0
  85. ddx/rest_client/contracts/__init__.py +0 -0
  86. ddx/rest_client/contracts/checkpoint/__init__.py +560 -0
  87. ddx/rest_client/contracts/ddx/__init__.py +1949 -0
  88. ddx/rest_client/contracts/dummy_token/__init__.py +1014 -0
  89. ddx/rest_client/contracts/i_collateral/__init__.py +1414 -0
  90. ddx/rest_client/contracts/i_stake/__init__.py +696 -0
  91. ddx/rest_client/exceptions/__init__.py +0 -0
  92. ddx/rest_client/exceptions/exceptions.py +32 -0
  93. ddx/rest_client/http/__init__.py +0 -0
  94. ddx/rest_client/http/http_client.py +305 -0
  95. ddx/rest_client/models/__init__.py +0 -0
  96. ddx/rest_client/models/market.py +683 -0
  97. ddx/rest_client/models/signed.py +60 -0
  98. ddx/rest_client/models/system.py +390 -0
  99. ddx/rest_client/models/trade.py +140 -0
  100. ddx/rest_client/utils/__init__.py +0 -0
  101. ddx/rest_client/utils/encryption_utils.py +26 -0
  102. ddx_python-1.0.5.dist-info/METADATA +63 -0
  103. ddx_python-1.0.5.dist-info/RECORD +104 -0
  104. ddx_python-1.0.5.dist-info/WHEEL +4 -0
@@ -0,0 +1,1414 @@
1
+ """Generated wrapper for ICollateral Solidity contract."""
2
+
3
+ # pylint: disable=too-many-arguments
4
+
5
+ import json
6
+ from typing import ( # pylint: disable=unused-import
7
+ Any,
8
+ List,
9
+ Optional,
10
+ Tuple,
11
+ Union,
12
+ )
13
+
14
+ from eth_utils import to_checksum_address
15
+ from mypy_extensions import TypedDict # pylint: disable=unused-import
16
+ from hexbytes import HexBytes
17
+ from web3 import Web3
18
+ from web3.datastructures import AttributeDict
19
+ from web3.providers.base import BaseProvider
20
+
21
+ from zero_ex.contract_wrappers.bases import ContractMethod, Validator
22
+ from zero_ex.contract_wrappers.tx_params import TxParams
23
+
24
+
25
+ # Try to import a custom validator class definition; if there isn't one,
26
+ # declare one that we can instantiate for the default argument to the
27
+ # constructor for ICollateral below.
28
+ try:
29
+ # both mypy and pylint complain about what we're doing here, but this
30
+ # works just fine, so their messages have been disabled here.
31
+ from . import ( # type: ignore # pylint: disable=import-self
32
+ ICollateralValidator,
33
+ )
34
+ except ImportError:
35
+
36
+ class ICollateralValidator( # type: ignore
37
+ Validator
38
+ ):
39
+ """No-op input validator."""
40
+
41
+
42
+ try:
43
+ from .middleware import MIDDLEWARE # type: ignore
44
+ except ImportError:
45
+ pass
46
+
47
+
48
+ class SharedDefsBalance256(TypedDict):
49
+ """Python representation of a tuple or struct.
50
+
51
+ Solidity compiler output does not include the names of structs that appear
52
+ in method definitions. A tuple found in an ABI may have been written in
53
+ Solidity as a literal, anonymous tuple, or it may have been written as a
54
+ named `struct`:code:, but there is no way to tell from the compiler
55
+ output. This class represents a tuple that appeared in a method
56
+ definition. Its name is derived from a hash of that tuple's field names,
57
+ and every method whose ABI refers to a tuple with that same list of field
58
+ names will have a generated wrapper method that refers to this class.
59
+
60
+ Any members of type `bytes`:code: should be encoded as UTF-8, which can be
61
+ accomplished via `str.encode("utf_8")`:code:
62
+ """
63
+
64
+ tokens: List[str]
65
+
66
+ amounts: List[int]
67
+
68
+
69
+ class SharedDefsBalance128(TypedDict):
70
+ """Python representation of a tuple or struct.
71
+
72
+ Solidity compiler output does not include the names of structs that appear
73
+ in method definitions. A tuple found in an ABI may have been written in
74
+ Solidity as a literal, anonymous tuple, or it may have been written as a
75
+ named `struct`:code:, but there is no way to tell from the compiler
76
+ output. This class represents a tuple that appeared in a method
77
+ definition. Its name is derived from a hash of that tuple's field names,
78
+ and every method whose ABI refers to a tuple with that same list of field
79
+ names will have a generated wrapper method that refers to this class.
80
+
81
+ Any members of type `bytes`:code: should be encoded as UTF-8, which can be
82
+ accomplished via `str.encode("utf_8")`:code:
83
+ """
84
+
85
+ tokens: List[str]
86
+
87
+ amounts: List[int]
88
+
89
+
90
+ class DepositDefsStrategyData(TypedDict):
91
+ """Python representation of a tuple or struct.
92
+
93
+ Solidity compiler output does not include the names of structs that appear
94
+ in method definitions. A tuple found in an ABI may have been written in
95
+ Solidity as a literal, anonymous tuple, or it may have been written as a
96
+ named `struct`:code:, but there is no way to tell from the compiler
97
+ output. This class represents a tuple that appeared in a method
98
+ definition. Its name is derived from a hash of that tuple's field names,
99
+ and every method whose ABI refers to a tuple with that same list of field
100
+ names will have a generated wrapper method that refers to this class.
101
+
102
+ Any members of type `bytes`:code: should be encoded as UTF-8, which can be
103
+ accomplished via `str.encode("utf_8")`:code:
104
+ """
105
+
106
+ availCollateral: SharedDefsBalance256
107
+
108
+ lockedCollateral: SharedDefsBalance128
109
+
110
+ maxLeverage: int
111
+
112
+ frozen: bool
113
+
114
+
115
+ class DepositDefsExchangeCollateral(TypedDict):
116
+ """Python representation of a tuple or struct.
117
+
118
+ Solidity compiler output does not include the names of structs that appear
119
+ in method definitions. A tuple found in an ABI may have been written in
120
+ Solidity as a literal, anonymous tuple, or it may have been written as a
121
+ named `struct`:code:, but there is no way to tell from the compiler
122
+ output. This class represents a tuple that appeared in a method
123
+ definition. Its name is derived from a hash of that tuple's field names,
124
+ and every method whose ABI refers to a tuple with that same list of field
125
+ names will have a generated wrapper method that refers to this class.
126
+
127
+ Any members of type `bytes`:code: should be encoded as UTF-8, which can be
128
+ accomplished via `str.encode("utf_8")`:code:
129
+ """
130
+
131
+ underlyingToken: str
132
+
133
+ flavor: int
134
+
135
+ isListed: bool
136
+
137
+
138
+ class AddExchangeCollateralMethod(ContractMethod): # pylint: disable=invalid-name
139
+ """Various interfaces to the addExchangeCollateral method."""
140
+
141
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
142
+ """Persist instance data."""
143
+ super().__init__(web3_or_provider, contract_address, validator)
144
+ self._underlying_method = contract_function
145
+
146
+ def validate_and_normalize_inputs(self, collateral_token: str, minimum_rate_limit: int):
147
+ """Validate the inputs to the addExchangeCollateral method."""
148
+ self.validator.assert_valid(
149
+ method_name='addExchangeCollateral',
150
+ parameter_name='_collateralToken',
151
+ argument_value=collateral_token,
152
+ )
153
+ collateral_token = self.validate_and_checksum_address(collateral_token)
154
+ self.validator.assert_valid(
155
+ method_name='addExchangeCollateral',
156
+ parameter_name='_minimumRateLimit',
157
+ argument_value=minimum_rate_limit,
158
+ )
159
+ return (collateral_token, minimum_rate_limit)
160
+
161
+ def call(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> None:
162
+ """Execute underlying contract method via eth_call.
163
+
164
+ This function purposefully prevents governance from adding collateral
165
+ flavors that are not Vanilla. Claiming Compound or Aave rewards has not
166
+ been implemented yet, so adding these tokens as collateral will
167
+ encourage users to waste their rewards.
168
+
169
+ :param _collateralToken: The collateral token to add.
170
+ :param _minimumRateLimit: The minimum amount that the rate limit will
171
+ be set to.
172
+ :param tx_params: transaction parameters
173
+ :returns: the return value of the underlying method.
174
+ """
175
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
176
+ tx_params = super().normalize_tx_params(tx_params)
177
+ self._underlying_method(collateral_token, minimum_rate_limit).call(tx_params.as_dict())
178
+
179
+ def send_transaction(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
180
+ """Execute underlying contract method via eth_sendTransaction.
181
+
182
+ This function purposefully prevents governance from adding collateral
183
+ flavors that are not Vanilla. Claiming Compound or Aave rewards has not
184
+ been implemented yet, so adding these tokens as collateral will
185
+ encourage users to waste their rewards.
186
+
187
+ :param _collateralToken: The collateral token to add.
188
+ :param _minimumRateLimit: The minimum amount that the rate limit will
189
+ be set to.
190
+ :param tx_params: transaction parameters
191
+ """
192
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
193
+ tx_params = super().normalize_tx_params(tx_params)
194
+ return self._underlying_method(collateral_token, minimum_rate_limit).transact(tx_params.as_dict())
195
+
196
+ def build_transaction(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> dict:
197
+ """Construct calldata to be used as input to the method."""
198
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
199
+ tx_params = super().normalize_tx_params(tx_params)
200
+ return self._underlying_method(collateral_token, minimum_rate_limit).build_transaction(tx_params.as_dict())
201
+
202
+ def estimate_gas(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> int:
203
+ """Estimate gas consumption of method call."""
204
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
205
+ tx_params = super().normalize_tx_params(tx_params)
206
+ return self._underlying_method(collateral_token, minimum_rate_limit).estimate_gas(tx_params.as_dict())
207
+
208
+ class DepositMethod(ContractMethod): # pylint: disable=invalid-name
209
+ """Various interfaces to the deposit method."""
210
+
211
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
212
+ """Persist instance data."""
213
+ super().__init__(web3_or_provider, contract_address, validator)
214
+ self._underlying_method = contract_function
215
+
216
+ def validate_and_normalize_inputs(self, collateral_address: str, strategy_id: Union[bytes, str], amount: int, expiry_block: int, signature: Union[bytes, str]):
217
+ """Validate the inputs to the deposit method."""
218
+ self.validator.assert_valid(
219
+ method_name='deposit',
220
+ parameter_name='_collateralAddress',
221
+ argument_value=collateral_address,
222
+ )
223
+ collateral_address = self.validate_and_checksum_address(collateral_address)
224
+ self.validator.assert_valid(
225
+ method_name='deposit',
226
+ parameter_name='_strategyId',
227
+ argument_value=strategy_id,
228
+ )
229
+ self.validator.assert_valid(
230
+ method_name='deposit',
231
+ parameter_name='_amount',
232
+ argument_value=amount,
233
+ )
234
+ self.validator.assert_valid(
235
+ method_name='deposit',
236
+ parameter_name='_expiryBlock',
237
+ argument_value=expiry_block,
238
+ )
239
+ # safeguard against fractional inputs
240
+ expiry_block = int(expiry_block)
241
+ self.validator.assert_valid(
242
+ method_name='deposit',
243
+ parameter_name='_signature',
244
+ argument_value=signature,
245
+ )
246
+ return (collateral_address, strategy_id, amount, expiry_block, signature)
247
+
248
+ def call(self, collateral_address: str, strategy_id: Union[bytes, str], amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> None:
249
+ """Execute underlying contract method via eth_call.
250
+
251
+ :param _amount: The amount to deposit.
252
+ :param _collateralAddress: The address of the collateral that should be
253
+ deposited.
254
+ :param _expiryBlock: Expiry block number for KYC authorization.
255
+ :param _signature: Signature of KYC authorization address.
256
+ :param _strategyId: The ID of the strategy to deposit into.
257
+ :param tx_params: transaction parameters
258
+ :returns: the return value of the underlying method.
259
+ """
260
+ (collateral_address, strategy_id, amount, expiry_block, signature) = self.validate_and_normalize_inputs(collateral_address, strategy_id, amount, expiry_block, signature)
261
+ tx_params = super().normalize_tx_params(tx_params)
262
+ self._underlying_method(collateral_address, strategy_id, amount, expiry_block, signature).call(tx_params.as_dict())
263
+
264
+ def send_transaction(self, collateral_address: str, strategy_id: Union[bytes, str], amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
265
+ """Execute underlying contract method via eth_sendTransaction.
266
+
267
+ :param _amount: The amount to deposit.
268
+ :param _collateralAddress: The address of the collateral that should be
269
+ deposited.
270
+ :param _expiryBlock: Expiry block number for KYC authorization.
271
+ :param _signature: Signature of KYC authorization address.
272
+ :param _strategyId: The ID of the strategy to deposit into.
273
+ :param tx_params: transaction parameters
274
+ """
275
+ (collateral_address, strategy_id, amount, expiry_block, signature) = self.validate_and_normalize_inputs(collateral_address, strategy_id, amount, expiry_block, signature)
276
+ tx_params = super().normalize_tx_params(tx_params)
277
+ return self._underlying_method(collateral_address, strategy_id, amount, expiry_block, signature).transact(tx_params.as_dict())
278
+
279
+ def build_transaction(self, collateral_address: str, strategy_id: Union[bytes, str], amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
280
+ """Construct calldata to be used as input to the method."""
281
+ (collateral_address, strategy_id, amount, expiry_block, signature) = self.validate_and_normalize_inputs(collateral_address, strategy_id, amount, expiry_block, signature)
282
+ tx_params = super().normalize_tx_params(tx_params)
283
+ return self._underlying_method(collateral_address, strategy_id, amount, expiry_block, signature).build_transaction(tx_params.as_dict())
284
+
285
+ def estimate_gas(self, collateral_address: str, strategy_id: Union[bytes, str], amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
286
+ """Estimate gas consumption of method call."""
287
+ (collateral_address, strategy_id, amount, expiry_block, signature) = self.validate_and_normalize_inputs(collateral_address, strategy_id, amount, expiry_block, signature)
288
+ tx_params = super().normalize_tx_params(tx_params)
289
+ return self._underlying_method(collateral_address, strategy_id, amount, expiry_block, signature).estimate_gas(tx_params.as_dict())
290
+
291
+ class GetAddressesHaveDepositedMethod(ContractMethod): # pylint: disable=invalid-name
292
+ """Various interfaces to the getAddressesHaveDeposited method."""
293
+
294
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
295
+ """Persist instance data."""
296
+ super().__init__(web3_or_provider, contract_address, validator)
297
+ self._underlying_method = contract_function
298
+
299
+ def validate_and_normalize_inputs(self, traders: List[str]):
300
+ """Validate the inputs to the getAddressesHaveDeposited method."""
301
+ self.validator.assert_valid(
302
+ method_name='getAddressesHaveDeposited',
303
+ parameter_name='_traders',
304
+ argument_value=traders,
305
+ )
306
+ return (traders)
307
+
308
+ def call(self, traders: List[str], tx_params: Optional[TxParams] = None) -> List[bool]:
309
+ """Execute underlying contract method via eth_call.
310
+
311
+ :param tx_params: transaction parameters
312
+ :returns: the return value of the underlying method.
313
+ """
314
+ (traders) = self.validate_and_normalize_inputs(traders)
315
+ tx_params = super().normalize_tx_params(tx_params)
316
+ returned = self._underlying_method(traders).call(tx_params.as_dict())
317
+ return [bool(element) for element in returned]
318
+
319
+ def send_transaction(self, traders: List[str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
320
+ """Execute underlying contract method via eth_sendTransaction.
321
+
322
+ :param tx_params: transaction parameters
323
+ """
324
+ (traders) = self.validate_and_normalize_inputs(traders)
325
+ tx_params = super().normalize_tx_params(tx_params)
326
+ return self._underlying_method(traders).transact(tx_params.as_dict())
327
+
328
+ def build_transaction(self, traders: List[str], tx_params: Optional[TxParams] = None) -> dict:
329
+ """Construct calldata to be used as input to the method."""
330
+ (traders) = self.validate_and_normalize_inputs(traders)
331
+ tx_params = super().normalize_tx_params(tx_params)
332
+ return self._underlying_method(traders).build_transaction(tx_params.as_dict())
333
+
334
+ def estimate_gas(self, traders: List[str], tx_params: Optional[TxParams] = None) -> int:
335
+ """Estimate gas consumption of method call."""
336
+ (traders) = self.validate_and_normalize_inputs(traders)
337
+ tx_params = super().normalize_tx_params(tx_params)
338
+ return self._underlying_method(traders).estimate_gas(tx_params.as_dict())
339
+
340
+ class GetExchangeCollateralInfoMethod(ContractMethod): # pylint: disable=invalid-name
341
+ """Various interfaces to the getExchangeCollateralInfo method."""
342
+
343
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
344
+ """Persist instance data."""
345
+ super().__init__(web3_or_provider, contract_address, validator)
346
+ self._underlying_method = contract_function
347
+
348
+ def validate_and_normalize_inputs(self, collateral_token: str):
349
+ """Validate the inputs to the getExchangeCollateralInfo method."""
350
+ self.validator.assert_valid(
351
+ method_name='getExchangeCollateralInfo',
352
+ parameter_name='_collateralToken',
353
+ argument_value=collateral_token,
354
+ )
355
+ collateral_token = self.validate_and_checksum_address(collateral_token)
356
+ return (collateral_token)
357
+
358
+ def call(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> DepositDefsExchangeCollateral:
359
+ """Execute underlying contract method via eth_call.
360
+
361
+ :param _collateralToken: The collateral token of the collateral to
362
+ query.
363
+ :param tx_params: transaction parameters
364
+ :returns: the return value of the underlying method.
365
+ """
366
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
367
+ tx_params = super().normalize_tx_params(tx_params)
368
+ returned = self._underlying_method(collateral_token).call(tx_params.as_dict())
369
+ return DepositDefsExchangeCollateral(underlyingToken=returned[0],flavor=returned[1],isListed=returned[2],)
370
+
371
+ def send_transaction(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
372
+ """Execute underlying contract method via eth_sendTransaction.
373
+
374
+ :param _collateralToken: The collateral token of the collateral to
375
+ query.
376
+ :param tx_params: transaction parameters
377
+ """
378
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
379
+ tx_params = super().normalize_tx_params(tx_params)
380
+ return self._underlying_method(collateral_token).transact(tx_params.as_dict())
381
+
382
+ def build_transaction(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> dict:
383
+ """Construct calldata to be used as input to the method."""
384
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
385
+ tx_params = super().normalize_tx_params(tx_params)
386
+ return self._underlying_method(collateral_token).build_transaction(tx_params.as_dict())
387
+
388
+ def estimate_gas(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> int:
389
+ """Estimate gas consumption of method call."""
390
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
391
+ tx_params = super().normalize_tx_params(tx_params)
392
+ return self._underlying_method(collateral_token).estimate_gas(tx_params.as_dict())
393
+
394
+ class GetGuardedDepositInfoMethod(ContractMethod): # pylint: disable=invalid-name
395
+ """Various interfaces to the getGuardedDepositInfo method."""
396
+
397
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function):
398
+ """Persist instance data."""
399
+ super().__init__(web3_or_provider, contract_address)
400
+ self._underlying_method = contract_function
401
+
402
+ def call(self, tx_params: Optional[TxParams] = None) -> Tuple[int, int, int]:
403
+ """Execute underlying contract method via eth_call.
404
+
405
+ :param tx_params: transaction parameters
406
+ :returns: the return value of the underlying method.
407
+ """
408
+ tx_params = super().normalize_tx_params(tx_params)
409
+ returned = self._underlying_method().call(tx_params.as_dict())
410
+ return (returned[0],returned[1],returned[2],)
411
+
412
+ def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
413
+ """Execute underlying contract method via eth_sendTransaction.
414
+
415
+ :param tx_params: transaction parameters
416
+ """
417
+ tx_params = super().normalize_tx_params(tx_params)
418
+ return self._underlying_method().transact(tx_params.as_dict())
419
+
420
+ def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
421
+ """Construct calldata to be used as input to the method."""
422
+ tx_params = super().normalize_tx_params(tx_params)
423
+ return self._underlying_method().build_transaction(tx_params.as_dict())
424
+
425
+ def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
426
+ """Estimate gas consumption of method call."""
427
+ tx_params = super().normalize_tx_params(tx_params)
428
+ return self._underlying_method().estimate_gas(tx_params.as_dict())
429
+
430
+ class GetMaximumWithdrawalMethod(ContractMethod): # pylint: disable=invalid-name
431
+ """Various interfaces to the getMaximumWithdrawal method."""
432
+
433
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
434
+ """Persist instance data."""
435
+ super().__init__(web3_or_provider, contract_address, validator)
436
+ self._underlying_method = contract_function
437
+
438
+ def validate_and_normalize_inputs(self, token_address: str):
439
+ """Validate the inputs to the getMaximumWithdrawal method."""
440
+ self.validator.assert_valid(
441
+ method_name='getMaximumWithdrawal',
442
+ parameter_name='_tokenAddress',
443
+ argument_value=token_address,
444
+ )
445
+ token_address = self.validate_and_checksum_address(token_address)
446
+ return (token_address)
447
+
448
+ def call(self, token_address: str, tx_params: Optional[TxParams] = None) -> Tuple[int, int]:
449
+ """Execute underlying contract method via eth_call.
450
+
451
+ :param _tokenAddress: The address of the token to withdraw.
452
+ :param tx_params: transaction parameters
453
+ :returns: the return value of the underlying method.
454
+ """
455
+ (token_address) = self.validate_and_normalize_inputs(token_address)
456
+ tx_params = super().normalize_tx_params(tx_params)
457
+ returned = self._underlying_method(token_address).call(tx_params.as_dict())
458
+ return (returned[0],returned[1],)
459
+
460
+ def send_transaction(self, token_address: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
461
+ """Execute underlying contract method via eth_sendTransaction.
462
+
463
+ :param _tokenAddress: The address of the token to withdraw.
464
+ :param tx_params: transaction parameters
465
+ """
466
+ (token_address) = self.validate_and_normalize_inputs(token_address)
467
+ tx_params = super().normalize_tx_params(tx_params)
468
+ return self._underlying_method(token_address).transact(tx_params.as_dict())
469
+
470
+ def build_transaction(self, token_address: str, tx_params: Optional[TxParams] = None) -> dict:
471
+ """Construct calldata to be used as input to the method."""
472
+ (token_address) = self.validate_and_normalize_inputs(token_address)
473
+ tx_params = super().normalize_tx_params(tx_params)
474
+ return self._underlying_method(token_address).build_transaction(tx_params.as_dict())
475
+
476
+ def estimate_gas(self, token_address: str, tx_params: Optional[TxParams] = None) -> int:
477
+ """Estimate gas consumption of method call."""
478
+ (token_address) = self.validate_and_normalize_inputs(token_address)
479
+ tx_params = super().normalize_tx_params(tx_params)
480
+ return self._underlying_method(token_address).estimate_gas(tx_params.as_dict())
481
+
482
+ class GetProcessedWithdrawalsMethod(ContractMethod): # pylint: disable=invalid-name
483
+ """Various interfaces to the getProcessedWithdrawals method."""
484
+
485
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
486
+ """Persist instance data."""
487
+ super().__init__(web3_or_provider, contract_address, validator)
488
+ self._underlying_method = contract_function
489
+
490
+ def validate_and_normalize_inputs(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, block_number: int):
491
+ """Validate the inputs to the getProcessedWithdrawals method."""
492
+ self.validator.assert_valid(
493
+ method_name='getProcessedWithdrawals',
494
+ parameter_name='_withdrawAddress',
495
+ argument_value=withdraw_address,
496
+ )
497
+ withdraw_address = self.validate_and_checksum_address(withdraw_address)
498
+ self.validator.assert_valid(
499
+ method_name='getProcessedWithdrawals',
500
+ parameter_name='_strategyIdHash',
501
+ argument_value=strategy_id_hash,
502
+ )
503
+ self.validator.assert_valid(
504
+ method_name='getProcessedWithdrawals',
505
+ parameter_name='_tokenAddress',
506
+ argument_value=token_address,
507
+ )
508
+ token_address = self.validate_and_checksum_address(token_address)
509
+ self.validator.assert_valid(
510
+ method_name='getProcessedWithdrawals',
511
+ parameter_name='_blockNumber',
512
+ argument_value=block_number,
513
+ )
514
+ return (withdraw_address, strategy_id_hash, token_address, block_number)
515
+
516
+ def call(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> int:
517
+ """Execute underlying contract method via eth_call.
518
+
519
+ :param _blockNumber: The confirmed block number to use for the query.
520
+ :param _strategyIdHash: The ID hash of the strategy that is being
521
+ withdrawn from.
522
+ :param _tokenAddress: The address of the collateral that was withdrawn.
523
+ :param _withdrawAddress: The address that is attempting to withdraw.
524
+ :param tx_params: transaction parameters
525
+ :returns: the return value of the underlying method.
526
+ """
527
+ (withdraw_address, strategy_id_hash, token_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address, block_number)
528
+ tx_params = super().normalize_tx_params(tx_params)
529
+ returned = self._underlying_method(withdraw_address, strategy_id_hash, token_address, block_number).call(tx_params.as_dict())
530
+ return int(returned)
531
+
532
+ def send_transaction(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
533
+ """Execute underlying contract method via eth_sendTransaction.
534
+
535
+ :param _blockNumber: The confirmed block number to use for the query.
536
+ :param _strategyIdHash: The ID hash of the strategy that is being
537
+ withdrawn from.
538
+ :param _tokenAddress: The address of the collateral that was withdrawn.
539
+ :param _withdrawAddress: The address that is attempting to withdraw.
540
+ :param tx_params: transaction parameters
541
+ """
542
+ (withdraw_address, strategy_id_hash, token_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address, block_number)
543
+ tx_params = super().normalize_tx_params(tx_params)
544
+ return self._underlying_method(withdraw_address, strategy_id_hash, token_address, block_number).transact(tx_params.as_dict())
545
+
546
+ def build_transaction(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> dict:
547
+ """Construct calldata to be used as input to the method."""
548
+ (withdraw_address, strategy_id_hash, token_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address, block_number)
549
+ tx_params = super().normalize_tx_params(tx_params)
550
+ return self._underlying_method(withdraw_address, strategy_id_hash, token_address, block_number).build_transaction(tx_params.as_dict())
551
+
552
+ def estimate_gas(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> int:
553
+ """Estimate gas consumption of method call."""
554
+ (withdraw_address, strategy_id_hash, token_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address, block_number)
555
+ tx_params = super().normalize_tx_params(tx_params)
556
+ return self._underlying_method(withdraw_address, strategy_id_hash, token_address, block_number).estimate_gas(tx_params.as_dict())
557
+
558
+ class GetRateLimitParametersMethod(ContractMethod): # pylint: disable=invalid-name
559
+ """Various interfaces to the getRateLimitParameters method."""
560
+
561
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function):
562
+ """Persist instance data."""
563
+ super().__init__(web3_or_provider, contract_address)
564
+ self._underlying_method = contract_function
565
+
566
+ def call(self, tx_params: Optional[TxParams] = None) -> Tuple[int, int]:
567
+ """Execute underlying contract method via eth_call.
568
+
569
+ :param tx_params: transaction parameters
570
+ :returns: the return value of the underlying method.
571
+ """
572
+ tx_params = super().normalize_tx_params(tx_params)
573
+ returned = self._underlying_method().call(tx_params.as_dict())
574
+ return (returned[0],returned[1],)
575
+
576
+ def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
577
+ """Execute underlying contract method via eth_sendTransaction.
578
+
579
+ :param tx_params: transaction parameters
580
+ """
581
+ tx_params = super().normalize_tx_params(tx_params)
582
+ return self._underlying_method().transact(tx_params.as_dict())
583
+
584
+ def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
585
+ """Construct calldata to be used as input to the method."""
586
+ tx_params = super().normalize_tx_params(tx_params)
587
+ return self._underlying_method().build_transaction(tx_params.as_dict())
588
+
589
+ def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
590
+ """Estimate gas consumption of method call."""
591
+ tx_params = super().normalize_tx_params(tx_params)
592
+ return self._underlying_method().estimate_gas(tx_params.as_dict())
593
+
594
+ class GetUnprocessedWithdrawalsMethod(ContractMethod): # pylint: disable=invalid-name
595
+ """Various interfaces to the getUnprocessedWithdrawals method."""
596
+
597
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
598
+ """Persist instance data."""
599
+ super().__init__(web3_or_provider, contract_address, validator)
600
+ self._underlying_method = contract_function
601
+
602
+ def validate_and_normalize_inputs(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str):
603
+ """Validate the inputs to the getUnprocessedWithdrawals method."""
604
+ self.validator.assert_valid(
605
+ method_name='getUnprocessedWithdrawals',
606
+ parameter_name='_withdrawAddress',
607
+ argument_value=withdraw_address,
608
+ )
609
+ withdraw_address = self.validate_and_checksum_address(withdraw_address)
610
+ self.validator.assert_valid(
611
+ method_name='getUnprocessedWithdrawals',
612
+ parameter_name='_strategyIdHash',
613
+ argument_value=strategy_id_hash,
614
+ )
615
+ self.validator.assert_valid(
616
+ method_name='getUnprocessedWithdrawals',
617
+ parameter_name='_tokenAddress',
618
+ argument_value=token_address,
619
+ )
620
+ token_address = self.validate_and_checksum_address(token_address)
621
+ return (withdraw_address, strategy_id_hash, token_address)
622
+
623
+ def call(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, tx_params: Optional[TxParams] = None) -> int:
624
+ """Execute underlying contract method via eth_call.
625
+
626
+ :param _strategyIdHash: The ID hash of the strategy that is being
627
+ withdrawn from.
628
+ :param _tokenAddress: The address of the collateral that was withdrawn.
629
+ :param _withdrawAddress: The address that is attempting to withdraw.
630
+ :param tx_params: transaction parameters
631
+ :returns: the return value of the underlying method.
632
+ """
633
+ (withdraw_address, strategy_id_hash, token_address) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address)
634
+ tx_params = super().normalize_tx_params(tx_params)
635
+ returned = self._underlying_method(withdraw_address, strategy_id_hash, token_address).call(tx_params.as_dict())
636
+ return int(returned)
637
+
638
+ def send_transaction(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
639
+ """Execute underlying contract method via eth_sendTransaction.
640
+
641
+ :param _strategyIdHash: The ID hash of the strategy that is being
642
+ withdrawn from.
643
+ :param _tokenAddress: The address of the collateral that was withdrawn.
644
+ :param _withdrawAddress: The address that is attempting to withdraw.
645
+ :param tx_params: transaction parameters
646
+ """
647
+ (withdraw_address, strategy_id_hash, token_address) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address)
648
+ tx_params = super().normalize_tx_params(tx_params)
649
+ return self._underlying_method(withdraw_address, strategy_id_hash, token_address).transact(tx_params.as_dict())
650
+
651
+ def build_transaction(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, tx_params: Optional[TxParams] = None) -> dict:
652
+ """Construct calldata to be used as input to the method."""
653
+ (withdraw_address, strategy_id_hash, token_address) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address)
654
+ tx_params = super().normalize_tx_params(tx_params)
655
+ return self._underlying_method(withdraw_address, strategy_id_hash, token_address).build_transaction(tx_params.as_dict())
656
+
657
+ def estimate_gas(self, withdraw_address: str, strategy_id_hash: Union[bytes, str], token_address: str, tx_params: Optional[TxParams] = None) -> int:
658
+ """Estimate gas consumption of method call."""
659
+ (withdraw_address, strategy_id_hash, token_address) = self.validate_and_normalize_inputs(withdraw_address, strategy_id_hash, token_address)
660
+ tx_params = super().normalize_tx_params(tx_params)
661
+ return self._underlying_method(withdraw_address, strategy_id_hash, token_address).estimate_gas(tx_params.as_dict())
662
+
663
+ class GetWithdrawalAllowanceMethod(ContractMethod): # pylint: disable=invalid-name
664
+ """Various interfaces to the getWithdrawalAllowance method."""
665
+
666
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
667
+ """Persist instance data."""
668
+ super().__init__(web3_or_provider, contract_address, validator)
669
+ self._underlying_method = contract_function
670
+
671
+ def validate_and_normalize_inputs(self, token_address: str):
672
+ """Validate the inputs to the getWithdrawalAllowance method."""
673
+ self.validator.assert_valid(
674
+ method_name='getWithdrawalAllowance',
675
+ parameter_name='_tokenAddress',
676
+ argument_value=token_address,
677
+ )
678
+ token_address = self.validate_and_checksum_address(token_address)
679
+ return (token_address)
680
+
681
+ def call(self, token_address: str, tx_params: Optional[TxParams] = None) -> int:
682
+ """Execute underlying contract method via eth_call.
683
+
684
+ :param _tokenAddress: The specified token.
685
+ :param tx_params: transaction parameters
686
+ :returns: the return value of the underlying method.
687
+ """
688
+ (token_address) = self.validate_and_normalize_inputs(token_address)
689
+ tx_params = super().normalize_tx_params(tx_params)
690
+ returned = self._underlying_method(token_address).call(tx_params.as_dict())
691
+ return int(returned)
692
+
693
+ def send_transaction(self, token_address: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
694
+ """Execute underlying contract method via eth_sendTransaction.
695
+
696
+ :param _tokenAddress: The specified token.
697
+ :param tx_params: transaction parameters
698
+ """
699
+ (token_address) = self.validate_and_normalize_inputs(token_address)
700
+ tx_params = super().normalize_tx_params(tx_params)
701
+ return self._underlying_method(token_address).transact(tx_params.as_dict())
702
+
703
+ def build_transaction(self, token_address: str, tx_params: Optional[TxParams] = None) -> dict:
704
+ """Construct calldata to be used as input to the method."""
705
+ (token_address) = self.validate_and_normalize_inputs(token_address)
706
+ tx_params = super().normalize_tx_params(tx_params)
707
+ return self._underlying_method(token_address).build_transaction(tx_params.as_dict())
708
+
709
+ def estimate_gas(self, token_address: str, tx_params: Optional[TxParams] = None) -> int:
710
+ """Estimate gas consumption of method call."""
711
+ (token_address) = self.validate_and_normalize_inputs(token_address)
712
+ tx_params = super().normalize_tx_params(tx_params)
713
+ return self._underlying_method(token_address).estimate_gas(tx_params.as_dict())
714
+
715
+ class InitializeMethod(ContractMethod): # pylint: disable=invalid-name
716
+ """Various interfaces to the initialize method."""
717
+
718
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
719
+ """Persist instance data."""
720
+ super().__init__(web3_or_provider, contract_address, validator)
721
+ self._underlying_method = contract_function
722
+
723
+ def validate_and_normalize_inputs(self, rate_limit_period: int, rate_limit_percentage: int, max_deposited_addresses: int, min_deposit: int):
724
+ """Validate the inputs to the initialize method."""
725
+ self.validator.assert_valid(
726
+ method_name='initialize',
727
+ parameter_name='_rateLimitPeriod',
728
+ argument_value=rate_limit_period,
729
+ )
730
+ self.validator.assert_valid(
731
+ method_name='initialize',
732
+ parameter_name='_rateLimitPercentage',
733
+ argument_value=rate_limit_percentage,
734
+ )
735
+ self.validator.assert_valid(
736
+ method_name='initialize',
737
+ parameter_name='_maxDepositedAddresses',
738
+ argument_value=max_deposited_addresses,
739
+ )
740
+ self.validator.assert_valid(
741
+ method_name='initialize',
742
+ parameter_name='_minDeposit',
743
+ argument_value=min_deposit,
744
+ )
745
+ return (rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit)
746
+
747
+ def call(self, rate_limit_period: int, rate_limit_percentage: int, max_deposited_addresses: int, min_deposit: int, tx_params: Optional[TxParams] = None) -> None:
748
+ """Execute underlying contract method via eth_call.
749
+
750
+ This function is intended to be the initialization target of the
751
+ diamond cut function. This function is not included in the selectors
752
+ being added to the diamond, meaning it cannot be called again.
753
+
754
+ :param _maxDepositedAddresses: The maximum number of deposited
755
+ addresses.
756
+ :param _minDeposit: The minimum amount of USDC that must be deposited.
757
+ :param _rateLimitPercentage: The dynamic component of the withdrawal
758
+ rate limits.
759
+ :param _rateLimitPeriod: The number of blocks before token-specific
760
+ rate limits are reassessed.
761
+ :param tx_params: transaction parameters
762
+ :returns: the return value of the underlying method.
763
+ """
764
+ (rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit)
765
+ tx_params = super().normalize_tx_params(tx_params)
766
+ self._underlying_method(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit).call(tx_params.as_dict())
767
+
768
+ def send_transaction(self, rate_limit_period: int, rate_limit_percentage: int, max_deposited_addresses: int, min_deposit: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
769
+ """Execute underlying contract method via eth_sendTransaction.
770
+
771
+ This function is intended to be the initialization target of the
772
+ diamond cut function. This function is not included in the selectors
773
+ being added to the diamond, meaning it cannot be called again.
774
+
775
+ :param _maxDepositedAddresses: The maximum number of deposited
776
+ addresses.
777
+ :param _minDeposit: The minimum amount of USDC that must be deposited.
778
+ :param _rateLimitPercentage: The dynamic component of the withdrawal
779
+ rate limits.
780
+ :param _rateLimitPeriod: The number of blocks before token-specific
781
+ rate limits are reassessed.
782
+ :param tx_params: transaction parameters
783
+ """
784
+ (rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit)
785
+ tx_params = super().normalize_tx_params(tx_params)
786
+ return self._underlying_method(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit).transact(tx_params.as_dict())
787
+
788
+ def build_transaction(self, rate_limit_period: int, rate_limit_percentage: int, max_deposited_addresses: int, min_deposit: int, tx_params: Optional[TxParams] = None) -> dict:
789
+ """Construct calldata to be used as input to the method."""
790
+ (rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit)
791
+ tx_params = super().normalize_tx_params(tx_params)
792
+ return self._underlying_method(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit).build_transaction(tx_params.as_dict())
793
+
794
+ def estimate_gas(self, rate_limit_period: int, rate_limit_percentage: int, max_deposited_addresses: int, min_deposit: int, tx_params: Optional[TxParams] = None) -> int:
795
+ """Estimate gas consumption of method call."""
796
+ (rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit)
797
+ tx_params = super().normalize_tx_params(tx_params)
798
+ return self._underlying_method(rate_limit_period, rate_limit_percentage, max_deposited_addresses, min_deposit).estimate_gas(tx_params.as_dict())
799
+
800
+ class RemoveExchangeCollateralMethod(ContractMethod): # pylint: disable=invalid-name
801
+ """Various interfaces to the removeExchangeCollateral method."""
802
+
803
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
804
+ """Persist instance data."""
805
+ super().__init__(web3_or_provider, contract_address, validator)
806
+ self._underlying_method = contract_function
807
+
808
+ def validate_and_normalize_inputs(self, collateral_token: str):
809
+ """Validate the inputs to the removeExchangeCollateral method."""
810
+ self.validator.assert_valid(
811
+ method_name='removeExchangeCollateral',
812
+ parameter_name='_collateralToken',
813
+ argument_value=collateral_token,
814
+ )
815
+ collateral_token = self.validate_and_checksum_address(collateral_token)
816
+ return (collateral_token)
817
+
818
+ def call(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> None:
819
+ """Execute underlying contract method via eth_call.
820
+
821
+ :param _collateralToken: The collateral token to remove.
822
+ :param tx_params: transaction parameters
823
+ :returns: the return value of the underlying method.
824
+ """
825
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
826
+ tx_params = super().normalize_tx_params(tx_params)
827
+ self._underlying_method(collateral_token).call(tx_params.as_dict())
828
+
829
+ def send_transaction(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
830
+ """Execute underlying contract method via eth_sendTransaction.
831
+
832
+ :param _collateralToken: The collateral token to remove.
833
+ :param tx_params: transaction parameters
834
+ """
835
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
836
+ tx_params = super().normalize_tx_params(tx_params)
837
+ return self._underlying_method(collateral_token).transact(tx_params.as_dict())
838
+
839
+ def build_transaction(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> dict:
840
+ """Construct calldata to be used as input to the method."""
841
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
842
+ tx_params = super().normalize_tx_params(tx_params)
843
+ return self._underlying_method(collateral_token).build_transaction(tx_params.as_dict())
844
+
845
+ def estimate_gas(self, collateral_token: str, tx_params: Optional[TxParams] = None) -> int:
846
+ """Estimate gas consumption of method call."""
847
+ (collateral_token) = self.validate_and_normalize_inputs(collateral_token)
848
+ tx_params = super().normalize_tx_params(tx_params)
849
+ return self._underlying_method(collateral_token).estimate_gas(tx_params.as_dict())
850
+
851
+ class SetMaxDepositedAddressesMethod(ContractMethod): # pylint: disable=invalid-name
852
+ """Various interfaces to the setMaxDepositedAddresses method."""
853
+
854
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
855
+ """Persist instance data."""
856
+ super().__init__(web3_or_provider, contract_address, validator)
857
+ self._underlying_method = contract_function
858
+
859
+ def validate_and_normalize_inputs(self, max_deposited_addresses: int):
860
+ """Validate the inputs to the setMaxDepositedAddresses method."""
861
+ self.validator.assert_valid(
862
+ method_name='setMaxDepositedAddresses',
863
+ parameter_name='_maxDepositedAddresses',
864
+ argument_value=max_deposited_addresses,
865
+ )
866
+ return (max_deposited_addresses)
867
+
868
+ def call(self, max_deposited_addresses: int, tx_params: Optional[TxParams] = None) -> None:
869
+ """Execute underlying contract method via eth_call.
870
+
871
+ :param _maxDepositedAddresses: The maximum number of deposited
872
+ addresses.
873
+ :param tx_params: transaction parameters
874
+ :returns: the return value of the underlying method.
875
+ """
876
+ (max_deposited_addresses) = self.validate_and_normalize_inputs(max_deposited_addresses)
877
+ tx_params = super().normalize_tx_params(tx_params)
878
+ self._underlying_method(max_deposited_addresses).call(tx_params.as_dict())
879
+
880
+ def send_transaction(self, max_deposited_addresses: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
881
+ """Execute underlying contract method via eth_sendTransaction.
882
+
883
+ :param _maxDepositedAddresses: The maximum number of deposited
884
+ addresses.
885
+ :param tx_params: transaction parameters
886
+ """
887
+ (max_deposited_addresses) = self.validate_and_normalize_inputs(max_deposited_addresses)
888
+ tx_params = super().normalize_tx_params(tx_params)
889
+ return self._underlying_method(max_deposited_addresses).transact(tx_params.as_dict())
890
+
891
+ def build_transaction(self, max_deposited_addresses: int, tx_params: Optional[TxParams] = None) -> dict:
892
+ """Construct calldata to be used as input to the method."""
893
+ (max_deposited_addresses) = self.validate_and_normalize_inputs(max_deposited_addresses)
894
+ tx_params = super().normalize_tx_params(tx_params)
895
+ return self._underlying_method(max_deposited_addresses).build_transaction(tx_params.as_dict())
896
+
897
+ def estimate_gas(self, max_deposited_addresses: int, tx_params: Optional[TxParams] = None) -> int:
898
+ """Estimate gas consumption of method call."""
899
+ (max_deposited_addresses) = self.validate_and_normalize_inputs(max_deposited_addresses)
900
+ tx_params = super().normalize_tx_params(tx_params)
901
+ return self._underlying_method(max_deposited_addresses).estimate_gas(tx_params.as_dict())
902
+
903
+ class SetMinDepositMethod(ContractMethod): # pylint: disable=invalid-name
904
+ """Various interfaces to the setMinDeposit method."""
905
+
906
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
907
+ """Persist instance data."""
908
+ super().__init__(web3_or_provider, contract_address, validator)
909
+ self._underlying_method = contract_function
910
+
911
+ def validate_and_normalize_inputs(self, min_deposit: int):
912
+ """Validate the inputs to the setMinDeposit method."""
913
+ self.validator.assert_valid(
914
+ method_name='setMinDeposit',
915
+ parameter_name='_minDeposit',
916
+ argument_value=min_deposit,
917
+ )
918
+ return (min_deposit)
919
+
920
+ def call(self, min_deposit: int, tx_params: Optional[TxParams] = None) -> None:
921
+ """Execute underlying contract method via eth_call.
922
+
923
+ :param _minDeposit: The minimum amount of USDC that must be deposited.
924
+ :param tx_params: transaction parameters
925
+ :returns: the return value of the underlying method.
926
+ """
927
+ (min_deposit) = self.validate_and_normalize_inputs(min_deposit)
928
+ tx_params = super().normalize_tx_params(tx_params)
929
+ self._underlying_method(min_deposit).call(tx_params.as_dict())
930
+
931
+ def send_transaction(self, min_deposit: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
932
+ """Execute underlying contract method via eth_sendTransaction.
933
+
934
+ :param _minDeposit: The minimum amount of USDC that must be deposited.
935
+ :param tx_params: transaction parameters
936
+ """
937
+ (min_deposit) = self.validate_and_normalize_inputs(min_deposit)
938
+ tx_params = super().normalize_tx_params(tx_params)
939
+ return self._underlying_method(min_deposit).transact(tx_params.as_dict())
940
+
941
+ def build_transaction(self, min_deposit: int, tx_params: Optional[TxParams] = None) -> dict:
942
+ """Construct calldata to be used as input to the method."""
943
+ (min_deposit) = self.validate_and_normalize_inputs(min_deposit)
944
+ tx_params = super().normalize_tx_params(tx_params)
945
+ return self._underlying_method(min_deposit).build_transaction(tx_params.as_dict())
946
+
947
+ def estimate_gas(self, min_deposit: int, tx_params: Optional[TxParams] = None) -> int:
948
+ """Estimate gas consumption of method call."""
949
+ (min_deposit) = self.validate_and_normalize_inputs(min_deposit)
950
+ tx_params = super().normalize_tx_params(tx_params)
951
+ return self._underlying_method(min_deposit).estimate_gas(tx_params.as_dict())
952
+
953
+ class SetRateLimitParametersMethod(ContractMethod): # pylint: disable=invalid-name
954
+ """Various interfaces to the setRateLimitParameters method."""
955
+
956
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
957
+ """Persist instance data."""
958
+ super().__init__(web3_or_provider, contract_address, validator)
959
+ self._underlying_method = contract_function
960
+
961
+ def validate_and_normalize_inputs(self, rate_limit_period: int, rate_limit_percentage: int):
962
+ """Validate the inputs to the setRateLimitParameters method."""
963
+ self.validator.assert_valid(
964
+ method_name='setRateLimitParameters',
965
+ parameter_name='_rateLimitPeriod',
966
+ argument_value=rate_limit_period,
967
+ )
968
+ self.validator.assert_valid(
969
+ method_name='setRateLimitParameters',
970
+ parameter_name='_rateLimitPercentage',
971
+ argument_value=rate_limit_percentage,
972
+ )
973
+ return (rate_limit_period, rate_limit_percentage)
974
+
975
+ def call(self, rate_limit_period: int, rate_limit_percentage: int, tx_params: Optional[TxParams] = None) -> None:
976
+ """Execute underlying contract method via eth_call.
977
+
978
+ :param _rateLimitPercentage: The new rate limit percentage.
979
+ :param tx_params: transaction parameters
980
+ :returns: the return value of the underlying method.
981
+ """
982
+ (rate_limit_period, rate_limit_percentage) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage)
983
+ tx_params = super().normalize_tx_params(tx_params)
984
+ self._underlying_method(rate_limit_period, rate_limit_percentage).call(tx_params.as_dict())
985
+
986
+ def send_transaction(self, rate_limit_period: int, rate_limit_percentage: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
987
+ """Execute underlying contract method via eth_sendTransaction.
988
+
989
+ :param _rateLimitPercentage: The new rate limit percentage.
990
+ :param tx_params: transaction parameters
991
+ """
992
+ (rate_limit_period, rate_limit_percentage) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage)
993
+ tx_params = super().normalize_tx_params(tx_params)
994
+ return self._underlying_method(rate_limit_period, rate_limit_percentage).transact(tx_params.as_dict())
995
+
996
+ def build_transaction(self, rate_limit_period: int, rate_limit_percentage: int, tx_params: Optional[TxParams] = None) -> dict:
997
+ """Construct calldata to be used as input to the method."""
998
+ (rate_limit_period, rate_limit_percentage) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage)
999
+ tx_params = super().normalize_tx_params(tx_params)
1000
+ return self._underlying_method(rate_limit_period, rate_limit_percentage).build_transaction(tx_params.as_dict())
1001
+
1002
+ def estimate_gas(self, rate_limit_period: int, rate_limit_percentage: int, tx_params: Optional[TxParams] = None) -> int:
1003
+ """Estimate gas consumption of method call."""
1004
+ (rate_limit_period, rate_limit_percentage) = self.validate_and_normalize_inputs(rate_limit_period, rate_limit_percentage)
1005
+ tx_params = super().normalize_tx_params(tx_params)
1006
+ return self._underlying_method(rate_limit_period, rate_limit_percentage).estimate_gas(tx_params.as_dict())
1007
+
1008
+ class UpdateExchangeCollateralMethod(ContractMethod): # pylint: disable=invalid-name
1009
+ """Various interfaces to the updateExchangeCollateral method."""
1010
+
1011
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
1012
+ """Persist instance data."""
1013
+ super().__init__(web3_or_provider, contract_address, validator)
1014
+ self._underlying_method = contract_function
1015
+
1016
+ def validate_and_normalize_inputs(self, collateral_token: str, minimum_rate_limit: int):
1017
+ """Validate the inputs to the updateExchangeCollateral method."""
1018
+ self.validator.assert_valid(
1019
+ method_name='updateExchangeCollateral',
1020
+ parameter_name='_collateralToken',
1021
+ argument_value=collateral_token,
1022
+ )
1023
+ collateral_token = self.validate_and_checksum_address(collateral_token)
1024
+ self.validator.assert_valid(
1025
+ method_name='updateExchangeCollateral',
1026
+ parameter_name='_minimumRateLimit',
1027
+ argument_value=minimum_rate_limit,
1028
+ )
1029
+ return (collateral_token, minimum_rate_limit)
1030
+
1031
+ def call(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> None:
1032
+ """Execute underlying contract method via eth_call.
1033
+
1034
+ :param _collateralToken: The collateral token to update.
1035
+ :param _minimumRateLimit: The minimum amount that the rate limit will
1036
+ be set to.
1037
+ :param tx_params: transaction parameters
1038
+ :returns: the return value of the underlying method.
1039
+ """
1040
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
1041
+ tx_params = super().normalize_tx_params(tx_params)
1042
+ self._underlying_method(collateral_token, minimum_rate_limit).call(tx_params.as_dict())
1043
+
1044
+ def send_transaction(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
1045
+ """Execute underlying contract method via eth_sendTransaction.
1046
+
1047
+ :param _collateralToken: The collateral token to update.
1048
+ :param _minimumRateLimit: The minimum amount that the rate limit will
1049
+ be set to.
1050
+ :param tx_params: transaction parameters
1051
+ """
1052
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
1053
+ tx_params = super().normalize_tx_params(tx_params)
1054
+ return self._underlying_method(collateral_token, minimum_rate_limit).transact(tx_params.as_dict())
1055
+
1056
+ def build_transaction(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> dict:
1057
+ """Construct calldata to be used as input to the method."""
1058
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
1059
+ tx_params = super().normalize_tx_params(tx_params)
1060
+ return self._underlying_method(collateral_token, minimum_rate_limit).build_transaction(tx_params.as_dict())
1061
+
1062
+ def estimate_gas(self, collateral_token: str, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> int:
1063
+ """Estimate gas consumption of method call."""
1064
+ (collateral_token, minimum_rate_limit) = self.validate_and_normalize_inputs(collateral_token, minimum_rate_limit)
1065
+ tx_params = super().normalize_tx_params(tx_params)
1066
+ return self._underlying_method(collateral_token, minimum_rate_limit).estimate_gas(tx_params.as_dict())
1067
+
1068
+ class WithdrawMethod(ContractMethod): # pylint: disable=invalid-name
1069
+ """Various interfaces to the withdraw method."""
1070
+
1071
+ def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
1072
+ """Persist instance data."""
1073
+ super().__init__(web3_or_provider, contract_address, validator)
1074
+ self._underlying_method = contract_function
1075
+
1076
+ def validate_and_normalize_inputs(self, strategy_id_hash: Union[bytes, str], withdrawal_data: SharedDefsBalance128, strategy: DepositDefsStrategyData, proof: Union[bytes, str]):
1077
+ """Validate the inputs to the withdraw method."""
1078
+ self.validator.assert_valid(
1079
+ method_name='withdraw',
1080
+ parameter_name='_strategyIdHash',
1081
+ argument_value=strategy_id_hash,
1082
+ )
1083
+ self.validator.assert_valid(
1084
+ method_name='withdraw',
1085
+ parameter_name='_withdrawalData',
1086
+ argument_value=withdrawal_data,
1087
+ )
1088
+ self.validator.assert_valid(
1089
+ method_name='withdraw',
1090
+ parameter_name='_strategy',
1091
+ argument_value=strategy,
1092
+ )
1093
+ self.validator.assert_valid(
1094
+ method_name='withdraw',
1095
+ parameter_name='_proof',
1096
+ argument_value=proof,
1097
+ )
1098
+ return (strategy_id_hash, withdrawal_data, strategy, proof)
1099
+
1100
+ def call(self, strategy_id_hash: Union[bytes, str], withdrawal_data: SharedDefsBalance128, strategy: DepositDefsStrategyData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> None:
1101
+ """Execute underlying contract method via eth_call.
1102
+
1103
+ This withdrawal strategy does not incorporate rebalancing to ensure
1104
+ that users can always withdraw the tokens that they specify. This
1105
+ consideration doesn't have an effect on UX when there is only one type
1106
+ of collateral that is accepted by the exchange, but it will become more
1107
+ pressing once multi-collateral support has been implemented.
1108
+
1109
+ :param _proof: A merkle proof that proves that the included strategy is
1110
+ in the most recent state root.
1111
+ :param _strategy: The data that is contained within the strategy.
1112
+ :param _strategyIdHash: The hash of the strategy id to withdraw from.
1113
+ :param _withdrawalData: Data that specifies the tokens and amounts to
1114
+ withdraw. The withdraw data that is provided to this function
1115
+ must be given in the same order as the
1116
+ `_strategy.lockedCollateral` field. Misordering this
1117
+ parameter will cause the function to revert.
1118
+ :param tx_params: transaction parameters
1119
+ :returns: the return value of the underlying method.
1120
+ """
1121
+ (strategy_id_hash, withdrawal_data, strategy, proof) = self.validate_and_normalize_inputs(strategy_id_hash, withdrawal_data, strategy, proof)
1122
+ tx_params = super().normalize_tx_params(tx_params)
1123
+ self._underlying_method(strategy_id_hash, withdrawal_data, strategy, proof).call(tx_params.as_dict())
1124
+
1125
+ def send_transaction(self, strategy_id_hash: Union[bytes, str], withdrawal_data: SharedDefsBalance128, strategy: DepositDefsStrategyData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
1126
+ """Execute underlying contract method via eth_sendTransaction.
1127
+
1128
+ This withdrawal strategy does not incorporate rebalancing to ensure
1129
+ that users can always withdraw the tokens that they specify. This
1130
+ consideration doesn't have an effect on UX when there is only one type
1131
+ of collateral that is accepted by the exchange, but it will become more
1132
+ pressing once multi-collateral support has been implemented.
1133
+
1134
+ :param _proof: A merkle proof that proves that the included strategy is
1135
+ in the most recent state root.
1136
+ :param _strategy: The data that is contained within the strategy.
1137
+ :param _strategyIdHash: The hash of the strategy id to withdraw from.
1138
+ :param _withdrawalData: Data that specifies the tokens and amounts to
1139
+ withdraw. The withdraw data that is provided to this function
1140
+ must be given in the same order as the
1141
+ `_strategy.lockedCollateral` field. Misordering this
1142
+ parameter will cause the function to revert.
1143
+ :param tx_params: transaction parameters
1144
+ """
1145
+ (strategy_id_hash, withdrawal_data, strategy, proof) = self.validate_and_normalize_inputs(strategy_id_hash, withdrawal_data, strategy, proof)
1146
+ tx_params = super().normalize_tx_params(tx_params)
1147
+ return self._underlying_method(strategy_id_hash, withdrawal_data, strategy, proof).transact(tx_params.as_dict())
1148
+
1149
+ def build_transaction(self, strategy_id_hash: Union[bytes, str], withdrawal_data: SharedDefsBalance128, strategy: DepositDefsStrategyData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
1150
+ """Construct calldata to be used as input to the method."""
1151
+ (strategy_id_hash, withdrawal_data, strategy, proof) = self.validate_and_normalize_inputs(strategy_id_hash, withdrawal_data, strategy, proof)
1152
+ tx_params = super().normalize_tx_params(tx_params)
1153
+ return self._underlying_method(strategy_id_hash, withdrawal_data, strategy, proof).build_transaction(tx_params.as_dict())
1154
+
1155
+ def estimate_gas(self, strategy_id_hash: Union[bytes, str], withdrawal_data: SharedDefsBalance128, strategy: DepositDefsStrategyData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
1156
+ """Estimate gas consumption of method call."""
1157
+ (strategy_id_hash, withdrawal_data, strategy, proof) = self.validate_and_normalize_inputs(strategy_id_hash, withdrawal_data, strategy, proof)
1158
+ tx_params = super().normalize_tx_params(tx_params)
1159
+ return self._underlying_method(strategy_id_hash, withdrawal_data, strategy, proof).estimate_gas(tx_params.as_dict())
1160
+
1161
+ # pylint: disable=too-many-public-methods,too-many-instance-attributes
1162
+ class ICollateral:
1163
+ """Wrapper class for ICollateral Solidity contract.
1164
+
1165
+ All method parameters of type `bytes`:code: should be encoded as UTF-8,
1166
+ which can be accomplished via `str.encode("utf_8")`:code:.
1167
+ """
1168
+ add_exchange_collateral: AddExchangeCollateralMethod
1169
+ """Constructor-initialized instance of
1170
+ :class:`AddExchangeCollateralMethod`.
1171
+ """
1172
+
1173
+ deposit: DepositMethod
1174
+ """Constructor-initialized instance of
1175
+ :class:`DepositMethod`.
1176
+ """
1177
+
1178
+ get_addresses_have_deposited: GetAddressesHaveDepositedMethod
1179
+ """Constructor-initialized instance of
1180
+ :class:`GetAddressesHaveDepositedMethod`.
1181
+ """
1182
+
1183
+ get_exchange_collateral_info: GetExchangeCollateralInfoMethod
1184
+ """Constructor-initialized instance of
1185
+ :class:`GetExchangeCollateralInfoMethod`.
1186
+ """
1187
+
1188
+ get_guarded_deposit_info: GetGuardedDepositInfoMethod
1189
+ """Constructor-initialized instance of
1190
+ :class:`GetGuardedDepositInfoMethod`.
1191
+ """
1192
+
1193
+ get_maximum_withdrawal: GetMaximumWithdrawalMethod
1194
+ """Constructor-initialized instance of
1195
+ :class:`GetMaximumWithdrawalMethod`.
1196
+ """
1197
+
1198
+ get_processed_withdrawals: GetProcessedWithdrawalsMethod
1199
+ """Constructor-initialized instance of
1200
+ :class:`GetProcessedWithdrawalsMethod`.
1201
+ """
1202
+
1203
+ get_rate_limit_parameters: GetRateLimitParametersMethod
1204
+ """Constructor-initialized instance of
1205
+ :class:`GetRateLimitParametersMethod`.
1206
+ """
1207
+
1208
+ get_unprocessed_withdrawals: GetUnprocessedWithdrawalsMethod
1209
+ """Constructor-initialized instance of
1210
+ :class:`GetUnprocessedWithdrawalsMethod`.
1211
+ """
1212
+
1213
+ get_withdrawal_allowance: GetWithdrawalAllowanceMethod
1214
+ """Constructor-initialized instance of
1215
+ :class:`GetWithdrawalAllowanceMethod`.
1216
+ """
1217
+
1218
+ initialize: InitializeMethod
1219
+ """Constructor-initialized instance of
1220
+ :class:`InitializeMethod`.
1221
+ """
1222
+
1223
+ remove_exchange_collateral: RemoveExchangeCollateralMethod
1224
+ """Constructor-initialized instance of
1225
+ :class:`RemoveExchangeCollateralMethod`.
1226
+ """
1227
+
1228
+ set_max_deposited_addresses: SetMaxDepositedAddressesMethod
1229
+ """Constructor-initialized instance of
1230
+ :class:`SetMaxDepositedAddressesMethod`.
1231
+ """
1232
+
1233
+ set_min_deposit: SetMinDepositMethod
1234
+ """Constructor-initialized instance of
1235
+ :class:`SetMinDepositMethod`.
1236
+ """
1237
+
1238
+ set_rate_limit_parameters: SetRateLimitParametersMethod
1239
+ """Constructor-initialized instance of
1240
+ :class:`SetRateLimitParametersMethod`.
1241
+ """
1242
+
1243
+ update_exchange_collateral: UpdateExchangeCollateralMethod
1244
+ """Constructor-initialized instance of
1245
+ :class:`UpdateExchangeCollateralMethod`.
1246
+ """
1247
+
1248
+ withdraw: WithdrawMethod
1249
+ """Constructor-initialized instance of
1250
+ :class:`WithdrawMethod`.
1251
+ """
1252
+
1253
+
1254
+ def __init__(
1255
+ self,
1256
+ web3_or_provider: Union[Web3, BaseProvider],
1257
+ contract_address: str,
1258
+ validator: ICollateralValidator = None,
1259
+ ):
1260
+ """Get an instance of wrapper for smart contract.
1261
+
1262
+ :param web3_or_provider: Either an instance of `web3.Web3`:code: or
1263
+ `web3.providers.base.BaseProvider`:code:
1264
+ :param contract_address: where the contract has been deployed
1265
+ :param validator: for validation of method inputs.
1266
+ """
1267
+ # pylint: disable=too-many-statements
1268
+
1269
+ self.contract_address = contract_address
1270
+
1271
+ if not validator:
1272
+ validator = ICollateralValidator(web3_or_provider, contract_address)
1273
+
1274
+ web3 = None
1275
+ if isinstance(web3_or_provider, BaseProvider):
1276
+ web3 = Web3(web3_or_provider)
1277
+ elif isinstance(web3_or_provider, Web3):
1278
+ web3 = web3_or_provider
1279
+ else:
1280
+ raise TypeError(
1281
+ "Expected parameter 'web3_or_provider' to be an instance of either"
1282
+ + " Web3 or BaseProvider"
1283
+ )
1284
+
1285
+ # if any middleware was imported, inject it
1286
+ try:
1287
+ MIDDLEWARE
1288
+ except NameError:
1289
+ pass
1290
+ else:
1291
+ try:
1292
+ for middleware in MIDDLEWARE:
1293
+ web3.middleware_onion.inject(
1294
+ middleware['function'], layer=middleware['layer'],
1295
+ )
1296
+ except ValueError as value_error:
1297
+ if value_error.args == ("You can't add the same un-named instance twice",):
1298
+ pass
1299
+
1300
+ self._web3_eth = web3.eth
1301
+
1302
+ functions = self._web3_eth.contract(address=to_checksum_address(contract_address), abi=ICollateral.abi()).functions
1303
+
1304
+ self.add_exchange_collateral = AddExchangeCollateralMethod(web3_or_provider, contract_address, functions.addExchangeCollateral, validator)
1305
+
1306
+ self.deposit = DepositMethod(web3_or_provider, contract_address, functions.deposit, validator)
1307
+
1308
+ self.get_addresses_have_deposited = GetAddressesHaveDepositedMethod(web3_or_provider, contract_address, functions.getAddressesHaveDeposited, validator)
1309
+
1310
+ self.get_exchange_collateral_info = GetExchangeCollateralInfoMethod(web3_or_provider, contract_address, functions.getExchangeCollateralInfo, validator)
1311
+
1312
+ self.get_guarded_deposit_info = GetGuardedDepositInfoMethod(web3_or_provider, contract_address, functions.getGuardedDepositInfo)
1313
+
1314
+ self.get_maximum_withdrawal = GetMaximumWithdrawalMethod(web3_or_provider, contract_address, functions.getMaximumWithdrawal, validator)
1315
+
1316
+ self.get_processed_withdrawals = GetProcessedWithdrawalsMethod(web3_or_provider, contract_address, functions.getProcessedWithdrawals, validator)
1317
+
1318
+ self.get_rate_limit_parameters = GetRateLimitParametersMethod(web3_or_provider, contract_address, functions.getRateLimitParameters)
1319
+
1320
+ self.get_unprocessed_withdrawals = GetUnprocessedWithdrawalsMethod(web3_or_provider, contract_address, functions.getUnprocessedWithdrawals, validator)
1321
+
1322
+ self.get_withdrawal_allowance = GetWithdrawalAllowanceMethod(web3_or_provider, contract_address, functions.getWithdrawalAllowance, validator)
1323
+
1324
+ self.initialize = InitializeMethod(web3_or_provider, contract_address, functions.initialize, validator)
1325
+
1326
+ self.remove_exchange_collateral = RemoveExchangeCollateralMethod(web3_or_provider, contract_address, functions.removeExchangeCollateral, validator)
1327
+
1328
+ self.set_max_deposited_addresses = SetMaxDepositedAddressesMethod(web3_or_provider, contract_address, functions.setMaxDepositedAddresses, validator)
1329
+
1330
+ self.set_min_deposit = SetMinDepositMethod(web3_or_provider, contract_address, functions.setMinDeposit, validator)
1331
+
1332
+ self.set_rate_limit_parameters = SetRateLimitParametersMethod(web3_or_provider, contract_address, functions.setRateLimitParameters, validator)
1333
+
1334
+ self.update_exchange_collateral = UpdateExchangeCollateralMethod(web3_or_provider, contract_address, functions.updateExchangeCollateral, validator)
1335
+
1336
+ self.withdraw = WithdrawMethod(web3_or_provider, contract_address, functions.withdraw, validator)
1337
+
1338
+ def get_exchange_collateral_added_event(
1339
+ self, tx_hash: Union[HexBytes, bytes]
1340
+ ) -> Tuple[AttributeDict]:
1341
+ """Get log entry for ExchangeCollateralAdded event.
1342
+
1343
+ :param tx_hash: hash of transaction emitting ExchangeCollateralAdded
1344
+ event
1345
+ """
1346
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1347
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.ExchangeCollateralAdded().process_receipt(tx_receipt)
1348
+ def get_exchange_collateral_removed_event(
1349
+ self, tx_hash: Union[HexBytes, bytes]
1350
+ ) -> Tuple[AttributeDict]:
1351
+ """Get log entry for ExchangeCollateralRemoved event.
1352
+
1353
+ :param tx_hash: hash of transaction emitting ExchangeCollateralRemoved
1354
+ event
1355
+ """
1356
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1357
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.ExchangeCollateralRemoved().process_receipt(tx_receipt)
1358
+ def get_exchange_collateral_updated_event(
1359
+ self, tx_hash: Union[HexBytes, bytes]
1360
+ ) -> Tuple[AttributeDict]:
1361
+ """Get log entry for ExchangeCollateralUpdated event.
1362
+
1363
+ :param tx_hash: hash of transaction emitting ExchangeCollateralUpdated
1364
+ event
1365
+ """
1366
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1367
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.ExchangeCollateralUpdated().process_receipt(tx_receipt)
1368
+ def get_max_deposited_addresses_set_event(
1369
+ self, tx_hash: Union[HexBytes, bytes]
1370
+ ) -> Tuple[AttributeDict]:
1371
+ """Get log entry for MaxDepositedAddressesSet event.
1372
+
1373
+ :param tx_hash: hash of transaction emitting MaxDepositedAddressesSet
1374
+ event
1375
+ """
1376
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1377
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.MaxDepositedAddressesSet().process_receipt(tx_receipt)
1378
+ def get_min_deposit_set_event(
1379
+ self, tx_hash: Union[HexBytes, bytes]
1380
+ ) -> Tuple[AttributeDict]:
1381
+ """Get log entry for MinDepositSet event.
1382
+
1383
+ :param tx_hash: hash of transaction emitting MinDepositSet event
1384
+ """
1385
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1386
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.MinDepositSet().process_receipt(tx_receipt)
1387
+ def get_rate_limit_parameters_set_event(
1388
+ self, tx_hash: Union[HexBytes, bytes]
1389
+ ) -> Tuple[AttributeDict]:
1390
+ """Get log entry for RateLimitParametersSet event.
1391
+
1392
+ :param tx_hash: hash of transaction emitting RateLimitParametersSet
1393
+ event
1394
+ """
1395
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1396
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.RateLimitParametersSet().process_receipt(tx_receipt)
1397
+ def get_strategy_updated_event(
1398
+ self, tx_hash: Union[HexBytes, bytes]
1399
+ ) -> Tuple[AttributeDict]:
1400
+ """Get log entry for StrategyUpdated event.
1401
+
1402
+ :param tx_hash: hash of transaction emitting StrategyUpdated event
1403
+ """
1404
+ tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
1405
+ return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=ICollateral.abi()).events.StrategyUpdated().process_receipt(tx_receipt)
1406
+
1407
+ @staticmethod
1408
+ def abi():
1409
+ """Return the ABI to the underlying contract."""
1410
+ return json.loads(
1411
+ '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":true,"internalType":"address","name":"underlyingToken","type":"address"},{"indexed":false,"internalType":"enum SharedDefs.Flavor","name":"flavor","type":"uint8"},{"indexed":false,"internalType":"uint128","name":"minimumRateLimit","type":"uint128"}],"name":"ExchangeCollateralAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collateralToken","type":"address"}],"name":"ExchangeCollateralRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint128","name":"minimumRateLimit","type":"uint128"}],"name":"ExchangeCollateralUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"maxDepositedAddresses","type":"uint128"}],"name":"MaxDepositedAddressesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"minDeposit","type":"uint128"}],"name":"MinDepositSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"rateLimitPeriod","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"rateLimitPercentage","type":"uint128"}],"name":"RateLimitParametersSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"collateralAddress","type":"address"},{"indexed":true,"internalType":"bytes4","name":"strategyIdHash","type":"bytes4"},{"indexed":false,"internalType":"bytes32","name":"strategyId","type":"bytes32"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"enum DepositDefs.StrategyUpdateKind","name":"updateKind","type":"uint8"}],"name":"StrategyUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"uint128","name":"_minimumRateLimit","type":"uint128"}],"name":"addExchangeCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralAddress","type":"address"},{"internalType":"bytes32","name":"_strategyId","type":"bytes32"},{"internalType":"uint128","name":"_amount","type":"uint128"},{"internalType":"uint256","name":"_expiryBlock","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_traders","type":"address[]"}],"name":"getAddressesHaveDeposited","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"}],"name":"getExchangeCollateralInfo","outputs":[{"components":[{"internalType":"address","name":"underlyingToken","type":"address"},{"internalType":"enum SharedDefs.Flavor","name":"flavor","type":"uint8"},{"internalType":"bool","name":"isListed","type":"bool"}],"internalType":"struct DepositDefs.ExchangeCollateral","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGuardedDepositInfo","outputs":[{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"getMaximumWithdrawal","outputs":[{"internalType":"uint128","name":"maximumWithdrawalAmount","type":"uint128"},{"internalType":"uint128","name":"blocksRemaining","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_withdrawAddress","type":"address"},{"internalType":"bytes4","name":"_strategyIdHash","type":"bytes4"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint128","name":"_blockNumber","type":"uint128"}],"name":"getProcessedWithdrawals","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRateLimitParameters","outputs":[{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_withdrawAddress","type":"address"},{"internalType":"bytes4","name":"_strategyIdHash","type":"bytes4"},{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"getUnprocessedWithdrawals","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"getWithdrawalAllowance","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_rateLimitPeriod","type":"uint128"},{"internalType":"uint128","name":"_rateLimitPercentage","type":"uint128"},{"internalType":"uint128","name":"_maxDepositedAddresses","type":"uint128"},{"internalType":"uint128","name":"_minDeposit","type":"uint128"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"}],"name":"removeExchangeCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_maxDepositedAddresses","type":"uint128"}],"name":"setMaxDepositedAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_minDeposit","type":"uint128"}],"name":"setMinDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_rateLimitPeriod","type":"uint128"},{"internalType":"uint128","name":"_rateLimitPercentage","type":"uint128"}],"name":"setRateLimitParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"uint128","name":"_minimumRateLimit","type":"uint128"}],"name":"updateExchangeCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_strategyIdHash","type":"bytes4"},{"components":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint128[]","name":"amounts","type":"uint128[]"}],"internalType":"struct SharedDefs.Balance128","name":"_withdrawalData","type":"tuple"},{"components":[{"components":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"internalType":"struct SharedDefs.Balance256","name":"availCollateral","type":"tuple"},{"components":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint128[]","name":"amounts","type":"uint128[]"}],"internalType":"struct SharedDefs.Balance128","name":"lockedCollateral","type":"tuple"},{"internalType":"uint64","name":"maxLeverage","type":"uint64"},{"internalType":"bool","name":"frozen","type":"bool"}],"internalType":"struct DepositDefs.StrategyData","name":"_strategy","type":"tuple"},{"internalType":"bytes","name":"_proof","type":"bytes"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]' # noqa: E501 (line-too-long)
1412
+ )
1413
+
1414
+ # pylint: disable=too-many-lines