olas-operate-middleware 0.9.0__tar.gz → 0.13.5__tar.gz
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.
- olas_operate_middleware-0.13.5/PKG-INFO +56 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/__init__.py +12 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/bridge/bridge_manager.py +64 -57
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/bridge/providers/lifi_provider.py +5 -4
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/bridge/providers/native_bridge_provider.py +32 -18
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/bridge/providers/provider.py +47 -121
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/bridge/providers/relay_provider.py +21 -6
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/cli.py +724 -168
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/constants.py +38 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/dual_staking_token/contract.py +3 -3
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/dual_staking_token/contract.yaml +2 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/foreign_omnibridge/contract.yaml +1 -1
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/home_omnibridge/contract.py +2 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/home_omnibridge/contract.yaml +2 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l1_standard_bridge/contract.py +20 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l1_standard_bridge/contract.yaml +2 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l2_standard_bridge/contract.py +4 -4
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l2_standard_bridge/contract.yaml +2 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/mech_activity/contract.yaml +1 -1
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/optimism_mintable_erc20/contract.yaml +1 -1
- olas_operate_middleware-0.13.5/operate/data/contracts/recovery_module/__init__.py +20 -0
- olas_operate_middleware-0.13.5/operate/data/contracts/recovery_module/build/RecoveryModule.json +811 -0
- olas_operate_middleware-0.13.5/operate/data/contracts/recovery_module/contract.py +61 -0
- olas_operate_middleware-0.13.5/operate/data/contracts/recovery_module/contract.yaml +23 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/requester_activity_checker/contract.yaml +1 -1
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/staking_token/contract.py +3 -3
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/staking_token/contract.yaml +2 -2
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/uniswap_v2_erc20/contract.yaml +3 -3
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/uniswap_v2_erc20/tests/test_contract.py +5 -5
- olas_operate_middleware-0.13.5/operate/keys.py +193 -0
- olas_operate_middleware-0.13.5/operate/ledger/__init__.py +196 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/ledger/profiles.py +160 -71
- olas_operate_middleware-0.13.5/operate/migration.py +555 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/operate_http/__init__.py +0 -2
- olas_operate_middleware-0.13.5/operate/operate_types.py +454 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/analyse_logs.py +1 -4
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/claim_staking_rewards.py +11 -25
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/reset_configs.py +1 -4
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/reset_password.py +5 -12
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/reset_staking.py +4 -5
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/run_service.py +101 -23
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/stop_service.py +9 -5
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/terminate_on_chain_service.py +0 -3
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/quickstart/utils.py +16 -12
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/resource.py +11 -27
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/agent_runner.py +23 -31
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/deployment_runner.py +348 -120
- olas_operate_middleware-0.13.5/operate/services/funding_manager.py +929 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/health_checker.py +50 -11
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/manage.py +551 -440
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/protocol.py +649 -354
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/service.py +249 -319
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/utils/mech.py +3 -3
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/utils/tendermint.py +5 -3
- olas_operate_middleware-0.13.5/operate/settings.py +70 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/utils/__init__.py +61 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/utils/gnosis.py +159 -119
- olas_operate_middleware-0.13.5/operate/utils/single_instance.py +226 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/wallet/master.py +289 -241
- olas_operate_middleware-0.13.5/operate/wallet/wallet_recovery_manager.py +509 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/pyproject.toml +12 -28
- olas_operate_middleware-0.9.0/PKG-INFO +0 -72
- olas_operate_middleware-0.9.0/operate/keys.py +0 -135
- olas_operate_middleware-0.9.0/operate/ledger/__init__.py +0 -98
- olas_operate_middleware-0.9.0/operate/migration.py +0 -122
- olas_operate_middleware-0.9.0/operate/operate_types.py +0 -320
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/LICENSE +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/README.md +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/account/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/account/user.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/README.md +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/dual_staking_token/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/dual_staking_token/build/DualStakingToken.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/foreign_omnibridge/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/foreign_omnibridge/build/ForeignOmnibridge.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/foreign_omnibridge/contract.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/home_omnibridge/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/home_omnibridge/build/HomeOmnibridge.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l1_standard_bridge/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l1_standard_bridge/build/L1StandardBridge.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l2_standard_bridge/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/l2_standard_bridge/build/L2StandardBridge.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/mech_activity/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/mech_activity/build/MechActivity.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/mech_activity/contract.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/optimism_mintable_erc20/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/optimism_mintable_erc20/build/OptimismMintableERC20.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/optimism_mintable_erc20/contract.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/requester_activity_checker/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/requester_activity_checker/build/RequesterActivityChecker.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/requester_activity_checker/contract.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/staking_token/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/staking_token/build/StakingToken.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/uniswap_v2_erc20/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/uniswap_v2_erc20/build/IUniswapV2ERC20.json +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/uniswap_v2_erc20/contract.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/data/contracts/uniswap_v2_erc20/tests/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/operate_http/exceptions.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/pearl.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/services/utils/__init__.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/utils/ssl.py +0 -0
- {olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/wallet/__init__.py +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: olas-operate-middleware
|
|
3
|
+
Version: 0.13.5
|
|
4
|
+
Summary:
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Author: David Vilela
|
|
7
|
+
Author-email: dvilelaf@gmail.com
|
|
8
|
+
Requires-Python: >=3.10,<3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Requires-Dist: argon2-cffi (==23.1.0)
|
|
13
|
+
Requires-Dist: clea (==0.1.0rc4)
|
|
14
|
+
Requires-Dist: cryptography (>=46.0.3,<47.0.0)
|
|
15
|
+
Requires-Dist: cytoolz (==0.12.3)
|
|
16
|
+
Requires-Dist: deepdiff (>=8.6.1,<9.0.0)
|
|
17
|
+
Requires-Dist: fastapi (==0.110.3)
|
|
18
|
+
Requires-Dist: halo (==0.0.31)
|
|
19
|
+
Requires-Dist: multiaddr (==0.0.9)
|
|
20
|
+
Requires-Dist: open-aea-cli-ipfs (>=2.0.6,<3.0.0)
|
|
21
|
+
Requires-Dist: open-aea-ledger-cosmos (>=2.0.6,<3.0.0)
|
|
22
|
+
Requires-Dist: open-aea-ledger-ethereum (>=2.0.6,<3.0.0)
|
|
23
|
+
Requires-Dist: open-aea-ledger-ethereum-flashbots (>=2.0.6,<3.0.0)
|
|
24
|
+
Requires-Dist: open-autonomy (>=0.21.4,<0.22.0)
|
|
25
|
+
Requires-Dist: psutil (>=5.9.8,<6.0.0)
|
|
26
|
+
Requires-Dist: pyinstaller (>=6.8.0,<7.0.0)
|
|
27
|
+
Requires-Dist: requests-mock (>=1.12.1,<2.0.0)
|
|
28
|
+
Requires-Dist: uvicorn (==0.27.0)
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
<h1 align="center">
|
|
32
|
+
<b>Olas Operate Middleware</b>
|
|
33
|
+
</h1>
|
|
34
|
+
|
|
35
|
+
A cross-platform python package used to run autonomous agents powered by the OLAS Network.
|
|
36
|
+
|
|
37
|
+
## Getting Started
|
|
38
|
+
|
|
39
|
+
Install using
|
|
40
|
+
```
|
|
41
|
+
pip install olas-operate-middleware
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Start the daemon service using
|
|
45
|
+
```
|
|
46
|
+
python -m operate.cli daemon
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
- [Apache 2.0](LICENSE)
|
|
52
|
+
|
|
53
|
+
## Security
|
|
54
|
+
|
|
55
|
+
- [Security Policy](SECURITY.md)
|
|
56
|
+
|
|
@@ -20,6 +20,18 @@
|
|
|
20
20
|
"""Operate app."""
|
|
21
21
|
|
|
22
22
|
import logging
|
|
23
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
23
24
|
|
|
24
25
|
|
|
26
|
+
try:
|
|
27
|
+
# Prefer the distribution name if installed; fall back to the module name
|
|
28
|
+
__version__ = version("olas-operate-middleware")
|
|
29
|
+
except PackageNotFoundError:
|
|
30
|
+
try:
|
|
31
|
+
__version__ = version("operate")
|
|
32
|
+
except PackageNotFoundError:
|
|
33
|
+
logger = logging.getLogger("operate")
|
|
34
|
+
logger.warning("Could not determine version, using 0.0.0+local")
|
|
35
|
+
__version__ = "0.0.0+local"
|
|
36
|
+
|
|
25
37
|
logging.getLogger("aea").setLevel(logging.ERROR)
|
{olas_operate_middleware-0.9.0 → olas_operate_middleware-0.13.5}/operate/bridge/bridge_manager.py
RENAMED
|
@@ -29,7 +29,6 @@ from dataclasses import dataclass
|
|
|
29
29
|
from pathlib import Path
|
|
30
30
|
from typing import cast
|
|
31
31
|
|
|
32
|
-
from aea.helpers.logging import setup_logger
|
|
33
32
|
from deepdiff import DeepDiff
|
|
34
33
|
from web3 import Web3
|
|
35
34
|
|
|
@@ -43,10 +42,9 @@ from operate.bridge.providers.provider import Provider, ProviderRequest
|
|
|
43
42
|
from operate.bridge.providers.relay_provider import RelayProvider
|
|
44
43
|
from operate.constants import ZERO_ADDRESS
|
|
45
44
|
from operate.ledger.profiles import USDC
|
|
46
|
-
from operate.operate_types import Chain
|
|
45
|
+
from operate.operate_types import Chain, ChainAmounts
|
|
47
46
|
from operate.resource import LocalResource
|
|
48
47
|
from operate.services.manage import get_assets_balances
|
|
49
|
-
from operate.utils import merge_sum_dicts, subtract_dicts
|
|
50
48
|
from operate.wallet.master import MasterWalletManager
|
|
51
49
|
|
|
52
50
|
|
|
@@ -59,52 +57,60 @@ RELAY_PROVIDER_ID = "relay-provider"
|
|
|
59
57
|
|
|
60
58
|
NATIVE_BRIDGE_PROVIDER_CONFIGS: t.Dict[str, t.Any] = {
|
|
61
59
|
"native-ethereum-to-base": {
|
|
62
|
-
"from_chain":
|
|
60
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
63
61
|
"from_bridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
|
|
64
|
-
"to_chain":
|
|
62
|
+
"to_chain": Chain.BASE.value,
|
|
65
63
|
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
66
64
|
"bridge_eta": 300,
|
|
67
65
|
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
68
66
|
},
|
|
67
|
+
"native-ethereum-to-celo": {
|
|
68
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
69
|
+
"from_bridge": "0x9C4955b92F34148dbcfDCD82e9c9eCe5CF2badfe",
|
|
70
|
+
"to_chain": Chain.CELO.value,
|
|
71
|
+
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
72
|
+
"bridge_eta": 300,
|
|
73
|
+
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
74
|
+
},
|
|
75
|
+
"native-ethereum-to-gnosis": {
|
|
76
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
77
|
+
"from_bridge": "0x88ad09518695c6c3712AC10a214bE5109a655671",
|
|
78
|
+
"to_chain": Chain.GNOSIS.value,
|
|
79
|
+
"to_bridge": "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d",
|
|
80
|
+
"bridge_eta": 1800,
|
|
81
|
+
"bridge_contract_adaptor_class": OmnibridgeContractAdaptor,
|
|
82
|
+
},
|
|
69
83
|
"native-ethereum-to-mode": {
|
|
70
|
-
"from_chain":
|
|
84
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
71
85
|
"from_bridge": "0x735aDBbE72226BD52e818E7181953f42E3b0FF21",
|
|
72
|
-
"to_chain":
|
|
86
|
+
"to_chain": Chain.MODE.value,
|
|
73
87
|
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
74
88
|
"bridge_eta": 300,
|
|
75
89
|
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
76
90
|
},
|
|
77
91
|
"native-ethereum-to-optimism": {
|
|
78
|
-
"from_chain":
|
|
92
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
79
93
|
"from_bridge": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1",
|
|
80
|
-
"to_chain":
|
|
94
|
+
"to_chain": Chain.OPTIMISM.value,
|
|
81
95
|
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
82
96
|
"bridge_eta": 300,
|
|
83
97
|
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
84
98
|
},
|
|
85
|
-
"native-ethereum-to-gnosis": {
|
|
86
|
-
"from_chain": "ethereum",
|
|
87
|
-
"from_bridge": "0x88ad09518695c6c3712AC10a214bE5109a655671",
|
|
88
|
-
"to_chain": "gnosis",
|
|
89
|
-
"to_bridge": "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d",
|
|
90
|
-
"bridge_eta": 1800,
|
|
91
|
-
"bridge_contract_adaptor_class": OmnibridgeContractAdaptor,
|
|
92
|
-
},
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
# Routes are defined as the tuples (from_chain, from_token, to_chain, to_token)
|
|
102
|
+
PREFERRED_ROUTES = {
|
|
97
103
|
(
|
|
98
|
-
Chain.ETHEREUM,
|
|
99
|
-
USDC[Chain.ETHEREUM],
|
|
100
|
-
Chain.OPTIMISM,
|
|
101
|
-
USDC[Chain.OPTIMISM],
|
|
104
|
+
Chain.ETHEREUM,
|
|
105
|
+
USDC[Chain.ETHEREUM],
|
|
106
|
+
Chain.OPTIMISM,
|
|
107
|
+
USDC[Chain.OPTIMISM],
|
|
102
108
|
): LIFI_PROVIDER_ID,
|
|
103
109
|
(
|
|
104
|
-
Chain.ETHEREUM,
|
|
105
|
-
USDC[Chain.ETHEREUM],
|
|
106
|
-
Chain.BASE,
|
|
107
|
-
USDC[Chain.BASE],
|
|
110
|
+
Chain.ETHEREUM,
|
|
111
|
+
USDC[Chain.ETHEREUM],
|
|
112
|
+
Chain.BASE,
|
|
113
|
+
USDC[Chain.BASE],
|
|
108
114
|
): LIFI_PROVIDER_ID,
|
|
109
115
|
(Chain.ETHEREUM, ZERO_ADDRESS, Chain.GNOSIS, ZERO_ADDRESS): RELAY_PROVIDER_ID,
|
|
110
116
|
}
|
|
@@ -187,14 +193,14 @@ class BridgeManager:
|
|
|
187
193
|
self,
|
|
188
194
|
path: Path,
|
|
189
195
|
wallet_manager: MasterWalletManager,
|
|
190
|
-
logger:
|
|
191
|
-
|
|
196
|
+
logger: logging.Logger,
|
|
197
|
+
bundle_validity_period: int = DEFAULT_BUNDLE_VALIDITY_PERIOD,
|
|
192
198
|
) -> None:
|
|
193
199
|
"""Initialize bridge manager."""
|
|
194
200
|
self.path = path
|
|
195
201
|
self.wallet_manager = wallet_manager
|
|
196
|
-
self.logger = logger
|
|
197
|
-
self.
|
|
202
|
+
self.logger = logger
|
|
203
|
+
self.bundle_validity_period = bundle_validity_period
|
|
198
204
|
self.path.mkdir(exist_ok=True)
|
|
199
205
|
(self.path / EXECUTED_BUNDLES_PATH).mkdir(exist_ok=True)
|
|
200
206
|
self.data: BridgeManagerData = cast(
|
|
@@ -252,7 +258,7 @@ class BridgeManager:
|
|
|
252
258
|
self.logger.info("[BRIDGE MANAGER] Force bundle update.")
|
|
253
259
|
self.quote_bundle(bundle)
|
|
254
260
|
self._store_data()
|
|
255
|
-
elif now > bundle.timestamp + self.
|
|
261
|
+
elif now > bundle.timestamp + self.bundle_validity_period:
|
|
256
262
|
self.logger.info("[BRIDGE MANAGER] Bundle expired.")
|
|
257
263
|
self.quote_bundle(bundle)
|
|
258
264
|
self._store_data()
|
|
@@ -262,24 +268,26 @@ class BridgeManager:
|
|
|
262
268
|
|
|
263
269
|
provider_requests = []
|
|
264
270
|
for params in requests_params:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
271
|
+
route = (
|
|
272
|
+
Chain(params["from"]["chain"]),
|
|
273
|
+
params["from"]["token"],
|
|
274
|
+
Chain(params["to"]["chain"]),
|
|
275
|
+
params["to"]["token"],
|
|
276
|
+
)
|
|
277
|
+
provider_id = PREFERRED_ROUTES.get(route)
|
|
278
|
+
|
|
279
|
+
if not provider_id:
|
|
280
|
+
for provider in self._native_bridge_providers.values():
|
|
281
|
+
if provider.can_handle_request(params):
|
|
282
|
+
provider_id = provider.provider_id
|
|
283
|
+
break
|
|
284
|
+
|
|
285
|
+
if not provider_id:
|
|
286
|
+
provider_id = RELAY_PROVIDER_ID
|
|
287
|
+
|
|
288
|
+
provider_requests.append(
|
|
289
|
+
self._providers[provider_id].create_request(params=params)
|
|
290
|
+
)
|
|
283
291
|
|
|
284
292
|
bundle = ProviderRequestBundle(
|
|
285
293
|
id=f"{BRIDGE_REQUEST_BUNDLE_PREFIX}{uuid.uuid4()}",
|
|
@@ -336,7 +344,7 @@ class BridgeManager:
|
|
|
336
344
|
|
|
337
345
|
bundle = self._get_updated_bundle(requests_params, force_update)
|
|
338
346
|
|
|
339
|
-
balances =
|
|
347
|
+
balances = ChainAmounts()
|
|
340
348
|
for chain in bundle.get_from_chains():
|
|
341
349
|
ledger_api = self.wallet_manager.load(chain.ledger_type).ledger_api(chain)
|
|
342
350
|
balances[chain.value] = get_assets_balances(
|
|
@@ -347,9 +355,8 @@ class BridgeManager:
|
|
|
347
355
|
|
|
348
356
|
bridge_total_requirements = self.bridge_total_requirements(bundle)
|
|
349
357
|
|
|
350
|
-
bridge_refill_requirements =
|
|
351
|
-
|
|
352
|
-
subtract_dicts(bridge_total_requirements, balances),
|
|
358
|
+
bridge_refill_requirements = ChainAmounts.shortfalls(
|
|
359
|
+
bridge_total_requirements, balances
|
|
353
360
|
)
|
|
354
361
|
|
|
355
362
|
is_refill_required = any(
|
|
@@ -365,7 +372,7 @@ class BridgeManager:
|
|
|
365
372
|
"balances": balances,
|
|
366
373
|
"bridge_refill_requirements": bridge_refill_requirements,
|
|
367
374
|
"bridge_total_requirements": bridge_total_requirements,
|
|
368
|
-
"expiration_timestamp": bundle.timestamp + self.
|
|
375
|
+
"expiration_timestamp": bundle.timestamp + self.bundle_validity_period,
|
|
369
376
|
"is_refill_required": is_refill_required,
|
|
370
377
|
}
|
|
371
378
|
)
|
|
@@ -442,14 +449,14 @@ class BridgeManager:
|
|
|
442
449
|
"bridge_request_status": provider_request_status,
|
|
443
450
|
}
|
|
444
451
|
|
|
445
|
-
def bridge_total_requirements(self, bundle: ProviderRequestBundle) ->
|
|
452
|
+
def bridge_total_requirements(self, bundle: ProviderRequestBundle) -> ChainAmounts:
|
|
446
453
|
"""Sum bridge requirements."""
|
|
447
454
|
requirements = []
|
|
448
455
|
for provider_request in bundle.provider_requests:
|
|
449
456
|
provider = self._providers[provider_request.provider_id]
|
|
450
457
|
requirements.append(provider.requirements(provider_request))
|
|
451
458
|
|
|
452
|
-
return
|
|
459
|
+
return ChainAmounts.add(*requirements)
|
|
453
460
|
|
|
454
461
|
def quote_bundle(self, bundle: ProviderRequestBundle) -> None:
|
|
455
462
|
"""Update the bundle with the quotes."""
|
|
@@ -38,6 +38,7 @@ from operate.bridge.providers.provider import (
|
|
|
38
38
|
QuoteData,
|
|
39
39
|
)
|
|
40
40
|
from operate.constants import ZERO_ADDRESS
|
|
41
|
+
from operate.ledger import update_tx_with_gas_estimate, update_tx_with_gas_pricing
|
|
41
42
|
from operate.operate_types import Chain
|
|
42
43
|
|
|
43
44
|
|
|
@@ -240,8 +241,8 @@ class LiFiProvider(Provider):
|
|
|
240
241
|
amount=from_amount,
|
|
241
242
|
)
|
|
242
243
|
approve_tx["gas"] = 200_000 # TODO backport to ERC20 contract as default
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
update_tx_with_gas_pricing(approve_tx, from_ledger_api)
|
|
245
|
+
update_tx_with_gas_estimate(approve_tx, from_ledger_api)
|
|
245
246
|
return approve_tx
|
|
246
247
|
|
|
247
248
|
def _get_bridge_tx(self, provider_request: ProviderRequest) -> t.Optional[t.Dict]:
|
|
@@ -285,8 +286,8 @@ class LiFiProvider(Provider):
|
|
|
285
286
|
transaction_request["from"]
|
|
286
287
|
),
|
|
287
288
|
}
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
update_tx_with_gas_pricing(bridge_tx, from_ledger_api)
|
|
290
|
+
update_tx_with_gas_estimate(bridge_tx, from_ledger_api)
|
|
290
291
|
return bridge_tx
|
|
291
292
|
|
|
292
293
|
def _get_txs(
|
|
@@ -53,6 +53,11 @@ from operate.data.contracts.l2_standard_bridge.contract import L2StandardBridge
|
|
|
53
53
|
from operate.data.contracts.optimism_mintable_erc20.contract import (
|
|
54
54
|
OptimismMintableERC20,
|
|
55
55
|
)
|
|
56
|
+
from operate.ledger import (
|
|
57
|
+
get_default_ledger_api,
|
|
58
|
+
update_tx_with_gas_estimate,
|
|
59
|
+
update_tx_with_gas_pricing,
|
|
60
|
+
)
|
|
56
61
|
from operate.ledger.profiles import ERC20_TOKENS, EXPLORER_URL
|
|
57
62
|
from operate.operate_types import Chain
|
|
58
63
|
from operate.wallet.master import MasterWalletManager
|
|
@@ -74,13 +79,15 @@ class BridgeContractAdaptor(ABC):
|
|
|
74
79
|
) -> None:
|
|
75
80
|
"""Initialize the bridge contract adaptor."""
|
|
76
81
|
super().__init__()
|
|
82
|
+
if from_chain == to_chain:
|
|
83
|
+
raise ValueError("from_chain and to_chain cannot be the same.")
|
|
77
84
|
self.from_chain = from_chain
|
|
78
85
|
self.from_bridge = from_bridge
|
|
79
86
|
self.to_chain = to_chain
|
|
80
87
|
self.to_bridge = to_bridge
|
|
81
88
|
self.bridge_eta = bridge_eta
|
|
82
89
|
|
|
83
|
-
def can_handle_request(self,
|
|
90
|
+
def can_handle_request(self, params: t.Dict) -> bool:
|
|
84
91
|
"""Returns 'true' if the contract adaptor can handle a request for 'params'."""
|
|
85
92
|
from_chain = params["from"]["chain"]
|
|
86
93
|
from_token = Web3.to_checksum_address(params["from"]["token"])
|
|
@@ -96,7 +103,7 @@ class BridgeContractAdaptor(ABC):
|
|
|
96
103
|
if from_token == ZERO_ADDRESS and to_token == ZERO_ADDRESS:
|
|
97
104
|
return True
|
|
98
105
|
|
|
99
|
-
for token_map in ERC20_TOKENS:
|
|
106
|
+
for token_map in ERC20_TOKENS.values():
|
|
100
107
|
if (
|
|
101
108
|
Chain(from_chain) in token_map
|
|
102
109
|
and Chain(to_chain) in token_map
|
|
@@ -157,11 +164,24 @@ class OptimismContractAdaptor(BridgeContractAdaptor):
|
|
|
157
164
|
),
|
|
158
165
|
)
|
|
159
166
|
|
|
160
|
-
def can_handle_request(self,
|
|
167
|
+
def can_handle_request(self, params: t.Dict) -> bool:
|
|
161
168
|
"""Returns 'true' if the contract adaptor can handle a request for 'params'."""
|
|
162
169
|
|
|
170
|
+
if not super().can_handle_request(params):
|
|
171
|
+
return False
|
|
172
|
+
|
|
173
|
+
from_chain = params["from"]["chain"]
|
|
163
174
|
from_token = Web3.to_checksum_address(params["from"]["token"])
|
|
175
|
+
from_ledger_api = get_default_ledger_api(Chain(from_chain))
|
|
176
|
+
to_chain = params["to"]["chain"]
|
|
164
177
|
to_token = Web3.to_checksum_address(params["to"]["token"])
|
|
178
|
+
to_ledger_api = get_default_ledger_api(Chain(to_chain))
|
|
179
|
+
|
|
180
|
+
if from_token == ZERO_ADDRESS and to_token == ZERO_ADDRESS:
|
|
181
|
+
if not self._l1_standard_bridge_contract.supports_bridge_eth_to(
|
|
182
|
+
ledger_api=from_ledger_api, contract_address=self.from_bridge
|
|
183
|
+
):
|
|
184
|
+
return False
|
|
165
185
|
|
|
166
186
|
if to_token != ZERO_ADDRESS:
|
|
167
187
|
try:
|
|
@@ -175,7 +195,7 @@ class OptimismContractAdaptor(BridgeContractAdaptor):
|
|
|
175
195
|
except Exception: # pylint: disable=broad-except
|
|
176
196
|
return False
|
|
177
197
|
|
|
178
|
-
return
|
|
198
|
+
return True
|
|
179
199
|
|
|
180
200
|
def build_bridge_tx(
|
|
181
201
|
self, from_ledger_api: LedgerApi, provider_request: ProviderRequest
|
|
@@ -287,13 +307,13 @@ class OmnibridgeContractAdaptor(BridgeContractAdaptor):
|
|
|
287
307
|
),
|
|
288
308
|
)
|
|
289
309
|
|
|
290
|
-
def can_handle_request(self,
|
|
310
|
+
def can_handle_request(self, params: t.Dict) -> bool:
|
|
291
311
|
"""Returns 'true' if the contract adaptor can handle a request for 'params'."""
|
|
292
312
|
from_token = Web3.to_checksum_address(params["from"]["token"])
|
|
293
313
|
if from_token == ZERO_ADDRESS:
|
|
294
314
|
return False
|
|
295
315
|
|
|
296
|
-
return super().can_handle_request(
|
|
316
|
+
return super().can_handle_request(params)
|
|
297
317
|
|
|
298
318
|
def build_bridge_tx(
|
|
299
319
|
self, from_ledger_api: LedgerApi, provider_request: ProviderRequest
|
|
@@ -417,7 +437,7 @@ class NativeBridgeProvider(Provider):
|
|
|
417
437
|
bridge_contract_adaptor: BridgeContractAdaptor,
|
|
418
438
|
provider_id: str,
|
|
419
439
|
wallet_manager: MasterWalletManager,
|
|
420
|
-
logger:
|
|
440
|
+
logger: logging.Logger,
|
|
421
441
|
) -> None:
|
|
422
442
|
"""Initialize the provider."""
|
|
423
443
|
self.bridge_contract_adaptor = bridge_contract_adaptor
|
|
@@ -427,16 +447,10 @@ class NativeBridgeProvider(Provider):
|
|
|
427
447
|
|
|
428
448
|
def can_handle_request(self, params: t.Dict) -> bool:
|
|
429
449
|
"""Returns 'true' if the provider can handle a request for 'params'."""
|
|
430
|
-
|
|
431
450
|
if not super().can_handle_request(params):
|
|
432
451
|
return False
|
|
433
452
|
|
|
434
|
-
|
|
435
|
-
chain = Chain(to_chain)
|
|
436
|
-
wallet = self.wallet_manager.load(chain.ledger_type)
|
|
437
|
-
to_ledger_api = wallet.ledger_api(chain)
|
|
438
|
-
|
|
439
|
-
if not self.bridge_contract_adaptor.can_handle_request(to_ledger_api, params):
|
|
453
|
+
if not self.bridge_contract_adaptor.can_handle_request(params):
|
|
440
454
|
return False
|
|
441
455
|
|
|
442
456
|
return True
|
|
@@ -512,8 +526,8 @@ class NativeBridgeProvider(Provider):
|
|
|
512
526
|
amount=to_amount,
|
|
513
527
|
)
|
|
514
528
|
approve_tx["gas"] = 200_000 # TODO backport to ERC20 contract as default
|
|
515
|
-
|
|
516
|
-
|
|
529
|
+
update_tx_with_gas_pricing(approve_tx, from_ledger_api)
|
|
530
|
+
update_tx_with_gas_estimate(approve_tx, from_ledger_api)
|
|
517
531
|
return approve_tx
|
|
518
532
|
|
|
519
533
|
def _get_bridge_tx(self, provider_request: ProviderRequest) -> t.Optional[t.Dict]:
|
|
@@ -534,8 +548,8 @@ class NativeBridgeProvider(Provider):
|
|
|
534
548
|
from_ledger_api=from_ledger_api, provider_request=provider_request
|
|
535
549
|
)
|
|
536
550
|
|
|
537
|
-
|
|
538
|
-
|
|
551
|
+
update_tx_with_gas_pricing(bridge_tx, from_ledger_api)
|
|
552
|
+
update_tx_with_gas_estimate(bridge_tx, from_ledger_api)
|
|
539
553
|
return bridge_tx
|
|
540
554
|
|
|
541
555
|
def _get_txs(
|