prediction-market-agent-tooling 0.64.11.dev657__py3-none-any.whl → 0.64.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prediction_market_agent_tooling/chains.py +4 -0
- prediction_market_agent_tooling/config.py +4 -3
- prediction_market_agent_tooling/markets/omen/omen_contracts.py +8 -0
- prediction_market_agent_tooling/tools/contract.py +54 -14
- {prediction_market_agent_tooling-0.64.11.dev657.dist-info → prediction_market_agent_tooling-0.64.12.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.64.11.dev657.dist-info → prediction_market_agent_tooling-0.64.12.dist-info}/RECORD +9 -8
- {prediction_market_agent_tooling-0.64.11.dev657.dist-info → prediction_market_agent_tooling-0.64.12.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.64.11.dev657.dist-info → prediction_market_agent_tooling-0.64.12.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.64.11.dev657.dist-info → prediction_market_agent_tooling-0.64.12.dist-info}/entry_points.txt +0 -0
@@ -12,6 +12,7 @@ from safe_eth.eth import EthereumClient
|
|
12
12
|
from safe_eth.safe.safe import SafeV141
|
13
13
|
from web3 import Account, Web3
|
14
14
|
|
15
|
+
from prediction_market_agent_tooling.chains import ETHEREUM_ID, GNOSIS_CHAIN_ID
|
15
16
|
from prediction_market_agent_tooling.deploy.gcp.utils import gcp_get_secret_value
|
16
17
|
from prediction_market_agent_tooling.gtypes import (
|
17
18
|
ChainID,
|
@@ -280,7 +281,7 @@ class RPCConfig(BaseSettings):
|
|
280
281
|
|
281
282
|
ETHEREUM_RPC_URL: URI = Field(default=URI("https://rpc.eth.gateway.fm"))
|
282
283
|
GNOSIS_RPC_URL: URI = Field(default=URI("https://rpc.gnosis.gateway.fm"))
|
283
|
-
CHAIN_ID: ChainID = Field(default=
|
284
|
+
CHAIN_ID: ChainID = Field(default=GNOSIS_CHAIN_ID)
|
284
285
|
|
285
286
|
@property
|
286
287
|
def ethereum_rpc_url(self) -> URI:
|
@@ -299,9 +300,9 @@ class RPCConfig(BaseSettings):
|
|
299
300
|
return check_not_none(self.CHAIN_ID, "CHAIN_ID missing in the environment.")
|
300
301
|
|
301
302
|
def chain_id_to_rpc_url(self, chain_id: ChainID) -> URI:
|
302
|
-
if chain_id ==
|
303
|
+
if chain_id == ETHEREUM_ID:
|
303
304
|
return self.ethereum_rpc_url
|
304
|
-
elif chain_id ==
|
305
|
+
elif chain_id == GNOSIS_CHAIN_ID:
|
305
306
|
return self.gnosis_rpc_url
|
306
307
|
else:
|
307
308
|
raise ValueError(f"Unsupported chain ID: {chain_id}")
|
@@ -431,6 +431,12 @@ class OmenFixedProductMarketMakerContract(ContractOnGnosisChain):
|
|
431
431
|
)
|
432
432
|
|
433
433
|
|
434
|
+
class MetriSuperGroup(ContractERC20OnGnosisChain):
|
435
|
+
address: ChecksumAddress = Web3.to_checksum_address(
|
436
|
+
"0x7147A7405fCFe5CFa30c6d5363f9f357a317d082"
|
437
|
+
)
|
438
|
+
|
439
|
+
|
434
440
|
class GNOContract(ContractERC20OnGnosisChain):
|
435
441
|
address: ChecksumAddress = Web3.to_checksum_address(
|
436
442
|
"0x9c58bacc331c9aa871afd802db6379a98e80cedb"
|
@@ -923,10 +929,12 @@ class CollateralTokenChoice(str, Enum):
|
|
923
929
|
wxdai = "wxdai"
|
924
930
|
sdai = "sdai"
|
925
931
|
gno = "gno"
|
932
|
+
metri_super_user = "metri_super_user"
|
926
933
|
|
927
934
|
|
928
935
|
COLLATERAL_TOKEN_CHOICE_TO_ADDRESS = {
|
929
936
|
CollateralTokenChoice.wxdai: WrappedxDaiContract().address,
|
930
937
|
CollateralTokenChoice.sdai: sDaiContract().address,
|
931
938
|
CollateralTokenChoice.gno: GNOContract().address,
|
939
|
+
CollateralTokenChoice.metri_super_user: MetriSuperGroup().address,
|
932
940
|
}
|
@@ -4,6 +4,8 @@ import time
|
|
4
4
|
import typing as t
|
5
5
|
from contextlib import contextmanager
|
6
6
|
|
7
|
+
import eth_abi
|
8
|
+
from eth_abi.exceptions import DecodingError
|
7
9
|
from pydantic import BaseModel, field_validator
|
8
10
|
from web3 import Web3
|
9
11
|
from web3.constants import CHECKSUM_ADDRESSS_ZERO
|
@@ -20,6 +22,7 @@ from prediction_market_agent_tooling.gtypes import (
|
|
20
22
|
TxReceipt,
|
21
23
|
Wei,
|
22
24
|
)
|
25
|
+
from prediction_market_agent_tooling.loggers import logger
|
23
26
|
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
24
27
|
from prediction_market_agent_tooling.tools.web3_utils import (
|
25
28
|
call_function_on_contract,
|
@@ -591,27 +594,64 @@ def contract_implements_function(
|
|
591
594
|
look_for_proxy_contract: bool = True,
|
592
595
|
) -> bool:
|
593
596
|
function_signature = f"{function_name}({','.join(function_arg_types or [])})"
|
594
|
-
|
597
|
+
function_selector = web3.keccak(text=function_signature)[0:4].hex()[2:]
|
598
|
+
# 1. Check directly in bytecode
|
599
|
+
bytecode = web3.eth.get_code(contract_address).hex()
|
600
|
+
if function_selector in bytecode:
|
601
|
+
return True
|
595
602
|
contract_code = web3.eth.get_code(contract_address).hex()
|
596
|
-
implements =
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
603
|
+
implements = function_selector in contract_code
|
604
|
+
|
605
|
+
# If not found directly and we should check proxies
|
606
|
+
if not implements and look_for_proxy_contract:
|
607
|
+
# Case 1: Check if it's a standard proxy (has implementation() function)
|
608
|
+
if contract_implements_function(
|
601
609
|
contract_address, "implementation", web3, look_for_proxy_contract=False
|
602
|
-
)
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
610
|
+
):
|
611
|
+
# Get the implementation address and check the function there
|
612
|
+
implementation_address = ContractProxyOnGnosisChain(
|
613
|
+
address=contract_address
|
614
|
+
).implementation()
|
615
|
+
implements = contract_implements_function(
|
616
|
+
implementation_address,
|
617
|
+
function_name=function_name,
|
618
|
+
web3=web3,
|
619
|
+
function_arg_types=function_arg_types,
|
620
|
+
look_for_proxy_contract=False,
|
621
|
+
)
|
622
|
+
else:
|
623
|
+
# Case 2: Check if it's a minimal proxy contract
|
624
|
+
implements = minimal_proxy_implements_function(
|
625
|
+
contract_address=contract_address,
|
626
|
+
function_name=function_name,
|
627
|
+
web3=web3,
|
628
|
+
function_arg_types=function_arg_types,
|
629
|
+
)
|
630
|
+
|
631
|
+
return implements
|
632
|
+
|
633
|
+
|
634
|
+
def minimal_proxy_implements_function(
|
635
|
+
contract_address: ChecksumAddress,
|
636
|
+
function_name: str,
|
637
|
+
web3: Web3,
|
638
|
+
function_arg_types: list[str] | None = None,
|
639
|
+
) -> bool:
|
640
|
+
try:
|
641
|
+
# Read storage slot 0 which should contain the implementation address in minimal proxies
|
642
|
+
raw_slot_0 = web3.eth.get_storage_at(contract_address, 0)
|
643
|
+
singleton_address = eth_abi.decode(["address"], raw_slot_0)[0]
|
644
|
+
# Recurse into singleton
|
645
|
+
return contract_implements_function(
|
646
|
+
Web3.to_checksum_address(singleton_address),
|
609
647
|
function_name=function_name,
|
610
648
|
web3=web3,
|
611
649
|
function_arg_types=function_arg_types,
|
612
650
|
look_for_proxy_contract=False,
|
613
651
|
)
|
614
|
-
|
652
|
+
except DecodingError:
|
653
|
+
logger.info(f"Error decoding contract address for singleton")
|
654
|
+
return False
|
615
655
|
|
616
656
|
|
617
657
|
def init_collateral_token_contract(
|
@@ -22,7 +22,8 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
|
|
22
22
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
|
23
23
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
|
24
24
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
|
25
|
-
prediction_market_agent_tooling/
|
25
|
+
prediction_market_agent_tooling/chains.py,sha256=1qQstoqXMwqwM7k-KH7MjMz8Ei-D83KZByvDbCZpAxs,116
|
26
|
+
prediction_market_agent_tooling/config.py,sha256=rdpRHZyoTvRIDn7Qu6eViOjPBkR9Z0MOdEMFsQOuAIE,10822
|
26
27
|
prediction_market_agent_tooling/deploy/agent.py,sha256=dobqPUQkaDPhsvMmXwibNKu4hSSTXTvmfa3F46ylLBc,26560
|
27
28
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
|
28
29
|
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=p25t7VU7I4hSkSl6SpzI_W55kLbYEySQdBqeschmARY,12918
|
@@ -57,7 +58,7 @@ prediction_market_agent_tooling/markets/omen/cow_contracts.py,sha256=sl1L4cK5nAJ
|
|
57
58
|
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=4YEOpU-ypq8IBxlEr_qgrKKWwE7wKG6VE_Dq-UKVdOE,30513
|
58
59
|
prediction_market_agent_tooling/markets/omen/omen.py,sha256=NKeTT2gU6uZ9a4gGpa9Dxy6msFQp_41Ug85hIdCmQy4,51733
|
59
60
|
prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=D9oflYKafLQiHYtB5sScMHqmXyzM8JP8J0yATmc4SQQ,233
|
60
|
-
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=
|
61
|
+
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=c6Z-hZzOybnmU-xRgzKElZmy_238Mf2mQ6dSUaYP_tY,29834
|
61
62
|
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=Cyi9Ci-Z-K8WCZWVLs9oSuJC6qRobi_CpqDCno_5F-0,10238
|
62
63
|
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=j-x_0Cm8IO-qynIXutu0iSPwrRDxdeCPYf5UHm6MJbs,39446
|
63
64
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
|
@@ -90,7 +91,7 @@ prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=68zFWUj
|
|
90
91
|
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=rZIGhgijquwwPtp_qncSAPR1SDF2XxIVZL1ir0fgzWw,12127
|
91
92
|
prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
|
92
93
|
prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
|
93
|
-
prediction_market_agent_tooling/tools/contract.py,sha256=
|
94
|
+
prediction_market_agent_tooling/tools/contract.py,sha256=pdr9ZYmj4QVUfgVKdvOU6ucYdBpJGdha_FMR_LgtcEs,22912
|
94
95
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
95
96
|
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=nZafUa5d23mFnEL2arm3jLdqdA9zl-z_fN39ceovwg4,9079
|
96
97
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
@@ -125,8 +126,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMD
|
|
125
126
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
126
127
|
prediction_market_agent_tooling/tools/utils.py,sha256=AC2a68jwASMWuQi-w8twl8b_M52YwrEJ81abmuEaqMY,6661
|
127
128
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=zRq-eeBGWt8uUGN9G_WfjmJ0eVvO8aWE9S0Pz_Y6AOA,12342
|
128
|
-
prediction_market_agent_tooling-0.64.
|
129
|
-
prediction_market_agent_tooling-0.64.
|
130
|
-
prediction_market_agent_tooling-0.64.
|
131
|
-
prediction_market_agent_tooling-0.64.
|
132
|
-
prediction_market_agent_tooling-0.64.
|
129
|
+
prediction_market_agent_tooling-0.64.12.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
130
|
+
prediction_market_agent_tooling-0.64.12.dist-info/METADATA,sha256=yt6lfStMOmUD_6GOSu-oeuwHIHEmXN7HAogInnoOPIU,8742
|
131
|
+
prediction_market_agent_tooling-0.64.12.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
132
|
+
prediction_market_agent_tooling-0.64.12.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
133
|
+
prediction_market_agent_tooling-0.64.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|