From b1a949ca36cb137f746d7e6c2e85385192f56842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Thu, 25 Apr 2024 08:39:38 -0300 Subject: [PATCH 1/4] add generated subgraph files --- cow_py/subgraph/__init__.py | 0 cow_py/subgraph/client/__init__.py | 115 + cow_py/subgraph/client/async_base_client.py | 370 +++ cow_py/subgraph/client/base_model.py | 30 + cow_py/subgraph/client/enums.py | 423 +++ cow_py/subgraph/client/exceptions.py | 85 + cow_py/subgraph/client/input_types.py | 2567 +++++++++++++++++ cow_py/subgraph/client/last_days_volume.py | 17 + cow_py/subgraph/client/last_hours_volume.py | 17 + cow_py/subgraph/client/subgraph_client.py | 75 + cow_py/subgraph/client/totals.py | 23 + cow_py/subgraph/deployments.py | 40 + cow_py/subgraph/queries/lastDayVolume.gql | 10 + cow_py/subgraph/queries/lastHoursVolume.gql | 10 + cow_py/subgraph/queries/totals.gql | 15 + tests/subgraph/__init__.py | 0 tests/subgraph/client/test_subgraph_client.py | 466 +++ tests/subgraph/test_deployments.py | 44 + 18 files changed, 4307 insertions(+) create mode 100644 cow_py/subgraph/__init__.py create mode 100644 cow_py/subgraph/client/__init__.py create mode 100644 cow_py/subgraph/client/async_base_client.py create mode 100644 cow_py/subgraph/client/base_model.py create mode 100644 cow_py/subgraph/client/enums.py create mode 100644 cow_py/subgraph/client/exceptions.py create mode 100644 cow_py/subgraph/client/input_types.py create mode 100644 cow_py/subgraph/client/last_days_volume.py create mode 100644 cow_py/subgraph/client/last_hours_volume.py create mode 100644 cow_py/subgraph/client/subgraph_client.py create mode 100644 cow_py/subgraph/client/totals.py create mode 100644 cow_py/subgraph/deployments.py create mode 100644 cow_py/subgraph/queries/lastDayVolume.gql create mode 100644 cow_py/subgraph/queries/lastHoursVolume.gql create mode 100644 cow_py/subgraph/queries/totals.gql create mode 100644 tests/subgraph/__init__.py create mode 100644 tests/subgraph/client/test_subgraph_client.py create mode 100644 tests/subgraph/test_deployments.py diff --git a/cow_py/subgraph/__init__.py b/cow_py/subgraph/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cow_py/subgraph/client/__init__.py b/cow_py/subgraph/client/__init__.py new file mode 100644 index 0000000..ec3b94a --- /dev/null +++ b/cow_py/subgraph/client/__init__.py @@ -0,0 +1,115 @@ +# Generated by ariadne-codegen + +from .async_base_client import AsyncBaseClient +from .base_model import BaseModel, Upload +from .enums import ( + Aggregation_interval, + Bundle_orderBy, + DailyTotal_orderBy, + HourlyTotal_orderBy, + Order_orderBy, + OrderDirection, + Pair_orderBy, + PairDaily_orderBy, + PairHourly_orderBy, + Settlement_orderBy, + Token_orderBy, + TokenDailyTotal_orderBy, + TokenHourlyTotal_orderBy, + TokenTradingEvent_orderBy, + Total_orderBy, + Trade_orderBy, + UniswapPool_orderBy, + UniswapToken_orderBy, + User_orderBy, + _SubgraphErrorPolicy_, +) +from .exceptions import ( + GraphQLClientError, + GraphQLClientGraphQLError, + GraphQLClientGraphQLMultiError, + GraphQLClientHttpError, + GraphQLClientInvalidResponseError, +) +from .input_types import ( + Block_height, + BlockChangedFilter, + Bundle_filter, + DailyTotal_filter, + HourlyTotal_filter, + Order_filter, + Pair_filter, + PairDaily_filter, + PairHourly_filter, + Settlement_filter, + Token_filter, + TokenDailyTotal_filter, + TokenHourlyTotal_filter, + TokenTradingEvent_filter, + Total_filter, + Trade_filter, + UniswapPool_filter, + UniswapToken_filter, + User_filter, +) +from .last_days_volume import LastDaysVolume, LastDaysVolumeDailyTotals +from .last_hours_volume import LastHoursVolume, LastHoursVolumeHourlyTotals +from .subgraph_client import SubgraphClient +from .totals import Totals, TotalsTotals + +__all__ = [ + "Aggregation_interval", + "AsyncBaseClient", + "BaseModel", + "BlockChangedFilter", + "Block_height", + "Bundle_filter", + "Bundle_orderBy", + "DailyTotal_filter", + "DailyTotal_orderBy", + "GraphQLClientError", + "GraphQLClientGraphQLError", + "GraphQLClientGraphQLMultiError", + "GraphQLClientHttpError", + "GraphQLClientInvalidResponseError", + "HourlyTotal_filter", + "HourlyTotal_orderBy", + "LastDaysVolume", + "LastDaysVolumeDailyTotals", + "LastHoursVolume", + "LastHoursVolumeHourlyTotals", + "OrderDirection", + "Order_filter", + "Order_orderBy", + "PairDaily_filter", + "PairDaily_orderBy", + "PairHourly_filter", + "PairHourly_orderBy", + "Pair_filter", + "Pair_orderBy", + "Settlement_filter", + "Settlement_orderBy", + "SubgraphClient", + "TokenDailyTotal_filter", + "TokenDailyTotal_orderBy", + "TokenHourlyTotal_filter", + "TokenHourlyTotal_orderBy", + "TokenTradingEvent_filter", + "TokenTradingEvent_orderBy", + "Token_filter", + "Token_orderBy", + "Total_filter", + "Total_orderBy", + "Totals", + "TotalsTotals", + "Trade_filter", + "Trade_orderBy", + "UniswapPool_filter", + "UniswapPool_orderBy", + "UniswapToken_filter", + "UniswapToken_orderBy", + "Upload", + "User_filter", + "User_orderBy", + "_SubgraphErrorPolicy_", +] diff --git a/cow_py/subgraph/client/async_base_client.py b/cow_py/subgraph/client/async_base_client.py new file mode 100644 index 0000000..b9f1f6b --- /dev/null +++ b/cow_py/subgraph/client/async_base_client.py @@ -0,0 +1,370 @@ +# Generated by ariadne-codegen + +import enum +import json +from typing import IO, Any, AsyncIterator, Dict, List, Optional, Tuple, TypeVar, cast +from uuid import uuid4 + +import httpx +from pydantic import BaseModel +from pydantic_core import to_jsonable_python + +from .base_model import UNSET, Upload +from .exceptions import ( + GraphQLClientGraphQLMultiError, + GraphQLClientHttpError, + GraphQLClientInvalidMessageFormat, + GraphQLClientInvalidResponseError, +) + +try: + from websockets.client import WebSocketClientProtocol + from websockets.client import connect as ws_connect # type: ignore[import-not-found,unused-ignore] + from websockets.typing import ( # type: ignore[import-not-found,unused-ignore] + Data, + Origin, + Subprotocol, + ) +except ImportError: + from contextlib import asynccontextmanager + + @asynccontextmanager # type: ignore + async def ws_connect(*args, **kwargs): # pylint: disable=unused-argument + raise NotImplementedError("Subscriptions require 'websockets' package.") + yield # pylint: disable=unreachable + + WebSocketClientProtocol = Any # type: ignore[misc,assignment,unused-ignore] + Data = Any # type: ignore[misc,assignment,unused-ignore] + Origin = Any # type: ignore[misc,assignment,unused-ignore] + + def Subprotocol(*args, **kwargs): # type: ignore # pylint: disable=invalid-name + raise NotImplementedError("Subscriptions require 'websockets' package.") + + +Self = TypeVar("Self", bound="AsyncBaseClient") + +GRAPHQL_TRANSPORT_WS = "graphql-transport-ws" + + +class GraphQLTransportWSMessageType(str, enum.Enum): + CONNECTION_INIT = "connection_init" + CONNECTION_ACK = "connection_ack" + PING = "ping" + PONG = "pong" + SUBSCRIBE = "subscribe" + NEXT = "next" + ERROR = "error" + COMPLETE = "complete" + + +class AsyncBaseClient: + def __init__( + self, + url: str = "", + headers: Optional[Dict[str, str]] = None, + http_client: Optional[httpx.AsyncClient] = None, + ws_url: str = "", + ws_headers: Optional[Dict[str, Any]] = None, + ws_origin: Optional[str] = None, + ws_connection_init_payload: Optional[Dict[str, Any]] = None, + ) -> None: + self.url = url + self.headers = headers + self.http_client = ( + http_client if http_client else httpx.AsyncClient(headers=headers) + ) + + self.ws_url = ws_url + self.ws_headers = ws_headers or {} + self.ws_origin = Origin(ws_origin) if ws_origin else None + self.ws_connection_init_payload = ws_connection_init_payload + + async def __aenter__(self: Self) -> Self: + return self + + async def __aexit__( + self, + exc_type: object, + exc_val: object, + exc_tb: object, + ) -> None: + await self.http_client.aclose() + + async def execute( + self, + query: str, + operation_name: Optional[str] = None, + variables: Optional[Dict[str, Any]] = None, + **kwargs: Any, + ) -> httpx.Response: + processed_variables, files, files_map = self._process_variables(variables) + + if files and files_map: + return await self._execute_multipart( + query=query, + operation_name=operation_name, + variables=processed_variables, + files=files, + files_map=files_map, + **kwargs, + ) + + return await self._execute_json( + query=query, + operation_name=operation_name, + variables=processed_variables, + **kwargs, + ) + + def get_data(self, response: httpx.Response) -> Dict[str, Any]: + if not response.is_success: + raise GraphQLClientHttpError( + status_code=response.status_code, response=response + ) + + try: + response_json = response.json() + except ValueError as exc: + raise GraphQLClientInvalidResponseError(response=response) from exc + + if (not isinstance(response_json, dict)) or ( + "data" not in response_json and "errors" not in response_json + ): + raise GraphQLClientInvalidResponseError(response=response) + + data = response_json.get("data") + errors = response_json.get("errors") + + if errors: + raise GraphQLClientGraphQLMultiError.from_errors_dicts( + errors_dicts=errors, data=data + ) + + return cast(Dict[str, Any], data) + + async def execute_ws( + self, + query: str, + operation_name: Optional[str] = None, + variables: Optional[Dict[str, Any]] = None, + **kwargs: Any, + ) -> AsyncIterator[Dict[str, Any]]: + headers = self.ws_headers.copy() + headers.update(kwargs.get("extra_headers", {})) + + merged_kwargs: Dict[str, Any] = {"origin": self.ws_origin} + merged_kwargs.update(kwargs) + merged_kwargs["extra_headers"] = headers + + operation_id = str(uuid4()) + async with ws_connect( + self.ws_url, + subprotocols=[Subprotocol(GRAPHQL_TRANSPORT_WS)], + **merged_kwargs, + ) as websocket: + await self._send_connection_init(websocket) + # wait for connection_ack from server + await self._handle_ws_message( + await websocket.recv(), + websocket, + expected_type=GraphQLTransportWSMessageType.CONNECTION_ACK, + ) + await self._send_subscribe( + websocket, + operation_id=operation_id, + query=query, + operation_name=operation_name, + variables=variables, + ) + + async for message in websocket: + data = await self._handle_ws_message(message, websocket) + if data: + yield data + + def _process_variables( + self, variables: Optional[Dict[str, Any]] + ) -> Tuple[ + Dict[str, Any], Dict[str, Tuple[str, IO[bytes], str]], Dict[str, List[str]] + ]: + if not variables: + return {}, {}, {} + + serializable_variables = self._convert_dict_to_json_serializable(variables) + return self._get_files_from_variables(serializable_variables) + + def _convert_dict_to_json_serializable( + self, dict_: Dict[str, Any] + ) -> Dict[str, Any]: + return { + key: self._convert_value(value) + for key, value in dict_.items() + if value is not UNSET + } + + def _convert_value(self, value: Any) -> Any: + if isinstance(value, BaseModel): + return value.model_dump(by_alias=True, exclude_unset=True) + if isinstance(value, list): + return [self._convert_value(item) for item in value] + return value + + def _get_files_from_variables( + self, variables: Dict[str, Any] + ) -> Tuple[ + Dict[str, Any], Dict[str, Tuple[str, IO[bytes], str]], Dict[str, List[str]] + ]: + files_map: Dict[str, List[str]] = {} + files_list: List[Upload] = [] + + def separate_files(path: str, obj: Any) -> Any: + if isinstance(obj, list): + nulled_list = [] + for index, value in enumerate(obj): + value = separate_files(f"{path}.{index}", value) + nulled_list.append(value) + return nulled_list + + if isinstance(obj, dict): + nulled_dict = {} + for key, value in obj.items(): + value = separate_files(f"{path}.{key}", value) + nulled_dict[key] = value + return nulled_dict + + if isinstance(obj, Upload): + if obj in files_list: + file_index = files_list.index(obj) + files_map[str(file_index)].append(path) + else: + file_index = len(files_list) + files_list.append(obj) + files_map[str(file_index)] = [path] + return None + + return obj + + nulled_variables = separate_files("variables", variables) + files: Dict[str, Tuple[str, IO[bytes], str]] = { + str(i): (file_.filename, cast(IO[bytes], file_.content), file_.content_type) + for i, file_ in enumerate(files_list) + } + return nulled_variables, files, files_map + + async def _execute_multipart( + self, + query: str, + operation_name: Optional[str], + variables: Dict[str, Any], + files: Dict[str, Tuple[str, IO[bytes], str]], + files_map: Dict[str, List[str]], + **kwargs: Any, + ) -> httpx.Response: + data = { + "operations": json.dumps( + { + "query": query, + "operationName": operation_name, + "variables": variables, + }, + default=to_jsonable_python, + ), + "map": json.dumps(files_map, default=to_jsonable_python), + } + + return await self.http_client.post( + url=self.url, data=data, files=files, **kwargs + ) + + async def _execute_json( + self, + query: str, + operation_name: Optional[str], + variables: Dict[str, Any], + **kwargs: Any, + ) -> httpx.Response: + headers: Dict[str, str] = {"Content-Type": "application/json"} + headers.update(kwargs.get("headers", {})) + + merged_kwargs: Dict[str, Any] = kwargs.copy() + merged_kwargs["headers"] = headers + + return await self.http_client.post( + url=self.url, + content=json.dumps( + { + "query": query, + "operationName": operation_name, + "variables": variables, + }, + default=to_jsonable_python, + ), + **merged_kwargs, + ) + + async def _send_connection_init(self, websocket: WebSocketClientProtocol) -> None: + payload: Dict[str, Any] = { + "type": GraphQLTransportWSMessageType.CONNECTION_INIT.value + } + if self.ws_connection_init_payload: + payload["payload"] = self.ws_connection_init_payload + await websocket.send(json.dumps(payload)) + + async def _send_subscribe( + self, + websocket: WebSocketClientProtocol, + operation_id: str, + query: str, + operation_name: Optional[str] = None, + variables: Optional[Dict[str, Any]] = None, + ) -> None: + payload: Dict[str, Any] = { + "id": operation_id, + "type": GraphQLTransportWSMessageType.SUBSCRIBE.value, + "payload": {"query": query, "operationName": operation_name}, + } + if variables: + payload["payload"]["variables"] = self._convert_dict_to_json_serializable( + variables + ) + await websocket.send(json.dumps(payload)) + + async def _handle_ws_message( + self, + message: Data, + websocket: WebSocketClientProtocol, + expected_type: Optional[GraphQLTransportWSMessageType] = None, + ) -> Optional[Dict[str, Any]]: + try: + message_dict = json.loads(message) + except json.JSONDecodeError as exc: + raise GraphQLClientInvalidMessageFormat(message=message) from exc + + type_ = message_dict.get("type") + payload = message_dict.get("payload", {}) + + if not type_ or type_ not in {t.value for t in GraphQLTransportWSMessageType}: + raise GraphQLClientInvalidMessageFormat(message=message) + + if expected_type and expected_type != type_: + raise GraphQLClientInvalidMessageFormat( + f"Invalid message received. Expected: {expected_type.value}" + ) + + if type_ == GraphQLTransportWSMessageType.NEXT: + if "data" not in payload: + raise GraphQLClientInvalidMessageFormat(message=message) + return cast(Dict[str, Any], payload["data"]) + + if type_ == GraphQLTransportWSMessageType.COMPLETE: + await websocket.close() + elif type_ == GraphQLTransportWSMessageType.PING: + await websocket.send( + json.dumps({"type": GraphQLTransportWSMessageType.PONG.value}) + ) + elif type_ == GraphQLTransportWSMessageType.ERROR: + raise GraphQLClientGraphQLMultiError.from_errors_dicts( + errors_dicts=payload, data=message_dict + ) + + return None diff --git a/cow_py/subgraph/client/base_model.py b/cow_py/subgraph/client/base_model.py new file mode 100644 index 0000000..a93b416 --- /dev/null +++ b/cow_py/subgraph/client/base_model.py @@ -0,0 +1,30 @@ +# Generated by ariadne-codegen + +from io import IOBase + +from pydantic import BaseModel as PydanticBaseModel +from pydantic import ConfigDict + + +class UnsetType: + def __bool__(self) -> bool: + return False + + +UNSET = UnsetType() + + +class BaseModel(PydanticBaseModel): + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + arbitrary_types_allowed=True, + protected_namespaces=(), + ) + + +class Upload: + def __init__(self, filename: str, content: IOBase, content_type: str): + self.filename = filename + self.content = content + self.content_type = content_type diff --git a/cow_py/subgraph/client/enums.py b/cow_py/subgraph/client/enums.py new file mode 100644 index 0000000..1225b1a --- /dev/null +++ b/cow_py/subgraph/client/enums.py @@ -0,0 +1,423 @@ +# Generated by ariadne-codegen +# Source: https://api.thegraph.com/subgraphs/name/cowprotocol/cow + +from enum import Enum + + +class Aggregation_interval(str, Enum): + hour = "hour" + day = "day" + + +class Bundle_orderBy(str, Enum): + id = "id" + ethPriceUSD = "ethPriceUSD" + + +class DailyTotal_orderBy(str, Enum): + id = "id" + timestamp = "timestamp" + totalTokens = "totalTokens" + numberOfTrades = "numberOfTrades" + orders = "orders" + settlements = "settlements" + volumeUsd = "volumeUsd" + volumeEth = "volumeEth" + feesUsd = "feesUsd" + feesEth = "feesEth" + tokens = "tokens" + + +class HourlyTotal_orderBy(str, Enum): + id = "id" + timestamp = "timestamp" + totalTokens = "totalTokens" + numberOfTrades = "numberOfTrades" + orders = "orders" + settlements = "settlements" + volumeUsd = "volumeUsd" + volumeEth = "volumeEth" + feesUsd = "feesUsd" + feesEth = "feesEth" + tokens = "tokens" + + +class OrderDirection(str, Enum): + asc = "asc" + desc = "desc" + + +class Order_orderBy(str, Enum): + id = "id" + owner = "owner" + owner__id = "owner__id" + owner__address = "owner__address" + owner__firstTradeTimestamp = "owner__firstTradeTimestamp" + owner__isSolver = "owner__isSolver" + owner__numberOfTrades = "owner__numberOfTrades" + owner__solvedAmountEth = "owner__solvedAmountEth" + owner__solvedAmountUsd = "owner__solvedAmountUsd" + owner__tradedAmountUsd = "owner__tradedAmountUsd" + owner__tradedAmountEth = "owner__tradedAmountEth" + tradesTimestamp = "tradesTimestamp" + invalidateTimestamp = "invalidateTimestamp" + presignTimestamp = "presignTimestamp" + trades = "trades" + isSigned = "isSigned" + isValid = "isValid" + + +class PairDaily_orderBy(str, Enum): + id = "id" + token0 = "token0" + token0__id = "token0__id" + token0__address = "token0__address" + token0__firstTradeTimestamp = "token0__firstTradeTimestamp" + token0__name = "token0__name" + token0__symbol = "token0__symbol" + token0__decimals = "token0__decimals" + token0__totalVolume = "token0__totalVolume" + token0__priceEth = "token0__priceEth" + token0__priceUsd = "token0__priceUsd" + token0__numberOfTrades = "token0__numberOfTrades" + token0__totalVolumeUsd = "token0__totalVolumeUsd" + token0__totalVolumeEth = "token0__totalVolumeEth" + token1 = "token1" + token1__id = "token1__id" + token1__address = "token1__address" + token1__firstTradeTimestamp = "token1__firstTradeTimestamp" + token1__name = "token1__name" + token1__symbol = "token1__symbol" + token1__decimals = "token1__decimals" + token1__totalVolume = "token1__totalVolume" + token1__priceEth = "token1__priceEth" + token1__priceUsd = "token1__priceUsd" + token1__numberOfTrades = "token1__numberOfTrades" + token1__totalVolumeUsd = "token1__totalVolumeUsd" + token1__totalVolumeEth = "token1__totalVolumeEth" + token0Price = "token0Price" + token1Price = "token1Price" + token0relativePrice = "token0relativePrice" + token1relativePrice = "token1relativePrice" + timestamp = "timestamp" + volumeToken0 = "volumeToken0" + volumeToken1 = "volumeToken1" + volumeTradedEth = "volumeTradedEth" + volumeTradedUsd = "volumeTradedUsd" + + +class PairHourly_orderBy(str, Enum): + id = "id" + token0 = "token0" + token0__id = "token0__id" + token0__address = "token0__address" + token0__firstTradeTimestamp = "token0__firstTradeTimestamp" + token0__name = "token0__name" + token0__symbol = "token0__symbol" + token0__decimals = "token0__decimals" + token0__totalVolume = "token0__totalVolume" + token0__priceEth = "token0__priceEth" + token0__priceUsd = "token0__priceUsd" + token0__numberOfTrades = "token0__numberOfTrades" + token0__totalVolumeUsd = "token0__totalVolumeUsd" + token0__totalVolumeEth = "token0__totalVolumeEth" + token1 = "token1" + token1__id = "token1__id" + token1__address = "token1__address" + token1__firstTradeTimestamp = "token1__firstTradeTimestamp" + token1__name = "token1__name" + token1__symbol = "token1__symbol" + token1__decimals = "token1__decimals" + token1__totalVolume = "token1__totalVolume" + token1__priceEth = "token1__priceEth" + token1__priceUsd = "token1__priceUsd" + token1__numberOfTrades = "token1__numberOfTrades" + token1__totalVolumeUsd = "token1__totalVolumeUsd" + token1__totalVolumeEth = "token1__totalVolumeEth" + token0Price = "token0Price" + token1Price = "token1Price" + token0relativePrice = "token0relativePrice" + token1relativePrice = "token1relativePrice" + timestamp = "timestamp" + volumeToken0 = "volumeToken0" + volumeToken1 = "volumeToken1" + volumeTradedEth = "volumeTradedEth" + volumeTradedUsd = "volumeTradedUsd" + + +class Pair_orderBy(str, Enum): + id = "id" + token0 = "token0" + token0__id = "token0__id" + token0__address = "token0__address" + token0__firstTradeTimestamp = "token0__firstTradeTimestamp" + token0__name = "token0__name" + token0__symbol = "token0__symbol" + token0__decimals = "token0__decimals" + token0__totalVolume = "token0__totalVolume" + token0__priceEth = "token0__priceEth" + token0__priceUsd = "token0__priceUsd" + token0__numberOfTrades = "token0__numberOfTrades" + token0__totalVolumeUsd = "token0__totalVolumeUsd" + token0__totalVolumeEth = "token0__totalVolumeEth" + token1 = "token1" + token1__id = "token1__id" + token1__address = "token1__address" + token1__firstTradeTimestamp = "token1__firstTradeTimestamp" + token1__name = "token1__name" + token1__symbol = "token1__symbol" + token1__decimals = "token1__decimals" + token1__totalVolume = "token1__totalVolume" + token1__priceEth = "token1__priceEth" + token1__priceUsd = "token1__priceUsd" + token1__numberOfTrades = "token1__numberOfTrades" + token1__totalVolumeUsd = "token1__totalVolumeUsd" + token1__totalVolumeEth = "token1__totalVolumeEth" + token0Price = "token0Price" + token1Price = "token1Price" + token0relativePrice = "token0relativePrice" + token1relativePrice = "token1relativePrice" + volumeToken0 = "volumeToken0" + volumeToken1 = "volumeToken1" + volumeTradedEth = "volumeTradedEth" + volumeTradedUsd = "volumeTradedUsd" + + +class Settlement_orderBy(str, Enum): + id = "id" + txHash = "txHash" + firstTradeTimestamp = "firstTradeTimestamp" + trades = "trades" + solver = "solver" + solver__id = "solver__id" + solver__address = "solver__address" + solver__firstTradeTimestamp = "solver__firstTradeTimestamp" + solver__isSolver = "solver__isSolver" + solver__numberOfTrades = "solver__numberOfTrades" + solver__solvedAmountEth = "solver__solvedAmountEth" + solver__solvedAmountUsd = "solver__solvedAmountUsd" + solver__tradedAmountUsd = "solver__tradedAmountUsd" + solver__tradedAmountEth = "solver__tradedAmountEth" + + +class TokenDailyTotal_orderBy(str, Enum): + id = "id" + token = "token" + token__id = "token__id" + token__address = "token__address" + token__firstTradeTimestamp = "token__firstTradeTimestamp" + token__name = "token__name" + token__symbol = "token__symbol" + token__decimals = "token__decimals" + token__totalVolume = "token__totalVolume" + token__priceEth = "token__priceEth" + token__priceUsd = "token__priceUsd" + token__numberOfTrades = "token__numberOfTrades" + token__totalVolumeUsd = "token__totalVolumeUsd" + token__totalVolumeEth = "token__totalVolumeEth" + timestamp = "timestamp" + totalVolume = "totalVolume" + totalVolumeUsd = "totalVolumeUsd" + totalVolumeEth = "totalVolumeEth" + totalTrades = "totalTrades" + openPrice = "openPrice" + closePrice = "closePrice" + higherPrice = "higherPrice" + lowerPrice = "lowerPrice" + averagePrice = "averagePrice" + + +class TokenHourlyTotal_orderBy(str, Enum): + id = "id" + token = "token" + token__id = "token__id" + token__address = "token__address" + token__firstTradeTimestamp = "token__firstTradeTimestamp" + token__name = "token__name" + token__symbol = "token__symbol" + token__decimals = "token__decimals" + token__totalVolume = "token__totalVolume" + token__priceEth = "token__priceEth" + token__priceUsd = "token__priceUsd" + token__numberOfTrades = "token__numberOfTrades" + token__totalVolumeUsd = "token__totalVolumeUsd" + token__totalVolumeEth = "token__totalVolumeEth" + timestamp = "timestamp" + totalVolume = "totalVolume" + totalVolumeUsd = "totalVolumeUsd" + totalVolumeEth = "totalVolumeEth" + totalTrades = "totalTrades" + openPrice = "openPrice" + closePrice = "closePrice" + higherPrice = "higherPrice" + lowerPrice = "lowerPrice" + averagePrice = "averagePrice" + + +class TokenTradingEvent_orderBy(str, Enum): + id = "id" + token = "token" + token__id = "token__id" + token__address = "token__address" + token__firstTradeTimestamp = "token__firstTradeTimestamp" + token__name = "token__name" + token__symbol = "token__symbol" + token__decimals = "token__decimals" + token__totalVolume = "token__totalVolume" + token__priceEth = "token__priceEth" + token__priceUsd = "token__priceUsd" + token__numberOfTrades = "token__numberOfTrades" + token__totalVolumeUsd = "token__totalVolumeUsd" + token__totalVolumeEth = "token__totalVolumeEth" + trade = "trade" + trade__id = "trade__id" + trade__timestamp = "trade__timestamp" + trade__gasPrice = "trade__gasPrice" + trade__feeAmount = "trade__feeAmount" + trade__txHash = "trade__txHash" + trade__buyAmount = "trade__buyAmount" + trade__sellAmount = "trade__sellAmount" + trade__buyAmountEth = "trade__buyAmountEth" + trade__sellAmountEth = "trade__sellAmountEth" + trade__buyAmountUsd = "trade__buyAmountUsd" + trade__sellAmountUsd = "trade__sellAmountUsd" + timestamp = "timestamp" + amountEth = "amountEth" + amountUsd = "amountUsd" + + +class Token_orderBy(str, Enum): + id = "id" + address = "address" + firstTradeTimestamp = "firstTradeTimestamp" + name = "name" + symbol = "symbol" + decimals = "decimals" + totalVolume = "totalVolume" + priceEth = "priceEth" + priceUsd = "priceUsd" + history = "history" + hourlyTotals = "hourlyTotals" + dailyTotals = "dailyTotals" + numberOfTrades = "numberOfTrades" + totalVolumeUsd = "totalVolumeUsd" + totalVolumeEth = "totalVolumeEth" + + +class Total_orderBy(str, Enum): + id = "id" + tokens = "tokens" + orders = "orders" + traders = "traders" + numberOfTrades = "numberOfTrades" + settlements = "settlements" + volumeUsd = "volumeUsd" + volumeEth = "volumeEth" + feesUsd = "feesUsd" + feesEth = "feesEth" + + +class Trade_orderBy(str, Enum): + id = "id" + timestamp = "timestamp" + gasPrice = "gasPrice" + feeAmount = "feeAmount" + txHash = "txHash" + settlement = "settlement" + settlement__id = "settlement__id" + settlement__txHash = "settlement__txHash" + settlement__firstTradeTimestamp = "settlement__firstTradeTimestamp" + buyAmount = "buyAmount" + sellAmount = "sellAmount" + sellToken = "sellToken" + sellToken__id = "sellToken__id" + sellToken__address = "sellToken__address" + sellToken__firstTradeTimestamp = "sellToken__firstTradeTimestamp" + sellToken__name = "sellToken__name" + sellToken__symbol = "sellToken__symbol" + sellToken__decimals = "sellToken__decimals" + sellToken__totalVolume = "sellToken__totalVolume" + sellToken__priceEth = "sellToken__priceEth" + sellToken__priceUsd = "sellToken__priceUsd" + sellToken__numberOfTrades = "sellToken__numberOfTrades" + sellToken__totalVolumeUsd = "sellToken__totalVolumeUsd" + sellToken__totalVolumeEth = "sellToken__totalVolumeEth" + buyToken = "buyToken" + buyToken__id = "buyToken__id" + buyToken__address = "buyToken__address" + buyToken__firstTradeTimestamp = "buyToken__firstTradeTimestamp" + buyToken__name = "buyToken__name" + buyToken__symbol = "buyToken__symbol" + buyToken__decimals = "buyToken__decimals" + buyToken__totalVolume = "buyToken__totalVolume" + buyToken__priceEth = "buyToken__priceEth" + buyToken__priceUsd = "buyToken__priceUsd" + buyToken__numberOfTrades = "buyToken__numberOfTrades" + buyToken__totalVolumeUsd = "buyToken__totalVolumeUsd" + buyToken__totalVolumeEth = "buyToken__totalVolumeEth" + order = "order" + order__id = "order__id" + order__tradesTimestamp = "order__tradesTimestamp" + order__invalidateTimestamp = "order__invalidateTimestamp" + order__presignTimestamp = "order__presignTimestamp" + order__isSigned = "order__isSigned" + order__isValid = "order__isValid" + buyAmountEth = "buyAmountEth" + sellAmountEth = "sellAmountEth" + buyAmountUsd = "buyAmountUsd" + sellAmountUsd = "sellAmountUsd" + + +class UniswapPool_orderBy(str, Enum): + id = "id" + token0 = "token0" + token0__id = "token0__id" + token0__address = "token0__address" + token0__name = "token0__name" + token0__symbol = "token0__symbol" + token0__decimals = "token0__decimals" + token0__priceEth = "token0__priceEth" + token0__priceUsd = "token0__priceUsd" + token1 = "token1" + token1__id = "token1__id" + token1__address = "token1__address" + token1__name = "token1__name" + token1__symbol = "token1__symbol" + token1__decimals = "token1__decimals" + token1__priceEth = "token1__priceEth" + token1__priceUsd = "token1__priceUsd" + liquidity = "liquidity" + token0Price = "token0Price" + token1Price = "token1Price" + tick = "tick" + totalValueLockedToken0 = "totalValueLockedToken0" + totalValueLockedToken1 = "totalValueLockedToken1" + + +class UniswapToken_orderBy(str, Enum): + id = "id" + address = "address" + name = "name" + symbol = "symbol" + decimals = "decimals" + priceEth = "priceEth" + priceUsd = "priceUsd" + allowedPools = "allowedPools" + + +class User_orderBy(str, Enum): + id = "id" + address = "address" + firstTradeTimestamp = "firstTradeTimestamp" + ordersPlaced = "ordersPlaced" + isSolver = "isSolver" + numberOfTrades = "numberOfTrades" + solvedAmountEth = "solvedAmountEth" + solvedAmountUsd = "solvedAmountUsd" + tradedAmountUsd = "tradedAmountUsd" + tradedAmountEth = "tradedAmountEth" + + +class _SubgraphErrorPolicy_(str, Enum): + allow = "allow" + deny = "deny" diff --git a/cow_py/subgraph/client/exceptions.py b/cow_py/subgraph/client/exceptions.py new file mode 100644 index 0000000..9fbe116 --- /dev/null +++ b/cow_py/subgraph/client/exceptions.py @@ -0,0 +1,85 @@ +# Generated by ariadne-codegen + +from typing import Any, Dict, List, Optional, Union + +import httpx + + +class GraphQLClientError(Exception): + """Base exception.""" + + +class GraphQLClientHttpError(GraphQLClientError): + def __init__(self, status_code: int, response: httpx.Response) -> None: + self.status_code = status_code + self.response = response + + def __str__(self) -> str: + return f"HTTP status code: {self.status_code}" + + +class GraphQLClientInvalidResponseError(GraphQLClientError): + def __init__(self, response: httpx.Response) -> None: + self.response = response + + def __str__(self) -> str: + return "Invalid response format." + + +class GraphQLClientGraphQLError(GraphQLClientError): + def __init__( + self, + message: str, + locations: Optional[List[Dict[str, int]]] = None, + path: Optional[List[str]] = None, + extensions: Optional[Dict[str, object]] = None, + orginal: Optional[Dict[str, object]] = None, + ): + self.message = message + self.locations = locations + self.path = path + self.extensions = extensions + self.orginal = orginal + + def __str__(self) -> str: + return self.message + + @classmethod + def from_dict(cls, error: Dict[str, Any]) -> "GraphQLClientGraphQLError": + return cls( + message=error["message"], + locations=error.get("locations"), + path=error.get("path"), + extensions=error.get("extensions"), + orginal=error, + ) + + +class GraphQLClientGraphQLMultiError(GraphQLClientError): + def __init__( + self, + errors: List[GraphQLClientGraphQLError], + data: Optional[Dict[str, Any]] = None, + ): + self.errors = errors + self.data = data + + def __str__(self) -> str: + return "; ".join(str(e) for e in self.errors) + + @classmethod + def from_errors_dicts( + cls, errors_dicts: List[Dict[str, Any]], data: Optional[Dict[str, Any]] = None + ) -> "GraphQLClientGraphQLMultiError": + return cls( + errors=[GraphQLClientGraphQLError.from_dict(e) for e in errors_dicts], + data=data, + ) + + +class GraphQLClientInvalidMessageFormat(GraphQLClientError): + def __init__(self, message: Union[str, bytes]) -> None: + self.message = message + + def __str__(self) -> str: + return "Invalid message format." diff --git a/cow_py/subgraph/client/input_types.py b/cow_py/subgraph/client/input_types.py new file mode 100644 index 0000000..19b104b --- /dev/null +++ b/cow_py/subgraph/client/input_types.py @@ -0,0 +1,2567 @@ +# Generated by ariadne-codegen +# Source: https://api.thegraph.com/subgraphs/name/cowprotocol/cow + +from typing import Any, List, Optional + +from pydantic import Field + +from .base_model import BaseModel + + +class BlockChangedFilter(BaseModel): + number_gte: int + + +class Block_height(BaseModel): + hash: Optional[Any] = None + number: Optional[int] = None + number_gte: Optional[int] = None + + +class Bundle_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + eth_price_usd: Optional[Any] = Field(alias="ethPriceUSD", default=None) + eth_price_not: Optional[Any] = Field(alias="ethPriceUSD_not", default=None) + eth_price_gt: Optional[Any] = Field(alias="ethPriceUSD_gt", default=None) + eth_price_lt: Optional[Any] = Field(alias="ethPriceUSD_lt", default=None) + eth_price_gte: Optional[Any] = Field(alias="ethPriceUSD_gte", default=None) + eth_price_lte: Optional[Any] = Field(alias="ethPriceUSD_lte", default=None) + eth_price_in: Optional[List[Any]] = Field(alias="ethPriceUSD_in", default=None) + eth_price_not_in: Optional[List[Any]] = Field( + alias="ethPriceUSD_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Bundle_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["Bundle_filter"]]] = Field(alias="or", default=None) + + +class DailyTotal_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + total_tokens: Optional[Any] = Field(alias="totalTokens", default=None) + total_tokens_not: Optional[Any] = Field(alias="totalTokens_not", default=None) + total_tokens_gt: Optional[Any] = Field(alias="totalTokens_gt", default=None) + total_tokens_lt: Optional[Any] = Field(alias="totalTokens_lt", default=None) + total_tokens_gte: Optional[Any] = Field(alias="totalTokens_gte", default=None) + total_tokens_lte: Optional[Any] = Field(alias="totalTokens_lte", default=None) + total_tokens_in: Optional[List[Any]] = Field(alias="totalTokens_in", default=None) + total_tokens_not_in: Optional[List[Any]] = Field( + alias="totalTokens_not_in", default=None + ) + number_of_trades: Optional[Any] = Field(alias="numberOfTrades", default=None) + number_of_trades_not: Optional[Any] = Field( + alias="numberOfTrades_not", default=None + ) + number_of_trades_gt: Optional[Any] = Field(alias="numberOfTrades_gt", default=None) + number_of_trades_lt: Optional[Any] = Field(alias="numberOfTrades_lt", default=None) + number_of_trades_gte: Optional[Any] = Field( + alias="numberOfTrades_gte", default=None + ) + number_of_trades_lte: Optional[Any] = Field( + alias="numberOfTrades_lte", default=None + ) + number_of_trades_in: Optional[List[Any]] = Field( + alias="numberOfTrades_in", default=None + ) + number_of_trades_not_in: Optional[List[Any]] = Field( + alias="numberOfTrades_not_in", default=None + ) + orders: Optional[Any] = None + orders_not: Optional[Any] = None + orders_gt: Optional[Any] = None + orders_lt: Optional[Any] = None + orders_gte: Optional[Any] = None + orders_lte: Optional[Any] = None + orders_in: Optional[List[Any]] = None + orders_not_in: Optional[List[Any]] = None + settlements: Optional[Any] = None + settlements_not: Optional[Any] = None + settlements_gt: Optional[Any] = None + settlements_lt: Optional[Any] = None + settlements_gte: Optional[Any] = None + settlements_lte: Optional[Any] = None + settlements_in: Optional[List[Any]] = None + settlements_not_in: Optional[List[Any]] = None + volume_usd: Optional[Any] = Field(alias="volumeUsd", default=None) + volume_usd_not: Optional[Any] = Field(alias="volumeUsd_not", default=None) + volume_usd_gt: Optional[Any] = Field(alias="volumeUsd_gt", default=None) + volume_usd_lt: Optional[Any] = Field(alias="volumeUsd_lt", default=None) + volume_usd_gte: Optional[Any] = Field(alias="volumeUsd_gte", default=None) + volume_usd_lte: Optional[Any] = Field(alias="volumeUsd_lte", default=None) + volume_usd_in: Optional[List[Any]] = Field(alias="volumeUsd_in", default=None) + volume_usd_not_in: Optional[List[Any]] = Field( + alias="volumeUsd_not_in", default=None + ) + volume_eth: Optional[Any] = Field(alias="volumeEth", default=None) + volume_eth_not: Optional[Any] = Field(alias="volumeEth_not", default=None) + volume_eth_gt: Optional[Any] = Field(alias="volumeEth_gt", default=None) + volume_eth_lt: Optional[Any] = Field(alias="volumeEth_lt", default=None) + volume_eth_gte: Optional[Any] = Field(alias="volumeEth_gte", default=None) + volume_eth_lte: Optional[Any] = Field(alias="volumeEth_lte", default=None) + volume_eth_in: Optional[List[Any]] = Field(alias="volumeEth_in", default=None) + volume_eth_not_in: Optional[List[Any]] = Field( + alias="volumeEth_not_in", default=None + ) + fees_usd: Optional[Any] = Field(alias="feesUsd", default=None) + fees_usd_not: Optional[Any] = Field(alias="feesUsd_not", default=None) + fees_usd_gt: Optional[Any] = Field(alias="feesUsd_gt", default=None) + fees_usd_lt: Optional[Any] = Field(alias="feesUsd_lt", default=None) + fees_usd_gte: Optional[Any] = Field(alias="feesUsd_gte", default=None) + fees_usd_lte: Optional[Any] = Field(alias="feesUsd_lte", default=None) + fees_usd_in: Optional[List[Any]] = Field(alias="feesUsd_in", default=None) + fees_usd_not_in: Optional[List[Any]] = Field(alias="feesUsd_not_in", default=None) + fees_eth: Optional[Any] = Field(alias="feesEth", default=None) + fees_eth_not: Optional[Any] = Field(alias="feesEth_not", default=None) + fees_eth_gt: Optional[Any] = Field(alias="feesEth_gt", default=None) + fees_eth_lt: Optional[Any] = Field(alias="feesEth_lt", default=None) + fees_eth_gte: Optional[Any] = Field(alias="feesEth_gte", default=None) + fees_eth_lte: Optional[Any] = Field(alias="feesEth_lte", default=None) + fees_eth_in: Optional[List[Any]] = Field(alias="feesEth_in", default=None) + fees_eth_not_in: Optional[List[Any]] = Field(alias="feesEth_not_in", default=None) + tokens: Optional[List[str]] = None + tokens_not: Optional[List[str]] = None + tokens_contains: Optional[List[str]] = None + tokens_contains_nocase: Optional[List[str]] = None + tokens_not_contains: Optional[List[str]] = None + tokens_not_contains_nocase: Optional[List[str]] = None + tokens: Optional["Token_filter"] = Field(alias="tokens_", default=None) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["DailyTotal_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["DailyTotal_filter"]]] = Field(alias="or", default=None) + + +class HourlyTotal_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + total_tokens: Optional[Any] = Field(alias="totalTokens", default=None) + total_tokens_not: Optional[Any] = Field(alias="totalTokens_not", default=None) + total_tokens_gt: Optional[Any] = Field(alias="totalTokens_gt", default=None) + total_tokens_lt: Optional[Any] = Field(alias="totalTokens_lt", default=None) + total_tokens_gte: Optional[Any] = Field(alias="totalTokens_gte", default=None) + total_tokens_lte: Optional[Any] = Field(alias="totalTokens_lte", default=None) + total_tokens_in: Optional[List[Any]] = Field(alias="totalTokens_in", default=None) + total_tokens_not_in: Optional[List[Any]] = Field( + alias="totalTokens_not_in", default=None + ) + number_of_trades: Optional[Any] = Field(alias="numberOfTrades", default=None) + number_of_trades_not: Optional[Any] = Field( + alias="numberOfTrades_not", default=None + ) + number_of_trades_gt: Optional[Any] = Field(alias="numberOfTrades_gt", default=None) + number_of_trades_lt: Optional[Any] = Field(alias="numberOfTrades_lt", default=None) + number_of_trades_gte: Optional[Any] = Field( + alias="numberOfTrades_gte", default=None + ) + number_of_trades_lte: Optional[Any] = Field( + alias="numberOfTrades_lte", default=None + ) + number_of_trades_in: Optional[List[Any]] = Field( + alias="numberOfTrades_in", default=None + ) + number_of_trades_not_in: Optional[List[Any]] = Field( + alias="numberOfTrades_not_in", default=None + ) + orders: Optional[Any] = None + orders_not: Optional[Any] = None + orders_gt: Optional[Any] = None + orders_lt: Optional[Any] = None + orders_gte: Optional[Any] = None + orders_lte: Optional[Any] = None + orders_in: Optional[List[Any]] = None + orders_not_in: Optional[List[Any]] = None + settlements: Optional[Any] = None + settlements_not: Optional[Any] = None + settlements_gt: Optional[Any] = None + settlements_lt: Optional[Any] = None + settlements_gte: Optional[Any] = None + settlements_lte: Optional[Any] = None + settlements_in: Optional[List[Any]] = None + settlements_not_in: Optional[List[Any]] = None + volume_usd: Optional[Any] = Field(alias="volumeUsd", default=None) + volume_usd_not: Optional[Any] = Field(alias="volumeUsd_not", default=None) + volume_usd_gt: Optional[Any] = Field(alias="volumeUsd_gt", default=None) + volume_usd_lt: Optional[Any] = Field(alias="volumeUsd_lt", default=None) + volume_usd_gte: Optional[Any] = Field(alias="volumeUsd_gte", default=None) + volume_usd_lte: Optional[Any] = Field(alias="volumeUsd_lte", default=None) + volume_usd_in: Optional[List[Any]] = Field(alias="volumeUsd_in", default=None) + volume_usd_not_in: Optional[List[Any]] = Field( + alias="volumeUsd_not_in", default=None + ) + volume_eth: Optional[Any] = Field(alias="volumeEth", default=None) + volume_eth_not: Optional[Any] = Field(alias="volumeEth_not", default=None) + volume_eth_gt: Optional[Any] = Field(alias="volumeEth_gt", default=None) + volume_eth_lt: Optional[Any] = Field(alias="volumeEth_lt", default=None) + volume_eth_gte: Optional[Any] = Field(alias="volumeEth_gte", default=None) + volume_eth_lte: Optional[Any] = Field(alias="volumeEth_lte", default=None) + volume_eth_in: Optional[List[Any]] = Field(alias="volumeEth_in", default=None) + volume_eth_not_in: Optional[List[Any]] = Field( + alias="volumeEth_not_in", default=None + ) + fees_usd: Optional[Any] = Field(alias="feesUsd", default=None) + fees_usd_not: Optional[Any] = Field(alias="feesUsd_not", default=None) + fees_usd_gt: Optional[Any] = Field(alias="feesUsd_gt", default=None) + fees_usd_lt: Optional[Any] = Field(alias="feesUsd_lt", default=None) + fees_usd_gte: Optional[Any] = Field(alias="feesUsd_gte", default=None) + fees_usd_lte: Optional[Any] = Field(alias="feesUsd_lte", default=None) + fees_usd_in: Optional[List[Any]] = Field(alias="feesUsd_in", default=None) + fees_usd_not_in: Optional[List[Any]] = Field(alias="feesUsd_not_in", default=None) + fees_eth: Optional[Any] = Field(alias="feesEth", default=None) + fees_eth_not: Optional[Any] = Field(alias="feesEth_not", default=None) + fees_eth_gt: Optional[Any] = Field(alias="feesEth_gt", default=None) + fees_eth_lt: Optional[Any] = Field(alias="feesEth_lt", default=None) + fees_eth_gte: Optional[Any] = Field(alias="feesEth_gte", default=None) + fees_eth_lte: Optional[Any] = Field(alias="feesEth_lte", default=None) + fees_eth_in: Optional[List[Any]] = Field(alias="feesEth_in", default=None) + fees_eth_not_in: Optional[List[Any]] = Field(alias="feesEth_not_in", default=None) + tokens: Optional[List[str]] = None + tokens_not: Optional[List[str]] = None + tokens_contains: Optional[List[str]] = None + tokens_contains_nocase: Optional[List[str]] = None + tokens_not_contains: Optional[List[str]] = None + tokens_not_contains_nocase: Optional[List[str]] = None + tokens: Optional["Token_filter"] = Field(alias="tokens_", default=None) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["HourlyTotal_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["HourlyTotal_filter"]]] = Field( + alias="or", default=None + ) + + +class Order_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + owner: Optional[str] = None + owner_not: Optional[str] = None + owner_gt: Optional[str] = None + owner_lt: Optional[str] = None + owner_gte: Optional[str] = None + owner_lte: Optional[str] = None + owner_in: Optional[List[str]] = None + owner_not_in: Optional[List[str]] = None + owner_contains: Optional[str] = None + owner_contains_nocase: Optional[str] = None + owner_not_contains: Optional[str] = None + owner_not_contains_nocase: Optional[str] = None + owner_starts_with: Optional[str] = None + owner_starts_with_nocase: Optional[str] = None + owner_not_starts_with: Optional[str] = None + owner_not_starts_with_nocase: Optional[str] = None + owner_ends_with: Optional[str] = None + owner_ends_with_nocase: Optional[str] = None + owner_not_ends_with: Optional[str] = None + owner_not_ends_with_nocase: Optional[str] = None + owner: Optional["User_filter"] = Field(alias="owner_", default=None) + trades_timestamp: Optional[int] = Field(alias="tradesTimestamp", default=None) + trades_timestamp_not: Optional[int] = Field( + alias="tradesTimestamp_not", default=None + ) + trades_timestamp_gt: Optional[int] = Field(alias="tradesTimestamp_gt", default=None) + trades_timestamp_lt: Optional[int] = Field(alias="tradesTimestamp_lt", default=None) + trades_timestamp_gte: Optional[int] = Field( + alias="tradesTimestamp_gte", default=None + ) + trades_timestamp_lte: Optional[int] = Field( + alias="tradesTimestamp_lte", default=None + ) + trades_timestamp_in: Optional[List[int]] = Field( + alias="tradesTimestamp_in", default=None + ) + trades_timestamp_not_in: Optional[List[int]] = Field( + alias="tradesTimestamp_not_in", default=None + ) + invalidate_timestamp: Optional[int] = Field( + alias="invalidateTimestamp", default=None + ) + invalidate_timestamp_not: Optional[int] = Field( + alias="invalidateTimestamp_not", default=None + ) + invalidate_timestamp_gt: Optional[int] = Field( + alias="invalidateTimestamp_gt", default=None + ) + invalidate_timestamp_lt: Optional[int] = Field( + alias="invalidateTimestamp_lt", default=None + ) + invalidate_timestamp_gte: Optional[int] = Field( + alias="invalidateTimestamp_gte", default=None + ) + invalidate_timestamp_lte: Optional[int] = Field( + alias="invalidateTimestamp_lte", default=None + ) + invalidate_timestamp_in: Optional[List[int]] = Field( + alias="invalidateTimestamp_in", default=None + ) + invalidate_timestamp_not_in: Optional[List[int]] = Field( + alias="invalidateTimestamp_not_in", default=None + ) + presign_timestamp: Optional[int] = Field(alias="presignTimestamp", default=None) + presign_timestamp_not: Optional[int] = Field( + alias="presignTimestamp_not", default=None + ) + presign_timestamp_gt: Optional[int] = Field( + alias="presignTimestamp_gt", default=None + ) + presign_timestamp_lt: Optional[int] = Field( + alias="presignTimestamp_lt", default=None + ) + presign_timestamp_gte: Optional[int] = Field( + alias="presignTimestamp_gte", default=None + ) + presign_timestamp_lte: Optional[int] = Field( + alias="presignTimestamp_lte", default=None + ) + presign_timestamp_in: Optional[List[int]] = Field( + alias="presignTimestamp_in", default=None + ) + presign_timestamp_not_in: Optional[List[int]] = Field( + alias="presignTimestamp_not_in", default=None + ) + trades: Optional["Trade_filter"] = Field(alias="trades_", default=None) + is_signed: Optional[bool] = Field(alias="isSigned", default=None) + is_signed_not: Optional[bool] = Field(alias="isSigned_not", default=None) + is_signed_in: Optional[List[bool]] = Field(alias="isSigned_in", default=None) + is_signed_not_in: Optional[List[bool]] = Field( + alias="isSigned_not_in", default=None + ) + is_valid: Optional[bool] = Field(alias="isValid", default=None) + is_valid_not: Optional[bool] = Field(alias="isValid_not", default=None) + is_valid_in: Optional[List[bool]] = Field(alias="isValid_in", default=None) + is_valid_not_in: Optional[List[bool]] = Field(alias="isValid_not_in", default=None) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Order_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["Order_filter"]]] = Field(alias="or", default=None) + + +class PairDaily_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token_0: Optional[str] = Field(alias="token0", default=None) + token_0_not: Optional[str] = Field(alias="token0_not", default=None) + token_0_gt: Optional[str] = Field(alias="token0_gt", default=None) + token_0_lt: Optional[str] = Field(alias="token0_lt", default=None) + token_0_gte: Optional[str] = Field(alias="token0_gte", default=None) + token_0_lte: Optional[str] = Field(alias="token0_lte", default=None) + token_0_in: Optional[List[str]] = Field(alias="token0_in", default=None) + token_0_not_in: Optional[List[str]] = Field(alias="token0_not_in", default=None) + token_0_contains: Optional[str] = Field(alias="token0_contains", default=None) + token_0_contains_nocase: Optional[str] = Field( + alias="token0_contains_nocase", default=None + ) + token_0_not_contains: Optional[str] = Field( + alias="token0_not_contains", default=None + ) + token_0_not_contains_nocase: Optional[str] = Field( + alias="token0_not_contains_nocase", default=None + ) + token_0_starts_with: Optional[str] = Field(alias="token0_starts_with", default=None) + token_0_starts_with_nocase: Optional[str] = Field( + alias="token0_starts_with_nocase", default=None + ) + token_0_not_starts_with: Optional[str] = Field( + alias="token0_not_starts_with", default=None + ) + token_0_not_starts_with_nocase: Optional[str] = Field( + alias="token0_not_starts_with_nocase", default=None + ) + token_0_ends_with: Optional[str] = Field(alias="token0_ends_with", default=None) + token_0_ends_with_nocase: Optional[str] = Field( + alias="token0_ends_with_nocase", default=None + ) + token_0_not_ends_with: Optional[str] = Field( + alias="token0_not_ends_with", default=None + ) + token_0_not_ends_with_nocase: Optional[str] = Field( + alias="token0_not_ends_with_nocase", default=None + ) + token_0: Optional["Token_filter"] = Field(alias="token0_", default=None) + token_1: Optional[str] = Field(alias="token1", default=None) + token_1_not: Optional[str] = Field(alias="token1_not", default=None) + token_1_gt: Optional[str] = Field(alias="token1_gt", default=None) + token_1_lt: Optional[str] = Field(alias="token1_lt", default=None) + token_1_gte: Optional[str] = Field(alias="token1_gte", default=None) + token_1_lte: Optional[str] = Field(alias="token1_lte", default=None) + token_1_in: Optional[List[str]] = Field(alias="token1_in", default=None) + token_1_not_in: Optional[List[str]] = Field(alias="token1_not_in", default=None) + token_1_contains: Optional[str] = Field(alias="token1_contains", default=None) + token_1_contains_nocase: Optional[str] = Field( + alias="token1_contains_nocase", default=None + ) + token_1_not_contains: Optional[str] = Field( + alias="token1_not_contains", default=None + ) + token_1_not_contains_nocase: Optional[str] = Field( + alias="token1_not_contains_nocase", default=None + ) + token_1_starts_with: Optional[str] = Field(alias="token1_starts_with", default=None) + token_1_starts_with_nocase: Optional[str] = Field( + alias="token1_starts_with_nocase", default=None + ) + token_1_not_starts_with: Optional[str] = Field( + alias="token1_not_starts_with", default=None + ) + token_1_not_starts_with_nocase: Optional[str] = Field( + alias="token1_not_starts_with_nocase", default=None + ) + token_1_ends_with: Optional[str] = Field(alias="token1_ends_with", default=None) + token_1_ends_with_nocase: Optional[str] = Field( + alias="token1_ends_with_nocase", default=None + ) + token_1_not_ends_with: Optional[str] = Field( + alias="token1_not_ends_with", default=None + ) + token_1_not_ends_with_nocase: Optional[str] = Field( + alias="token1_not_ends_with_nocase", default=None + ) + token_1: Optional["Token_filter"] = Field(alias="token1_", default=None) + token_0_price: Optional[Any] = Field(alias="token0Price", default=None) + token_0_price_not: Optional[Any] = Field(alias="token0Price_not", default=None) + token_0_price_gt: Optional[Any] = Field(alias="token0Price_gt", default=None) + token_0_price_lt: Optional[Any] = Field(alias="token0Price_lt", default=None) + token_0_price_gte: Optional[Any] = Field(alias="token0Price_gte", default=None) + token_0_price_lte: Optional[Any] = Field(alias="token0Price_lte", default=None) + token_0_price_in: Optional[List[Any]] = Field(alias="token0Price_in", default=None) + token_0_price_not_in: Optional[List[Any]] = Field( + alias="token0Price_not_in", default=None + ) + token_1_price: Optional[Any] = Field(alias="token1Price", default=None) + token_1_price_not: Optional[Any] = Field(alias="token1Price_not", default=None) + token_1_price_gt: Optional[Any] = Field(alias="token1Price_gt", default=None) + token_1_price_lt: Optional[Any] = Field(alias="token1Price_lt", default=None) + token_1_price_gte: Optional[Any] = Field(alias="token1Price_gte", default=None) + token_1_price_lte: Optional[Any] = Field(alias="token1Price_lte", default=None) + token_1_price_in: Optional[List[Any]] = Field(alias="token1Price_in", default=None) + token_1_price_not_in: Optional[List[Any]] = Field( + alias="token1Price_not_in", default=None + ) + token_0_relative_price: Optional[Any] = Field( + alias="token0relativePrice", default=None + ) + token_0_relative_price_not: Optional[Any] = Field( + alias="token0relativePrice_not", default=None + ) + token_0_relative_price_gt: Optional[Any] = Field( + alias="token0relativePrice_gt", default=None + ) + token_0_relative_price_lt: Optional[Any] = Field( + alias="token0relativePrice_lt", default=None + ) + token_0_relative_price_gte: Optional[Any] = Field( + alias="token0relativePrice_gte", default=None + ) + token_0_relative_price_lte: Optional[Any] = Field( + alias="token0relativePrice_lte", default=None + ) + token_0_relative_price_in: Optional[List[Any]] = Field( + alias="token0relativePrice_in", default=None + ) + token_0_relative_price_not_in: Optional[List[Any]] = Field( + alias="token0relativePrice_not_in", default=None + ) + token_1_relative_price: Optional[Any] = Field( + alias="token1relativePrice", default=None + ) + token_1_relative_price_not: Optional[Any] = Field( + alias="token1relativePrice_not", default=None + ) + token_1_relative_price_gt: Optional[Any] = Field( + alias="token1relativePrice_gt", default=None + ) + token_1_relative_price_lt: Optional[Any] = Field( + alias="token1relativePrice_lt", default=None + ) + token_1_relative_price_gte: Optional[Any] = Field( + alias="token1relativePrice_gte", default=None + ) + token_1_relative_price_lte: Optional[Any] = Field( + alias="token1relativePrice_lte", default=None + ) + token_1_relative_price_in: Optional[List[Any]] = Field( + alias="token1relativePrice_in", default=None + ) + token_1_relative_price_not_in: Optional[List[Any]] = Field( + alias="token1relativePrice_not_in", default=None + ) + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + volume_token_0: Optional[Any] = Field(alias="volumeToken0", default=None) + volume_token_0_not: Optional[Any] = Field(alias="volumeToken0_not", default=None) + volume_token_0_gt: Optional[Any] = Field(alias="volumeToken0_gt", default=None) + volume_token_0_lt: Optional[Any] = Field(alias="volumeToken0_lt", default=None) + volume_token_0_gte: Optional[Any] = Field(alias="volumeToken0_gte", default=None) + volume_token_0_lte: Optional[Any] = Field(alias="volumeToken0_lte", default=None) + volume_token_0_in: Optional[List[Any]] = Field( + alias="volumeToken0_in", default=None + ) + volume_token_0_not_in: Optional[List[Any]] = Field( + alias="volumeToken0_not_in", default=None + ) + volume_token_1: Optional[Any] = Field(alias="volumeToken1", default=None) + volume_token_1_not: Optional[Any] = Field(alias="volumeToken1_not", default=None) + volume_token_1_gt: Optional[Any] = Field(alias="volumeToken1_gt", default=None) + volume_token_1_lt: Optional[Any] = Field(alias="volumeToken1_lt", default=None) + volume_token_1_gte: Optional[Any] = Field(alias="volumeToken1_gte", default=None) + volume_token_1_lte: Optional[Any] = Field(alias="volumeToken1_lte", default=None) + volume_token_1_in: Optional[List[Any]] = Field( + alias="volumeToken1_in", default=None + ) + volume_token_1_not_in: Optional[List[Any]] = Field( + alias="volumeToken1_not_in", default=None + ) + volume_traded_eth: Optional[Any] = Field(alias="volumeTradedEth", default=None) + volume_traded_eth_not: Optional[Any] = Field( + alias="volumeTradedEth_not", default=None + ) + volume_traded_eth_gt: Optional[Any] = Field( + alias="volumeTradedEth_gt", default=None + ) + volume_traded_eth_lt: Optional[Any] = Field( + alias="volumeTradedEth_lt", default=None + ) + volume_traded_eth_gte: Optional[Any] = Field( + alias="volumeTradedEth_gte", default=None + ) + volume_traded_eth_lte: Optional[Any] = Field( + alias="volumeTradedEth_lte", default=None + ) + volume_traded_eth_in: Optional[List[Any]] = Field( + alias="volumeTradedEth_in", default=None + ) + volume_traded_eth_not_in: Optional[List[Any]] = Field( + alias="volumeTradedEth_not_in", default=None + ) + volume_traded_usd: Optional[Any] = Field(alias="volumeTradedUsd", default=None) + volume_traded_usd_not: Optional[Any] = Field( + alias="volumeTradedUsd_not", default=None + ) + volume_traded_usd_gt: Optional[Any] = Field( + alias="volumeTradedUsd_gt", default=None + ) + volume_traded_usd_lt: Optional[Any] = Field( + alias="volumeTradedUsd_lt", default=None + ) + volume_traded_usd_gte: Optional[Any] = Field( + alias="volumeTradedUsd_gte", default=None + ) + volume_traded_usd_lte: Optional[Any] = Field( + alias="volumeTradedUsd_lte", default=None + ) + volume_traded_usd_in: Optional[List[Any]] = Field( + alias="volumeTradedUsd_in", default=None + ) + volume_traded_usd_not_in: Optional[List[Any]] = Field( + alias="volumeTradedUsd_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["PairDaily_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["PairDaily_filter"]]] = Field(alias="or", default=None) + + +class PairHourly_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token_0: Optional[str] = Field(alias="token0", default=None) + token_0_not: Optional[str] = Field(alias="token0_not", default=None) + token_0_gt: Optional[str] = Field(alias="token0_gt", default=None) + token_0_lt: Optional[str] = Field(alias="token0_lt", default=None) + token_0_gte: Optional[str] = Field(alias="token0_gte", default=None) + token_0_lte: Optional[str] = Field(alias="token0_lte", default=None) + token_0_in: Optional[List[str]] = Field(alias="token0_in", default=None) + token_0_not_in: Optional[List[str]] = Field(alias="token0_not_in", default=None) + token_0_contains: Optional[str] = Field(alias="token0_contains", default=None) + token_0_contains_nocase: Optional[str] = Field( + alias="token0_contains_nocase", default=None + ) + token_0_not_contains: Optional[str] = Field( + alias="token0_not_contains", default=None + ) + token_0_not_contains_nocase: Optional[str] = Field( + alias="token0_not_contains_nocase", default=None + ) + token_0_starts_with: Optional[str] = Field(alias="token0_starts_with", default=None) + token_0_starts_with_nocase: Optional[str] = Field( + alias="token0_starts_with_nocase", default=None + ) + token_0_not_starts_with: Optional[str] = Field( + alias="token0_not_starts_with", default=None + ) + token_0_not_starts_with_nocase: Optional[str] = Field( + alias="token0_not_starts_with_nocase", default=None + ) + token_0_ends_with: Optional[str] = Field(alias="token0_ends_with", default=None) + token_0_ends_with_nocase: Optional[str] = Field( + alias="token0_ends_with_nocase", default=None + ) + token_0_not_ends_with: Optional[str] = Field( + alias="token0_not_ends_with", default=None + ) + token_0_not_ends_with_nocase: Optional[str] = Field( + alias="token0_not_ends_with_nocase", default=None + ) + token_0: Optional["Token_filter"] = Field(alias="token0_", default=None) + token_1: Optional[str] = Field(alias="token1", default=None) + token_1_not: Optional[str] = Field(alias="token1_not", default=None) + token_1_gt: Optional[str] = Field(alias="token1_gt", default=None) + token_1_lt: Optional[str] = Field(alias="token1_lt", default=None) + token_1_gte: Optional[str] = Field(alias="token1_gte", default=None) + token_1_lte: Optional[str] = Field(alias="token1_lte", default=None) + token_1_in: Optional[List[str]] = Field(alias="token1_in", default=None) + token_1_not_in: Optional[List[str]] = Field(alias="token1_not_in", default=None) + token_1_contains: Optional[str] = Field(alias="token1_contains", default=None) + token_1_contains_nocase: Optional[str] = Field( + alias="token1_contains_nocase", default=None + ) + token_1_not_contains: Optional[str] = Field( + alias="token1_not_contains", default=None + ) + token_1_not_contains_nocase: Optional[str] = Field( + alias="token1_not_contains_nocase", default=None + ) + token_1_starts_with: Optional[str] = Field(alias="token1_starts_with", default=None) + token_1_starts_with_nocase: Optional[str] = Field( + alias="token1_starts_with_nocase", default=None + ) + token_1_not_starts_with: Optional[str] = Field( + alias="token1_not_starts_with", default=None + ) + token_1_not_starts_with_nocase: Optional[str] = Field( + alias="token1_not_starts_with_nocase", default=None + ) + token_1_ends_with: Optional[str] = Field(alias="token1_ends_with", default=None) + token_1_ends_with_nocase: Optional[str] = Field( + alias="token1_ends_with_nocase", default=None + ) + token_1_not_ends_with: Optional[str] = Field( + alias="token1_not_ends_with", default=None + ) + token_1_not_ends_with_nocase: Optional[str] = Field( + alias="token1_not_ends_with_nocase", default=None + ) + token_1: Optional["Token_filter"] = Field(alias="token1_", default=None) + token_0_price: Optional[Any] = Field(alias="token0Price", default=None) + token_0_price_not: Optional[Any] = Field(alias="token0Price_not", default=None) + token_0_price_gt: Optional[Any] = Field(alias="token0Price_gt", default=None) + token_0_price_lt: Optional[Any] = Field(alias="token0Price_lt", default=None) + token_0_price_gte: Optional[Any] = Field(alias="token0Price_gte", default=None) + token_0_price_lte: Optional[Any] = Field(alias="token0Price_lte", default=None) + token_0_price_in: Optional[List[Any]] = Field(alias="token0Price_in", default=None) + token_0_price_not_in: Optional[List[Any]] = Field( + alias="token0Price_not_in", default=None + ) + token_1_price: Optional[Any] = Field(alias="token1Price", default=None) + token_1_price_not: Optional[Any] = Field(alias="token1Price_not", default=None) + token_1_price_gt: Optional[Any] = Field(alias="token1Price_gt", default=None) + token_1_price_lt: Optional[Any] = Field(alias="token1Price_lt", default=None) + token_1_price_gte: Optional[Any] = Field(alias="token1Price_gte", default=None) + token_1_price_lte: Optional[Any] = Field(alias="token1Price_lte", default=None) + token_1_price_in: Optional[List[Any]] = Field(alias="token1Price_in", default=None) + token_1_price_not_in: Optional[List[Any]] = Field( + alias="token1Price_not_in", default=None + ) + token_0_relative_price: Optional[Any] = Field( + alias="token0relativePrice", default=None + ) + token_0_relative_price_not: Optional[Any] = Field( + alias="token0relativePrice_not", default=None + ) + token_0_relative_price_gt: Optional[Any] = Field( + alias="token0relativePrice_gt", default=None + ) + token_0_relative_price_lt: Optional[Any] = Field( + alias="token0relativePrice_lt", default=None + ) + token_0_relative_price_gte: Optional[Any] = Field( + alias="token0relativePrice_gte", default=None + ) + token_0_relative_price_lte: Optional[Any] = Field( + alias="token0relativePrice_lte", default=None + ) + token_0_relative_price_in: Optional[List[Any]] = Field( + alias="token0relativePrice_in", default=None + ) + token_0_relative_price_not_in: Optional[List[Any]] = Field( + alias="token0relativePrice_not_in", default=None + ) + token_1_relative_price: Optional[Any] = Field( + alias="token1relativePrice", default=None + ) + token_1_relative_price_not: Optional[Any] = Field( + alias="token1relativePrice_not", default=None + ) + token_1_relative_price_gt: Optional[Any] = Field( + alias="token1relativePrice_gt", default=None + ) + token_1_relative_price_lt: Optional[Any] = Field( + alias="token1relativePrice_lt", default=None + ) + token_1_relative_price_gte: Optional[Any] = Field( + alias="token1relativePrice_gte", default=None + ) + token_1_relative_price_lte: Optional[Any] = Field( + alias="token1relativePrice_lte", default=None + ) + token_1_relative_price_in: Optional[List[Any]] = Field( + alias="token1relativePrice_in", default=None + ) + token_1_relative_price_not_in: Optional[List[Any]] = Field( + alias="token1relativePrice_not_in", default=None + ) + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + volume_token_0: Optional[Any] = Field(alias="volumeToken0", default=None) + volume_token_0_not: Optional[Any] = Field(alias="volumeToken0_not", default=None) + volume_token_0_gt: Optional[Any] = Field(alias="volumeToken0_gt", default=None) + volume_token_0_lt: Optional[Any] = Field(alias="volumeToken0_lt", default=None) + volume_token_0_gte: Optional[Any] = Field(alias="volumeToken0_gte", default=None) + volume_token_0_lte: Optional[Any] = Field(alias="volumeToken0_lte", default=None) + volume_token_0_in: Optional[List[Any]] = Field( + alias="volumeToken0_in", default=None + ) + volume_token_0_not_in: Optional[List[Any]] = Field( + alias="volumeToken0_not_in", default=None + ) + volume_token_1: Optional[Any] = Field(alias="volumeToken1", default=None) + volume_token_1_not: Optional[Any] = Field(alias="volumeToken1_not", default=None) + volume_token_1_gt: Optional[Any] = Field(alias="volumeToken1_gt", default=None) + volume_token_1_lt: Optional[Any] = Field(alias="volumeToken1_lt", default=None) + volume_token_1_gte: Optional[Any] = Field(alias="volumeToken1_gte", default=None) + volume_token_1_lte: Optional[Any] = Field(alias="volumeToken1_lte", default=None) + volume_token_1_in: Optional[List[Any]] = Field( + alias="volumeToken1_in", default=None + ) + volume_token_1_not_in: Optional[List[Any]] = Field( + alias="volumeToken1_not_in", default=None + ) + volume_traded_eth: Optional[Any] = Field(alias="volumeTradedEth", default=None) + volume_traded_eth_not: Optional[Any] = Field( + alias="volumeTradedEth_not", default=None + ) + volume_traded_eth_gt: Optional[Any] = Field( + alias="volumeTradedEth_gt", default=None + ) + volume_traded_eth_lt: Optional[Any] = Field( + alias="volumeTradedEth_lt", default=None + ) + volume_traded_eth_gte: Optional[Any] = Field( + alias="volumeTradedEth_gte", default=None + ) + volume_traded_eth_lte: Optional[Any] = Field( + alias="volumeTradedEth_lte", default=None + ) + volume_traded_eth_in: Optional[List[Any]] = Field( + alias="volumeTradedEth_in", default=None + ) + volume_traded_eth_not_in: Optional[List[Any]] = Field( + alias="volumeTradedEth_not_in", default=None + ) + volume_traded_usd: Optional[Any] = Field(alias="volumeTradedUsd", default=None) + volume_traded_usd_not: Optional[Any] = Field( + alias="volumeTradedUsd_not", default=None + ) + volume_traded_usd_gt: Optional[Any] = Field( + alias="volumeTradedUsd_gt", default=None + ) + volume_traded_usd_lt: Optional[Any] = Field( + alias="volumeTradedUsd_lt", default=None + ) + volume_traded_usd_gte: Optional[Any] = Field( + alias="volumeTradedUsd_gte", default=None + ) + volume_traded_usd_lte: Optional[Any] = Field( + alias="volumeTradedUsd_lte", default=None + ) + volume_traded_usd_in: Optional[List[Any]] = Field( + alias="volumeTradedUsd_in", default=None + ) + volume_traded_usd_not_in: Optional[List[Any]] = Field( + alias="volumeTradedUsd_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["PairHourly_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["PairHourly_filter"]]] = Field(alias="or", default=None) + + +class Pair_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token_0: Optional[str] = Field(alias="token0", default=None) + token_0_not: Optional[str] = Field(alias="token0_not", default=None) + token_0_gt: Optional[str] = Field(alias="token0_gt", default=None) + token_0_lt: Optional[str] = Field(alias="token0_lt", default=None) + token_0_gte: Optional[str] = Field(alias="token0_gte", default=None) + token_0_lte: Optional[str] = Field(alias="token0_lte", default=None) + token_0_in: Optional[List[str]] = Field(alias="token0_in", default=None) + token_0_not_in: Optional[List[str]] = Field(alias="token0_not_in", default=None) + token_0_contains: Optional[str] = Field(alias="token0_contains", default=None) + token_0_contains_nocase: Optional[str] = Field( + alias="token0_contains_nocase", default=None + ) + token_0_not_contains: Optional[str] = Field( + alias="token0_not_contains", default=None + ) + token_0_not_contains_nocase: Optional[str] = Field( + alias="token0_not_contains_nocase", default=None + ) + token_0_starts_with: Optional[str] = Field(alias="token0_starts_with", default=None) + token_0_starts_with_nocase: Optional[str] = Field( + alias="token0_starts_with_nocase", default=None + ) + token_0_not_starts_with: Optional[str] = Field( + alias="token0_not_starts_with", default=None + ) + token_0_not_starts_with_nocase: Optional[str] = Field( + alias="token0_not_starts_with_nocase", default=None + ) + token_0_ends_with: Optional[str] = Field(alias="token0_ends_with", default=None) + token_0_ends_with_nocase: Optional[str] = Field( + alias="token0_ends_with_nocase", default=None + ) + token_0_not_ends_with: Optional[str] = Field( + alias="token0_not_ends_with", default=None + ) + token_0_not_ends_with_nocase: Optional[str] = Field( + alias="token0_not_ends_with_nocase", default=None + ) + token_0: Optional["Token_filter"] = Field(alias="token0_", default=None) + token_1: Optional[str] = Field(alias="token1", default=None) + token_1_not: Optional[str] = Field(alias="token1_not", default=None) + token_1_gt: Optional[str] = Field(alias="token1_gt", default=None) + token_1_lt: Optional[str] = Field(alias="token1_lt", default=None) + token_1_gte: Optional[str] = Field(alias="token1_gte", default=None) + token_1_lte: Optional[str] = Field(alias="token1_lte", default=None) + token_1_in: Optional[List[str]] = Field(alias="token1_in", default=None) + token_1_not_in: Optional[List[str]] = Field(alias="token1_not_in", default=None) + token_1_contains: Optional[str] = Field(alias="token1_contains", default=None) + token_1_contains_nocase: Optional[str] = Field( + alias="token1_contains_nocase", default=None + ) + token_1_not_contains: Optional[str] = Field( + alias="token1_not_contains", default=None + ) + token_1_not_contains_nocase: Optional[str] = Field( + alias="token1_not_contains_nocase", default=None + ) + token_1_starts_with: Optional[str] = Field(alias="token1_starts_with", default=None) + token_1_starts_with_nocase: Optional[str] = Field( + alias="token1_starts_with_nocase", default=None + ) + token_1_not_starts_with: Optional[str] = Field( + alias="token1_not_starts_with", default=None + ) + token_1_not_starts_with_nocase: Optional[str] = Field( + alias="token1_not_starts_with_nocase", default=None + ) + token_1_ends_with: Optional[str] = Field(alias="token1_ends_with", default=None) + token_1_ends_with_nocase: Optional[str] = Field( + alias="token1_ends_with_nocase", default=None + ) + token_1_not_ends_with: Optional[str] = Field( + alias="token1_not_ends_with", default=None + ) + token_1_not_ends_with_nocase: Optional[str] = Field( + alias="token1_not_ends_with_nocase", default=None + ) + token_1: Optional["Token_filter"] = Field(alias="token1_", default=None) + token_0_price: Optional[Any] = Field(alias="token0Price", default=None) + token_0_price_not: Optional[Any] = Field(alias="token0Price_not", default=None) + token_0_price_gt: Optional[Any] = Field(alias="token0Price_gt", default=None) + token_0_price_lt: Optional[Any] = Field(alias="token0Price_lt", default=None) + token_0_price_gte: Optional[Any] = Field(alias="token0Price_gte", default=None) + token_0_price_lte: Optional[Any] = Field(alias="token0Price_lte", default=None) + token_0_price_in: Optional[List[Any]] = Field(alias="token0Price_in", default=None) + token_0_price_not_in: Optional[List[Any]] = Field( + alias="token0Price_not_in", default=None + ) + token_1_price: Optional[Any] = Field(alias="token1Price", default=None) + token_1_price_not: Optional[Any] = Field(alias="token1Price_not", default=None) + token_1_price_gt: Optional[Any] = Field(alias="token1Price_gt", default=None) + token_1_price_lt: Optional[Any] = Field(alias="token1Price_lt", default=None) + token_1_price_gte: Optional[Any] = Field(alias="token1Price_gte", default=None) + token_1_price_lte: Optional[Any] = Field(alias="token1Price_lte", default=None) + token_1_price_in: Optional[List[Any]] = Field(alias="token1Price_in", default=None) + token_1_price_not_in: Optional[List[Any]] = Field( + alias="token1Price_not_in", default=None + ) + token_0_relative_price: Optional[Any] = Field( + alias="token0relativePrice", default=None + ) + token_0_relative_price_not: Optional[Any] = Field( + alias="token0relativePrice_not", default=None + ) + token_0_relative_price_gt: Optional[Any] = Field( + alias="token0relativePrice_gt", default=None + ) + token_0_relative_price_lt: Optional[Any] = Field( + alias="token0relativePrice_lt", default=None + ) + token_0_relative_price_gte: Optional[Any] = Field( + alias="token0relativePrice_gte", default=None + ) + token_0_relative_price_lte: Optional[Any] = Field( + alias="token0relativePrice_lte", default=None + ) + token_0_relative_price_in: Optional[List[Any]] = Field( + alias="token0relativePrice_in", default=None + ) + token_0_relative_price_not_in: Optional[List[Any]] = Field( + alias="token0relativePrice_not_in", default=None + ) + token_1_relative_price: Optional[Any] = Field( + alias="token1relativePrice", default=None + ) + token_1_relative_price_not: Optional[Any] = Field( + alias="token1relativePrice_not", default=None + ) + token_1_relative_price_gt: Optional[Any] = Field( + alias="token1relativePrice_gt", default=None + ) + token_1_relative_price_lt: Optional[Any] = Field( + alias="token1relativePrice_lt", default=None + ) + token_1_relative_price_gte: Optional[Any] = Field( + alias="token1relativePrice_gte", default=None + ) + token_1_relative_price_lte: Optional[Any] = Field( + alias="token1relativePrice_lte", default=None + ) + token_1_relative_price_in: Optional[List[Any]] = Field( + alias="token1relativePrice_in", default=None + ) + token_1_relative_price_not_in: Optional[List[Any]] = Field( + alias="token1relativePrice_not_in", default=None + ) + volume_token_0: Optional[Any] = Field(alias="volumeToken0", default=None) + volume_token_0_not: Optional[Any] = Field(alias="volumeToken0_not", default=None) + volume_token_0_gt: Optional[Any] = Field(alias="volumeToken0_gt", default=None) + volume_token_0_lt: Optional[Any] = Field(alias="volumeToken0_lt", default=None) + volume_token_0_gte: Optional[Any] = Field(alias="volumeToken0_gte", default=None) + volume_token_0_lte: Optional[Any] = Field(alias="volumeToken0_lte", default=None) + volume_token_0_in: Optional[List[Any]] = Field( + alias="volumeToken0_in", default=None + ) + volume_token_0_not_in: Optional[List[Any]] = Field( + alias="volumeToken0_not_in", default=None + ) + volume_token_1: Optional[Any] = Field(alias="volumeToken1", default=None) + volume_token_1_not: Optional[Any] = Field(alias="volumeToken1_not", default=None) + volume_token_1_gt: Optional[Any] = Field(alias="volumeToken1_gt", default=None) + volume_token_1_lt: Optional[Any] = Field(alias="volumeToken1_lt", default=None) + volume_token_1_gte: Optional[Any] = Field(alias="volumeToken1_gte", default=None) + volume_token_1_lte: Optional[Any] = Field(alias="volumeToken1_lte", default=None) + volume_token_1_in: Optional[List[Any]] = Field( + alias="volumeToken1_in", default=None + ) + volume_token_1_not_in: Optional[List[Any]] = Field( + alias="volumeToken1_not_in", default=None + ) + volume_traded_eth: Optional[Any] = Field(alias="volumeTradedEth", default=None) + volume_traded_eth_not: Optional[Any] = Field( + alias="volumeTradedEth_not", default=None + ) + volume_traded_eth_gt: Optional[Any] = Field( + alias="volumeTradedEth_gt", default=None + ) + volume_traded_eth_lt: Optional[Any] = Field( + alias="volumeTradedEth_lt", default=None + ) + volume_traded_eth_gte: Optional[Any] = Field( + alias="volumeTradedEth_gte", default=None + ) + volume_traded_eth_lte: Optional[Any] = Field( + alias="volumeTradedEth_lte", default=None + ) + volume_traded_eth_in: Optional[List[Any]] = Field( + alias="volumeTradedEth_in", default=None + ) + volume_traded_eth_not_in: Optional[List[Any]] = Field( + alias="volumeTradedEth_not_in", default=None + ) + volume_traded_usd: Optional[Any] = Field(alias="volumeTradedUsd", default=None) + volume_traded_usd_not: Optional[Any] = Field( + alias="volumeTradedUsd_not", default=None + ) + volume_traded_usd_gt: Optional[Any] = Field( + alias="volumeTradedUsd_gt", default=None + ) + volume_traded_usd_lt: Optional[Any] = Field( + alias="volumeTradedUsd_lt", default=None + ) + volume_traded_usd_gte: Optional[Any] = Field( + alias="volumeTradedUsd_gte", default=None + ) + volume_traded_usd_lte: Optional[Any] = Field( + alias="volumeTradedUsd_lte", default=None + ) + volume_traded_usd_in: Optional[List[Any]] = Field( + alias="volumeTradedUsd_in", default=None + ) + volume_traded_usd_not_in: Optional[List[Any]] = Field( + alias="volumeTradedUsd_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Pair_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["Pair_filter"]]] = Field(alias="or", default=None) + + +class Settlement_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + tx_hash: Optional[Any] = Field(alias="txHash", default=None) + tx_hash_not: Optional[Any] = Field(alias="txHash_not", default=None) + tx_hash_gt: Optional[Any] = Field(alias="txHash_gt", default=None) + tx_hash_lt: Optional[Any] = Field(alias="txHash_lt", default=None) + tx_hash_gte: Optional[Any] = Field(alias="txHash_gte", default=None) + tx_hash_lte: Optional[Any] = Field(alias="txHash_lte", default=None) + tx_hash_in: Optional[List[Any]] = Field(alias="txHash_in", default=None) + tx_hash_not_in: Optional[List[Any]] = Field(alias="txHash_not_in", default=None) + tx_hash_contains: Optional[Any] = Field(alias="txHash_contains", default=None) + tx_hash_not_contains: Optional[Any] = Field( + alias="txHash_not_contains", default=None + ) + first_trade_timestamp: Optional[int] = Field( + alias="firstTradeTimestamp", default=None + ) + first_trade_timestamp_not: Optional[int] = Field( + alias="firstTradeTimestamp_not", default=None + ) + first_trade_timestamp_gt: Optional[int] = Field( + alias="firstTradeTimestamp_gt", default=None + ) + first_trade_timestamp_lt: Optional[int] = Field( + alias="firstTradeTimestamp_lt", default=None + ) + first_trade_timestamp_gte: Optional[int] = Field( + alias="firstTradeTimestamp_gte", default=None + ) + first_trade_timestamp_lte: Optional[int] = Field( + alias="firstTradeTimestamp_lte", default=None + ) + first_trade_timestamp_in: Optional[List[int]] = Field( + alias="firstTradeTimestamp_in", default=None + ) + first_trade_timestamp_not_in: Optional[List[int]] = Field( + alias="firstTradeTimestamp_not_in", default=None + ) + trades: Optional["Trade_filter"] = Field(alias="trades_", default=None) + solver: Optional[str] = None + solver_not: Optional[str] = None + solver_gt: Optional[str] = None + solver_lt: Optional[str] = None + solver_gte: Optional[str] = None + solver_lte: Optional[str] = None + solver_in: Optional[List[str]] = None + solver_not_in: Optional[List[str]] = None + solver_contains: Optional[str] = None + solver_contains_nocase: Optional[str] = None + solver_not_contains: Optional[str] = None + solver_not_contains_nocase: Optional[str] = None + solver_starts_with: Optional[str] = None + solver_starts_with_nocase: Optional[str] = None + solver_not_starts_with: Optional[str] = None + solver_not_starts_with_nocase: Optional[str] = None + solver_ends_with: Optional[str] = None + solver_ends_with_nocase: Optional[str] = None + solver_not_ends_with: Optional[str] = None + solver_not_ends_with_nocase: Optional[str] = None + solver: Optional["User_filter"] = Field(alias="solver_", default=None) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Settlement_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["Settlement_filter"]]] = Field(alias="or", default=None) + + +class TokenDailyTotal_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token: Optional[str] = None + token_not: Optional[str] = None + token_gt: Optional[str] = None + token_lt: Optional[str] = None + token_gte: Optional[str] = None + token_lte: Optional[str] = None + token_in: Optional[List[str]] = None + token_not_in: Optional[List[str]] = None + token_contains: Optional[str] = None + token_contains_nocase: Optional[str] = None + token_not_contains: Optional[str] = None + token_not_contains_nocase: Optional[str] = None + token_starts_with: Optional[str] = None + token_starts_with_nocase: Optional[str] = None + token_not_starts_with: Optional[str] = None + token_not_starts_with_nocase: Optional[str] = None + token_ends_with: Optional[str] = None + token_ends_with_nocase: Optional[str] = None + token_not_ends_with: Optional[str] = None + token_not_ends_with_nocase: Optional[str] = None + token: Optional["Token_filter"] = Field(alias="token_", default=None) + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + total_volume: Optional[Any] = Field(alias="totalVolume", default=None) + total_volume_not: Optional[Any] = Field(alias="totalVolume_not", default=None) + total_volume_gt: Optional[Any] = Field(alias="totalVolume_gt", default=None) + total_volume_lt: Optional[Any] = Field(alias="totalVolume_lt", default=None) + total_volume_gte: Optional[Any] = Field(alias="totalVolume_gte", default=None) + total_volume_lte: Optional[Any] = Field(alias="totalVolume_lte", default=None) + total_volume_in: Optional[List[Any]] = Field(alias="totalVolume_in", default=None) + total_volume_not_in: Optional[List[Any]] = Field( + alias="totalVolume_not_in", default=None + ) + total_volume_usd: Optional[Any] = Field(alias="totalVolumeUsd", default=None) + total_volume_usd_not: Optional[Any] = Field( + alias="totalVolumeUsd_not", default=None + ) + total_volume_usd_gt: Optional[Any] = Field(alias="totalVolumeUsd_gt", default=None) + total_volume_usd_lt: Optional[Any] = Field(alias="totalVolumeUsd_lt", default=None) + total_volume_usd_gte: Optional[Any] = Field( + alias="totalVolumeUsd_gte", default=None + ) + total_volume_usd_lte: Optional[Any] = Field( + alias="totalVolumeUsd_lte", default=None + ) + total_volume_usd_in: Optional[List[Any]] = Field( + alias="totalVolumeUsd_in", default=None + ) + total_volume_usd_not_in: Optional[List[Any]] = Field( + alias="totalVolumeUsd_not_in", default=None + ) + total_volume_eth: Optional[Any] = Field(alias="totalVolumeEth", default=None) + total_volume_eth_not: Optional[Any] = Field( + alias="totalVolumeEth_not", default=None + ) + total_volume_eth_gt: Optional[Any] = Field(alias="totalVolumeEth_gt", default=None) + total_volume_eth_lt: Optional[Any] = Field(alias="totalVolumeEth_lt", default=None) + total_volume_eth_gte: Optional[Any] = Field( + alias="totalVolumeEth_gte", default=None + ) + total_volume_eth_lte: Optional[Any] = Field( + alias="totalVolumeEth_lte", default=None + ) + total_volume_eth_in: Optional[List[Any]] = Field( + alias="totalVolumeEth_in", default=None + ) + total_volume_eth_not_in: Optional[List[Any]] = Field( + alias="totalVolumeEth_not_in", default=None + ) + total_trades: Optional[Any] = Field(alias="totalTrades", default=None) + total_trades_not: Optional[Any] = Field(alias="totalTrades_not", default=None) + total_trades_gt: Optional[Any] = Field(alias="totalTrades_gt", default=None) + total_trades_lt: Optional[Any] = Field(alias="totalTrades_lt", default=None) + total_trades_gte: Optional[Any] = Field(alias="totalTrades_gte", default=None) + total_trades_lte: Optional[Any] = Field(alias="totalTrades_lte", default=None) + total_trades_in: Optional[List[Any]] = Field(alias="totalTrades_in", default=None) + total_trades_not_in: Optional[List[Any]] = Field( + alias="totalTrades_not_in", default=None + ) + open_price: Optional[Any] = Field(alias="openPrice", default=None) + open_price_not: Optional[Any] = Field(alias="openPrice_not", default=None) + open_price_gt: Optional[Any] = Field(alias="openPrice_gt", default=None) + open_price_lt: Optional[Any] = Field(alias="openPrice_lt", default=None) + open_price_gte: Optional[Any] = Field(alias="openPrice_gte", default=None) + open_price_lte: Optional[Any] = Field(alias="openPrice_lte", default=None) + open_price_in: Optional[List[Any]] = Field(alias="openPrice_in", default=None) + open_price_not_in: Optional[List[Any]] = Field( + alias="openPrice_not_in", default=None + ) + close_price: Optional[Any] = Field(alias="closePrice", default=None) + close_price_not: Optional[Any] = Field(alias="closePrice_not", default=None) + close_price_gt: Optional[Any] = Field(alias="closePrice_gt", default=None) + close_price_lt: Optional[Any] = Field(alias="closePrice_lt", default=None) + close_price_gte: Optional[Any] = Field(alias="closePrice_gte", default=None) + close_price_lte: Optional[Any] = Field(alias="closePrice_lte", default=None) + close_price_in: Optional[List[Any]] = Field(alias="closePrice_in", default=None) + close_price_not_in: Optional[List[Any]] = Field( + alias="closePrice_not_in", default=None + ) + higher_price: Optional[Any] = Field(alias="higherPrice", default=None) + higher_price_not: Optional[Any] = Field(alias="higherPrice_not", default=None) + higher_price_gt: Optional[Any] = Field(alias="higherPrice_gt", default=None) + higher_price_lt: Optional[Any] = Field(alias="higherPrice_lt", default=None) + higher_price_gte: Optional[Any] = Field(alias="higherPrice_gte", default=None) + higher_price_lte: Optional[Any] = Field(alias="higherPrice_lte", default=None) + higher_price_in: Optional[List[Any]] = Field(alias="higherPrice_in", default=None) + higher_price_not_in: Optional[List[Any]] = Field( + alias="higherPrice_not_in", default=None + ) + lower_price: Optional[Any] = Field(alias="lowerPrice", default=None) + lower_price_not: Optional[Any] = Field(alias="lowerPrice_not", default=None) + lower_price_gt: Optional[Any] = Field(alias="lowerPrice_gt", default=None) + lower_price_lt: Optional[Any] = Field(alias="lowerPrice_lt", default=None) + lower_price_gte: Optional[Any] = Field(alias="lowerPrice_gte", default=None) + lower_price_lte: Optional[Any] = Field(alias="lowerPrice_lte", default=None) + lower_price_in: Optional[List[Any]] = Field(alias="lowerPrice_in", default=None) + lower_price_not_in: Optional[List[Any]] = Field( + alias="lowerPrice_not_in", default=None + ) + average_price: Optional[Any] = Field(alias="averagePrice", default=None) + average_price_not: Optional[Any] = Field(alias="averagePrice_not", default=None) + average_price_gt: Optional[Any] = Field(alias="averagePrice_gt", default=None) + average_price_lt: Optional[Any] = Field(alias="averagePrice_lt", default=None) + average_price_gte: Optional[Any] = Field(alias="averagePrice_gte", default=None) + average_price_lte: Optional[Any] = Field(alias="averagePrice_lte", default=None) + average_price_in: Optional[List[Any]] = Field(alias="averagePrice_in", default=None) + average_price_not_in: Optional[List[Any]] = Field( + alias="averagePrice_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["TokenDailyTotal_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["TokenDailyTotal_filter"]]] = Field( + alias="or", default=None + ) + + +class TokenHourlyTotal_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token: Optional[str] = None + token_not: Optional[str] = None + token_gt: Optional[str] = None + token_lt: Optional[str] = None + token_gte: Optional[str] = None + token_lte: Optional[str] = None + token_in: Optional[List[str]] = None + token_not_in: Optional[List[str]] = None + token_contains: Optional[str] = None + token_contains_nocase: Optional[str] = None + token_not_contains: Optional[str] = None + token_not_contains_nocase: Optional[str] = None + token_starts_with: Optional[str] = None + token_starts_with_nocase: Optional[str] = None + token_not_starts_with: Optional[str] = None + token_not_starts_with_nocase: Optional[str] = None + token_ends_with: Optional[str] = None + token_ends_with_nocase: Optional[str] = None + token_not_ends_with: Optional[str] = None + token_not_ends_with_nocase: Optional[str] = None + token: Optional["Token_filter"] = Field(alias="token_", default=None) + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + total_volume: Optional[Any] = Field(alias="totalVolume", default=None) + total_volume_not: Optional[Any] = Field(alias="totalVolume_not", default=None) + total_volume_gt: Optional[Any] = Field(alias="totalVolume_gt", default=None) + total_volume_lt: Optional[Any] = Field(alias="totalVolume_lt", default=None) + total_volume_gte: Optional[Any] = Field(alias="totalVolume_gte", default=None) + total_volume_lte: Optional[Any] = Field(alias="totalVolume_lte", default=None) + total_volume_in: Optional[List[Any]] = Field(alias="totalVolume_in", default=None) + total_volume_not_in: Optional[List[Any]] = Field( + alias="totalVolume_not_in", default=None + ) + total_volume_usd: Optional[Any] = Field(alias="totalVolumeUsd", default=None) + total_volume_usd_not: Optional[Any] = Field( + alias="totalVolumeUsd_not", default=None + ) + total_volume_usd_gt: Optional[Any] = Field(alias="totalVolumeUsd_gt", default=None) + total_volume_usd_lt: Optional[Any] = Field(alias="totalVolumeUsd_lt", default=None) + total_volume_usd_gte: Optional[Any] = Field( + alias="totalVolumeUsd_gte", default=None + ) + total_volume_usd_lte: Optional[Any] = Field( + alias="totalVolumeUsd_lte", default=None + ) + total_volume_usd_in: Optional[List[Any]] = Field( + alias="totalVolumeUsd_in", default=None + ) + total_volume_usd_not_in: Optional[List[Any]] = Field( + alias="totalVolumeUsd_not_in", default=None + ) + total_volume_eth: Optional[Any] = Field(alias="totalVolumeEth", default=None) + total_volume_eth_not: Optional[Any] = Field( + alias="totalVolumeEth_not", default=None + ) + total_volume_eth_gt: Optional[Any] = Field(alias="totalVolumeEth_gt", default=None) + total_volume_eth_lt: Optional[Any] = Field(alias="totalVolumeEth_lt", default=None) + total_volume_eth_gte: Optional[Any] = Field( + alias="totalVolumeEth_gte", default=None + ) + total_volume_eth_lte: Optional[Any] = Field( + alias="totalVolumeEth_lte", default=None + ) + total_volume_eth_in: Optional[List[Any]] = Field( + alias="totalVolumeEth_in", default=None + ) + total_volume_eth_not_in: Optional[List[Any]] = Field( + alias="totalVolumeEth_not_in", default=None + ) + total_trades: Optional[Any] = Field(alias="totalTrades", default=None) + total_trades_not: Optional[Any] = Field(alias="totalTrades_not", default=None) + total_trades_gt: Optional[Any] = Field(alias="totalTrades_gt", default=None) + total_trades_lt: Optional[Any] = Field(alias="totalTrades_lt", default=None) + total_trades_gte: Optional[Any] = Field(alias="totalTrades_gte", default=None) + total_trades_lte: Optional[Any] = Field(alias="totalTrades_lte", default=None) + total_trades_in: Optional[List[Any]] = Field(alias="totalTrades_in", default=None) + total_trades_not_in: Optional[List[Any]] = Field( + alias="totalTrades_not_in", default=None + ) + open_price: Optional[Any] = Field(alias="openPrice", default=None) + open_price_not: Optional[Any] = Field(alias="openPrice_not", default=None) + open_price_gt: Optional[Any] = Field(alias="openPrice_gt", default=None) + open_price_lt: Optional[Any] = Field(alias="openPrice_lt", default=None) + open_price_gte: Optional[Any] = Field(alias="openPrice_gte", default=None) + open_price_lte: Optional[Any] = Field(alias="openPrice_lte", default=None) + open_price_in: Optional[List[Any]] = Field(alias="openPrice_in", default=None) + open_price_not_in: Optional[List[Any]] = Field( + alias="openPrice_not_in", default=None + ) + close_price: Optional[Any] = Field(alias="closePrice", default=None) + close_price_not: Optional[Any] = Field(alias="closePrice_not", default=None) + close_price_gt: Optional[Any] = Field(alias="closePrice_gt", default=None) + close_price_lt: Optional[Any] = Field(alias="closePrice_lt", default=None) + close_price_gte: Optional[Any] = Field(alias="closePrice_gte", default=None) + close_price_lte: Optional[Any] = Field(alias="closePrice_lte", default=None) + close_price_in: Optional[List[Any]] = Field(alias="closePrice_in", default=None) + close_price_not_in: Optional[List[Any]] = Field( + alias="closePrice_not_in", default=None + ) + higher_price: Optional[Any] = Field(alias="higherPrice", default=None) + higher_price_not: Optional[Any] = Field(alias="higherPrice_not", default=None) + higher_price_gt: Optional[Any] = Field(alias="higherPrice_gt", default=None) + higher_price_lt: Optional[Any] = Field(alias="higherPrice_lt", default=None) + higher_price_gte: Optional[Any] = Field(alias="higherPrice_gte", default=None) + higher_price_lte: Optional[Any] = Field(alias="higherPrice_lte", default=None) + higher_price_in: Optional[List[Any]] = Field(alias="higherPrice_in", default=None) + higher_price_not_in: Optional[List[Any]] = Field( + alias="higherPrice_not_in", default=None + ) + lower_price: Optional[Any] = Field(alias="lowerPrice", default=None) + lower_price_not: Optional[Any] = Field(alias="lowerPrice_not", default=None) + lower_price_gt: Optional[Any] = Field(alias="lowerPrice_gt", default=None) + lower_price_lt: Optional[Any] = Field(alias="lowerPrice_lt", default=None) + lower_price_gte: Optional[Any] = Field(alias="lowerPrice_gte", default=None) + lower_price_lte: Optional[Any] = Field(alias="lowerPrice_lte", default=None) + lower_price_in: Optional[List[Any]] = Field(alias="lowerPrice_in", default=None) + lower_price_not_in: Optional[List[Any]] = Field( + alias="lowerPrice_not_in", default=None + ) + average_price: Optional[Any] = Field(alias="averagePrice", default=None) + average_price_not: Optional[Any] = Field(alias="averagePrice_not", default=None) + average_price_gt: Optional[Any] = Field(alias="averagePrice_gt", default=None) + average_price_lt: Optional[Any] = Field(alias="averagePrice_lt", default=None) + average_price_gte: Optional[Any] = Field(alias="averagePrice_gte", default=None) + average_price_lte: Optional[Any] = Field(alias="averagePrice_lte", default=None) + average_price_in: Optional[List[Any]] = Field(alias="averagePrice_in", default=None) + average_price_not_in: Optional[List[Any]] = Field( + alias="averagePrice_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["TokenHourlyTotal_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["TokenHourlyTotal_filter"]]] = Field( + alias="or", default=None + ) + + +class TokenTradingEvent_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token: Optional[str] = None + token_not: Optional[str] = None + token_gt: Optional[str] = None + token_lt: Optional[str] = None + token_gte: Optional[str] = None + token_lte: Optional[str] = None + token_in: Optional[List[str]] = None + token_not_in: Optional[List[str]] = None + token_contains: Optional[str] = None + token_contains_nocase: Optional[str] = None + token_not_contains: Optional[str] = None + token_not_contains_nocase: Optional[str] = None + token_starts_with: Optional[str] = None + token_starts_with_nocase: Optional[str] = None + token_not_starts_with: Optional[str] = None + token_not_starts_with_nocase: Optional[str] = None + token_ends_with: Optional[str] = None + token_ends_with_nocase: Optional[str] = None + token_not_ends_with: Optional[str] = None + token_not_ends_with_nocase: Optional[str] = None + token: Optional["Token_filter"] = Field(alias="token_", default=None) + trade: Optional[str] = None + trade_not: Optional[str] = None + trade_gt: Optional[str] = None + trade_lt: Optional[str] = None + trade_gte: Optional[str] = None + trade_lte: Optional[str] = None + trade_in: Optional[List[str]] = None + trade_not_in: Optional[List[str]] = None + trade_contains: Optional[str] = None + trade_contains_nocase: Optional[str] = None + trade_not_contains: Optional[str] = None + trade_not_contains_nocase: Optional[str] = None + trade_starts_with: Optional[str] = None + trade_starts_with_nocase: Optional[str] = None + trade_not_starts_with: Optional[str] = None + trade_not_starts_with_nocase: Optional[str] = None + trade_ends_with: Optional[str] = None + trade_ends_with_nocase: Optional[str] = None + trade_not_ends_with: Optional[str] = None + trade_not_ends_with_nocase: Optional[str] = None + trade: Optional["Trade_filter"] = Field(alias="trade_", default=None) + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + amount_eth: Optional[Any] = Field(alias="amountEth", default=None) + amount_eth_not: Optional[Any] = Field(alias="amountEth_not", default=None) + amount_eth_gt: Optional[Any] = Field(alias="amountEth_gt", default=None) + amount_eth_lt: Optional[Any] = Field(alias="amountEth_lt", default=None) + amount_eth_gte: Optional[Any] = Field(alias="amountEth_gte", default=None) + amount_eth_lte: Optional[Any] = Field(alias="amountEth_lte", default=None) + amount_eth_in: Optional[List[Any]] = Field(alias="amountEth_in", default=None) + amount_eth_not_in: Optional[List[Any]] = Field( + alias="amountEth_not_in", default=None + ) + amount_usd: Optional[Any] = Field(alias="amountUsd", default=None) + amount_usd_not: Optional[Any] = Field(alias="amountUsd_not", default=None) + amount_usd_gt: Optional[Any] = Field(alias="amountUsd_gt", default=None) + amount_usd_lt: Optional[Any] = Field(alias="amountUsd_lt", default=None) + amount_usd_gte: Optional[Any] = Field(alias="amountUsd_gte", default=None) + amount_usd_lte: Optional[Any] = Field(alias="amountUsd_lte", default=None) + amount_usd_in: Optional[List[Any]] = Field(alias="amountUsd_in", default=None) + amount_usd_not_in: Optional[List[Any]] = Field( + alias="amountUsd_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["TokenTradingEvent_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["TokenTradingEvent_filter"]]] = Field( + alias="or", default=None + ) + + +class Token_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + address: Optional[Any] = None + address_not: Optional[Any] = None + address_gt: Optional[Any] = None + address_lt: Optional[Any] = None + address_gte: Optional[Any] = None + address_lte: Optional[Any] = None + address_in: Optional[List[Any]] = None + address_not_in: Optional[List[Any]] = None + address_contains: Optional[Any] = None + address_not_contains: Optional[Any] = None + first_trade_timestamp: Optional[int] = Field( + alias="firstTradeTimestamp", default=None + ) + first_trade_timestamp_not: Optional[int] = Field( + alias="firstTradeTimestamp_not", default=None + ) + first_trade_timestamp_gt: Optional[int] = Field( + alias="firstTradeTimestamp_gt", default=None + ) + first_trade_timestamp_lt: Optional[int] = Field( + alias="firstTradeTimestamp_lt", default=None + ) + first_trade_timestamp_gte: Optional[int] = Field( + alias="firstTradeTimestamp_gte", default=None + ) + first_trade_timestamp_lte: Optional[int] = Field( + alias="firstTradeTimestamp_lte", default=None + ) + first_trade_timestamp_in: Optional[List[int]] = Field( + alias="firstTradeTimestamp_in", default=None + ) + first_trade_timestamp_not_in: Optional[List[int]] = Field( + alias="firstTradeTimestamp_not_in", default=None + ) + name: Optional[str] = None + name_not: Optional[str] = None + name_gt: Optional[str] = None + name_lt: Optional[str] = None + name_gte: Optional[str] = None + name_lte: Optional[str] = None + name_in: Optional[List[str]] = None + name_not_in: Optional[List[str]] = None + name_contains: Optional[str] = None + name_contains_nocase: Optional[str] = None + name_not_contains: Optional[str] = None + name_not_contains_nocase: Optional[str] = None + name_starts_with: Optional[str] = None + name_starts_with_nocase: Optional[str] = None + name_not_starts_with: Optional[str] = None + name_not_starts_with_nocase: Optional[str] = None + name_ends_with: Optional[str] = None + name_ends_with_nocase: Optional[str] = None + name_not_ends_with: Optional[str] = None + name_not_ends_with_nocase: Optional[str] = None + symbol: Optional[str] = None + symbol_not: Optional[str] = None + symbol_gt: Optional[str] = None + symbol_lt: Optional[str] = None + symbol_gte: Optional[str] = None + symbol_lte: Optional[str] = None + symbol_in: Optional[List[str]] = None + symbol_not_in: Optional[List[str]] = None + symbol_contains: Optional[str] = None + symbol_contains_nocase: Optional[str] = None + symbol_not_contains: Optional[str] = None + symbol_not_contains_nocase: Optional[str] = None + symbol_starts_with: Optional[str] = None + symbol_starts_with_nocase: Optional[str] = None + symbol_not_starts_with: Optional[str] = None + symbol_not_starts_with_nocase: Optional[str] = None + symbol_ends_with: Optional[str] = None + symbol_ends_with_nocase: Optional[str] = None + symbol_not_ends_with: Optional[str] = None + symbol_not_ends_with_nocase: Optional[str] = None + decimals: Optional[int] = None + decimals_not: Optional[int] = None + decimals_gt: Optional[int] = None + decimals_lt: Optional[int] = None + decimals_gte: Optional[int] = None + decimals_lte: Optional[int] = None + decimals_in: Optional[List[int]] = None + decimals_not_in: Optional[List[int]] = None + total_volume: Optional[Any] = Field(alias="totalVolume", default=None) + total_volume_not: Optional[Any] = Field(alias="totalVolume_not", default=None) + total_volume_gt: Optional[Any] = Field(alias="totalVolume_gt", default=None) + total_volume_lt: Optional[Any] = Field(alias="totalVolume_lt", default=None) + total_volume_gte: Optional[Any] = Field(alias="totalVolume_gte", default=None) + total_volume_lte: Optional[Any] = Field(alias="totalVolume_lte", default=None) + total_volume_in: Optional[List[Any]] = Field(alias="totalVolume_in", default=None) + total_volume_not_in: Optional[List[Any]] = Field( + alias="totalVolume_not_in", default=None + ) + price_eth: Optional[Any] = Field(alias="priceEth", default=None) + price_eth_not: Optional[Any] = Field(alias="priceEth_not", default=None) + price_eth_gt: Optional[Any] = Field(alias="priceEth_gt", default=None) + price_eth_lt: Optional[Any] = Field(alias="priceEth_lt", default=None) + price_eth_gte: Optional[Any] = Field(alias="priceEth_gte", default=None) + price_eth_lte: Optional[Any] = Field(alias="priceEth_lte", default=None) + price_eth_in: Optional[List[Any]] = Field(alias="priceEth_in", default=None) + price_eth_not_in: Optional[List[Any]] = Field(alias="priceEth_not_in", default=None) + price_usd: Optional[Any] = Field(alias="priceUsd", default=None) + price_usd_not: Optional[Any] = Field(alias="priceUsd_not", default=None) + price_usd_gt: Optional[Any] = Field(alias="priceUsd_gt", default=None) + price_usd_lt: Optional[Any] = Field(alias="priceUsd_lt", default=None) + price_usd_gte: Optional[Any] = Field(alias="priceUsd_gte", default=None) + price_usd_lte: Optional[Any] = Field(alias="priceUsd_lte", default=None) + price_usd_in: Optional[List[Any]] = Field(alias="priceUsd_in", default=None) + price_usd_not_in: Optional[List[Any]] = Field(alias="priceUsd_not_in", default=None) + history: Optional["TokenTradingEvent_filter"] = Field( + alias="history_", default=None + ) + hourly_totals: Optional["TokenHourlyTotal_filter"] = Field( + alias="hourlyTotals_", default=None + ) + daily_totals: Optional["TokenDailyTotal_filter"] = Field( + alias="dailyTotals_", default=None + ) + number_of_trades: Optional[int] = Field(alias="numberOfTrades", default=None) + number_of_trades_not: Optional[int] = Field( + alias="numberOfTrades_not", default=None + ) + number_of_trades_gt: Optional[int] = Field(alias="numberOfTrades_gt", default=None) + number_of_trades_lt: Optional[int] = Field(alias="numberOfTrades_lt", default=None) + number_of_trades_gte: Optional[int] = Field( + alias="numberOfTrades_gte", default=None + ) + number_of_trades_lte: Optional[int] = Field( + alias="numberOfTrades_lte", default=None + ) + number_of_trades_in: Optional[List[int]] = Field( + alias="numberOfTrades_in", default=None + ) + number_of_trades_not_in: Optional[List[int]] = Field( + alias="numberOfTrades_not_in", default=None + ) + total_volume_usd: Optional[Any] = Field(alias="totalVolumeUsd", default=None) + total_volume_usd_not: Optional[Any] = Field( + alias="totalVolumeUsd_not", default=None + ) + total_volume_usd_gt: Optional[Any] = Field(alias="totalVolumeUsd_gt", default=None) + total_volume_usd_lt: Optional[Any] = Field(alias="totalVolumeUsd_lt", default=None) + total_volume_usd_gte: Optional[Any] = Field( + alias="totalVolumeUsd_gte", default=None + ) + total_volume_usd_lte: Optional[Any] = Field( + alias="totalVolumeUsd_lte", default=None + ) + total_volume_usd_in: Optional[List[Any]] = Field( + alias="totalVolumeUsd_in", default=None + ) + total_volume_usd_not_in: Optional[List[Any]] = Field( + alias="totalVolumeUsd_not_in", default=None + ) + total_volume_eth: Optional[Any] = Field(alias="totalVolumeEth", default=None) + total_volume_eth_not: Optional[Any] = Field( + alias="totalVolumeEth_not", default=None + ) + total_volume_eth_gt: Optional[Any] = Field(alias="totalVolumeEth_gt", default=None) + total_volume_eth_lt: Optional[Any] = Field(alias="totalVolumeEth_lt", default=None) + total_volume_eth_gte: Optional[Any] = Field( + alias="totalVolumeEth_gte", default=None + ) + total_volume_eth_lte: Optional[Any] = Field( + alias="totalVolumeEth_lte", default=None + ) + total_volume_eth_in: Optional[List[Any]] = Field( + alias="totalVolumeEth_in", default=None + ) + total_volume_eth_not_in: Optional[List[Any]] = Field( + alias="totalVolumeEth_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Token_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["Token_filter"]]] = Field(alias="or", default=None) + + +class Total_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + tokens: Optional[Any] = None + tokens_not: Optional[Any] = None + tokens_gt: Optional[Any] = None + tokens_lt: Optional[Any] = None + tokens_gte: Optional[Any] = None + tokens_lte: Optional[Any] = None + tokens_in: Optional[List[Any]] = None + tokens_not_in: Optional[List[Any]] = None + orders: Optional[Any] = None + orders_not: Optional[Any] = None + orders_gt: Optional[Any] = None + orders_lt: Optional[Any] = None + orders_gte: Optional[Any] = None + orders_lte: Optional[Any] = None + orders_in: Optional[List[Any]] = None + orders_not_in: Optional[List[Any]] = None + traders: Optional[Any] = None + traders_not: Optional[Any] = None + traders_gt: Optional[Any] = None + traders_lt: Optional[Any] = None + traders_gte: Optional[Any] = None + traders_lte: Optional[Any] = None + traders_in: Optional[List[Any]] = None + traders_not_in: Optional[List[Any]] = None + number_of_trades: Optional[Any] = Field(alias="numberOfTrades", default=None) + number_of_trades_not: Optional[Any] = Field( + alias="numberOfTrades_not", default=None + ) + number_of_trades_gt: Optional[Any] = Field(alias="numberOfTrades_gt", default=None) + number_of_trades_lt: Optional[Any] = Field(alias="numberOfTrades_lt", default=None) + number_of_trades_gte: Optional[Any] = Field( + alias="numberOfTrades_gte", default=None + ) + number_of_trades_lte: Optional[Any] = Field( + alias="numberOfTrades_lte", default=None + ) + number_of_trades_in: Optional[List[Any]] = Field( + alias="numberOfTrades_in", default=None + ) + number_of_trades_not_in: Optional[List[Any]] = Field( + alias="numberOfTrades_not_in", default=None + ) + settlements: Optional[Any] = None + settlements_not: Optional[Any] = None + settlements_gt: Optional[Any] = None + settlements_lt: Optional[Any] = None + settlements_gte: Optional[Any] = None + settlements_lte: Optional[Any] = None + settlements_in: Optional[List[Any]] = None + settlements_not_in: Optional[List[Any]] = None + volume_usd: Optional[Any] = Field(alias="volumeUsd", default=None) + volume_usd_not: Optional[Any] = Field(alias="volumeUsd_not", default=None) + volume_usd_gt: Optional[Any] = Field(alias="volumeUsd_gt", default=None) + volume_usd_lt: Optional[Any] = Field(alias="volumeUsd_lt", default=None) + volume_usd_gte: Optional[Any] = Field(alias="volumeUsd_gte", default=None) + volume_usd_lte: Optional[Any] = Field(alias="volumeUsd_lte", default=None) + volume_usd_in: Optional[List[Any]] = Field(alias="volumeUsd_in", default=None) + volume_usd_not_in: Optional[List[Any]] = Field( + alias="volumeUsd_not_in", default=None + ) + volume_eth: Optional[Any] = Field(alias="volumeEth", default=None) + volume_eth_not: Optional[Any] = Field(alias="volumeEth_not", default=None) + volume_eth_gt: Optional[Any] = Field(alias="volumeEth_gt", default=None) + volume_eth_lt: Optional[Any] = Field(alias="volumeEth_lt", default=None) + volume_eth_gte: Optional[Any] = Field(alias="volumeEth_gte", default=None) + volume_eth_lte: Optional[Any] = Field(alias="volumeEth_lte", default=None) + volume_eth_in: Optional[List[Any]] = Field(alias="volumeEth_in", default=None) + volume_eth_not_in: Optional[List[Any]] = Field( + alias="volumeEth_not_in", default=None + ) + fees_usd: Optional[Any] = Field(alias="feesUsd", default=None) + fees_usd_not: Optional[Any] = Field(alias="feesUsd_not", default=None) + fees_usd_gt: Optional[Any] = Field(alias="feesUsd_gt", default=None) + fees_usd_lt: Optional[Any] = Field(alias="feesUsd_lt", default=None) + fees_usd_gte: Optional[Any] = Field(alias="feesUsd_gte", default=None) + fees_usd_lte: Optional[Any] = Field(alias="feesUsd_lte", default=None) + fees_usd_in: Optional[List[Any]] = Field(alias="feesUsd_in", default=None) + fees_usd_not_in: Optional[List[Any]] = Field(alias="feesUsd_not_in", default=None) + fees_eth: Optional[Any] = Field(alias="feesEth", default=None) + fees_eth_not: Optional[Any] = Field(alias="feesEth_not", default=None) + fees_eth_gt: Optional[Any] = Field(alias="feesEth_gt", default=None) + fees_eth_lt: Optional[Any] = Field(alias="feesEth_lt", default=None) + fees_eth_gte: Optional[Any] = Field(alias="feesEth_gte", default=None) + fees_eth_lte: Optional[Any] = Field(alias="feesEth_lte", default=None) + fees_eth_in: Optional[List[Any]] = Field(alias="feesEth_in", default=None) + fees_eth_not_in: Optional[List[Any]] = Field(alias="feesEth_not_in", default=None) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Total_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["Total_filter"]]] = Field(alias="or", default=None) + + +class Trade_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + timestamp: Optional[int] = None + timestamp_not: Optional[int] = None + timestamp_gt: Optional[int] = None + timestamp_lt: Optional[int] = None + timestamp_gte: Optional[int] = None + timestamp_lte: Optional[int] = None + timestamp_in: Optional[List[int]] = None + timestamp_not_in: Optional[List[int]] = None + gas_price: Optional[Any] = Field(alias="gasPrice", default=None) + gas_price_not: Optional[Any] = Field(alias="gasPrice_not", default=None) + gas_price_gt: Optional[Any] = Field(alias="gasPrice_gt", default=None) + gas_price_lt: Optional[Any] = Field(alias="gasPrice_lt", default=None) + gas_price_gte: Optional[Any] = Field(alias="gasPrice_gte", default=None) + gas_price_lte: Optional[Any] = Field(alias="gasPrice_lte", default=None) + gas_price_in: Optional[List[Any]] = Field(alias="gasPrice_in", default=None) + gas_price_not_in: Optional[List[Any]] = Field(alias="gasPrice_not_in", default=None) + fee_amount: Optional[Any] = Field(alias="feeAmount", default=None) + fee_amount_not: Optional[Any] = Field(alias="feeAmount_not", default=None) + fee_amount_gt: Optional[Any] = Field(alias="feeAmount_gt", default=None) + fee_amount_lt: Optional[Any] = Field(alias="feeAmount_lt", default=None) + fee_amount_gte: Optional[Any] = Field(alias="feeAmount_gte", default=None) + fee_amount_lte: Optional[Any] = Field(alias="feeAmount_lte", default=None) + fee_amount_in: Optional[List[Any]] = Field(alias="feeAmount_in", default=None) + fee_amount_not_in: Optional[List[Any]] = Field( + alias="feeAmount_not_in", default=None + ) + tx_hash: Optional[Any] = Field(alias="txHash", default=None) + tx_hash_not: Optional[Any] = Field(alias="txHash_not", default=None) + tx_hash_gt: Optional[Any] = Field(alias="txHash_gt", default=None) + tx_hash_lt: Optional[Any] = Field(alias="txHash_lt", default=None) + tx_hash_gte: Optional[Any] = Field(alias="txHash_gte", default=None) + tx_hash_lte: Optional[Any] = Field(alias="txHash_lte", default=None) + tx_hash_in: Optional[List[Any]] = Field(alias="txHash_in", default=None) + tx_hash_not_in: Optional[List[Any]] = Field(alias="txHash_not_in", default=None) + tx_hash_contains: Optional[Any] = Field(alias="txHash_contains", default=None) + tx_hash_not_contains: Optional[Any] = Field( + alias="txHash_not_contains", default=None + ) + settlement: Optional[str] = None + settlement_not: Optional[str] = None + settlement_gt: Optional[str] = None + settlement_lt: Optional[str] = None + settlement_gte: Optional[str] = None + settlement_lte: Optional[str] = None + settlement_in: Optional[List[str]] = None + settlement_not_in: Optional[List[str]] = None + settlement_contains: Optional[str] = None + settlement_contains_nocase: Optional[str] = None + settlement_not_contains: Optional[str] = None + settlement_not_contains_nocase: Optional[str] = None + settlement_starts_with: Optional[str] = None + settlement_starts_with_nocase: Optional[str] = None + settlement_not_starts_with: Optional[str] = None + settlement_not_starts_with_nocase: Optional[str] = None + settlement_ends_with: Optional[str] = None + settlement_ends_with_nocase: Optional[str] = None + settlement_not_ends_with: Optional[str] = None + settlement_not_ends_with_nocase: Optional[str] = None + settlement: Optional["Settlement_filter"] = Field(alias="settlement_", default=None) + buy_amount: Optional[Any] = Field(alias="buyAmount", default=None) + buy_amount_not: Optional[Any] = Field(alias="buyAmount_not", default=None) + buy_amount_gt: Optional[Any] = Field(alias="buyAmount_gt", default=None) + buy_amount_lt: Optional[Any] = Field(alias="buyAmount_lt", default=None) + buy_amount_gte: Optional[Any] = Field(alias="buyAmount_gte", default=None) + buy_amount_lte: Optional[Any] = Field(alias="buyAmount_lte", default=None) + buy_amount_in: Optional[List[Any]] = Field(alias="buyAmount_in", default=None) + buy_amount_not_in: Optional[List[Any]] = Field( + alias="buyAmount_not_in", default=None + ) + sell_amount: Optional[Any] = Field(alias="sellAmount", default=None) + sell_amount_not: Optional[Any] = Field(alias="sellAmount_not", default=None) + sell_amount_gt: Optional[Any] = Field(alias="sellAmount_gt", default=None) + sell_amount_lt: Optional[Any] = Field(alias="sellAmount_lt", default=None) + sell_amount_gte: Optional[Any] = Field(alias="sellAmount_gte", default=None) + sell_amount_lte: Optional[Any] = Field(alias="sellAmount_lte", default=None) + sell_amount_in: Optional[List[Any]] = Field(alias="sellAmount_in", default=None) + sell_amount_not_in: Optional[List[Any]] = Field( + alias="sellAmount_not_in", default=None + ) + sell_token: Optional[str] = Field(alias="sellToken", default=None) + sell_token_not: Optional[str] = Field(alias="sellToken_not", default=None) + sell_token_gt: Optional[str] = Field(alias="sellToken_gt", default=None) + sell_token_lt: Optional[str] = Field(alias="sellToken_lt", default=None) + sell_token_gte: Optional[str] = Field(alias="sellToken_gte", default=None) + sell_token_lte: Optional[str] = Field(alias="sellToken_lte", default=None) + sell_token_in: Optional[List[str]] = Field(alias="sellToken_in", default=None) + sell_token_not_in: Optional[List[str]] = Field( + alias="sellToken_not_in", default=None + ) + sell_token_contains: Optional[str] = Field(alias="sellToken_contains", default=None) + sell_token_contains_nocase: Optional[str] = Field( + alias="sellToken_contains_nocase", default=None + ) + sell_token_not_contains: Optional[str] = Field( + alias="sellToken_not_contains", default=None + ) + sell_token_not_contains_nocase: Optional[str] = Field( + alias="sellToken_not_contains_nocase", default=None + ) + sell_token_starts_with: Optional[str] = Field( + alias="sellToken_starts_with", default=None + ) + sell_token_starts_with_nocase: Optional[str] = Field( + alias="sellToken_starts_with_nocase", default=None + ) + sell_token_not_starts_with: Optional[str] = Field( + alias="sellToken_not_starts_with", default=None + ) + sell_token_not_starts_with_nocase: Optional[str] = Field( + alias="sellToken_not_starts_with_nocase", default=None + ) + sell_token_ends_with: Optional[str] = Field( + alias="sellToken_ends_with", default=None + ) + sell_token_ends_with_nocase: Optional[str] = Field( + alias="sellToken_ends_with_nocase", default=None + ) + sell_token_not_ends_with: Optional[str] = Field( + alias="sellToken_not_ends_with", default=None + ) + sell_token_not_ends_with_nocase: Optional[str] = Field( + alias="sellToken_not_ends_with_nocase", default=None + ) + sell_token: Optional["Token_filter"] = Field(alias="sellToken_", default=None) + buy_token: Optional[str] = Field(alias="buyToken", default=None) + buy_token_not: Optional[str] = Field(alias="buyToken_not", default=None) + buy_token_gt: Optional[str] = Field(alias="buyToken_gt", default=None) + buy_token_lt: Optional[str] = Field(alias="buyToken_lt", default=None) + buy_token_gte: Optional[str] = Field(alias="buyToken_gte", default=None) + buy_token_lte: Optional[str] = Field(alias="buyToken_lte", default=None) + buy_token_in: Optional[List[str]] = Field(alias="buyToken_in", default=None) + buy_token_not_in: Optional[List[str]] = Field(alias="buyToken_not_in", default=None) + buy_token_contains: Optional[str] = Field(alias="buyToken_contains", default=None) + buy_token_contains_nocase: Optional[str] = Field( + alias="buyToken_contains_nocase", default=None + ) + buy_token_not_contains: Optional[str] = Field( + alias="buyToken_not_contains", default=None + ) + buy_token_not_contains_nocase: Optional[str] = Field( + alias="buyToken_not_contains_nocase", default=None + ) + buy_token_starts_with: Optional[str] = Field( + alias="buyToken_starts_with", default=None + ) + buy_token_starts_with_nocase: Optional[str] = Field( + alias="buyToken_starts_with_nocase", default=None + ) + buy_token_not_starts_with: Optional[str] = Field( + alias="buyToken_not_starts_with", default=None + ) + buy_token_not_starts_with_nocase: Optional[str] = Field( + alias="buyToken_not_starts_with_nocase", default=None + ) + buy_token_ends_with: Optional[str] = Field(alias="buyToken_ends_with", default=None) + buy_token_ends_with_nocase: Optional[str] = Field( + alias="buyToken_ends_with_nocase", default=None + ) + buy_token_not_ends_with: Optional[str] = Field( + alias="buyToken_not_ends_with", default=None + ) + buy_token_not_ends_with_nocase: Optional[str] = Field( + alias="buyToken_not_ends_with_nocase", default=None + ) + buy_token: Optional["Token_filter"] = Field(alias="buyToken_", default=None) + order: Optional[str] = None + order_not: Optional[str] = None + order_gt: Optional[str] = None + order_lt: Optional[str] = None + order_gte: Optional[str] = None + order_lte: Optional[str] = None + order_in: Optional[List[str]] = None + order_not_in: Optional[List[str]] = None + order_contains: Optional[str] = None + order_contains_nocase: Optional[str] = None + order_not_contains: Optional[str] = None + order_not_contains_nocase: Optional[str] = None + order_starts_with: Optional[str] = None + order_starts_with_nocase: Optional[str] = None + order_not_starts_with: Optional[str] = None + order_not_starts_with_nocase: Optional[str] = None + order_ends_with: Optional[str] = None + order_ends_with_nocase: Optional[str] = None + order_not_ends_with: Optional[str] = None + order_not_ends_with_nocase: Optional[str] = None + order: Optional["Order_filter"] = Field(alias="order_", default=None) + buy_amount_eth: Optional[Any] = Field(alias="buyAmountEth", default=None) + buy_amount_eth_not: Optional[Any] = Field(alias="buyAmountEth_not", default=None) + buy_amount_eth_gt: Optional[Any] = Field(alias="buyAmountEth_gt", default=None) + buy_amount_eth_lt: Optional[Any] = Field(alias="buyAmountEth_lt", default=None) + buy_amount_eth_gte: Optional[Any] = Field(alias="buyAmountEth_gte", default=None) + buy_amount_eth_lte: Optional[Any] = Field(alias="buyAmountEth_lte", default=None) + buy_amount_eth_in: Optional[List[Any]] = Field( + alias="buyAmountEth_in", default=None + ) + buy_amount_eth_not_in: Optional[List[Any]] = Field( + alias="buyAmountEth_not_in", default=None + ) + sell_amount_eth: Optional[Any] = Field(alias="sellAmountEth", default=None) + sell_amount_eth_not: Optional[Any] = Field(alias="sellAmountEth_not", default=None) + sell_amount_eth_gt: Optional[Any] = Field(alias="sellAmountEth_gt", default=None) + sell_amount_eth_lt: Optional[Any] = Field(alias="sellAmountEth_lt", default=None) + sell_amount_eth_gte: Optional[Any] = Field(alias="sellAmountEth_gte", default=None) + sell_amount_eth_lte: Optional[Any] = Field(alias="sellAmountEth_lte", default=None) + sell_amount_eth_in: Optional[List[Any]] = Field( + alias="sellAmountEth_in", default=None + ) + sell_amount_eth_not_in: Optional[List[Any]] = Field( + alias="sellAmountEth_not_in", default=None + ) + buy_amount_usd: Optional[Any] = Field(alias="buyAmountUsd", default=None) + buy_amount_usd_not: Optional[Any] = Field(alias="buyAmountUsd_not", default=None) + buy_amount_usd_gt: Optional[Any] = Field(alias="buyAmountUsd_gt", default=None) + buy_amount_usd_lt: Optional[Any] = Field(alias="buyAmountUsd_lt", default=None) + buy_amount_usd_gte: Optional[Any] = Field(alias="buyAmountUsd_gte", default=None) + buy_amount_usd_lte: Optional[Any] = Field(alias="buyAmountUsd_lte", default=None) + buy_amount_usd_in: Optional[List[Any]] = Field( + alias="buyAmountUsd_in", default=None + ) + buy_amount_usd_not_in: Optional[List[Any]] = Field( + alias="buyAmountUsd_not_in", default=None + ) + sell_amount_usd: Optional[Any] = Field(alias="sellAmountUsd", default=None) + sell_amount_usd_not: Optional[Any] = Field(alias="sellAmountUsd_not", default=None) + sell_amount_usd_gt: Optional[Any] = Field(alias="sellAmountUsd_gt", default=None) + sell_amount_usd_lt: Optional[Any] = Field(alias="sellAmountUsd_lt", default=None) + sell_amount_usd_gte: Optional[Any] = Field(alias="sellAmountUsd_gte", default=None) + sell_amount_usd_lte: Optional[Any] = Field(alias="sellAmountUsd_lte", default=None) + sell_amount_usd_in: Optional[List[Any]] = Field( + alias="sellAmountUsd_in", default=None + ) + sell_amount_usd_not_in: Optional[List[Any]] = Field( + alias="sellAmountUsd_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["Trade_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["Trade_filter"]]] = Field(alias="or", default=None) + + +class UniswapPool_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + token_0: Optional[str] = Field(alias="token0", default=None) + token_0_not: Optional[str] = Field(alias="token0_not", default=None) + token_0_gt: Optional[str] = Field(alias="token0_gt", default=None) + token_0_lt: Optional[str] = Field(alias="token0_lt", default=None) + token_0_gte: Optional[str] = Field(alias="token0_gte", default=None) + token_0_lte: Optional[str] = Field(alias="token0_lte", default=None) + token_0_in: Optional[List[str]] = Field(alias="token0_in", default=None) + token_0_not_in: Optional[List[str]] = Field(alias="token0_not_in", default=None) + token_0_contains: Optional[str] = Field(alias="token0_contains", default=None) + token_0_contains_nocase: Optional[str] = Field( + alias="token0_contains_nocase", default=None + ) + token_0_not_contains: Optional[str] = Field( + alias="token0_not_contains", default=None + ) + token_0_not_contains_nocase: Optional[str] = Field( + alias="token0_not_contains_nocase", default=None + ) + token_0_starts_with: Optional[str] = Field(alias="token0_starts_with", default=None) + token_0_starts_with_nocase: Optional[str] = Field( + alias="token0_starts_with_nocase", default=None + ) + token_0_not_starts_with: Optional[str] = Field( + alias="token0_not_starts_with", default=None + ) + token_0_not_starts_with_nocase: Optional[str] = Field( + alias="token0_not_starts_with_nocase", default=None + ) + token_0_ends_with: Optional[str] = Field(alias="token0_ends_with", default=None) + token_0_ends_with_nocase: Optional[str] = Field( + alias="token0_ends_with_nocase", default=None + ) + token_0_not_ends_with: Optional[str] = Field( + alias="token0_not_ends_with", default=None + ) + token_0_not_ends_with_nocase: Optional[str] = Field( + alias="token0_not_ends_with_nocase", default=None + ) + token_0: Optional["UniswapToken_filter"] = Field(alias="token0_", default=None) + token_1: Optional[str] = Field(alias="token1", default=None) + token_1_not: Optional[str] = Field(alias="token1_not", default=None) + token_1_gt: Optional[str] = Field(alias="token1_gt", default=None) + token_1_lt: Optional[str] = Field(alias="token1_lt", default=None) + token_1_gte: Optional[str] = Field(alias="token1_gte", default=None) + token_1_lte: Optional[str] = Field(alias="token1_lte", default=None) + token_1_in: Optional[List[str]] = Field(alias="token1_in", default=None) + token_1_not_in: Optional[List[str]] = Field(alias="token1_not_in", default=None) + token_1_contains: Optional[str] = Field(alias="token1_contains", default=None) + token_1_contains_nocase: Optional[str] = Field( + alias="token1_contains_nocase", default=None + ) + token_1_not_contains: Optional[str] = Field( + alias="token1_not_contains", default=None + ) + token_1_not_contains_nocase: Optional[str] = Field( + alias="token1_not_contains_nocase", default=None + ) + token_1_starts_with: Optional[str] = Field(alias="token1_starts_with", default=None) + token_1_starts_with_nocase: Optional[str] = Field( + alias="token1_starts_with_nocase", default=None + ) + token_1_not_starts_with: Optional[str] = Field( + alias="token1_not_starts_with", default=None + ) + token_1_not_starts_with_nocase: Optional[str] = Field( + alias="token1_not_starts_with_nocase", default=None + ) + token_1_ends_with: Optional[str] = Field(alias="token1_ends_with", default=None) + token_1_ends_with_nocase: Optional[str] = Field( + alias="token1_ends_with_nocase", default=None + ) + token_1_not_ends_with: Optional[str] = Field( + alias="token1_not_ends_with", default=None + ) + token_1_not_ends_with_nocase: Optional[str] = Field( + alias="token1_not_ends_with_nocase", default=None + ) + token_1: Optional["UniswapToken_filter"] = Field(alias="token1_", default=None) + liquidity: Optional[Any] = None + liquidity_not: Optional[Any] = None + liquidity_gt: Optional[Any] = None + liquidity_lt: Optional[Any] = None + liquidity_gte: Optional[Any] = None + liquidity_lte: Optional[Any] = None + liquidity_in: Optional[List[Any]] = None + liquidity_not_in: Optional[List[Any]] = None + token_0_price: Optional[Any] = Field(alias="token0Price", default=None) + token_0_price_not: Optional[Any] = Field(alias="token0Price_not", default=None) + token_0_price_gt: Optional[Any] = Field(alias="token0Price_gt", default=None) + token_0_price_lt: Optional[Any] = Field(alias="token0Price_lt", default=None) + token_0_price_gte: Optional[Any] = Field(alias="token0Price_gte", default=None) + token_0_price_lte: Optional[Any] = Field(alias="token0Price_lte", default=None) + token_0_price_in: Optional[List[Any]] = Field(alias="token0Price_in", default=None) + token_0_price_not_in: Optional[List[Any]] = Field( + alias="token0Price_not_in", default=None + ) + token_1_price: Optional[Any] = Field(alias="token1Price", default=None) + token_1_price_not: Optional[Any] = Field(alias="token1Price_not", default=None) + token_1_price_gt: Optional[Any] = Field(alias="token1Price_gt", default=None) + token_1_price_lt: Optional[Any] = Field(alias="token1Price_lt", default=None) + token_1_price_gte: Optional[Any] = Field(alias="token1Price_gte", default=None) + token_1_price_lte: Optional[Any] = Field(alias="token1Price_lte", default=None) + token_1_price_in: Optional[List[Any]] = Field(alias="token1Price_in", default=None) + token_1_price_not_in: Optional[List[Any]] = Field( + alias="token1Price_not_in", default=None + ) + tick: Optional[Any] = None + tick_not: Optional[Any] = None + tick_gt: Optional[Any] = None + tick_lt: Optional[Any] = None + tick_gte: Optional[Any] = None + tick_lte: Optional[Any] = None + tick_in: Optional[List[Any]] = None + tick_not_in: Optional[List[Any]] = None + total_value_locked_token_0: Optional[Any] = Field( + alias="totalValueLockedToken0", default=None + ) + total_value_locked_token_0_not: Optional[Any] = Field( + alias="totalValueLockedToken0_not", default=None + ) + total_value_locked_token_0_gt: Optional[Any] = Field( + alias="totalValueLockedToken0_gt", default=None + ) + total_value_locked_token_0_lt: Optional[Any] = Field( + alias="totalValueLockedToken0_lt", default=None + ) + total_value_locked_token_0_gte: Optional[Any] = Field( + alias="totalValueLockedToken0_gte", default=None + ) + total_value_locked_token_0_lte: Optional[Any] = Field( + alias="totalValueLockedToken0_lte", default=None + ) + total_value_locked_token_0_in: Optional[List[Any]] = Field( + alias="totalValueLockedToken0_in", default=None + ) + total_value_locked_token_0_not_in: Optional[List[Any]] = Field( + alias="totalValueLockedToken0_not_in", default=None + ) + total_value_locked_token_1: Optional[Any] = Field( + alias="totalValueLockedToken1", default=None + ) + total_value_locked_token_1_not: Optional[Any] = Field( + alias="totalValueLockedToken1_not", default=None + ) + total_value_locked_token_1_gt: Optional[Any] = Field( + alias="totalValueLockedToken1_gt", default=None + ) + total_value_locked_token_1_lt: Optional[Any] = Field( + alias="totalValueLockedToken1_lt", default=None + ) + total_value_locked_token_1_gte: Optional[Any] = Field( + alias="totalValueLockedToken1_gte", default=None + ) + total_value_locked_token_1_lte: Optional[Any] = Field( + alias="totalValueLockedToken1_lte", default=None + ) + total_value_locked_token_1_in: Optional[List[Any]] = Field( + alias="totalValueLockedToken1_in", default=None + ) + total_value_locked_token_1_not_in: Optional[List[Any]] = Field( + alias="totalValueLockedToken1_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["UniswapPool_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["UniswapPool_filter"]]] = Field( + alias="or", default=None + ) + + +class UniswapToken_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + address: Optional[Any] = None + address_not: Optional[Any] = None + address_gt: Optional[Any] = None + address_lt: Optional[Any] = None + address_gte: Optional[Any] = None + address_lte: Optional[Any] = None + address_in: Optional[List[Any]] = None + address_not_in: Optional[List[Any]] = None + address_contains: Optional[Any] = None + address_not_contains: Optional[Any] = None + name: Optional[str] = None + name_not: Optional[str] = None + name_gt: Optional[str] = None + name_lt: Optional[str] = None + name_gte: Optional[str] = None + name_lte: Optional[str] = None + name_in: Optional[List[str]] = None + name_not_in: Optional[List[str]] = None + name_contains: Optional[str] = None + name_contains_nocase: Optional[str] = None + name_not_contains: Optional[str] = None + name_not_contains_nocase: Optional[str] = None + name_starts_with: Optional[str] = None + name_starts_with_nocase: Optional[str] = None + name_not_starts_with: Optional[str] = None + name_not_starts_with_nocase: Optional[str] = None + name_ends_with: Optional[str] = None + name_ends_with_nocase: Optional[str] = None + name_not_ends_with: Optional[str] = None + name_not_ends_with_nocase: Optional[str] = None + symbol: Optional[str] = None + symbol_not: Optional[str] = None + symbol_gt: Optional[str] = None + symbol_lt: Optional[str] = None + symbol_gte: Optional[str] = None + symbol_lte: Optional[str] = None + symbol_in: Optional[List[str]] = None + symbol_not_in: Optional[List[str]] = None + symbol_contains: Optional[str] = None + symbol_contains_nocase: Optional[str] = None + symbol_not_contains: Optional[str] = None + symbol_not_contains_nocase: Optional[str] = None + symbol_starts_with: Optional[str] = None + symbol_starts_with_nocase: Optional[str] = None + symbol_not_starts_with: Optional[str] = None + symbol_not_starts_with_nocase: Optional[str] = None + symbol_ends_with: Optional[str] = None + symbol_ends_with_nocase: Optional[str] = None + symbol_not_ends_with: Optional[str] = None + symbol_not_ends_with_nocase: Optional[str] = None + decimals: Optional[int] = None + decimals_not: Optional[int] = None + decimals_gt: Optional[int] = None + decimals_lt: Optional[int] = None + decimals_gte: Optional[int] = None + decimals_lte: Optional[int] = None + decimals_in: Optional[List[int]] = None + decimals_not_in: Optional[List[int]] = None + price_eth: Optional[Any] = Field(alias="priceEth", default=None) + price_eth_not: Optional[Any] = Field(alias="priceEth_not", default=None) + price_eth_gt: Optional[Any] = Field(alias="priceEth_gt", default=None) + price_eth_lt: Optional[Any] = Field(alias="priceEth_lt", default=None) + price_eth_gte: Optional[Any] = Field(alias="priceEth_gte", default=None) + price_eth_lte: Optional[Any] = Field(alias="priceEth_lte", default=None) + price_eth_in: Optional[List[Any]] = Field(alias="priceEth_in", default=None) + price_eth_not_in: Optional[List[Any]] = Field(alias="priceEth_not_in", default=None) + price_usd: Optional[Any] = Field(alias="priceUsd", default=None) + price_usd_not: Optional[Any] = Field(alias="priceUsd_not", default=None) + price_usd_gt: Optional[Any] = Field(alias="priceUsd_gt", default=None) + price_usd_lt: Optional[Any] = Field(alias="priceUsd_lt", default=None) + price_usd_gte: Optional[Any] = Field(alias="priceUsd_gte", default=None) + price_usd_lte: Optional[Any] = Field(alias="priceUsd_lte", default=None) + price_usd_in: Optional[List[Any]] = Field(alias="priceUsd_in", default=None) + price_usd_not_in: Optional[List[Any]] = Field(alias="priceUsd_not_in", default=None) + allowed_pools: Optional[List[str]] = Field(alias="allowedPools", default=None) + allowed_pools_not: Optional[List[str]] = Field( + alias="allowedPools_not", default=None + ) + allowed_pools_contains: Optional[List[str]] = Field( + alias="allowedPools_contains", default=None + ) + allowed_pools_contains_nocase: Optional[List[str]] = Field( + alias="allowedPools_contains_nocase", default=None + ) + allowed_pools_not_contains: Optional[List[str]] = Field( + alias="allowedPools_not_contains", default=None + ) + allowed_pools_not_contains_nocase: Optional[List[str]] = Field( + alias="allowedPools_not_contains_nocase", default=None + ) + allowed_pools: Optional["UniswapToken_filter"] = Field( + alias="allowedPools_", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["UniswapToken_filter"]]] = Field( + alias="and", default=None + ) + or_: Optional[List[Optional["UniswapToken_filter"]]] = Field( + alias="or", default=None + ) + + +class User_filter(BaseModel): + id: Optional[str] = None + id_not: Optional[str] = None + id_gt: Optional[str] = None + id_lt: Optional[str] = None + id_gte: Optional[str] = None + id_lte: Optional[str] = None + id_in: Optional[List[str]] = None + id_not_in: Optional[List[str]] = None + address: Optional[Any] = None + address_not: Optional[Any] = None + address_gt: Optional[Any] = None + address_lt: Optional[Any] = None + address_gte: Optional[Any] = None + address_lte: Optional[Any] = None + address_in: Optional[List[Any]] = None + address_not_in: Optional[List[Any]] = None + address_contains: Optional[Any] = None + address_not_contains: Optional[Any] = None + first_trade_timestamp: Optional[int] = Field( + alias="firstTradeTimestamp", default=None + ) + first_trade_timestamp_not: Optional[int] = Field( + alias="firstTradeTimestamp_not", default=None + ) + first_trade_timestamp_gt: Optional[int] = Field( + alias="firstTradeTimestamp_gt", default=None + ) + first_trade_timestamp_lt: Optional[int] = Field( + alias="firstTradeTimestamp_lt", default=None + ) + first_trade_timestamp_gte: Optional[int] = Field( + alias="firstTradeTimestamp_gte", default=None + ) + first_trade_timestamp_lte: Optional[int] = Field( + alias="firstTradeTimestamp_lte", default=None + ) + first_trade_timestamp_in: Optional[List[int]] = Field( + alias="firstTradeTimestamp_in", default=None + ) + first_trade_timestamp_not_in: Optional[List[int]] = Field( + alias="firstTradeTimestamp_not_in", default=None + ) + orders_placed: Optional["Order_filter"] = Field(alias="ordersPlaced_", default=None) + is_solver: Optional[bool] = Field(alias="isSolver", default=None) + is_solver_not: Optional[bool] = Field(alias="isSolver_not", default=None) + is_solver_in: Optional[List[bool]] = Field(alias="isSolver_in", default=None) + is_solver_not_in: Optional[List[bool]] = Field( + alias="isSolver_not_in", default=None + ) + number_of_trades: Optional[int] = Field(alias="numberOfTrades", default=None) + number_of_trades_not: Optional[int] = Field( + alias="numberOfTrades_not", default=None + ) + number_of_trades_gt: Optional[int] = Field(alias="numberOfTrades_gt", default=None) + number_of_trades_lt: Optional[int] = Field(alias="numberOfTrades_lt", default=None) + number_of_trades_gte: Optional[int] = Field( + alias="numberOfTrades_gte", default=None + ) + number_of_trades_lte: Optional[int] = Field( + alias="numberOfTrades_lte", default=None + ) + number_of_trades_in: Optional[List[int]] = Field( + alias="numberOfTrades_in", default=None + ) + number_of_trades_not_in: Optional[List[int]] = Field( + alias="numberOfTrades_not_in", default=None + ) + solved_amount_eth: Optional[Any] = Field(alias="solvedAmountEth", default=None) + solved_amount_eth_not: Optional[Any] = Field( + alias="solvedAmountEth_not", default=None + ) + solved_amount_eth_gt: Optional[Any] = Field( + alias="solvedAmountEth_gt", default=None + ) + solved_amount_eth_lt: Optional[Any] = Field( + alias="solvedAmountEth_lt", default=None + ) + solved_amount_eth_gte: Optional[Any] = Field( + alias="solvedAmountEth_gte", default=None + ) + solved_amount_eth_lte: Optional[Any] = Field( + alias="solvedAmountEth_lte", default=None + ) + solved_amount_eth_in: Optional[List[Any]] = Field( + alias="solvedAmountEth_in", default=None + ) + solved_amount_eth_not_in: Optional[List[Any]] = Field( + alias="solvedAmountEth_not_in", default=None + ) + solved_amount_usd: Optional[Any] = Field(alias="solvedAmountUsd", default=None) + solved_amount_usd_not: Optional[Any] = Field( + alias="solvedAmountUsd_not", default=None + ) + solved_amount_usd_gt: Optional[Any] = Field( + alias="solvedAmountUsd_gt", default=None + ) + solved_amount_usd_lt: Optional[Any] = Field( + alias="solvedAmountUsd_lt", default=None + ) + solved_amount_usd_gte: Optional[Any] = Field( + alias="solvedAmountUsd_gte", default=None + ) + solved_amount_usd_lte: Optional[Any] = Field( + alias="solvedAmountUsd_lte", default=None + ) + solved_amount_usd_in: Optional[List[Any]] = Field( + alias="solvedAmountUsd_in", default=None + ) + solved_amount_usd_not_in: Optional[List[Any]] = Field( + alias="solvedAmountUsd_not_in", default=None + ) + traded_amount_usd: Optional[Any] = Field(alias="tradedAmountUsd", default=None) + traded_amount_usd_not: Optional[Any] = Field( + alias="tradedAmountUsd_not", default=None + ) + traded_amount_usd_gt: Optional[Any] = Field( + alias="tradedAmountUsd_gt", default=None + ) + traded_amount_usd_lt: Optional[Any] = Field( + alias="tradedAmountUsd_lt", default=None + ) + traded_amount_usd_gte: Optional[Any] = Field( + alias="tradedAmountUsd_gte", default=None + ) + traded_amount_usd_lte: Optional[Any] = Field( + alias="tradedAmountUsd_lte", default=None + ) + traded_amount_usd_in: Optional[List[Any]] = Field( + alias="tradedAmountUsd_in", default=None + ) + traded_amount_usd_not_in: Optional[List[Any]] = Field( + alias="tradedAmountUsd_not_in", default=None + ) + traded_amount_eth: Optional[Any] = Field(alias="tradedAmountEth", default=None) + traded_amount_eth_not: Optional[Any] = Field( + alias="tradedAmountEth_not", default=None + ) + traded_amount_eth_gt: Optional[Any] = Field( + alias="tradedAmountEth_gt", default=None + ) + traded_amount_eth_lt: Optional[Any] = Field( + alias="tradedAmountEth_lt", default=None + ) + traded_amount_eth_gte: Optional[Any] = Field( + alias="tradedAmountEth_gte", default=None + ) + traded_amount_eth_lte: Optional[Any] = Field( + alias="tradedAmountEth_lte", default=None + ) + traded_amount_eth_in: Optional[List[Any]] = Field( + alias="tradedAmountEth_in", default=None + ) + traded_amount_eth_not_in: Optional[List[Any]] = Field( + alias="tradedAmountEth_not_in", default=None + ) + change_block: Optional["BlockChangedFilter"] = Field( + alias="_change_block", default=None + ) + and_: Optional[List[Optional["User_filter"]]] = Field(alias="and", default=None) + or_: Optional[List[Optional["User_filter"]]] = Field(alias="or", default=None) diff --git a/cow_py/subgraph/client/last_days_volume.py b/cow_py/subgraph/client/last_days_volume.py new file mode 100644 index 0000000..a27cdb9 --- /dev/null +++ b/cow_py/subgraph/client/last_days_volume.py @@ -0,0 +1,17 @@ +# Generated by ariadne-codegen +# Source: cow_py/subgraph/queries + +from typing import Any, List, Optional + +from pydantic import Field + +from .base_model import BaseModel + + +class LastDaysVolume(BaseModel): + daily_totals: List["LastDaysVolumeDailyTotals"] = Field(alias="dailyTotals") + + +class LastDaysVolumeDailyTotals(BaseModel): + timestamp: int + volume_usd: Optional[Any] = Field(alias="volumeUsd") diff --git a/cow_py/subgraph/client/last_hours_volume.py b/cow_py/subgraph/client/last_hours_volume.py new file mode 100644 index 0000000..bff2776 --- /dev/null +++ b/cow_py/subgraph/client/last_hours_volume.py @@ -0,0 +1,17 @@ +# Generated by ariadne-codegen +# Source: cow_py/subgraph/queries + +from typing import Any, List, Optional + +from pydantic import Field + +from .base_model import BaseModel + + +class LastHoursVolume(BaseModel): + hourly_totals: List["LastHoursVolumeHourlyTotals"] = Field(alias="hourlyTotals") + + +class LastHoursVolumeHourlyTotals(BaseModel): + timestamp: int + volume_usd: Optional[Any] = Field(alias="volumeUsd") diff --git a/cow_py/subgraph/client/subgraph_client.py b/cow_py/subgraph/client/subgraph_client.py new file mode 100644 index 0000000..4ed8ba8 --- /dev/null +++ b/cow_py/subgraph/client/subgraph_client.py @@ -0,0 +1,75 @@ +# Generated by ariadne-codegen +# Source: cow_py/subgraph/queries + +from typing import Any, Dict + +from .async_base_client import AsyncBaseClient +from .last_days_volume import LastDaysVolume +from .last_hours_volume import LastHoursVolume +from .totals import Totals + + +def gql(q: str) -> str: + return q + + +class SubgraphClient(AsyncBaseClient): + async def last_days_volume(self, days: int, **kwargs: Any) -> LastDaysVolume: + query = gql( + """ + query LastDaysVolume($days: Int!) { + dailyTotals(orderBy: timestamp, orderDirection: desc, first: $days) { + timestamp + volumeUsd + } + } + """ + ) + variables: Dict[str, object] = {"days": days} + response = await self.execute( + query=query, operation_name="LastDaysVolume", variables=variables, **kwargs + ) + data = self.get_data(response) + return LastDaysVolume.model_validate(data) + + async def last_hours_volume(self, hours: int, **kwargs: Any) -> LastHoursVolume: + query = gql( + """ + query LastHoursVolume($hours: Int!) { + hourlyTotals(orderBy: timestamp, orderDirection: desc, first: $hours) { + timestamp + volumeUsd + } + } + """ + ) + variables: Dict[str, object] = {"hours": hours} + response = await self.execute( + query=query, operation_name="LastHoursVolume", variables=variables, **kwargs + ) + data = self.get_data(response) + return LastHoursVolume.model_validate(data) + + async def totals(self, **kwargs: Any) -> Totals: + query = gql( + """ + query Totals { + totals { + tokens + orders + traders + settlements + volumeUsd + volumeEth + feesUsd + feesEth + } + } + """ + ) + variables: Dict[str, object] = {} + response = await self.execute( + query=query, operation_name="Totals", variables=variables, **kwargs + ) + data = self.get_data(response) + return Totals.model_validate(data) diff --git a/cow_py/subgraph/client/totals.py b/cow_py/subgraph/client/totals.py new file mode 100644 index 0000000..1686b3b --- /dev/null +++ b/cow_py/subgraph/client/totals.py @@ -0,0 +1,23 @@ +# Generated by ariadne-codegen +# Source: cow_py/subgraph/queries + +from typing import Any, List, Optional + +from pydantic import Field + +from .base_model import BaseModel + + +class Totals(BaseModel): + totals: List["TotalsTotals"] + + +class TotalsTotals(BaseModel): + tokens: Any + orders: Any + traders: Any + settlements: Any + volume_usd: Optional[Any] = Field(alias="volumeUsd") + volume_eth: Optional[Any] = Field(alias="volumeEth") + fees_usd: Optional[Any] = Field(alias="feesUsd") + fees_eth: Optional[Any] = Field(alias="feesEth") diff --git a/cow_py/subgraph/deployments.py b/cow_py/subgraph/deployments.py new file mode 100644 index 0000000..ce98ebc --- /dev/null +++ b/cow_py/subgraph/deployments.py @@ -0,0 +1,40 @@ +from dataclasses import dataclass +from enum import Enum + +from cow_py.common.chains import Chain + + +class SubgraphEnvironment(Enum): + PRODUCTION = "production" + STAGING = "staging" + + +SUBGRAPH_BASE_URL = "https://api.thegraph.com/subgraph/name/cowprotocol" + + +def build_subgraph_url( + chain: Chain = Chain.MAINNET, + env: SubgraphEnvironment = SubgraphEnvironment.PRODUCTION, +) -> str: + base_url = SUBGRAPH_BASE_URL + + network_suffix = "" if chain == Chain.MAINNET else "-gc" + env_suffix = "-" + env.value if env == SubgraphEnvironment.STAGING else "" + + if chain == Chain.SEPOLIA: + raise ValueError(f"Unsupported chain: {chain}") + + return f"{base_url}/cow{network_suffix}{env_suffix}" + + +@dataclass +class SubgraphConfig: + chain: Chain + + @property + def production(self) -> str: + return build_subgraph_url(self.chain, SubgraphEnvironment.PRODUCTION) + + @property + def staging(self) -> str: + return build_subgraph_url(self.chain, SubgraphEnvironment.STAGING) diff --git a/cow_py/subgraph/queries/lastDayVolume.gql b/cow_py/subgraph/queries/lastDayVolume.gql new file mode 100644 index 0000000..264c3b8 --- /dev/null +++ b/cow_py/subgraph/queries/lastDayVolume.gql @@ -0,0 +1,10 @@ +# /** +# * GraphQL query for the total volume over the last N days. +# * @param days The number of days to query. +# */ +query LastDaysVolume($days: Int!) { + dailyTotals(orderBy: timestamp, orderDirection: desc, first: $days) { + timestamp + volumeUsd + } +} diff --git a/cow_py/subgraph/queries/lastHoursVolume.gql b/cow_py/subgraph/queries/lastHoursVolume.gql new file mode 100644 index 0000000..882aa2e --- /dev/null +++ b/cow_py/subgraph/queries/lastHoursVolume.gql @@ -0,0 +1,10 @@ +# /** +# * GraphQL query for the total volume over the last N hours. +# * @param hours The number of hours to query. +# */ +query LastHoursVolume($hours: Int!) { + hourlyTotals(orderBy: timestamp, orderDirection: desc, first: $hours) { + timestamp + volumeUsd + } +} diff --git a/cow_py/subgraph/queries/totals.gql b/cow_py/subgraph/queries/totals.gql new file mode 100644 index 0000000..241aab9 --- /dev/null +++ b/cow_py/subgraph/queries/totals.gql @@ -0,0 +1,15 @@ +# /** +# * GraphQL query for the total number of tokens, orders, traders, settlements, volume, and fees. +# */ +query Totals { + totals { + tokens + orders + traders + settlements + volumeUsd + volumeEth + feesUsd + feesEth + } +} \ No newline at end of file diff --git a/tests/subgraph/__init__.py b/tests/subgraph/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/subgraph/client/test_subgraph_client.py b/tests/subgraph/client/test_subgraph_client.py new file mode 100644 index 0000000..6bc57e4 --- /dev/null +++ b/tests/subgraph/client/test_subgraph_client.py @@ -0,0 +1,466 @@ +import pytest +from pytest_httpx import HTTPXMock + +from cow_py.subgraph.client import SubgraphClient +from cow_py.subgraph.client.exceptions import GraphQLClientGraphQLMultiError +from cow_py.subgraph.client.last_days_volume import ( + LastDaysVolume, + LastDaysVolumeDailyTotals, +) +from cow_py.subgraph.client.last_hours_volume import ( + LastHoursVolume, + LastHoursVolumeHourlyTotals, +) +from cow_py.subgraph.client.totals import Totals, TotalsTotals + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "query_method, variables, mocked_response, expected_response", + [ + ( + "totals", + dict(), + { + "data": { + "totals": [ + { + "tokens": "192", + "orders": "365210", + "traders": "50731", + "settlements": "160092", + "volumeUsd": "49548634.23978489392550883815112596", + "volumeEth": "20349080.82753326160179174564685693", + "feesUsd": "1495.18088540037791409373835505834", + "feesEth": "632.7328748466552906975758491191759", + } + ] + } + }, + Totals( + totals=[ + TotalsTotals( + tokens="192", + orders="365210", + traders="50731", + settlements="160092", + volumeUsd="49548634.23978489392550883815112596", + volumeEth="20349080.82753326160179174564685693", + feesUsd="1495.18088540037791409373835505834", + feesEth="632.7328748466552906975758491191759", + ) + ] + ), + ), + ( + "last_days_volume", + dict(days=7), + { + "data": { + "dailyTotals": [ + { + "timestamp": "1651104000", + "volumeUsd": "32085.1639220805155999650325844739", + }, + { + "timestamp": "1651017600", + "volumeUsd": "34693.62007717297749801092930059675", + }, + { + "timestamp": "1650931200", + "volumeUsd": "33122.5365226034644783539316622137", + }, + { + "timestamp": "1650844800", + "volumeUsd": "44339.87713137673812392999146686429", + }, + { + "timestamp": "1650758400", + "volumeUsd": "33152.20678736108925012284114682263", + }, + { + "timestamp": "1650672000", + "volumeUsd": "74499.81969341967474378140565634503", + }, + { + "timestamp": "1650585600", + "volumeUsd": "55696.47839632449194353566942457261", + }, + ] + } + }, + LastDaysVolume( + dailyTotals=[ + LastDaysVolumeDailyTotals( + timestamp=1651104000, + volumeUsd="32085.1639220805155999650325844739", + ), + LastDaysVolumeDailyTotals( + timestamp=1651017600, + volumeUsd="34693.62007717297749801092930059675", + ), + LastDaysVolumeDailyTotals( + timestamp=1650931200, + volumeUsd="33122.5365226034644783539316622137", + ), + LastDaysVolumeDailyTotals( + timestamp=1650844800, + volumeUsd="44339.87713137673812392999146686429", + ), + LastDaysVolumeDailyTotals( + timestamp=1650758400, + volumeUsd="33152.20678736108925012284114682263", + ), + LastDaysVolumeDailyTotals( + timestamp=1650672000, + volumeUsd="74499.81969341967474378140565634503", + ), + LastDaysVolumeDailyTotals( + timestamp=1650585600, + volumeUsd="55696.47839632449194353566942457261", + ), + ] + ), + ), + ( + "last_hours_volume", + dict(hours=24), + { + "data": { + "hourlyTotals": [ + { + "timestamp": "1651186800", + "volumeUsd": "190.9404913756501392195019404899438", + }, + { + "timestamp": "1651183200", + "volumeUsd": "529.9946238000561779423929757743504", + }, + { + "timestamp": "1651179600", + "volumeUsd": "645.3587505699802324165958548720157", + }, + { + "timestamp": "1651176000", + "volumeUsd": "1708.483608648853800630669110444808", + }, + { + "timestamp": "1651172400", + "volumeUsd": "7121.457330823292680300996744986044", + }, + { + "timestamp": "1651168800", + "volumeUsd": "1821.297602760111978245784985569166", + }, + { + "timestamp": "1651165200", + "volumeUsd": "2785.484680212634326873580046251588", + }, + { + "timestamp": "1651161600", + "volumeUsd": "1969.469152211506355791899301692229", + }, + { + "timestamp": "1651158000", + "volumeUsd": "2162.897300873319012826008286358389", + }, + { + "timestamp": "1651154400", + "volumeUsd": "1513.553639465779399627761684465762", + }, + { + "timestamp": "1651150800", + "volumeUsd": "187.4730505008263524958136028913312", + }, + { + "timestamp": "1651147200", + "volumeUsd": "1003.733903282400166632845200890861", + }, + { + "timestamp": "1651143600", + "volumeUsd": "430.0861170487354094851133346726692", + }, + { + "timestamp": "1651140000", + "volumeUsd": "332.7800791403069749429589009477125", + }, + { + "timestamp": "1651136400", + "volumeUsd": "97.63235373438852625638744867165181", + }, + { + "timestamp": "1651132800", + "volumeUsd": "30.59818396279718981525514608110329", + }, + { + "timestamp": "1651129200", + "volumeUsd": "4891.57094852254524822966041865283", + }, + { + "timestamp": "1651125600", + "volumeUsd": "0.2822502035827220060153182158280592", + }, + { + "timestamp": "1651122000", + "volumeUsd": "2618.536314756480243120625177213215", + }, + { + "timestamp": "1651118400", + "volumeUsd": "188.6060152287524476251961231904293", + }, + { + "timestamp": "1651114800", + "volumeUsd": "1081.900497533608727191602938189487", + }, + { + "timestamp": "1651111200", + "volumeUsd": "189.2511347347182236433877630220942", + }, + { + "timestamp": "1651107600", + "volumeUsd": "443.7262478626930371100298278690119", + }, + { + "timestamp": "1651104000", + "volumeUsd": "240.7104588694898118223893758683719", + }, + ] + } + }, + LastHoursVolume( + hourlyTotals=[ + LastHoursVolumeHourlyTotals( + timestamp=1651186800, + volumeUsd="190.9404913756501392195019404899438", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651183200, + volumeUsd="529.9946238000561779423929757743504", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651179600, + volumeUsd="645.3587505699802324165958548720157", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651176000, + volumeUsd="1708.483608648853800630669110444808", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651172400, + volumeUsd="7121.457330823292680300996744986044", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651168800, + volumeUsd="1821.297602760111978245784985569166", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651165200, + volumeUsd="2785.484680212634326873580046251588", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651161600, + volumeUsd="1969.469152211506355791899301692229", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651158000, + volumeUsd="2162.897300873319012826008286358389", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651154400, + volumeUsd="1513.553639465779399627761684465762", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651150800, + volumeUsd="187.4730505008263524958136028913312", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651147200, + volumeUsd="1003.733903282400166632845200890861", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651143600, + volumeUsd="430.0861170487354094851133346726692", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651140000, + volumeUsd="332.7800791403069749429589009477125", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651136400, + volumeUsd="97.63235373438852625638744867165181", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651132800, + volumeUsd="30.59818396279718981525514608110329", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651129200, + volumeUsd="4891.57094852254524822966041865283", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651125600, + volumeUsd="0.2822502035827220060153182158280592", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651122000, + volumeUsd="2618.536314756480243120625177213215", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651118400, + volumeUsd="188.6060152287524476251961231904293", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651114800, + volumeUsd="1081.900497533608727191602938189487", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651111200, + volumeUsd="189.2511347347182236433877630220942", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651107600, + volumeUsd="443.7262478626930371100298278690119", + ), + LastHoursVolumeHourlyTotals( + timestamp=1651104000, + volumeUsd="240.7104588694898118223893758683719", + ), + ] + ), + ), + ], +) +async def test_subgraph_client_existing_queries( + httpx_mock: HTTPXMock, query_method, variables, mocked_response, expected_response +): + httpx_mock.add_response(json=mocked_response) + + client = SubgraphClient(url="https://test_url") + query = await getattr(client, query_method)(*variables) + + assert query == expected_response + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "query, mocked_response, expected_response", + [ + ( + """ + query TokensByVolume { + tokens(first: 5, orderBy: totalVolumeUsd, orderDirection: desc) { + address + symbol + totalVolumeUsd + priceUsd + } + } + """, + { + "data": { + "tokens": [ + { + "address": "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d", + "symbol": "WXDAI", + "totalVolumeUsd": "32889034.621839712648167717", + "priceUsd": "1", + }, + { + "address": "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83", + "symbol": "USDC", + "totalVolumeUsd": "31296380.98818012532887553375630894", + "priceUsd": "0.9983008873217955125012875742815512", + }, + { + "address": "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1", + "symbol": "WETH", + "totalVolumeUsd": "11313677.56406394346907690670613874", + "priceUsd": "2930.058705030603523831034274967579", + }, + { + "address": "0x4ecaba5870353805a9f068101a40e0f32ed605c6", + "symbol": "USDT", + "totalVolumeUsd": "9390602.813697073697851431730404586", + "priceUsd": "1.00560814041993584287438922806966", + }, + { + "address": "0x9c58bacc331c9aa871afd802db6379a98e80cedb", + "symbol": "GNO", + "totalVolumeUsd": "5667965.685777522243148118842046968", + "priceUsd": "327.4436350035803489070442497891915", + }, + ] + } + }, + { + "tokens": [ + { + "address": "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d", + "symbol": "WXDAI", + "totalVolumeUsd": "32889034.621839712648167717", + "priceUsd": "1", + }, + { + "address": "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83", + "symbol": "USDC", + "totalVolumeUsd": "31296380.98818012532887553375630894", + "priceUsd": "0.9983008873217955125012875742815512", + }, + { + "address": "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1", + "symbol": "WETH", + "totalVolumeUsd": "11313677.56406394346907690670613874", + "priceUsd": "2930.058705030603523831034274967579", + }, + { + "address": "0x4ecaba5870353805a9f068101a40e0f32ed605c6", + "symbol": "USDT", + "totalVolumeUsd": "9390602.813697073697851431730404586", + "priceUsd": "1.00560814041993584287438922806966", + }, + { + "address": "0x9c58bacc331c9aa871afd802db6379a98e80cedb", + "symbol": "GNO", + "totalVolumeUsd": "5667965.685777522243148118842046968", + "priceUsd": "327.4436350035803489070442497891915", + }, + ] + }, + ) + ], +) +async def test_subgraph_client_custom_query( + httpx_mock: HTTPXMock, query, mocked_response, expected_response +): + httpx_mock.add_response(json=mocked_response) + client = SubgraphClient(url="https://test_url") + response = await client.execute(query=query) + + assert client.get_data(response) == expected_response + + +@pytest.mark.asyncio +async def test_subgraph_client_invalid_query(httpx_mock: HTTPXMock): + httpx_mock.add_response( + json={ + "errors": [ + { + "locations": [{"line": 2, "column": 9}], + "message": "Type `Query` has no field `invalidQuery`", + } + ] + } + ) + query = """ + query InvalidQuery { + invalidQuery { + field1 + field2 + } + } + """ + client = SubgraphClient(url="https://test_url") + response = await client.execute(query=query) + + with pytest.raises(GraphQLClientGraphQLMultiError): + client.get_data(response) diff --git a/tests/subgraph/test_deployments.py b/tests/subgraph/test_deployments.py new file mode 100644 index 0000000..2fd097b --- /dev/null +++ b/tests/subgraph/test_deployments.py @@ -0,0 +1,44 @@ +import pytest + +from cow_py.common.chains import Chain +from cow_py.subgraph.deployments import ( + SUBGRAPH_BASE_URL, + SubgraphConfig, + SubgraphEnvironment, + build_subgraph_url, +) + + +def test_build_subgraph_url(): + assert ( + build_subgraph_url(Chain.MAINNET, SubgraphEnvironment.PRODUCTION) + == f"{SUBGRAPH_BASE_URL}/cow" + ) + assert ( + build_subgraph_url(Chain.MAINNET, SubgraphEnvironment.STAGING) + == f"{SUBGRAPH_BASE_URL}/cow-staging" + ) + assert ( + build_subgraph_url(Chain.GNOSIS, SubgraphEnvironment.PRODUCTION) + == f"{SUBGRAPH_BASE_URL}/cow-gc" + ) + assert ( + build_subgraph_url(Chain.GNOSIS, SubgraphEnvironment.STAGING) + == f"{SUBGRAPH_BASE_URL}/cow-gc-staging" + ) + + with pytest.raises(ValueError): + build_subgraph_url(Chain.SEPOLIA, SubgraphEnvironment.PRODUCTION) + + +def test_subgraph_config(): + mainnet_config = SubgraphConfig(Chain.MAINNET) + assert mainnet_config.production == f"{SUBGRAPH_BASE_URL}/cow" + assert mainnet_config.staging == f"{SUBGRAPH_BASE_URL}/cow-staging" + + gnosis_chain_config = SubgraphConfig(Chain.GNOSIS) + assert gnosis_chain_config.production == f"{SUBGRAPH_BASE_URL}/cow-gc" + assert gnosis_chain_config.staging == f"{SUBGRAPH_BASE_URL}/cow-gc-staging" + + with pytest.raises(ValueError): + SubgraphConfig(Chain.SEPOLIA).production From 9cf40215b16e88b25f000165456dfbcca2d10fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Thu, 25 Apr 2024 08:39:53 -0300 Subject: [PATCH 2/4] add contract abis --- cow_py/contracts/abi/Milkman.json | 140 ++++++++++++++++++++++++++++++ cow_py/contracts/abi/__init__.py | 0 2 files changed, 140 insertions(+) create mode 100644 cow_py/contracts/abi/Milkman.json create mode 100644 cow_py/contracts/abi/__init__.py diff --git a/cow_py/contracts/abi/Milkman.json b/cow_py/contracts/abi/Milkman.json new file mode 100644 index 0000000..d8b0488 --- /dev/null +++ b/cow_py/contracts/abi/Milkman.json @@ -0,0 +1,140 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "orderContract", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "orderCreator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "fromToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "toToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "priceChecker", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "priceCheckerData", + "type": "bytes" + } + ], + "name": "SwapRequested", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { + "internalType": "contract IERC20", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "toToken", + "type": "address" + }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "address", "name": "priceChecker", "type": "address" }, + { "internalType": "bytes", "name": "priceCheckerData", "type": "bytes" } + ], + "name": "cancelSwap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "fromToken", + "type": "address" + }, + { "internalType": "bytes32", "name": "_swapHash", "type": "bytes32" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "orderDigest", "type": "bytes32" }, + { "internalType": "bytes", "name": "encodedOrder", "type": "bytes" } + ], + "name": "isValidSignature", + "outputs": [{ "internalType": "bytes4", "name": "", "type": "bytes4" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { + "internalType": "contract IERC20", + "name": "fromToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "toToken", + "type": "address" + }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "address", "name": "priceChecker", "type": "address" }, + { "internalType": "bytes", "name": "priceCheckerData", "type": "bytes" } + ], + "name": "requestSwapExactTokensForTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "swapHash", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/cow_py/contracts/abi/__init__.py b/cow_py/contracts/abi/__init__.py new file mode 100644 index 0000000..e69de29 From e9a8acd7304b88a7c9128ebe3952468ae1431e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Thu, 25 Apr 2024 08:40:04 -0300 Subject: [PATCH 3/4] add generated codegen --- cow_py/codegen/__generated__/ComposableCow.py | 145 ++++++++++++++++++ .../ExtensibleFallbackHandler.py | 103 +++++++++++++ cow_py/codegen/__generated__/Milkman.py | 73 +++++++++ cow_py/codegen/__generated__/TWAP.py | 95 ++++++++++++ 4 files changed, 416 insertions(+) create mode 100644 cow_py/codegen/__generated__/ComposableCow.py create mode 100644 cow_py/codegen/__generated__/ExtensibleFallbackHandler.py create mode 100644 cow_py/codegen/__generated__/Milkman.py create mode 100644 cow_py/codegen/__generated__/TWAP.py diff --git a/cow_py/codegen/__generated__/ComposableCow.py b/cow_py/codegen/__generated__/ComposableCow.py new file mode 100644 index 0000000..fdfcfa5 --- /dev/null +++ b/cow_py/codegen/__generated__/ComposableCow.py @@ -0,0 +1,145 @@ +from dataclasses import dataclass +from typing import List, Tuple + +from hexbytes import HexBytes + +from cow_py.codegen.components import ( + BaseContract, + BaseMixin, + ContractFactory, + FileAbiLoader, + get_abi_file, +) +from cow_py.common.chains import Chain + + +@dataclass +class IConditionalOrder_ConditionalOrderParams: + handler: str + salt: HexBytes + staticInput: HexBytes + + +@dataclass +class ComposableCoW_Proof: + location: int + data: HexBytes + + +@dataclass +class GPv2Order_Data: + sellToken: str + buyToken: str + receiver: str + sellAmount: int + buyAmount: int + validTo: int + appData: HexBytes + feeAmount: int + kind: HexBytes + partiallyFillable: bool + sellTokenBalance: HexBytes + buyTokenBalance: HexBytes + + +class ComposableCowMixin(BaseMixin): + def cabinet(self, str_arg_0: str, hexbytes_arg_0: HexBytes) -> HexBytes: + return self.call_contract_method("cabinet", str_arg_0, hexbytes_arg_0) + + def create( + self, params: IConditionalOrder_ConditionalOrderParams, dispatch: bool + ) -> None: + return self.call_contract_method( + "create", (params.handler, params.salt, params.staticInput), dispatch + ) + + def create_with_context( + self, + params: IConditionalOrder_ConditionalOrderParams, + factory: str, + data: HexBytes, + dispatch: bool, + ) -> None: + return self.call_contract_method( + "createWithContext", + (params.handler, params.salt, params.staticInput), + factory, + data, + dispatch, + ) + + def domain_separator(self) -> HexBytes: + return self.call_contract_method("domainSeparator") + + def get_tradeable_order_with_signature( + self, + owner: str, + params: IConditionalOrder_ConditionalOrderParams, + offchain_input: HexBytes, + proof: List[HexBytes], + ) -> Tuple[GPv2Order_Data, HexBytes]: + return self.call_contract_method( + "getTradeableOrderWithSignature", + owner, + (params.handler, params.salt, params.staticInput), + offchain_input, + proof, + ) + + def hash(self, params: IConditionalOrder_ConditionalOrderParams) -> HexBytes: + return self.call_contract_method( + "hash", (params.handler, params.salt, params.staticInput) + ) + + def is_valid_safe_signature( + self, + safe: str, + sender: str, + _hash: HexBytes, + _domain_separator: HexBytes, + hexbytes_arg_0: HexBytes, + encode_data: HexBytes, + payload: HexBytes, + ) -> HexBytes: + return self.call_contract_method( + "isValidSafeSignature", + safe, + sender, + _hash, + _domain_separator, + hexbytes_arg_0, + encode_data, + payload, + ) + + def remove(self, single_order_hash: HexBytes) -> None: + return self.call_contract_method("remove", single_order_hash) + + def roots(self, str_arg_0: str) -> HexBytes: + return self.call_contract_method("roots", str_arg_0) + + def set_root(self, root: HexBytes, proof: ComposableCoW_Proof) -> None: + return self.call_contract_method("setRoot", root, (proof.location, proof.data)) + + def set_root_with_context( + self, root: HexBytes, proof: ComposableCoW_Proof, factory: str, data: HexBytes + ) -> None: + return self.call_contract_method( + "setRootWithContext", root, (proof.location, proof.data), factory, data + ) + + def set_swap_guard(self, swap_guard: str) -> None: + return self.call_contract_method("setSwapGuard", swap_guard) + + def single_orders(self, str_arg_0: str, hexbytes_arg_0: HexBytes) -> bool: + return self.call_contract_method("singleOrders", str_arg_0, hexbytes_arg_0) + + def swap_guards(self, str_arg_0: str) -> str: + return self.call_contract_method("swapGuards", str_arg_0) + + +class ComposableCow(BaseContract, ComposableCowMixin): + def __init__(self, chain: Chain = Chain.MAINNET, address: str = ""): + abi_loader = FileAbiLoader(get_abi_file("ComposableCow")) + contract = ContractFactory.create("ComposableCow", chain, address, abi_loader) + super(ComposableCow, self).__init__(address, chain, abi=contract.ABI) diff --git a/cow_py/codegen/__generated__/ExtensibleFallbackHandler.py b/cow_py/codegen/__generated__/ExtensibleFallbackHandler.py new file mode 100644 index 0000000..2492af1 --- /dev/null +++ b/cow_py/codegen/__generated__/ExtensibleFallbackHandler.py @@ -0,0 +1,103 @@ +from typing import List + +from hexbytes import HexBytes + +from cow_py.codegen.components import ( + BaseContract, + BaseMixin, + ContractFactory, + FileAbiLoader, + get_abi_file, +) +from cow_py.common.chains import Chain + + +class ExtensibleFallbackHandlerMixin(BaseMixin): + def domain_verifiers(self, str_arg_0: str, hexbytes_arg_0: HexBytes) -> str: + return self.call_contract_method("domainVerifiers", str_arg_0, hexbytes_arg_0) + + def is_valid_signature(self, _hash: HexBytes, signature: HexBytes) -> HexBytes: + return self.call_contract_method("isValidSignature", _hash, signature) + + def on_erc_1155_batch_received( + self, + str_arg_0: str, + str_arg_1: str, + int_list_arg_0: List[int], + int_list_arg_1: List[int], + hexbytes_arg_0: HexBytes, + ) -> HexBytes: + return self.call_contract_method( + "onERC1155BatchReceived", + str_arg_0, + str_arg_1, + int_list_arg_0, + int_list_arg_1, + hexbytes_arg_0, + ) + + def on_erc_1155_received( + self, + str_arg_0: str, + str_arg_1: str, + int_arg_0: int, + int_arg_1: int, + hexbytes_arg_0: HexBytes, + ) -> HexBytes: + return self.call_contract_method( + "onERC1155Received", + str_arg_0, + str_arg_1, + int_arg_0, + int_arg_1, + hexbytes_arg_0, + ) + + def on_erc_721_received( + self, str_arg_0: str, str_arg_1: str, int_arg_0: int, hexbytes_arg_0: HexBytes + ) -> HexBytes: + return self.call_contract_method( + "onERC721Received", str_arg_0, str_arg_1, int_arg_0, hexbytes_arg_0 + ) + + def safe_interfaces(self, str_arg_0: str, hexbytes_arg_0: HexBytes) -> bool: + return self.call_contract_method("safeInterfaces", str_arg_0, hexbytes_arg_0) + + def safe_methods(self, str_arg_0: str, hexbytes_arg_0: HexBytes) -> HexBytes: + return self.call_contract_method("safeMethods", str_arg_0, hexbytes_arg_0) + + def set_domain_verifier( + self, domain_separator: HexBytes, new_verifier: str + ) -> None: + return self.call_contract_method( + "setDomainVerifier", domain_separator, new_verifier + ) + + def set_safe_method(self, selector: HexBytes, new_method: HexBytes) -> None: + return self.call_contract_method("setSafeMethod", selector, new_method) + + def set_supported_interface(self, interface_id: HexBytes, supported: bool) -> None: + return self.call_contract_method( + "setSupportedInterface", interface_id, supported + ) + + def set_supported_interface_batch( + self, _interface_id: HexBytes, handler_with_selectors: List[HexBytes] + ) -> None: + return self.call_contract_method( + "setSupportedInterfaceBatch", _interface_id, handler_with_selectors + ) + + def supports_interface(self, interface_id: HexBytes) -> bool: + return self.call_contract_method("supportsInterface", interface_id) + + +class ExtensibleFallbackHandler(BaseContract, ExtensibleFallbackHandlerMixin): + def __init__(self, chain: Chain = Chain.MAINNET, address: str = ""): + abi_loader = FileAbiLoader(get_abi_file("ExtensibleFallbackHandler")) + contract = ContractFactory.create( + "ExtensibleFallbackHandler", chain, address, abi_loader + ) + super(ExtensibleFallbackHandler, self).__init__( + address, chain, abi=contract.ABI + ) diff --git a/cow_py/codegen/__generated__/Milkman.py b/cow_py/codegen/__generated__/Milkman.py new file mode 100644 index 0000000..5a35cee --- /dev/null +++ b/cow_py/codegen/__generated__/Milkman.py @@ -0,0 +1,73 @@ +from hexbytes import HexBytes + +from cow_py.codegen.components import ( + BaseContract, + BaseMixin, + ContractFactory, + FileAbiLoader, + get_abi_file, +) +from cow_py.common.chains import Chain + + +class MilkmanMixin(BaseMixin): + def domain_separator(self) -> HexBytes: + return self.call_contract_method("DOMAIN_SEPARATOR") + + def cancel_swap( + self, + amount_in: int, + from_token: str, + to_token: str, + to: str, + price_checker: str, + price_checker_data: HexBytes, + ) -> None: + return self.call_contract_method( + "cancelSwap", + amount_in, + from_token, + to_token, + to, + price_checker, + price_checker_data, + ) + + def initialize(self, from_token: str, _swap_hash: HexBytes) -> None: + return self.call_contract_method("initialize", from_token, _swap_hash) + + def is_valid_signature( + self, order_digest: HexBytes, encoded_order: HexBytes + ) -> HexBytes: + return self.call_contract_method( + "isValidSignature", order_digest, encoded_order + ) + + def request_swap_exact_tokens_for_tokens( + self, + amount_in: int, + from_token: str, + to_token: str, + to: str, + price_checker: str, + price_checker_data: HexBytes, + ) -> None: + return self.call_contract_method( + "requestSwapExactTokensForTokens", + amount_in, + from_token, + to_token, + to, + price_checker, + price_checker_data, + ) + + def swap_hash(self) -> HexBytes: + return self.call_contract_method("swapHash") + + +class Milkman(BaseContract, MilkmanMixin): + def __init__(self, chain: Chain = Chain.MAINNET, address: str = ""): + abi_loader = FileAbiLoader(get_abi_file("Milkman")) + contract = ContractFactory.create("Milkman", chain, address, abi_loader) + super(Milkman, self).__init__(address, chain, abi=contract.ABI) diff --git a/cow_py/codegen/__generated__/TWAP.py b/cow_py/codegen/__generated__/TWAP.py new file mode 100644 index 0000000..877acc5 --- /dev/null +++ b/cow_py/codegen/__generated__/TWAP.py @@ -0,0 +1,95 @@ +from dataclasses import dataclass + +from hexbytes import HexBytes + +from cow_py.codegen.components import ( + BaseContract, + BaseMixin, + ContractFactory, + FileAbiLoader, + get_abi_file, +) +from cow_py.common.chains import Chain + + +@dataclass +class IConditionalOrder_ConditionalOrderParams: + handler: str + salt: HexBytes + staticInput: HexBytes + + +@dataclass +class GPv2Order_Data: + sellToken: str + buyToken: str + receiver: str + sellAmount: int + buyAmount: int + validTo: int + appData: HexBytes + feeAmount: int + kind: HexBytes + partiallyFillable: bool + sellTokenBalance: HexBytes + buyTokenBalance: HexBytes + + +class TWAPMixin(BaseMixin): + def get_tradeable_order( + self, + owner: str, + str_arg_0: str, + ctx: HexBytes, + static_input: HexBytes, + hexbytes_arg_0: HexBytes, + ) -> GPv2Order_Data: + return self.call_contract_method( + "getTradeableOrder", owner, str_arg_0, ctx, static_input, hexbytes_arg_0 + ) + + def supports_interface(self, interface_id: HexBytes) -> bool: + return self.call_contract_method("supportsInterface", interface_id) + + def verify( + self, + owner: str, + sender: str, + _hash: HexBytes, + domain_separator: HexBytes, + ctx: HexBytes, + static_input: HexBytes, + offchain_input: HexBytes, + gpv_2order_data_arg_0: GPv2Order_Data, + ) -> None: + return self.call_contract_method( + "verify", + owner, + sender, + _hash, + domain_separator, + ctx, + static_input, + offchain_input, + ( + gpv_2order_data_arg_0.sellToken, + gpv_2order_data_arg_0.buyToken, + gpv_2order_data_arg_0.receiver, + gpv_2order_data_arg_0.sellAmount, + gpv_2order_data_arg_0.buyAmount, + gpv_2order_data_arg_0.validTo, + gpv_2order_data_arg_0.appData, + gpv_2order_data_arg_0.feeAmount, + gpv_2order_data_arg_0.kind, + gpv_2order_data_arg_0.partiallyFillable, + gpv_2order_data_arg_0.sellTokenBalance, + gpv_2order_data_arg_0.buyTokenBalance, + ), + ) + + +class TWAP(BaseContract, TWAPMixin): + def __init__(self, chain: Chain = Chain.MAINNET, address: str = ""): + abi_loader = FileAbiLoader(get_abi_file("TWAP")) + contract = ContractFactory.create("TWAP", chain, address, abi_loader) + super(TWAP, self).__init__(address, chain, abi=contract.ABI) From ca26b908465df612286d8eb1fb9e6da0e52f7378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Thu, 25 Apr 2024 08:40:10 -0300 Subject: [PATCH 4/4] add generated order_book --- cow_py/order_book/generated/model.py | 711 +++++++++++++++++++++++++++ 1 file changed, 711 insertions(+) create mode 100644 cow_py/order_book/generated/model.py diff --git a/cow_py/order_book/generated/model.py b/cow_py/order_book/generated/model.py new file mode 100644 index 0000000..5f5188f --- /dev/null +++ b/cow_py/order_book/generated/model.py @@ -0,0 +1,711 @@ +# generated by datamodel-codegen: +# filename: https://raw.githubusercontent.com/cowprotocol/services/v2.245.1/crates/orderbook/openapi.yml +# timestamp: 2024-04-12T14:44:16+00:00 + +from __future__ import annotations + +from enum import Enum +from typing import Any, Dict, List, Optional, Union + +from pydantic import BaseModel, Field, RootModel + + +class TransactionHash(RootModel[str]): + root: str = Field( + ..., + description="32 byte digest encoded as a hex with `0x` prefix.", + examples=["0xd51f28edffcaaa76be4a22f6375ad289272c037f3cc072345676e88d92ced8b5"], + ) + + +class Address(RootModel[str]): + root: str = Field( + ..., + description="20 byte Ethereum address encoded as a hex with `0x` prefix.", + examples=["0x6810e776880c02933d47db1b9fc05908e5386b96"], + ) + + +class AppData(RootModel[str]): + root: str = Field( + ..., + description="The string encoding of a JSON object representing some `appData`. The\nformat of the JSON expected in the `appData` field is defined\n[here](https://github.com/cowprotocol/app-data).\n", + examples=['{"version":"0.9.0","metadata":{}}'], + ) + + +class AppDataHash(RootModel[str]): + root: str = Field( + ..., + description="32 bytes encoded as hex with `0x` prefix.\nIt's expected to be the hash of the stringified JSON object representing the `appData`.\n", + examples=["0x0000000000000000000000000000000000000000000000000000000000000000"], + ) + + +class AppDataObject(BaseModel): + fullAppData: Optional[AppData] = None + + +class BigUint(RootModel[str]): + root: str = Field( + ..., + description="A big unsigned integer encoded in decimal.", + examples=["1234567890"], + ) + + +class CallData(RootModel[str]): + root: str = Field( + ..., + description="Some `calldata` sent to a contract in a transaction encoded as a hex with `0x` prefix.", + examples=["0xca11da7a"], + ) + + +class TokenAmount(RootModel[str]): + root: str = Field( + ..., + description="Amount of a token. `uint256` encoded in decimal.", + examples=["1234567890"], + ) + + +class PlacementError(Enum): + QuoteNotFound = "QuoteNotFound" + ValidToTooFarInFuture = "ValidToTooFarInFuture" + PreValidationError = "PreValidationError" + + +class OnchainOrderData(BaseModel): + sender: Address = Field( + ..., + description="If orders are placed as on-chain orders, the owner of the order might\nbe a smart contract, but not the user placing the order. The\nactual user will be provided in this field.\n", + ) + placementError: Optional[PlacementError] = Field( + None, + description="Describes the error, if the order placement was not successful. This could\nhappen, for example, if the `validTo` is too high, or no valid quote was\nfound or generated.\n", + ) + + +class EthflowData(BaseModel): + refundTxHash: TransactionHash = Field( + ..., + description="Specifies in which transaction the order was refunded. If\nthis field is null the order was not yet refunded.\n", + ) + userValidTo: int = Field( + ..., + description="Describes the `validTo` of an order ethflow order.\n\n**NOTE**: For ethflow orders, the `validTo` encoded in the smart\ncontract is `type(uint256).max`.\n", + ) + + +class OrderKind(Enum): + buy = "buy" + sell = "sell" + + +class OrderClass(Enum): + market = "market" + limit = "limit" + liquidity = "liquidity" + + +class SellTokenSource(Enum): + erc20 = "erc20" + internal = "internal" + external = "external" + + +class BuyTokenDestination(Enum): + erc20 = "erc20" + internal = "internal" + + +class PriceQuality(Enum): + fast = "fast" + optimal = "optimal" + verified = "verified" + + +class OrderStatus(Enum): + presignaturePending = "presignaturePending" + open = "open" + fulfilled = "fulfilled" + cancelled = "cancelled" + expired = "expired" + + +class ProtocolAppData(BaseModel): + pass + + +class AuctionPrices(RootModel[Optional[Dict[str, BigUint]]]): + root: Optional[Dict[str, BigUint]] = None + + +class UID(RootModel[str]): + root: str = Field( + ..., + description="Unique identifier for the order: 56 bytes encoded as hex with `0x` prefix.\nBytes 0..32 are the order digest, bytes 30..52 the owner address and bytes\n52..56 the expiry (`validTo`) as a `uint32` unix epoch timestamp.\n", + examples=[ + "0xff2e2e54d178997f173266817c1e9ed6fee1a1aae4b43971c53b543cffcc2969845c6f5599fbb25dbdd1b9b013daf85c03f3c63763e4bc4a" + ], + ) + + +class SigningScheme(Enum): + eip712 = "eip712" + ethsign = "ethsign" + presign = "presign" + eip1271 = "eip1271" + + +class EcdsaSigningScheme(Enum): + eip712 = "eip712" + ethsign = "ethsign" + + +class EcdsaSignature(RootModel[str]): + root: str = Field( + ..., + description="65 bytes encoded as hex with `0x` prefix. `r || s || v` from the spec.", + examples=[ + "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + ) + + +class PreSignature(RootModel[str]): + root: str = Field( + ..., + description='Empty signature bytes. Used for "presign" signatures.', + examples=["0x"], + ) + + +class ErrorType(Enum): + DuplicatedOrder = "DuplicatedOrder" + QuoteNotFound = "QuoteNotFound" + InvalidQuote = "InvalidQuote" + MissingFrom = "MissingFrom" + WrongOwner = "WrongOwner" + InvalidEip1271Signature = "InvalidEip1271Signature" + InsufficientBalance = "InsufficientBalance" + InsufficientAllowance = "InsufficientAllowance" + InvalidSignature = "InvalidSignature" + InsufficientFee = "InsufficientFee" + SellAmountOverflow = "SellAmountOverflow" + TransferSimulationFailed = "TransferSimulationFailed" + ZeroAmount = "ZeroAmount" + IncompatibleSigningScheme = "IncompatibleSigningScheme" + TooManyLimitOrders_UnsupportedBuyTokenDestination = ( + "TooManyLimitOrders UnsupportedBuyTokenDestination" + ) + UnsupportedSellTokenSource = "UnsupportedSellTokenSource" + UnsupportedOrderType = "UnsupportedOrderType" + InsufficientValidTo = "InsufficientValidTo" + ExcessiveValidTo = "ExcessiveValidTo" + InvalidNativeSellToken = "InvalidNativeSellToken" + SameBuyAndSellToken = "SameBuyAndSellToken" + UnsupportedToken = "UnsupportedToken" + InvalidAppData = "InvalidAppData" + AppDataHashMismatch = "AppDataHashMismatch" + AppdataFromMismatch = "AppdataFromMismatch" + + +class OrderPostError(BaseModel): + errorType: ErrorType + description: str + + +class ErrorType1(Enum): + InvalidSignature = "InvalidSignature" + WrongOwner = "WrongOwner" + OrderNotFound = "OrderNotFound" + AlreadyCancelled = "AlreadyCancelled" + OrderFullyExecuted = "OrderFullyExecuted" + OrderExpired = "OrderExpired" + OnChainOrder = "OnChainOrder" + + +class OrderCancellationError(BaseModel): + errorType: ErrorType1 + description: str + + +class ErrorType2(Enum): + AlreadyCancelled = "AlreadyCancelled" + OrderFullyExecuted = "OrderFullyExecuted" + OrderExpired = "OrderExpired" + OnChainOrder = "OnChainOrder" + DuplicatedOrder = "DuplicatedOrder" + InsufficientFee = "InsufficientFee" + InsufficientAllowance = "InsufficientAllowance" + InsufficientBalance = "InsufficientBalance" + InsufficientValidTo = "InsufficientValidTo" + ExcessiveValidTo = "ExcessiveValidTo" + InvalidSignature = "InvalidSignature" + TransferSimulationFailed = "TransferSimulationFailed" + UnsupportedToken = "UnsupportedToken" + WrongOwner = "WrongOwner" + SameBuyAndSellToken = "SameBuyAndSellToken" + ZeroAmount = "ZeroAmount" + UnsupportedBuyTokenDestination = "UnsupportedBuyTokenDestination" + UnsupportedSellTokenSource = "UnsupportedSellTokenSource" + UnsupportedOrderType = "UnsupportedOrderType" + + +class ReplaceOrderError(BaseModel): + errorType: ErrorType2 + description: str + + +class ErrorType3(Enum): + UnsupportedToken = "UnsupportedToken" + ZeroAmount = "ZeroAmount" + UnsupportedOrderType = "UnsupportedOrderType" + + +class PriceEstimationError(BaseModel): + errorType: ErrorType3 + description: str + + +class OrderQuoteSideKindSell(Enum): + sell = "sell" + + +class OrderQuoteSideKindBuy(Enum): + buy = "buy" + + +class OrderQuoteValidity1(BaseModel): + validTo: Optional[int] = Field( + None, description="Unix timestamp (`uint32`) until which the order is valid." + ) + + +class OrderQuoteValidity2(BaseModel): + validFor: Optional[int] = Field( + None, + description="Number (`uint32`) of seconds that the order should be valid for.", + ) + + +class OrderQuoteValidity(RootModel[Union[OrderQuoteValidity1, OrderQuoteValidity2]]): + root: Union[OrderQuoteValidity1, OrderQuoteValidity2] = Field( + ..., description="The validity for the order." + ) + + +class Objective(BaseModel): + total: Optional[float] = Field( + None, description="The total objective value used for ranking solutions." + ) + surplus: Optional[float] = None + fees: Optional[float] = None + cost: Optional[float] = None + gas: Optional[int] = None + + +class Order1(BaseModel): + id: Optional[UID] = None + executedAmount: Optional[BigUint] = None + + +class SolverSettlement(BaseModel): + solver: Optional[str] = Field(None, description="Name of the solver.") + solverAddress: Optional[str] = Field( + None, + description="The address used by the solver to execute the settlement on-chain.\nThis field is missing for old settlements, the zero address has been used instead.\n", + ) + objective: Optional[Objective] = None + score: Optional[BigUint] = Field( + None, + description="The score of the current auction as defined in [CIP-20](https://snapshot.org/#/cow.eth/proposal/0x2d3f9bd1ea72dca84b03e97dda3efc1f4a42a772c54bd2037e8b62e7d09a491f).\nIt is `null` for old auctions.\n", + ) + clearingPrices: Optional[Dict[str, BigUint]] = Field( + None, + description="The prices of tokens for settled user orders as passed to the settlement contract.\n", + ) + orders: Optional[List[Order1]] = Field(None, description="Touched orders.") + callData: Optional[CallData] = Field( + None, + description="Transaction `calldata` that is executed on-chain if the settlement is executed.", + ) + uninternalizedCallData: Optional[CallData] = Field( + None, + description="Full `calldata` as generated from the original solver output.\n\nIt can be different from the executed transaction if part of the settlements are internalised\n(use internal liquidity in lieu of trading against on-chain liquidity).\n\nThis field is omitted in case it coincides with `callData`.\n", + ) + + +class NativePriceResponse(BaseModel): + price: Optional[float] = Field(None, description="Estimated price of the token.") + + +class TotalSurplus(BaseModel): + totalSurplus: Optional[str] = Field(None, description="The total surplus.") + + +class InteractionData(BaseModel): + target: Optional[Address] = None + value: Optional[TokenAmount] = None + call_data: Optional[List[CallData]] = Field( + None, description="The call data to be used for the interaction." + ) + + +class Surplus(BaseModel): + factor: float + max_volume_factor: float + + +class Volume(BaseModel): + factor: float + + +class FeePolicy(RootModel[Union[Surplus, Volume]]): + root: Union[Surplus, Volume] = Field( + ..., description="Defines the ways to calculate the protocol fee." + ) + + +class OrderParameters(BaseModel): + sellToken: Address = Field(..., description="ERC-20 token to be sold.") + buyToken: Address = Field(..., description="ERC-20 token to be bought.") + receiver: Optional[Address] = Field( + None, + description="An optional Ethereum address to receive the proceeds of the trade instead\nof the owner (i.e. the order signer).\n", + ) + sellAmount: TokenAmount = Field( + ..., description="Amount of `sellToken` to be sold in atoms." + ) + buyAmount: TokenAmount = Field( + ..., description="Amount of `buyToken` to be bought in atoms." + ) + validTo: int = Field( + ..., description="Unix timestamp (`uint32`) until which the order is valid." + ) + appData: AppDataHash + feeAmount: TokenAmount = Field( + ..., description="feeRatio * sellAmount + minimal_fee in atoms." + ) + kind: OrderKind = Field(..., description="The kind is either a buy or sell order.") + partiallyFillable: bool = Field( + ..., description="Is the order fill-or-kill or partially fillable?" + ) + sellTokenBalance: Optional[SellTokenSource] = "erc20" + buyTokenBalance: Optional[BuyTokenDestination] = "erc20" + signingScheme: Optional[SigningScheme] = "eip712" + + +class OrderMetaData(BaseModel): + creationDate: str = Field( + ..., + description="Creation time of the order. Encoded as ISO 8601 UTC.", + examples=["2020-12-03T18:35:18.814523Z"], + ) + class_: OrderClass = Field(..., alias="class") + owner: Address + uid: UID + availableBalance: Optional[TokenAmount] = Field( + None, + description="Unused field that is currently always set to `null` and will be removed in the future.\n", + ) + executedSellAmount: BigUint = Field( + ..., + description="The total amount of `sellToken` that has been executed for this order including fees.\n", + ) + executedSellAmountBeforeFees: BigUint = Field( + ..., + description="The total amount of `sellToken` that has been executed for this order without fees.\n", + ) + executedBuyAmount: BigUint = Field( + ..., + description="The total amount of `buyToken` that has been executed for this order.\n", + ) + executedFeeAmount: BigUint = Field( + ..., + description="The total amount of fees that have been executed for this order.", + ) + invalidated: bool = Field(..., description="Has this order been invalidated?") + status: OrderStatus = Field(..., description="Order status.") + fullFeeAmount: Optional[TokenAmount] = Field( + None, description="Amount that the signed fee would be without subsidies." + ) + isLiquidityOrder: Optional[bool] = Field( + None, + description="Liquidity orders are functionally the same as normal smart contract orders but are not\nplaced with the intent of actively getting traded. Instead they facilitate the\ntrade of normal orders by allowing them to be matched against liquidity orders which\nuses less gas and can have better prices than external liquidity.\n\nAs such liquidity orders will only be used in order to improve settlement of normal\norders. They should not be expected to be traded otherwise and should not expect to get\nsurplus.\n", + ) + ethflowData: Optional[EthflowData] = None + onchainUser: Optional[Address] = Field( + None, + description="This represents the actual trader of an on-chain order.\n\n### ethflow orders\n\nIn this case, the `owner` would be the `EthFlow` contract and *not* the actual trader.\n", + ) + onchainOrderData: Optional[OnchainOrderData] = Field( + None, + description="There is some data only available for orders that are placed on-chain. This data\ncan be found in this object.\n", + ) + executedSurplusFee: Optional[BigUint] = Field( + None, description="Surplus fee that the limit order was executed with." + ) + fullAppData: Optional[str] = Field( + None, + description="Full `appData`, which the contract-level `appData` is a hash of. See `OrderCreation`\nfor more information.\n", + ) + + +class CompetitionAuction(BaseModel): + orders: Optional[List[UID]] = Field( + None, description="The UIDs of the orders included in the auction.\n" + ) + prices: Optional[AuctionPrices] = None + + +class OrderCancellations(BaseModel): + orderUids: Optional[List[UID]] = Field( + None, description="UIDs of orders to cancel." + ) + signature: EcdsaSignature = Field( + ..., description="`OrderCancellation` signed by the owner." + ) + signingScheme: EcdsaSigningScheme + + +class OrderCancellation(BaseModel): + signature: EcdsaSignature = Field( + ..., description="OrderCancellation signed by owner" + ) + signingScheme: EcdsaSigningScheme + + +class Trade(BaseModel): + blockNumber: int = Field(..., description="Block in which trade occurred.") + logIndex: int = Field( + ..., description="Index in which transaction was included in block." + ) + orderUid: UID = Field(..., description="UID of the order matched by this trade.") + owner: Address = Field(..., description="Address of trader.") + sellToken: Address = Field(..., description="Address of token sold.") + buyToken: Address = Field(..., description="Address of token bought.") + sellAmount: TokenAmount = Field( + ..., + description="Total amount of `sellToken` that has been executed for this trade (including fees).", + ) + sellAmountBeforeFees: BigUint = Field( + ..., + description="The total amount of `sellToken` that has been executed for this order without fees.", + ) + buyAmount: TokenAmount = Field( + ..., description="Total amount of `buyToken` received in this trade." + ) + txHash: TransactionHash = Field( + ..., + description="Transaction hash of the corresponding settlement transaction containing the trade (if available).", + ) + + +class Signature(RootModel[Union[EcdsaSignature, PreSignature]]): + root: Union[EcdsaSignature, PreSignature] = Field(..., description="A signature.") + + +class OrderQuoteSide1(BaseModel): + kind: OrderQuoteSideKindSell + sellAmountBeforeFee: TokenAmount = Field( + ..., + description="The total amount that is available for the order. From this value, the fee\nis deducted and the buy amount is calculated.\n", + ) + + +class OrderQuoteSide2(BaseModel): + kind: OrderQuoteSideKindSell + sellAmountAfterFee: TokenAmount = Field( + ..., description="The `sellAmount` for the order." + ) + + +class OrderQuoteSide3(BaseModel): + kind: OrderQuoteSideKindBuy + buyAmountAfterFee: TokenAmount = Field( + ..., description="The `buyAmount` for the order." + ) + + +class OrderQuoteSide( + RootModel[Union[OrderQuoteSide1, OrderQuoteSide2, OrderQuoteSide3]] +): + root: Union[OrderQuoteSide1, OrderQuoteSide2, OrderQuoteSide3] = Field( + ..., description="The buy or sell side when quoting an order." + ) + + +class OrderQuoteRequest(BaseModel): + sellToken: Address = Field(..., description="ERC-20 token to be sold") + buyToken: Address = Field(..., description="ERC-20 token to be bought") + receiver: Optional[Address] = Field( + None, + description="An optional address to receive the proceeds of the trade instead of the\n`owner` (i.e. the order signer).\n", + ) + appData: Optional[Union[AppData, AppDataHash]] = Field( + None, + description="AppData which will be assigned to the order.\nExpects either a string JSON doc as defined on [AppData](https://github.com/cowprotocol/app-data) or a\nhex encoded string for backwards compatibility.\nWhen the first format is used, it's possible to provide the derived appDataHash field.\n", + ) + appDataHash: Optional[AppDataHash] = Field( + None, + description="The hash of the stringified JSON appData doc.\nIf present, `appData` field must be set with the aforementioned data where this hash is derived from.\nIn case they differ, the call will fail.\n", + ) + sellTokenBalance: Optional[SellTokenSource] = "erc20" + buyTokenBalance: Optional[BuyTokenDestination] = "erc20" + from_: Address = Field(..., alias="from") + priceQuality: Optional[PriceQuality] = "verified" + signingScheme: Optional[SigningScheme] = "eip712" + onchainOrder: Optional[Any] = Field( + False, + description='Flag to signal whether the order is intended for on-chain order placement. Only valid\nfor non ECDSA-signed orders."\n', + ) + + +class OrderQuoteResponse(BaseModel): + quote: OrderParameters + from_: Optional[Address] = Field(None, alias="from") + expiration: str = Field( + ..., + description="Expiration date of the offered fee. Order service might not accept\nthe fee after this expiration date. Encoded as ISO 8601 UTC.\n", + examples=["1985-03-10T18:35:18.814523Z"], + ) + id: Optional[int] = Field( + None, + description="Quote ID linked to a quote to enable providing more metadata when analysing\norder slippage.\n", + ) + verified: bool = Field( + ..., + description="Whether it was possible to verify that the quoted amounts are accurate using a simulation.\n", + ) + + +class SolverCompetitionResponse(BaseModel): + auctionId: Optional[int] = Field( + None, description="The ID of the auction the competition info is for." + ) + transactionHash: Optional[TransactionHash] = Field( + None, + description="The hash of the transaction that the winning solution of this info was submitted in.", + ) + gasPrice: Optional[float] = Field( + None, description="Gas price used for ranking solutions." + ) + liquidityCollectedBlock: Optional[int] = None + competitionSimulationBlock: Optional[int] = None + auction: Optional[CompetitionAuction] = None + solutions: Optional[List[SolverSettlement]] = Field( + None, + description="Maps from solver name to object describing that solver's settlement.", + ) + + +class OrderCreation(BaseModel): + sellToken: Address = Field(..., description="see `OrderParameters::sellToken`") + buyToken: Address = Field(..., description="see `OrderParameters::buyToken`") + receiver: Optional[Address] = Field( + None, description="see `OrderParameters::receiver`" + ) + sellAmount: TokenAmount = Field( + ..., description="see `OrderParameters::sellAmount`" + ) + buyAmount: TokenAmount = Field(..., description="see `OrderParameters::buyAmount`") + validTo: int = Field(..., description="see `OrderParameters::validTo`") + feeAmount: TokenAmount = Field(..., description="see `OrderParameters::feeAmount`") + kind: OrderKind = Field(..., description="see `OrderParameters::kind`") + partiallyFillable: bool = Field( + ..., description="see `OrderParameters::partiallyFillable`" + ) + sellTokenBalance: Optional[SellTokenSource] = Field( + "erc20", description="see `OrderParameters::sellTokenBalance`" + ) + buyTokenBalance: Optional[BuyTokenDestination] = Field( + "erc20", description="see `OrderParameters::buyTokenBalance`" + ) + signingScheme: SigningScheme + signature: Signature + from_: Optional[Address] = Field( + None, + alias="from", + description="If set, the backend enforces that this address matches what is decoded as the *signer* of\nthe signature. This helps catch errors with invalid signature encodings as the backend\nmight otherwise silently work with an unexpected address that for example does not have\nany balance.\n", + ) + quoteId: Optional[int] = Field( + None, + description="Orders can optionally include a quote ID. This way the order can be linked to a quote\nand enable providing more metadata when analysing order slippage.\n", + ) + appData: Union[AppData, AppDataHash] = Field( + ..., + description="This field comes in two forms for backward compatibility. The hash form will eventually \nstop being accepted.\n", + ) + appDataHash: Optional[AppDataHash] = Field( + None, + description="May be set for debugging purposes. If set, this field is compared to what the backend\ninternally calculates as the app data hash based on the contents of `appData`. If the\nhash does not match, an error is returned. If this field is set, then `appData` **MUST** be\na string encoding of a JSON object.\n", + ) + + +class Order(OrderCreation, OrderMetaData): + pass + + +class AuctionOrder(BaseModel): + uid: UID + sellToken: Address = Field(..., description="see `OrderParameters::sellToken`") + buyToken: Address = Field(..., description="see `OrderParameters::buyToken`") + sellAmount: TokenAmount = Field( + ..., description="see `OrderParameters::sellAmount`" + ) + buyAmount: TokenAmount = Field(..., description="see `OrderParameters::buyAmount`") + userFee: TokenAmount = Field(..., description="see `OrderParameters::feeAmount`") + validTo: int = Field(..., description="see `OrderParameters::validTo`") + kind: OrderKind = Field(..., description="see `OrderParameters::kind`") + receiver: Address = Field(..., description="see `OrderParameters::receiver`") + owner: Address + partiallyFillable: bool = Field( + ..., description="see `OrderParameters::partiallyFillable`" + ) + executed: TokenAmount = Field( + ..., + description="Currently executed amount of sell/buy token, depending on the order kind.\n", + ) + preInteractions: List[InteractionData] = Field( + ..., + description="The pre-interactions that need to be executed before the first execution of the order.\n", + ) + postInteractions: List[InteractionData] = Field( + ..., + description="The post-interactions that need to be executed after the execution of the order.\n", + ) + sellTokenBalance: SellTokenSource = Field( + ..., description="see `OrderParameters::sellTokenBalance`" + ) + buyTokenBalance: BuyTokenDestination = Field( + ..., description="see `OrderParameters::buyTokenBalance`" + ) + class_: OrderClass = Field(..., alias="class") + appData: AppDataHash + signature: Signature + protocolFees: List[FeePolicy] = Field( + ..., + description="The fee policies that are used to compute the protocol fees for this order.\n", + ) + + +class Auction(BaseModel): + id: Optional[int] = Field( + None, + description="The unique identifier of the auction. Increment whenever the backend creates a new auction.\n", + ) + block: Optional[int] = Field( + None, + description="The block number for the auction. Orders and prices are guaranteed to be valid on this\nblock. Proposed settlements should be valid for this block as well.\n", + ) + latestSettlementBlock: Optional[int] = Field( + None, + description="The latest block on which a settlement has been processed.\n\n**NOTE**: Under certain conditions it is possible for a settlement to have been mined as\npart of `block` but not have yet been processed.\n", + ) + orders: Optional[List[AuctionOrder]] = Field( + None, description="The solvable orders included in the auction.\n" + ) + prices: Optional[AuctionPrices] = None