ddx-python 1.0.4__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.
- ddx/.gitignore +1 -0
- ddx/__init__.py +58 -0
- ddx/_rust/__init__.pyi +2685 -0
- ddx/_rust/common/__init__.pyi +17 -0
- ddx/_rust/common/accounting.pyi +6 -0
- ddx/_rust/common/enums.pyi +3 -0
- ddx/_rust/common/requests/__init__.pyi +23 -0
- ddx/_rust/common/requests/intents.pyi +19 -0
- ddx/_rust/common/specs.pyi +17 -0
- ddx/_rust/common/state/__init__.pyi +41 -0
- ddx/_rust/common/state/keys.pyi +29 -0
- ddx/_rust/common/transactions.pyi +7 -0
- ddx/_rust/decimal.pyi +3 -0
- ddx/_rust/h256.pyi +3 -0
- ddx/_rust.abi3.so +0 -0
- ddx/app_config/ethereum/addresses.json +526 -0
- ddx/auditor/README.md +32 -0
- ddx/auditor/__init__.py +0 -0
- ddx/auditor/auditor_driver.py +1043 -0
- ddx/auditor/websocket_message.py +54 -0
- ddx/common/__init__.py +0 -0
- ddx/common/epoch_params.py +28 -0
- ddx/common/fill_context.py +141 -0
- ddx/common/logging.py +184 -0
- ddx/common/market_aware_account.py +259 -0
- ddx/common/market_specs.py +64 -0
- ddx/common/trade_mining_params.py +19 -0
- ddx/common/transaction_utils.py +85 -0
- ddx/common/transactions/__init__.py +0 -0
- ddx/common/transactions/advance_epoch.py +91 -0
- ddx/common/transactions/advance_settlement_epoch.py +63 -0
- ddx/common/transactions/all_price_checkpoints.py +84 -0
- ddx/common/transactions/cancel.py +76 -0
- ddx/common/transactions/cancel_all.py +88 -0
- ddx/common/transactions/complete_fill.py +103 -0
- ddx/common/transactions/disaster_recovery.py +96 -0
- ddx/common/transactions/event.py +48 -0
- ddx/common/transactions/fee_distribution.py +119 -0
- ddx/common/transactions/funding.py +292 -0
- ddx/common/transactions/futures_expiry.py +123 -0
- ddx/common/transactions/genesis.py +108 -0
- ddx/common/transactions/inner/__init__.py +0 -0
- ddx/common/transactions/inner/adl_outcome.py +25 -0
- ddx/common/transactions/inner/fill.py +232 -0
- ddx/common/transactions/inner/liquidated_position.py +41 -0
- ddx/common/transactions/inner/liquidation_entry.py +41 -0
- ddx/common/transactions/inner/liquidation_fill.py +118 -0
- ddx/common/transactions/inner/outcome.py +32 -0
- ddx/common/transactions/inner/trade_fill.py +292 -0
- ddx/common/transactions/insurance_fund_update.py +138 -0
- ddx/common/transactions/insurance_fund_withdraw.py +100 -0
- ddx/common/transactions/liquidation.py +353 -0
- ddx/common/transactions/partial_fill.py +125 -0
- ddx/common/transactions/pnl_realization.py +120 -0
- ddx/common/transactions/post.py +72 -0
- ddx/common/transactions/post_order.py +95 -0
- ddx/common/transactions/price_checkpoint.py +97 -0
- ddx/common/transactions/signer_registered.py +62 -0
- ddx/common/transactions/specs_update.py +61 -0
- ddx/common/transactions/strategy_update.py +158 -0
- ddx/common/transactions/tradable_product_update.py +98 -0
- ddx/common/transactions/trade_mining.py +147 -0
- ddx/common/transactions/trader_update.py +131 -0
- ddx/common/transactions/withdraw.py +90 -0
- ddx/common/transactions/withdraw_ddx.py +74 -0
- ddx/common/utils.py +176 -0
- ddx/config.py +17 -0
- ddx/derivadex_client.py +270 -0
- ddx/models/__init__.py +0 -0
- ddx/models/base.py +132 -0
- ddx/py.typed +0 -0
- ddx/realtime_client/__init__.py +2 -0
- ddx/realtime_client/config.py +2 -0
- ddx/realtime_client/models/__init__.py +611 -0
- ddx/realtime_client/realtime_client.py +646 -0
- ddx/rest_client/__init__.py +0 -0
- ddx/rest_client/clients/__init__.py +0 -0
- ddx/rest_client/clients/base_client.py +60 -0
- ddx/rest_client/clients/market_client.py +1243 -0
- ddx/rest_client/clients/on_chain_client.py +439 -0
- ddx/rest_client/clients/signed_client.py +292 -0
- ddx/rest_client/clients/system_client.py +843 -0
- ddx/rest_client/clients/trade_client.py +357 -0
- ddx/rest_client/constants/__init__.py +0 -0
- ddx/rest_client/constants/endpoints.py +66 -0
- ddx/rest_client/contracts/__init__.py +0 -0
- ddx/rest_client/contracts/checkpoint/__init__.py +560 -0
- ddx/rest_client/contracts/ddx/__init__.py +1949 -0
- ddx/rest_client/contracts/dummy_token/__init__.py +1014 -0
- ddx/rest_client/contracts/i_collateral/__init__.py +1414 -0
- ddx/rest_client/contracts/i_stake/__init__.py +696 -0
- ddx/rest_client/exceptions/__init__.py +0 -0
- ddx/rest_client/exceptions/exceptions.py +32 -0
- ddx/rest_client/http/__init__.py +0 -0
- ddx/rest_client/http/http_client.py +336 -0
- ddx/rest_client/models/__init__.py +0 -0
- ddx/rest_client/models/market.py +693 -0
- ddx/rest_client/models/signed.py +61 -0
- ddx/rest_client/models/system.py +311 -0
- ddx/rest_client/models/trade.py +185 -0
- ddx/rest_client/utils/__init__.py +0 -0
- ddx/rest_client/utils/encryption_utils.py +26 -0
- ddx/utils/__init__.py +0 -0
- ddx_python-1.0.4.dist-info/METADATA +63 -0
- ddx_python-1.0.4.dist-info/RECORD +106 -0
- ddx_python-1.0.4.dist-info/WHEEL +5 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
"""Generated wrapper for IStake 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 IStake 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
|
+
IStakeValidator,
|
|
33
|
+
)
|
|
34
|
+
except ImportError:
|
|
35
|
+
|
|
36
|
+
class IStakeValidator( # 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 DepositDefsTraderData(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
|
+
availDDXBalance: int
|
|
65
|
+
|
|
66
|
+
lockedDDXBalance: int
|
|
67
|
+
|
|
68
|
+
referralAddress: str
|
|
69
|
+
|
|
70
|
+
payFeesInDDX: bool
|
|
71
|
+
|
|
72
|
+
accessDenied: bool
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class DepositDdxMethod(ContractMethod): # pylint: disable=invalid-name
|
|
76
|
+
"""Various interfaces to the depositDDX method."""
|
|
77
|
+
|
|
78
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
79
|
+
"""Persist instance data."""
|
|
80
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
81
|
+
self._underlying_method = contract_function
|
|
82
|
+
|
|
83
|
+
def validate_and_normalize_inputs(self, amount: int, expiry_block: int, signature: Union[bytes, str]):
|
|
84
|
+
"""Validate the inputs to the depositDDX method."""
|
|
85
|
+
self.validator.assert_valid(
|
|
86
|
+
method_name='depositDDX',
|
|
87
|
+
parameter_name='_amount',
|
|
88
|
+
argument_value=amount,
|
|
89
|
+
)
|
|
90
|
+
self.validator.assert_valid(
|
|
91
|
+
method_name='depositDDX',
|
|
92
|
+
parameter_name='_expiryBlock',
|
|
93
|
+
argument_value=expiry_block,
|
|
94
|
+
)
|
|
95
|
+
# safeguard against fractional inputs
|
|
96
|
+
expiry_block = int(expiry_block)
|
|
97
|
+
self.validator.assert_valid(
|
|
98
|
+
method_name='depositDDX',
|
|
99
|
+
parameter_name='_signature',
|
|
100
|
+
argument_value=signature,
|
|
101
|
+
)
|
|
102
|
+
return (amount, expiry_block, signature)
|
|
103
|
+
|
|
104
|
+
def call(self, amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> None:
|
|
105
|
+
"""Execute underlying contract method via eth_call.
|
|
106
|
+
|
|
107
|
+
:param _amount: The amount to deposit.
|
|
108
|
+
:param _expiryBlock: Expiry block number for KYC authorization.
|
|
109
|
+
:param _signature: Signature of KYC authorization address.
|
|
110
|
+
:param tx_params: transaction parameters
|
|
111
|
+
:returns: the return value of the underlying method.
|
|
112
|
+
"""
|
|
113
|
+
(amount, expiry_block, signature) = self.validate_and_normalize_inputs(amount, expiry_block, signature)
|
|
114
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
115
|
+
self._underlying_method(amount, expiry_block, signature).call(tx_params.as_dict())
|
|
116
|
+
|
|
117
|
+
def send_transaction(self, amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
118
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
119
|
+
|
|
120
|
+
:param _amount: The amount to deposit.
|
|
121
|
+
:param _expiryBlock: Expiry block number for KYC authorization.
|
|
122
|
+
:param _signature: Signature of KYC authorization address.
|
|
123
|
+
:param tx_params: transaction parameters
|
|
124
|
+
"""
|
|
125
|
+
(amount, expiry_block, signature) = self.validate_and_normalize_inputs(amount, expiry_block, signature)
|
|
126
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
127
|
+
return self._underlying_method(amount, expiry_block, signature).transact(tx_params.as_dict())
|
|
128
|
+
|
|
129
|
+
def build_transaction(self, amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
|
|
130
|
+
"""Construct calldata to be used as input to the method."""
|
|
131
|
+
(amount, expiry_block, signature) = self.validate_and_normalize_inputs(amount, expiry_block, signature)
|
|
132
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
133
|
+
return self._underlying_method(amount, expiry_block, signature).build_transaction(tx_params.as_dict())
|
|
134
|
+
|
|
135
|
+
def estimate_gas(self, amount: int, expiry_block: int, signature: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
|
|
136
|
+
"""Estimate gas consumption of method call."""
|
|
137
|
+
(amount, expiry_block, signature) = self.validate_and_normalize_inputs(amount, expiry_block, signature)
|
|
138
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
139
|
+
return self._underlying_method(amount, expiry_block, signature).estimate_gas(tx_params.as_dict())
|
|
140
|
+
|
|
141
|
+
class GetMaxDdxCapMethod(ContractMethod): # pylint: disable=invalid-name
|
|
142
|
+
"""Various interfaces to the getMaxDDXCap method."""
|
|
143
|
+
|
|
144
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function):
|
|
145
|
+
"""Persist instance data."""
|
|
146
|
+
super().__init__(web3_or_provider, contract_address)
|
|
147
|
+
self._underlying_method = contract_function
|
|
148
|
+
|
|
149
|
+
def call(self, tx_params: Optional[TxParams] = None) -> int:
|
|
150
|
+
"""Execute underlying contract method via eth_call.
|
|
151
|
+
|
|
152
|
+
:param tx_params: transaction parameters
|
|
153
|
+
:returns: the return value of the underlying method.
|
|
154
|
+
"""
|
|
155
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
156
|
+
returned = self._underlying_method().call(tx_params.as_dict())
|
|
157
|
+
return int(returned)
|
|
158
|
+
|
|
159
|
+
def send_transaction(self, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
160
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
161
|
+
|
|
162
|
+
:param tx_params: transaction parameters
|
|
163
|
+
"""
|
|
164
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
165
|
+
return self._underlying_method().transact(tx_params.as_dict())
|
|
166
|
+
|
|
167
|
+
def build_transaction(self, tx_params: Optional[TxParams] = None) -> dict:
|
|
168
|
+
"""Construct calldata to be used as input to the method."""
|
|
169
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
170
|
+
return self._underlying_method().build_transaction(tx_params.as_dict())
|
|
171
|
+
|
|
172
|
+
def estimate_gas(self, tx_params: Optional[TxParams] = None) -> int:
|
|
173
|
+
"""Estimate gas consumption of method call."""
|
|
174
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
175
|
+
return self._underlying_method().estimate_gas(tx_params.as_dict())
|
|
176
|
+
|
|
177
|
+
class GetProcessedDdxWithdrawalsMethod(ContractMethod): # pylint: disable=invalid-name
|
|
178
|
+
"""Various interfaces to the getProcessedDDXWithdrawals method."""
|
|
179
|
+
|
|
180
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
181
|
+
"""Persist instance data."""
|
|
182
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
183
|
+
self._underlying_method = contract_function
|
|
184
|
+
|
|
185
|
+
def validate_and_normalize_inputs(self, withdraw_address: str, block_number: int):
|
|
186
|
+
"""Validate the inputs to the getProcessedDDXWithdrawals method."""
|
|
187
|
+
self.validator.assert_valid(
|
|
188
|
+
method_name='getProcessedDDXWithdrawals',
|
|
189
|
+
parameter_name='_withdrawAddress',
|
|
190
|
+
argument_value=withdraw_address,
|
|
191
|
+
)
|
|
192
|
+
withdraw_address = self.validate_and_checksum_address(withdraw_address)
|
|
193
|
+
self.validator.assert_valid(
|
|
194
|
+
method_name='getProcessedDDXWithdrawals',
|
|
195
|
+
parameter_name='_blockNumber',
|
|
196
|
+
argument_value=block_number,
|
|
197
|
+
)
|
|
198
|
+
return (withdraw_address, block_number)
|
|
199
|
+
|
|
200
|
+
def call(self, withdraw_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> int:
|
|
201
|
+
"""Execute underlying contract method via eth_call.
|
|
202
|
+
|
|
203
|
+
:param _blockNumber: The confirmed block number to use for the query.
|
|
204
|
+
:param _withdrawAddress: The address that is attempting to withdraw.
|
|
205
|
+
:param tx_params: transaction parameters
|
|
206
|
+
:returns: the return value of the underlying method.
|
|
207
|
+
"""
|
|
208
|
+
(withdraw_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, block_number)
|
|
209
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
210
|
+
returned = self._underlying_method(withdraw_address, block_number).call(tx_params.as_dict())
|
|
211
|
+
return int(returned)
|
|
212
|
+
|
|
213
|
+
def send_transaction(self, withdraw_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
214
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
215
|
+
|
|
216
|
+
:param _blockNumber: The confirmed block number to use for the query.
|
|
217
|
+
:param _withdrawAddress: The address that is attempting to withdraw.
|
|
218
|
+
:param tx_params: transaction parameters
|
|
219
|
+
"""
|
|
220
|
+
(withdraw_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, block_number)
|
|
221
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
222
|
+
return self._underlying_method(withdraw_address, block_number).transact(tx_params.as_dict())
|
|
223
|
+
|
|
224
|
+
def build_transaction(self, withdraw_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> dict:
|
|
225
|
+
"""Construct calldata to be used as input to the method."""
|
|
226
|
+
(withdraw_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, block_number)
|
|
227
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
228
|
+
return self._underlying_method(withdraw_address, block_number).build_transaction(tx_params.as_dict())
|
|
229
|
+
|
|
230
|
+
def estimate_gas(self, withdraw_address: str, block_number: int, tx_params: Optional[TxParams] = None) -> int:
|
|
231
|
+
"""Estimate gas consumption of method call."""
|
|
232
|
+
(withdraw_address, block_number) = self.validate_and_normalize_inputs(withdraw_address, block_number)
|
|
233
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
234
|
+
return self._underlying_method(withdraw_address, block_number).estimate_gas(tx_params.as_dict())
|
|
235
|
+
|
|
236
|
+
class GetUnprocessedDdxWithdrawalsMethod(ContractMethod): # pylint: disable=invalid-name
|
|
237
|
+
"""Various interfaces to the getUnprocessedDDXWithdrawals method."""
|
|
238
|
+
|
|
239
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
240
|
+
"""Persist instance data."""
|
|
241
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
242
|
+
self._underlying_method = contract_function
|
|
243
|
+
|
|
244
|
+
def validate_and_normalize_inputs(self, withdraw_address: str):
|
|
245
|
+
"""Validate the inputs to the getUnprocessedDDXWithdrawals method."""
|
|
246
|
+
self.validator.assert_valid(
|
|
247
|
+
method_name='getUnprocessedDDXWithdrawals',
|
|
248
|
+
parameter_name='_withdrawAddress',
|
|
249
|
+
argument_value=withdraw_address,
|
|
250
|
+
)
|
|
251
|
+
withdraw_address = self.validate_and_checksum_address(withdraw_address)
|
|
252
|
+
return (withdraw_address)
|
|
253
|
+
|
|
254
|
+
def call(self, withdraw_address: str, tx_params: Optional[TxParams] = None) -> int:
|
|
255
|
+
"""Execute underlying contract method via eth_call.
|
|
256
|
+
|
|
257
|
+
:param _withdrawAddress: The address that is attempting to withdraw.
|
|
258
|
+
:param tx_params: transaction parameters
|
|
259
|
+
:returns: the return value of the underlying method.
|
|
260
|
+
"""
|
|
261
|
+
(withdraw_address) = self.validate_and_normalize_inputs(withdraw_address)
|
|
262
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
263
|
+
returned = self._underlying_method(withdraw_address).call(tx_params.as_dict())
|
|
264
|
+
return int(returned)
|
|
265
|
+
|
|
266
|
+
def send_transaction(self, withdraw_address: str, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
267
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
268
|
+
|
|
269
|
+
:param _withdrawAddress: The address that is attempting to withdraw.
|
|
270
|
+
:param tx_params: transaction parameters
|
|
271
|
+
"""
|
|
272
|
+
(withdraw_address) = self.validate_and_normalize_inputs(withdraw_address)
|
|
273
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
274
|
+
return self._underlying_method(withdraw_address).transact(tx_params.as_dict())
|
|
275
|
+
|
|
276
|
+
def build_transaction(self, withdraw_address: str, tx_params: Optional[TxParams] = None) -> dict:
|
|
277
|
+
"""Construct calldata to be used as input to the method."""
|
|
278
|
+
(withdraw_address) = self.validate_and_normalize_inputs(withdraw_address)
|
|
279
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
280
|
+
return self._underlying_method(withdraw_address).build_transaction(tx_params.as_dict())
|
|
281
|
+
|
|
282
|
+
def estimate_gas(self, withdraw_address: str, tx_params: Optional[TxParams] = None) -> int:
|
|
283
|
+
"""Estimate gas consumption of method call."""
|
|
284
|
+
(withdraw_address) = self.validate_and_normalize_inputs(withdraw_address)
|
|
285
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
286
|
+
return self._underlying_method(withdraw_address).estimate_gas(tx_params.as_dict())
|
|
287
|
+
|
|
288
|
+
class InitializeMethod(ContractMethod): # pylint: disable=invalid-name
|
|
289
|
+
"""Various interfaces to the initialize method."""
|
|
290
|
+
|
|
291
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
292
|
+
"""Persist instance data."""
|
|
293
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
294
|
+
self._underlying_method = contract_function
|
|
295
|
+
|
|
296
|
+
def validate_and_normalize_inputs(self, ddx_minimum_rate_limit: int, max_ddx_cap: int):
|
|
297
|
+
"""Validate the inputs to the initialize method."""
|
|
298
|
+
self.validator.assert_valid(
|
|
299
|
+
method_name='initialize',
|
|
300
|
+
parameter_name='_ddxMinimumRateLimit',
|
|
301
|
+
argument_value=ddx_minimum_rate_limit,
|
|
302
|
+
)
|
|
303
|
+
self.validator.assert_valid(
|
|
304
|
+
method_name='initialize',
|
|
305
|
+
parameter_name='_maxDDXCap',
|
|
306
|
+
argument_value=max_ddx_cap,
|
|
307
|
+
)
|
|
308
|
+
# safeguard against fractional inputs
|
|
309
|
+
max_ddx_cap = int(max_ddx_cap)
|
|
310
|
+
return (ddx_minimum_rate_limit, max_ddx_cap)
|
|
311
|
+
|
|
312
|
+
def call(self, ddx_minimum_rate_limit: int, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> None:
|
|
313
|
+
"""Execute underlying contract method via eth_call.
|
|
314
|
+
|
|
315
|
+
This function is intended to be the initialization target of the
|
|
316
|
+
diamond cut function. This function is not included in the selectors
|
|
317
|
+
being added to the diamond, meaning it cannot be called again.
|
|
318
|
+
|
|
319
|
+
:param _ddxMinimumRateLimit: The minimum rate limit for DDX withdrawn
|
|
320
|
+
from the DDX trader leaves.
|
|
321
|
+
:param _maxDDXCap: The maximum DDX capitalization allowed within the
|
|
322
|
+
SMT.
|
|
323
|
+
:param tx_params: transaction parameters
|
|
324
|
+
:returns: the return value of the underlying method.
|
|
325
|
+
"""
|
|
326
|
+
(ddx_minimum_rate_limit, max_ddx_cap) = self.validate_and_normalize_inputs(ddx_minimum_rate_limit, max_ddx_cap)
|
|
327
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
328
|
+
self._underlying_method(ddx_minimum_rate_limit, max_ddx_cap).call(tx_params.as_dict())
|
|
329
|
+
|
|
330
|
+
def send_transaction(self, ddx_minimum_rate_limit: int, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
331
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
332
|
+
|
|
333
|
+
This function is intended to be the initialization target of the
|
|
334
|
+
diamond cut function. This function is not included in the selectors
|
|
335
|
+
being added to the diamond, meaning it cannot be called again.
|
|
336
|
+
|
|
337
|
+
:param _ddxMinimumRateLimit: The minimum rate limit for DDX withdrawn
|
|
338
|
+
from the DDX trader leaves.
|
|
339
|
+
:param _maxDDXCap: The maximum DDX capitalization allowed within the
|
|
340
|
+
SMT.
|
|
341
|
+
:param tx_params: transaction parameters
|
|
342
|
+
"""
|
|
343
|
+
(ddx_minimum_rate_limit, max_ddx_cap) = self.validate_and_normalize_inputs(ddx_minimum_rate_limit, max_ddx_cap)
|
|
344
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
345
|
+
return self._underlying_method(ddx_minimum_rate_limit, max_ddx_cap).transact(tx_params.as_dict())
|
|
346
|
+
|
|
347
|
+
def build_transaction(self, ddx_minimum_rate_limit: int, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> dict:
|
|
348
|
+
"""Construct calldata to be used as input to the method."""
|
|
349
|
+
(ddx_minimum_rate_limit, max_ddx_cap) = self.validate_and_normalize_inputs(ddx_minimum_rate_limit, max_ddx_cap)
|
|
350
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
351
|
+
return self._underlying_method(ddx_minimum_rate_limit, max_ddx_cap).build_transaction(tx_params.as_dict())
|
|
352
|
+
|
|
353
|
+
def estimate_gas(self, ddx_minimum_rate_limit: int, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> int:
|
|
354
|
+
"""Estimate gas consumption of method call."""
|
|
355
|
+
(ddx_minimum_rate_limit, max_ddx_cap) = self.validate_and_normalize_inputs(ddx_minimum_rate_limit, max_ddx_cap)
|
|
356
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
357
|
+
return self._underlying_method(ddx_minimum_rate_limit, max_ddx_cap).estimate_gas(tx_params.as_dict())
|
|
358
|
+
|
|
359
|
+
class SetDdxRateLimitsMethod(ContractMethod): # pylint: disable=invalid-name
|
|
360
|
+
"""Various interfaces to the setDDXRateLimits method."""
|
|
361
|
+
|
|
362
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
363
|
+
"""Persist instance data."""
|
|
364
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
365
|
+
self._underlying_method = contract_function
|
|
366
|
+
|
|
367
|
+
def validate_and_normalize_inputs(self, minimum_rate_limit: int):
|
|
368
|
+
"""Validate the inputs to the setDDXRateLimits method."""
|
|
369
|
+
self.validator.assert_valid(
|
|
370
|
+
method_name='setDDXRateLimits',
|
|
371
|
+
parameter_name='_minimumRateLimit',
|
|
372
|
+
argument_value=minimum_rate_limit,
|
|
373
|
+
)
|
|
374
|
+
return (minimum_rate_limit)
|
|
375
|
+
|
|
376
|
+
def call(self, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> None:
|
|
377
|
+
"""Execute underlying contract method via eth_call.
|
|
378
|
+
|
|
379
|
+
:param _minimumRateLimit: The minimum amount that the rate limit will
|
|
380
|
+
be set to.
|
|
381
|
+
:param tx_params: transaction parameters
|
|
382
|
+
:returns: the return value of the underlying method.
|
|
383
|
+
"""
|
|
384
|
+
(minimum_rate_limit) = self.validate_and_normalize_inputs(minimum_rate_limit)
|
|
385
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
386
|
+
self._underlying_method(minimum_rate_limit).call(tx_params.as_dict())
|
|
387
|
+
|
|
388
|
+
def send_transaction(self, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
389
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
390
|
+
|
|
391
|
+
:param _minimumRateLimit: The minimum amount that the rate limit will
|
|
392
|
+
be set to.
|
|
393
|
+
:param tx_params: transaction parameters
|
|
394
|
+
"""
|
|
395
|
+
(minimum_rate_limit) = self.validate_and_normalize_inputs(minimum_rate_limit)
|
|
396
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
397
|
+
return self._underlying_method(minimum_rate_limit).transact(tx_params.as_dict())
|
|
398
|
+
|
|
399
|
+
def build_transaction(self, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> dict:
|
|
400
|
+
"""Construct calldata to be used as input to the method."""
|
|
401
|
+
(minimum_rate_limit) = self.validate_and_normalize_inputs(minimum_rate_limit)
|
|
402
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
403
|
+
return self._underlying_method(minimum_rate_limit).build_transaction(tx_params.as_dict())
|
|
404
|
+
|
|
405
|
+
def estimate_gas(self, minimum_rate_limit: int, tx_params: Optional[TxParams] = None) -> int:
|
|
406
|
+
"""Estimate gas consumption of method call."""
|
|
407
|
+
(minimum_rate_limit) = self.validate_and_normalize_inputs(minimum_rate_limit)
|
|
408
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
409
|
+
return self._underlying_method(minimum_rate_limit).estimate_gas(tx_params.as_dict())
|
|
410
|
+
|
|
411
|
+
class SetMaxDdxCapMethod(ContractMethod): # pylint: disable=invalid-name
|
|
412
|
+
"""Various interfaces to the setMaxDDXCap method."""
|
|
413
|
+
|
|
414
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
415
|
+
"""Persist instance data."""
|
|
416
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
417
|
+
self._underlying_method = contract_function
|
|
418
|
+
|
|
419
|
+
def validate_and_normalize_inputs(self, max_ddx_cap: int):
|
|
420
|
+
"""Validate the inputs to the setMaxDDXCap method."""
|
|
421
|
+
self.validator.assert_valid(
|
|
422
|
+
method_name='setMaxDDXCap',
|
|
423
|
+
parameter_name='_maxDDXCap',
|
|
424
|
+
argument_value=max_ddx_cap,
|
|
425
|
+
)
|
|
426
|
+
# safeguard against fractional inputs
|
|
427
|
+
max_ddx_cap = int(max_ddx_cap)
|
|
428
|
+
return (max_ddx_cap)
|
|
429
|
+
|
|
430
|
+
def call(self, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> None:
|
|
431
|
+
"""Execute underlying contract method via eth_call.
|
|
432
|
+
|
|
433
|
+
We intentionally avoid checking to see that the max DDX cap is greater
|
|
434
|
+
than the current DDX balance as this check could be front-run in order
|
|
435
|
+
to keep the cap at the elevated level. Instead, we simply set the cap
|
|
436
|
+
to the chosen value which prevents further deposits from taking place.
|
|
437
|
+
The operation is still susceptible to front-running, but the ability to
|
|
438
|
+
keep the cap arbitrarily elevated is removed.
|
|
439
|
+
|
|
440
|
+
:param _maxDDXCap: The maximum amount of DDX that can be held within
|
|
441
|
+
the DerivaDEX SMT.
|
|
442
|
+
:param tx_params: transaction parameters
|
|
443
|
+
:returns: the return value of the underlying method.
|
|
444
|
+
"""
|
|
445
|
+
(max_ddx_cap) = self.validate_and_normalize_inputs(max_ddx_cap)
|
|
446
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
447
|
+
self._underlying_method(max_ddx_cap).call(tx_params.as_dict())
|
|
448
|
+
|
|
449
|
+
def send_transaction(self, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
450
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
451
|
+
|
|
452
|
+
We intentionally avoid checking to see that the max DDX cap is greater
|
|
453
|
+
than the current DDX balance as this check could be front-run in order
|
|
454
|
+
to keep the cap at the elevated level. Instead, we simply set the cap
|
|
455
|
+
to the chosen value which prevents further deposits from taking place.
|
|
456
|
+
The operation is still susceptible to front-running, but the ability to
|
|
457
|
+
keep the cap arbitrarily elevated is removed.
|
|
458
|
+
|
|
459
|
+
:param _maxDDXCap: The maximum amount of DDX that can be held within
|
|
460
|
+
the DerivaDEX SMT.
|
|
461
|
+
:param tx_params: transaction parameters
|
|
462
|
+
"""
|
|
463
|
+
(max_ddx_cap) = self.validate_and_normalize_inputs(max_ddx_cap)
|
|
464
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
465
|
+
return self._underlying_method(max_ddx_cap).transact(tx_params.as_dict())
|
|
466
|
+
|
|
467
|
+
def build_transaction(self, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> dict:
|
|
468
|
+
"""Construct calldata to be used as input to the method."""
|
|
469
|
+
(max_ddx_cap) = self.validate_and_normalize_inputs(max_ddx_cap)
|
|
470
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
471
|
+
return self._underlying_method(max_ddx_cap).build_transaction(tx_params.as_dict())
|
|
472
|
+
|
|
473
|
+
def estimate_gas(self, max_ddx_cap: int, tx_params: Optional[TxParams] = None) -> int:
|
|
474
|
+
"""Estimate gas consumption of method call."""
|
|
475
|
+
(max_ddx_cap) = self.validate_and_normalize_inputs(max_ddx_cap)
|
|
476
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
477
|
+
return self._underlying_method(max_ddx_cap).estimate_gas(tx_params.as_dict())
|
|
478
|
+
|
|
479
|
+
class WithdrawDdxMethod(ContractMethod): # pylint: disable=invalid-name
|
|
480
|
+
"""Various interfaces to the withdrawDDX method."""
|
|
481
|
+
|
|
482
|
+
def __init__(self, web3_or_provider: Union[Web3, BaseProvider], contract_address: str, contract_function, validator: Validator=None):
|
|
483
|
+
"""Persist instance data."""
|
|
484
|
+
super().__init__(web3_or_provider, contract_address, validator)
|
|
485
|
+
self._underlying_method = contract_function
|
|
486
|
+
|
|
487
|
+
def validate_and_normalize_inputs(self, amount: int, trader: DepositDefsTraderData, proof: Union[bytes, str]):
|
|
488
|
+
"""Validate the inputs to the withdrawDDX method."""
|
|
489
|
+
self.validator.assert_valid(
|
|
490
|
+
method_name='withdrawDDX',
|
|
491
|
+
parameter_name='_amount',
|
|
492
|
+
argument_value=amount,
|
|
493
|
+
)
|
|
494
|
+
self.validator.assert_valid(
|
|
495
|
+
method_name='withdrawDDX',
|
|
496
|
+
parameter_name='_trader',
|
|
497
|
+
argument_value=trader,
|
|
498
|
+
)
|
|
499
|
+
self.validator.assert_valid(
|
|
500
|
+
method_name='withdrawDDX',
|
|
501
|
+
parameter_name='_proof',
|
|
502
|
+
argument_value=proof,
|
|
503
|
+
)
|
|
504
|
+
return (amount, trader, proof)
|
|
505
|
+
|
|
506
|
+
def call(self, amount: int, trader: DepositDefsTraderData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> None:
|
|
507
|
+
"""Execute underlying contract method via eth_call.
|
|
508
|
+
|
|
509
|
+
:param _amount: The amount of DDX to withdraw.
|
|
510
|
+
:param _proof: The merkle proof that will be used to verify whether or
|
|
511
|
+
not the trader can withdraw the requested amount.
|
|
512
|
+
:param _trader: The Trader leaf that should represent the sender's
|
|
513
|
+
trader account within the DDX state root.
|
|
514
|
+
:param tx_params: transaction parameters
|
|
515
|
+
:returns: the return value of the underlying method.
|
|
516
|
+
"""
|
|
517
|
+
(amount, trader, proof) = self.validate_and_normalize_inputs(amount, trader, proof)
|
|
518
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
519
|
+
self._underlying_method(amount, trader, proof).call(tx_params.as_dict())
|
|
520
|
+
|
|
521
|
+
def send_transaction(self, amount: int, trader: DepositDefsTraderData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
|
|
522
|
+
"""Execute underlying contract method via eth_sendTransaction.
|
|
523
|
+
|
|
524
|
+
:param _amount: The amount of DDX to withdraw.
|
|
525
|
+
:param _proof: The merkle proof that will be used to verify whether or
|
|
526
|
+
not the trader can withdraw the requested amount.
|
|
527
|
+
:param _trader: The Trader leaf that should represent the sender's
|
|
528
|
+
trader account within the DDX state root.
|
|
529
|
+
:param tx_params: transaction parameters
|
|
530
|
+
"""
|
|
531
|
+
(amount, trader, proof) = self.validate_and_normalize_inputs(amount, trader, proof)
|
|
532
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
533
|
+
return self._underlying_method(amount, trader, proof).transact(tx_params.as_dict())
|
|
534
|
+
|
|
535
|
+
def build_transaction(self, amount: int, trader: DepositDefsTraderData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> dict:
|
|
536
|
+
"""Construct calldata to be used as input to the method."""
|
|
537
|
+
(amount, trader, proof) = self.validate_and_normalize_inputs(amount, trader, proof)
|
|
538
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
539
|
+
return self._underlying_method(amount, trader, proof).build_transaction(tx_params.as_dict())
|
|
540
|
+
|
|
541
|
+
def estimate_gas(self, amount: int, trader: DepositDefsTraderData, proof: Union[bytes, str], tx_params: Optional[TxParams] = None) -> int:
|
|
542
|
+
"""Estimate gas consumption of method call."""
|
|
543
|
+
(amount, trader, proof) = self.validate_and_normalize_inputs(amount, trader, proof)
|
|
544
|
+
tx_params = super().normalize_tx_params(tx_params)
|
|
545
|
+
return self._underlying_method(amount, trader, proof).estimate_gas(tx_params.as_dict())
|
|
546
|
+
|
|
547
|
+
# pylint: disable=too-many-public-methods,too-many-instance-attributes
|
|
548
|
+
class IStake:
|
|
549
|
+
"""Wrapper class for IStake Solidity contract.
|
|
550
|
+
|
|
551
|
+
All method parameters of type `bytes`:code: should be encoded as UTF-8,
|
|
552
|
+
which can be accomplished via `str.encode("utf_8")`:code:.
|
|
553
|
+
"""
|
|
554
|
+
deposit_ddx: DepositDdxMethod
|
|
555
|
+
"""Constructor-initialized instance of
|
|
556
|
+
:class:`DepositDdxMethod`.
|
|
557
|
+
"""
|
|
558
|
+
|
|
559
|
+
get_max_ddx_cap: GetMaxDdxCapMethod
|
|
560
|
+
"""Constructor-initialized instance of
|
|
561
|
+
:class:`GetMaxDdxCapMethod`.
|
|
562
|
+
"""
|
|
563
|
+
|
|
564
|
+
get_processed_ddx_withdrawals: GetProcessedDdxWithdrawalsMethod
|
|
565
|
+
"""Constructor-initialized instance of
|
|
566
|
+
:class:`GetProcessedDdxWithdrawalsMethod`.
|
|
567
|
+
"""
|
|
568
|
+
|
|
569
|
+
get_unprocessed_ddx_withdrawals: GetUnprocessedDdxWithdrawalsMethod
|
|
570
|
+
"""Constructor-initialized instance of
|
|
571
|
+
:class:`GetUnprocessedDdxWithdrawalsMethod`.
|
|
572
|
+
"""
|
|
573
|
+
|
|
574
|
+
initialize: InitializeMethod
|
|
575
|
+
"""Constructor-initialized instance of
|
|
576
|
+
:class:`InitializeMethod`.
|
|
577
|
+
"""
|
|
578
|
+
|
|
579
|
+
set_ddx_rate_limits: SetDdxRateLimitsMethod
|
|
580
|
+
"""Constructor-initialized instance of
|
|
581
|
+
:class:`SetDdxRateLimitsMethod`.
|
|
582
|
+
"""
|
|
583
|
+
|
|
584
|
+
set_max_ddx_cap: SetMaxDdxCapMethod
|
|
585
|
+
"""Constructor-initialized instance of
|
|
586
|
+
:class:`SetMaxDdxCapMethod`.
|
|
587
|
+
"""
|
|
588
|
+
|
|
589
|
+
withdraw_ddx: WithdrawDdxMethod
|
|
590
|
+
"""Constructor-initialized instance of
|
|
591
|
+
:class:`WithdrawDdxMethod`.
|
|
592
|
+
"""
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
def __init__(
|
|
596
|
+
self,
|
|
597
|
+
web3_or_provider: Union[Web3, BaseProvider],
|
|
598
|
+
contract_address: str,
|
|
599
|
+
validator: IStakeValidator = None,
|
|
600
|
+
):
|
|
601
|
+
"""Get an instance of wrapper for smart contract.
|
|
602
|
+
|
|
603
|
+
:param web3_or_provider: Either an instance of `web3.Web3`:code: or
|
|
604
|
+
`web3.providers.base.BaseProvider`:code:
|
|
605
|
+
:param contract_address: where the contract has been deployed
|
|
606
|
+
:param validator: for validation of method inputs.
|
|
607
|
+
"""
|
|
608
|
+
# pylint: disable=too-many-statements
|
|
609
|
+
|
|
610
|
+
self.contract_address = contract_address
|
|
611
|
+
|
|
612
|
+
if not validator:
|
|
613
|
+
validator = IStakeValidator(web3_or_provider, contract_address)
|
|
614
|
+
|
|
615
|
+
web3 = None
|
|
616
|
+
if isinstance(web3_or_provider, BaseProvider):
|
|
617
|
+
web3 = Web3(web3_or_provider)
|
|
618
|
+
elif isinstance(web3_or_provider, Web3):
|
|
619
|
+
web3 = web3_or_provider
|
|
620
|
+
else:
|
|
621
|
+
raise TypeError(
|
|
622
|
+
"Expected parameter 'web3_or_provider' to be an instance of either"
|
|
623
|
+
+ " Web3 or BaseProvider"
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
# if any middleware was imported, inject it
|
|
627
|
+
try:
|
|
628
|
+
MIDDLEWARE
|
|
629
|
+
except NameError:
|
|
630
|
+
pass
|
|
631
|
+
else:
|
|
632
|
+
try:
|
|
633
|
+
for middleware in MIDDLEWARE:
|
|
634
|
+
web3.middleware_onion.inject(
|
|
635
|
+
middleware['function'], layer=middleware['layer'],
|
|
636
|
+
)
|
|
637
|
+
except ValueError as value_error:
|
|
638
|
+
if value_error.args == ("You can't add the same un-named instance twice",):
|
|
639
|
+
pass
|
|
640
|
+
|
|
641
|
+
self._web3_eth = web3.eth
|
|
642
|
+
|
|
643
|
+
functions = self._web3_eth.contract(address=to_checksum_address(contract_address), abi=IStake.abi()).functions
|
|
644
|
+
|
|
645
|
+
self.deposit_ddx = DepositDdxMethod(web3_or_provider, contract_address, functions.depositDDX, validator)
|
|
646
|
+
|
|
647
|
+
self.get_max_ddx_cap = GetMaxDdxCapMethod(web3_or_provider, contract_address, functions.getMaxDDXCap)
|
|
648
|
+
|
|
649
|
+
self.get_processed_ddx_withdrawals = GetProcessedDdxWithdrawalsMethod(web3_or_provider, contract_address, functions.getProcessedDDXWithdrawals, validator)
|
|
650
|
+
|
|
651
|
+
self.get_unprocessed_ddx_withdrawals = GetUnprocessedDdxWithdrawalsMethod(web3_or_provider, contract_address, functions.getUnprocessedDDXWithdrawals, validator)
|
|
652
|
+
|
|
653
|
+
self.initialize = InitializeMethod(web3_or_provider, contract_address, functions.initialize, validator)
|
|
654
|
+
|
|
655
|
+
self.set_ddx_rate_limits = SetDdxRateLimitsMethod(web3_or_provider, contract_address, functions.setDDXRateLimits, validator)
|
|
656
|
+
|
|
657
|
+
self.set_max_ddx_cap = SetMaxDdxCapMethod(web3_or_provider, contract_address, functions.setMaxDDXCap, validator)
|
|
658
|
+
|
|
659
|
+
self.withdraw_ddx = WithdrawDdxMethod(web3_or_provider, contract_address, functions.withdrawDDX, validator)
|
|
660
|
+
|
|
661
|
+
def get_ddx_rate_limit_set_event(
|
|
662
|
+
self, tx_hash: Union[HexBytes, bytes]
|
|
663
|
+
) -> Tuple[AttributeDict]:
|
|
664
|
+
"""Get log entry for DDXRateLimitSet event.
|
|
665
|
+
|
|
666
|
+
:param tx_hash: hash of transaction emitting DDXRateLimitSet event
|
|
667
|
+
"""
|
|
668
|
+
tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
|
|
669
|
+
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=IStake.abi()).events.DDXRateLimitSet().process_receipt(tx_receipt)
|
|
670
|
+
def get_max_ddx_cap_set_event(
|
|
671
|
+
self, tx_hash: Union[HexBytes, bytes]
|
|
672
|
+
) -> Tuple[AttributeDict]:
|
|
673
|
+
"""Get log entry for MaxDDXCapSet event.
|
|
674
|
+
|
|
675
|
+
:param tx_hash: hash of transaction emitting MaxDDXCapSet event
|
|
676
|
+
"""
|
|
677
|
+
tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
|
|
678
|
+
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=IStake.abi()).events.MaxDDXCapSet().process_receipt(tx_receipt)
|
|
679
|
+
def get_trader_updated_event(
|
|
680
|
+
self, tx_hash: Union[HexBytes, bytes]
|
|
681
|
+
) -> Tuple[AttributeDict]:
|
|
682
|
+
"""Get log entry for TraderUpdated event.
|
|
683
|
+
|
|
684
|
+
:param tx_hash: hash of transaction emitting TraderUpdated event
|
|
685
|
+
"""
|
|
686
|
+
tx_receipt = self._web3_eth.get_transaction_receipt(tx_hash)
|
|
687
|
+
return self._web3_eth.contract(address=to_checksum_address(self.contract_address), abi=IStake.abi()).events.TraderUpdated().process_receipt(tx_receipt)
|
|
688
|
+
|
|
689
|
+
@staticmethod
|
|
690
|
+
def abi():
|
|
691
|
+
"""Return the ABI to the underlying contract."""
|
|
692
|
+
return json.loads(
|
|
693
|
+
'[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"minimumRateLimit","type":"uint128"}],"name":"DDXRateLimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldMaxCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMaxCap","type":"uint256"}],"name":"MaxDDXCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"enum DepositDefs.TraderUpdateKind","name":"updateKind","type":"uint8"}],"name":"TraderUpdated","type":"event"},{"inputs":[{"internalType":"uint128","name":"_amount","type":"uint128"},{"internalType":"uint256","name":"_expiryBlock","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"depositDDX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getMaxDDXCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_withdrawAddress","type":"address"},{"internalType":"uint128","name":"_blockNumber","type":"uint128"}],"name":"getProcessedDDXWithdrawals","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_withdrawAddress","type":"address"}],"name":"getUnprocessedDDXWithdrawals","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_ddxMinimumRateLimit","type":"uint128"},{"internalType":"uint256","name":"_maxDDXCap","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_minimumRateLimit","type":"uint128"}],"name":"setDDXRateLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxDDXCap","type":"uint256"}],"name":"setMaxDDXCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_amount","type":"uint128"},{"components":[{"internalType":"uint128","name":"availDDXBalance","type":"uint128"},{"internalType":"uint128","name":"lockedDDXBalance","type":"uint128"},{"internalType":"bytes21","name":"referralAddress","type":"bytes21"},{"internalType":"bool","name":"payFeesInDDX","type":"bool"},{"internalType":"bool","name":"accessDenied","type":"bool"}],"internalType":"struct DepositDefs.TraderData","name":"_trader","type":"tuple"},{"internalType":"bytes","name":"_proof","type":"bytes"}],"name":"withdrawDDX","outputs":[],"stateMutability":"nonpayable","type":"function"}]' # noqa: E501 (line-too-long)
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
# pylint: disable=too-many-lines
|