polymarket-apis 0.3.1__py3-none-any.whl → 0.3.3__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.
Potentially problematic release.
This version of polymarket-apis might be problematic. Click here for more details.
- polymarket_apis/__init__.py +3 -2
- polymarket_apis/clients/clob_client.py +4 -4
- polymarket_apis/clients/data_client.py +105 -15
- polymarket_apis/clients/gamma_client.py +520 -50
- polymarket_apis/clients/web3_client.py +288 -86
- polymarket_apis/types/__init__.py +9 -37
- polymarket_apis/types/clob_types.py +3 -3
- polymarket_apis/types/common.py +13 -32
- polymarket_apis/types/data_types.py +11 -1
- polymarket_apis/types/gamma_types.py +517 -264
- polymarket_apis/types/websockets_types.py +1 -29
- polymarket_apis/utilities/constants.py +1 -1
- polymarket_apis/utilities/web3/abis/Safe.json +1138 -0
- polymarket_apis/utilities/web3/abis/SafeProxyFactory.json +224 -0
- polymarket_apis/utilities/web3/helpers.py +152 -0
- {polymarket_apis-0.3.1.dist-info → polymarket_apis-0.3.3.dist-info}/METADATA +30 -3
- {polymarket_apis-0.3.1.dist-info → polymarket_apis-0.3.3.dist-info}/RECORD +18 -16
- {polymarket_apis-0.3.1.dist-info → polymarket_apis-0.3.3.dist-info}/WHEEL +0 -0
polymarket_apis/types/common.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from datetime import datetime
|
|
2
|
+
from datetime import UTC, datetime
|
|
3
3
|
from typing import Annotated
|
|
4
4
|
|
|
5
|
+
from dateutil import parser
|
|
5
6
|
from pydantic import AfterValidator, BaseModel, BeforeValidator, Field
|
|
6
7
|
|
|
7
8
|
|
|
@@ -12,37 +13,17 @@ def validate_keccak256(v: str) -> str:
|
|
|
12
13
|
return v
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
def
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if tz_pos == -1:
|
|
27
|
-
tz_pos = v.find("-", dot_pos)
|
|
28
|
-
|
|
29
|
-
if tz_pos != -1:
|
|
30
|
-
frac = v[dot_pos + 1 : tz_pos]
|
|
31
|
-
if len(frac) < 6:
|
|
32
|
-
frac = frac.ljust(6, "0")
|
|
33
|
-
v = f"{v[: dot_pos + 1]}{frac}{v[tz_pos:]}"
|
|
34
|
-
|
|
35
|
-
# Try parsing with and without microseconds
|
|
36
|
-
for fmt in ("%Y-%m-%d %H:%M:%S.%f%z", "%Y-%m-%d %H:%M:%S%z"):
|
|
37
|
-
try:
|
|
38
|
-
return datetime.strptime(v, fmt) # noqa: DTZ007
|
|
39
|
-
except ValueError:
|
|
40
|
-
continue
|
|
41
|
-
msg = f"Time data '{v}' does not match expected formats."
|
|
42
|
-
raise ValueError(msg)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
TimestampWithTZ = Annotated[datetime, BeforeValidator(parse_timestamp)]
|
|
16
|
+
def parse_flexible_datetime(v: str | datetime) -> datetime:
|
|
17
|
+
"""Parse datetime from multiple formats using dateutil."""
|
|
18
|
+
if v in {"NOW*()", "NOW()"}:
|
|
19
|
+
return datetime.fromtimestamp(0, tz=UTC)
|
|
20
|
+
|
|
21
|
+
if isinstance(v, str):
|
|
22
|
+
return parser.parse(v)
|
|
23
|
+
return v
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
FlexibleDatetime = Annotated[datetime, BeforeValidator(parse_flexible_datetime)]
|
|
46
27
|
EthAddress = Annotated[str, Field(pattern=r"^0x[A-Fa-f0-9]{40}$")]
|
|
47
28
|
Keccak256 = Annotated[str, AfterValidator(validate_keccak256)]
|
|
48
29
|
EmptyString = Annotated[str, Field(pattern=r"^$", description="An empty string")]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from datetime import UTC, datetime
|
|
2
|
-
from typing import Literal
|
|
2
|
+
from typing import Literal, Optional
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel, Field, field_validator
|
|
5
5
|
|
|
@@ -162,3 +162,13 @@ class UserMetric(User):
|
|
|
162
162
|
class UserRank(User):
|
|
163
163
|
amount: float
|
|
164
164
|
rank: int
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class MarketValue(BaseModel):
|
|
168
|
+
condition_id: Keccak256 = Field(alias="market")
|
|
169
|
+
value: float
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class EventLiveVolume(BaseModel):
|
|
173
|
+
total: Optional[float]
|
|
174
|
+
markets: Optional[list[MarketValue]]
|