prediction-market-agent-tooling 0.69.9__py3-none-any.whl → 0.69.10.dev1120__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.
@@ -1,6 +1,6 @@
1
1
  import typing as t
2
2
  from decimal import Decimal
3
- from typing import NewType
3
+ from typing import Annotated, NewType, TypeAlias
4
4
 
5
5
  from eth_typing.evm import ( # noqa: F401 # Import for the sake of easy importing with others from here.
6
6
  Address,
@@ -8,6 +8,7 @@ from eth_typing.evm import ( # noqa: F401 # Import for the sake of easy import
8
8
  HexAddress,
9
9
  HexStr,
10
10
  )
11
+ from pydantic import BeforeValidator
11
12
  from pydantic.types import SecretStr
12
13
  from pydantic.v1.types import SecretStr as SecretStrV1
13
14
  from web3 import Web3
@@ -18,6 +19,7 @@ from web3.types import ( # noqa: F401 # Import for the sake of easy importing
18
19
  )
19
20
  from web3.types import Wei as Web3Wei
20
21
 
22
+ from prediction_market_agent_tooling.gtypes import ChecksumAddress
21
23
  from prediction_market_agent_tooling.tools._generic_value import _GenericValue
22
24
  from prediction_market_agent_tooling.tools.datetime_utc import ( # noqa: F401 # Import for the sake of easy importing with others from here.
23
25
  DatetimeUTC,
@@ -26,6 +28,14 @@ from prediction_market_agent_tooling.tools.hexbytes_custom import ( # noqa: F40
26
28
  HexBytes,
27
29
  )
28
30
 
31
+ VerifiedChecksumAddress: TypeAlias = Annotated[
32
+ ChecksumAddress, BeforeValidator(Web3.to_checksum_address)
33
+ ]
34
+ VerifiedChecksumAddressOrNone: TypeAlias = Annotated[
35
+ ChecksumAddress | None,
36
+ BeforeValidator(lambda x: Web3.to_checksum_address(x) if x is not None else None),
37
+ ]
38
+
29
39
 
30
40
  class CollateralToken(_GenericValue[int | float | str | Decimal, float], parser=float):
31
41
  """
@@ -399,6 +399,22 @@ def get_orders_by_owner(
399
399
  return [Order.model_validate(i) for i in items]
400
400
 
401
401
 
402
+ @tenacity.retry(
403
+ stop=stop_after_attempt(3),
404
+ wait=wait_fixed(1),
405
+ after=lambda x: logger.debug(f"get_order_by_uid failed, {x.attempt_number=}."),
406
+ )
407
+ async def get_order_by_uid(
408
+ uid: HexBytes,
409
+ ) -> Order:
410
+ async with httpx.AsyncClient() as client:
411
+ response = await client.get(
412
+ f"https://api.cow.fi/xdai/api/v1/orders/{uid.to_0x_hex()}"
413
+ )
414
+ response.raise_for_status()
415
+ return Order.model_validate(response.json())
416
+
417
+
402
418
  @tenacity.retry(
403
419
  stop=stop_after_attempt(3),
404
420
  wait=wait_fixed(1),
@@ -1,23 +1,115 @@
1
- from pydantic import BaseModel
1
+ from enum import Enum
2
+ from typing import Optional
3
+
4
+ from pydantic import BaseModel, ConfigDict
2
5
  from sqlmodel import Field, SQLModel
3
6
 
4
- from prediction_market_agent_tooling.gtypes import ChecksumAddress, HexBytes
7
+ from prediction_market_agent_tooling.gtypes import (
8
+ HexBytes,
9
+ VerifiedChecksumAddress,
10
+ VerifiedChecksumAddressOrNone,
11
+ Wei,
12
+ )
5
13
  from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
6
14
  from prediction_market_agent_tooling.tools.utils import utcnow
7
15
 
8
16
 
9
17
  class MinimalisticTrade(BaseModel):
10
- sellToken: ChecksumAddress
11
- buyToken: ChecksumAddress
18
+ sellToken: VerifiedChecksumAddress
19
+ buyToken: VerifiedChecksumAddress
12
20
  orderUid: HexBytes
13
21
  txHash: HexBytes
14
22
 
15
23
 
24
+ class EthFlowData(BaseModel):
25
+ refundTxHash: Optional[HexBytes]
26
+ userValidTo: int
27
+
28
+
29
+ class PlacementError(str, Enum):
30
+ QuoteNotFound = "QuoteNotFound"
31
+ ValidToTooFarInFuture = "ValidToTooFarInFuture"
32
+ PreValidationError = "PreValidationError"
33
+
34
+
35
+ class OnchainOrderData(BaseModel):
36
+ sender: VerifiedChecksumAddress
37
+ placementError: Optional[PlacementError]
38
+
39
+
40
+ class OrderKind(str, Enum):
41
+ buy = "buy"
42
+ sell = "sell"
43
+
44
+
45
+ class SellTokenBalance(str, Enum):
46
+ external = "external"
47
+ internal = "internal"
48
+ erc20 = "erc20"
49
+
50
+
51
+ class BuyTokenBalance(str, Enum):
52
+ internal = "internal"
53
+ erc20 = "erc20"
54
+
55
+
56
+ class SigningScheme(str, Enum):
57
+ eip712 = "eip712"
58
+ ethsign = "ethsign"
59
+ presign = "presign"
60
+ eip1271 = "eip1271"
61
+
62
+
63
+ class OrderClass(str, Enum):
64
+ limit = "limit"
65
+ liquidity = "liquidity"
66
+ market = "market"
67
+
68
+
69
+ class OrderStatus(str, Enum):
70
+ presignaturePending = "presignaturePending"
71
+ open = "open"
72
+ fulfilled = "fulfilled"
73
+ cancelled = "cancelled"
74
+ expired = "expired"
75
+
76
+
16
77
  class Order(BaseModel):
78
+ model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
79
+
17
80
  uid: str
18
- sellToken: str
19
- buyToken: str
81
+ quoteId: int | None = None
82
+ validTo: int
83
+ sellAmount: Wei
84
+ sellToken: VerifiedChecksumAddress
85
+ buyAmount: Wei
86
+ buyToken: VerifiedChecksumAddress
87
+ receiver: VerifiedChecksumAddressOrNone
88
+ feeAmount: Wei
20
89
  creationDate: DatetimeUTC
90
+ kind: OrderKind
91
+ partiallyFillable: bool
92
+ sellTokenBalance: SellTokenBalance | None
93
+ buyTokenBalance: BuyTokenBalance | None
94
+ signingScheme: SigningScheme
95
+ signature: HexBytes
96
+ from_: VerifiedChecksumAddressOrNone = Field(None, alias="from")
97
+ appData: str
98
+ fullAppData: str | None
99
+ appDataHash: HexBytes | None = None
100
+ class_: str = Field(None, alias="class")
101
+ owner: VerifiedChecksumAddress
102
+ executedSellAmount: Wei
103
+ executedSellAmountBeforeFees: Wei
104
+ executedBuyAmount: Wei
105
+ executedFeeAmount: Wei | None
106
+ invalidated: bool
107
+ status: str
108
+ isLiquidityOrder: bool | None
109
+ ethflowData: EthFlowData | None = None
110
+ onchainUser: VerifiedChecksumAddressOrNone = None
111
+ executedFee: Wei
112
+ executedFeeToken: VerifiedChecksumAddressOrNone
21
113
 
22
114
 
23
115
  class RateLimit(SQLModel, table=True):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.69.9
3
+ Version: 0.69.10.dev1120
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  License-File: LICENSE
6
6
  Author: Gnosis
@@ -36,7 +36,7 @@ prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5
36
36
  prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=OsPboCFGiZKsvGyntGZHwdqPlLTthITkNF5rJFvGgU8,2582
37
37
  prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=WI2ycX1X-IlTRoNoG4ggFlRwPL28kwM9VGDFD2fePLo,5699
38
38
  prediction_market_agent_tooling/deploy/trade_interval.py,sha256=Xk9j45alQ_vrasGvsNyuW70XHIQ7wfvjoxNR3F6HYCw,1155
39
- prediction_market_agent_tooling/gtypes.py,sha256=bUIZfZIGvIi3aiZNu5rVE9kRevw8sfMa4bcze6QeBg8,6058
39
+ prediction_market_agent_tooling/gtypes.py,sha256=tHXMBjh0iAEJEcBywFvwzwPqDkBUpjEyeb7ynh7fOKc,6469
40
40
  prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  prediction_market_agent_tooling/jobs/jobs_models.py,sha256=4KZ0iaKZx5zEZBBiEo9CHk0OpX3bKjoYA0wmptR0Wyk,2455
42
42
  prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=CojpgghRs0lFEf5wl-oWhGaQozG616YD0cXdlmFO-U0,5116
@@ -95,8 +95,8 @@ prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp
95
95
  prediction_market_agent_tooling/tools/contract.py,sha256=BzpAFcbKl_KqwgAlaXx63Fg8jzr0EO3qEeOs1K11CPA,33905
96
96
  prediction_market_agent_tooling/tools/contract_utils.py,sha256=9X9raICUZkPDShilt02aYzS_ILZ62u0vG5081uWLdqk,2152
97
97
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
98
- prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=kdvhWVTb31oHVspQFowDNEIoDtx8hwGTlKsWYGRh3oQ,14050
99
- prediction_market_agent_tooling/tools/cow/models.py,sha256=2hTW-Ye6SamBBAO32nVo4f3vjAOOySw8ehECReRcA3o,756
98
+ prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=DN_8cPrr4jWVpXdS4D0j1QB19nB8fxDoSheo2BFMc8M,14523
99
+ prediction_market_agent_tooling/tools/cow/models.py,sha256=EpCziNs4sGmN7ZvPKpqdqjhVd_-zPZHsJVeVfFu4Y60,3005
100
100
  prediction_market_agent_tooling/tools/cow/semaphore.py,sha256=LPB-4wNQf7El7dgBD4Tmol6vr5j1CP9qMeDm8dcs6RI,3741
101
101
  prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
102
102
  prediction_market_agent_tooling/tools/datetime_utc.py,sha256=_oO6mMc28C9aSmQfrG-S7UQy5uMHVEQqia8arnscVCk,3213
@@ -137,8 +137,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=DPO-4HBTy1-TZHKL_9CnH
137
137
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
138
138
  prediction_market_agent_tooling/tools/utils.py,sha256=ruq6P5TFs8CBHxeBLj1Plpx7kuNFPpDgMsJGQgDiRNs,8785
139
139
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=CDbaidlLeQ4VHzSg150L7QNfHfGveljSePGuDVFEYqc,13963
140
- prediction_market_agent_tooling-0.69.9.dist-info/METADATA,sha256=fBezbmaBxLVzpMNtCsmCnE2Pc8ywbXJTnCRF7HMJcYw,8890
141
- prediction_market_agent_tooling-0.69.9.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
142
- prediction_market_agent_tooling-0.69.9.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
143
- prediction_market_agent_tooling-0.69.9.dist-info/licenses/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
144
- prediction_market_agent_tooling-0.69.9.dist-info/RECORD,,
140
+ prediction_market_agent_tooling-0.69.10.dev1120.dist-info/METADATA,sha256=_zBgziT22Ha55DnWQSUlO2ITl7W1-zIXoNY19nKoGqs,8899
141
+ prediction_market_agent_tooling-0.69.10.dev1120.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
142
+ prediction_market_agent_tooling-0.69.10.dev1120.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
143
+ prediction_market_agent_tooling-0.69.10.dev1120.dist-info/licenses/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
144
+ prediction_market_agent_tooling-0.69.10.dev1120.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.0
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any