From 176f9064a6cc372e2f9388c31b7add84b2bdae53 Mon Sep 17 00:00:00 2001 From: zarathustra Date: Sat, 20 Sep 2025 22:54:20 +0200 Subject: [PATCH 1/6] feat: download OpenAPI specs --- scripts/generate-models.py | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 scripts/generate-models.py diff --git a/scripts/generate-models.py b/scripts/generate-models.py new file mode 100644 index 00000000..e31432e0 --- /dev/null +++ b/scripts/generate-models.py @@ -0,0 +1,70 @@ +import json +import re +from pathlib import Path + +import requests +from requests.adapters import HTTPAdapter +from urllib3.util.retry import Retry + +TIMEOUT = 10 + + +def make_session_with_retries( + total: int = 3, + backoff_factor: float = 0.3, + status_forcelist: tuple = (500, 502, 504), + allowed_methods: tuple = ("GET", "POST"), +) -> requests.Session: + session = requests.Session() + retries = Retry( + total=total, + backoff_factor=backoff_factor, + status_forcelist=status_forcelist, + allowed_methods=allowed_methods, + raise_on_status=False, + ) + adapter = HTTPAdapter(max_retries=retries) + session.mount("https://", adapter) + session.mount("http://", adapter) + return session + + +def download_openapi_specs(base_url: str, dest_dir: Path) -> list[Path]: + dest_dir.mkdir(parents=True, exist_ok=True) + index_url = f"{base_url}/openapi" + + with make_session_with_retries() as session: + print(f"Fetching OpenAPI index: {index_url}") + resp = session.get(index_url, timeout=TIMEOUT) + resp.raise_for_status() + html = resp.text + + text_pattern = r']*href="(/openapi/[^"]+)"[^>]*>([^<]+)' + matches = re.findall(text_pattern, html) + + if not matches: + raise RuntimeError(f"No openapi links found at {index_url}") + + saved_files = [] + for href, text in matches: + spec_url = base_url + href + print(f"Downloading: {spec_url}") + resp = session.get(spec_url, timeout=TIMEOUT) + resp.raise_for_status() + file_name = text.replace(" ", "").replace(".", "_") + file_path = (openapi_specs_path / file_name).with_suffix(".json") + file_path.write_text(json.dumps(resp.json(), indent=2)) + saved_files.append(file_path) + print(f"Saved OpenAPI spec at: {file_path}") + + return saved_files + + +if __name__ == "__main__": + base_url = "https://docs.derive.xyz" + repo_root = Path(__file__).parent.parent + + openapi_specs_path = repo_root / "derive_client" / "data" / "openapi" + openapi_specs_path.mkdir(exist_ok=True) + + files = download_openapi_specs(base_url=base_url, dest_dir=openapi_specs_path) From 3e66ea316a1e5831a3b6103168fc2926730c81af Mon Sep 17 00:00:00 2001 From: zarathustra Date: Sat, 20 Sep 2025 22:56:43 +0200 Subject: [PATCH 2/6] feat: generate pydantic models from OpenAPI spec --- scripts/generate-models.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/generate-models.py b/scripts/generate-models.py index e31432e0..6bd030be 100644 --- a/scripts/generate-models.py +++ b/scripts/generate-models.py @@ -3,6 +3,7 @@ from pathlib import Path import requests +from datamodel_code_generator import DataModelType, InputFileType, PythonVersion, generate from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry @@ -60,6 +61,23 @@ def download_openapi_specs(base_url: str, dest_dir: Path) -> list[Path]: return saved_files +def generate_models(input_path: Path, output_path: Path): + print(f"Generating models from {input_path.name} -> {output_path}") + generate( + input_=input_path, + input_file_type=InputFileType.OpenAPI, + output=output_path, + output_model_type=DataModelType.PydanticV2BaseModel, + target_python_version=PythonVersion.PY_310, + reuse_model=True, + use_subclass_enum=True, + strict_nullable=True, + use_double_quotes=True, + field_constraints=True, + ) + print(f"Models generated at: {output_path}") + + if __name__ == "__main__": base_url = "https://docs.derive.xyz" repo_root = Path(__file__).parent.parent @@ -68,3 +86,11 @@ def download_openapi_specs(base_url: str, dest_dir: Path) -> list[Path]: openapi_specs_path.mkdir(exist_ok=True) files = download_openapi_specs(base_url=base_url, dest_dir=openapi_specs_path) + + input_path = next((p for p in files if "latest" in p.stem.lower()), None) + if input_path is None: + available = ", ".join(p.name for p in files) + raise RuntimeError(f"No 'latest' spec found among downloaded files: {available}") + + output_path = repo_root / "derive_client" / "_clients" / "models.py" + generate_models(input_path=input_path, output_path=output_path) From 3152ac1125ed770f2dbcf258400c9cadcccb8f1e Mon Sep 17 00:00:00 2001 From: zarathustra Date: Sun, 21 Sep 2025 00:01:46 +0200 Subject: [PATCH 3/6] chore: generate pydantic models from OpenAPI spec --- derive_client/_clients/models.py | 5879 ++++++++++++++++++++++++++++++ 1 file changed, 5879 insertions(+) create mode 100644 derive_client/_clients/models.py diff --git a/derive_client/_clients/models.py b/derive_client/_clients/models.py new file mode 100644 index 00000000..9d04b27a --- /dev/null +++ b/derive_client/_clients/models.py @@ -0,0 +1,5879 @@ +# generated by datamodel-codegen: +# filename: RESTAPI-v2_0-latest.json +# timestamp: 2025-09-20T20:37:05+00:00 + +from __future__ import annotations + +from decimal import Decimal +from enum import Enum +from typing import Any, Dict, List, Optional, Union +from uuid import UUID + +from pydantic import BaseModel, ConfigDict, Field + + +class Status(Enum): + unseen = "unseen" + seen = "seen" + hidden = "hidden" + + +class TypeEnum(Enum): + deposit = "deposit" + withdraw = "withdraw" + transfer = "transfer" + trade = "trade" + settlement = "settlement" + liquidation = "liquidation" + custom = "custom" + + +class PrivateGetNotificationsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + page: Optional[int] = Field(1, description="Page number of results to return", title="page") + page_size: Optional[int] = Field( + 50, + description="Number of results per page (must be between 0-50)", + title="page_size", + ) + status: Optional[Status] = Field(None, description="Status of the notification", title="status") + subaccount_id: Optional[int] = Field( + None, + description="Subaccount_id (must be set if wallet param is not set)", + title="subaccount_id", + ) + type: Optional[List[TypeEnum]] = Field(None, description="List of notification types to filter by", title="type") + wallet: Optional[str] = Field( + None, + description="Wallet address (if set, subaccount_id ignored)", + title="wallet", + ) + + +class NotificationResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + event: str = Field( + ..., + description="The specific event leading to the notification.", + title="event", + ) + event_details: Dict[str, Any] = Field( + ..., + description="A JSON-structured dictionary containing detailed data or context about the event.", + title="event_details", + ) + id: int = Field(..., description="The unique identifier for the notification.", title="id") + status: str = Field( + ..., + description="The status of the notification, indicating if it has been read, pending, or processed.", + title="status", + ) + subaccount_id: int = Field( + ..., + description="The subaccount_id associated with the notification.", + title="subaccount_id", + ) + timestamp: int = Field( + ..., + description="The timestamp indicating when the notification was created or triggered.", + title="timestamp", + ) + transaction_id: Optional[int] = Field( + None, + description="The transaction id associated with the notification.", + title="transaction_id", + ) + tx_hash: Optional[str] = Field( + None, + description="The transaction hash associated with the notification.", + title="tx_hash", + ) + + +class PaginationInfoSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + count: int = Field(..., description="Total number of items, across all pages", title="count") + num_pages: int = Field(..., description="Number of pages", title="num_pages") + + +class PublicGetCurrencyParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field( + ..., + description="Underlying currency of asset (`ETH`, `BTC`, etc)", + title="currency", + ) + + +class InstrumentType(Enum): + erc20 = "erc20" + option = "option" + perp = "perp" + + +class MarketType(Enum): + ALL = "ALL" + SRM_BASE_ONLY = "SRM_BASE_ONLY" + SRM_OPTION_ONLY = "SRM_OPTION_ONLY" + SRM_PERP_ONLY = "SRM_PERP_ONLY" + CASH = "CASH" + + +class OpenInterestStatsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + current_open_interest: Decimal = Field( + ..., + description="Current open interest for the margin type", + title="current_open_interest", + ) + interest_cap: Decimal = Field(..., description="Total open interest cap", title="interest_cap") + manager_currency: Optional[str] = Field( + None, + description="Currency of the manager (only applies to Portfolio Margin)", + title="manager_currency", + ) + + +class MarginType(Enum): + PM = "PM" + SM = "SM" + PM2 = "PM2" + + +class ManagerContractResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + address: str = Field(..., description="Address of the manager", title="address") + currency: Optional[str] = Field( + None, + description="Currency of the manager (only applies to portfolio managers)", + title="currency", + ) + margin_type: MarginType = Field(..., description="Margin type of the manager", title="margin_type") + + +class PM2CollateralDiscountsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + im_discount: Decimal = Field( + ..., + description="Initial Margin discount for given collateral in PM2", + title="im_discount", + ) + manager_currency: str = Field(..., description="Currency of the manager", title="manager_currency") + mm_discount: Decimal = Field( + ..., + description="Maintenance Margin discount for given collateral in PM2", + title="mm_discount", + ) + + +class ProtocolAssetAddressesSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + option: Optional[str] = Field( + None, + description="Address of the Derive protocol option contract (none if not supported)", + title="option", + ) + perp: Optional[str] = Field( + None, + description="Address of the Derive protocol perp contract (none if not supported)", + title="perp", + ) + spot: Optional[str] = Field( + None, + description="Address of the Derive protocol spot contract (none if not supported)", + title="spot", + ) + underlying_erc20: Optional[str] = Field( + None, + description="Address of the erc20 asset on Derive chain. This is the asset that is deposited into the spot asset", + title="underlying_erc20", + ) + + +class PrivateSetMmpConfigParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency of this mmp config", title="currency") + mmp_amount_limit: Decimal = Field( + "0", + description="Maximum total order amount that can be traded within the mmp_interval across all instruments of the provided currency. The amounts are not netted, so a filled bid of 1 and a filled ask of 2 would count as 3.
Default: 0 (no limit)", + title="mmp_amount_limit", + ) + mmp_delta_limit: Decimal = Field( + "0", + description="Maximum total delta that can be traded within the mmp_interval across all instruments of the provided currency. This quantity is netted, so a filled order with +1 delta and a filled order with -2 delta would count as -1
Default: 0 (no limit)", + title="mmp_delta_limit", + ) + mmp_frozen_time: int = Field( + ..., + description="Time interval in ms setting how long the subaccount is frozen after an mmp trigger, if 0 then a manual reset would be required via private/reset_mmp", + title="mmp_frozen_time", + ) + mmp_interval: int = Field( + ..., + description="Time interval in ms over which the limits are monotored, if 0 then mmp is disabled", + title="mmp_interval", + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to set the config", + title="subaccount_id", + ) + + +PrivateSetMmpConfigResultSchema = PrivateSetMmpConfigParamsSchema + + +class Direction(Enum): + buy = "buy" + sell = "sell" + + +class TradeModuleParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") + direction: Direction = Field(..., description="Order direction", title="direction") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + limit_price: Decimal = Field( + ..., + description="Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.", + title="limit_price", + ) + max_fee: Decimal = Field( + ..., + description="Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.", + title="max_fee", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.", + title="nonce", + ) + signature: str = Field(..., description="Ethereum signature of the order", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed order", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class CancelReason(Enum): + field_ = "" + user_request = "user_request" + mmp_trigger = "mmp_trigger" + insufficient_margin = "insufficient_margin" + signed_max_fee_too_low = "signed_max_fee_too_low" + cancel_on_disconnect = "cancel_on_disconnect" + ioc_or_market_partial_fill = "ioc_or_market_partial_fill" + session_key_deregistered = "session_key_deregistered" + subaccount_withdrawn = "subaccount_withdrawn" + compliance = "compliance" + trigger_failed = "trigger_failed" + validation_failed = "validation_failed" + + +class OrderStatus(Enum): + open = "open" + filled = "filled" + cancelled = "cancelled" + expired = "expired" + untriggered = "untriggered" + + +class OrderType(Enum): + limit = "limit" + market = "market" + + +class TimeInForce(Enum): + gtc = "gtc" + post_only = "post_only" + fok = "fok" + ioc = "ioc" + + +class TriggerPriceType(Enum): + mark = "mark" + index = "index" + + +class TriggerType(Enum): + stoploss = "stoploss" + takeprofit = "takeprofit" + + +class OrderResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") + average_price: Decimal = Field(..., description="Average fill price", title="average_price") + cancel_reason: CancelReason = Field( + ..., + description="If cancelled, reason behind order cancellation", + title="cancel_reason", + ) + creation_timestamp: int = Field( + ..., + description="Creation timestamp (in ms since Unix epoch)", + title="creation_timestamp", + ) + direction: Direction = Field(..., description="Order direction", title="direction") + filled_amount: Decimal = Field(..., description="Total filled amount for the order", title="filled_amount") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + is_transfer: bool = Field( + ..., + description="Whether the order was generated through `private/transfer_position`", + title="is_transfer", + ) + label: str = Field(..., description="Optional user-defined label for the order", title="label") + last_update_timestamp: int = Field( + ..., + description="Last update timestamp (in ms since Unix epoch)", + title="last_update_timestamp", + ) + limit_price: Decimal = Field(..., description="Limit price in quote currency", title="limit_price") + max_fee: Decimal = Field(..., description="Max fee in units of the quote currency", title="max_fee") + mmp: bool = Field( + ..., + description="Whether the order is tagged for market maker protections", + title="mmp", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + order_fee: Decimal = Field(..., description="Total order fee paid so far", title="order_fee") + order_id: str = Field(..., description="Order ID", title="order_id") + order_status: OrderStatus = Field(..., description="Order status", title="order_status") + order_type: OrderType = Field(..., description="Order type", title="order_type") + quote_id: Optional[UUID] = Field(..., description="Quote ID if the trade was executed via RFQ", title="quote_id") + replaced_order_id: Optional[UUID] = Field( + None, + description="If replaced, ID of the order that was replaced", + title="replaced_order_id", + ) + signature: str = Field(..., description="Ethereum signature of the order", title="signature") + signature_expiry_sec: int = Field(..., description="Signature expiry timestamp", title="signature_expiry_sec") + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed order", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + time_in_force: TimeInForce = Field(..., description="Time in force", title="time_in_force") + trigger_price: Optional[Decimal] = Field( + None, + description="(Required for trigger orders) Index or Market price to trigger order at", + title="trigger_price", + ) + trigger_price_type: Optional[TriggerPriceType] = Field( + None, + description="(Required for trigger orders) Trigger with Index or Mark Price", + title="trigger_price_type", + ) + trigger_reject_message: Optional[str] = Field( + None, + description="(Required for trigger orders) Error message if error occured during trigger", + title="trigger_reject_message", + ) + trigger_type: Optional[TriggerType] = Field( + None, + description="(Required for trigger orders) Stop-loss or Take-profit.", + title="trigger_type", + ) + + +class LiquidityRole(Enum): + maker = "maker" + taker = "taker" + + +class TxStatus(Enum): + requested = "requested" + pending = "pending" + settled = "settled" + reverted = "reverted" + ignored = "ignored" + timed_out = "timed_out" + + +class TradeResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + direction: Direction = Field(..., description="Order direction", title="direction") + expected_rebate: Decimal = Field(..., description="Expected rebate for this trade", title="expected_rebate") + index_price: Decimal = Field( + ..., + description="Index price of the underlying at the time of the trade", + title="index_price", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + is_transfer: bool = Field( + ..., + description="Whether the trade was generated through `private/transfer_position`", + title="is_transfer", + ) + label: str = Field(..., description="Optional user-defined label for the order", title="label") + liquidity_role: LiquidityRole = Field(..., description="Role of the user in the trade", title="liquidity_role") + mark_price: Decimal = Field( + ..., + description="Mark price of the instrument at the time of the trade", + title="mark_price", + ) + order_id: str = Field(..., description="Order ID", title="order_id") + quote_id: Optional[UUID] = Field(..., description="Quote ID if the trade was executed via RFQ", title="quote_id") + realized_pnl: Decimal = Field(..., description="Realized PnL for this trade", title="realized_pnl") + realized_pnl_excl_fees: Decimal = Field( + ..., + description="Realized PnL for this trade using cost accounting that excludes fees", + title="realized_pnl_excl_fees", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + timestamp: int = Field(..., description="Trade timestamp (in ms since Unix epoch)", title="timestamp") + trade_amount: Decimal = Field(..., description="Amount filled in this trade", title="trade_amount") + trade_fee: Decimal = Field(..., description="Fee for this trade", title="trade_fee") + trade_id: str = Field(..., description="Trade ID", title="trade_id") + trade_price: Decimal = Field(..., description="Price at which the trade was filled", title="trade_price") + transaction_id: str = Field( + ..., + description="The transaction id of the related settlement transaction", + title="transaction_id", + ) + tx_hash: Optional[str] = Field(..., description="Blockchain transaction hash", title="tx_hash") + tx_status: TxStatus = Field(..., description="Blockchain transaction status", title="tx_status") + + +class PrivateCreateSubaccountParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") + asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") + currency: Optional[str] = Field( + None, + description="Base currency of the subaccount (only for `PM`)", + title="currency", + ) + margin_type: MarginType = Field( + ..., + description="`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", + title="margin_type", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature: str = Field(..., description="Ethereum signature of the deposit", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the deposit", + title="signer", + ) + wallet: str = Field(..., description="Ethereum wallet address", title="wallet") + + +class PrivateCreateSubaccountResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + status: str = Field(..., description="`requested`", title="status") + transaction_id: UUID = Field(..., description="Transaction id of the request", title="transaction_id") + + +class LegUnpricedSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount in units of the base", title="amount") + direction: Direction = Field(..., description="Leg direction", title="direction") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + + +class CancelReason1(Enum): + field_ = "" + user_request = "user_request" + insufficient_margin = "insufficient_margin" + signed_max_fee_too_low = "signed_max_fee_too_low" + mmp_trigger = "mmp_trigger" + cancel_on_disconnect = "cancel_on_disconnect" + session_key_deregistered = "session_key_deregistered" + subaccount_withdrawn = "subaccount_withdrawn" + rfq_no_longer_open = "rfq_no_longer_open" + compliance = "compliance" + + +class Status1(Enum): + open = "open" + filled = "filled" + cancelled = "cancelled" + expired = "expired" + + +class PrivateSendRfqResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + ask_total_cost: Optional[Decimal] = Field( + ..., + description="Ask total cost for the RFQ implied from orderbook (as `sell`)", + title="ask_total_cost", + ) + bid_total_cost: Optional[Decimal] = Field( + ..., + description="Bid total cost for the RFQ implied from orderbook (as `buy`)", + title="bid_total_cost", + ) + cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") + counterparties: Optional[List[str]] = Field( + ..., + description="List of requested counterparties, if applicable", + title="counterparties", + ) + creation_timestamp: int = Field( + ..., + description="Creation timestamp in ms since Unix epoch", + title="creation_timestamp", + ) + filled_direction: Optional[Direction] = Field( + ..., + description="Direction at which the RFQ was filled (only if filled)", + title="filled_direction", + ) + filled_pct: Decimal = Field( + ..., + description="Percentage of the RFQ that has been filled, from 0 to 1.", + title="filled_pct", + ) + label: str = Field(..., description="User-defined label, if any", title="label") + last_update_timestamp: int = Field( + ..., + description="Last update timestamp in ms since Unix epoch", + title="last_update_timestamp", + ) + legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") + mark_total_cost: Optional[Decimal] = Field( + ..., + description="Mark total cost for the RFQ (assuming `buy` direction)", + title="mark_total_cost", + ) + max_total_cost: Optional[Decimal] = Field(..., description="Max total cost for the RFQ", title="max_total_cost") + min_total_cost: Optional[Decimal] = Field(..., description="Min total cost for the RFQ", title="min_total_cost") + partial_fill_step: Decimal = Field( + ..., + description="Step size for partial fills (default: 1)", + title="partial_fill_step", + ) + rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") + status: Status1 = Field(..., description="Status", title="status") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + total_cost: Optional[Decimal] = Field( + ..., description="Total cost for the RFQ (only if filled)", title="total_cost" + ) + valid_until: int = Field( + ..., + description="RFQ expiry timestamp in ms since Unix epoch", + title="valid_until", + ) + + +class PublicMarginWatchParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + force_onchain: bool = Field( + False, + description="Force the fetching of on-chain balances, default False.", + title="force_onchain", + ) + subaccount_id: int = Field(..., description="Subaccount ID to get margin for.", title="subaccount_id") + + +class CollateralPublicResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Asset amount of given collateral", title="amount") + asset_name: str = Field(..., description="Asset name", title="asset_name") + asset_type: InstrumentType = Field( + ..., + description="Type of asset collateral (currently always `erc20`)", + title="asset_type", + ) + initial_margin: Decimal = Field( + ..., + description="USD value of collateral that contributes to initial margin", + title="initial_margin", + ) + maintenance_margin: Decimal = Field( + ..., + description="USD value of collateral that contributes to maintenance margin", + title="maintenance_margin", + ) + mark_price: Decimal = Field(..., description="Current mark price of the asset", title="mark_price") + mark_value: Decimal = Field( + ..., + description="USD value of the collateral (amount * mark price)", + title="mark_value", + ) + + +class PositionPublicResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Position amount held by subaccount", title="amount") + delta: Decimal = Field( + ..., + description="Asset delta (w.r.t. forward price for options, `1.0` for perps)", + title="delta", + ) + gamma: Decimal = Field(..., description="Asset gamma (zero for non-options)", title="gamma") + index_price: Decimal = Field( + ..., + description="Current index (oracle) price for position's currency", + title="index_price", + ) + initial_margin: Decimal = Field( + ..., + description="USD initial margin requirement for this position", + title="initial_margin", + ) + instrument_name: str = Field( + ..., + description="Instrument name (same as the base Asset name)", + title="instrument_name", + ) + instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") + liquidation_price: Optional[Decimal] = Field( + ..., + description="Index price at which position will be liquidated", + title="liquidation_price", + ) + maintenance_margin: Decimal = Field( + ..., + description="USD maintenance margin requirement for this position", + title="maintenance_margin", + ) + mark_price: Decimal = Field( + ..., + description="Current mark price for position's instrument", + title="mark_price", + ) + mark_value: Decimal = Field( + ..., + description="USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price", + title="mark_value", + ) + theta: Decimal = Field(..., description="Asset theta (zero for non-options)", title="theta") + vega: Decimal = Field(..., description="Asset vega (zero for non-options)", title="vega") + + +class PublicStatisticsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: Optional[str] = Field(None, description="Currency for stats", title="currency") + end_time: Optional[int] = Field(None, description="End time for statistics in ms", title="end_time") + instrument_name: str = Field( + ..., + description="Instrument name or 'ALL', 'OPTION', 'PERP', 'SPOT'", + title="instrument_name", + ) + + +class PublicStatisticsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + daily_fees: Decimal = Field(..., description="24h Fees", title="daily_fees") + daily_notional_volume: Decimal = Field(..., description="24h Notional volume", title="daily_notional_volume") + daily_premium_volume: Decimal = Field(..., description="24h Premium volume", title="daily_premium_volume") + daily_trades: int = Field(..., description="24h Trades", title="daily_trades") + open_interest: Decimal = Field(..., description="Open interest", title="open_interest") + total_fees: Decimal = Field(..., description="Total fees", title="total_fees") + total_notional_volume: Decimal = Field(..., description="Total notional volume", title="total_notional_volume") + total_premium_volume: Decimal = Field(..., description="Total premium volume", title="total_premium_volume") + total_trades: int = Field(..., description="Total trades", title="total_trades") + + +class PublicLoginParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + signature: str = Field( + ..., + description="Signature of the timestamp, signed with the wallet's private key or a session key", + title="signature", + ) + timestamp: str = Field( + ..., + description="Message that was signed, in the form of a timestamp in ms since Unix epoch", + title="timestamp", + ) + wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") + + +class PublicLoginResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[int] = Field( + ..., + description="List of subaccount IDs that have been authenticated", + title="result", + ) + + +class PrivateCancelParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instrument_name: str = Field(..., title="instrument_name") + order_id: UUID = Field(..., title="order_id") + subaccount_id: int = Field(..., title="subaccount_id") + + +PrivateCancelResultSchema = OrderResponseSchema + + +class LegPricedSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount in units of the base", title="amount") + direction: Direction = Field(..., description="Leg direction", title="direction") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + price: Decimal = Field(..., description="Leg price", title="price") + + +class PrivateExecuteQuoteResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") + creation_timestamp: int = Field( + ..., + description="Creation timestamp in ms since Unix epoch", + title="creation_timestamp", + ) + direction: Direction = Field(..., description="Quote direction", title="direction") + fee: Decimal = Field(..., description="Fee paid for this quote (if executed)", title="fee") + fill_pct: Decimal = Field( + ..., + description="Percentage of the RFQ that this quote would fill, from 0 to 1.", + title="fill_pct", + ) + is_transfer: bool = Field( + ..., + description="Whether the order was generated through `private/transfer_position`", + title="is_transfer", + ) + label: str = Field(..., description="User-defined label, if any", title="label") + last_update_timestamp: int = Field( + ..., + description="Last update timestamp in ms since Unix epoch", + title="last_update_timestamp", + ) + legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") + legs_hash: str = Field( + ..., + description="Hash of the legs of the best quote to be signed by the taker.", + title="legs_hash", + ) + liquidity_role: LiquidityRole = Field(..., description="Liquidity role", title="liquidity_role") + max_fee: Decimal = Field(..., description="Signed max fee", title="max_fee") + mmp: bool = Field( + ..., + description="Whether the quote is tagged for market maker protections (default false)", + title="mmp", + ) + nonce: int = Field(..., description="Nonce", title="nonce") + quote_id: UUID = Field(..., description="Quote ID", title="quote_id") + rfq_filled_pct: Decimal = Field( + ..., + description="Total percentage of the RFQ that has already been filled after this execution, from 0 to 1.", + title="rfq_filled_pct", + ) + rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") + signature: str = Field(..., description="Ethereum signature of the quote", title="signature") + signature_expiry_sec: int = Field(..., description="Unix timestamp in seconds", title="signature_expiry_sec") + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed the quote", + title="signer", + ) + status: Status1 = Field(..., description="Status", title="status") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + tx_hash: Optional[str] = Field( + ..., + description="Blockchain transaction hash (only for executed quotes)", + title="tx_hash", + ) + tx_status: Optional[TxStatus] = Field( + ..., + description="Blockchain transaction status (only for executed quotes)", + title="tx_status", + ) + + +class Period(Enum): + field_60 = 60 + field_300 = 300 + field_900 = 900 + field_1800 = 1800 + field_3600 = 3600 + field_14400 = 14400 + field_28800 = 28800 + field_86400 = 86400 + field_604800 = 604800 + + +class PublicGetSpotFeedHistoryCandlesParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency", title="currency") + end_timestamp: int = Field(..., description="End timestamp", title="end_timestamp") + period: Period = Field(..., description="Period", title="period") + start_timestamp: int = Field(..., description="Start timestamp", title="start_timestamp") + + +class SpotFeedHistoryCandlesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + close_price: Decimal = Field(..., description="Close price", title="close_price") + high_price: Decimal = Field(..., description="High price", title="high_price") + low_price: Decimal = Field(..., description="Low price", title="low_price") + open_price: Decimal = Field(..., description="Open price", title="open_price") + price: Decimal = Field(..., description="Spot price", title="price") + timestamp: int = Field( + ..., + description="Timestamp of when the spot price was recored into the database", + title="timestamp", + ) + timestamp_bucket: int = Field( + ..., + description="Timestamp bucket; this value is regularly spaced out with `period` seconds between data points, missing values are forward-filled from earlier data where possible, if no earlier data is available, values are back-filled from the first observed data point", + title="timestamp_bucket", + ) + + +class PrivatePollRfqsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + from_timestamp: int = Field( + 0, + description="Earliest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to 0.", + title="from_timestamp", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + rfq_id: Optional[UUID] = Field(None, description="RFQ ID filter, if applicable", title="rfq_id") + rfq_subaccount_id: Optional[int] = Field( + None, + description="Filter returned RFQs by rfq requestor subaccount", + title="rfq_subaccount_id", + ) + status: Optional[Status1] = Field(None, description="RFQ status filter, if applicable", title="status") + subaccount_id: int = Field( + ..., + description="Subaccount ID for auth purposes, returned data will be scoped to this subaccount.", + title="subaccount_id", + ) + to_timestamp: int = Field( + 18446744073709552000, + description="Latest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", + title="to_timestamp", + ) + + +class RFQResultPublicSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") + creation_timestamp: int = Field( + ..., + description="Creation timestamp in ms since Unix epoch", + title="creation_timestamp", + ) + filled_direction: Optional[Direction] = Field( + ..., + description="Direction at which the RFQ was filled (only if filled)", + title="filled_direction", + ) + filled_pct: Decimal = Field( + ..., + description="Percentage of the RFQ that has been filled, from 0 to 1.", + title="filled_pct", + ) + last_update_timestamp: int = Field( + ..., + description="Last update timestamp in ms since Unix epoch", + title="last_update_timestamp", + ) + legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") + partial_fill_step: Decimal = Field( + ..., + description="Step size for partial fills (default: 1)", + title="partial_fill_step", + ) + rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") + status: Status1 = Field(..., description="Status", title="status") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + total_cost: Optional[Decimal] = Field( + ..., description="Total cost for the RFQ (only if filled)", title="total_cost" + ) + valid_until: int = Field( + ..., + description="RFQ expiry timestamp in ms since Unix epoch", + title="valid_until", + ) + + +class PrivateGetLiquidationHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field( + 9223372036854776000, + description="End timestamp of the event history (default current time)", + title="end_timestamp", + ) + start_timestamp: int = Field( + 0, + description="Start timestamp of the event history (default 0)", + title="start_timestamp", + ) + subaccount_id: int = Field(..., description="Subaccount id", title="subaccount_id") + + +class AuctionType(Enum): + solvent = "solvent" + insolvent = "insolvent" + + +class AuctionBidEventSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amounts_liquidated: Dict[str, Decimal] = Field( + ..., + description="Amounts of each asset that were closed", + title="amounts_liquidated", + ) + cash_received: Decimal = Field( + ..., + description="Cash received by the subaccount for the liquidation. For the liquidated accounts this is the amount the liquidator paid to buy out the percentage of the portfolio. For the liquidator account, this is the amount they received from the security module (if positive) or the amount they paid for the bid (if negative)", + title="cash_received", + ) + discount_pnl: Decimal = Field( + ..., + description="Realized PnL due to liquidating or being liquidated at a discount to mark portfolio value", + title="discount_pnl", + ) + percent_liquidated: Decimal = Field( + ..., + description="Percent of the subaccount that was liquidated", + title="percent_liquidated", + ) + positions_realized_pnl: Dict[str, Decimal] = Field( + ..., + description="Realized PnL of each position that was closed", + title="positions_realized_pnl", + ) + positions_realized_pnl_excl_fees: Dict[str, Decimal] = Field( + ..., + description="Realized PnL of each position that was closed, excluding fees from total cost basis", + title="positions_realized_pnl_excl_fees", + ) + realized_pnl: Decimal = Field( + ..., + description="Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation", + title="realized_pnl", + ) + realized_pnl_excl_fees: Decimal = Field( + ..., + description="Realized PnL of the auction bid, excluding fees from total cost basis, assuming positions are closed at mark price at the time of the liquidation", + title="realized_pnl_excl_fees", + ) + timestamp: int = Field( + ..., + description="Timestamp of the bid (in ms since UNIX epoch)", + title="timestamp", + ) + tx_hash: str = Field(..., description="Hash of the bid transaction", title="tx_hash") + + +class PrivateOrderDebugParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") + direction: Direction = Field(..., description="Order direction", title="direction") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + is_atomic_signing: Optional[bool] = Field( + False, + description="Used by vaults to determine whether the signature is an EIP-1271 signature.", + title="is_atomic_signing", + ) + label: str = Field("", description="Optional user-defined label for the order", title="label") + limit_price: Decimal = Field( + ..., + description="Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.", + title="limit_price", + ) + max_fee: Decimal = Field( + ..., + description="Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.", + title="max_fee", + ) + mmp: bool = Field( + False, + description="Whether the order is tagged for market maker protections (default false)", + title="mmp", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.", + title="nonce", + ) + order_type: OrderType = Field( + "limit", + description="Order type:
- `limit`: limit order (default)
- `market`: market order, note that limit_price is still required for market orders, but unfilled order portion will be marked as cancelled", + title="order_type", + ) + reduce_only: bool = Field( + False, + description="If true, the order will not be able to increase position's size (default false). If the order amount exceeds available position size, the order will be filled up to the position size and the remainder will be cancelled. This flag is only supported for market orders or non-resting limit orders (IOC or FOK)", + title="reduce_only", + ) + referral_code: str = Field("", description="Optional referral code for the order", title="referral_code") + reject_timestamp: int = Field( + 9223372036854776000, + description="UTC timestamp in ms, if provided the matching engine will reject the order with an error if `reject_timestamp` < `server_time`. Note that the timestamp must be consistent with the server time: use `public/get_time` method to obtain current server time.", + title="reject_timestamp", + ) + signature: str = Field(..., description="Ethereum signature of the order", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed order", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + time_in_force: TimeInForce = Field( + "gtc", + description="Time in force behaviour:
- `gtc`: good til cancelled (default)
- `post_only`: a limit order that will be rejected if it crosses any order in the book, i.e. acts as a taker order
- `fok`: fill or kill, will be rejected if it is not fully filled
- `ioc`: immediate or cancel, fill at best bid/ask (market) or at limit price (limit), the unfilled portion is cancelled
Note that the order will still expire on the `signature_expiry_sec` timestamp.", + title="time_in_force", + ) + trigger_price: Optional[Decimal] = Field( + None, + description='(Required for trigger orders) "index" or "mark" price to trigger order at', + title="trigger_price", + ) + trigger_price_type: Optional[TriggerPriceType] = Field( + None, + description='(Required for trigger orders) Trigger with "mark" price as "index" price type not supported yet.', + title="trigger_price_type", + ) + trigger_type: Optional[TriggerType] = Field( + None, + description='(Required for trigger orders) "stoploss" or "takeprofit"', + title="trigger_type", + ) + + +class TradeModuleDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + asset: str = Field(..., title="asset") + desired_amount: Decimal = Field(..., title="desired_amount") + is_bid: bool = Field(..., title="is_bid") + limit_price: Decimal = Field(..., title="limit_price") + recipient_id: int = Field(..., title="recipient_id") + sub_id: int = Field(..., title="sub_id") + trade_id: str = Field(..., title="trade_id") + worst_fee: Decimal = Field(..., title="worst_fee") + + +class PrivateDepositParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") + asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") + is_atomic_signing: bool = Field( + False, + description="Used by vaults to determine whether the signature is an EIP-1271 signature", + title="is_atomic_signing", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature: str = Field(..., description="Ethereum signature of the deposit", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the deposit", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PrivateDepositResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + status: str = Field(..., description="`requested`", title="status") + transaction_id: UUID = Field(..., description="Transaction id of the deposit", title="transaction_id") + + +class PrivateUpdateNotificationsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + notification_ids: List[int] = Field( + ..., + description="List of notification IDs to be marked as seen", + title="notification_ids", + ) + status: Status = Field("seen", description="Status of the notification", title="status") + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PrivateUpdateNotificationsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + updated_count: int = Field(..., description="Number of notifications marked as seen", title="updated_count") + + +class PrivateChangeSubaccountLabelParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + label: str = Field(..., description="User defined label", title="label") + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +PrivateChangeSubaccountLabelResultSchema = PrivateChangeSubaccountLabelParamsSchema + + +class SignedQuoteParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + direction: Direction = Field( + ..., + description="Quote direction, `buy` means trading each leg at its direction, `sell` means trading each leg in the opposite direction.", + title="direction", + ) + legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") + max_fee: Decimal = Field( + ..., + description="Max fee ($ for the full trade). Request will be rejected if the supplied max fee is below the estimated fee for this trade.", + title="max_fee", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as a concatenated `UTC timestamp in ms` and `random number up to 6 digits` (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature: str = Field(..., description="Ethereum signature of the quote", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be at least 310 seconds from now. Once time till signature expiry reaches 300 seconds, the quote will be considered expired. This buffer is meant to ensure the trade can settle on chain in case of a blockchain congestion.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed the quote", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class QuoteResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") + creation_timestamp: int = Field( + ..., + description="Creation timestamp in ms since Unix epoch", + title="creation_timestamp", + ) + direction: Direction = Field(..., description="Quote direction", title="direction") + fee: Decimal = Field(..., description="Fee paid for this quote (if executed)", title="fee") + fill_pct: Decimal = Field( + ..., + description="Percentage of the RFQ that this quote would fill, from 0 to 1.", + title="fill_pct", + ) + is_transfer: bool = Field( + ..., + description="Whether the order was generated through `private/transfer_position`", + title="is_transfer", + ) + label: str = Field(..., description="User-defined label, if any", title="label") + last_update_timestamp: int = Field( + ..., + description="Last update timestamp in ms since Unix epoch", + title="last_update_timestamp", + ) + legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") + legs_hash: str = Field( + ..., + description="Hash of the legs of the best quote to be signed by the taker.", + title="legs_hash", + ) + liquidity_role: LiquidityRole = Field(..., description="Liquidity role", title="liquidity_role") + max_fee: Decimal = Field(..., description="Signed max fee", title="max_fee") + mmp: bool = Field( + ..., + description="Whether the quote is tagged for market maker protections (default false)", + title="mmp", + ) + nonce: int = Field(..., description="Nonce", title="nonce") + quote_id: UUID = Field(..., description="Quote ID", title="quote_id") + rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") + signature: str = Field(..., description="Ethereum signature of the quote", title="signature") + signature_expiry_sec: int = Field(..., description="Unix timestamp in seconds", title="signature_expiry_sec") + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed the quote", + title="signer", + ) + status: Status1 = Field(..., description="Status", title="status") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + tx_hash: Optional[str] = Field( + ..., + description="Blockchain transaction hash (only for executed quotes)", + title="tx_hash", + ) + tx_status: Optional[TxStatus] = Field( + ..., + description="Blockchain transaction status (only for executed quotes)", + title="tx_status", + ) + + +class PublicGetMakerProgramsParamsSchema(BaseModel): + pass + model_config = ConfigDict( + extra="forbid", + ) + + +class ProgramResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + asset_types: List[str] = Field( + ..., + description="List of asset types covered by the program", + title="asset_types", + ) + currencies: List[str] = Field(..., description="List of currencies covered by the program", title="currencies") + end_timestamp: int = Field(..., description="End timestamp of the epoch", title="end_timestamp") + min_notional: Decimal = Field( + ..., + description="Minimum dollar notional to quote for eligibility", + title="min_notional", + ) + name: str = Field(..., description="Name of the program", title="name") + rewards: Dict[str, Decimal] = Field( + ..., + description="Rewards for the program as a token -> total reward amount mapping", + title="rewards", + ) + start_timestamp: int = Field(..., description="Start timestamp of the epoch", title="start_timestamp") + + +class SimulatedCollateralSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Collateral amount to simulate", title="amount") + asset_name: str = Field( + ..., + description="Collateral ERC20 asset name (e.g. ETH, USDC, WSTETH)", + title="asset_name", + ) + + +class SimulatedPositionSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Position amount to simulate", title="amount") + entry_price: Optional[Decimal] = Field( + None, + description="Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + title="entry_price", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + + +class PublicGetMarginResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + is_valid_trade: bool = Field( + ..., + description="True if trade passes margin requirement", + title="is_valid_trade", + ) + post_initial_margin: Decimal = Field( + ..., + description="Initial margin requirement post trade", + title="post_initial_margin", + ) + post_maintenance_margin: Decimal = Field( + ..., + description="Maintenance margin requirement post trade", + title="post_maintenance_margin", + ) + pre_initial_margin: Decimal = Field( + ..., + description="Initial margin requirement before trade", + title="pre_initial_margin", + ) + pre_maintenance_margin: Decimal = Field( + ..., + description="Maintenance margin requirement before trade", + title="pre_maintenance_margin", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PrivateCancelByNonceParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + nonce: int = Field(..., description="Cancel an order with this nonce", title="nonce") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + wallet: str = Field(..., description="Wallet address", title="wallet") + + +class PrivateCancelByNonceResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancelled_orders: int = Field(..., description="Number of cancelled orders", title="cancelled_orders") + + +class PublicGetSpotFeedHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency", title="currency") + end_timestamp: int = Field(..., description="End timestamp", title="end_timestamp") + period: int = Field(..., description="Period", title="period") + start_timestamp: int = Field(..., description="Start timestamp", title="start_timestamp") + + +class SpotFeedHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + price: Decimal = Field(..., description="Spot price", title="price") + timestamp: int = Field( + ..., + description="Timestamp of when the spot price was recored into the database", + title="timestamp", + ) + timestamp_bucket: int = Field( + ..., + description="Timestamp bucket; this value is regularly spaced out with `period` seconds between data points, missing values are forward-filled from earlier data where possible, if no earlier data is available, values are back-filled from the first observed data point", + title="timestamp_bucket", + ) + + +class PrivateGetSubaccountsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") + + +class PrivateGetSubaccountsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_ids: List[int] = Field( + ..., + description="List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + title="subaccount_ids", + ) + wallet: str = Field(..., description="Ethereum wallet address", title="wallet") + + +PrivateGetDepositHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema + + +class DepositSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount deposited by the subaccount", title="amount") + asset: str = Field(..., description="Asset deposited", title="asset") + error_log: Optional[Dict[str, Any]] = Field(..., description="If failed, error log for reason", title="error_log") + timestamp: int = Field( + ..., + description="Timestamp of the deposit (in ms since UNIX epoch)", + title="timestamp", + ) + transaction_id: UUID = Field(..., description="Transaction ID", title="transaction_id") + tx_hash: str = Field( + ..., + description="Hash of the transaction that deposited the funds", + title="tx_hash", + ) + tx_status: TxStatus = Field( + ..., + description="Status of the transaction that deposited the funds", + title="tx_status", + ) + + +class PrivateCancelByLabelParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instrument_name: Optional[str] = Field( + None, + description="Instrument name. If not provided, all orders for all instruments with the label will be cancelled. If provided, request counts as a regular matching request for ratelimit purposes.", + title="instrument_name", + ) + label: str = Field(..., description="Cancel all orders for this label", title="label") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +PrivateCancelByLabelResultSchema = PrivateCancelByNonceResultSchema + + +class PrivateGetMarginParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + simulated_collateral_changes: Optional[List[SimulatedCollateralSchema]] = Field( + None, + description="Optional, add collaterals to simulate deposits / withdrawals / spot trades", + title="simulated_collateral_changes", + ) + simulated_position_changes: Optional[List[SimulatedPositionSchema]] = Field( + None, + description="Optional, add positions to simulate perp / option trades", + title="simulated_position_changes", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +PrivateGetMarginResultSchema = PublicGetMarginResultSchema + + +class PublicCreateSubaccountDebugParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") + asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") + currency: Optional[str] = Field( + None, + description="Base currency of the subaccount (only for `PM`)", + title="currency", + ) + margin_type: MarginType = Field( + ..., + description="`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", + title="margin_type", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the deposit", + title="signer", + ) + wallet: str = Field(..., description="Ethereum wallet address", title="wallet") + + +class PublicCreateSubaccountDebugResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + action_hash: str = Field(..., description="Keccak hashed action data", title="action_hash") + encoded_data: str = Field(..., description="ABI encoded deposit data", title="encoded_data") + encoded_data_hashed: str = Field(..., description="Keccak hashed encoded_data", title="encoded_data_hashed") + typed_data_hash: str = Field(..., description="EIP 712 typed data hash", title="typed_data_hash") + + +class PublicGetInstrumentParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + + +class ERC20PublicDetailsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + borrow_index: Decimal = Field( + "1", + description="Latest borrow index as per `CashAsset.sol` implementation", + title="borrow_index", + ) + decimals: int = Field( + ..., + description="Number of decimals of the underlying on-chain ERC20 token", + title="decimals", + ) + supply_index: Decimal = Field( + "1", + description="Latest supply index as per `CashAsset.sol` implementation", + title="supply_index", + ) + underlying_erc20_address: str = Field( + "", + description="Address of underlying on-chain ERC20 (not V2 asset)", + title="underlying_erc20_address", + ) + + +class OptionType(Enum): + C = "C" + P = "P" + + +class OptionPublicDetailsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry: int = Field(..., description="Unix timestamp of expiry date (in seconds)", title="expiry") + index: str = Field(..., description="Underlying settlement price index", title="index") + option_type: OptionType = Field(..., title="option_type") + settlement_price: Optional[Decimal] = Field( + None, description="Settlement price of the option", title="settlement_price" + ) + strike: Decimal = Field(..., title="strike") + + +class PerpPublicDetailsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + aggregate_funding: Decimal = Field( + ..., + description="Latest aggregated funding as per `PerpAsset.sol`", + title="aggregate_funding", + ) + funding_rate: Decimal = Field( + ..., + description="Current hourly funding rate as per `PerpAsset.sol`", + title="funding_rate", + ) + index: str = Field(..., description="Underlying spot price index for funding rate", title="index") + max_rate_per_hour: Decimal = Field( + ..., + description="Max rate per hour as per `PerpAsset.sol`", + title="max_rate_per_hour", + ) + min_rate_per_hour: Decimal = Field( + ..., + description="Min rate per hour as per `PerpAsset.sol`", + title="min_rate_per_hour", + ) + static_interest_rate: Decimal = Field( + ..., + description="Static interest rate as per `PerpAsset.sol`", + title="static_interest_rate", + ) + + +class PrivateEditSessionKeyParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + disable: bool = Field( + False, + description="Flag whether or not to disable to session key. Defaulted to false. Only allowed for non-admin keys. Admin keys must go through `/deregister_session_key` for now.", + title="disable", + ) + ip_whitelist: Optional[List[str]] = Field( + None, + description="Optional list of whitelisted IPs, an empty list can be supplied to whitelist all IPs", + title="ip_whitelist", + ) + label: Optional[str] = Field(None, description="Optional new label for the session key", title="label") + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") + + +class PrivateEditSessionKeyResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry_sec: int = Field(..., description="Session key expiry timestamp in sec", title="expiry_sec") + ip_whitelist: List[str] = Field( + ..., + description="List of whitelisted IPs, if empty then any IP is allowed.", + title="ip_whitelist", + ) + label: str = Field(..., description="User-defined session key label", title="label") + public_session_key: str = Field( + ..., + description="Public session key address (Ethereum EOA)", + title="public_session_key", + ) + scope: str = Field(..., description="Session key permission level scope", title="scope") + + +class PrivateGetLiquidatorHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field( + 9223372036854776000, + description="End timestamp of the event history (default current time)", + title="end_timestamp", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + start_timestamp: int = Field( + 0, + description="Start timestamp of the event history (default 0)", + title="start_timestamp", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class PrivateGetLiquidatorHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + bids: List[AuctionBidEventSchema] = Field(..., description="List of auction bid events", title="bids") + pagination: PaginationInfoSchema + + +class PrivateGetPositionsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PositionResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Position amount held by subaccount", title="amount") + amount_step: Decimal = Field(..., description="Minimum amount step for the position", title="amount_step") + average_price: Decimal = Field(..., description="Average price of whole position", title="average_price") + average_price_excl_fees: Decimal = Field( + ..., + description="Average price of whole position excluding fees", + title="average_price_excl_fees", + ) + creation_timestamp: int = Field( + ..., + description="Timestamp of when the position was opened (in ms since Unix epoch)", + title="creation_timestamp", + ) + cumulative_funding: Decimal = Field( + ..., + description="Cumulative funding for the position (only for perpetuals).", + title="cumulative_funding", + ) + delta: Decimal = Field( + ..., + description="Asset delta (w.r.t. forward price for options, `1.0` for perps)", + title="delta", + ) + gamma: Decimal = Field(..., description="Asset gamma (zero for non-options)", title="gamma") + index_price: Decimal = Field( + ..., + description="Current index (oracle) price for position's currency", + title="index_price", + ) + initial_margin: Decimal = Field( + ..., + description="USD initial margin requirement for this position", + title="initial_margin", + ) + instrument_name: str = Field( + ..., + description="Instrument name (same as the base Asset name)", + title="instrument_name", + ) + instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") + leverage: Optional[Decimal] = Field( + ..., + description="Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + title="leverage", + ) + liquidation_price: Optional[Decimal] = Field( + ..., + description="Index price at which position will be liquidated", + title="liquidation_price", + ) + maintenance_margin: Decimal = Field( + ..., + description="USD maintenance margin requirement for this position", + title="maintenance_margin", + ) + mark_price: Decimal = Field( + ..., + description="Current mark price for position's instrument", + title="mark_price", + ) + mark_value: Decimal = Field( + ..., + description="USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price", + title="mark_value", + ) + net_settlements: Decimal = Field( + ..., + description="Net amount of USD from position settlements that has been paid to the user's subaccount. This number is subtracted from the portfolio value for margin calculations purposes.
Positive values mean the user has recieved USD from settlements, or is awaiting settlement of USD losses. Negative values mean the user has paid USD for settlements, or is awaiting settlement of USD gains.", + title="net_settlements", + ) + open_orders_margin: Decimal = Field( + ..., + description="USD margin requirement for all open orders for this asset / instrument", + title="open_orders_margin", + ) + pending_funding: Decimal = Field( + ..., + description="A portion of funding payments that has not yet been settled into cash balance (only for perpetuals). This number is added to the portfolio value for margin calculations purposes.", + title="pending_funding", + ) + realized_pnl: Decimal = Field( + ..., + description="Realized trading profit or loss of the position.", + title="realized_pnl", + ) + realized_pnl_excl_fees: Decimal = Field( + ..., + description="Realized trading profit or loss of the position excluding fees", + title="realized_pnl_excl_fees", + ) + theta: Decimal = Field(..., description="Asset theta (zero for non-options)", title="theta") + total_fees: Decimal = Field( + ..., + description="Total fees paid for opening and changing the position", + title="total_fees", + ) + unrealized_pnl: Decimal = Field( + ..., + description="Unrealized trading profit or loss of the position.", + title="unrealized_pnl", + ) + unrealized_pnl_excl_fees: Decimal = Field( + ..., + description="Unrealized trading profit or loss of the position excluding fees", + title="unrealized_pnl_excl_fees", + ) + vega: Decimal = Field(..., description="Asset vega (zero for non-options)", title="vega") + + +class TxStatus4(Enum): + settled = "settled" + reverted = "reverted" + timed_out = "timed_out" + + +class PublicGetTradeHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: Optional[str] = Field(None, description="Currency to filter by (defaults to all)", title="currency") + from_timestamp: int = Field( + 0, + description="Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0.", + title="from_timestamp", + ) + instrument_name: Optional[str] = Field( + None, + description="Instrument name to filter by (defaults to all)", + title="instrument_name", + ) + instrument_type: Optional[InstrumentType] = Field( + None, + description="Instrument type to filter by (defaults to all)", + title="instrument_type", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + subaccount_id: Optional[int] = Field(None, description="Subaccount ID to filter by", title="subaccount_id") + to_timestamp: int = Field( + 18446744073709552000, + description="Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", + title="to_timestamp", + ) + trade_id: Optional[UUID] = Field( + None, + description="Trade ID to filter by. If set, all other filters are ignored", + title="trade_id", + ) + tx_hash: Optional[str] = Field( + None, + description="On-chain tx hash to filter by. If set, all other filters are ignored", + title="tx_hash", + ) + tx_status: TxStatus4 = Field( + "settled", + description="Transaction status to filter by (default `settled`).", + title="tx_status", + ) + + +class TradeSettledPublicResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + direction: Direction = Field(..., description="Order direction", title="direction") + expected_rebate: Decimal = Field(..., description="Expected rebate for this trade", title="expected_rebate") + index_price: Decimal = Field( + ..., + description="Index price of the underlying at the time of the trade", + title="index_price", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + liquidity_role: LiquidityRole = Field(..., description="Role of the user in the trade", title="liquidity_role") + mark_price: Decimal = Field( + ..., + description="Mark price of the instrument at the time of the trade", + title="mark_price", + ) + quote_id: Optional[UUID] = Field(..., description="Quote ID if the trade was executed via RFQ", title="quote_id") + realized_pnl: Decimal = Field(..., description="Realized PnL for this trade", title="realized_pnl") + realized_pnl_excl_fees: Decimal = Field( + ..., + description="Realized PnL for this trade using cost accounting that excludes fees", + title="realized_pnl_excl_fees", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + timestamp: int = Field(..., description="Trade timestamp (in ms since Unix epoch)", title="timestamp") + trade_amount: Decimal = Field(..., description="Amount filled in this trade", title="trade_amount") + trade_fee: Decimal = Field(..., description="Fee for this trade", title="trade_fee") + trade_id: str = Field(..., description="Trade ID", title="trade_id") + trade_price: Decimal = Field(..., description="Price at which the trade was filled", title="trade_price") + tx_hash: str = Field(..., description="Blockchain transaction hash", title="tx_hash") + tx_status: TxStatus4 = Field(..., description="Blockchain transaction status", title="tx_status") + wallet: str = Field(..., description="Wallet address (owner) of the subaccount", title="wallet") + + +class PrivateGetRfqsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + from_timestamp: int = Field( + 0, + description="Earliest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to 0.", + title="from_timestamp", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + rfq_id: Optional[UUID] = Field(None, description="RFQ ID filter, if applicable", title="rfq_id") + status: Optional[Status1] = Field(None, description="RFQ status filter, if applicable", title="status") + subaccount_id: int = Field( + ..., + description="Subaccount ID for auth purposes, returned data will be scoped to this subaccount.", + title="subaccount_id", + ) + to_timestamp: int = Field( + 18446744073709552000, + description="Latest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", + title="to_timestamp", + ) + + +RFQResultSchema = PrivateSendRfqResultSchema + + +class SignatureDetailsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature: str = Field(..., description="Ethereum signature of the transfer", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the transfer", + title="signer", + ) + + +class TransferDetailsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + address: str = Field( + ..., + description="Ethereum address of the asset being transferred", + title="address", + ) + amount: Decimal = Field(..., description="Amount to transfer", title="amount") + sub_id: int = Field(..., description="Sub ID of the asset being transferred", title="sub_id") + + +class PrivateTransferErc20ResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + status: str = Field(..., description="`requested`", title="status") + transaction_id: UUID = Field(..., description="Transaction id of the transfer", title="transaction_id") + + +class PrivateSendQuoteParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + direction: Direction = Field( + ..., + description="Quote direction, `buy` means trading each leg at its direction, `sell` means trading each leg in the opposite direction.", + title="direction", + ) + label: str = Field("", description="Optional user-defined label for the quote", title="label") + legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") + max_fee: Decimal = Field( + ..., + description="Max fee ($ for the full trade). Request will be rejected if the supplied max fee is below the estimated fee for this trade.", + title="max_fee", + ) + mmp: bool = Field( + False, + description="Whether the quote is tagged for market maker protections (default false)", + title="mmp", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as a concatenated `UTC timestamp in ms` and `random number up to 6 digits` (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + rfq_id: UUID = Field(..., description="RFQ ID the quote is for", title="rfq_id") + signature: str = Field(..., description="Ethereum signature of the quote", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be at least 310 seconds from now. Once time till signature expiry reaches 300 seconds, the quote will be considered expired. This buffer is meant to ensure the trade can settle on chain in case of a blockchain congestion.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed the quote", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +PrivateSendQuoteResultSchema = QuoteResultSchema + + +class PrivateCancelTriggerOrderParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + order_id: UUID = Field(..., title="order_id") + subaccount_id: int = Field(..., title="subaccount_id") + + +PrivateCancelTriggerOrderResultSchema = OrderResponseSchema + + +PrivateGetWithdrawalHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema + + +class WithdrawalSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount withdrawn by the subaccount", title="amount") + asset: str = Field(..., description="Asset withdrawn", title="asset") + error_log: Optional[Dict[str, Any]] = Field(..., description="If failed, error log for reason", title="error_log") + timestamp: int = Field( + ..., + description="Timestamp of the withdrawal (in ms since UNIX epoch)", + title="timestamp", + ) + tx_hash: str = Field( + ..., + description="Hash of the transaction that withdrew the funds", + title="tx_hash", + ) + tx_status: TxStatus = Field( + ..., + description="Status of the transaction that deposited the funds", + title="tx_status", + ) + + +class PublicGetOptionSettlementPricesParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency for which to show expiries", title="currency") + + +class ExpiryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry_date: str = Field(..., description="Expiry date in `YYYYMMDD` format", title="expiry_date") + price: Optional[Decimal] = Field( + ..., + description="Settlement price will show None if not yet settled onchain", + title="price", + ) + utc_expiry_sec: int = Field(..., description="UTC timestamp of expiry", title="utc_expiry_sec") + + +class PublicGetMakerProgramScoresParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + epoch_start_timestamp: int = Field( + ..., + description="Start timestamp of the program epoch", + title="epoch_start_timestamp", + ) + program_name: str = Field(..., description="Program name", title="program_name") + + +class ScoreBreakdownSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + coverage_score: Decimal = Field( + ..., + description="Coverag component of the score of the account for this program", + title="coverage_score", + ) + holder_boost: Decimal = Field( + ..., + description="A custom account multiplier for the score due to holding tokens", + title="holder_boost", + ) + quality_score: Decimal = Field( + ..., + description="Quality component of the score of the account for this program", + title="quality_score", + ) + total_score: Decimal = Field( + ..., + description="Total score of the account for this program", + title="total_score", + ) + volume: Decimal = Field(..., description="Volume traded by the account for this epoch", title="volume") + volume_multiplier: Decimal = Field( + ..., + description="Multiplier for the volume traded by the account", + title="volume_multiplier", + ) + wallet: str = Field(..., description="Wallet address of the account", title="wallet") + + +class PublicBuildRegisterSessionKeyTxParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry_sec: int = Field(..., description="Expiry of the session key", title="expiry_sec") + gas: Optional[int] = Field( + ..., + description="Gas allowance for transaction. If none, will use estimateGas * 150%", + title="gas", + ) + nonce: Optional[int] = Field( + ..., + description="Wallet's transaction count, If none, will use eth.getTransactionCount()", + title="nonce", + ) + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") + + +class PublicBuildRegisterSessionKeyTxResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + tx_params: Dict[str, Any] = Field( + ..., + description="Transaction params in dictionary form, same as `TxParams` in `web3.py`", + title="tx_params", + ) + + +class PublicRegisterSessionKeyParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry_sec: int = Field(..., description="Expiry of the session key", title="expiry_sec") + label: str = Field(..., description="Ethereum wallet address", title="label") + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + signed_raw_tx: str = Field( + ..., + description="A signed RLP encoded ETH transaction in form of a hex string (same as `w3.eth.account.sign_transaction(unsigned_tx, private_key).rawTransaction.hex()`)", + title="signed_raw_tx", + ) + wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") + + +class PublicRegisterSessionKeyResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + label: str = Field(..., description="User-defined session key label", title="label") + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + transaction_id: UUID = Field(..., description="ID to lookup status of transaction", title="transaction_id") + + +class PrivateGetOrderHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get order history", + title="subaccount_id", + ) + + +class PrivateGetOrderHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + orders: List[OrderResponseSchema] = Field(..., description="List of open orders", title="orders") + pagination: PaginationInfoSchema + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get open orders", + title="subaccount_id", + ) + + +class PrivateCancelRfqParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + rfq_id: UUID = Field(..., description="RFQ ID to cancel", title="rfq_id") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class Result(Enum): + ok = "ok" + + +class PrivateCancelRfqResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: Result = Field( + ..., + description="The result of this method call, `ok` if successful", + title="result", + ) + + +class PrivateCancelBatchRfqsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + label: Optional[str] = Field(None, description="Cancel RFQs with this label", title="label") + nonce: Optional[int] = Field(None, description="Cancel RFQ with this nonce", title="nonce") + rfq_id: Optional[UUID] = Field(None, description="RFQ ID to cancel", title="rfq_id") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class PrivateCancelBatchRfqsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancelled_ids: List[UUID] = Field(..., description="RFQ IDs of the cancelled RFQs", title="cancelled_ids") + + +class PrivateCancelBatchQuotesParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + label: Optional[str] = Field(None, description="Cancel quotes with this label", title="label") + nonce: Optional[int] = Field(None, description="Cancel quote with this nonce", title="nonce") + quote_id: Optional[UUID] = Field(None, description="Quote ID to cancel", title="quote_id") + rfq_id: Optional[UUID] = Field(None, description="Cancel quotes for this RFQ ID", title="rfq_id") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class PrivateCancelBatchQuotesResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancelled_ids: List[UUID] = Field(..., description="Quote IDs of the cancelled quotes", title="cancelled_ids") + + +PublicGetTimeParamsSchema = PublicGetMakerProgramsParamsSchema + + +class PublicGetTimeResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: int = Field(..., description="Current time in milliseconds since UNIX epoch", title="result") + + +class PrivateGetFundingHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field( + 9223372036854776000, + description="End timestamp of the event history (default current time)", + title="end_timestamp", + ) + instrument_name: Optional[str] = Field( + None, + description="Instrument name (returns history for all perpetuals if not provided)", + title="instrument_name", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + start_timestamp: int = Field( + 0, + description="Start timestamp of the event history (default 0)", + title="start_timestamp", + ) + subaccount_id: int = Field(..., description="Subaccount id", title="subaccount_id") + + +class FundingPaymentSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + funding: Decimal = Field( + ..., + description="Dollar funding paid (if negative) or received (if positive) by the subaccount", + title="funding", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + pnl: Decimal = Field(..., description="Cashflow from the perp PnL settlement", title="pnl") + timestamp: int = Field( + ..., + description="Timestamp of the funding payment (in ms since UNIX epoch)", + title="timestamp", + ) + + +class PrivateGetOpenOrdersParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get open orders", + title="subaccount_id", + ) + + +class PrivateGetOpenOrdersResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + orders: List[OrderResponseSchema] = Field(..., description="List of open orders", title="orders") + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get open orders", + title="subaccount_id", + ) + + +PrivateGetAccountParamsSchema = PrivateGetSubaccountsParamsSchema + + +class AccountFeeInfoSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + base_fee_discount: Decimal = Field(..., description="Base fee discount", title="base_fee_discount") + option_maker_fee: Optional[Decimal] = Field( + ..., + description="Option maker fee - uses default instrument fee rate if None", + title="option_maker_fee", + ) + option_taker_fee: Optional[Decimal] = Field( + ..., + description="Option taker fee - uses default instrument fee rate if None", + title="option_taker_fee", + ) + perp_maker_fee: Optional[Decimal] = Field( + ..., + description="Perp maker fee - uses default instrument fee rate if None", + title="perp_maker_fee", + ) + perp_taker_fee: Optional[Decimal] = Field( + ..., + description="Perp taker fee - uses default instrument fee rate if None", + title="perp_taker_fee", + ) + rfq_maker_discount: Decimal = Field(..., description="RFQ maker fee discount", title="rfq_maker_discount") + rfq_taker_discount: Decimal = Field(..., description="RFQ taker fee discount", title="rfq_taker_discount") + spot_maker_fee: Optional[Decimal] = Field( + ..., + description="Spot maker fee - uses default instrument fee rate if None", + title="spot_maker_fee", + ) + spot_taker_fee: Optional[Decimal] = Field( + ..., + description="Spot taker fee - uses default instrument fee rate if None", + title="spot_taker_fee", + ) + + +class PublicGetAllInstrumentsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: Optional[str] = Field( + None, + description="Underlying currency of asset (`ETH`, `BTC`, etc)", + title="currency", + ) + expired: bool = Field(..., description="If `True`: include expired instruments.", title="expired") + instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + + +class InstrumentPublicResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount_step: Decimal = Field(..., description="Minimum valid increment of order amount", title="amount_step") + base_asset_address: str = Field( + ..., + description="Blockchain address of the base asset", + title="base_asset_address", + ) + base_asset_sub_id: str = Field( + ..., + description="Sub ID of the specific base asset as defined in Asset.sol", + title="base_asset_sub_id", + ) + base_currency: str = Field( + ..., + description="Underlying currency of base asset (`ETH`, `BTC`, etc)", + title="base_currency", + ) + base_fee: Decimal = Field(..., description="$ base fee added to every taker order", title="base_fee") + erc20_details: Optional[ERC20PublicDetailsSchema] = Field(...) + fifo_min_allocation: Decimal = Field( + ..., + description="Minimum number of contracts that get filled using FIFO. Actual number of contracts that gets filled by FIFO will be the max between this value and (1 - pro_rata_fraction) x order_amount, plus any size leftovers due to rounding.", + title="fifo_min_allocation", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") + is_active: bool = Field( + ..., + description="If `True`: instrument is tradeable within `activation` and `deactivation` timestamps", + title="is_active", + ) + maker_fee_rate: Decimal = Field( + ..., + description="Percent of spot price fee rate for makers", + title="maker_fee_rate", + ) + mark_price_fee_rate_cap: Optional[Decimal] = Field( + None, + description="Percent of option price fee cap, e.g. 12.5%, null if not applicable", + title="mark_price_fee_rate_cap", + ) + maximum_amount: Decimal = Field( + ..., + description="Maximum valid amount of contracts / tokens per trade", + title="maximum_amount", + ) + minimum_amount: Decimal = Field( + ..., + description="Minimum valid amount of contracts / tokens per trade", + title="minimum_amount", + ) + option_details: Optional[OptionPublicDetailsSchema] = Field(...) + perp_details: Optional[PerpPublicDetailsSchema] = Field(...) + pro_rata_amount_step: Decimal = Field( + ..., + description="Pro-rata fill share of every order is rounded down to be a multiple of this number. Leftovers of the order due to rounding are filled FIFO.", + title="pro_rata_amount_step", + ) + pro_rata_fraction: Decimal = Field( + ..., + description="Fraction of order that gets filled using pro-rata matching. If zero, the matching is full FIFO.", + title="pro_rata_fraction", + ) + quote_currency: str = Field( + ..., + description="Quote currency (`USD` for perps, `USDC` for options)", + title="quote_currency", + ) + scheduled_activation: int = Field( + ..., + description="Timestamp at which became or will become active (if applicable)", + title="scheduled_activation", + ) + scheduled_deactivation: int = Field( + ..., + description="Scheduled deactivation time for instrument (if applicable)", + title="scheduled_deactivation", + ) + taker_fee_rate: Decimal = Field( + ..., + description="Percent of spot price fee rate for takers", + title="taker_fee_rate", + ) + tick_size: Decimal = Field( + ..., + description="Tick size of the instrument, i.e. minimum price increment", + title="tick_size", + ) + + +PublicGetTickerParamsSchema = PublicGetInstrumentParamsSchema + + +class OptionPricingSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + ask_iv: Decimal = Field(..., description="Implied volatility of the current best ask", title="ask_iv") + bid_iv: Decimal = Field(..., description="Implied volatility of the current best bid", title="bid_iv") + delta: Decimal = Field(..., description="Delta of the option", title="delta") + discount_factor: Decimal = Field( + ..., + description="Discount factor used to calculate option premium", + title="discount_factor", + ) + forward_price: Decimal = Field( + ..., + description="Forward price used to calculate option premium", + title="forward_price", + ) + gamma: Decimal = Field(..., description="Gamma of the option", title="gamma") + iv: Decimal = Field(..., description="Implied volatility of the option", title="iv") + mark_price: Decimal = Field(..., description="Mark price of the option", title="mark_price") + rho: Decimal = Field(..., description="Rho of the option", title="rho") + theta: Decimal = Field(..., description="Theta of the option", title="theta") + vega: Decimal = Field(..., description="Vega of the option", title="vega") + + +class AggregateTradingStatsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + contract_volume: Decimal = Field( + ..., + description="Number of contracts traded during last 24 hours", + title="contract_volume", + ) + high: Decimal = Field(..., description="Highest trade price during last 24h", title="high") + low: Decimal = Field(..., description="Lowest trade price during last 24h", title="low") + num_trades: Decimal = Field(..., description="Number of trades during last 24h ", title="num_trades") + open_interest: Decimal = Field(..., description="Current total open interest", title="open_interest") + percent_change: Decimal = Field( + ..., + description="24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price", + title="percent_change", + ) + usd_change: Decimal = Field(..., description="24-hour price change in USD.", title="usd_change") + + +class PublicGetVaultShareParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + from_timestamp_sec: int = Field(..., description="From timestamp in seconds", title="from_timestamp_sec") + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + to_timestamp_sec: int = Field(..., description="To timestamp in seconds", title="to_timestamp_sec") + vault_name: str = Field(..., description="Name of the vault", title="vault_name") + + +class VaultShareResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + base_value: Decimal = Field( + ..., + description="The value of the vault's token against the base currency. Ex: rswETHC vs rswETH", + title="base_value", + ) + block_number: int = Field(..., description="The Derive chain block number", title="block_number") + block_timestamp: int = Field( + ..., + description="Timestamp of the Derive chain block number", + title="block_timestamp", + ) + underlying_value: Optional[Decimal] = Field( + ..., + description="The value of the vault's token against the underlying currency. Ex: rswETHC vs ETH", + title="underlying_value", + ) + usd_value: Decimal = Field(..., description="The value of the vault's token against USD", title="usd_value") + + +PrivateGetCollateralsParamsSchema = PrivateGetPositionsParamsSchema + + +class CollateralResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Asset amount of given collateral", title="amount") + amount_step: Decimal = Field(..., description="Minimum amount step for the collateral", title="amount_step") + asset_name: str = Field(..., description="Asset name", title="asset_name") + asset_type: InstrumentType = Field( + ..., + description="Type of asset collateral (currently always `erc20`)", + title="asset_type", + ) + average_price: Decimal = Field( + ..., + description="Average price of the collateral, 0 for USDC.", + title="average_price", + ) + average_price_excl_fees: Decimal = Field( + ..., + description="Average price of whole position excluding fees", + title="average_price_excl_fees", + ) + creation_timestamp: int = Field( + ..., + description="Timestamp of when the position was opened (in ms since Unix epoch)", + title="creation_timestamp", + ) + cumulative_interest: Decimal = Field( + ..., + description="Cumulative interest earned on supplying collateral or paid for borrowing", + title="cumulative_interest", + ) + currency: str = Field( + ..., + description="Underlying currency of asset (`ETH`, `BTC`, etc)", + title="currency", + ) + delta: Decimal = Field(..., description="Asset delta w.r.t. the delta currency", title="delta") + delta_currency: str = Field( + ..., + description="Currency with respect to which delta is reported.For example, LRTs like WEETH have their delta reported in ETH", + title="delta_currency", + ) + initial_margin: Decimal = Field( + ..., + description="USD value of collateral that contributes to initial margin", + title="initial_margin", + ) + maintenance_margin: Decimal = Field( + ..., + description="USD value of collateral that contributes to maintenance margin", + title="maintenance_margin", + ) + mark_price: Decimal = Field(..., description="Current mark price of the asset", title="mark_price") + mark_value: Decimal = Field( + ..., + description="USD value of the collateral (amount * mark price)", + title="mark_value", + ) + open_orders_margin: Decimal = Field( + ..., + description="USD margin requirement for all open orders for this asset / instrument", + title="open_orders_margin", + ) + pending_interest: Decimal = Field( + ..., + description="Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes.", + title="pending_interest", + ) + realized_pnl: Decimal = Field( + ..., + description="Realized trading profit or loss of the collateral, 0 for USDC.", + title="realized_pnl", + ) + realized_pnl_excl_fees: Decimal = Field( + ..., + description="Realized trading profit or loss of the position excluding fees", + title="realized_pnl_excl_fees", + ) + total_fees: Decimal = Field( + ..., + description="Total fees paid for opening and changing the position", + title="total_fees", + ) + unrealized_pnl: Decimal = Field( + ..., + description="Unrealized trading profit or loss of the collateral, 0 for USDC.", + title="unrealized_pnl", + ) + unrealized_pnl_excl_fees: Decimal = Field( + ..., + description="Unrealized trading profit or loss of the position excluding fees", + title="unrealized_pnl_excl_fees", + ) + + +class Scope(Enum): + admin = "admin" + account = "account" + read_only = "read_only" + + +class PrivateRegisterScopedSessionKeyParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry_sec: int = Field(..., description="Expiry of the session key", title="expiry_sec") + ip_whitelist: Optional[List[str]] = Field( + None, + description="List of whitelisted IPs, if empty then any IP is allowed.", + title="ip_whitelist", + ) + label: Optional[str] = Field(None, description="User-defined session key label", title="label") + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + scope: Scope = Field( + "read_only", + description="Scope of the session key. Defaults to READ_ONLY level permissions. ", + title="scope", + ) + signed_raw_tx: Optional[str] = Field( + None, + description="A signed RLP encoded ETH transaction in form of a hex string (same as `w3.eth.account.sign_transaction(unsigned_tx, private_key).rawTransaction.hex()`) Must be included if the scope is ADMIN.", + title="signed_raw_tx", + ) + wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") + + +class PrivateRegisterScopedSessionKeyResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiry_sec: int = Field(..., description="Session key expiry timestamp in sec", title="expiry_sec") + ip_whitelist: Optional[List[str]] = Field( + ..., + description="List of whitelisted IPs, if empty then any IP is allowed.", + title="ip_whitelist", + ) + label: Optional[str] = Field(..., description="User-defined session key label", title="label") + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + scope: Scope = Field(..., description="Session key permission level scope", title="scope") + transaction_id: Optional[UUID] = Field( + ..., + description="ID to lookup status of transaction if signed_raw_tx is provided", + title="transaction_id", + ) + + +class PrivateExpiredAndCancelledHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field(..., description="End Unix timestamp", title="end_timestamp") + expiry: int = Field( + ..., + description="Expiry of download link in seconds. Maximum of 604800.", + title="expiry", + ) + start_timestamp: int = Field(..., description="Start Unix timestamp", title="start_timestamp") + subaccount_id: int = Field(..., description="Subaccount to download data for", title="subaccount_id") + wallet: str = Field(..., description="Wallet to download data for", title="wallet") + + +class PrivateExpiredAndCancelledHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + presigned_urls: List[str] = Field( + ..., + description="List of presigned URLs to the snapshots", + title="presigned_urls", + ) + + +PrivateSessionKeysParamsSchema = PrivateGetSubaccountsParamsSchema + + +SessionKeyResponseSchema = PrivateEditSessionKeyResultSchema + + +class PrivateGetMmpConfigParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: Optional[str] = Field( + None, + description="Currency to get the config for. If not provided, returns all configs for the subaccount", + title="currency", + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get the config", + title="subaccount_id", + ) + + +class MMPConfigResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency of this mmp config", title="currency") + is_frozen: bool = Field(..., description="Whether the subaccount is currently frozen", title="is_frozen") + mmp_amount_limit: Decimal = Field( + "0", + description="Maximum total order amount that can be traded within the mmp_interval across all instruments of the provided currency. The amounts are not netted, so a filled bid of 1 and a filled ask of 2 would count as 3.
Default: 0 (no limit)", + title="mmp_amount_limit", + ) + mmp_delta_limit: Decimal = Field( + "0", + description="Maximum total delta that can be traded within the mmp_interval across all instruments of the provided currency. This quantity is netted, so a filled order with +1 delta and a filled order with -2 delta would count as -1
Default: 0 (no limit)", + title="mmp_delta_limit", + ) + mmp_frozen_time: int = Field( + ..., + description="Time interval in ms setting how long the subaccount is frozen after an mmp trigger, if 0 then a manual reset would be required via private/reset_mmp", + title="mmp_frozen_time", + ) + mmp_interval: int = Field( + ..., + description="Time interval in ms over which the limits are monotored, if 0 then mmp is disabled", + title="mmp_interval", + ) + mmp_unfreeze_time: int = Field( + ..., + description="Timestamp in ms after which the subaccount will be unfrozen", + title="mmp_unfreeze_time", + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to set the config", + title="subaccount_id", + ) + + +PrivateOrderParamsSchema = PrivateOrderDebugParamsSchema + + +class PrivateOrderResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + order: OrderResponseSchema + trades: List[TradeResponseSchema] = Field(..., title="trades") + + +PrivateGetSubaccountParamsSchema = PrivateGetPositionsParamsSchema + + +class PrivateGetSubaccountResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + collaterals: List[CollateralResponseSchema] = Field( + ..., + description="All collaterals that count towards margin of subaccount", + title="collaterals", + ) + collaterals_initial_margin: Decimal = Field( + ..., + description="Total initial margin credit contributed by collaterals", + title="collaterals_initial_margin", + ) + collaterals_maintenance_margin: Decimal = Field( + ..., + description="Total maintenance margin credit contributed by collaterals", + title="collaterals_maintenance_margin", + ) + collaterals_value: Decimal = Field( + ..., + description="Total mark-to-market value of all collaterals", + title="collaterals_value", + ) + currency: str = Field(..., description="Currency of subaccount", title="currency") + initial_margin: Decimal = Field( + ..., + description="Total initial margin requirement of all positions and collaterals.Trades will be rejected if this value falls below zero after the trade.", + title="initial_margin", + ) + is_under_liquidation: bool = Field( + ..., + description="Whether the subaccount is undergoing a liquidation auction", + title="is_under_liquidation", + ) + label: str = Field(..., description="User defined label", title="label") + maintenance_margin: Decimal = Field( + ..., + description="Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation.", + title="maintenance_margin", + ) + margin_type: MarginType = Field( + ..., + description="Margin type of subaccount (`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", + title="margin_type", + ) + open_orders: List[OrderResponseSchema] = Field( + ..., description="All open orders of subaccount", title="open_orders" + ) + open_orders_margin: Decimal = Field( + ..., + description="Total margin requirement of all open orders.Orders will be rejected if this value plus initial margin are below zero after the order.", + title="open_orders_margin", + ) + positions: List[PositionResponseSchema] = Field( + ..., description="All active positions of subaccount", title="positions" + ) + positions_initial_margin: Decimal = Field( + ..., + description="Total initial margin requirement of all positions", + title="positions_initial_margin", + ) + positions_maintenance_margin: Decimal = Field( + ..., + description="Total maintenance margin requirement of all positions", + title="positions_maintenance_margin", + ) + positions_value: Decimal = Field( + ..., + description="Total mark-to-market value of all positions", + title="positions_value", + ) + projected_margin_change: Decimal = Field( + ..., + description="Projected change in maintenance margin requirement between now and projected margin at 8:01 UTC. If this value plus current maintenance margin ise below zero, the account is at risk of being flagged for liquidation right after the upcoming expiry.", + title="projected_margin_change", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + subaccount_value: Decimal = Field( + ..., + description="Total mark-to-market value of all positions and collaterals", + title="subaccount_value", + ) + + +class PublicGetInterestRateHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + from_timestamp_sec: int = Field(..., description="From timestamp in seconds", title="from_timestamp_sec") + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + to_timestamp_sec: int = Field(..., description="To timestamp in seconds", title="to_timestamp_sec") + + +class InterestRateHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + block: int = Field(..., description="Derive Chain block number", title="block") + borrow_apy: Decimal = Field(..., description="Borrow APY", title="borrow_apy") + supply_apy: Decimal = Field(..., description="Supply APY", title="supply_apy") + timestamp_sec: int = Field(..., description="Timestamp in seconds", title="timestamp_sec") + total_borrow: Decimal = Field(..., description="Total USDC borrowed", title="total_borrow") + total_supply: Decimal = Field(..., description="Total USDC supplied", title="total_supply") + + +class PrivateGetAllPortfoliosParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + wallet: str = Field(..., description="Wallet address", title="wallet") + + +class PrivateGetAllPortfoliosResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[PrivateGetSubaccountResultSchema] = Field(..., description="", title="result") + + +class PublicGetLiquidationHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field( + 9223372036854776000, + description="End timestamp of the event history (default current time)", + title="end_timestamp", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + start_timestamp: int = Field( + 0, + description="Start timestamp of the event history (default 0)", + title="start_timestamp", + ) + subaccount_id: Optional[int] = Field(None, description="(Optional) Subaccount ID", title="subaccount_id") + + +class PublicDepositDebugParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") + asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") + is_atomic_signing: bool = Field( + False, + description="Used by vaults to determine whether the signature is an EIP-1271 signature", + title="is_atomic_signing", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the deposit", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +PublicDepositDebugResultSchema = PublicCreateSubaccountDebugResultSchema + + +class PublicGetVaultBalancesParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + smart_contract_owner: Optional[str] = Field( + None, + description="If wallet not provided, can query balances by EOA that owns smart contract wallet", + title="smart_contract_owner", + ) + wallet: Optional[str] = Field(None, description="Ethereum wallet address of smart contract", title="wallet") + + +class VaultBalanceResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + address: str = Field(..., title="address") + amount: Decimal = Field(..., title="amount") + chain_id: int = Field(..., title="chain_id") + name: str = Field(..., title="name") + vault_asset_type: str = Field(..., title="vault_asset_type") + + +class PublicGetReferralPerformanceParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_ms: int = Field(..., description="End timestamp in UTC milliseconds", title="end_ms") + referral_code: Optional[str] = Field(None, description="(Optional) referral code", title="referral_code") + start_ms: int = Field(..., description="Start timestamp in UTC milliseconds", title="start_ms") + wallet: Optional[str] = Field(None, description="(Optional) wallet of the referrer", title="wallet") + + +class ReferralPerformanceByInstrumentTypeSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + fee_reward: Decimal = Field(..., description="Fee reward to referrer", title="fee_reward") + notional_volume: Decimal = Field(..., description="Notional volume", title="notional_volume") + referred_fee: Decimal = Field(..., description="Fees paid by referred trader", title="referred_fee") + + +class PrivateSetCancelOnDisconnectParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + enabled: bool = Field( + ..., + description="Whether to enable or disable cancel on disconnect", + title="enabled", + ) + wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") + + +class PrivateSetCancelOnDisconnectResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: Result = Field(..., description="", title="result") + + +class PrivateCancelQuoteParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + quote_id: UUID = Field(..., description="Quote ID to cancel", title="quote_id") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +PrivateCancelQuoteResultSchema = QuoteResultSchema + + +class PrivateGetQuotesParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + from_timestamp: int = Field( + 0, + description="Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0.", + title="from_timestamp", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + quote_id: Optional[UUID] = Field(None, description="Quote ID filter, if applicable", title="quote_id") + rfq_id: Optional[UUID] = Field(None, description="RFQ ID filter, if applicable", title="rfq_id") + status: Optional[Status1] = Field(None, description="Quote status filter, if applicable", title="status") + subaccount_id: int = Field( + ..., + description="Subaccount ID for auth purposes, returned data will be scoped to this subaccount.", + title="subaccount_id", + ) + to_timestamp: int = Field( + 18446744073709552000, + description="Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", + title="to_timestamp", + ) + + +class PrivateGetQuotesResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + quotes: List[QuoteResultSchema] = Field(..., description="Quotes matching filter criteria", title="quotes") + + +class PublicExecuteQuoteDebugParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + direction: Direction = Field( + ..., + description="Quote direction, `buy` means trading each leg at its direction, `sell` means trading each leg in the opposite direction.", + title="direction", + ) + enable_taker_protection: bool = Field( + False, + description="Whether taker protection is enabled for the quote", + title="enable_taker_protection", + ) + label: str = Field("", description="Optional user-defined label for the quote", title="label") + legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") + max_fee: Decimal = Field( + ..., + description="Max fee ($ for the full trade). Request will be rejected if the supplied max fee is below the estimated fee for this trade.", + title="max_fee", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as a concatenated `UTC timestamp in ms` and `random number up to 6 digits` (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + quote_id: UUID = Field(..., description="Quote ID to execute against", title="quote_id") + rfq_id: UUID = Field( + ..., + description="RFQ ID to execute (must be sent by `subaccount_id`)", + title="rfq_id", + ) + signature: str = Field(..., description="Ethereum signature of the quote", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be at least 310 seconds from now. Once time till signature expiry reaches 300 seconds, the quote will be considered expired. This buffer is meant to ensure the trade can settle on chain in case of a blockchain congestion.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed the quote", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class PublicExecuteQuoteDebugResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + action_hash: str = Field(..., description="Keccak hashed action data", title="action_hash") + encoded_data: str = Field(..., description="ABI encoded deposit data", title="encoded_data") + encoded_data_hashed: str = Field(..., description="Keccak hashed encoded_data", title="encoded_data_hashed") + encoded_legs: str = Field(..., description="ABI encoded legs data", title="encoded_legs") + legs_hash: str = Field(..., description="Keccak hashed legs data", title="legs_hash") + typed_data_hash: str = Field(..., description="EIP 712 typed data hash", title="typed_data_hash") + + +class PrivateGetOptionSettlementHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_id: int = Field( + ..., + description="Subaccount ID for which to get expired option settlement history", + title="subaccount_id", + ) + + +class OptionSettlementResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount that was settled", title="amount") + expiry: int = Field(..., description="Expiry timestamp of the option", title="expiry") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + option_settlement_pnl: Decimal = Field( + ..., + description="USD profit or loss from option settlements calculated as: settlement value - (average cost including fees x amount)", + title="option_settlement_pnl", + ) + option_settlement_pnl_excl_fees: Decimal = Field( + ..., + description="USD profit or loss from option settlements calculated as: settlement value - (average price excluding fees x amount)", + title="option_settlement_pnl_excl_fees", + ) + settlement_price: Decimal = Field(..., description="Price of option settlement", title="settlement_price") + subaccount_id: int = Field(..., description="Subaccount ID of the settlement event", title="subaccount_id") + + +class PrivateResetMmpParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: Optional[str] = Field( + None, + description="Currency to reset the mmp for. If not provided, resets all configs for the subaccount", + title="currency", + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to reset the mmp state", + title="subaccount_id", + ) + + +PrivateResetMmpResponseSchema = PrivateCancelRfqResponseSchema + + +PrivateGetErc20TransferHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema + + +class ERC20TransferSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount withdrawn by the subaccount", title="amount") + asset: str = Field(..., description="Asset withdrawn", title="asset") + counterparty_subaccount_id: int = Field( + ..., + description="Recipient or sender subaccount_id of transfer", + title="counterparty_subaccount_id", + ) + is_outgoing: bool = Field( + ..., + description="True if the transfer was initiated by the subaccount, False otherwise", + title="is_outgoing", + ) + timestamp: int = Field( + ..., + description="Timestamp of the transfer (in ms since UNIX epoch)", + title="timestamp", + ) + tx_hash: str = Field( + ..., + description="Hash of the transaction that withdrew the funds", + title="tx_hash", + ) + + +PublicGetAllCurrenciesParamsSchema = PublicGetMakerProgramsParamsSchema + + +class CurrencyDetailedResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + asset_cap_and_supply_per_manager: Dict[str, Dict[str, List[OpenInterestStatsSchema]]] = Field( + ..., + description="Current open interest and open interest cap by manager and asset type", + title="asset_cap_and_supply_per_manager", + ) + borrow_apy: Decimal = Field(..., description="Borrow APY (only for USDC)", title="borrow_apy") + currency: str = Field( + ..., + description="Underlying currency of asset (`ETH`, `BTC`, etc)", + title="currency", + ) + erc20_details: Optional[Dict[str, Optional[str]]] = Field( + None, + description="Details of the erc20 asset (if applicable)", + title="erc20_details", + ) + instrument_types: List[InstrumentType] = Field( + ..., + description="Instrument types supported for the currency", + title="instrument_types", + ) + managers: List[ManagerContractResponseSchema] = Field( + ..., description="Managers supported for the currency", title="managers" + ) + market_type: MarketType = Field(..., description="Market type of the currency", title="market_type") + pm2_collateral_discounts: List[PM2CollateralDiscountsSchema] = Field( + ..., + description="Initial and Maintenance Margin discounts for given collateral in PM2", + title="pm2_collateral_discounts", + ) + protocol_asset_addresses: ProtocolAssetAddressesSchema + spot_price: Decimal = Field(..., description="Spot price of the currency", title="spot_price") + spot_price_24h: Optional[Decimal] = Field( + None, + description="Spot price of the currency 24 hours ago", + title="spot_price_24h", + ) + srm_im_discount: Decimal = Field( + ..., + description="Initial Margin discount for given collateral in Standard Manager (e.g. LTV). Only the Standard Manager supports non-USDC collateral", + title="srm_im_discount", + ) + srm_mm_discount: Decimal = Field( + ..., + description="Maintenance Margin discount for given collateral in Standard Manager (e.g. liquidation threshold). Only the Standard Manager supports non-USDC collateral", + title="srm_mm_discount", + ) + supply_apy: Decimal = Field(..., description="Supply APY (only for USDC)", title="supply_apy") + total_borrow: Decimal = Field( + ..., + description="Total collateral borrowed in the protocol (only USDC is borrowable)", + title="total_borrow", + ) + total_supply: Decimal = Field( + ..., + description="Total collateral supplied in the protocol", + title="total_supply", + ) + + +class PrivateGetSubaccountValueHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field(..., description="End timestamp", title="end_timestamp") + period: int = Field(..., description="Period", title="period") + start_timestamp: int = Field(..., description="Start timestamp", title="start_timestamp") + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class SubAccountValueHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_value: Decimal = Field( + ..., + description="Total mark-to-market value of all positions and collaterals", + title="subaccount_value", + ) + timestamp: int = Field( + ..., + description="Timestamp of when the subaccount value was recorded into the database", + title="timestamp", + ) + + +PublicSendQuoteDebugParamsSchema = PrivateSendQuoteParamsSchema + + +PublicSendQuoteDebugResultSchema = PublicCreateSubaccountDebugResultSchema + + +PublicGetLiveIncidentsParamsSchema = PublicGetMakerProgramsParamsSchema + + +class MonitorType(Enum): + manual = "manual" + auto = "auto" + + +class Severity(Enum): + low = "low" + medium = "medium" + high = "high" + + +class IncidentResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + creation_timestamp_sec: int = Field( + ..., + description="Timestamp of incident in UTC sec", + title="creation_timestamp_sec", + ) + label: str = Field(..., description="Incident label", title="label") + message: str = Field(..., description="Incident message", title="message") + monitor_type: MonitorType = Field(..., description="Incident trigger type", title="monitor_type") + severity: Severity = Field(..., description="Incident severity", title="severity") + + +class PublicGetTransactionParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + transaction_id: UUID = Field( + ..., + description="transaction_id of the transaction to get", + title="transaction_id", + ) + + +class PublicGetTransactionResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + data: str = Field(..., description="Data used to create transaction", title="data") + error_log: Optional[str] = Field(..., description="Error log if failed tx", title="error_log") + status: TxStatus = Field(..., description="Status of the transaction", title="status") + transaction_hash: Optional[str] = Field( + ..., description="Transaction hash of a pending tx", title="transaction_hash" + ) + + +class PrivateGetOrdersParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instrument_name: Optional[str] = Field(None, description="Filter by instrument name", title="instrument_name") + label: Optional[str] = Field(None, description="Filter by label", title="label") + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + status: Optional[OrderStatus] = Field(None, description="Filter by order status", title="status") + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get open orders", + title="subaccount_id", + ) + + +PrivateGetOrdersResultSchema = PrivateGetOrderHistoryResultSchema + + +PrivateGetInterestHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema + + +class InterestPaymentSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + interest: Decimal = Field( + ..., + description="Dollar interest paid (if negative) or received (if positive) by the subaccount", + title="interest", + ) + timestamp: int = Field( + ..., + description="Timestamp of the interest payment (in ms since UNIX epoch)", + title="timestamp", + ) + + +PrivatePollQuotesParamsSchema = PrivateGetQuotesParamsSchema + + +class QuoteResultPublicSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") + creation_timestamp: int = Field( + ..., + description="Creation timestamp in ms since Unix epoch", + title="creation_timestamp", + ) + direction: Direction = Field(..., description="Quote direction", title="direction") + fill_pct: Decimal = Field( + ..., + description="Percentage of the RFQ that this quote would fill, from 0 to 1.", + title="fill_pct", + ) + last_update_timestamp: int = Field( + ..., + description="Last update timestamp in ms since Unix epoch", + title="last_update_timestamp", + ) + legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") + legs_hash: str = Field( + ..., + description="Hash of the legs of the best quote to be signed by the taker.", + title="legs_hash", + ) + liquidity_role: LiquidityRole = Field(..., description="Liquidity role", title="liquidity_role") + quote_id: UUID = Field(..., description="Quote ID", title="quote_id") + rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") + status: Status1 = Field(..., description="Status", title="status") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + tx_hash: Optional[str] = Field( + ..., + description="Blockchain transaction hash (only for executed quotes)", + title="tx_hash", + ) + tx_status: Optional[TxStatus] = Field( + ..., + description="Blockchain transaction status (only for executed quotes)", + title="tx_status", + ) + wallet: str = Field(..., description="Wallet address of the quote sender", title="wallet") + + +class PrivateGetOrderParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + order_id: str = Field(..., description="Order ID", title="order_id") + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +PrivateGetOrderResultSchema = OrderResponseSchema + + +PublicGetVaultStatisticsParamsSchema = PublicGetMakerProgramsParamsSchema + + +class VaultStatisticsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + base_value: Decimal = Field( + ..., + description="The value of the vault's token against the base currency. Ex: rswETHC vs rswETH", + title="base_value", + ) + block_number: int = Field(..., description="The Derive chain block number", title="block_number") + block_timestamp: int = Field( + ..., + description="Timestamp of the Derive chain block number", + title="block_timestamp", + ) + subaccount_value_at_last_trade: Optional[Decimal] = Field( + ..., + description="Will return None before vault creates subaccount or if no trades found.", + title="subaccount_value_at_last_trade", + ) + total_supply: Decimal = Field( + ..., + description="Total supply of the vault's token on Derive chain", + title="total_supply", + ) + underlying_value: Optional[Decimal] = Field( + ..., + description="The value of the vault's token against the underlying currency. Ex: rswETHC vs ETH", + title="underlying_value", + ) + usd_tvl: Decimal = Field(..., description="Total USD TVL of the vault", title="usd_tvl") + usd_value: Decimal = Field(..., description="The value of the vault's token against USD", title="usd_value") + vault_name: str = Field(..., description="Name of the vault", title="vault_name") + + +class PublicWithdrawDebugParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount of the asset to withdraw", title="amount") + asset_name: str = Field(..., description="Name of asset to withdraw", title="asset_name") + is_atomic_signing: bool = Field( + False, + description="Used by vaults to determine whether the signature is an EIP-1271 signature", + title="is_atomic_signing", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the withdraw", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +PublicWithdrawDebugResultSchema = PublicCreateSubaccountDebugResultSchema + + +class Period1(Enum): + field_900 = 900 + field_3600 = 3600 + field_14400 = 14400 + field_28800 = 28800 + field_86400 = 86400 + + +class PublicGetFundingRateHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + end_timestamp: int = Field( + 9223372036854776000, + description="End timestamp of the event history (default current time)", + title="end_timestamp", + ) + instrument_name: str = Field( + ..., + description="Instrument name to return funding history for", + title="instrument_name", + ) + period: Period1 = Field(3600, description="Period of the funding rate", title="period") + start_timestamp: int = Field( + 0, + description="Start timestamp of the event history (default 0)", + title="start_timestamp", + ) + + +class FundingRateSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + funding_rate: Decimal = Field( + ..., + description="Hourly funding rate value at the event time", + title="funding_rate", + ) + timestamp: int = Field( + ..., + description="Timestamp of the funding rate update (in ms since UNIX epoch)", + title="timestamp", + ) + + +class PrivateRfqGetBestQuoteParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + counterparties: Optional[List[str]] = Field( + None, + description="Optional list of market maker account addresses to request quotes from. If not supplied, all market makers who are approved as RFQ makers will be notified.", + title="counterparties", + ) + direction: Direction = Field( + "buy", + description="Planned execution direction (default `buy`)", + title="direction", + ) + label: str = Field("", description="Optional user-defined label for the RFQ", title="label") + legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") + max_total_cost: Optional[Decimal] = Field( + None, + description="An optional max total cost for the RFQ. Only used when the RFQ sender executes as buyer. Polling endpoints and channels will ignore quotes where the total cost across all legs is above this value. Positive values mean the RFQ sender expects to pay $, negative mean the RFQ sender expects to receive $.This field is not disclosed to the market makers.", + title="max_total_cost", + ) + min_total_cost: Optional[Decimal] = Field( + None, + description="An optional min total cost for the RFQ. Only used when the RFQ sender executes as seller. Polling endpoints and channels will ignore quotes where the total cost across all legs is below this value. Positive values mean the RFQ sender expects to receive $, negative mean the RFQ sender expects to pay $.This field is not disclosed to the market makers.", + title="min_total_cost", + ) + partial_fill_step: Decimal = Field( + "1", + description="Optional step size for partial fills. If not supplied, the RFQ will not support partial fills.", + title="partial_fill_step", + ) + rfq_id: Optional[UUID] = Field( + None, + description="RFQ ID to get best quote for. If not provided, will return estimates based on mark prices", + title="rfq_id", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class InvalidReason(Enum): + Account_is_currently_under_maintenance_margin_requirements__trading_is_frozen_ = ( + "Account is currently under maintenance margin requirements, trading is frozen." + ) + This_order_would_cause_account_to_fall_under_maintenance_margin_requirements_ = ( + "This order would cause account to fall under maintenance margin requirements." + ) + Insufficient_buying_power__only_a_single_risk_reducing_open_order_is_allowed_ = ( + "Insufficient buying power, only a single risk-reducing open order is allowed." + ) + Insufficient_buying_power__consider_reducing_order_size_ = ( + "Insufficient buying power, consider reducing order size." + ) + Insufficient_buying_power__consider_reducing_order_size_or_canceling_other_orders_ = ( + "Insufficient buying power, consider reducing order size or canceling other orders." + ) + Consider_canceling_other_limit_orders_or_using_IOC__FOK__or_market_orders__This_order_is_risk_reducing__but_if_filled_with_other_open_orders__buying_power_might_be_insufficient_ = "Consider canceling other limit orders or using IOC, FOK, or market orders. This order is risk-reducing, but if filled with other open orders, buying power might be insufficient." + Insufficient_buying_power_ = "Insufficient buying power." + + +class PrivateRfqGetBestQuoteResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + best_quote: Optional[QuoteResultPublicSchema] = Field(...) + direction: Direction = Field(..., description="RFQ direction.", title="direction") + down_liquidation_price: Optional[Decimal] = Field( + ..., + description="Liquidation price if the trade were to be filled and the market moves down.", + title="down_liquidation_price", + ) + estimated_fee: Decimal = Field( + ..., + description="An estimate for how much the user will pay in fees ($ for the whole trade).", + title="estimated_fee", + ) + estimated_realized_pnl: Decimal = Field( + ..., + description="An estimate for the realized PnL of the trade.", + title="estimated_realized_pnl", + ) + estimated_realized_pnl_excl_fees: Decimal = Field( + ..., + description="An estimate for the realized PnL of the trade. with cost basis calculated without considering fees.", + title="estimated_realized_pnl_excl_fees", + ) + estimated_total_cost: Decimal = Field( + ..., + description="An estimate for the total $ cost of the trade.", + title="estimated_total_cost", + ) + filled_pct: Decimal = Field( + ..., + description="Percentage of the RFQ that has already been filled, from 0 to 1.", + title="filled_pct", + ) + invalid_reason: Optional[InvalidReason] = Field( + ..., + description="Reason for the RFQ being invalid, if any.", + title="invalid_reason", + ) + is_valid: bool = Field( + ..., + description="`True` if RFQ is expected to pass margin requirements.", + title="is_valid", + ) + orderbook_total_cost: Optional[Decimal] = Field( + ..., + description="Total cost of the RFQ if it were to be filled at current orderbook prices (same direction as the RFQ). If lower than `estimated_total_cost`, the user may want to use the orderbook instead of RFQs for this order. Will return null if any of the legs do not have orderbook data or enough liquidity for the full fill.", + title="orderbook_total_cost", + ) + post_initial_margin: Decimal = Field( + ..., + description="User's hypothetical margin balance if the trade were to get executed.", + title="post_initial_margin", + ) + post_liquidation_price: Optional[Decimal] = Field( + ..., + description="Liquidation price if the trade were to be filled. If both upside and downside liquidation prices exist, returns the closest one to the current index price.", + title="post_liquidation_price", + ) + pre_initial_margin: Decimal = Field( + ..., + description="User's initial margin balance before the trade.", + title="pre_initial_margin", + ) + suggested_max_fee: Decimal = Field( + ..., + description="Recommended value for `max_fee` of the trade.", + title="suggested_max_fee", + ) + up_liquidation_price: Optional[Decimal] = Field( + ..., + description="Liquidation price if the trade were to be filled and the market moves up.", + title="up_liquidation_price", + ) + + +class PublicGetInstrumentsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field( + ..., + description="Underlying currency of asset (`ETH`, `BTC`, etc)", + title="currency", + ) + expired: bool = Field( + ..., + description="If `True`: include expired assets. Note: will soon be capped up to only 1 week in the past.", + title="expired", + ) + instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") + + +class PublicGetInstrumentsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[InstrumentPublicResponseSchema] = Field(..., description="", title="result") + + +class PublicGetOptionSettlementHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + subaccount_id: Optional[int] = Field( + None, + description="Subaccount ID filter (defaults to all if not provided)", + title="subaccount_id", + ) + + +class PublicGetOptionSettlementHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + settlements: List[OptionSettlementResponseSchema] = Field( + ..., description="List of expired option settlements", title="settlements" + ) + + +class PrivateLiquidateParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cash_transfer: Decimal = Field( + ..., + description="Amount of cash to transfer to a newly created subaccount for bidding. Must be non-negative.", + title="cash_transfer", + ) + last_seen_trade_id: int = Field( + ..., + description="Last seen trade ID for account being liquidated. Not checked if set to 0.", + title="last_seen_trade_id", + ) + liquidated_subaccount_id: int = Field( + ..., + description="Subaccount ID of the account to be liquidated.", + title="liquidated_subaccount_id", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + percent_bid: Decimal = Field( + ..., + description="Percent of the liquidated position to bid for. Will bid for the maximum possible percent of the position if set to 1", + title="percent_bid", + ) + price_limit: Decimal = Field( + ..., + description="Maximum amount of cash to be paid from bidder to liquidated account (supports negative amounts for insolvent auctions). Not checked if set to 0.", + title="price_limit", + ) + signature: str = Field(..., description="Ethereum signature of the order", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed order", + title="signer", + ) + subaccount_id: int = Field( + ..., + description="Subaccount ID owned by wallet, that will be doing the bidding.", + title="subaccount_id", + ) + + +class PrivateLiquidateResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + estimated_bid_price: Decimal = Field( + ..., + description="Estimated bid price for this liquidation", + title="estimated_bid_price", + ) + estimated_discount_pnl: Decimal = Field( + ..., + description="Estimated profit (increase in the subaccount mark value) if the liquidation is successful.", + title="estimated_discount_pnl", + ) + estimated_percent_bid: Decimal = Field( + ..., + description="Estimated percent of account the bid will aquire", + title="estimated_percent_bid", + ) + transaction_id: UUID = Field( + ..., + description="The transaction id of the related settlement transaction", + title="transaction_id", + ) + + +class PrivateGetTradeHistoryParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + from_timestamp: int = Field( + 0, + description="Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0.", + title="from_timestamp", + ) + instrument_name: Optional[str] = Field(None, description="Instrument name to filter by", title="instrument_name") + order_id: Optional[str] = Field(None, description="Order id to filter by", title="order_id") + page: int = Field( + 1, + description="Page number of results to return (default 1, returns last if above `num_pages`)", + title="page", + ) + page_size: int = Field( + 100, + description="Number of results per page (default 100, max 1000)", + title="page_size", + ) + quote_id: Optional[str] = Field( + None, + description="If supplied, quote id to filter by. Supports either a concrete UUID, or `is_quote` and `is_not_quote` enum", + title="quote_id", + ) + subaccount_id: Optional[int] = Field( + None, + description="Subaccount_id (must be set if wallet is blank)", + title="subaccount_id", + ) + to_timestamp: int = Field( + 18446744073709552000, + description="Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", + title="to_timestamp", + ) + wallet: Optional[str] = Field( + None, + description="Wallet address (if set, subaccount_id ignored)", + title="wallet", + ) + + +class PrivateGetTradeHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + subaccount_id: int = Field( + ..., + description="Subaccount ID requested, or 0 if not provided", + title="subaccount_id", + ) + trades: List[TradeResponseSchema] = Field(..., description="List of trades", title="trades") + + +class PublicGetLatestSignedFeedsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: Optional[str] = Field( + None, + description="Currency filter, (defaults to all currencies)", + title="currency", + ) + expiry: Optional[int] = Field( + None, + description="Expiry filter for options and forward data (defaults to all expiries). Use `0` to get data only for spot and perpetuals", + title="expiry", + ) + + +class OracleSignatureDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + signatures: Optional[List[str]] = Field(None, description="The signatures of the given signers", title="signatures") + signers: Optional[List[str]] = Field(None, description="The signers who verify the data integrity", title="signers") + + +class Type(Enum): + P = "P" + A = "A" + B = "B" + + +class PerpFeedDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") + currency: str = Field( + ..., + description="The currency for which the spot feed represents", + title="currency", + ) + deadline: int = Field( + ..., + description="The latest time the data can be submitted on chain", + title="deadline", + ) + signatures: OracleSignatureDataSchema + spot_diff_value: Decimal = Field( + ..., + description="The difference between the spot price and the perp price", + title="spot_diff_value", + ) + timestamp: int = Field( + ..., + description="The timestamp for which the data was created", + title="timestamp", + ) + type: Type = Field( + ..., + description="The type of perp feed; mid price, ask impact or bid impact", + title="type", + ) + + +class RateFeedDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + confidence: Decimal = Field(..., description="The confidence score of the rate", title="confidence") + currency: str = Field( + ..., + description="The currency for which the spot feed represents", + title="currency", + ) + deadline: int = Field( + ..., + description="The latest time the data can be submitted on chain", + title="deadline", + ) + expiry: int = Field(..., description="The expiry for the rate feed", title="expiry") + rate: Decimal = Field(..., description="The implied rate for the currency/expiry", title="rate") + signatures: OracleSignatureDataSchema + timestamp: int = Field( + ..., + description="The timestamp for which the data was created", + title="timestamp", + ) + + +class FeedSourceType(Enum): + S = "S" + O = "O" + + +class SpotFeedDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") + currency: str = Field( + ..., + description="The currency for which the spot feed represents", + title="currency", + ) + deadline: int = Field( + ..., + description="The latest time the data can be submitted on chain", + title="deadline", + ) + feed_source_type: FeedSourceType = Field("S", description="The source of the feed", title="feed_source_type") + price: Decimal = Field(..., description="The price of the currency in USD", title="price") + signatures: OracleSignatureDataSchema + timestamp: int = Field( + ..., + description="The timestamp for which the data was created", + title="timestamp", + ) + + +class VolSVIParamDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + SVI_a: Decimal = Field(..., title="SVI_a") + SVI_b: Decimal = Field(..., title="SVI_b") + SVI_fwd: Decimal = Field(..., title="SVI_fwd") + SVI_m: Decimal = Field(..., title="SVI_m") + SVI_refTau: Decimal = Field(..., title="SVI_refTau") + SVI_rho: Decimal = Field(..., title="SVI_rho") + SVI_sigma: Decimal = Field(..., title="SVI_sigma") + + +class PrivateReplaceParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") + direction: Direction = Field(..., description="Order direction", title="direction") + expected_filled_amount: Optional[Decimal] = Field( + None, + description="Optional check to only create new order if old order filled_amount is equal to this value.", + title="expected_filled_amount", + ) + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + is_atomic_signing: Optional[bool] = Field( + False, + description="Used by vaults to determine whether the signature is an EIP-1271 signature.", + title="is_atomic_signing", + ) + label: str = Field("", description="Optional user-defined label for the order", title="label") + limit_price: Decimal = Field( + ..., + description="Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.", + title="limit_price", + ) + max_fee: Decimal = Field( + ..., + description="Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.", + title="max_fee", + ) + mmp: bool = Field( + False, + description="Whether the order is tagged for market maker protections (default false)", + title="mmp", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.", + title="nonce", + ) + nonce_to_cancel: Optional[int] = Field( + None, + description="Cancel order by nonce (choose either order_id or nonce).", + title="nonce_to_cancel", + ) + order_id_to_cancel: Optional[UUID] = Field( + None, + description="Cancel order by order_id (choose either order_id or nonce).", + title="order_id_to_cancel", + ) + order_type: OrderType = Field( + "limit", + description="Order type:
- `limit`: limit order (default)
- `market`: market order, note that limit_price is still required for market orders, but unfilled order portion will be marked as cancelled", + title="order_type", + ) + reduce_only: bool = Field( + False, + description="If true, the order will not be able to increase position's size (default false). If the order amount exceeds available position size, the order will be filled up to the position size and the remainder will be cancelled. This flag is only supported for market orders or non-resting limit orders (IOC or FOK)", + title="reduce_only", + ) + referral_code: str = Field("", description="Optional referral code for the order", title="referral_code") + reject_timestamp: int = Field( + 9223372036854776000, + description="UTC timestamp in ms, if provided the matching engine will reject the order with an error if `reject_timestamp` < `server_time`. Note that the timestamp must be consistent with the server time: use `public/get_time` method to obtain current server time.", + title="reject_timestamp", + ) + signature: str = Field(..., description="Ethereum signature of the order", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Owner wallet address or registered session key that signed order", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + time_in_force: TimeInForce = Field( + "gtc", + description="Time in force behaviour:
- `gtc`: good til cancelled (default)
- `post_only`: a limit order that will be rejected if it crosses any order in the book, i.e. acts as a taker order
- `fok`: fill or kill, will be rejected if it is not fully filled
- `ioc`: immediate or cancel, fill at best bid/ask (market) or at limit price (limit), the unfilled portion is cancelled
Note that the order will still expire on the `signature_expiry_sec` timestamp.", + title="time_in_force", + ) + trigger_price: Optional[Decimal] = Field( + None, + description='(Required for trigger orders) "index" or "mark" price to trigger order at', + title="trigger_price", + ) + trigger_price_type: Optional[TriggerPriceType] = Field( + None, + description='(Required for trigger orders) Trigger with "mark" price as "index" price type not supported yet.', + title="trigger_price_type", + ) + trigger_type: Optional[TriggerType] = Field( + None, + description='(Required for trigger orders) "stoploss" or "takeprofit"', + title="trigger_type", + ) + + +class RPCErrorFormatSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + code: int = Field(..., title="code") + data: Optional[str] = Field(None, title="data") + message: str = Field(..., title="message") + + +class PrivateCancelByInstrumentParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instrument_name: str = Field( + ..., + description="Cancel all orders for this instrument", + title="instrument_name", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +PrivateCancelByInstrumentResultSchema = PrivateCancelByNonceResultSchema + + +class PrivateCancelAllParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_id: int = Field(..., title="subaccount_id") + + +PrivateCancelAllResponseSchema = PrivateSetCancelOnDisconnectResponseSchema + + +class PublicDeregisterSessionKeyParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + signed_raw_tx: str = Field( + ..., + description="A signed RLP encoded ETH transaction in form of a hex string (same as `w3.eth.account.sign_transaction(unsigned_tx, private_key).rawTransaction.hex()`)", + title="signed_raw_tx", + ) + wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") + + +class PublicDeregisterSessionKeyResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + public_session_key: str = Field( + ..., + description="Session key in the form of an Ethereum EOA", + title="public_session_key", + ) + transaction_id: UUID = Field(..., description="ID to lookup status of transaction", title="transaction_id") + + +class PrivateWithdrawParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount: Decimal = Field(..., description="Amount of the asset to withdraw", title="amount") + asset_name: str = Field(..., description="Name of asset to withdraw", title="asset_name") + is_atomic_signing: bool = Field( + False, + description="Used by vaults to determine whether the signature is an EIP-1271 signature", + title="is_atomic_signing", + ) + nonce: int = Field( + ..., + description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", + title="nonce", + ) + signature: str = Field(..., description="Ethereum signature of the withdraw", title="signature") + signature_expiry_sec: int = Field( + ..., + description="Unix timestamp in seconds. Expiry MUST be >5min from now", + title="signature_expiry_sec", + ) + signer: str = Field( + ..., + description="Ethereum wallet address that is signing the withdraw", + title="signer", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PrivateWithdrawResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + status: str = Field(..., description="`requested`", title="status") + transaction_id: UUID = Field(..., description="Transaction id of the withdrawal", title="transaction_id") + + +class PrivateGetNotificationsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + notifications: List[NotificationResponseSchema] = Field( + ..., description="Notification response", title="notifications" + ) + pagination: PaginationInfoSchema + + +PublicGetCurrencyResultSchema = CurrencyDetailedResponseSchema + + +class PrivateSetMmpConfigResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateSetMmpConfigResultSchema + + +class PrivateTransferPositionParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + maker_params: TradeModuleParamsSchema + taker_params: TradeModuleParamsSchema + wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") + + +class PrivateTransferPositionResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + maker_order: OrderResponseSchema + maker_trade: TradeResponseSchema + taker_order: OrderResponseSchema + taker_trade: TradeResponseSchema + + +class PrivateCreateSubaccountResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCreateSubaccountResultSchema + + +class PrivateSendRfqParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + counterparties: Optional[List[str]] = Field( + None, + description="Optional list of market maker account addresses to request quotes from. If not supplied, all market makers who are approved as RFQ makers will be notified.", + title="counterparties", + ) + label: str = Field("", description="Optional user-defined label for the RFQ", title="label") + legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") + max_total_cost: Optional[Decimal] = Field( + None, + description="An optional max total cost for the RFQ. Only used when the RFQ sender executes as buyer. Polling endpoints and channels will ignore quotes where the total cost across all legs is above this value. Positive values mean the RFQ sender expects to pay $, negative mean the RFQ sender expects to receive $.This field is not disclosed to the market makers.", + title="max_total_cost", + ) + min_total_cost: Optional[Decimal] = Field( + None, + description="An optional min total cost for the RFQ. Only used when the RFQ sender executes as seller. Polling endpoints and channels will ignore quotes where the total cost across all legs is below this value. Positive values mean the RFQ sender expects to receive $, negative mean the RFQ sender expects to pay $.This field is not disclosed to the market makers.", + title="min_total_cost", + ) + partial_fill_step: Decimal = Field( + "1", + description="Optional step size for partial fills. If not supplied, the RFQ will not support partial fills.", + title="partial_fill_step", + ) + subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") + + +class PrivateSendRfqResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateSendRfqResultSchema + + +class PublicMarginWatchResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + collaterals: List[CollateralPublicResponseSchema] = Field( + ..., + description="All collaterals that count towards margin of subaccount", + title="collaterals", + ) + currency: str = Field(..., description="Currency of subaccount", title="currency") + initial_margin: Decimal = Field( + ..., + description="Total initial margin requirement of all positions and collaterals.", + title="initial_margin", + ) + maintenance_margin: Decimal = Field( + ..., + description="Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation.", + title="maintenance_margin", + ) + margin_type: MarginType = Field( + ..., + description="Margin type of subaccount (`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", + title="margin_type", + ) + positions: List[PositionPublicResponseSchema] = Field( + ..., description="All active positions of subaccount", title="positions" + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + subaccount_value: Decimal = Field( + ..., + description="Total mark-to-market value of all positions and collaterals", + title="subaccount_value", + ) + valuation_timestamp: int = Field( + ..., + description="Timestamp (in seconds since epoch) of when margin and MtM were computed.", + title="valuation_timestamp", + ) + + +class PublicStatisticsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicStatisticsResultSchema + + +class PrivateCancelResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelResultSchema + + +PrivateExecuteQuoteParamsSchema = PublicExecuteQuoteDebugParamsSchema + + +class PrivateExecuteQuoteResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateExecuteQuoteResultSchema + + +class PublicGetSpotFeedHistoryCandlesResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency", title="currency") + spot_feed_history: List[SpotFeedHistoryCandlesResponseSchema] = Field( + ..., description="Spot feed history candles", title="spot_feed_history" + ) + + +class PrivatePollRfqsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + rfqs: List[RFQResultPublicSchema] = Field(..., description="RFQs matching filter criteria", title="rfqs") + + +class AuctionResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + auction_id: str = Field(..., description="Unique ID of the auction", title="auction_id") + auction_type: AuctionType = Field(..., description="Type of auction", title="auction_type") + bids: List[AuctionBidEventSchema] = Field(..., description="List of auction bid events", title="bids") + end_timestamp: Optional[int] = Field( + ..., + description="Timestamp of the auction end (in ms since UNIX epoch), or `null` if not ended", + title="end_timestamp", + ) + fee: Decimal = Field(..., description="Fee paid by the subaccount", title="fee") + start_timestamp: int = Field( + ..., + description="Timestamp of the auction start (in ms since UNIX epoch)", + title="start_timestamp", + ) + subaccount_id: int = Field(..., description="Liquidated subaccount ID", title="subaccount_id") + tx_hash: str = Field( + ..., + description="Hash of the transaction that started the auction", + title="tx_hash", + ) + + +class SignedTradeOrderSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + data: TradeModuleDataSchema + expiry: int = Field(..., title="expiry") + is_atomic_signing: bool = Field(..., title="is_atomic_signing") + module: str = Field(..., title="module") + nonce: int = Field(..., title="nonce") + owner: str = Field(..., title="owner") + signature: str = Field(..., title="signature") + signer: str = Field(..., title="signer") + subaccount_id: int = Field(..., title="subaccount_id") + + +class PrivateDepositResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateDepositResultSchema + + +class PrivateUpdateNotificationsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateUpdateNotificationsResultSchema + + +class PrivateChangeSubaccountLabelResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateChangeSubaccountLabelResultSchema + + +class PrivateTransferPositionsParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + maker_params: SignedQuoteParamsSchema + taker_params: SignedQuoteParamsSchema + wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") + + +class PrivateTransferPositionsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + maker_quote: QuoteResultSchema + taker_quote: QuoteResultSchema + + +class PublicGetMakerProgramsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[ProgramResponseSchema] = Field(..., description="", title="result") + + +class PublicGetMarginParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + margin_type: MarginType = Field( + ..., + description="`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", + title="margin_type", + ) + market: Optional[str] = Field(None, description="Must be defined for Portfolio Margin", title="market") + simulated_collateral_changes: Optional[List[SimulatedCollateralSchema]] = Field( + None, + description="Optional, add collaterals to simulate deposits / withdrawals / spot trades", + title="simulated_collateral_changes", + ) + simulated_collaterals: List[SimulatedCollateralSchema] = Field( + ..., + description="List of collaterals in a simulated portfolio", + title="simulated_collaterals", + ) + simulated_position_changes: Optional[List[SimulatedPositionSchema]] = Field( + None, + description="Optional, add positions to simulate perp / option trades", + title="simulated_position_changes", + ) + simulated_positions: List[SimulatedPositionSchema] = Field( + ..., + description="List of positions in a simulated portfolio", + title="simulated_positions", + ) + + +class PublicGetMarginResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetMarginResultSchema + + +class PrivateCancelByNonceResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelByNonceResultSchema + + +class PublicGetSpotFeedHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + currency: str = Field(..., description="Currency", title="currency") + spot_feed_history: List[SpotFeedHistoryResponseSchema] = Field( + ..., description="Spot feed history", title="spot_feed_history" + ) + + +class PrivateGetSubaccountsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetSubaccountsResultSchema + + +class PrivateGetDepositHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + events: List[DepositSchema] = Field(..., description="List of deposit payments", title="events") + + +class PrivateCancelByLabelResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelByLabelResultSchema + + +class PrivateGetMarginResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetMarginResultSchema + + +class PublicCreateSubaccountDebugResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicCreateSubaccountDebugResultSchema + + +PublicGetInstrumentResultSchema = InstrumentPublicResponseSchema + + +class PrivateEditSessionKeyResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateEditSessionKeyResultSchema + + +class PrivateGetLiquidatorHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetLiquidatorHistoryResultSchema + + +class PrivateGetPositionsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + positions: List[PositionResponseSchema] = Field( + ..., description="All active positions of subaccount", title="positions" + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PublicGetTradeHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + trades: List[TradeSettledPublicResponseSchema] = Field(..., description="List of trades", title="trades") + + +class PrivateGetRfqsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + rfqs: List[RFQResultSchema] = Field(..., description="RFQs matching filter criteria", title="rfqs") + + +class PrivateTransferErc20ParamsSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + recipient_details: SignatureDetailsSchema + recipient_subaccount_id: int = Field( + ..., + description="Subaccount_id of the recipient", + title="recipient_subaccount_id", + ) + sender_details: SignatureDetailsSchema + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + transfer: TransferDetailsSchema + + +class PrivateTransferErc20ResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateTransferErc20ResultSchema + + +class PrivateSendQuoteResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateSendQuoteResultSchema + + +class PrivateCancelTriggerOrderResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelTriggerOrderResultSchema + + +class PrivateGetWithdrawalHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + events: List[WithdrawalSchema] = Field(..., description="List of withdrawals", title="events") + + +class PublicGetOptionSettlementPricesResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + expiries: List[ExpiryResponseSchema] = Field(..., description="List of expiry details", title="expiries") + + +class PublicGetMakerProgramScoresResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + program: ProgramResponseSchema + scores: List[ScoreBreakdownSchema] = Field( + ..., + description="Scores breakdown of the program by market maker", + title="scores", + ) + total_score: Decimal = Field( + ..., + description="Total score across all market makers for the epoch", + title="total_score", + ) + total_volume: Decimal = Field( + ..., + description="Total volume across all market makers for the epoch", + title="total_volume", + ) + + +class PublicBuildRegisterSessionKeyTxResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicBuildRegisterSessionKeyTxResultSchema + + +class PublicRegisterSessionKeyResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicRegisterSessionKeyResultSchema + + +class PrivateGetOrderHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetOrderHistoryResultSchema + + +class PrivateCancelBatchRfqsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelBatchRfqsResultSchema + + +class PrivateCancelBatchQuotesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelBatchQuotesResultSchema + + +class PrivateGetFundingHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + events: List[FundingPaymentSchema] = Field(..., description="List of funding payments", title="events") + pagination: PaginationInfoSchema + + +class PrivateGetOpenOrdersResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetOpenOrdersResultSchema + + +class PrivateGetAccountResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancel_on_disconnect: bool = Field( + ..., + description="Whether cancel on disconnect is enabled for the account", + title="cancel_on_disconnect", + ) + fee_info: AccountFeeInfoSchema + is_rfq_maker: bool = Field( + ..., + description="Whether account allowed to market make RFQs", + title="is_rfq_maker", + ) + per_endpoint_tps: Dict[str, Any] = Field( + ..., + description="If a particular endpoint has a different max TPS, it will be specified here", + title="per_endpoint_tps", + ) + referral_code: Optional[str] = Field( + None, + description="Referral code for the account (must register with broker program first)", + title="referral_code", + ) + subaccount_ids: List[int] = Field( + ..., + description="List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + title="subaccount_ids", + ) + wallet: str = Field(..., description="Ethereum wallet address", title="wallet") + websocket_matching_tps: int = Field( + ..., + description="Max transactions per second for matching requests over websocket (see `Rate Limiting` in docs)", + title="websocket_matching_tps", + ) + websocket_non_matching_tps: int = Field( + ..., + description="Max transactions per second for non-matching requests over websocket (see `Rate Limiting` in docs)", + title="websocket_non_matching_tps", + ) + websocket_option_tps: int = Field( + ..., + description="Max transactions per second for EACH option instrument over websocket (see `Rate Limiting` in docs)", + title="websocket_option_tps", + ) + websocket_perp_tps: int = Field( + ..., + description="Max transactions per second for EACH perp instrument over websocket (see `Rate Limiting` in docs)", + title="websocket_perp_tps", + ) + + +class PublicGetAllInstrumentsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + instruments: List[InstrumentPublicResponseSchema] = Field( + ..., description="List of instruments", title="instruments" + ) + pagination: PaginationInfoSchema + + +class PublicGetTickerResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + amount_step: Decimal = Field(..., description="Minimum valid increment of order amount", title="amount_step") + base_asset_address: str = Field( + ..., + description="Blockchain address of the base asset", + title="base_asset_address", + ) + base_asset_sub_id: str = Field( + ..., + description="Sub ID of the specific base asset as defined in Asset.sol", + title="base_asset_sub_id", + ) + base_currency: str = Field( + ..., + description="Underlying currency of base asset (`ETH`, `BTC`, etc)", + title="base_currency", + ) + base_fee: Decimal = Field(..., description="$ base fee added to every taker order", title="base_fee") + best_ask_amount: Decimal = Field( + ..., + description="Amount of contracts / tokens available at best ask price", + title="best_ask_amount", + ) + best_ask_price: Decimal = Field(..., description="Best ask price", title="best_ask_price") + best_bid_amount: Decimal = Field( + ..., + description="Amount of contracts / tokens available at best bid price", + title="best_bid_amount", + ) + best_bid_price: Decimal = Field(..., description="Best bid price", title="best_bid_price") + erc20_details: Optional[ERC20PublicDetailsSchema] = Field(...) + fifo_min_allocation: Decimal = Field( + ..., + description="Minimum number of contracts that get filled using FIFO. Actual number of contracts that gets filled by FIFO will be the max between this value and (1 - pro_rata_fraction) x order_amount, plus any size leftovers due to rounding.", + title="fifo_min_allocation", + ) + five_percent_ask_depth: Decimal = Field( + ..., + description="Total amount of contracts / tokens available at 5 percent above best ask price", + title="five_percent_ask_depth", + ) + five_percent_bid_depth: Decimal = Field( + ..., + description="Total amount of contracts / tokens available at 5 percent below best bid price", + title="five_percent_bid_depth", + ) + index_price: Decimal = Field(..., description="Index price", title="index_price") + instrument_name: str = Field(..., description="Instrument name", title="instrument_name") + instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") + is_active: bool = Field( + ..., + description="If `True`: instrument is tradeable within `activation` and `deactivation` timestamps", + title="is_active", + ) + maker_fee_rate: Decimal = Field( + ..., + description="Percent of spot price fee rate for makers", + title="maker_fee_rate", + ) + mark_price: Decimal = Field(..., description="Mark price", title="mark_price") + mark_price_fee_rate_cap: Optional[Decimal] = Field( + None, + description="Percent of option price fee cap, e.g. 12.5%, null if not applicable", + title="mark_price_fee_rate_cap", + ) + max_price: Decimal = Field( + ..., + description="Maximum price at which an agressive buyer can be matched. Any portion of a market order that would execute above this price will be cancelled. A limit buy order with limit price above this value is treated as post only (i.e. it will be rejected if it would cross any existing resting order).", + title="max_price", + ) + maximum_amount: Decimal = Field( + ..., + description="Maximum valid amount of contracts / tokens per trade", + title="maximum_amount", + ) + min_price: Decimal = Field( + ..., + description="Minimum price at which an agressive seller can be matched. Any portion of a market order that would execute below this price will be cancelled. A limit sell order with limit price below this value is treated as post only (i.e. it will be rejected if it would cross any existing resting order).", + title="min_price", + ) + minimum_amount: Decimal = Field( + ..., + description="Minimum valid amount of contracts / tokens per trade", + title="minimum_amount", + ) + open_interest: Dict[str, List[OpenInterestStatsSchema]] = Field( + ..., + description="Margin type of subaccount (`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin)) -> (current open interest, open interest cap, manager currency)", + title="open_interest", + ) + option_details: Optional[OptionPublicDetailsSchema] = Field(...) + option_pricing: Optional[OptionPricingSchema] = Field(...) + perp_details: Optional[PerpPublicDetailsSchema] = Field(...) + pro_rata_amount_step: Decimal = Field( + ..., + description="Pro-rata fill share of every order is rounded down to be a multiple of this number. Leftovers of the order due to rounding are filled FIFO.", + title="pro_rata_amount_step", + ) + pro_rata_fraction: Decimal = Field( + ..., + description="Fraction of order that gets filled using pro-rata matching. If zero, the matching is full FIFO.", + title="pro_rata_fraction", + ) + quote_currency: str = Field( + ..., + description="Quote currency (`USD` for perps, `USDC` for options)", + title="quote_currency", + ) + scheduled_activation: int = Field( + ..., + description="Timestamp at which became or will become active (if applicable)", + title="scheduled_activation", + ) + scheduled_deactivation: int = Field( + ..., + description="Scheduled deactivation time for instrument (if applicable)", + title="scheduled_deactivation", + ) + stats: AggregateTradingStatsSchema + taker_fee_rate: Decimal = Field( + ..., + description="Percent of spot price fee rate for takers", + title="taker_fee_rate", + ) + tick_size: Decimal = Field( + ..., + description="Tick size of the instrument, i.e. minimum price increment", + title="tick_size", + ) + timestamp: int = Field(..., description="Timestamp of the ticker feed snapshot", title="timestamp") + + +class PublicGetVaultShareResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + vault_shares: List[VaultShareResponseSchema] = Field( + ..., + description="List of vault history shares, recent first", + title="vault_shares", + ) + + +class PrivateGetCollateralsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + collaterals: List[CollateralResponseSchema] = Field( + ..., + description="All collaterals that count towards margin of subaccount", + title="collaterals", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + + +class PrivateRegisterScopedSessionKeyResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateRegisterScopedSessionKeyResultSchema + + +class PrivateExpiredAndCancelledHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateExpiredAndCancelledHistoryResultSchema + + +class PrivateSessionKeysResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + public_session_keys: List[SessionKeyResponseSchema] = Field( + ..., + description="List of session keys (includes unactivated and expired keys)", + title="public_session_keys", + ) + + +class PrivateGetMmpConfigResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[MMPConfigResultSchema] = Field(..., description="", title="result") + + +class PrivateOrderResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateOrderResultSchema + + +class PrivateGetSubaccountResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetSubaccountResultSchema + + +class PublicGetInterestRateHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + interest_rates: List[InterestRateHistoryResponseSchema] = Field( + ..., description="List of interest rates, recent first", title="interest_rates" + ) + pagination: PaginationInfoSchema + + +class PublicGetLiquidationHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + auctions: List[AuctionResultSchema] = Field(..., description="List of auction results", title="auctions") + pagination: PaginationInfoSchema + + +class PublicDepositDebugResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicDepositDebugResultSchema + + +class PublicGetVaultBalancesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[VaultBalanceResponseSchema] = Field(..., description="", title="result") + + +class PublicGetReferralPerformanceResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + fee_share_percentage: Decimal = Field( + ..., + description="Fee share percentage rewarded to referrer", + title="fee_share_percentage", + ) + referral_code: str = Field(..., description="Referral code used to get performance", title="referral_code") + rewards: Dict[str, Dict[str, Dict[str, ReferralPerformanceByInstrumentTypeSchema]]] = Field( + ..., + description="Performance by liquidity role / currency / instrument type", + title="rewards", + ) + stdrv_balance: Decimal = Field( + ..., + description="Staked DRV held used to determine fee share percentage", + title="stdrv_balance", + ) + total_fee_rewards: Decimal = Field(..., description="Total fee rewards to referrers", title="total_fee_rewards") + total_notional_volume: Decimal = Field( + ..., description="Total referred notional volume", title="total_notional_volume" + ) + total_referred_fees: Decimal = Field( + ..., + description="Total fees paid by referred traders (double counts if both taker and maker of a trade with rebated fees)", + title="total_referred_fees", + ) + + +class PrivateCancelQuoteResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelQuoteResultSchema + + +class PrivateGetQuotesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetQuotesResultSchema + + +class PublicExecuteQuoteDebugResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicExecuteQuoteDebugResultSchema + + +class PrivateGetOptionSettlementHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + settlements: List[OptionSettlementResponseSchema] = Field( + ..., description="List of expired option settlements", title="settlements" + ) + subaccount_id: int = Field( + ..., + description="Subaccount_id for which to get expired option settlement history", + title="subaccount_id", + ) + + +class PrivateGetErc20TransferHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + events: List[ERC20TransferSchema] = Field(..., description="List of erc20 transfers", title="events") + + +class PublicGetAllCurrenciesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[CurrencyDetailedResponseSchema] = Field(..., description="", title="result") + + +class PrivateGetSubaccountValueHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + subaccount_value_history: List[SubAccountValueHistoryResponseSchema] = Field( + ..., description="Subaccount value history", title="subaccount_value_history" + ) + + +class PublicSendQuoteDebugResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicSendQuoteDebugResultSchema + + +class PublicGetLiveIncidentsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + incidents: List[IncidentResponseSchema] = Field(..., description="List of ongoing incidents", title="incidents") + + +class PublicGetTransactionResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetTransactionResultSchema + + +class PrivateGetOrdersResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetOrdersResultSchema + + +class PrivateGetInterestHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + events: List[InterestPaymentSchema] = Field(..., description="List of interest payments", title="events") + + +class PrivatePollQuotesResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + pagination: PaginationInfoSchema + quotes: List[QuoteResultPublicSchema] = Field(..., description="Quotes matching filter criteria", title="quotes") + + +class PrivateGetOrderResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetOrderResultSchema + + +class PublicGetVaultStatisticsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[VaultStatisticsResponseSchema] = Field(..., description="", title="result") + + +class PublicWithdrawDebugResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicWithdrawDebugResultSchema + + +class PublicGetFundingRateHistoryResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + funding_rate_history: List[FundingRateSchema] = Field( + ..., description="List of funding rates", title="funding_rate_history" + ) + + +class PrivateRfqGetBestQuoteResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateRfqGetBestQuoteResultSchema + + +class PublicGetOptionSettlementHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetOptionSettlementHistoryResultSchema + + +class PrivateLiquidateResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateLiquidateResultSchema + + +class PrivateGetTradeHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetTradeHistoryResultSchema + + +class ForwardFeedDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") + currency: str = Field( + ..., + description="The currency for which the spot feed represents", + title="currency", + ) + deadline: int = Field( + ..., + description="The latest time the data can be submitted on chain", + title="deadline", + ) + expiry: int = Field(..., description="The expiry for the forward feed", title="expiry") + fwd_diff: Decimal = Field( + ..., + description="difference of forward price from current spot price", + title="fwd_diff", + ) + signatures: OracleSignatureDataSchema + spot_aggregate_latest: Decimal = Field( + ..., + description="expiry -> spot * time value at the latest timestamp", + title="spot_aggregate_latest", + ) + spot_aggregate_start: Decimal = Field( + ..., + description="spot * time value at the start of the settlement period", + title="spot_aggregate_start", + ) + timestamp: int = Field( + ..., + description="The timestamp for which the data was created", + title="timestamp", + ) + + +class VolFeedDataSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") + currency: str = Field( + ..., + description="The currency for which the spot feed represents", + title="currency", + ) + deadline: int = Field( + ..., + description="The latest time the data can be submitted on chain", + title="deadline", + ) + expiry: int = Field(..., description="The expiry for the options for the vol feed", title="expiry") + signatures: OracleSignatureDataSchema + timestamp: int = Field( + ..., + description="The timestamp for which the data was created", + title="timestamp", + ) + vol_data: VolSVIParamDataSchema + + +class PrivateReplaceResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + cancelled_order: OrderResponseSchema + create_order_error: Optional[RPCErrorFormatSchema] = None + order: Optional[OrderResponseSchema] = None + trades: Optional[List[TradeResponseSchema]] = Field( + None, description="List of trades executed by the created order", title="trades" + ) + + +class PrivateCancelByInstrumentResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateCancelByInstrumentResultSchema + + +class PublicDeregisterSessionKeyResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicDeregisterSessionKeyResultSchema + + +class PrivateWithdrawResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateWithdrawResultSchema + + +class PrivateGetNotificationsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetNotificationsResultSchema + + +class PublicGetCurrencyResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetCurrencyResultSchema + + +class PrivateTransferPositionResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateTransferPositionResultSchema + + +class PublicMarginWatchResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicMarginWatchResultSchema + + +class PublicGetSpotFeedHistoryCandlesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetSpotFeedHistoryCandlesResultSchema + + +class PrivatePollRfqsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivatePollRfqsResultSchema + + +class PrivateGetLiquidationHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: List[AuctionResultSchema] = Field(..., description="", title="result") + + +class PrivateOrderDebugResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + action_hash: str = Field(..., description="Keccak hashed action data", title="action_hash") + encoded_data: str = Field(..., description="ABI encoded order data", title="encoded_data") + encoded_data_hashed: str = Field(..., description="Keccak hashed encoded_data", title="encoded_data_hashed") + raw_data: SignedTradeOrderSchema + typed_data_hash: str = Field(..., description="EIP 712 typed data hash", title="typed_data_hash") + + +class PrivateTransferPositionsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateTransferPositionsResultSchema + + +class PublicGetSpotFeedHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetSpotFeedHistoryResultSchema + + +class PrivateGetDepositHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetDepositHistoryResultSchema + + +class PublicGetInstrumentResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetInstrumentResultSchema + + +class PrivateGetPositionsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetPositionsResultSchema + + +class PublicGetTradeHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetTradeHistoryResultSchema + + +class PrivateGetRfqsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetRfqsResultSchema + + +class PrivateGetWithdrawalHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetWithdrawalHistoryResultSchema + + +class PublicGetOptionSettlementPricesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetOptionSettlementPricesResultSchema + + +class PublicGetMakerProgramScoresResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetMakerProgramScoresResultSchema + + +class PrivateGetFundingHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetFundingHistoryResultSchema + + +class PrivateGetAccountResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetAccountResultSchema + + +class PublicGetAllInstrumentsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetAllInstrumentsResultSchema + + +class PublicGetTickerResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetTickerResultSchema + + +class PublicGetVaultShareResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetVaultShareResultSchema + + +class PrivateGetCollateralsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetCollateralsResultSchema + + +class PrivateSessionKeysResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateSessionKeysResultSchema + + +class PublicGetInterestRateHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetInterestRateHistoryResultSchema + + +class PublicGetLiquidationHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetLiquidationHistoryResultSchema + + +class PublicGetReferralPerformanceResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetReferralPerformanceResultSchema + + +class PrivateGetOptionSettlementHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetOptionSettlementHistoryResultSchema + + +class PrivateGetErc20TransferHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetErc20TransferHistoryResultSchema + + +class PrivateGetSubaccountValueHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetSubaccountValueHistoryResultSchema + + +class PublicGetLiveIncidentsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetLiveIncidentsResultSchema + + +class PrivateGetInterestHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateGetInterestHistoryResultSchema + + +class PrivatePollQuotesResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivatePollQuotesResultSchema + + +class PublicGetFundingRateHistoryResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetFundingRateHistoryResultSchema + + +class PublicGetLatestSignedFeedsResultSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + fwd_data: Dict[str, Dict[str, ForwardFeedDataSchema]] = Field( + ..., + description="currency -> expiry -> latest forward feed data", + title="fwd_data", + ) + perp_data: Dict[str, Dict[str, PerpFeedDataSchema]] = Field( + ..., + description="currency -> feed type -> latest perp feed data", + title="perp_data", + ) + rate_data: Dict[str, Dict[str, RateFeedDataSchema]] = Field( + ..., + description="currency -> expiry -> latest rate feed data", + title="rate_data", + ) + spot_data: Dict[str, SpotFeedDataSchema] = Field( + ..., description="currency -> latest spot feed data", title="spot_data" + ) + vol_data: Dict[str, Dict[str, VolFeedDataSchema]] = Field( + ..., description="currency -> expiry -> latest vol feed data", title="vol_data" + ) + + +class PrivateReplaceResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateReplaceResultSchema + + +class PrivateOrderDebugResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PrivateOrderDebugResultSchema + + +class PublicGetLatestSignedFeedsResponseSchema(BaseModel): + model_config = ConfigDict( + extra="forbid", + ) + id: Union[str, int] + result: PublicGetLatestSignedFeedsResultSchema From c66a66efb7755caa8d9d3891b38a0add57f769b0 Mon Sep 17 00:00:00 2001 From: zarathustra Date: Wed, 1 Oct 2025 14:15:29 +0200 Subject: [PATCH 4/6] fix: generate regular dataclasses instead of pydantic models --- derive_client/_clients/models.py | 6973 +++++++++--------------------- scripts/generate-models.py | 2 +- 2 files changed, 2033 insertions(+), 4942 deletions(-) diff --git a/derive_client/_clients/models.py b/derive_client/_clients/models.py index 9d04b27a..26ddf95d 100644 --- a/derive_client/_clients/models.py +++ b/derive_client/_clients/models.py @@ -1,24 +1,22 @@ # generated by datamodel-codegen: # filename: RESTAPI-v2_0-latest.json -# timestamp: 2025-09-20T20:37:05+00:00 +# timestamp: 2025-10-01T12:11:13+00:00 from __future__ import annotations +from dataclasses import dataclass from decimal import Decimal from enum import Enum from typing import Any, Dict, List, Optional, Union -from uuid import UUID -from pydantic import BaseModel, ConfigDict, Field - -class Status(Enum): +class Status(str, Enum): unseen = "unseen" seen = "seen" hidden = "hidden" -class TypeEnum(Enum): +class TypeEnum(str, Enum): deposit = "deposit" withdraw = "withdraw" transfer = "transfer" @@ -28,98 +26,46 @@ class TypeEnum(Enum): custom = "custom" -class PrivateGetNotificationsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - page: Optional[int] = Field(1, description="Page number of results to return", title="page") - page_size: Optional[int] = Field( - 50, - description="Number of results per page (must be between 0-50)", - title="page_size", - ) - status: Optional[Status] = Field(None, description="Status of the notification", title="status") - subaccount_id: Optional[int] = Field( - None, - description="Subaccount_id (must be set if wallet param is not set)", - title="subaccount_id", - ) - type: Optional[List[TypeEnum]] = Field(None, description="List of notification types to filter by", title="type") - wallet: Optional[str] = Field( - None, - description="Wallet address (if set, subaccount_id ignored)", - title="wallet", - ) +@dataclass +class PrivateGetNotificationsParamsSchema: + page: Optional[int] = 1 + page_size: Optional[int] = 50 + status: Optional[Status] = None + subaccount_id: Optional[int] = None + type: Optional[List[TypeEnum]] = None + wallet: Optional[str] = None -class NotificationResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - event: str = Field( - ..., - description="The specific event leading to the notification.", - title="event", - ) - event_details: Dict[str, Any] = Field( - ..., - description="A JSON-structured dictionary containing detailed data or context about the event.", - title="event_details", - ) - id: int = Field(..., description="The unique identifier for the notification.", title="id") - status: str = Field( - ..., - description="The status of the notification, indicating if it has been read, pending, or processed.", - title="status", - ) - subaccount_id: int = Field( - ..., - description="The subaccount_id associated with the notification.", - title="subaccount_id", - ) - timestamp: int = Field( - ..., - description="The timestamp indicating when the notification was created or triggered.", - title="timestamp", - ) - transaction_id: Optional[int] = Field( - None, - description="The transaction id associated with the notification.", - title="transaction_id", - ) - tx_hash: Optional[str] = Field( - None, - description="The transaction hash associated with the notification.", - title="tx_hash", - ) +@dataclass +class NotificationResponseSchema: + event: str + event_details: Dict[str, Any] + id: int + status: str + subaccount_id: int + timestamp: int + transaction_id: Optional[int] = None + tx_hash: Optional[str] = None -class PaginationInfoSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - count: int = Field(..., description="Total number of items, across all pages", title="count") - num_pages: int = Field(..., description="Number of pages", title="num_pages") +@dataclass +class PaginationInfoSchema: + count: int + num_pages: int -class PublicGetCurrencyParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field( - ..., - description="Underlying currency of asset (`ETH`, `BTC`, etc)", - title="currency", - ) +@dataclass +class PublicGetCurrencyParamsSchema: + currency: str -class InstrumentType(Enum): +class InstrumentType(str, Enum): erc20 = "erc20" option = "option" perp = "perp" -class MarketType(Enum): +class MarketType(str, Enum): ALL = "ALL" SRM_BASE_ONLY = "SRM_BASE_ONLY" SRM_OPTION_ONLY = "SRM_OPTION_ONLY" @@ -127,162 +73,76 @@ class MarketType(Enum): CASH = "CASH" -class OpenInterestStatsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - current_open_interest: Decimal = Field( - ..., - description="Current open interest for the margin type", - title="current_open_interest", - ) - interest_cap: Decimal = Field(..., description="Total open interest cap", title="interest_cap") - manager_currency: Optional[str] = Field( - None, - description="Currency of the manager (only applies to Portfolio Margin)", - title="manager_currency", - ) +@dataclass +class OpenInterestStatsSchema: + current_open_interest: Decimal + interest_cap: Decimal + manager_currency: Optional[str] = None -class MarginType(Enum): +class MarginType(str, Enum): PM = "PM" SM = "SM" PM2 = "PM2" -class ManagerContractResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - address: str = Field(..., description="Address of the manager", title="address") - currency: Optional[str] = Field( - None, - description="Currency of the manager (only applies to portfolio managers)", - title="currency", - ) - margin_type: MarginType = Field(..., description="Margin type of the manager", title="margin_type") +@dataclass +class ManagerContractResponseSchema: + address: str + margin_type: MarginType + currency: Optional[str] = None -class PM2CollateralDiscountsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - im_discount: Decimal = Field( - ..., - description="Initial Margin discount for given collateral in PM2", - title="im_discount", - ) - manager_currency: str = Field(..., description="Currency of the manager", title="manager_currency") - mm_discount: Decimal = Field( - ..., - description="Maintenance Margin discount for given collateral in PM2", - title="mm_discount", - ) +@dataclass +class PM2CollateralDiscountsSchema: + im_discount: Decimal + manager_currency: str + mm_discount: Decimal -class ProtocolAssetAddressesSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - option: Optional[str] = Field( - None, - description="Address of the Derive protocol option contract (none if not supported)", - title="option", - ) - perp: Optional[str] = Field( - None, - description="Address of the Derive protocol perp contract (none if not supported)", - title="perp", - ) - spot: Optional[str] = Field( - None, - description="Address of the Derive protocol spot contract (none if not supported)", - title="spot", - ) - underlying_erc20: Optional[str] = Field( - None, - description="Address of the erc20 asset on Derive chain. This is the asset that is deposited into the spot asset", - title="underlying_erc20", - ) +@dataclass +class ProtocolAssetAddressesSchema: + option: Optional[str] = None + perp: Optional[str] = None + spot: Optional[str] = None + underlying_erc20: Optional[str] = None -class PrivateSetMmpConfigParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency of this mmp config", title="currency") - mmp_amount_limit: Decimal = Field( - "0", - description="Maximum total order amount that can be traded within the mmp_interval across all instruments of the provided currency. The amounts are not netted, so a filled bid of 1 and a filled ask of 2 would count as 3.
Default: 0 (no limit)", - title="mmp_amount_limit", - ) - mmp_delta_limit: Decimal = Field( - "0", - description="Maximum total delta that can be traded within the mmp_interval across all instruments of the provided currency. This quantity is netted, so a filled order with +1 delta and a filled order with -2 delta would count as -1
Default: 0 (no limit)", - title="mmp_delta_limit", - ) - mmp_frozen_time: int = Field( - ..., - description="Time interval in ms setting how long the subaccount is frozen after an mmp trigger, if 0 then a manual reset would be required via private/reset_mmp", - title="mmp_frozen_time", - ) - mmp_interval: int = Field( - ..., - description="Time interval in ms over which the limits are monotored, if 0 then mmp is disabled", - title="mmp_interval", - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to set the config", - title="subaccount_id", - ) +@dataclass +class PrivateSetMmpConfigParamsSchema: + currency: str + mmp_frozen_time: int + mmp_interval: int + subaccount_id: int + mmp_amount_limit: Decimal = "0" + mmp_delta_limit: Decimal = "0" -PrivateSetMmpConfigResultSchema = PrivateSetMmpConfigParamsSchema +@dataclass +class PrivateSetMmpConfigResultSchema(PrivateSetMmpConfigParamsSchema): + pass -class Direction(Enum): +class Direction(str, Enum): buy = "buy" sell = "sell" -class TradeModuleParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") - direction: Direction = Field(..., description="Order direction", title="direction") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - limit_price: Decimal = Field( - ..., - description="Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.", - title="limit_price", - ) - max_fee: Decimal = Field( - ..., - description="Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.", - title="max_fee", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.", - title="nonce", - ) - signature: str = Field(..., description="Ethereum signature of the order", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed order", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class TradeModuleParamsSchema: + amount: Decimal + direction: Direction + instrument_name: str + limit_price: Decimal + max_fee: Decimal + nonce: int + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int -class CancelReason(Enum): +class CancelReason(str, Enum): field_ = "" user_request = "user_request" mmp_trigger = "mmp_trigger" @@ -297,7 +157,7 @@ class CancelReason(Enum): validation_failed = "validation_failed" -class OrderStatus(Enum): +class OrderStatus(str, Enum): open = "open" filled = "filled" cancelled = "cancelled" @@ -305,117 +165,67 @@ class OrderStatus(Enum): untriggered = "untriggered" -class OrderType(Enum): +class OrderType(str, Enum): limit = "limit" market = "market" -class TimeInForce(Enum): +class TimeInForce(str, Enum): gtc = "gtc" post_only = "post_only" fok = "fok" ioc = "ioc" -class TriggerPriceType(Enum): +class TriggerPriceType(str, Enum): mark = "mark" index = "index" -class TriggerType(Enum): +class TriggerType(str, Enum): stoploss = "stoploss" takeprofit = "takeprofit" -class OrderResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") - average_price: Decimal = Field(..., description="Average fill price", title="average_price") - cancel_reason: CancelReason = Field( - ..., - description="If cancelled, reason behind order cancellation", - title="cancel_reason", - ) - creation_timestamp: int = Field( - ..., - description="Creation timestamp (in ms since Unix epoch)", - title="creation_timestamp", - ) - direction: Direction = Field(..., description="Order direction", title="direction") - filled_amount: Decimal = Field(..., description="Total filled amount for the order", title="filled_amount") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - is_transfer: bool = Field( - ..., - description="Whether the order was generated through `private/transfer_position`", - title="is_transfer", - ) - label: str = Field(..., description="Optional user-defined label for the order", title="label") - last_update_timestamp: int = Field( - ..., - description="Last update timestamp (in ms since Unix epoch)", - title="last_update_timestamp", - ) - limit_price: Decimal = Field(..., description="Limit price in quote currency", title="limit_price") - max_fee: Decimal = Field(..., description="Max fee in units of the quote currency", title="max_fee") - mmp: bool = Field( - ..., - description="Whether the order is tagged for market maker protections", - title="mmp", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - order_fee: Decimal = Field(..., description="Total order fee paid so far", title="order_fee") - order_id: str = Field(..., description="Order ID", title="order_id") - order_status: OrderStatus = Field(..., description="Order status", title="order_status") - order_type: OrderType = Field(..., description="Order type", title="order_type") - quote_id: Optional[UUID] = Field(..., description="Quote ID if the trade was executed via RFQ", title="quote_id") - replaced_order_id: Optional[UUID] = Field( - None, - description="If replaced, ID of the order that was replaced", - title="replaced_order_id", - ) - signature: str = Field(..., description="Ethereum signature of the order", title="signature") - signature_expiry_sec: int = Field(..., description="Signature expiry timestamp", title="signature_expiry_sec") - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed order", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - time_in_force: TimeInForce = Field(..., description="Time in force", title="time_in_force") - trigger_price: Optional[Decimal] = Field( - None, - description="(Required for trigger orders) Index or Market price to trigger order at", - title="trigger_price", - ) - trigger_price_type: Optional[TriggerPriceType] = Field( - None, - description="(Required for trigger orders) Trigger with Index or Mark Price", - title="trigger_price_type", - ) - trigger_reject_message: Optional[str] = Field( - None, - description="(Required for trigger orders) Error message if error occured during trigger", - title="trigger_reject_message", - ) - trigger_type: Optional[TriggerType] = Field( - None, - description="(Required for trigger orders) Stop-loss or Take-profit.", - title="trigger_type", - ) - - -class LiquidityRole(Enum): +@dataclass +class OrderResponseSchema: + amount: Decimal + average_price: Decimal + cancel_reason: CancelReason + creation_timestamp: int + direction: Direction + filled_amount: Decimal + instrument_name: str + is_transfer: bool + label: str + last_update_timestamp: int + limit_price: Decimal + max_fee: Decimal + mmp: bool + nonce: int + order_fee: Decimal + order_id: str + order_status: OrderStatus + order_type: OrderType + quote_id: Optional[str] + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + time_in_force: TimeInForce + replaced_order_id: Optional[str] = None + trigger_price: Optional[Decimal] = None + trigger_price_type: Optional[TriggerPriceType] = None + trigger_reject_message: Optional[str] = None + trigger_type: Optional[TriggerType] = None + + +class LiquidityRole(str, Enum): maker = "maker" taker = "taker" -class TxStatus(Enum): +class TxStatus(str, Enum): requested = "requested" pending = "pending" settled = "settled" @@ -424,106 +234,58 @@ class TxStatus(Enum): timed_out = "timed_out" -class TradeResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - direction: Direction = Field(..., description="Order direction", title="direction") - expected_rebate: Decimal = Field(..., description="Expected rebate for this trade", title="expected_rebate") - index_price: Decimal = Field( - ..., - description="Index price of the underlying at the time of the trade", - title="index_price", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - is_transfer: bool = Field( - ..., - description="Whether the trade was generated through `private/transfer_position`", - title="is_transfer", - ) - label: str = Field(..., description="Optional user-defined label for the order", title="label") - liquidity_role: LiquidityRole = Field(..., description="Role of the user in the trade", title="liquidity_role") - mark_price: Decimal = Field( - ..., - description="Mark price of the instrument at the time of the trade", - title="mark_price", - ) - order_id: str = Field(..., description="Order ID", title="order_id") - quote_id: Optional[UUID] = Field(..., description="Quote ID if the trade was executed via RFQ", title="quote_id") - realized_pnl: Decimal = Field(..., description="Realized PnL for this trade", title="realized_pnl") - realized_pnl_excl_fees: Decimal = Field( - ..., - description="Realized PnL for this trade using cost accounting that excludes fees", - title="realized_pnl_excl_fees", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - timestamp: int = Field(..., description="Trade timestamp (in ms since Unix epoch)", title="timestamp") - trade_amount: Decimal = Field(..., description="Amount filled in this trade", title="trade_amount") - trade_fee: Decimal = Field(..., description="Fee for this trade", title="trade_fee") - trade_id: str = Field(..., description="Trade ID", title="trade_id") - trade_price: Decimal = Field(..., description="Price at which the trade was filled", title="trade_price") - transaction_id: str = Field( - ..., - description="The transaction id of the related settlement transaction", - title="transaction_id", - ) - tx_hash: Optional[str] = Field(..., description="Blockchain transaction hash", title="tx_hash") - tx_status: TxStatus = Field(..., description="Blockchain transaction status", title="tx_status") - - -class PrivateCreateSubaccountParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") - asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") - currency: Optional[str] = Field( - None, - description="Base currency of the subaccount (only for `PM`)", - title="currency", - ) - margin_type: MarginType = Field( - ..., - description="`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", - title="margin_type", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature: str = Field(..., description="Ethereum signature of the deposit", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the deposit", - title="signer", - ) - wallet: str = Field(..., description="Ethereum wallet address", title="wallet") - - -class PrivateCreateSubaccountResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - status: str = Field(..., description="`requested`", title="status") - transaction_id: UUID = Field(..., description="Transaction id of the request", title="transaction_id") - - -class LegUnpricedSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount in units of the base", title="amount") - direction: Direction = Field(..., description="Leg direction", title="direction") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - - -class CancelReason1(Enum): +@dataclass +class TradeResponseSchema: + direction: Direction + expected_rebate: Decimal + index_price: Decimal + instrument_name: str + is_transfer: bool + label: str + liquidity_role: LiquidityRole + mark_price: Decimal + order_id: str + quote_id: Optional[str] + realized_pnl: Decimal + realized_pnl_excl_fees: Decimal + subaccount_id: int + timestamp: int + trade_amount: Decimal + trade_fee: Decimal + trade_id: str + trade_price: Decimal + transaction_id: str + tx_hash: Optional[str] + tx_status: TxStatus + + +@dataclass +class PrivateCreateSubaccountParamsSchema: + amount: Decimal + asset_name: str + margin_type: MarginType + nonce: int + signature: str + signature_expiry_sec: int + signer: str + wallet: str + currency: Optional[str] = None + + +@dataclass +class PrivateCreateSubaccountResultSchema: + status: str + transaction_id: str + + +@dataclass +class LegUnpricedSchema: + amount: Decimal + direction: Direction + instrument_name: str + + +class CancelReason1(str, Enum): field_ = "" user_request = "user_request" insufficient_margin = "insufficient_margin" @@ -536,3167 +298,1492 @@ class CancelReason1(Enum): compliance = "compliance" -class Status1(Enum): +class Status1(str, Enum): open = "open" filled = "filled" cancelled = "cancelled" expired = "expired" -class PrivateSendRfqResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - ask_total_cost: Optional[Decimal] = Field( - ..., - description="Ask total cost for the RFQ implied from orderbook (as `sell`)", - title="ask_total_cost", - ) - bid_total_cost: Optional[Decimal] = Field( - ..., - description="Bid total cost for the RFQ implied from orderbook (as `buy`)", - title="bid_total_cost", - ) - cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") - counterparties: Optional[List[str]] = Field( - ..., - description="List of requested counterparties, if applicable", - title="counterparties", - ) - creation_timestamp: int = Field( - ..., - description="Creation timestamp in ms since Unix epoch", - title="creation_timestamp", - ) - filled_direction: Optional[Direction] = Field( - ..., - description="Direction at which the RFQ was filled (only if filled)", - title="filled_direction", - ) - filled_pct: Decimal = Field( - ..., - description="Percentage of the RFQ that has been filled, from 0 to 1.", - title="filled_pct", - ) - label: str = Field(..., description="User-defined label, if any", title="label") - last_update_timestamp: int = Field( - ..., - description="Last update timestamp in ms since Unix epoch", - title="last_update_timestamp", - ) - legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") - mark_total_cost: Optional[Decimal] = Field( - ..., - description="Mark total cost for the RFQ (assuming `buy` direction)", - title="mark_total_cost", - ) - max_total_cost: Optional[Decimal] = Field(..., description="Max total cost for the RFQ", title="max_total_cost") - min_total_cost: Optional[Decimal] = Field(..., description="Min total cost for the RFQ", title="min_total_cost") - partial_fill_step: Decimal = Field( - ..., - description="Step size for partial fills (default: 1)", - title="partial_fill_step", - ) - rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") - status: Status1 = Field(..., description="Status", title="status") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - total_cost: Optional[Decimal] = Field( - ..., description="Total cost for the RFQ (only if filled)", title="total_cost" - ) - valid_until: int = Field( - ..., - description="RFQ expiry timestamp in ms since Unix epoch", - title="valid_until", - ) +@dataclass +class PrivateSendRfqResultSchema: + ask_total_cost: Optional[Decimal] + bid_total_cost: Optional[Decimal] + cancel_reason: CancelReason1 + counterparties: Optional[List[str]] + creation_timestamp: int + filled_direction: Optional[Direction] + filled_pct: Decimal + label: str + last_update_timestamp: int + legs: List[LegUnpricedSchema] + mark_total_cost: Optional[Decimal] + max_total_cost: Optional[Decimal] + min_total_cost: Optional[Decimal] + partial_fill_step: Decimal + rfq_id: str + status: Status1 + subaccount_id: int + total_cost: Optional[Decimal] + valid_until: int + + +@dataclass +class PublicMarginWatchParamsSchema: + subaccount_id: int + force_onchain: bool = False + + +@dataclass +class CollateralPublicResponseSchema: + amount: Decimal + asset_name: str + asset_type: InstrumentType + initial_margin: Decimal + maintenance_margin: Decimal + mark_price: Decimal + mark_value: Decimal + + +@dataclass +class PositionPublicResponseSchema: + amount: Decimal + delta: Decimal + gamma: Decimal + index_price: Decimal + initial_margin: Decimal + instrument_name: str + instrument_type: InstrumentType + liquidation_price: Optional[Decimal] + maintenance_margin: Decimal + mark_price: Decimal + mark_value: Decimal + theta: Decimal + vega: Decimal + + +@dataclass +class PublicStatisticsParamsSchema: + instrument_name: str + currency: Optional[str] = None + end_time: Optional[int] = None + + +@dataclass +class PublicStatisticsResultSchema: + daily_fees: Decimal + daily_notional_volume: Decimal + daily_premium_volume: Decimal + daily_trades: int + open_interest: Decimal + total_fees: Decimal + total_notional_volume: Decimal + total_premium_volume: Decimal + total_trades: int + + +@dataclass +class PublicLoginParamsSchema: + signature: str + timestamp: str + wallet: str + + +@dataclass +class PublicLoginResponseSchema: + id: Union[str, int] + result: List[int] + + +@dataclass +class PrivateCancelParamsSchema: + instrument_name: str + order_id: str + subaccount_id: int + + +@dataclass +class PrivateCancelResultSchema(OrderResponseSchema): + pass -class PublicMarginWatchParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - force_onchain: bool = Field( - False, - description="Force the fetching of on-chain balances, default False.", - title="force_onchain", - ) - subaccount_id: int = Field(..., description="Subaccount ID to get margin for.", title="subaccount_id") +@dataclass +class LegPricedSchema: + amount: Decimal + direction: Direction + instrument_name: str + price: Decimal + + +@dataclass +class PrivateExecuteQuoteResultSchema: + cancel_reason: CancelReason1 + creation_timestamp: int + direction: Direction + fee: Decimal + fill_pct: Decimal + is_transfer: bool + label: str + last_update_timestamp: int + legs: List[LegPricedSchema] + legs_hash: str + liquidity_role: LiquidityRole + max_fee: Decimal + mmp: bool + nonce: int + quote_id: str + rfq_filled_pct: Decimal + rfq_id: str + signature: str + signature_expiry_sec: int + signer: str + status: Status1 + subaccount_id: int + tx_hash: Optional[str] + tx_status: Optional[TxStatus] + + +class Period(str, Enum): + field_60 = 60 + field_300 = 300 + field_900 = 900 + field_1800 = 1800 + field_3600 = 3600 + field_14400 = 14400 + field_28800 = 28800 + field_86400 = 86400 + field_604800 = 604800 -class CollateralPublicResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Asset amount of given collateral", title="amount") - asset_name: str = Field(..., description="Asset name", title="asset_name") - asset_type: InstrumentType = Field( - ..., - description="Type of asset collateral (currently always `erc20`)", - title="asset_type", - ) - initial_margin: Decimal = Field( - ..., - description="USD value of collateral that contributes to initial margin", - title="initial_margin", - ) - maintenance_margin: Decimal = Field( - ..., - description="USD value of collateral that contributes to maintenance margin", - title="maintenance_margin", - ) - mark_price: Decimal = Field(..., description="Current mark price of the asset", title="mark_price") - mark_value: Decimal = Field( - ..., - description="USD value of the collateral (amount * mark price)", - title="mark_value", - ) +@dataclass +class PublicGetSpotFeedHistoryCandlesParamsSchema: + currency: str + end_timestamp: int + period: Period + start_timestamp: int + + +@dataclass +class SpotFeedHistoryCandlesResponseSchema: + close_price: Decimal + high_price: Decimal + low_price: Decimal + open_price: Decimal + price: Decimal + timestamp: int + timestamp_bucket: int + + +@dataclass +class PrivatePollRfqsParamsSchema: + subaccount_id: int + from_timestamp: int = 0 + page: int = 1 + page_size: int = 100 + rfq_id: Optional[str] = None + rfq_subaccount_id: Optional[int] = None + status: Optional[Status1] = None + to_timestamp: int = 18446744073709552000 + + +@dataclass +class RFQResultPublicSchema: + cancel_reason: CancelReason1 + creation_timestamp: int + filled_direction: Optional[Direction] + filled_pct: Decimal + last_update_timestamp: int + legs: List[LegUnpricedSchema] + partial_fill_step: Decimal + rfq_id: str + status: Status1 + subaccount_id: int + total_cost: Optional[Decimal] + valid_until: int + + +@dataclass +class PrivateGetLiquidationHistoryParamsSchema: + subaccount_id: int + end_timestamp: int = 9223372036854776000 + start_timestamp: int = 0 + + +class AuctionType(str, Enum): + solvent = "solvent" + insolvent = "insolvent" -class PositionPublicResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Position amount held by subaccount", title="amount") - delta: Decimal = Field( - ..., - description="Asset delta (w.r.t. forward price for options, `1.0` for perps)", - title="delta", - ) - gamma: Decimal = Field(..., description="Asset gamma (zero for non-options)", title="gamma") - index_price: Decimal = Field( - ..., - description="Current index (oracle) price for position's currency", - title="index_price", - ) - initial_margin: Decimal = Field( - ..., - description="USD initial margin requirement for this position", - title="initial_margin", - ) - instrument_name: str = Field( - ..., - description="Instrument name (same as the base Asset name)", - title="instrument_name", - ) - instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") - liquidation_price: Optional[Decimal] = Field( - ..., - description="Index price at which position will be liquidated", - title="liquidation_price", - ) - maintenance_margin: Decimal = Field( - ..., - description="USD maintenance margin requirement for this position", - title="maintenance_margin", - ) - mark_price: Decimal = Field( - ..., - description="Current mark price for position's instrument", - title="mark_price", - ) - mark_value: Decimal = Field( - ..., - description="USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price", - title="mark_value", - ) - theta: Decimal = Field(..., description="Asset theta (zero for non-options)", title="theta") - vega: Decimal = Field(..., description="Asset vega (zero for non-options)", title="vega") +@dataclass +class AuctionBidEventSchema: + amounts_liquidated: Dict[str, Decimal] + cash_received: Decimal + discount_pnl: Decimal + percent_liquidated: Decimal + positions_realized_pnl: Dict[str, Decimal] + positions_realized_pnl_excl_fees: Dict[str, Decimal] + realized_pnl: Decimal + realized_pnl_excl_fees: Decimal + timestamp: int + tx_hash: str + + +@dataclass +class PrivateOrderDebugParamsSchema: + amount: Decimal + direction: Direction + instrument_name: str + limit_price: Decimal + max_fee: Decimal + nonce: int + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + is_atomic_signing: Optional[bool] = False + label: str = "" + mmp: bool = False + order_type: OrderType = OrderType.limit + reduce_only: bool = False + referral_code: str = "" + reject_timestamp: int = 9223372036854776000 + time_in_force: TimeInForce = TimeInForce.gtc + trigger_price: Optional[Decimal] = None + trigger_price_type: Optional[TriggerPriceType] = None + trigger_type: Optional[TriggerType] = None + + +@dataclass +class TradeModuleDataSchema: + asset: str + desired_amount: Decimal + is_bid: bool + limit_price: Decimal + recipient_id: int + sub_id: int + trade_id: str + worst_fee: Decimal + + +@dataclass +class PrivateDepositParamsSchema: + amount: Decimal + asset_name: str + nonce: int + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + is_atomic_signing: bool = False + + +@dataclass +class PrivateDepositResultSchema(PrivateCreateSubaccountResultSchema): + pass -class PublicStatisticsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: Optional[str] = Field(None, description="Currency for stats", title="currency") - end_time: Optional[int] = Field(None, description="End time for statistics in ms", title="end_time") - instrument_name: str = Field( - ..., - description="Instrument name or 'ALL', 'OPTION', 'PERP', 'SPOT'", - title="instrument_name", - ) +@dataclass +class PrivateUpdateNotificationsParamsSchema: + notification_ids: List[int] + subaccount_id: int + status: Status = Status.seen -class PublicStatisticsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - daily_fees: Decimal = Field(..., description="24h Fees", title="daily_fees") - daily_notional_volume: Decimal = Field(..., description="24h Notional volume", title="daily_notional_volume") - daily_premium_volume: Decimal = Field(..., description="24h Premium volume", title="daily_premium_volume") - daily_trades: int = Field(..., description="24h Trades", title="daily_trades") - open_interest: Decimal = Field(..., description="Open interest", title="open_interest") - total_fees: Decimal = Field(..., description="Total fees", title="total_fees") - total_notional_volume: Decimal = Field(..., description="Total notional volume", title="total_notional_volume") - total_premium_volume: Decimal = Field(..., description="Total premium volume", title="total_premium_volume") - total_trades: int = Field(..., description="Total trades", title="total_trades") - - -class PublicLoginParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - signature: str = Field( - ..., - description="Signature of the timestamp, signed with the wallet's private key or a session key", - title="signature", - ) - timestamp: str = Field( - ..., - description="Message that was signed, in the form of a timestamp in ms since Unix epoch", - title="timestamp", - ) - wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") +@dataclass +class PrivateUpdateNotificationsResultSchema: + updated_count: int -class PublicLoginResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - id: Union[str, int] - result: List[int] = Field( - ..., - description="List of subaccount IDs that have been authenticated", - title="result", - ) +@dataclass +class PrivateChangeSubaccountLabelParamsSchema: + label: str + subaccount_id: int -class PrivateCancelParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instrument_name: str = Field(..., title="instrument_name") - order_id: UUID = Field(..., title="order_id") - subaccount_id: int = Field(..., title="subaccount_id") +@dataclass +class PrivateChangeSubaccountLabelResultSchema( + PrivateChangeSubaccountLabelParamsSchema +): + pass -PrivateCancelResultSchema = OrderResponseSchema +@dataclass +class SignedQuoteParamsSchema: + direction: Direction + legs: List[LegPricedSchema] + max_fee: Decimal + nonce: int + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + + +@dataclass +class QuoteResultSchema: + cancel_reason: CancelReason1 + creation_timestamp: int + direction: Direction + fee: Decimal + fill_pct: Decimal + is_transfer: bool + label: str + last_update_timestamp: int + legs: List[LegPricedSchema] + legs_hash: str + liquidity_role: LiquidityRole + max_fee: Decimal + mmp: bool + nonce: int + quote_id: str + rfq_id: str + signature: str + signature_expiry_sec: int + signer: str + status: Status1 + subaccount_id: int + tx_hash: Optional[str] + tx_status: Optional[TxStatus] + + +@dataclass +class PublicGetMakerProgramsParamsSchema: + pass -class LegPricedSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount in units of the base", title="amount") - direction: Direction = Field(..., description="Leg direction", title="direction") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - price: Decimal = Field(..., description="Leg price", title="price") +@dataclass +class ProgramResponseSchema: + asset_types: List[str] + currencies: List[str] + end_timestamp: int + min_notional: Decimal + name: str + rewards: Dict[str, Decimal] + start_timestamp: int -class PrivateExecuteQuoteResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") - creation_timestamp: int = Field( - ..., - description="Creation timestamp in ms since Unix epoch", - title="creation_timestamp", - ) - direction: Direction = Field(..., description="Quote direction", title="direction") - fee: Decimal = Field(..., description="Fee paid for this quote (if executed)", title="fee") - fill_pct: Decimal = Field( - ..., - description="Percentage of the RFQ that this quote would fill, from 0 to 1.", - title="fill_pct", - ) - is_transfer: bool = Field( - ..., - description="Whether the order was generated through `private/transfer_position`", - title="is_transfer", - ) - label: str = Field(..., description="User-defined label, if any", title="label") - last_update_timestamp: int = Field( - ..., - description="Last update timestamp in ms since Unix epoch", - title="last_update_timestamp", - ) - legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") - legs_hash: str = Field( - ..., - description="Hash of the legs of the best quote to be signed by the taker.", - title="legs_hash", - ) - liquidity_role: LiquidityRole = Field(..., description="Liquidity role", title="liquidity_role") - max_fee: Decimal = Field(..., description="Signed max fee", title="max_fee") - mmp: bool = Field( - ..., - description="Whether the quote is tagged for market maker protections (default false)", - title="mmp", - ) - nonce: int = Field(..., description="Nonce", title="nonce") - quote_id: UUID = Field(..., description="Quote ID", title="quote_id") - rfq_filled_pct: Decimal = Field( - ..., - description="Total percentage of the RFQ that has already been filled after this execution, from 0 to 1.", - title="rfq_filled_pct", - ) - rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") - signature: str = Field(..., description="Ethereum signature of the quote", title="signature") - signature_expiry_sec: int = Field(..., description="Unix timestamp in seconds", title="signature_expiry_sec") - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed the quote", - title="signer", - ) - status: Status1 = Field(..., description="Status", title="status") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - tx_hash: Optional[str] = Field( - ..., - description="Blockchain transaction hash (only for executed quotes)", - title="tx_hash", - ) - tx_status: Optional[TxStatus] = Field( - ..., - description="Blockchain transaction status (only for executed quotes)", - title="tx_status", - ) +@dataclass +class SimulatedCollateralSchema: + amount: Decimal + asset_name: str -class Period(Enum): - field_60 = 60 - field_300 = 300 - field_900 = 900 - field_1800 = 1800 - field_3600 = 3600 - field_14400 = 14400 - field_28800 = 28800 - field_86400 = 86400 - field_604800 = 604800 +@dataclass +class SimulatedPositionSchema: + amount: Decimal + instrument_name: str + entry_price: Optional[Decimal] = None -class PublicGetSpotFeedHistoryCandlesParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency", title="currency") - end_timestamp: int = Field(..., description="End timestamp", title="end_timestamp") - period: Period = Field(..., description="Period", title="period") - start_timestamp: int = Field(..., description="Start timestamp", title="start_timestamp") +@dataclass +class PublicGetMarginResultSchema: + is_valid_trade: bool + post_initial_margin: Decimal + post_maintenance_margin: Decimal + pre_initial_margin: Decimal + pre_maintenance_margin: Decimal + subaccount_id: int -class SpotFeedHistoryCandlesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - close_price: Decimal = Field(..., description="Close price", title="close_price") - high_price: Decimal = Field(..., description="High price", title="high_price") - low_price: Decimal = Field(..., description="Low price", title="low_price") - open_price: Decimal = Field(..., description="Open price", title="open_price") - price: Decimal = Field(..., description="Spot price", title="price") - timestamp: int = Field( - ..., - description="Timestamp of when the spot price was recored into the database", - title="timestamp", - ) - timestamp_bucket: int = Field( - ..., - description="Timestamp bucket; this value is regularly spaced out with `period` seconds between data points, missing values are forward-filled from earlier data where possible, if no earlier data is available, values are back-filled from the first observed data point", - title="timestamp_bucket", - ) +@dataclass +class PrivateCancelByNonceParamsSchema: + instrument_name: str + nonce: int + subaccount_id: int + wallet: str -class PrivatePollRfqsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - from_timestamp: int = Field( - 0, - description="Earliest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to 0.", - title="from_timestamp", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - rfq_id: Optional[UUID] = Field(None, description="RFQ ID filter, if applicable", title="rfq_id") - rfq_subaccount_id: Optional[int] = Field( - None, - description="Filter returned RFQs by rfq requestor subaccount", - title="rfq_subaccount_id", - ) - status: Optional[Status1] = Field(None, description="RFQ status filter, if applicable", title="status") - subaccount_id: int = Field( - ..., - description="Subaccount ID for auth purposes, returned data will be scoped to this subaccount.", - title="subaccount_id", - ) - to_timestamp: int = Field( - 18446744073709552000, - description="Latest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", - title="to_timestamp", - ) +@dataclass +class PrivateCancelByNonceResultSchema: + cancelled_orders: int -class RFQResultPublicSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") - creation_timestamp: int = Field( - ..., - description="Creation timestamp in ms since Unix epoch", - title="creation_timestamp", - ) - filled_direction: Optional[Direction] = Field( - ..., - description="Direction at which the RFQ was filled (only if filled)", - title="filled_direction", - ) - filled_pct: Decimal = Field( - ..., - description="Percentage of the RFQ that has been filled, from 0 to 1.", - title="filled_pct", - ) - last_update_timestamp: int = Field( - ..., - description="Last update timestamp in ms since Unix epoch", - title="last_update_timestamp", - ) - legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") - partial_fill_step: Decimal = Field( - ..., - description="Step size for partial fills (default: 1)", - title="partial_fill_step", - ) - rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") - status: Status1 = Field(..., description="Status", title="status") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - total_cost: Optional[Decimal] = Field( - ..., description="Total cost for the RFQ (only if filled)", title="total_cost" - ) - valid_until: int = Field( - ..., - description="RFQ expiry timestamp in ms since Unix epoch", - title="valid_until", - ) +@dataclass +class PublicGetSpotFeedHistoryParamsSchema: + currency: str + end_timestamp: int + period: int + start_timestamp: int -class PrivateGetLiquidationHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field( - 9223372036854776000, - description="End timestamp of the event history (default current time)", - title="end_timestamp", - ) - start_timestamp: int = Field( - 0, - description="Start timestamp of the event history (default 0)", - title="start_timestamp", - ) - subaccount_id: int = Field(..., description="Subaccount id", title="subaccount_id") +@dataclass +class SpotFeedHistoryResponseSchema: + price: Decimal + timestamp: int + timestamp_bucket: int -class AuctionType(Enum): - solvent = "solvent" - insolvent = "insolvent" +@dataclass +class PrivateGetSubaccountsParamsSchema: + wallet: str -class AuctionBidEventSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amounts_liquidated: Dict[str, Decimal] = Field( - ..., - description="Amounts of each asset that were closed", - title="amounts_liquidated", - ) - cash_received: Decimal = Field( - ..., - description="Cash received by the subaccount for the liquidation. For the liquidated accounts this is the amount the liquidator paid to buy out the percentage of the portfolio. For the liquidator account, this is the amount they received from the security module (if positive) or the amount they paid for the bid (if negative)", - title="cash_received", - ) - discount_pnl: Decimal = Field( - ..., - description="Realized PnL due to liquidating or being liquidated at a discount to mark portfolio value", - title="discount_pnl", - ) - percent_liquidated: Decimal = Field( - ..., - description="Percent of the subaccount that was liquidated", - title="percent_liquidated", - ) - positions_realized_pnl: Dict[str, Decimal] = Field( - ..., - description="Realized PnL of each position that was closed", - title="positions_realized_pnl", - ) - positions_realized_pnl_excl_fees: Dict[str, Decimal] = Field( - ..., - description="Realized PnL of each position that was closed, excluding fees from total cost basis", - title="positions_realized_pnl_excl_fees", - ) - realized_pnl: Decimal = Field( - ..., - description="Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation", - title="realized_pnl", - ) - realized_pnl_excl_fees: Decimal = Field( - ..., - description="Realized PnL of the auction bid, excluding fees from total cost basis, assuming positions are closed at mark price at the time of the liquidation", - title="realized_pnl_excl_fees", - ) - timestamp: int = Field( - ..., - description="Timestamp of the bid (in ms since UNIX epoch)", - title="timestamp", - ) - tx_hash: str = Field(..., description="Hash of the bid transaction", title="tx_hash") +@dataclass +class PrivateGetSubaccountsResultSchema: + subaccount_ids: List[int] + wallet: str -class PrivateOrderDebugParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") - direction: Direction = Field(..., description="Order direction", title="direction") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - is_atomic_signing: Optional[bool] = Field( - False, - description="Used by vaults to determine whether the signature is an EIP-1271 signature.", - title="is_atomic_signing", - ) - label: str = Field("", description="Optional user-defined label for the order", title="label") - limit_price: Decimal = Field( - ..., - description="Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.", - title="limit_price", - ) - max_fee: Decimal = Field( - ..., - description="Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.", - title="max_fee", - ) - mmp: bool = Field( - False, - description="Whether the order is tagged for market maker protections (default false)", - title="mmp", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.", - title="nonce", - ) - order_type: OrderType = Field( - "limit", - description="Order type:
- `limit`: limit order (default)
- `market`: market order, note that limit_price is still required for market orders, but unfilled order portion will be marked as cancelled", - title="order_type", - ) - reduce_only: bool = Field( - False, - description="If true, the order will not be able to increase position's size (default false). If the order amount exceeds available position size, the order will be filled up to the position size and the remainder will be cancelled. This flag is only supported for market orders or non-resting limit orders (IOC or FOK)", - title="reduce_only", - ) - referral_code: str = Field("", description="Optional referral code for the order", title="referral_code") - reject_timestamp: int = Field( - 9223372036854776000, - description="UTC timestamp in ms, if provided the matching engine will reject the order with an error if `reject_timestamp` < `server_time`. Note that the timestamp must be consistent with the server time: use `public/get_time` method to obtain current server time.", - title="reject_timestamp", - ) - signature: str = Field(..., description="Ethereum signature of the order", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed order", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - time_in_force: TimeInForce = Field( - "gtc", - description="Time in force behaviour:
- `gtc`: good til cancelled (default)
- `post_only`: a limit order that will be rejected if it crosses any order in the book, i.e. acts as a taker order
- `fok`: fill or kill, will be rejected if it is not fully filled
- `ioc`: immediate or cancel, fill at best bid/ask (market) or at limit price (limit), the unfilled portion is cancelled
Note that the order will still expire on the `signature_expiry_sec` timestamp.", - title="time_in_force", - ) - trigger_price: Optional[Decimal] = Field( - None, - description='(Required for trigger orders) "index" or "mark" price to trigger order at', - title="trigger_price", - ) - trigger_price_type: Optional[TriggerPriceType] = Field( - None, - description='(Required for trigger orders) Trigger with "mark" price as "index" price type not supported yet.', - title="trigger_price_type", - ) - trigger_type: Optional[TriggerType] = Field( - None, - description='(Required for trigger orders) "stoploss" or "takeprofit"', - title="trigger_type", - ) +@dataclass +class PrivateGetDepositHistoryParamsSchema(PrivateGetLiquidationHistoryParamsSchema): + pass -class TradeModuleDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - asset: str = Field(..., title="asset") - desired_amount: Decimal = Field(..., title="desired_amount") - is_bid: bool = Field(..., title="is_bid") - limit_price: Decimal = Field(..., title="limit_price") - recipient_id: int = Field(..., title="recipient_id") - sub_id: int = Field(..., title="sub_id") - trade_id: str = Field(..., title="trade_id") - worst_fee: Decimal = Field(..., title="worst_fee") - - -class PrivateDepositParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") - asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") - is_atomic_signing: bool = Field( - False, - description="Used by vaults to determine whether the signature is an EIP-1271 signature", - title="is_atomic_signing", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature: str = Field(..., description="Ethereum signature of the deposit", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the deposit", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class DepositSchema: + amount: Decimal + asset: str + error_log: Optional[Dict[str, Any]] + timestamp: int + transaction_id: str + tx_hash: str + tx_status: TxStatus -class PrivateDepositResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - status: str = Field(..., description="`requested`", title="status") - transaction_id: UUID = Field(..., description="Transaction id of the deposit", title="transaction_id") +@dataclass +class PrivateCancelByLabelParamsSchema: + label: str + subaccount_id: int + instrument_name: Optional[str] = None -class PrivateUpdateNotificationsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - notification_ids: List[int] = Field( - ..., - description="List of notification IDs to be marked as seen", - title="notification_ids", - ) - status: Status = Field("seen", description="Status of the notification", title="status") - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateCancelByLabelResultSchema(PrivateCancelByNonceResultSchema): + pass -class PrivateUpdateNotificationsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - updated_count: int = Field(..., description="Number of notifications marked as seen", title="updated_count") +@dataclass +class PrivateGetMarginParamsSchema: + subaccount_id: int + simulated_collateral_changes: Optional[List[SimulatedCollateralSchema]] = None + simulated_position_changes: Optional[List[SimulatedPositionSchema]] = None -class PrivateChangeSubaccountLabelParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - label: str = Field(..., description="User defined label", title="label") - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateGetMarginResultSchema(PublicGetMarginResultSchema): + pass -PrivateChangeSubaccountLabelResultSchema = PrivateChangeSubaccountLabelParamsSchema +@dataclass +class PublicCreateSubaccountDebugParamsSchema: + amount: Decimal + asset_name: str + margin_type: MarginType + nonce: int + signature_expiry_sec: int + signer: str + wallet: str + currency: Optional[str] = None -class SignedQuoteParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - direction: Direction = Field( - ..., - description="Quote direction, `buy` means trading each leg at its direction, `sell` means trading each leg in the opposite direction.", - title="direction", - ) - legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") - max_fee: Decimal = Field( - ..., - description="Max fee ($ for the full trade). Request will be rejected if the supplied max fee is below the estimated fee for this trade.", - title="max_fee", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as a concatenated `UTC timestamp in ms` and `random number up to 6 digits` (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature: str = Field(..., description="Ethereum signature of the quote", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be at least 310 seconds from now. Once time till signature expiry reaches 300 seconds, the quote will be considered expired. This buffer is meant to ensure the trade can settle on chain in case of a blockchain congestion.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed the quote", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PublicCreateSubaccountDebugResultSchema: + action_hash: str + encoded_data: str + encoded_data_hashed: str + typed_data_hash: str -class QuoteResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") - creation_timestamp: int = Field( - ..., - description="Creation timestamp in ms since Unix epoch", - title="creation_timestamp", - ) - direction: Direction = Field(..., description="Quote direction", title="direction") - fee: Decimal = Field(..., description="Fee paid for this quote (if executed)", title="fee") - fill_pct: Decimal = Field( - ..., - description="Percentage of the RFQ that this quote would fill, from 0 to 1.", - title="fill_pct", - ) - is_transfer: bool = Field( - ..., - description="Whether the order was generated through `private/transfer_position`", - title="is_transfer", - ) - label: str = Field(..., description="User-defined label, if any", title="label") - last_update_timestamp: int = Field( - ..., - description="Last update timestamp in ms since Unix epoch", - title="last_update_timestamp", - ) - legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") - legs_hash: str = Field( - ..., - description="Hash of the legs of the best quote to be signed by the taker.", - title="legs_hash", - ) - liquidity_role: LiquidityRole = Field(..., description="Liquidity role", title="liquidity_role") - max_fee: Decimal = Field(..., description="Signed max fee", title="max_fee") - mmp: bool = Field( - ..., - description="Whether the quote is tagged for market maker protections (default false)", - title="mmp", - ) - nonce: int = Field(..., description="Nonce", title="nonce") - quote_id: UUID = Field(..., description="Quote ID", title="quote_id") - rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") - signature: str = Field(..., description="Ethereum signature of the quote", title="signature") - signature_expiry_sec: int = Field(..., description="Unix timestamp in seconds", title="signature_expiry_sec") - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed the quote", - title="signer", - ) - status: Status1 = Field(..., description="Status", title="status") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - tx_hash: Optional[str] = Field( - ..., - description="Blockchain transaction hash (only for executed quotes)", - title="tx_hash", - ) - tx_status: Optional[TxStatus] = Field( - ..., - description="Blockchain transaction status (only for executed quotes)", - title="tx_status", - ) +@dataclass +class PublicGetInstrumentParamsSchema: + instrument_name: str -class PublicGetMakerProgramsParamsSchema(BaseModel): - pass - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class ERC20PublicDetailsSchema: + decimals: int + borrow_index: Decimal = "1" + supply_index: Decimal = "1" + underlying_erc20_address: str = "" -class ProgramResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - asset_types: List[str] = Field( - ..., - description="List of asset types covered by the program", - title="asset_types", - ) - currencies: List[str] = Field(..., description="List of currencies covered by the program", title="currencies") - end_timestamp: int = Field(..., description="End timestamp of the epoch", title="end_timestamp") - min_notional: Decimal = Field( - ..., - description="Minimum dollar notional to quote for eligibility", - title="min_notional", - ) - name: str = Field(..., description="Name of the program", title="name") - rewards: Dict[str, Decimal] = Field( - ..., - description="Rewards for the program as a token -> total reward amount mapping", - title="rewards", - ) - start_timestamp: int = Field(..., description="Start timestamp of the epoch", title="start_timestamp") +class OptionType(str, Enum): + C = "C" + P = "P" -class SimulatedCollateralSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Collateral amount to simulate", title="amount") - asset_name: str = Field( - ..., - description="Collateral ERC20 asset name (e.g. ETH, USDC, WSTETH)", - title="asset_name", - ) +@dataclass +class OptionPublicDetailsSchema: + expiry: int + index: str + option_type: OptionType + strike: Decimal + settlement_price: Optional[Decimal] = None -class SimulatedPositionSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Position amount to simulate", title="amount") - entry_price: Optional[Decimal] = Field( - None, - description="Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", - title="entry_price", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") +@dataclass +class PerpPublicDetailsSchema: + aggregate_funding: Decimal + funding_rate: Decimal + index: str + max_rate_per_hour: Decimal + min_rate_per_hour: Decimal + static_interest_rate: Decimal -class PublicGetMarginResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - is_valid_trade: bool = Field( - ..., - description="True if trade passes margin requirement", - title="is_valid_trade", - ) - post_initial_margin: Decimal = Field( - ..., - description="Initial margin requirement post trade", - title="post_initial_margin", - ) - post_maintenance_margin: Decimal = Field( - ..., - description="Maintenance margin requirement post trade", - title="post_maintenance_margin", - ) - pre_initial_margin: Decimal = Field( - ..., - description="Initial margin requirement before trade", - title="pre_initial_margin", - ) - pre_maintenance_margin: Decimal = Field( - ..., - description="Maintenance margin requirement before trade", - title="pre_maintenance_margin", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateEditSessionKeyParamsSchema: + public_session_key: str + wallet: str + disable: bool = False + ip_whitelist: Optional[List[str]] = None + label: Optional[str] = None -class PrivateCancelByNonceParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - nonce: int = Field(..., description="Cancel an order with this nonce", title="nonce") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - wallet: str = Field(..., description="Wallet address", title="wallet") +@dataclass +class PrivateEditSessionKeyResultSchema: + expiry_sec: int + ip_whitelist: List[str] + label: str + public_session_key: str + scope: str -class PrivateCancelByNonceResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancelled_orders: int = Field(..., description="Number of cancelled orders", title="cancelled_orders") +@dataclass +class PrivateGetLiquidatorHistoryParamsSchema: + subaccount_id: int + end_timestamp: int = 9223372036854776000 + page: int = 1 + page_size: int = 100 + start_timestamp: int = 0 -class PublicGetSpotFeedHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency", title="currency") - end_timestamp: int = Field(..., description="End timestamp", title="end_timestamp") - period: int = Field(..., description="Period", title="period") - start_timestamp: int = Field(..., description="Start timestamp", title="start_timestamp") +@dataclass +class PrivateGetLiquidatorHistoryResultSchema: + bids: List[AuctionBidEventSchema] + pagination: PaginationInfoSchema -class SpotFeedHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - price: Decimal = Field(..., description="Spot price", title="price") - timestamp: int = Field( - ..., - description="Timestamp of when the spot price was recored into the database", - title="timestamp", - ) - timestamp_bucket: int = Field( - ..., - description="Timestamp bucket; this value is regularly spaced out with `period` seconds between data points, missing values are forward-filled from earlier data where possible, if no earlier data is available, values are back-filled from the first observed data point", - title="timestamp_bucket", - ) - - -class PrivateGetSubaccountsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") - - -class PrivateGetSubaccountsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_ids: List[int] = Field( - ..., - description="List of subaccount_ids owned by the wallet in `SubAccounts.sol`", - title="subaccount_ids", - ) - wallet: str = Field(..., description="Ethereum wallet address", title="wallet") - - -PrivateGetDepositHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema - - -class DepositSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount deposited by the subaccount", title="amount") - asset: str = Field(..., description="Asset deposited", title="asset") - error_log: Optional[Dict[str, Any]] = Field(..., description="If failed, error log for reason", title="error_log") - timestamp: int = Field( - ..., - description="Timestamp of the deposit (in ms since UNIX epoch)", - title="timestamp", - ) - transaction_id: UUID = Field(..., description="Transaction ID", title="transaction_id") - tx_hash: str = Field( - ..., - description="Hash of the transaction that deposited the funds", - title="tx_hash", - ) - tx_status: TxStatus = Field( - ..., - description="Status of the transaction that deposited the funds", - title="tx_status", - ) - - -class PrivateCancelByLabelParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instrument_name: Optional[str] = Field( - None, - description="Instrument name. If not provided, all orders for all instruments with the label will be cancelled. If provided, request counts as a regular matching request for ratelimit purposes.", - title="instrument_name", - ) - label: str = Field(..., description="Cancel all orders for this label", title="label") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - - -PrivateCancelByLabelResultSchema = PrivateCancelByNonceResultSchema - - -class PrivateGetMarginParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - simulated_collateral_changes: Optional[List[SimulatedCollateralSchema]] = Field( - None, - description="Optional, add collaterals to simulate deposits / withdrawals / spot trades", - title="simulated_collateral_changes", - ) - simulated_position_changes: Optional[List[SimulatedPositionSchema]] = Field( - None, - description="Optional, add positions to simulate perp / option trades", - title="simulated_position_changes", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") - - -PrivateGetMarginResultSchema = PublicGetMarginResultSchema - - -class PublicCreateSubaccountDebugParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") - asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") - currency: Optional[str] = Field( - None, - description="Base currency of the subaccount (only for `PM`)", - title="currency", - ) - margin_type: MarginType = Field( - ..., - description="`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", - title="margin_type", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the deposit", - title="signer", - ) - wallet: str = Field(..., description="Ethereum wallet address", title="wallet") - - -class PublicCreateSubaccountDebugResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - action_hash: str = Field(..., description="Keccak hashed action data", title="action_hash") - encoded_data: str = Field(..., description="ABI encoded deposit data", title="encoded_data") - encoded_data_hashed: str = Field(..., description="Keccak hashed encoded_data", title="encoded_data_hashed") - typed_data_hash: str = Field(..., description="EIP 712 typed data hash", title="typed_data_hash") - - -class PublicGetInstrumentParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - - -class ERC20PublicDetailsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - borrow_index: Decimal = Field( - "1", - description="Latest borrow index as per `CashAsset.sol` implementation", - title="borrow_index", - ) - decimals: int = Field( - ..., - description="Number of decimals of the underlying on-chain ERC20 token", - title="decimals", - ) - supply_index: Decimal = Field( - "1", - description="Latest supply index as per `CashAsset.sol` implementation", - title="supply_index", - ) - underlying_erc20_address: str = Field( - "", - description="Address of underlying on-chain ERC20 (not V2 asset)", - title="underlying_erc20_address", - ) - - -class OptionType(Enum): - C = "C" - P = "P" - - -class OptionPublicDetailsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry: int = Field(..., description="Unix timestamp of expiry date (in seconds)", title="expiry") - index: str = Field(..., description="Underlying settlement price index", title="index") - option_type: OptionType = Field(..., title="option_type") - settlement_price: Optional[Decimal] = Field( - None, description="Settlement price of the option", title="settlement_price" - ) - strike: Decimal = Field(..., title="strike") - - -class PerpPublicDetailsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - aggregate_funding: Decimal = Field( - ..., - description="Latest aggregated funding as per `PerpAsset.sol`", - title="aggregate_funding", - ) - funding_rate: Decimal = Field( - ..., - description="Current hourly funding rate as per `PerpAsset.sol`", - title="funding_rate", - ) - index: str = Field(..., description="Underlying spot price index for funding rate", title="index") - max_rate_per_hour: Decimal = Field( - ..., - description="Max rate per hour as per `PerpAsset.sol`", - title="max_rate_per_hour", - ) - min_rate_per_hour: Decimal = Field( - ..., - description="Min rate per hour as per `PerpAsset.sol`", - title="min_rate_per_hour", - ) - static_interest_rate: Decimal = Field( - ..., - description="Static interest rate as per `PerpAsset.sol`", - title="static_interest_rate", - ) - - -class PrivateEditSessionKeyParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - disable: bool = Field( - False, - description="Flag whether or not to disable to session key. Defaulted to false. Only allowed for non-admin keys. Admin keys must go through `/deregister_session_key` for now.", - title="disable", - ) - ip_whitelist: Optional[List[str]] = Field( - None, - description="Optional list of whitelisted IPs, an empty list can be supplied to whitelist all IPs", - title="ip_whitelist", - ) - label: Optional[str] = Field(None, description="Optional new label for the session key", title="label") - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") - - -class PrivateEditSessionKeyResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry_sec: int = Field(..., description="Session key expiry timestamp in sec", title="expiry_sec") - ip_whitelist: List[str] = Field( - ..., - description="List of whitelisted IPs, if empty then any IP is allowed.", - title="ip_whitelist", - ) - label: str = Field(..., description="User-defined session key label", title="label") - public_session_key: str = Field( - ..., - description="Public session key address (Ethereum EOA)", - title="public_session_key", - ) - scope: str = Field(..., description="Session key permission level scope", title="scope") - - -class PrivateGetLiquidatorHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field( - 9223372036854776000, - description="End timestamp of the event history (default current time)", - title="end_timestamp", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - start_timestamp: int = Field( - 0, - description="Start timestamp of the event history (default 0)", - title="start_timestamp", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - - -class PrivateGetLiquidatorHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - bids: List[AuctionBidEventSchema] = Field(..., description="List of auction bid events", title="bids") - pagination: PaginationInfoSchema - - -class PrivateGetPositionsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") - - -class PositionResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Position amount held by subaccount", title="amount") - amount_step: Decimal = Field(..., description="Minimum amount step for the position", title="amount_step") - average_price: Decimal = Field(..., description="Average price of whole position", title="average_price") - average_price_excl_fees: Decimal = Field( - ..., - description="Average price of whole position excluding fees", - title="average_price_excl_fees", - ) - creation_timestamp: int = Field( - ..., - description="Timestamp of when the position was opened (in ms since Unix epoch)", - title="creation_timestamp", - ) - cumulative_funding: Decimal = Field( - ..., - description="Cumulative funding for the position (only for perpetuals).", - title="cumulative_funding", - ) - delta: Decimal = Field( - ..., - description="Asset delta (w.r.t. forward price for options, `1.0` for perps)", - title="delta", - ) - gamma: Decimal = Field(..., description="Asset gamma (zero for non-options)", title="gamma") - index_price: Decimal = Field( - ..., - description="Current index (oracle) price for position's currency", - title="index_price", - ) - initial_margin: Decimal = Field( - ..., - description="USD initial margin requirement for this position", - title="initial_margin", - ) - instrument_name: str = Field( - ..., - description="Instrument name (same as the base Asset name)", - title="instrument_name", - ) - instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") - leverage: Optional[Decimal] = Field( - ..., - description="Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", - title="leverage", - ) - liquidation_price: Optional[Decimal] = Field( - ..., - description="Index price at which position will be liquidated", - title="liquidation_price", - ) - maintenance_margin: Decimal = Field( - ..., - description="USD maintenance margin requirement for this position", - title="maintenance_margin", - ) - mark_price: Decimal = Field( - ..., - description="Current mark price for position's instrument", - title="mark_price", - ) - mark_value: Decimal = Field( - ..., - description="USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price", - title="mark_value", - ) - net_settlements: Decimal = Field( - ..., - description="Net amount of USD from position settlements that has been paid to the user's subaccount. This number is subtracted from the portfolio value for margin calculations purposes.
Positive values mean the user has recieved USD from settlements, or is awaiting settlement of USD losses. Negative values mean the user has paid USD for settlements, or is awaiting settlement of USD gains.", - title="net_settlements", - ) - open_orders_margin: Decimal = Field( - ..., - description="USD margin requirement for all open orders for this asset / instrument", - title="open_orders_margin", - ) - pending_funding: Decimal = Field( - ..., - description="A portion of funding payments that has not yet been settled into cash balance (only for perpetuals). This number is added to the portfolio value for margin calculations purposes.", - title="pending_funding", - ) - realized_pnl: Decimal = Field( - ..., - description="Realized trading profit or loss of the position.", - title="realized_pnl", - ) - realized_pnl_excl_fees: Decimal = Field( - ..., - description="Realized trading profit or loss of the position excluding fees", - title="realized_pnl_excl_fees", - ) - theta: Decimal = Field(..., description="Asset theta (zero for non-options)", title="theta") - total_fees: Decimal = Field( - ..., - description="Total fees paid for opening and changing the position", - title="total_fees", - ) - unrealized_pnl: Decimal = Field( - ..., - description="Unrealized trading profit or loss of the position.", - title="unrealized_pnl", - ) - unrealized_pnl_excl_fees: Decimal = Field( - ..., - description="Unrealized trading profit or loss of the position excluding fees", - title="unrealized_pnl_excl_fees", - ) - vega: Decimal = Field(..., description="Asset vega (zero for non-options)", title="vega") - - -class TxStatus4(Enum): +@dataclass +class PrivateGetPositionsParamsSchema: + subaccount_id: int + + +@dataclass +class PositionResponseSchema: + amount: Decimal + amount_step: Decimal + average_price: Decimal + average_price_excl_fees: Decimal + creation_timestamp: int + cumulative_funding: Decimal + delta: Decimal + gamma: Decimal + index_price: Decimal + initial_margin: Decimal + instrument_name: str + instrument_type: InstrumentType + leverage: Optional[Decimal] + liquidation_price: Optional[Decimal] + maintenance_margin: Decimal + mark_price: Decimal + mark_value: Decimal + net_settlements: Decimal + open_orders_margin: Decimal + pending_funding: Decimal + realized_pnl: Decimal + realized_pnl_excl_fees: Decimal + theta: Decimal + total_fees: Decimal + unrealized_pnl: Decimal + unrealized_pnl_excl_fees: Decimal + vega: Decimal + + +class TxStatus4(str, Enum): settled = "settled" reverted = "reverted" timed_out = "timed_out" -class PublicGetTradeHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: Optional[str] = Field(None, description="Currency to filter by (defaults to all)", title="currency") - from_timestamp: int = Field( - 0, - description="Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0.", - title="from_timestamp", - ) - instrument_name: Optional[str] = Field( - None, - description="Instrument name to filter by (defaults to all)", - title="instrument_name", - ) - instrument_type: Optional[InstrumentType] = Field( - None, - description="Instrument type to filter by (defaults to all)", - title="instrument_type", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - subaccount_id: Optional[int] = Field(None, description="Subaccount ID to filter by", title="subaccount_id") - to_timestamp: int = Field( - 18446744073709552000, - description="Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", - title="to_timestamp", - ) - trade_id: Optional[UUID] = Field( - None, - description="Trade ID to filter by. If set, all other filters are ignored", - title="trade_id", - ) - tx_hash: Optional[str] = Field( - None, - description="On-chain tx hash to filter by. If set, all other filters are ignored", - title="tx_hash", - ) - tx_status: TxStatus4 = Field( - "settled", - description="Transaction status to filter by (default `settled`).", - title="tx_status", - ) +@dataclass +class PublicGetTradeHistoryParamsSchema: + currency: Optional[str] = None + from_timestamp: int = 0 + instrument_name: Optional[str] = None + instrument_type: Optional[InstrumentType] = None + page: int = 1 + page_size: int = 100 + subaccount_id: Optional[int] = None + to_timestamp: int = 18446744073709552000 + trade_id: Optional[str] = None + tx_hash: Optional[str] = None + tx_status: TxStatus4 = TxStatus4.settled + + +@dataclass +class TradeSettledPublicResponseSchema: + direction: Direction + expected_rebate: Decimal + index_price: Decimal + instrument_name: str + liquidity_role: LiquidityRole + mark_price: Decimal + quote_id: Optional[str] + realized_pnl: Decimal + realized_pnl_excl_fees: Decimal + subaccount_id: int + timestamp: int + trade_amount: Decimal + trade_fee: Decimal + trade_id: str + trade_price: Decimal + tx_hash: str + tx_status: TxStatus4 + wallet: str + + +@dataclass +class PrivateGetRfqsParamsSchema: + subaccount_id: int + from_timestamp: int = 0 + page: int = 1 + page_size: int = 100 + rfq_id: Optional[str] = None + status: Optional[Status1] = None + to_timestamp: int = 18446744073709552000 + + +@dataclass +class RFQResultSchema(PrivateSendRfqResultSchema): + pass -class TradeSettledPublicResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - direction: Direction = Field(..., description="Order direction", title="direction") - expected_rebate: Decimal = Field(..., description="Expected rebate for this trade", title="expected_rebate") - index_price: Decimal = Field( - ..., - description="Index price of the underlying at the time of the trade", - title="index_price", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - liquidity_role: LiquidityRole = Field(..., description="Role of the user in the trade", title="liquidity_role") - mark_price: Decimal = Field( - ..., - description="Mark price of the instrument at the time of the trade", - title="mark_price", - ) - quote_id: Optional[UUID] = Field(..., description="Quote ID if the trade was executed via RFQ", title="quote_id") - realized_pnl: Decimal = Field(..., description="Realized PnL for this trade", title="realized_pnl") - realized_pnl_excl_fees: Decimal = Field( - ..., - description="Realized PnL for this trade using cost accounting that excludes fees", - title="realized_pnl_excl_fees", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - timestamp: int = Field(..., description="Trade timestamp (in ms since Unix epoch)", title="timestamp") - trade_amount: Decimal = Field(..., description="Amount filled in this trade", title="trade_amount") - trade_fee: Decimal = Field(..., description="Fee for this trade", title="trade_fee") - trade_id: str = Field(..., description="Trade ID", title="trade_id") - trade_price: Decimal = Field(..., description="Price at which the trade was filled", title="trade_price") - tx_hash: str = Field(..., description="Blockchain transaction hash", title="tx_hash") - tx_status: TxStatus4 = Field(..., description="Blockchain transaction status", title="tx_status") - wallet: str = Field(..., description="Wallet address (owner) of the subaccount", title="wallet") - - -class PrivateGetRfqsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - from_timestamp: int = Field( - 0, - description="Earliest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to 0.", - title="from_timestamp", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - rfq_id: Optional[UUID] = Field(None, description="RFQ ID filter, if applicable", title="rfq_id") - status: Optional[Status1] = Field(None, description="RFQ status filter, if applicable", title="status") - subaccount_id: int = Field( - ..., - description="Subaccount ID for auth purposes, returned data will be scoped to this subaccount.", - title="subaccount_id", - ) - to_timestamp: int = Field( - 18446744073709552000, - description="Latest `last_update_timestamp` to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", - title="to_timestamp", - ) +@dataclass +class SignatureDetailsSchema: + nonce: int + signature: str + signature_expiry_sec: int + signer: str -RFQResultSchema = PrivateSendRfqResultSchema +@dataclass +class TransferDetailsSchema: + address: str + amount: Decimal + sub_id: int -class SignatureDetailsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature: str = Field(..., description="Ethereum signature of the transfer", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the transfer", - title="signer", - ) +@dataclass +class PrivateTransferErc20ResultSchema(PrivateCreateSubaccountResultSchema): + pass -class TransferDetailsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - address: str = Field( - ..., - description="Ethereum address of the asset being transferred", - title="address", - ) - amount: Decimal = Field(..., description="Amount to transfer", title="amount") - sub_id: int = Field(..., description="Sub ID of the asset being transferred", title="sub_id") +@dataclass +class PrivateSendQuoteParamsSchema: + direction: Direction + legs: List[LegPricedSchema] + max_fee: Decimal + nonce: int + rfq_id: str + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + label: str = "" + mmp: bool = False -class PrivateTransferErc20ResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - status: str = Field(..., description="`requested`", title="status") - transaction_id: UUID = Field(..., description="Transaction id of the transfer", title="transaction_id") +@dataclass +class PrivateSendQuoteResultSchema(QuoteResultSchema): + pass -class PrivateSendQuoteParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - direction: Direction = Field( - ..., - description="Quote direction, `buy` means trading each leg at its direction, `sell` means trading each leg in the opposite direction.", - title="direction", - ) - label: str = Field("", description="Optional user-defined label for the quote", title="label") - legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") - max_fee: Decimal = Field( - ..., - description="Max fee ($ for the full trade). Request will be rejected if the supplied max fee is below the estimated fee for this trade.", - title="max_fee", - ) - mmp: bool = Field( - False, - description="Whether the quote is tagged for market maker protections (default false)", - title="mmp", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as a concatenated `UTC timestamp in ms` and `random number up to 6 digits` (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - rfq_id: UUID = Field(..., description="RFQ ID the quote is for", title="rfq_id") - signature: str = Field(..., description="Ethereum signature of the quote", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be at least 310 seconds from now. Once time till signature expiry reaches 300 seconds, the quote will be considered expired. This buffer is meant to ensure the trade can settle on chain in case of a blockchain congestion.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed the quote", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateCancelTriggerOrderParamsSchema: + order_id: str + subaccount_id: int -PrivateSendQuoteResultSchema = QuoteResultSchema +@dataclass +class PrivateCancelTriggerOrderResultSchema(OrderResponseSchema): + pass -class PrivateCancelTriggerOrderParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - order_id: UUID = Field(..., title="order_id") - subaccount_id: int = Field(..., title="subaccount_id") +@dataclass +class PrivateGetWithdrawalHistoryParamsSchema(PrivateGetLiquidationHistoryParamsSchema): + pass -PrivateCancelTriggerOrderResultSchema = OrderResponseSchema +@dataclass +class WithdrawalSchema: + amount: Decimal + asset: str + error_log: Optional[Dict[str, Any]] + timestamp: int + tx_hash: str + tx_status: TxStatus -PrivateGetWithdrawalHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema +@dataclass +class PublicGetOptionSettlementPricesParamsSchema(PublicGetCurrencyParamsSchema): + pass -class WithdrawalSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount withdrawn by the subaccount", title="amount") - asset: str = Field(..., description="Asset withdrawn", title="asset") - error_log: Optional[Dict[str, Any]] = Field(..., description="If failed, error log for reason", title="error_log") - timestamp: int = Field( - ..., - description="Timestamp of the withdrawal (in ms since UNIX epoch)", - title="timestamp", - ) - tx_hash: str = Field( - ..., - description="Hash of the transaction that withdrew the funds", - title="tx_hash", - ) - tx_status: TxStatus = Field( - ..., - description="Status of the transaction that deposited the funds", - title="tx_status", - ) +@dataclass +class ExpiryResponseSchema: + expiry_date: str + price: Optional[Decimal] + utc_expiry_sec: int -class PublicGetOptionSettlementPricesParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency for which to show expiries", title="currency") +@dataclass +class PublicGetMakerProgramScoresParamsSchema: + epoch_start_timestamp: int + program_name: str -class ExpiryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry_date: str = Field(..., description="Expiry date in `YYYYMMDD` format", title="expiry_date") - price: Optional[Decimal] = Field( - ..., - description="Settlement price will show None if not yet settled onchain", - title="price", - ) - utc_expiry_sec: int = Field(..., description="UTC timestamp of expiry", title="utc_expiry_sec") +@dataclass +class ScoreBreakdownSchema: + coverage_score: Decimal + holder_boost: Decimal + quality_score: Decimal + total_score: Decimal + volume: Decimal + volume_multiplier: Decimal + wallet: str -class PublicGetMakerProgramScoresParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - epoch_start_timestamp: int = Field( - ..., - description="Start timestamp of the program epoch", - title="epoch_start_timestamp", - ) - program_name: str = Field(..., description="Program name", title="program_name") +@dataclass +class PublicBuildRegisterSessionKeyTxParamsSchema: + expiry_sec: int + gas: Optional[int] + nonce: Optional[int] + public_session_key: str + wallet: str -class ScoreBreakdownSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - coverage_score: Decimal = Field( - ..., - description="Coverag component of the score of the account for this program", - title="coverage_score", - ) - holder_boost: Decimal = Field( - ..., - description="A custom account multiplier for the score due to holding tokens", - title="holder_boost", - ) - quality_score: Decimal = Field( - ..., - description="Quality component of the score of the account for this program", - title="quality_score", - ) - total_score: Decimal = Field( - ..., - description="Total score of the account for this program", - title="total_score", - ) - volume: Decimal = Field(..., description="Volume traded by the account for this epoch", title="volume") - volume_multiplier: Decimal = Field( - ..., - description="Multiplier for the volume traded by the account", - title="volume_multiplier", - ) - wallet: str = Field(..., description="Wallet address of the account", title="wallet") +@dataclass +class PublicBuildRegisterSessionKeyTxResultSchema: + tx_params: Dict[str, Any] -class PublicBuildRegisterSessionKeyTxParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry_sec: int = Field(..., description="Expiry of the session key", title="expiry_sec") - gas: Optional[int] = Field( - ..., - description="Gas allowance for transaction. If none, will use estimateGas * 150%", - title="gas", - ) - nonce: Optional[int] = Field( - ..., - description="Wallet's transaction count, If none, will use eth.getTransactionCount()", - title="nonce", - ) - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") +@dataclass +class PublicRegisterSessionKeyParamsSchema: + expiry_sec: int + label: str + public_session_key: str + signed_raw_tx: str + wallet: str -class PublicBuildRegisterSessionKeyTxResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - tx_params: Dict[str, Any] = Field( - ..., - description="Transaction params in dictionary form, same as `TxParams` in `web3.py`", - title="tx_params", - ) +@dataclass +class PublicRegisterSessionKeyResultSchema: + label: str + public_session_key: str + transaction_id: str -class PublicRegisterSessionKeyParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry_sec: int = Field(..., description="Expiry of the session key", title="expiry_sec") - label: str = Field(..., description="Ethereum wallet address", title="label") - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - signed_raw_tx: str = Field( - ..., - description="A signed RLP encoded ETH transaction in form of a hex string (same as `w3.eth.account.sign_transaction(unsigned_tx, private_key).rawTransaction.hex()`)", - title="signed_raw_tx", - ) - wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") - - -class PublicRegisterSessionKeyResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - label: str = Field(..., description="User-defined session key label", title="label") - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - transaction_id: UUID = Field(..., description="ID to lookup status of transaction", title="transaction_id") - - -class PrivateGetOrderHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get order history", - title="subaccount_id", - ) +@dataclass +class PrivateGetOrderHistoryParamsSchema: + subaccount_id: int + page: int = 1 + page_size: int = 100 -class PrivateGetOrderHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - orders: List[OrderResponseSchema] = Field(..., description="List of open orders", title="orders") +@dataclass +class PrivateGetOrderHistoryResultSchema: + orders: List[OrderResponseSchema] pagination: PaginationInfoSchema - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get open orders", - title="subaccount_id", - ) + subaccount_id: int -class PrivateCancelRfqParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - rfq_id: UUID = Field(..., description="RFQ ID to cancel", title="rfq_id") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateCancelRfqParamsSchema: + rfq_id: str + subaccount_id: int -class Result(Enum): +class Result(str, Enum): ok = "ok" -class PrivateCancelRfqResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelRfqResponseSchema: id: Union[str, int] - result: Result = Field( - ..., - description="The result of this method call, `ok` if successful", - title="result", - ) + result: Result -class PrivateCancelBatchRfqsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - label: Optional[str] = Field(None, description="Cancel RFQs with this label", title="label") - nonce: Optional[int] = Field(None, description="Cancel RFQ with this nonce", title="nonce") - rfq_id: Optional[UUID] = Field(None, description="RFQ ID to cancel", title="rfq_id") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateCancelBatchRfqsParamsSchema: + subaccount_id: int + label: Optional[str] = None + nonce: Optional[int] = None + rfq_id: Optional[str] = None -class PrivateCancelBatchRfqsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancelled_ids: List[UUID] = Field(..., description="RFQ IDs of the cancelled RFQs", title="cancelled_ids") +@dataclass +class PrivateCancelBatchRfqsResultSchema: + cancelled_ids: List[str] -class PrivateCancelBatchQuotesParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - label: Optional[str] = Field(None, description="Cancel quotes with this label", title="label") - nonce: Optional[int] = Field(None, description="Cancel quote with this nonce", title="nonce") - quote_id: Optional[UUID] = Field(None, description="Quote ID to cancel", title="quote_id") - rfq_id: Optional[UUID] = Field(None, description="Cancel quotes for this RFQ ID", title="rfq_id") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateCancelBatchQuotesParamsSchema: + subaccount_id: int + label: Optional[str] = None + nonce: Optional[int] = None + quote_id: Optional[str] = None + rfq_id: Optional[str] = None -class PrivateCancelBatchQuotesResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancelled_ids: List[UUID] = Field(..., description="Quote IDs of the cancelled quotes", title="cancelled_ids") +@dataclass +class PrivateCancelBatchQuotesResultSchema(PrivateCancelBatchRfqsResultSchema): + pass -PublicGetTimeParamsSchema = PublicGetMakerProgramsParamsSchema +@dataclass +class PublicGetTimeParamsSchema(PublicGetMakerProgramsParamsSchema): + pass -class PublicGetTimeResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetTimeResponseSchema: id: Union[str, int] - result: int = Field(..., description="Current time in milliseconds since UNIX epoch", title="result") - - -class PrivateGetFundingHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field( - 9223372036854776000, - description="End timestamp of the event history (default current time)", - title="end_timestamp", - ) - instrument_name: Optional[str] = Field( - None, - description="Instrument name (returns history for all perpetuals if not provided)", - title="instrument_name", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - start_timestamp: int = Field( - 0, - description="Start timestamp of the event history (default 0)", - title="start_timestamp", - ) - subaccount_id: int = Field(..., description="Subaccount id", title="subaccount_id") - - -class FundingPaymentSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - funding: Decimal = Field( - ..., - description="Dollar funding paid (if negative) or received (if positive) by the subaccount", - title="funding", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - pnl: Decimal = Field(..., description="Cashflow from the perp PnL settlement", title="pnl") - timestamp: int = Field( - ..., - description="Timestamp of the funding payment (in ms since UNIX epoch)", - title="timestamp", - ) + result: int -class PrivateGetOpenOrdersParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get open orders", - title="subaccount_id", - ) +@dataclass +class PrivateGetFundingHistoryParamsSchema: + subaccount_id: int + end_timestamp: int = 9223372036854776000 + instrument_name: Optional[str] = None + page: int = 1 + page_size: int = 100 + start_timestamp: int = 0 -class PrivateGetOpenOrdersResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - orders: List[OrderResponseSchema] = Field(..., description="List of open orders", title="orders") - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get open orders", - title="subaccount_id", - ) - - -PrivateGetAccountParamsSchema = PrivateGetSubaccountsParamsSchema +@dataclass +class FundingPaymentSchema: + funding: Decimal + instrument_name: str + pnl: Decimal + timestamp: int -class AccountFeeInfoSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - base_fee_discount: Decimal = Field(..., description="Base fee discount", title="base_fee_discount") - option_maker_fee: Optional[Decimal] = Field( - ..., - description="Option maker fee - uses default instrument fee rate if None", - title="option_maker_fee", - ) - option_taker_fee: Optional[Decimal] = Field( - ..., - description="Option taker fee - uses default instrument fee rate if None", - title="option_taker_fee", - ) - perp_maker_fee: Optional[Decimal] = Field( - ..., - description="Perp maker fee - uses default instrument fee rate if None", - title="perp_maker_fee", - ) - perp_taker_fee: Optional[Decimal] = Field( - ..., - description="Perp taker fee - uses default instrument fee rate if None", - title="perp_taker_fee", - ) - rfq_maker_discount: Decimal = Field(..., description="RFQ maker fee discount", title="rfq_maker_discount") - rfq_taker_discount: Decimal = Field(..., description="RFQ taker fee discount", title="rfq_taker_discount") - spot_maker_fee: Optional[Decimal] = Field( - ..., - description="Spot maker fee - uses default instrument fee rate if None", - title="spot_maker_fee", - ) - spot_taker_fee: Optional[Decimal] = Field( - ..., - description="Spot taker fee - uses default instrument fee rate if None", - title="spot_taker_fee", - ) - - -class PublicGetAllInstrumentsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: Optional[str] = Field( - None, - description="Underlying currency of asset (`ETH`, `BTC`, etc)", - title="currency", - ) - expired: bool = Field(..., description="If `True`: include expired instruments.", title="expired") - instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - - -class InstrumentPublicResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount_step: Decimal = Field(..., description="Minimum valid increment of order amount", title="amount_step") - base_asset_address: str = Field( - ..., - description="Blockchain address of the base asset", - title="base_asset_address", - ) - base_asset_sub_id: str = Field( - ..., - description="Sub ID of the specific base asset as defined in Asset.sol", - title="base_asset_sub_id", - ) - base_currency: str = Field( - ..., - description="Underlying currency of base asset (`ETH`, `BTC`, etc)", - title="base_currency", - ) - base_fee: Decimal = Field(..., description="$ base fee added to every taker order", title="base_fee") - erc20_details: Optional[ERC20PublicDetailsSchema] = Field(...) - fifo_min_allocation: Decimal = Field( - ..., - description="Minimum number of contracts that get filled using FIFO. Actual number of contracts that gets filled by FIFO will be the max between this value and (1 - pro_rata_fraction) x order_amount, plus any size leftovers due to rounding.", - title="fifo_min_allocation", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") - is_active: bool = Field( - ..., - description="If `True`: instrument is tradeable within `activation` and `deactivation` timestamps", - title="is_active", - ) - maker_fee_rate: Decimal = Field( - ..., - description="Percent of spot price fee rate for makers", - title="maker_fee_rate", - ) - mark_price_fee_rate_cap: Optional[Decimal] = Field( - None, - description="Percent of option price fee cap, e.g. 12.5%, null if not applicable", - title="mark_price_fee_rate_cap", - ) - maximum_amount: Decimal = Field( - ..., - description="Maximum valid amount of contracts / tokens per trade", - title="maximum_amount", - ) - minimum_amount: Decimal = Field( - ..., - description="Minimum valid amount of contracts / tokens per trade", - title="minimum_amount", - ) - option_details: Optional[OptionPublicDetailsSchema] = Field(...) - perp_details: Optional[PerpPublicDetailsSchema] = Field(...) - pro_rata_amount_step: Decimal = Field( - ..., - description="Pro-rata fill share of every order is rounded down to be a multiple of this number. Leftovers of the order due to rounding are filled FIFO.", - title="pro_rata_amount_step", - ) - pro_rata_fraction: Decimal = Field( - ..., - description="Fraction of order that gets filled using pro-rata matching. If zero, the matching is full FIFO.", - title="pro_rata_fraction", - ) - quote_currency: str = Field( - ..., - description="Quote currency (`USD` for perps, `USDC` for options)", - title="quote_currency", - ) - scheduled_activation: int = Field( - ..., - description="Timestamp at which became or will become active (if applicable)", - title="scheduled_activation", - ) - scheduled_deactivation: int = Field( - ..., - description="Scheduled deactivation time for instrument (if applicable)", - title="scheduled_deactivation", - ) - taker_fee_rate: Decimal = Field( - ..., - description="Percent of spot price fee rate for takers", - title="taker_fee_rate", - ) - tick_size: Decimal = Field( - ..., - description="Tick size of the instrument, i.e. minimum price increment", - title="tick_size", - ) - - -PublicGetTickerParamsSchema = PublicGetInstrumentParamsSchema - - -class OptionPricingSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - ask_iv: Decimal = Field(..., description="Implied volatility of the current best ask", title="ask_iv") - bid_iv: Decimal = Field(..., description="Implied volatility of the current best bid", title="bid_iv") - delta: Decimal = Field(..., description="Delta of the option", title="delta") - discount_factor: Decimal = Field( - ..., - description="Discount factor used to calculate option premium", - title="discount_factor", - ) - forward_price: Decimal = Field( - ..., - description="Forward price used to calculate option premium", - title="forward_price", - ) - gamma: Decimal = Field(..., description="Gamma of the option", title="gamma") - iv: Decimal = Field(..., description="Implied volatility of the option", title="iv") - mark_price: Decimal = Field(..., description="Mark price of the option", title="mark_price") - rho: Decimal = Field(..., description="Rho of the option", title="rho") - theta: Decimal = Field(..., description="Theta of the option", title="theta") - vega: Decimal = Field(..., description="Vega of the option", title="vega") - - -class AggregateTradingStatsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - contract_volume: Decimal = Field( - ..., - description="Number of contracts traded during last 24 hours", - title="contract_volume", - ) - high: Decimal = Field(..., description="Highest trade price during last 24h", title="high") - low: Decimal = Field(..., description="Lowest trade price during last 24h", title="low") - num_trades: Decimal = Field(..., description="Number of trades during last 24h ", title="num_trades") - open_interest: Decimal = Field(..., description="Current total open interest", title="open_interest") - percent_change: Decimal = Field( - ..., - description="24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price", - title="percent_change", - ) - usd_change: Decimal = Field(..., description="24-hour price change in USD.", title="usd_change") +@dataclass +class PrivateGetOpenOrdersParamsSchema(PrivateGetPositionsParamsSchema): + pass -class PublicGetVaultShareParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - from_timestamp_sec: int = Field(..., description="From timestamp in seconds", title="from_timestamp_sec") - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - to_timestamp_sec: int = Field(..., description="To timestamp in seconds", title="to_timestamp_sec") - vault_name: str = Field(..., description="Name of the vault", title="vault_name") +@dataclass +class PrivateGetOpenOrdersResultSchema: + orders: List[OrderResponseSchema] + subaccount_id: int -class VaultShareResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - base_value: Decimal = Field( - ..., - description="The value of the vault's token against the base currency. Ex: rswETHC vs rswETH", - title="base_value", - ) - block_number: int = Field(..., description="The Derive chain block number", title="block_number") - block_timestamp: int = Field( - ..., - description="Timestamp of the Derive chain block number", - title="block_timestamp", - ) - underlying_value: Optional[Decimal] = Field( - ..., - description="The value of the vault's token against the underlying currency. Ex: rswETHC vs ETH", - title="underlying_value", - ) - usd_value: Decimal = Field(..., description="The value of the vault's token against USD", title="usd_value") +@dataclass +class PrivateGetAccountParamsSchema(PrivateGetSubaccountsParamsSchema): + pass -PrivateGetCollateralsParamsSchema = PrivateGetPositionsParamsSchema +@dataclass +class AccountFeeInfoSchema: + base_fee_discount: Decimal + option_maker_fee: Optional[Decimal] + option_taker_fee: Optional[Decimal] + perp_maker_fee: Optional[Decimal] + perp_taker_fee: Optional[Decimal] + rfq_maker_discount: Decimal + rfq_taker_discount: Decimal + spot_maker_fee: Optional[Decimal] + spot_taker_fee: Optional[Decimal] + + +@dataclass +class PublicGetAllInstrumentsParamsSchema: + expired: bool + instrument_type: InstrumentType + currency: Optional[str] = None + page: int = 1 + page_size: int = 100 + + +@dataclass +class InstrumentPublicResponseSchema: + amount_step: Decimal + base_asset_address: str + base_asset_sub_id: str + base_currency: str + base_fee: Decimal + erc20_details: Optional[ERC20PublicDetailsSchema] + fifo_min_allocation: Decimal + instrument_name: str + instrument_type: InstrumentType + is_active: bool + maker_fee_rate: Decimal + maximum_amount: Decimal + minimum_amount: Decimal + option_details: Optional[OptionPublicDetailsSchema] + perp_details: Optional[PerpPublicDetailsSchema] + pro_rata_amount_step: Decimal + pro_rata_fraction: Decimal + quote_currency: str + scheduled_activation: int + scheduled_deactivation: int + taker_fee_rate: Decimal + tick_size: Decimal + mark_price_fee_rate_cap: Optional[Decimal] = None + + +@dataclass +class PublicGetTickerParamsSchema(PublicGetInstrumentParamsSchema): + pass -class CollateralResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Asset amount of given collateral", title="amount") - amount_step: Decimal = Field(..., description="Minimum amount step for the collateral", title="amount_step") - asset_name: str = Field(..., description="Asset name", title="asset_name") - asset_type: InstrumentType = Field( - ..., - description="Type of asset collateral (currently always `erc20`)", - title="asset_type", - ) - average_price: Decimal = Field( - ..., - description="Average price of the collateral, 0 for USDC.", - title="average_price", - ) - average_price_excl_fees: Decimal = Field( - ..., - description="Average price of whole position excluding fees", - title="average_price_excl_fees", - ) - creation_timestamp: int = Field( - ..., - description="Timestamp of when the position was opened (in ms since Unix epoch)", - title="creation_timestamp", - ) - cumulative_interest: Decimal = Field( - ..., - description="Cumulative interest earned on supplying collateral or paid for borrowing", - title="cumulative_interest", - ) - currency: str = Field( - ..., - description="Underlying currency of asset (`ETH`, `BTC`, etc)", - title="currency", - ) - delta: Decimal = Field(..., description="Asset delta w.r.t. the delta currency", title="delta") - delta_currency: str = Field( - ..., - description="Currency with respect to which delta is reported.For example, LRTs like WEETH have their delta reported in ETH", - title="delta_currency", - ) - initial_margin: Decimal = Field( - ..., - description="USD value of collateral that contributes to initial margin", - title="initial_margin", - ) - maintenance_margin: Decimal = Field( - ..., - description="USD value of collateral that contributes to maintenance margin", - title="maintenance_margin", - ) - mark_price: Decimal = Field(..., description="Current mark price of the asset", title="mark_price") - mark_value: Decimal = Field( - ..., - description="USD value of the collateral (amount * mark price)", - title="mark_value", - ) - open_orders_margin: Decimal = Field( - ..., - description="USD margin requirement for all open orders for this asset / instrument", - title="open_orders_margin", - ) - pending_interest: Decimal = Field( - ..., - description="Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes.", - title="pending_interest", - ) - realized_pnl: Decimal = Field( - ..., - description="Realized trading profit or loss of the collateral, 0 for USDC.", - title="realized_pnl", - ) - realized_pnl_excl_fees: Decimal = Field( - ..., - description="Realized trading profit or loss of the position excluding fees", - title="realized_pnl_excl_fees", - ) - total_fees: Decimal = Field( - ..., - description="Total fees paid for opening and changing the position", - title="total_fees", - ) - unrealized_pnl: Decimal = Field( - ..., - description="Unrealized trading profit or loss of the collateral, 0 for USDC.", - title="unrealized_pnl", - ) - unrealized_pnl_excl_fees: Decimal = Field( - ..., - description="Unrealized trading profit or loss of the position excluding fees", - title="unrealized_pnl_excl_fees", - ) +@dataclass +class OptionPricingSchema: + ask_iv: Decimal + bid_iv: Decimal + delta: Decimal + discount_factor: Decimal + forward_price: Decimal + gamma: Decimal + iv: Decimal + mark_price: Decimal + rho: Decimal + theta: Decimal + vega: Decimal + + +@dataclass +class AggregateTradingStatsSchema: + contract_volume: Decimal + high: Decimal + low: Decimal + num_trades: Decimal + open_interest: Decimal + percent_change: Decimal + usd_change: Decimal + + +@dataclass +class PublicGetVaultShareParamsSchema: + from_timestamp_sec: int + to_timestamp_sec: int + vault_name: str + page: int = 1 + page_size: int = 100 + + +@dataclass +class VaultShareResponseSchema: + base_value: Decimal + block_number: int + block_timestamp: int + underlying_value: Optional[Decimal] + usd_value: Decimal + + +@dataclass +class PrivateGetCollateralsParamsSchema(PrivateGetPositionsParamsSchema): + pass -class Scope(Enum): +@dataclass +class CollateralResponseSchema: + amount: Decimal + amount_step: Decimal + asset_name: str + asset_type: InstrumentType + average_price: Decimal + average_price_excl_fees: Decimal + creation_timestamp: int + cumulative_interest: Decimal + currency: str + delta: Decimal + delta_currency: str + initial_margin: Decimal + maintenance_margin: Decimal + mark_price: Decimal + mark_value: Decimal + open_orders_margin: Decimal + pending_interest: Decimal + realized_pnl: Decimal + realized_pnl_excl_fees: Decimal + total_fees: Decimal + unrealized_pnl: Decimal + unrealized_pnl_excl_fees: Decimal + + +class Scope(str, Enum): admin = "admin" account = "account" read_only = "read_only" -class PrivateRegisterScopedSessionKeyParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry_sec: int = Field(..., description="Expiry of the session key", title="expiry_sec") - ip_whitelist: Optional[List[str]] = Field( - None, - description="List of whitelisted IPs, if empty then any IP is allowed.", - title="ip_whitelist", - ) - label: Optional[str] = Field(None, description="User-defined session key label", title="label") - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - scope: Scope = Field( - "read_only", - description="Scope of the session key. Defaults to READ_ONLY level permissions. ", - title="scope", - ) - signed_raw_tx: Optional[str] = Field( - None, - description="A signed RLP encoded ETH transaction in form of a hex string (same as `w3.eth.account.sign_transaction(unsigned_tx, private_key).rawTransaction.hex()`) Must be included if the scope is ADMIN.", - title="signed_raw_tx", - ) - wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") - - -class PrivateRegisterScopedSessionKeyResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiry_sec: int = Field(..., description="Session key expiry timestamp in sec", title="expiry_sec") - ip_whitelist: Optional[List[str]] = Field( - ..., - description="List of whitelisted IPs, if empty then any IP is allowed.", - title="ip_whitelist", - ) - label: Optional[str] = Field(..., description="User-defined session key label", title="label") - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - scope: Scope = Field(..., description="Session key permission level scope", title="scope") - transaction_id: Optional[UUID] = Field( - ..., - description="ID to lookup status of transaction if signed_raw_tx is provided", - title="transaction_id", - ) +@dataclass +class PrivateRegisterScopedSessionKeyParamsSchema: + expiry_sec: int + public_session_key: str + wallet: str + ip_whitelist: Optional[List[str]] = None + label: Optional[str] = None + scope: Scope = Scope.read_only + signed_raw_tx: Optional[str] = None -class PrivateExpiredAndCancelledHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field(..., description="End Unix timestamp", title="end_timestamp") - expiry: int = Field( - ..., - description="Expiry of download link in seconds. Maximum of 604800.", - title="expiry", - ) - start_timestamp: int = Field(..., description="Start Unix timestamp", title="start_timestamp") - subaccount_id: int = Field(..., description="Subaccount to download data for", title="subaccount_id") - wallet: str = Field(..., description="Wallet to download data for", title="wallet") +@dataclass +class PrivateRegisterScopedSessionKeyResultSchema: + expiry_sec: int + ip_whitelist: Optional[List[str]] + label: Optional[str] + public_session_key: str + scope: Scope + transaction_id: Optional[str] -class PrivateExpiredAndCancelledHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - presigned_urls: List[str] = Field( - ..., - description="List of presigned URLs to the snapshots", - title="presigned_urls", - ) - +@dataclass +class PrivateExpiredAndCancelledHistoryParamsSchema: + end_timestamp: int + expiry: int + start_timestamp: int + subaccount_id: int + wallet: str -PrivateSessionKeysParamsSchema = PrivateGetSubaccountsParamsSchema +@dataclass +class PrivateExpiredAndCancelledHistoryResultSchema: + presigned_urls: List[str] -SessionKeyResponseSchema = PrivateEditSessionKeyResultSchema - -class PrivateGetMmpConfigParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: Optional[str] = Field( - None, - description="Currency to get the config for. If not provided, returns all configs for the subaccount", - title="currency", - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get the config", - title="subaccount_id", - ) - - -class MMPConfigResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency of this mmp config", title="currency") - is_frozen: bool = Field(..., description="Whether the subaccount is currently frozen", title="is_frozen") - mmp_amount_limit: Decimal = Field( - "0", - description="Maximum total order amount that can be traded within the mmp_interval across all instruments of the provided currency. The amounts are not netted, so a filled bid of 1 and a filled ask of 2 would count as 3.
Default: 0 (no limit)", - title="mmp_amount_limit", - ) - mmp_delta_limit: Decimal = Field( - "0", - description="Maximum total delta that can be traded within the mmp_interval across all instruments of the provided currency. This quantity is netted, so a filled order with +1 delta and a filled order with -2 delta would count as -1
Default: 0 (no limit)", - title="mmp_delta_limit", - ) - mmp_frozen_time: int = Field( - ..., - description="Time interval in ms setting how long the subaccount is frozen after an mmp trigger, if 0 then a manual reset would be required via private/reset_mmp", - title="mmp_frozen_time", - ) - mmp_interval: int = Field( - ..., - description="Time interval in ms over which the limits are monotored, if 0 then mmp is disabled", - title="mmp_interval", - ) - mmp_unfreeze_time: int = Field( - ..., - description="Timestamp in ms after which the subaccount will be unfrozen", - title="mmp_unfreeze_time", - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to set the config", - title="subaccount_id", - ) - - -PrivateOrderParamsSchema = PrivateOrderDebugParamsSchema - - -class PrivateOrderResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - order: OrderResponseSchema - trades: List[TradeResponseSchema] = Field(..., title="trades") - - -PrivateGetSubaccountParamsSchema = PrivateGetPositionsParamsSchema +@dataclass +class PrivateSessionKeysParamsSchema(PrivateGetSubaccountsParamsSchema): + pass -class PrivateGetSubaccountResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - collaterals: List[CollateralResponseSchema] = Field( - ..., - description="All collaterals that count towards margin of subaccount", - title="collaterals", - ) - collaterals_initial_margin: Decimal = Field( - ..., - description="Total initial margin credit contributed by collaterals", - title="collaterals_initial_margin", - ) - collaterals_maintenance_margin: Decimal = Field( - ..., - description="Total maintenance margin credit contributed by collaterals", - title="collaterals_maintenance_margin", - ) - collaterals_value: Decimal = Field( - ..., - description="Total mark-to-market value of all collaterals", - title="collaterals_value", - ) - currency: str = Field(..., description="Currency of subaccount", title="currency") - initial_margin: Decimal = Field( - ..., - description="Total initial margin requirement of all positions and collaterals.Trades will be rejected if this value falls below zero after the trade.", - title="initial_margin", - ) - is_under_liquidation: bool = Field( - ..., - description="Whether the subaccount is undergoing a liquidation auction", - title="is_under_liquidation", - ) - label: str = Field(..., description="User defined label", title="label") - maintenance_margin: Decimal = Field( - ..., - description="Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation.", - title="maintenance_margin", - ) - margin_type: MarginType = Field( - ..., - description="Margin type of subaccount (`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", - title="margin_type", - ) - open_orders: List[OrderResponseSchema] = Field( - ..., description="All open orders of subaccount", title="open_orders" - ) - open_orders_margin: Decimal = Field( - ..., - description="Total margin requirement of all open orders.Orders will be rejected if this value plus initial margin are below zero after the order.", - title="open_orders_margin", - ) - positions: List[PositionResponseSchema] = Field( - ..., description="All active positions of subaccount", title="positions" - ) - positions_initial_margin: Decimal = Field( - ..., - description="Total initial margin requirement of all positions", - title="positions_initial_margin", - ) - positions_maintenance_margin: Decimal = Field( - ..., - description="Total maintenance margin requirement of all positions", - title="positions_maintenance_margin", - ) - positions_value: Decimal = Field( - ..., - description="Total mark-to-market value of all positions", - title="positions_value", - ) - projected_margin_change: Decimal = Field( - ..., - description="Projected change in maintenance margin requirement between now and projected margin at 8:01 UTC. If this value plus current maintenance margin ise below zero, the account is at risk of being flagged for liquidation right after the upcoming expiry.", - title="projected_margin_change", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") - subaccount_value: Decimal = Field( - ..., - description="Total mark-to-market value of all positions and collaterals", - title="subaccount_value", - ) +@dataclass +class SessionKeyResponseSchema(PrivateEditSessionKeyResultSchema): + pass -class PublicGetInterestRateHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - from_timestamp_sec: int = Field(..., description="From timestamp in seconds", title="from_timestamp_sec") - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - to_timestamp_sec: int = Field(..., description="To timestamp in seconds", title="to_timestamp_sec") +@dataclass +class PrivateGetMmpConfigParamsSchema: + subaccount_id: int + currency: Optional[str] = None -class InterestRateHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - block: int = Field(..., description="Derive Chain block number", title="block") - borrow_apy: Decimal = Field(..., description="Borrow APY", title="borrow_apy") - supply_apy: Decimal = Field(..., description="Supply APY", title="supply_apy") - timestamp_sec: int = Field(..., description="Timestamp in seconds", title="timestamp_sec") - total_borrow: Decimal = Field(..., description="Total USDC borrowed", title="total_borrow") - total_supply: Decimal = Field(..., description="Total USDC supplied", title="total_supply") +@dataclass +class MMPConfigResultSchema: + currency: str + is_frozen: bool + mmp_frozen_time: int + mmp_interval: int + mmp_unfreeze_time: int + subaccount_id: int + mmp_amount_limit: Decimal = "0" + mmp_delta_limit: Decimal = "0" -class PrivateGetAllPortfoliosParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - wallet: str = Field(..., description="Wallet address", title="wallet") +@dataclass +class PrivateOrderParamsSchema(PrivateOrderDebugParamsSchema): + pass -class PrivateGetAllPortfoliosResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - id: Union[str, int] - result: List[PrivateGetSubaccountResultSchema] = Field(..., description="", title="result") +@dataclass +class PrivateOrderResultSchema: + order: OrderResponseSchema + trades: List[TradeResponseSchema] -class PublicGetLiquidationHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field( - 9223372036854776000, - description="End timestamp of the event history (default current time)", - title="end_timestamp", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - start_timestamp: int = Field( - 0, - description="Start timestamp of the event history (default 0)", - title="start_timestamp", - ) - subaccount_id: Optional[int] = Field(None, description="(Optional) Subaccount ID", title="subaccount_id") +@dataclass +class PrivateGetSubaccountParamsSchema(PrivateGetPositionsParamsSchema): + pass -class PublicDepositDebugParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount of the asset to deposit", title="amount") - asset_name: str = Field(..., description="Name of asset to deposit", title="asset_name") - is_atomic_signing: bool = Field( - False, - description="Used by vaults to determine whether the signature is an EIP-1271 signature", - title="is_atomic_signing", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the deposit", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateGetSubaccountResultSchema: + collaterals: List[CollateralResponseSchema] + collaterals_initial_margin: Decimal + collaterals_maintenance_margin: Decimal + collaterals_value: Decimal + currency: str + initial_margin: Decimal + is_under_liquidation: bool + label: str + maintenance_margin: Decimal + margin_type: MarginType + open_orders: List[OrderResponseSchema] + open_orders_margin: Decimal + positions: List[PositionResponseSchema] + positions_initial_margin: Decimal + positions_maintenance_margin: Decimal + positions_value: Decimal + projected_margin_change: Decimal + subaccount_id: int + subaccount_value: Decimal + + +@dataclass +class PublicGetInterestRateHistoryParamsSchema: + from_timestamp_sec: int + to_timestamp_sec: int + page: int = 1 + page_size: int = 100 + + +@dataclass +class InterestRateHistoryResponseSchema: + block: int + borrow_apy: Decimal + supply_apy: Decimal + timestamp_sec: int + total_borrow: Decimal + total_supply: Decimal + + +@dataclass +class PrivateGetAllPortfoliosParamsSchema(PrivateGetSubaccountsParamsSchema): + pass -PublicDepositDebugResultSchema = PublicCreateSubaccountDebugResultSchema +@dataclass +class PrivateGetAllPortfoliosResponseSchema: + id: Union[str, int] + result: List[PrivateGetSubaccountResultSchema] -class PublicGetVaultBalancesParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - smart_contract_owner: Optional[str] = Field( - None, - description="If wallet not provided, can query balances by EOA that owns smart contract wallet", - title="smart_contract_owner", - ) - wallet: Optional[str] = Field(None, description="Ethereum wallet address of smart contract", title="wallet") +@dataclass +class PublicGetLiquidationHistoryParamsSchema: + end_timestamp: int = 9223372036854776000 + page: int = 1 + page_size: int = 100 + start_timestamp: int = 0 + subaccount_id: Optional[int] = None -class VaultBalanceResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - address: str = Field(..., title="address") - amount: Decimal = Field(..., title="amount") - chain_id: int = Field(..., title="chain_id") - name: str = Field(..., title="name") - vault_asset_type: str = Field(..., title="vault_asset_type") +@dataclass +class PublicDepositDebugParamsSchema: + amount: Decimal + asset_name: str + nonce: int + signature_expiry_sec: int + signer: str + subaccount_id: int + is_atomic_signing: bool = False -class PublicGetReferralPerformanceParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_ms: int = Field(..., description="End timestamp in UTC milliseconds", title="end_ms") - referral_code: Optional[str] = Field(None, description="(Optional) referral code", title="referral_code") - start_ms: int = Field(..., description="Start timestamp in UTC milliseconds", title="start_ms") - wallet: Optional[str] = Field(None, description="(Optional) wallet of the referrer", title="wallet") +@dataclass +class PublicDepositDebugResultSchema(PublicCreateSubaccountDebugResultSchema): + pass -class ReferralPerformanceByInstrumentTypeSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - fee_reward: Decimal = Field(..., description="Fee reward to referrer", title="fee_reward") - notional_volume: Decimal = Field(..., description="Notional volume", title="notional_volume") - referred_fee: Decimal = Field(..., description="Fees paid by referred trader", title="referred_fee") +@dataclass +class PublicGetVaultBalancesParamsSchema: + smart_contract_owner: Optional[str] = None + wallet: Optional[str] = None -class PrivateSetCancelOnDisconnectParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - enabled: bool = Field( - ..., - description="Whether to enable or disable cancel on disconnect", - title="enabled", - ) - wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") +@dataclass +class VaultBalanceResponseSchema: + address: str + amount: Decimal + chain_id: int + name: str + vault_asset_type: str -class PrivateSetCancelOnDisconnectResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - id: Union[str, int] - result: Result = Field(..., description="", title="result") +@dataclass +class PublicGetReferralPerformanceParamsSchema: + end_ms: int + start_ms: int + referral_code: Optional[str] = None + wallet: Optional[str] = None -class PrivateCancelQuoteParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - quote_id: UUID = Field(..., description="Quote ID to cancel", title="quote_id") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class ReferralPerformanceByInstrumentTypeSchema: + fee_reward: Decimal + notional_volume: Decimal + referred_fee: Decimal -PrivateCancelQuoteResultSchema = QuoteResultSchema +@dataclass +class PrivateSetCancelOnDisconnectParamsSchema: + enabled: bool + wallet: str -class PrivateGetQuotesParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - from_timestamp: int = Field( - 0, - description="Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0.", - title="from_timestamp", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - quote_id: Optional[UUID] = Field(None, description="Quote ID filter, if applicable", title="quote_id") - rfq_id: Optional[UUID] = Field(None, description="RFQ ID filter, if applicable", title="rfq_id") - status: Optional[Status1] = Field(None, description="Quote status filter, if applicable", title="status") - subaccount_id: int = Field( - ..., - description="Subaccount ID for auth purposes, returned data will be scoped to this subaccount.", - title="subaccount_id", - ) - to_timestamp: int = Field( - 18446744073709552000, - description="Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", - title="to_timestamp", - ) +@dataclass +class PrivateSetCancelOnDisconnectResponseSchema(PrivateCancelRfqResponseSchema): + pass -class PrivateGetQuotesResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - pagination: PaginationInfoSchema - quotes: List[QuoteResultSchema] = Field(..., description="Quotes matching filter criteria", title="quotes") +@dataclass +class PrivateCancelQuoteParamsSchema: + quote_id: str + subaccount_id: int -class PublicExecuteQuoteDebugParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - direction: Direction = Field( - ..., - description="Quote direction, `buy` means trading each leg at its direction, `sell` means trading each leg in the opposite direction.", - title="direction", - ) - enable_taker_protection: bool = Field( - False, - description="Whether taker protection is enabled for the quote", - title="enable_taker_protection", - ) - label: str = Field("", description="Optional user-defined label for the quote", title="label") - legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") - max_fee: Decimal = Field( - ..., - description="Max fee ($ for the full trade). Request will be rejected if the supplied max fee is below the estimated fee for this trade.", - title="max_fee", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as a concatenated `UTC timestamp in ms` and `random number up to 6 digits` (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - quote_id: UUID = Field(..., description="Quote ID to execute against", title="quote_id") - rfq_id: UUID = Field( - ..., - description="RFQ ID to execute (must be sent by `subaccount_id`)", - title="rfq_id", - ) - signature: str = Field(..., description="Ethereum signature of the quote", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be at least 310 seconds from now. Once time till signature expiry reaches 300 seconds, the quote will be considered expired. This buffer is meant to ensure the trade can settle on chain in case of a blockchain congestion.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed the quote", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateCancelQuoteResultSchema(QuoteResultSchema): + pass -class PublicExecuteQuoteDebugResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - action_hash: str = Field(..., description="Keccak hashed action data", title="action_hash") - encoded_data: str = Field(..., description="ABI encoded deposit data", title="encoded_data") - encoded_data_hashed: str = Field(..., description="Keccak hashed encoded_data", title="encoded_data_hashed") - encoded_legs: str = Field(..., description="ABI encoded legs data", title="encoded_legs") - legs_hash: str = Field(..., description="Keccak hashed legs data", title="legs_hash") - typed_data_hash: str = Field(..., description="EIP 712 typed data hash", title="typed_data_hash") +@dataclass +class PrivateGetQuotesParamsSchema: + subaccount_id: int + from_timestamp: int = 0 + page: int = 1 + page_size: int = 100 + quote_id: Optional[str] = None + rfq_id: Optional[str] = None + status: Optional[Status1] = None + to_timestamp: int = 18446744073709552000 -class PrivateGetOptionSettlementHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_id: int = Field( - ..., - description="Subaccount ID for which to get expired option settlement history", - title="subaccount_id", - ) +@dataclass +class PrivateGetQuotesResultSchema: + pagination: PaginationInfoSchema + quotes: List[QuoteResultSchema] + + +@dataclass +class PublicExecuteQuoteDebugParamsSchema: + direction: Direction + legs: List[LegPricedSchema] + max_fee: Decimal + nonce: int + quote_id: str + rfq_id: str + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + enable_taker_protection: bool = False + label: str = "" + + +@dataclass +class PublicExecuteQuoteDebugResultSchema: + action_hash: str + encoded_data: str + encoded_data_hashed: str + encoded_legs: str + legs_hash: str + typed_data_hash: str + + +@dataclass +class PrivateGetOptionSettlementHistoryParamsSchema(PrivateGetPositionsParamsSchema): + pass -class OptionSettlementResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount that was settled", title="amount") - expiry: int = Field(..., description="Expiry timestamp of the option", title="expiry") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - option_settlement_pnl: Decimal = Field( - ..., - description="USD profit or loss from option settlements calculated as: settlement value - (average cost including fees x amount)", - title="option_settlement_pnl", - ) - option_settlement_pnl_excl_fees: Decimal = Field( - ..., - description="USD profit or loss from option settlements calculated as: settlement value - (average price excluding fees x amount)", - title="option_settlement_pnl_excl_fees", - ) - settlement_price: Decimal = Field(..., description="Price of option settlement", title="settlement_price") - subaccount_id: int = Field(..., description="Subaccount ID of the settlement event", title="subaccount_id") +@dataclass +class OptionSettlementResponseSchema: + amount: Decimal + expiry: int + instrument_name: str + option_settlement_pnl: Decimal + option_settlement_pnl_excl_fees: Decimal + settlement_price: Decimal + subaccount_id: int -class PrivateResetMmpParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: Optional[str] = Field( - None, - description="Currency to reset the mmp for. If not provided, resets all configs for the subaccount", - title="currency", - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to reset the mmp state", - title="subaccount_id", - ) +@dataclass +class PrivateResetMmpParamsSchema(PrivateGetMmpConfigParamsSchema): + pass -PrivateResetMmpResponseSchema = PrivateCancelRfqResponseSchema +@dataclass +class PrivateResetMmpResponseSchema(PrivateCancelRfqResponseSchema): + pass -PrivateGetErc20TransferHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema +@dataclass +class PrivateGetErc20TransferHistoryParamsSchema( + PrivateGetLiquidationHistoryParamsSchema +): + pass -class ERC20TransferSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount withdrawn by the subaccount", title="amount") - asset: str = Field(..., description="Asset withdrawn", title="asset") - counterparty_subaccount_id: int = Field( - ..., - description="Recipient or sender subaccount_id of transfer", - title="counterparty_subaccount_id", - ) - is_outgoing: bool = Field( - ..., - description="True if the transfer was initiated by the subaccount, False otherwise", - title="is_outgoing", - ) - timestamp: int = Field( - ..., - description="Timestamp of the transfer (in ms since UNIX epoch)", - title="timestamp", - ) - tx_hash: str = Field( - ..., - description="Hash of the transaction that withdrew the funds", - title="tx_hash", - ) +@dataclass +class ERC20TransferSchema: + amount: Decimal + asset: str + counterparty_subaccount_id: int + is_outgoing: bool + timestamp: int + tx_hash: str -PublicGetAllCurrenciesParamsSchema = PublicGetMakerProgramsParamsSchema +@dataclass +class PublicGetAllCurrenciesParamsSchema(PublicGetMakerProgramsParamsSchema): + pass -class CurrencyDetailedResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - asset_cap_and_supply_per_manager: Dict[str, Dict[str, List[OpenInterestStatsSchema]]] = Field( - ..., - description="Current open interest and open interest cap by manager and asset type", - title="asset_cap_and_supply_per_manager", - ) - borrow_apy: Decimal = Field(..., description="Borrow APY (only for USDC)", title="borrow_apy") - currency: str = Field( - ..., - description="Underlying currency of asset (`ETH`, `BTC`, etc)", - title="currency", - ) - erc20_details: Optional[Dict[str, Optional[str]]] = Field( - None, - description="Details of the erc20 asset (if applicable)", - title="erc20_details", - ) - instrument_types: List[InstrumentType] = Field( - ..., - description="Instrument types supported for the currency", - title="instrument_types", - ) - managers: List[ManagerContractResponseSchema] = Field( - ..., description="Managers supported for the currency", title="managers" - ) - market_type: MarketType = Field(..., description="Market type of the currency", title="market_type") - pm2_collateral_discounts: List[PM2CollateralDiscountsSchema] = Field( - ..., - description="Initial and Maintenance Margin discounts for given collateral in PM2", - title="pm2_collateral_discounts", - ) +@dataclass +class CurrencyDetailedResponseSchema: + asset_cap_and_supply_per_manager: Dict[ + str, Dict[str, List[OpenInterestStatsSchema]] + ] + borrow_apy: Decimal + currency: str + instrument_types: List[InstrumentType] + managers: List[ManagerContractResponseSchema] + market_type: MarketType + pm2_collateral_discounts: List[PM2CollateralDiscountsSchema] protocol_asset_addresses: ProtocolAssetAddressesSchema - spot_price: Decimal = Field(..., description="Spot price of the currency", title="spot_price") - spot_price_24h: Optional[Decimal] = Field( - None, - description="Spot price of the currency 24 hours ago", - title="spot_price_24h", - ) - srm_im_discount: Decimal = Field( - ..., - description="Initial Margin discount for given collateral in Standard Manager (e.g. LTV). Only the Standard Manager supports non-USDC collateral", - title="srm_im_discount", - ) - srm_mm_discount: Decimal = Field( - ..., - description="Maintenance Margin discount for given collateral in Standard Manager (e.g. liquidation threshold). Only the Standard Manager supports non-USDC collateral", - title="srm_mm_discount", - ) - supply_apy: Decimal = Field(..., description="Supply APY (only for USDC)", title="supply_apy") - total_borrow: Decimal = Field( - ..., - description="Total collateral borrowed in the protocol (only USDC is borrowable)", - title="total_borrow", - ) - total_supply: Decimal = Field( - ..., - description="Total collateral supplied in the protocol", - title="total_supply", - ) + spot_price: Decimal + srm_im_discount: Decimal + srm_mm_discount: Decimal + supply_apy: Decimal + total_borrow: Decimal + total_supply: Decimal + erc20_details: Optional[Dict[str, Optional[str]]] = None + spot_price_24h: Optional[Decimal] = None -class PrivateGetSubaccountValueHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field(..., description="End timestamp", title="end_timestamp") - period: int = Field(..., description="Period", title="period") - start_timestamp: int = Field(..., description="Start timestamp", title="start_timestamp") - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateGetSubaccountValueHistoryParamsSchema: + end_timestamp: int + period: int + start_timestamp: int + subaccount_id: int -class SubAccountValueHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_value: Decimal = Field( - ..., - description="Total mark-to-market value of all positions and collaterals", - title="subaccount_value", - ) - timestamp: int = Field( - ..., - description="Timestamp of when the subaccount value was recorded into the database", - title="timestamp", - ) +@dataclass +class SubAccountValueHistoryResponseSchema: + subaccount_value: Decimal + timestamp: int -PublicSendQuoteDebugParamsSchema = PrivateSendQuoteParamsSchema +@dataclass +class PublicSendQuoteDebugParamsSchema(PrivateSendQuoteParamsSchema): + pass -PublicSendQuoteDebugResultSchema = PublicCreateSubaccountDebugResultSchema +@dataclass +class PublicSendQuoteDebugResultSchema(PublicCreateSubaccountDebugResultSchema): + pass -PublicGetLiveIncidentsParamsSchema = PublicGetMakerProgramsParamsSchema +@dataclass +class PublicGetLiveIncidentsParamsSchema(PublicGetMakerProgramsParamsSchema): + pass -class MonitorType(Enum): +class MonitorType(str, Enum): manual = "manual" auto = "auto" -class Severity(Enum): +class Severity(str, Enum): low = "low" medium = "medium" high = "high" -class IncidentResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - creation_timestamp_sec: int = Field( - ..., - description="Timestamp of incident in UTC sec", - title="creation_timestamp_sec", - ) - label: str = Field(..., description="Incident label", title="label") - message: str = Field(..., description="Incident message", title="message") - monitor_type: MonitorType = Field(..., description="Incident trigger type", title="monitor_type") - severity: Severity = Field(..., description="Incident severity", title="severity") - - -class PublicGetTransactionParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - transaction_id: UUID = Field( - ..., - description="transaction_id of the transaction to get", - title="transaction_id", - ) +@dataclass +class IncidentResponseSchema: + creation_timestamp_sec: int + label: str + message: str + monitor_type: MonitorType + severity: Severity -class PublicGetTransactionResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - data: str = Field(..., description="Data used to create transaction", title="data") - error_log: Optional[str] = Field(..., description="Error log if failed tx", title="error_log") - status: TxStatus = Field(..., description="Status of the transaction", title="status") - transaction_hash: Optional[str] = Field( - ..., description="Transaction hash of a pending tx", title="transaction_hash" - ) +@dataclass +class PublicGetTransactionParamsSchema: + transaction_id: str -class PrivateGetOrdersParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instrument_name: Optional[str] = Field(None, description="Filter by instrument name", title="instrument_name") - label: Optional[str] = Field(None, description="Filter by label", title="label") - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - status: Optional[OrderStatus] = Field(None, description="Filter by order status", title="status") - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get open orders", - title="subaccount_id", - ) +@dataclass +class PublicGetTransactionResultSchema: + data: str + error_log: Optional[str] + status: TxStatus + transaction_hash: Optional[str] -PrivateGetOrdersResultSchema = PrivateGetOrderHistoryResultSchema +@dataclass +class PrivateGetOrdersParamsSchema: + subaccount_id: int + instrument_name: Optional[str] = None + label: Optional[str] = None + page: int = 1 + page_size: int = 100 + status: Optional[OrderStatus] = None -PrivateGetInterestHistoryParamsSchema = PrivateGetLiquidationHistoryParamsSchema +@dataclass +class PrivateGetOrdersResultSchema(PrivateGetOrderHistoryResultSchema): + pass -class InterestPaymentSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - interest: Decimal = Field( - ..., - description="Dollar interest paid (if negative) or received (if positive) by the subaccount", - title="interest", - ) - timestamp: int = Field( - ..., - description="Timestamp of the interest payment (in ms since UNIX epoch)", - title="timestamp", - ) +@dataclass +class PrivateGetInterestHistoryParamsSchema(PrivateGetLiquidationHistoryParamsSchema): + pass -PrivatePollQuotesParamsSchema = PrivateGetQuotesParamsSchema +@dataclass +class InterestPaymentSchema: + interest: Decimal + timestamp: int -class QuoteResultPublicSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancel_reason: CancelReason1 = Field(..., description="Cancel reason, if any", title="cancel_reason") - creation_timestamp: int = Field( - ..., - description="Creation timestamp in ms since Unix epoch", - title="creation_timestamp", - ) - direction: Direction = Field(..., description="Quote direction", title="direction") - fill_pct: Decimal = Field( - ..., - description="Percentage of the RFQ that this quote would fill, from 0 to 1.", - title="fill_pct", - ) - last_update_timestamp: int = Field( - ..., - description="Last update timestamp in ms since Unix epoch", - title="last_update_timestamp", - ) - legs: List[LegPricedSchema] = Field(..., description="Quote legs", title="legs") - legs_hash: str = Field( - ..., - description="Hash of the legs of the best quote to be signed by the taker.", - title="legs_hash", - ) - liquidity_role: LiquidityRole = Field(..., description="Liquidity role", title="liquidity_role") - quote_id: UUID = Field(..., description="Quote ID", title="quote_id") - rfq_id: UUID = Field(..., description="RFQ ID", title="rfq_id") - status: Status1 = Field(..., description="Status", title="status") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - tx_hash: Optional[str] = Field( - ..., - description="Blockchain transaction hash (only for executed quotes)", - title="tx_hash", - ) - tx_status: Optional[TxStatus] = Field( - ..., - description="Blockchain transaction status (only for executed quotes)", - title="tx_status", - ) - wallet: str = Field(..., description="Wallet address of the quote sender", title="wallet") +@dataclass +class PrivatePollQuotesParamsSchema(PrivateGetQuotesParamsSchema): + pass -class PrivateGetOrderParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - order_id: str = Field(..., description="Order ID", title="order_id") - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class QuoteResultPublicSchema: + cancel_reason: CancelReason1 + creation_timestamp: int + direction: Direction + fill_pct: Decimal + last_update_timestamp: int + legs: List[LegPricedSchema] + legs_hash: str + liquidity_role: LiquidityRole + quote_id: str + rfq_id: str + status: Status1 + subaccount_id: int + tx_hash: Optional[str] + tx_status: Optional[TxStatus] + wallet: str + + +@dataclass +class PrivateGetOrderParamsSchema(PrivateCancelTriggerOrderParamsSchema): + pass -PrivateGetOrderResultSchema = OrderResponseSchema +@dataclass +class PrivateGetOrderResultSchema(OrderResponseSchema): + pass -PublicGetVaultStatisticsParamsSchema = PublicGetMakerProgramsParamsSchema +@dataclass +class PublicGetVaultStatisticsParamsSchema(PublicGetMakerProgramsParamsSchema): + pass -class VaultStatisticsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - base_value: Decimal = Field( - ..., - description="The value of the vault's token against the base currency. Ex: rswETHC vs rswETH", - title="base_value", - ) - block_number: int = Field(..., description="The Derive chain block number", title="block_number") - block_timestamp: int = Field( - ..., - description="Timestamp of the Derive chain block number", - title="block_timestamp", - ) - subaccount_value_at_last_trade: Optional[Decimal] = Field( - ..., - description="Will return None before vault creates subaccount or if no trades found.", - title="subaccount_value_at_last_trade", - ) - total_supply: Decimal = Field( - ..., - description="Total supply of the vault's token on Derive chain", - title="total_supply", - ) - underlying_value: Optional[Decimal] = Field( - ..., - description="The value of the vault's token against the underlying currency. Ex: rswETHC vs ETH", - title="underlying_value", - ) - usd_tvl: Decimal = Field(..., description="Total USD TVL of the vault", title="usd_tvl") - usd_value: Decimal = Field(..., description="The value of the vault's token against USD", title="usd_value") - vault_name: str = Field(..., description="Name of the vault", title="vault_name") +@dataclass +class VaultStatisticsResponseSchema: + base_value: Decimal + block_number: int + block_timestamp: int + subaccount_value_at_last_trade: Optional[Decimal] + total_supply: Decimal + underlying_value: Optional[Decimal] + usd_tvl: Decimal + usd_value: Decimal + vault_name: str -class PublicWithdrawDebugParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount of the asset to withdraw", title="amount") - asset_name: str = Field(..., description="Name of asset to withdraw", title="asset_name") - is_atomic_signing: bool = Field( - False, - description="Used by vaults to determine whether the signature is an EIP-1271 signature", - title="is_atomic_signing", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the withdraw", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PublicWithdrawDebugParamsSchema(PublicDepositDebugParamsSchema): + pass -PublicWithdrawDebugResultSchema = PublicCreateSubaccountDebugResultSchema +@dataclass +class PublicWithdrawDebugResultSchema(PublicCreateSubaccountDebugResultSchema): + pass -class Period1(Enum): +class Period1(str, Enum): field_900 = 900 field_3600 = 3600 field_14400 = 14400 @@ -3704,84 +1791,34 @@ class Period1(Enum): field_86400 = 86400 -class PublicGetFundingRateHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - end_timestamp: int = Field( - 9223372036854776000, - description="End timestamp of the event history (default current time)", - title="end_timestamp", - ) - instrument_name: str = Field( - ..., - description="Instrument name to return funding history for", - title="instrument_name", - ) - period: Period1 = Field(3600, description="Period of the funding rate", title="period") - start_timestamp: int = Field( - 0, - description="Start timestamp of the event history (default 0)", - title="start_timestamp", - ) +@dataclass +class PublicGetFundingRateHistoryParamsSchema: + instrument_name: str + end_timestamp: int = 9223372036854776000 + period: Period1 = Period1.field_3600 + start_timestamp: int = 0 -class FundingRateSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - funding_rate: Decimal = Field( - ..., - description="Hourly funding rate value at the event time", - title="funding_rate", - ) - timestamp: int = Field( - ..., - description="Timestamp of the funding rate update (in ms since UNIX epoch)", - title="timestamp", - ) +@dataclass +class FundingRateSchema: + funding_rate: Decimal + timestamp: int -class PrivateRfqGetBestQuoteParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - counterparties: Optional[List[str]] = Field( - None, - description="Optional list of market maker account addresses to request quotes from. If not supplied, all market makers who are approved as RFQ makers will be notified.", - title="counterparties", - ) - direction: Direction = Field( - "buy", - description="Planned execution direction (default `buy`)", - title="direction", - ) - label: str = Field("", description="Optional user-defined label for the RFQ", title="label") - legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") - max_total_cost: Optional[Decimal] = Field( - None, - description="An optional max total cost for the RFQ. Only used when the RFQ sender executes as buyer. Polling endpoints and channels will ignore quotes where the total cost across all legs is above this value. Positive values mean the RFQ sender expects to pay $, negative mean the RFQ sender expects to receive $.This field is not disclosed to the market makers.", - title="max_total_cost", - ) - min_total_cost: Optional[Decimal] = Field( - None, - description="An optional min total cost for the RFQ. Only used when the RFQ sender executes as seller. Polling endpoints and channels will ignore quotes where the total cost across all legs is below this value. Positive values mean the RFQ sender expects to receive $, negative mean the RFQ sender expects to pay $.This field is not disclosed to the market makers.", - title="min_total_cost", - ) - partial_fill_step: Decimal = Field( - "1", - description="Optional step size for partial fills. If not supplied, the RFQ will not support partial fills.", - title="partial_fill_step", - ) - rfq_id: Optional[UUID] = Field( - None, - description="RFQ ID to get best quote for. If not provided, will return estimates based on mark prices", - title="rfq_id", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateRfqGetBestQuoteParamsSchema: + legs: List[LegUnpricedSchema] + subaccount_id: int + counterparties: Optional[List[str]] = None + direction: Direction = Direction.buy + label: str = "" + max_total_cost: Optional[Decimal] = None + min_total_cost: Optional[Decimal] = None + partial_fill_step: Decimal = "1" + rfq_id: Optional[str] = None -class InvalidReason(Enum): +class InvalidReason(str, Enum): Account_is_currently_under_maintenance_margin_requirements__trading_is_frozen_ = ( "Account is currently under maintenance margin requirements, trading is frozen." ) @@ -3794,2086 +1831,1140 @@ class InvalidReason(Enum): Insufficient_buying_power__consider_reducing_order_size_ = ( "Insufficient buying power, consider reducing order size." ) - Insufficient_buying_power__consider_reducing_order_size_or_canceling_other_orders_ = ( - "Insufficient buying power, consider reducing order size or canceling other orders." - ) + Insufficient_buying_power__consider_reducing_order_size_or_canceling_other_orders_ = "Insufficient buying power, consider reducing order size or canceling other orders." Consider_canceling_other_limit_orders_or_using_IOC__FOK__or_market_orders__This_order_is_risk_reducing__but_if_filled_with_other_open_orders__buying_power_might_be_insufficient_ = "Consider canceling other limit orders or using IOC, FOK, or market orders. This order is risk-reducing, but if filled with other open orders, buying power might be insufficient." Insufficient_buying_power_ = "Insufficient buying power." -class PrivateRfqGetBestQuoteResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - best_quote: Optional[QuoteResultPublicSchema] = Field(...) - direction: Direction = Field(..., description="RFQ direction.", title="direction") - down_liquidation_price: Optional[Decimal] = Field( - ..., - description="Liquidation price if the trade were to be filled and the market moves down.", - title="down_liquidation_price", - ) - estimated_fee: Decimal = Field( - ..., - description="An estimate for how much the user will pay in fees ($ for the whole trade).", - title="estimated_fee", - ) - estimated_realized_pnl: Decimal = Field( - ..., - description="An estimate for the realized PnL of the trade.", - title="estimated_realized_pnl", - ) - estimated_realized_pnl_excl_fees: Decimal = Field( - ..., - description="An estimate for the realized PnL of the trade. with cost basis calculated without considering fees.", - title="estimated_realized_pnl_excl_fees", - ) - estimated_total_cost: Decimal = Field( - ..., - description="An estimate for the total $ cost of the trade.", - title="estimated_total_cost", - ) - filled_pct: Decimal = Field( - ..., - description="Percentage of the RFQ that has already been filled, from 0 to 1.", - title="filled_pct", - ) - invalid_reason: Optional[InvalidReason] = Field( - ..., - description="Reason for the RFQ being invalid, if any.", - title="invalid_reason", - ) - is_valid: bool = Field( - ..., - description="`True` if RFQ is expected to pass margin requirements.", - title="is_valid", - ) - orderbook_total_cost: Optional[Decimal] = Field( - ..., - description="Total cost of the RFQ if it were to be filled at current orderbook prices (same direction as the RFQ). If lower than `estimated_total_cost`, the user may want to use the orderbook instead of RFQs for this order. Will return null if any of the legs do not have orderbook data or enough liquidity for the full fill.", - title="orderbook_total_cost", - ) - post_initial_margin: Decimal = Field( - ..., - description="User's hypothetical margin balance if the trade were to get executed.", - title="post_initial_margin", - ) - post_liquidation_price: Optional[Decimal] = Field( - ..., - description="Liquidation price if the trade were to be filled. If both upside and downside liquidation prices exist, returns the closest one to the current index price.", - title="post_liquidation_price", - ) - pre_initial_margin: Decimal = Field( - ..., - description="User's initial margin balance before the trade.", - title="pre_initial_margin", - ) - suggested_max_fee: Decimal = Field( - ..., - description="Recommended value for `max_fee` of the trade.", - title="suggested_max_fee", - ) - up_liquidation_price: Optional[Decimal] = Field( - ..., - description="Liquidation price if the trade were to be filled and the market moves up.", - title="up_liquidation_price", - ) +@dataclass +class PrivateRfqGetBestQuoteResultSchema: + best_quote: Optional[QuoteResultPublicSchema] + direction: Direction + down_liquidation_price: Optional[Decimal] + estimated_fee: Decimal + estimated_realized_pnl: Decimal + estimated_realized_pnl_excl_fees: Decimal + estimated_total_cost: Decimal + filled_pct: Decimal + invalid_reason: Optional[InvalidReason] + is_valid: bool + orderbook_total_cost: Optional[Decimal] + post_initial_margin: Decimal + post_liquidation_price: Optional[Decimal] + pre_initial_margin: Decimal + suggested_max_fee: Decimal + up_liquidation_price: Optional[Decimal] -class PublicGetInstrumentsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field( - ..., - description="Underlying currency of asset (`ETH`, `BTC`, etc)", - title="currency", - ) - expired: bool = Field( - ..., - description="If `True`: include expired assets. Note: will soon be capped up to only 1 week in the past.", - title="expired", - ) - instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") +@dataclass +class PublicGetInstrumentsParamsSchema: + currency: str + expired: bool + instrument_type: InstrumentType -class PublicGetInstrumentsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetInstrumentsResponseSchema: id: Union[str, int] - result: List[InstrumentPublicResponseSchema] = Field(..., description="", title="result") + result: List[InstrumentPublicResponseSchema] -class PublicGetOptionSettlementHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - subaccount_id: Optional[int] = Field( - None, - description="Subaccount ID filter (defaults to all if not provided)", - title="subaccount_id", - ) +@dataclass +class PublicGetOptionSettlementHistoryParamsSchema: + page: int = 1 + page_size: int = 100 + subaccount_id: Optional[int] = None -class PublicGetOptionSettlementHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetOptionSettlementHistoryResultSchema: pagination: PaginationInfoSchema - settlements: List[OptionSettlementResponseSchema] = Field( - ..., description="List of expired option settlements", title="settlements" - ) - - -class PrivateLiquidateParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cash_transfer: Decimal = Field( - ..., - description="Amount of cash to transfer to a newly created subaccount for bidding. Must be non-negative.", - title="cash_transfer", - ) - last_seen_trade_id: int = Field( - ..., - description="Last seen trade ID for account being liquidated. Not checked if set to 0.", - title="last_seen_trade_id", - ) - liquidated_subaccount_id: int = Field( - ..., - description="Subaccount ID of the account to be liquidated.", - title="liquidated_subaccount_id", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - percent_bid: Decimal = Field( - ..., - description="Percent of the liquidated position to bid for. Will bid for the maximum possible percent of the position if set to 1", - title="percent_bid", - ) - price_limit: Decimal = Field( - ..., - description="Maximum amount of cash to be paid from bidder to liquidated account (supports negative amounts for insolvent auctions). Not checked if set to 0.", - title="price_limit", - ) - signature: str = Field(..., description="Ethereum signature of the order", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed order", - title="signer", - ) - subaccount_id: int = Field( - ..., - description="Subaccount ID owned by wallet, that will be doing the bidding.", - title="subaccount_id", - ) - - -class PrivateLiquidateResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - estimated_bid_price: Decimal = Field( - ..., - description="Estimated bid price for this liquidation", - title="estimated_bid_price", - ) - estimated_discount_pnl: Decimal = Field( - ..., - description="Estimated profit (increase in the subaccount mark value) if the liquidation is successful.", - title="estimated_discount_pnl", - ) - estimated_percent_bid: Decimal = Field( - ..., - description="Estimated percent of account the bid will aquire", - title="estimated_percent_bid", - ) - transaction_id: UUID = Field( - ..., - description="The transaction id of the related settlement transaction", - title="transaction_id", - ) - - -class PrivateGetTradeHistoryParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - from_timestamp: int = Field( - 0, - description="Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0.", - title="from_timestamp", - ) - instrument_name: Optional[str] = Field(None, description="Instrument name to filter by", title="instrument_name") - order_id: Optional[str] = Field(None, description="Order id to filter by", title="order_id") - page: int = Field( - 1, - description="Page number of results to return (default 1, returns last if above `num_pages`)", - title="page", - ) - page_size: int = Field( - 100, - description="Number of results per page (default 100, max 1000)", - title="page_size", - ) - quote_id: Optional[str] = Field( - None, - description="If supplied, quote id to filter by. Supports either a concrete UUID, or `is_quote` and `is_not_quote` enum", - title="quote_id", - ) - subaccount_id: Optional[int] = Field( - None, - description="Subaccount_id (must be set if wallet is blank)", - title="subaccount_id", - ) - to_timestamp: int = Field( - 18446744073709552000, - description="Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time.", - title="to_timestamp", - ) - wallet: Optional[str] = Field( - None, - description="Wallet address (if set, subaccount_id ignored)", - title="wallet", - ) - - -class PrivateGetTradeHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) + settlements: List[OptionSettlementResponseSchema] + + +@dataclass +class PrivateLiquidateParamsSchema: + cash_transfer: Decimal + last_seen_trade_id: int + liquidated_subaccount_id: int + nonce: int + percent_bid: Decimal + price_limit: Decimal + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + + +@dataclass +class PrivateLiquidateResultSchema: + estimated_bid_price: Decimal + estimated_discount_pnl: Decimal + estimated_percent_bid: Decimal + transaction_id: str + + +@dataclass +class PrivateGetTradeHistoryParamsSchema: + from_timestamp: int = 0 + instrument_name: Optional[str] = None + order_id: Optional[str] = None + page: int = 1 + page_size: int = 100 + quote_id: Optional[str] = None + subaccount_id: Optional[int] = None + to_timestamp: int = 18446744073709552000 + wallet: Optional[str] = None + + +@dataclass +class PrivateGetTradeHistoryResultSchema: pagination: PaginationInfoSchema - subaccount_id: int = Field( - ..., - description="Subaccount ID requested, or 0 if not provided", - title="subaccount_id", - ) - trades: List[TradeResponseSchema] = Field(..., description="List of trades", title="trades") - - -class PublicGetLatestSignedFeedsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: Optional[str] = Field( - None, - description="Currency filter, (defaults to all currencies)", - title="currency", - ) - expiry: Optional[int] = Field( - None, - description="Expiry filter for options and forward data (defaults to all expiries). Use `0` to get data only for spot and perpetuals", - title="expiry", - ) - - -class OracleSignatureDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - signatures: Optional[List[str]] = Field(None, description="The signatures of the given signers", title="signatures") - signers: Optional[List[str]] = Field(None, description="The signers who verify the data integrity", title="signers") - - -class Type(Enum): - P = "P" - A = "A" - B = "B" - - -class PerpFeedDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") - currency: str = Field( - ..., - description="The currency for which the spot feed represents", - title="currency", - ) - deadline: int = Field( - ..., - description="The latest time the data can be submitted on chain", - title="deadline", - ) - signatures: OracleSignatureDataSchema - spot_diff_value: Decimal = Field( - ..., - description="The difference between the spot price and the perp price", - title="spot_diff_value", - ) - timestamp: int = Field( - ..., - description="The timestamp for which the data was created", - title="timestamp", - ) - type: Type = Field( - ..., - description="The type of perp feed; mid price, ask impact or bid impact", - title="type", - ) - - -class RateFeedDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - confidence: Decimal = Field(..., description="The confidence score of the rate", title="confidence") - currency: str = Field( - ..., - description="The currency for which the spot feed represents", - title="currency", - ) - deadline: int = Field( - ..., - description="The latest time the data can be submitted on chain", - title="deadline", - ) - expiry: int = Field(..., description="The expiry for the rate feed", title="expiry") - rate: Decimal = Field(..., description="The implied rate for the currency/expiry", title="rate") - signatures: OracleSignatureDataSchema - timestamp: int = Field( - ..., - description="The timestamp for which the data was created", - title="timestamp", - ) - - -class FeedSourceType(Enum): - S = "S" - O = "O" + subaccount_id: int + trades: List[TradeResponseSchema] -class SpotFeedDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") - currency: str = Field( - ..., - description="The currency for which the spot feed represents", - title="currency", - ) - deadline: int = Field( - ..., - description="The latest time the data can be submitted on chain", - title="deadline", - ) - feed_source_type: FeedSourceType = Field("S", description="The source of the feed", title="feed_source_type") - price: Decimal = Field(..., description="The price of the currency in USD", title="price") - signatures: OracleSignatureDataSchema - timestamp: int = Field( - ..., - description="The timestamp for which the data was created", - title="timestamp", - ) +@dataclass +class PublicGetLatestSignedFeedsParamsSchema: + currency: Optional[str] = None + expiry: Optional[int] = None -class VolSVIParamDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - SVI_a: Decimal = Field(..., title="SVI_a") - SVI_b: Decimal = Field(..., title="SVI_b") - SVI_fwd: Decimal = Field(..., title="SVI_fwd") - SVI_m: Decimal = Field(..., title="SVI_m") - SVI_refTau: Decimal = Field(..., title="SVI_refTau") - SVI_rho: Decimal = Field(..., title="SVI_rho") - SVI_sigma: Decimal = Field(..., title="SVI_sigma") - - -class PrivateReplaceParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Order amount in units of the base", title="amount") - direction: Direction = Field(..., description="Order direction", title="direction") - expected_filled_amount: Optional[Decimal] = Field( - None, - description="Optional check to only create new order if old order filled_amount is equal to this value.", - title="expected_filled_amount", - ) - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - is_atomic_signing: Optional[bool] = Field( - False, - description="Used by vaults to determine whether the signature is an EIP-1271 signature.", - title="is_atomic_signing", - ) - label: str = Field("", description="Optional user-defined label for the order", title="label") - limit_price: Decimal = Field( - ..., - description="Limit price in quote currency.
This field is still required for market orders because it is a component of the signature. However, market orders will not leave a resting order in the book in case of a partial fill.", - title="limit_price", - ) - max_fee: Decimal = Field( - ..., - description="Max fee per unit of volume, denominated in units of the quote currency (usually USDC).Order will be rejected if the supplied max fee is below the estimated fee for this order.", - title="max_fee", - ) - mmp: bool = Field( - False, - description="Whether the order is tagged for market maker protections (default false)", - title="mmp", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number).Note, using a random number beyond 3 digits will cause JSON serialization to fail.", - title="nonce", - ) - nonce_to_cancel: Optional[int] = Field( - None, - description="Cancel order by nonce (choose either order_id or nonce).", - title="nonce_to_cancel", - ) - order_id_to_cancel: Optional[UUID] = Field( - None, - description="Cancel order by order_id (choose either order_id or nonce).", - title="order_id_to_cancel", - ) - order_type: OrderType = Field( - "limit", - description="Order type:
- `limit`: limit order (default)
- `market`: market order, note that limit_price is still required for market orders, but unfilled order portion will be marked as cancelled", - title="order_type", - ) - reduce_only: bool = Field( - False, - description="If true, the order will not be able to increase position's size (default false). If the order amount exceeds available position size, the order will be filled up to the position size and the remainder will be cancelled. This flag is only supported for market orders or non-resting limit orders (IOC or FOK)", - title="reduce_only", - ) - referral_code: str = Field("", description="Optional referral code for the order", title="referral_code") - reject_timestamp: int = Field( - 9223372036854776000, - description="UTC timestamp in ms, if provided the matching engine will reject the order with an error if `reject_timestamp` < `server_time`. Note that the timestamp must be consistent with the server time: use `public/get_time` method to obtain current server time.", - title="reject_timestamp", - ) - signature: str = Field(..., description="Ethereum signature of the order", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Order signature becomes invalid after this time, and the system will cancel the order.Expiry MUST be at least 5 min from now.", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Owner wallet address or registered session key that signed order", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") - time_in_force: TimeInForce = Field( - "gtc", - description="Time in force behaviour:
- `gtc`: good til cancelled (default)
- `post_only`: a limit order that will be rejected if it crosses any order in the book, i.e. acts as a taker order
- `fok`: fill or kill, will be rejected if it is not fully filled
- `ioc`: immediate or cancel, fill at best bid/ask (market) or at limit price (limit), the unfilled portion is cancelled
Note that the order will still expire on the `signature_expiry_sec` timestamp.", - title="time_in_force", - ) - trigger_price: Optional[Decimal] = Field( - None, - description='(Required for trigger orders) "index" or "mark" price to trigger order at', - title="trigger_price", - ) - trigger_price_type: Optional[TriggerPriceType] = Field( - None, - description='(Required for trigger orders) Trigger with "mark" price as "index" price type not supported yet.', - title="trigger_price_type", - ) - trigger_type: Optional[TriggerType] = Field( - None, - description='(Required for trigger orders) "stoploss" or "takeprofit"', - title="trigger_type", - ) +@dataclass +class OracleSignatureDataSchema: + signatures: Optional[List[str]] = None + signers: Optional[List[str]] = None -class RPCErrorFormatSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - code: int = Field(..., title="code") - data: Optional[str] = Field(None, title="data") - message: str = Field(..., title="message") +class Type(str, Enum): + P = "P" + A = "A" + B = "B" -class PrivateCancelByInstrumentParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instrument_name: str = Field( - ..., - description="Cancel all orders for this instrument", - title="instrument_name", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PerpFeedDataSchema: + confidence: Decimal + currency: str + deadline: int + signatures: OracleSignatureDataSchema + spot_diff_value: Decimal + timestamp: int + type: Type + + +@dataclass +class RateFeedDataSchema: + confidence: Decimal + currency: str + deadline: int + expiry: int + rate: Decimal + signatures: OracleSignatureDataSchema + timestamp: int -PrivateCancelByInstrumentResultSchema = PrivateCancelByNonceResultSchema +class FeedSourceType(str, Enum): + S = "S" + O = "O" -class PrivateCancelAllParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_id: int = Field(..., title="subaccount_id") +@dataclass +class SpotFeedDataSchema: + confidence: Decimal + currency: str + deadline: int + price: Decimal + signatures: OracleSignatureDataSchema + timestamp: int + feed_source_type: FeedSourceType = FeedSourceType.S + + +@dataclass +class VolSVIParamDataSchema: + SVI_a: Decimal + SVI_b: Decimal + SVI_fwd: Decimal + SVI_m: Decimal + SVI_refTau: Decimal + SVI_rho: Decimal + SVI_sigma: Decimal + + +@dataclass +class PrivateReplaceParamsSchema: + amount: Decimal + direction: Direction + instrument_name: str + limit_price: Decimal + max_fee: Decimal + nonce: int + signature: str + signature_expiry_sec: int + signer: str + subaccount_id: int + expected_filled_amount: Optional[Decimal] = None + is_atomic_signing: Optional[bool] = False + label: str = "" + mmp: bool = False + nonce_to_cancel: Optional[int] = None + order_id_to_cancel: Optional[str] = None + order_type: OrderType = OrderType.limit + reduce_only: bool = False + referral_code: str = "" + reject_timestamp: int = 9223372036854776000 + time_in_force: TimeInForce = TimeInForce.gtc + trigger_price: Optional[Decimal] = None + trigger_price_type: Optional[TriggerPriceType] = None + trigger_type: Optional[TriggerType] = None + + +@dataclass +class RPCErrorFormatSchema: + code: int + message: str + data: Optional[str] = None + + +@dataclass +class PrivateCancelByInstrumentParamsSchema: + instrument_name: str + subaccount_id: int + + +@dataclass +class PrivateCancelByInstrumentResultSchema(PrivateCancelByNonceResultSchema): + pass -PrivateCancelAllResponseSchema = PrivateSetCancelOnDisconnectResponseSchema +@dataclass +class PrivateCancelAllParamsSchema(PrivateGetPositionsParamsSchema): + pass -class PublicDeregisterSessionKeyParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - signed_raw_tx: str = Field( - ..., - description="A signed RLP encoded ETH transaction in form of a hex string (same as `w3.eth.account.sign_transaction(unsigned_tx, private_key).rawTransaction.hex()`)", - title="signed_raw_tx", - ) - wallet: str = Field(..., description="Ethereum wallet address of account", title="wallet") +@dataclass +class PrivateCancelAllResponseSchema(PrivateCancelRfqResponseSchema): + pass -class PublicDeregisterSessionKeyResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - public_session_key: str = Field( - ..., - description="Session key in the form of an Ethereum EOA", - title="public_session_key", - ) - transaction_id: UUID = Field(..., description="ID to lookup status of transaction", title="transaction_id") +@dataclass +class PublicDeregisterSessionKeyParamsSchema: + public_session_key: str + signed_raw_tx: str + wallet: str -class PrivateWithdrawParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount: Decimal = Field(..., description="Amount of the asset to withdraw", title="amount") - asset_name: str = Field(..., description="Name of asset to withdraw", title="asset_name") - is_atomic_signing: bool = Field( - False, - description="Used by vaults to determine whether the signature is an EIP-1271 signature", - title="is_atomic_signing", - ) - nonce: int = Field( - ..., - description="Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)", - title="nonce", - ) - signature: str = Field(..., description="Ethereum signature of the withdraw", title="signature") - signature_expiry_sec: int = Field( - ..., - description="Unix timestamp in seconds. Expiry MUST be >5min from now", - title="signature_expiry_sec", - ) - signer: str = Field( - ..., - description="Ethereum wallet address that is signing the withdraw", - title="signer", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PublicDeregisterSessionKeyResultSchema: + public_session_key: str + transaction_id: str -class PrivateWithdrawResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - status: str = Field(..., description="`requested`", title="status") - transaction_id: UUID = Field(..., description="Transaction id of the withdrawal", title="transaction_id") +@dataclass +class PrivateWithdrawParamsSchema(PrivateDepositParamsSchema): + pass -class PrivateGetNotificationsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - notifications: List[NotificationResponseSchema] = Field( - ..., description="Notification response", title="notifications" - ) +@dataclass +class PrivateWithdrawResultSchema(PrivateCreateSubaccountResultSchema): + pass + + +@dataclass +class PrivateGetNotificationsResultSchema: + notifications: List[NotificationResponseSchema] pagination: PaginationInfoSchema -PublicGetCurrencyResultSchema = CurrencyDetailedResponseSchema +@dataclass +class PublicGetCurrencyResultSchema(CurrencyDetailedResponseSchema): + pass -class PrivateSetMmpConfigResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateSetMmpConfigResponseSchema: id: Union[str, int] result: PrivateSetMmpConfigResultSchema -class PrivateTransferPositionParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferPositionParamsSchema: maker_params: TradeModuleParamsSchema taker_params: TradeModuleParamsSchema - wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") + wallet: str -class PrivateTransferPositionResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferPositionResultSchema: maker_order: OrderResponseSchema maker_trade: TradeResponseSchema taker_order: OrderResponseSchema taker_trade: TradeResponseSchema -class PrivateCreateSubaccountResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCreateSubaccountResponseSchema: id: Union[str, int] result: PrivateCreateSubaccountResultSchema -class PrivateSendRfqParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - counterparties: Optional[List[str]] = Field( - None, - description="Optional list of market maker account addresses to request quotes from. If not supplied, all market makers who are approved as RFQ makers will be notified.", - title="counterparties", - ) - label: str = Field("", description="Optional user-defined label for the RFQ", title="label") - legs: List[LegUnpricedSchema] = Field(..., description="RFQ legs", title="legs") - max_total_cost: Optional[Decimal] = Field( - None, - description="An optional max total cost for the RFQ. Only used when the RFQ sender executes as buyer. Polling endpoints and channels will ignore quotes where the total cost across all legs is above this value. Positive values mean the RFQ sender expects to pay $, negative mean the RFQ sender expects to receive $.This field is not disclosed to the market makers.", - title="max_total_cost", - ) - min_total_cost: Optional[Decimal] = Field( - None, - description="An optional min total cost for the RFQ. Only used when the RFQ sender executes as seller. Polling endpoints and channels will ignore quotes where the total cost across all legs is below this value. Positive values mean the RFQ sender expects to receive $, negative mean the RFQ sender expects to pay $.This field is not disclosed to the market makers.", - title="min_total_cost", - ) - partial_fill_step: Decimal = Field( - "1", - description="Optional step size for partial fills. If not supplied, the RFQ will not support partial fills.", - title="partial_fill_step", - ) - subaccount_id: int = Field(..., description="Subaccount ID", title="subaccount_id") +@dataclass +class PrivateSendRfqParamsSchema: + legs: List[LegUnpricedSchema] + subaccount_id: int + counterparties: Optional[List[str]] = None + label: str = "" + max_total_cost: Optional[Decimal] = None + min_total_cost: Optional[Decimal] = None + partial_fill_step: Decimal = "1" -class PrivateSendRfqResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateSendRfqResponseSchema: id: Union[str, int] result: PrivateSendRfqResultSchema -class PublicMarginWatchResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - collaterals: List[CollateralPublicResponseSchema] = Field( - ..., - description="All collaterals that count towards margin of subaccount", - title="collaterals", - ) - currency: str = Field(..., description="Currency of subaccount", title="currency") - initial_margin: Decimal = Field( - ..., - description="Total initial margin requirement of all positions and collaterals.", - title="initial_margin", - ) - maintenance_margin: Decimal = Field( - ..., - description="Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation.", - title="maintenance_margin", - ) - margin_type: MarginType = Field( - ..., - description="Margin type of subaccount (`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", - title="margin_type", - ) - positions: List[PositionPublicResponseSchema] = Field( - ..., description="All active positions of subaccount", title="positions" - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") - subaccount_value: Decimal = Field( - ..., - description="Total mark-to-market value of all positions and collaterals", - title="subaccount_value", - ) - valuation_timestamp: int = Field( - ..., - description="Timestamp (in seconds since epoch) of when margin and MtM were computed.", - title="valuation_timestamp", - ) +@dataclass +class PublicMarginWatchResultSchema: + collaterals: List[CollateralPublicResponseSchema] + currency: str + initial_margin: Decimal + maintenance_margin: Decimal + margin_type: MarginType + positions: List[PositionPublicResponseSchema] + subaccount_id: int + subaccount_value: Decimal + valuation_timestamp: int -class PublicStatisticsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicStatisticsResponseSchema: id: Union[str, int] result: PublicStatisticsResultSchema -class PrivateCancelResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelResponseSchema: id: Union[str, int] result: PrivateCancelResultSchema -PrivateExecuteQuoteParamsSchema = PublicExecuteQuoteDebugParamsSchema +@dataclass +class PrivateExecuteQuoteParamsSchema(PublicExecuteQuoteDebugParamsSchema): + pass -class PrivateExecuteQuoteResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateExecuteQuoteResponseSchema: id: Union[str, int] result: PrivateExecuteQuoteResultSchema -class PublicGetSpotFeedHistoryCandlesResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency", title="currency") - spot_feed_history: List[SpotFeedHistoryCandlesResponseSchema] = Field( - ..., description="Spot feed history candles", title="spot_feed_history" - ) +@dataclass +class PublicGetSpotFeedHistoryCandlesResultSchema: + currency: str + spot_feed_history: List[SpotFeedHistoryCandlesResponseSchema] -class PrivatePollRfqsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivatePollRfqsResultSchema: pagination: PaginationInfoSchema - rfqs: List[RFQResultPublicSchema] = Field(..., description="RFQs matching filter criteria", title="rfqs") + rfqs: List[RFQResultPublicSchema] -class AuctionResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - auction_id: str = Field(..., description="Unique ID of the auction", title="auction_id") - auction_type: AuctionType = Field(..., description="Type of auction", title="auction_type") - bids: List[AuctionBidEventSchema] = Field(..., description="List of auction bid events", title="bids") - end_timestamp: Optional[int] = Field( - ..., - description="Timestamp of the auction end (in ms since UNIX epoch), or `null` if not ended", - title="end_timestamp", - ) - fee: Decimal = Field(..., description="Fee paid by the subaccount", title="fee") - start_timestamp: int = Field( - ..., - description="Timestamp of the auction start (in ms since UNIX epoch)", - title="start_timestamp", - ) - subaccount_id: int = Field(..., description="Liquidated subaccount ID", title="subaccount_id") - tx_hash: str = Field( - ..., - description="Hash of the transaction that started the auction", - title="tx_hash", - ) +@dataclass +class AuctionResultSchema: + auction_id: str + auction_type: AuctionType + bids: List[AuctionBidEventSchema] + end_timestamp: Optional[int] + fee: Decimal + start_timestamp: int + subaccount_id: int + tx_hash: str -class SignedTradeOrderSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class SignedTradeOrderSchema: data: TradeModuleDataSchema - expiry: int = Field(..., title="expiry") - is_atomic_signing: bool = Field(..., title="is_atomic_signing") - module: str = Field(..., title="module") - nonce: int = Field(..., title="nonce") - owner: str = Field(..., title="owner") - signature: str = Field(..., title="signature") - signer: str = Field(..., title="signer") - subaccount_id: int = Field(..., title="subaccount_id") - - -class PrivateDepositResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) + expiry: int + is_atomic_signing: bool + module: str + nonce: int + owner: str + signature: str + signer: str + subaccount_id: int + + +@dataclass +class PrivateDepositResponseSchema: id: Union[str, int] result: PrivateDepositResultSchema -class PrivateUpdateNotificationsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateUpdateNotificationsResponseSchema: id: Union[str, int] result: PrivateUpdateNotificationsResultSchema -class PrivateChangeSubaccountLabelResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateChangeSubaccountLabelResponseSchema: id: Union[str, int] result: PrivateChangeSubaccountLabelResultSchema -class PrivateTransferPositionsParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferPositionsParamsSchema: maker_params: SignedQuoteParamsSchema taker_params: SignedQuoteParamsSchema - wallet: str = Field(..., description="Public key (wallet) of the account", title="wallet") + wallet: str -class PrivateTransferPositionsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferPositionsResultSchema: maker_quote: QuoteResultSchema taker_quote: QuoteResultSchema -class PublicGetMakerProgramsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetMakerProgramsResponseSchema: id: Union[str, int] - result: List[ProgramResponseSchema] = Field(..., description="", title="result") + result: List[ProgramResponseSchema] -class PublicGetMarginParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - margin_type: MarginType = Field( - ..., - description="`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin))", - title="margin_type", - ) - market: Optional[str] = Field(None, description="Must be defined for Portfolio Margin", title="market") - simulated_collateral_changes: Optional[List[SimulatedCollateralSchema]] = Field( - None, - description="Optional, add collaterals to simulate deposits / withdrawals / spot trades", - title="simulated_collateral_changes", - ) - simulated_collaterals: List[SimulatedCollateralSchema] = Field( - ..., - description="List of collaterals in a simulated portfolio", - title="simulated_collaterals", - ) - simulated_position_changes: Optional[List[SimulatedPositionSchema]] = Field( - None, - description="Optional, add positions to simulate perp / option trades", - title="simulated_position_changes", - ) - simulated_positions: List[SimulatedPositionSchema] = Field( - ..., - description="List of positions in a simulated portfolio", - title="simulated_positions", - ) +@dataclass +class PublicGetMarginParamsSchema: + margin_type: MarginType + simulated_collaterals: List[SimulatedCollateralSchema] + simulated_positions: List[SimulatedPositionSchema] + market: Optional[str] = None + simulated_collateral_changes: Optional[List[SimulatedCollateralSchema]] = None + simulated_position_changes: Optional[List[SimulatedPositionSchema]] = None -class PublicGetMarginResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetMarginResponseSchema: id: Union[str, int] result: PublicGetMarginResultSchema -class PrivateCancelByNonceResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelByNonceResponseSchema: id: Union[str, int] result: PrivateCancelByNonceResultSchema -class PublicGetSpotFeedHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - currency: str = Field(..., description="Currency", title="currency") - spot_feed_history: List[SpotFeedHistoryResponseSchema] = Field( - ..., description="Spot feed history", title="spot_feed_history" - ) +@dataclass +class PublicGetSpotFeedHistoryResultSchema: + currency: str + spot_feed_history: List[SpotFeedHistoryResponseSchema] -class PrivateGetSubaccountsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetSubaccountsResponseSchema: id: Union[str, int] result: PrivateGetSubaccountsResultSchema -class PrivateGetDepositHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - events: List[DepositSchema] = Field(..., description="List of deposit payments", title="events") +@dataclass +class PrivateGetDepositHistoryResultSchema: + events: List[DepositSchema] -class PrivateCancelByLabelResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelByLabelResponseSchema: id: Union[str, int] result: PrivateCancelByLabelResultSchema -class PrivateGetMarginResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetMarginResponseSchema: id: Union[str, int] result: PrivateGetMarginResultSchema -class PublicCreateSubaccountDebugResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicCreateSubaccountDebugResponseSchema: id: Union[str, int] result: PublicCreateSubaccountDebugResultSchema -PublicGetInstrumentResultSchema = InstrumentPublicResponseSchema +@dataclass +class PublicGetInstrumentResultSchema(InstrumentPublicResponseSchema): + pass -class PrivateEditSessionKeyResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateEditSessionKeyResponseSchema: id: Union[str, int] result: PrivateEditSessionKeyResultSchema -class PrivateGetLiquidatorHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetLiquidatorHistoryResponseSchema: id: Union[str, int] result: PrivateGetLiquidatorHistoryResultSchema -class PrivateGetPositionsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - positions: List[PositionResponseSchema] = Field( - ..., description="All active positions of subaccount", title="positions" - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateGetPositionsResultSchema: + positions: List[PositionResponseSchema] + subaccount_id: int -class PublicGetTradeHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetTradeHistoryResultSchema: pagination: PaginationInfoSchema - trades: List[TradeSettledPublicResponseSchema] = Field(..., description="List of trades", title="trades") + trades: List[TradeSettledPublicResponseSchema] -class PrivateGetRfqsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetRfqsResultSchema: pagination: PaginationInfoSchema - rfqs: List[RFQResultSchema] = Field(..., description="RFQs matching filter criteria", title="rfqs") + rfqs: List[RFQResultSchema] -class PrivateTransferErc20ParamsSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferErc20ParamsSchema: recipient_details: SignatureDetailsSchema - recipient_subaccount_id: int = Field( - ..., - description="Subaccount_id of the recipient", - title="recipient_subaccount_id", - ) + recipient_subaccount_id: int sender_details: SignatureDetailsSchema - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") + subaccount_id: int transfer: TransferDetailsSchema -class PrivateTransferErc20ResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferErc20ResponseSchema: id: Union[str, int] result: PrivateTransferErc20ResultSchema -class PrivateSendQuoteResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateSendQuoteResponseSchema: id: Union[str, int] result: PrivateSendQuoteResultSchema -class PrivateCancelTriggerOrderResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelTriggerOrderResponseSchema: id: Union[str, int] result: PrivateCancelTriggerOrderResultSchema -class PrivateGetWithdrawalHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - events: List[WithdrawalSchema] = Field(..., description="List of withdrawals", title="events") +@dataclass +class PrivateGetWithdrawalHistoryResultSchema: + events: List[WithdrawalSchema] -class PublicGetOptionSettlementPricesResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - expiries: List[ExpiryResponseSchema] = Field(..., description="List of expiry details", title="expiries") +@dataclass +class PublicGetOptionSettlementPricesResultSchema: + expiries: List[ExpiryResponseSchema] -class PublicGetMakerProgramScoresResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetMakerProgramScoresResultSchema: program: ProgramResponseSchema - scores: List[ScoreBreakdownSchema] = Field( - ..., - description="Scores breakdown of the program by market maker", - title="scores", - ) - total_score: Decimal = Field( - ..., - description="Total score across all market makers for the epoch", - title="total_score", - ) - total_volume: Decimal = Field( - ..., - description="Total volume across all market makers for the epoch", - title="total_volume", - ) + scores: List[ScoreBreakdownSchema] + total_score: Decimal + total_volume: Decimal -class PublicBuildRegisterSessionKeyTxResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicBuildRegisterSessionKeyTxResponseSchema: id: Union[str, int] result: PublicBuildRegisterSessionKeyTxResultSchema -class PublicRegisterSessionKeyResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicRegisterSessionKeyResponseSchema: id: Union[str, int] result: PublicRegisterSessionKeyResultSchema -class PrivateGetOrderHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetOrderHistoryResponseSchema: id: Union[str, int] result: PrivateGetOrderHistoryResultSchema -class PrivateCancelBatchRfqsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelBatchRfqsResponseSchema: id: Union[str, int] result: PrivateCancelBatchRfqsResultSchema -class PrivateCancelBatchQuotesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelBatchQuotesResponseSchema: id: Union[str, int] result: PrivateCancelBatchQuotesResultSchema -class PrivateGetFundingHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - events: List[FundingPaymentSchema] = Field(..., description="List of funding payments", title="events") +@dataclass +class PrivateGetFundingHistoryResultSchema: + events: List[FundingPaymentSchema] pagination: PaginationInfoSchema -class PrivateGetOpenOrdersResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetOpenOrdersResponseSchema: id: Union[str, int] result: PrivateGetOpenOrdersResultSchema -class PrivateGetAccountResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - cancel_on_disconnect: bool = Field( - ..., - description="Whether cancel on disconnect is enabled for the account", - title="cancel_on_disconnect", - ) +@dataclass +class PrivateGetAccountResultSchema: + cancel_on_disconnect: bool fee_info: AccountFeeInfoSchema - is_rfq_maker: bool = Field( - ..., - description="Whether account allowed to market make RFQs", - title="is_rfq_maker", - ) - per_endpoint_tps: Dict[str, Any] = Field( - ..., - description="If a particular endpoint has a different max TPS, it will be specified here", - title="per_endpoint_tps", - ) - referral_code: Optional[str] = Field( - None, - description="Referral code for the account (must register with broker program first)", - title="referral_code", - ) - subaccount_ids: List[int] = Field( - ..., - description="List of subaccount_ids owned by the wallet in `SubAccounts.sol`", - title="subaccount_ids", - ) - wallet: str = Field(..., description="Ethereum wallet address", title="wallet") - websocket_matching_tps: int = Field( - ..., - description="Max transactions per second for matching requests over websocket (see `Rate Limiting` in docs)", - title="websocket_matching_tps", - ) - websocket_non_matching_tps: int = Field( - ..., - description="Max transactions per second for non-matching requests over websocket (see `Rate Limiting` in docs)", - title="websocket_non_matching_tps", - ) - websocket_option_tps: int = Field( - ..., - description="Max transactions per second for EACH option instrument over websocket (see `Rate Limiting` in docs)", - title="websocket_option_tps", - ) - websocket_perp_tps: int = Field( - ..., - description="Max transactions per second for EACH perp instrument over websocket (see `Rate Limiting` in docs)", - title="websocket_perp_tps", - ) - - -class PublicGetAllInstrumentsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - instruments: List[InstrumentPublicResponseSchema] = Field( - ..., description="List of instruments", title="instruments" - ) + is_rfq_maker: bool + per_endpoint_tps: Dict[str, Any] + subaccount_ids: List[int] + wallet: str + websocket_matching_tps: int + websocket_non_matching_tps: int + websocket_option_tps: int + websocket_perp_tps: int + referral_code: Optional[str] = None + + +@dataclass +class PublicGetAllInstrumentsResultSchema: + instruments: List[InstrumentPublicResponseSchema] pagination: PaginationInfoSchema -class PublicGetTickerResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - amount_step: Decimal = Field(..., description="Minimum valid increment of order amount", title="amount_step") - base_asset_address: str = Field( - ..., - description="Blockchain address of the base asset", - title="base_asset_address", - ) - base_asset_sub_id: str = Field( - ..., - description="Sub ID of the specific base asset as defined in Asset.sol", - title="base_asset_sub_id", - ) - base_currency: str = Field( - ..., - description="Underlying currency of base asset (`ETH`, `BTC`, etc)", - title="base_currency", - ) - base_fee: Decimal = Field(..., description="$ base fee added to every taker order", title="base_fee") - best_ask_amount: Decimal = Field( - ..., - description="Amount of contracts / tokens available at best ask price", - title="best_ask_amount", - ) - best_ask_price: Decimal = Field(..., description="Best ask price", title="best_ask_price") - best_bid_amount: Decimal = Field( - ..., - description="Amount of contracts / tokens available at best bid price", - title="best_bid_amount", - ) - best_bid_price: Decimal = Field(..., description="Best bid price", title="best_bid_price") - erc20_details: Optional[ERC20PublicDetailsSchema] = Field(...) - fifo_min_allocation: Decimal = Field( - ..., - description="Minimum number of contracts that get filled using FIFO. Actual number of contracts that gets filled by FIFO will be the max between this value and (1 - pro_rata_fraction) x order_amount, plus any size leftovers due to rounding.", - title="fifo_min_allocation", - ) - five_percent_ask_depth: Decimal = Field( - ..., - description="Total amount of contracts / tokens available at 5 percent above best ask price", - title="five_percent_ask_depth", - ) - five_percent_bid_depth: Decimal = Field( - ..., - description="Total amount of contracts / tokens available at 5 percent below best bid price", - title="five_percent_bid_depth", - ) - index_price: Decimal = Field(..., description="Index price", title="index_price") - instrument_name: str = Field(..., description="Instrument name", title="instrument_name") - instrument_type: InstrumentType = Field(..., description="`erc20`, `option`, or `perp`", title="instrument_type") - is_active: bool = Field( - ..., - description="If `True`: instrument is tradeable within `activation` and `deactivation` timestamps", - title="is_active", - ) - maker_fee_rate: Decimal = Field( - ..., - description="Percent of spot price fee rate for makers", - title="maker_fee_rate", - ) - mark_price: Decimal = Field(..., description="Mark price", title="mark_price") - mark_price_fee_rate_cap: Optional[Decimal] = Field( - None, - description="Percent of option price fee cap, e.g. 12.5%, null if not applicable", - title="mark_price_fee_rate_cap", - ) - max_price: Decimal = Field( - ..., - description="Maximum price at which an agressive buyer can be matched. Any portion of a market order that would execute above this price will be cancelled. A limit buy order with limit price above this value is treated as post only (i.e. it will be rejected if it would cross any existing resting order).", - title="max_price", - ) - maximum_amount: Decimal = Field( - ..., - description="Maximum valid amount of contracts / tokens per trade", - title="maximum_amount", - ) - min_price: Decimal = Field( - ..., - description="Minimum price at which an agressive seller can be matched. Any portion of a market order that would execute below this price will be cancelled. A limit sell order with limit price below this value is treated as post only (i.e. it will be rejected if it would cross any existing resting order).", - title="min_price", - ) - minimum_amount: Decimal = Field( - ..., - description="Minimum valid amount of contracts / tokens per trade", - title="minimum_amount", - ) - open_interest: Dict[str, List[OpenInterestStatsSchema]] = Field( - ..., - description="Margin type of subaccount (`PM` (Portfolio Margin), `PM2 (Portfolio Margin 2), or `SM` (Standard Margin)) -> (current open interest, open interest cap, manager currency)", - title="open_interest", - ) - option_details: Optional[OptionPublicDetailsSchema] = Field(...) - option_pricing: Optional[OptionPricingSchema] = Field(...) - perp_details: Optional[PerpPublicDetailsSchema] = Field(...) - pro_rata_amount_step: Decimal = Field( - ..., - description="Pro-rata fill share of every order is rounded down to be a multiple of this number. Leftovers of the order due to rounding are filled FIFO.", - title="pro_rata_amount_step", - ) - pro_rata_fraction: Decimal = Field( - ..., - description="Fraction of order that gets filled using pro-rata matching. If zero, the matching is full FIFO.", - title="pro_rata_fraction", - ) - quote_currency: str = Field( - ..., - description="Quote currency (`USD` for perps, `USDC` for options)", - title="quote_currency", - ) - scheduled_activation: int = Field( - ..., - description="Timestamp at which became or will become active (if applicable)", - title="scheduled_activation", - ) - scheduled_deactivation: int = Field( - ..., - description="Scheduled deactivation time for instrument (if applicable)", - title="scheduled_deactivation", - ) +@dataclass +class PublicGetTickerResultSchema: + amount_step: Decimal + base_asset_address: str + base_asset_sub_id: str + base_currency: str + base_fee: Decimal + best_ask_amount: Decimal + best_ask_price: Decimal + best_bid_amount: Decimal + best_bid_price: Decimal + erc20_details: Optional[ERC20PublicDetailsSchema] + fifo_min_allocation: Decimal + five_percent_ask_depth: Decimal + five_percent_bid_depth: Decimal + index_price: Decimal + instrument_name: str + instrument_type: InstrumentType + is_active: bool + maker_fee_rate: Decimal + mark_price: Decimal + max_price: Decimal + maximum_amount: Decimal + min_price: Decimal + minimum_amount: Decimal + open_interest: Dict[str, List[OpenInterestStatsSchema]] + option_details: Optional[OptionPublicDetailsSchema] + option_pricing: Optional[OptionPricingSchema] + perp_details: Optional[PerpPublicDetailsSchema] + pro_rata_amount_step: Decimal + pro_rata_fraction: Decimal + quote_currency: str + scheduled_activation: int + scheduled_deactivation: int stats: AggregateTradingStatsSchema - taker_fee_rate: Decimal = Field( - ..., - description="Percent of spot price fee rate for takers", - title="taker_fee_rate", - ) - tick_size: Decimal = Field( - ..., - description="Tick size of the instrument, i.e. minimum price increment", - title="tick_size", - ) - timestamp: int = Field(..., description="Timestamp of the ticker feed snapshot", title="timestamp") + taker_fee_rate: Decimal + tick_size: Decimal + timestamp: int + mark_price_fee_rate_cap: Optional[Decimal] = None -class PublicGetVaultShareResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetVaultShareResultSchema: pagination: PaginationInfoSchema - vault_shares: List[VaultShareResponseSchema] = Field( - ..., - description="List of vault history shares, recent first", - title="vault_shares", - ) + vault_shares: List[VaultShareResponseSchema] -class PrivateGetCollateralsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - collaterals: List[CollateralResponseSchema] = Field( - ..., - description="All collaterals that count towards margin of subaccount", - title="collaterals", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") +@dataclass +class PrivateGetCollateralsResultSchema: + collaterals: List[CollateralResponseSchema] + subaccount_id: int -class PrivateRegisterScopedSessionKeyResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateRegisterScopedSessionKeyResponseSchema: id: Union[str, int] result: PrivateRegisterScopedSessionKeyResultSchema -class PrivateExpiredAndCancelledHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateExpiredAndCancelledHistoryResponseSchema: id: Union[str, int] result: PrivateExpiredAndCancelledHistoryResultSchema -class PrivateSessionKeysResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - public_session_keys: List[SessionKeyResponseSchema] = Field( - ..., - description="List of session keys (includes unactivated and expired keys)", - title="public_session_keys", - ) +@dataclass +class PrivateSessionKeysResultSchema: + public_session_keys: List[SessionKeyResponseSchema] -class PrivateGetMmpConfigResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetMmpConfigResponseSchema: id: Union[str, int] - result: List[MMPConfigResultSchema] = Field(..., description="", title="result") + result: List[MMPConfigResultSchema] -class PrivateOrderResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateOrderResponseSchema: id: Union[str, int] result: PrivateOrderResultSchema -class PrivateGetSubaccountResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetSubaccountResponseSchema: id: Union[str, int] result: PrivateGetSubaccountResultSchema -class PublicGetInterestRateHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - interest_rates: List[InterestRateHistoryResponseSchema] = Field( - ..., description="List of interest rates, recent first", title="interest_rates" - ) +@dataclass +class PublicGetInterestRateHistoryResultSchema: + interest_rates: List[InterestRateHistoryResponseSchema] pagination: PaginationInfoSchema -class PublicGetLiquidationHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - auctions: List[AuctionResultSchema] = Field(..., description="List of auction results", title="auctions") +@dataclass +class PublicGetLiquidationHistoryResultSchema: + auctions: List[AuctionResultSchema] pagination: PaginationInfoSchema -class PublicDepositDebugResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicDepositDebugResponseSchema: id: Union[str, int] result: PublicDepositDebugResultSchema -class PublicGetVaultBalancesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetVaultBalancesResponseSchema: id: Union[str, int] - result: List[VaultBalanceResponseSchema] = Field(..., description="", title="result") + result: List[VaultBalanceResponseSchema] -class PublicGetReferralPerformanceResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - fee_share_percentage: Decimal = Field( - ..., - description="Fee share percentage rewarded to referrer", - title="fee_share_percentage", - ) - referral_code: str = Field(..., description="Referral code used to get performance", title="referral_code") - rewards: Dict[str, Dict[str, Dict[str, ReferralPerformanceByInstrumentTypeSchema]]] = Field( - ..., - description="Performance by liquidity role / currency / instrument type", - title="rewards", - ) - stdrv_balance: Decimal = Field( - ..., - description="Staked DRV held used to determine fee share percentage", - title="stdrv_balance", - ) - total_fee_rewards: Decimal = Field(..., description="Total fee rewards to referrers", title="total_fee_rewards") - total_notional_volume: Decimal = Field( - ..., description="Total referred notional volume", title="total_notional_volume" - ) - total_referred_fees: Decimal = Field( - ..., - description="Total fees paid by referred traders (double counts if both taker and maker of a trade with rebated fees)", - title="total_referred_fees", - ) +@dataclass +class PublicGetReferralPerformanceResultSchema: + fee_share_percentage: Decimal + referral_code: str + rewards: Dict[str, Dict[str, Dict[str, ReferralPerformanceByInstrumentTypeSchema]]] + stdrv_balance: Decimal + total_fee_rewards: Decimal + total_notional_volume: Decimal + total_referred_fees: Decimal -class PrivateCancelQuoteResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelQuoteResponseSchema: id: Union[str, int] result: PrivateCancelQuoteResultSchema -class PrivateGetQuotesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetQuotesResponseSchema: id: Union[str, int] result: PrivateGetQuotesResultSchema -class PublicExecuteQuoteDebugResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicExecuteQuoteDebugResponseSchema: id: Union[str, int] result: PublicExecuteQuoteDebugResultSchema -class PrivateGetOptionSettlementHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - settlements: List[OptionSettlementResponseSchema] = Field( - ..., description="List of expired option settlements", title="settlements" - ) - subaccount_id: int = Field( - ..., - description="Subaccount_id for which to get expired option settlement history", - title="subaccount_id", - ) +@dataclass +class PrivateGetOptionSettlementHistoryResultSchema: + settlements: List[OptionSettlementResponseSchema] + subaccount_id: int -class PrivateGetErc20TransferHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - events: List[ERC20TransferSchema] = Field(..., description="List of erc20 transfers", title="events") +@dataclass +class PrivateGetErc20TransferHistoryResultSchema: + events: List[ERC20TransferSchema] -class PublicGetAllCurrenciesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetAllCurrenciesResponseSchema: id: Union[str, int] - result: List[CurrencyDetailedResponseSchema] = Field(..., description="", title="result") + result: List[CurrencyDetailedResponseSchema] -class PrivateGetSubaccountValueHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - subaccount_id: int = Field(..., description="Subaccount_id", title="subaccount_id") - subaccount_value_history: List[SubAccountValueHistoryResponseSchema] = Field( - ..., description="Subaccount value history", title="subaccount_value_history" - ) +@dataclass +class PrivateGetSubaccountValueHistoryResultSchema: + subaccount_id: int + subaccount_value_history: List[SubAccountValueHistoryResponseSchema] -class PublicSendQuoteDebugResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicSendQuoteDebugResponseSchema: id: Union[str, int] result: PublicSendQuoteDebugResultSchema -class PublicGetLiveIncidentsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - incidents: List[IncidentResponseSchema] = Field(..., description="List of ongoing incidents", title="incidents") +@dataclass +class PublicGetLiveIncidentsResultSchema: + incidents: List[IncidentResponseSchema] -class PublicGetTransactionResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetTransactionResponseSchema: id: Union[str, int] result: PublicGetTransactionResultSchema -class PrivateGetOrdersResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetOrdersResponseSchema: id: Union[str, int] result: PrivateGetOrdersResultSchema -class PrivateGetInterestHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - events: List[InterestPaymentSchema] = Field(..., description="List of interest payments", title="events") +@dataclass +class PrivateGetInterestHistoryResultSchema: + events: List[InterestPaymentSchema] -class PrivatePollQuotesResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivatePollQuotesResultSchema: pagination: PaginationInfoSchema - quotes: List[QuoteResultPublicSchema] = Field(..., description="Quotes matching filter criteria", title="quotes") + quotes: List[QuoteResultPublicSchema] -class PrivateGetOrderResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetOrderResponseSchema: id: Union[str, int] result: PrivateGetOrderResultSchema -class PublicGetVaultStatisticsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetVaultStatisticsResponseSchema: id: Union[str, int] - result: List[VaultStatisticsResponseSchema] = Field(..., description="", title="result") + result: List[VaultStatisticsResponseSchema] -class PublicWithdrawDebugResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicWithdrawDebugResponseSchema: id: Union[str, int] result: PublicWithdrawDebugResultSchema -class PublicGetFundingRateHistoryResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - funding_rate_history: List[FundingRateSchema] = Field( - ..., description="List of funding rates", title="funding_rate_history" - ) +@dataclass +class PublicGetFundingRateHistoryResultSchema: + funding_rate_history: List[FundingRateSchema] -class PrivateRfqGetBestQuoteResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateRfqGetBestQuoteResponseSchema: id: Union[str, int] result: PrivateRfqGetBestQuoteResultSchema -class PublicGetOptionSettlementHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetOptionSettlementHistoryResponseSchema: id: Union[str, int] result: PublicGetOptionSettlementHistoryResultSchema -class PrivateLiquidateResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateLiquidateResponseSchema: id: Union[str, int] result: PrivateLiquidateResultSchema -class PrivateGetTradeHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetTradeHistoryResponseSchema: id: Union[str, int] result: PrivateGetTradeHistoryResultSchema -class ForwardFeedDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") - currency: str = Field( - ..., - description="The currency for which the spot feed represents", - title="currency", - ) - deadline: int = Field( - ..., - description="The latest time the data can be submitted on chain", - title="deadline", - ) - expiry: int = Field(..., description="The expiry for the forward feed", title="expiry") - fwd_diff: Decimal = Field( - ..., - description="difference of forward price from current spot price", - title="fwd_diff", - ) +@dataclass +class ForwardFeedDataSchema: + confidence: Decimal + currency: str + deadline: int + expiry: int + fwd_diff: Decimal signatures: OracleSignatureDataSchema - spot_aggregate_latest: Decimal = Field( - ..., - description="expiry -> spot * time value at the latest timestamp", - title="spot_aggregate_latest", - ) - spot_aggregate_start: Decimal = Field( - ..., - description="spot * time value at the start of the settlement period", - title="spot_aggregate_start", - ) - timestamp: int = Field( - ..., - description="The timestamp for which the data was created", - title="timestamp", - ) + spot_aggregate_latest: Decimal + spot_aggregate_start: Decimal + timestamp: int -class VolFeedDataSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - confidence: Decimal = Field(..., description="The confidence score of the price", title="confidence") - currency: str = Field( - ..., - description="The currency for which the spot feed represents", - title="currency", - ) - deadline: int = Field( - ..., - description="The latest time the data can be submitted on chain", - title="deadline", - ) - expiry: int = Field(..., description="The expiry for the options for the vol feed", title="expiry") +@dataclass +class VolFeedDataSchema: + confidence: Decimal + currency: str + deadline: int + expiry: int signatures: OracleSignatureDataSchema - timestamp: int = Field( - ..., - description="The timestamp for which the data was created", - title="timestamp", - ) + timestamp: int vol_data: VolSVIParamDataSchema -class PrivateReplaceResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateReplaceResultSchema: cancelled_order: OrderResponseSchema create_order_error: Optional[RPCErrorFormatSchema] = None order: Optional[OrderResponseSchema] = None - trades: Optional[List[TradeResponseSchema]] = Field( - None, description="List of trades executed by the created order", title="trades" - ) + trades: Optional[List[TradeResponseSchema]] = None -class PrivateCancelByInstrumentResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateCancelByInstrumentResponseSchema: id: Union[str, int] result: PrivateCancelByInstrumentResultSchema -class PublicDeregisterSessionKeyResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicDeregisterSessionKeyResponseSchema: id: Union[str, int] result: PublicDeregisterSessionKeyResultSchema -class PrivateWithdrawResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateWithdrawResponseSchema: id: Union[str, int] result: PrivateWithdrawResultSchema -class PrivateGetNotificationsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetNotificationsResponseSchema: id: Union[str, int] result: PrivateGetNotificationsResultSchema -class PublicGetCurrencyResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetCurrencyResponseSchema: id: Union[str, int] result: PublicGetCurrencyResultSchema -class PrivateTransferPositionResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferPositionResponseSchema: id: Union[str, int] result: PrivateTransferPositionResultSchema -class PublicMarginWatchResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicMarginWatchResponseSchema: id: Union[str, int] result: PublicMarginWatchResultSchema -class PublicGetSpotFeedHistoryCandlesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetSpotFeedHistoryCandlesResponseSchema: id: Union[str, int] result: PublicGetSpotFeedHistoryCandlesResultSchema -class PrivatePollRfqsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivatePollRfqsResponseSchema: id: Union[str, int] result: PrivatePollRfqsResultSchema -class PrivateGetLiquidationHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetLiquidationHistoryResponseSchema: id: Union[str, int] - result: List[AuctionResultSchema] = Field(..., description="", title="result") + result: List[AuctionResultSchema] -class PrivateOrderDebugResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - action_hash: str = Field(..., description="Keccak hashed action data", title="action_hash") - encoded_data: str = Field(..., description="ABI encoded order data", title="encoded_data") - encoded_data_hashed: str = Field(..., description="Keccak hashed encoded_data", title="encoded_data_hashed") +@dataclass +class PrivateOrderDebugResultSchema: + action_hash: str + encoded_data: str + encoded_data_hashed: str raw_data: SignedTradeOrderSchema - typed_data_hash: str = Field(..., description="EIP 712 typed data hash", title="typed_data_hash") + typed_data_hash: str -class PrivateTransferPositionsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateTransferPositionsResponseSchema: id: Union[str, int] result: PrivateTransferPositionsResultSchema -class PublicGetSpotFeedHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetSpotFeedHistoryResponseSchema: id: Union[str, int] result: PublicGetSpotFeedHistoryResultSchema -class PrivateGetDepositHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetDepositHistoryResponseSchema: id: Union[str, int] result: PrivateGetDepositHistoryResultSchema -class PublicGetInstrumentResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetInstrumentResponseSchema: id: Union[str, int] result: PublicGetInstrumentResultSchema -class PrivateGetPositionsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetPositionsResponseSchema: id: Union[str, int] result: PrivateGetPositionsResultSchema -class PublicGetTradeHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetTradeHistoryResponseSchema: id: Union[str, int] result: PublicGetTradeHistoryResultSchema -class PrivateGetRfqsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetRfqsResponseSchema: id: Union[str, int] result: PrivateGetRfqsResultSchema -class PrivateGetWithdrawalHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetWithdrawalHistoryResponseSchema: id: Union[str, int] result: PrivateGetWithdrawalHistoryResultSchema -class PublicGetOptionSettlementPricesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetOptionSettlementPricesResponseSchema: id: Union[str, int] result: PublicGetOptionSettlementPricesResultSchema -class PublicGetMakerProgramScoresResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetMakerProgramScoresResponseSchema: id: Union[str, int] result: PublicGetMakerProgramScoresResultSchema -class PrivateGetFundingHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetFundingHistoryResponseSchema: id: Union[str, int] result: PrivateGetFundingHistoryResultSchema -class PrivateGetAccountResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetAccountResponseSchema: id: Union[str, int] result: PrivateGetAccountResultSchema -class PublicGetAllInstrumentsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetAllInstrumentsResponseSchema: id: Union[str, int] result: PublicGetAllInstrumentsResultSchema -class PublicGetTickerResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetTickerResponseSchema: id: Union[str, int] result: PublicGetTickerResultSchema -class PublicGetVaultShareResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetVaultShareResponseSchema: id: Union[str, int] result: PublicGetVaultShareResultSchema -class PrivateGetCollateralsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetCollateralsResponseSchema: id: Union[str, int] result: PrivateGetCollateralsResultSchema -class PrivateSessionKeysResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateSessionKeysResponseSchema: id: Union[str, int] result: PrivateSessionKeysResultSchema -class PublicGetInterestRateHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetInterestRateHistoryResponseSchema: id: Union[str, int] result: PublicGetInterestRateHistoryResultSchema -class PublicGetLiquidationHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetLiquidationHistoryResponseSchema: id: Union[str, int] result: PublicGetLiquidationHistoryResultSchema -class PublicGetReferralPerformanceResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetReferralPerformanceResponseSchema: id: Union[str, int] result: PublicGetReferralPerformanceResultSchema -class PrivateGetOptionSettlementHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetOptionSettlementHistoryResponseSchema: id: Union[str, int] result: PrivateGetOptionSettlementHistoryResultSchema -class PrivateGetErc20TransferHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetErc20TransferHistoryResponseSchema: id: Union[str, int] result: PrivateGetErc20TransferHistoryResultSchema -class PrivateGetSubaccountValueHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetSubaccountValueHistoryResponseSchema: id: Union[str, int] result: PrivateGetSubaccountValueHistoryResultSchema -class PublicGetLiveIncidentsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetLiveIncidentsResponseSchema: id: Union[str, int] result: PublicGetLiveIncidentsResultSchema -class PrivateGetInterestHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateGetInterestHistoryResponseSchema: id: Union[str, int] result: PrivateGetInterestHistoryResultSchema -class PrivatePollQuotesResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivatePollQuotesResponseSchema: id: Union[str, int] result: PrivatePollQuotesResultSchema -class PublicGetFundingRateHistoryResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetFundingRateHistoryResponseSchema: id: Union[str, int] result: PublicGetFundingRateHistoryResultSchema -class PublicGetLatestSignedFeedsResultSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) - fwd_data: Dict[str, Dict[str, ForwardFeedDataSchema]] = Field( - ..., - description="currency -> expiry -> latest forward feed data", - title="fwd_data", - ) - perp_data: Dict[str, Dict[str, PerpFeedDataSchema]] = Field( - ..., - description="currency -> feed type -> latest perp feed data", - title="perp_data", - ) - rate_data: Dict[str, Dict[str, RateFeedDataSchema]] = Field( - ..., - description="currency -> expiry -> latest rate feed data", - title="rate_data", - ) - spot_data: Dict[str, SpotFeedDataSchema] = Field( - ..., description="currency -> latest spot feed data", title="spot_data" - ) - vol_data: Dict[str, Dict[str, VolFeedDataSchema]] = Field( - ..., description="currency -> expiry -> latest vol feed data", title="vol_data" - ) +@dataclass +class PublicGetLatestSignedFeedsResultSchema: + fwd_data: Dict[str, Dict[str, ForwardFeedDataSchema]] + perp_data: Dict[str, Dict[str, PerpFeedDataSchema]] + rate_data: Dict[str, Dict[str, RateFeedDataSchema]] + spot_data: Dict[str, SpotFeedDataSchema] + vol_data: Dict[str, Dict[str, VolFeedDataSchema]] -class PrivateReplaceResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateReplaceResponseSchema: id: Union[str, int] result: PrivateReplaceResultSchema -class PrivateOrderDebugResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PrivateOrderDebugResponseSchema: id: Union[str, int] result: PrivateOrderDebugResultSchema -class PublicGetLatestSignedFeedsResponseSchema(BaseModel): - model_config = ConfigDict( - extra="forbid", - ) +@dataclass +class PublicGetLatestSignedFeedsResponseSchema: id: Union[str, int] result: PublicGetLatestSignedFeedsResultSchema diff --git a/scripts/generate-models.py b/scripts/generate-models.py index 6bd030be..6a72ef30 100644 --- a/scripts/generate-models.py +++ b/scripts/generate-models.py @@ -67,7 +67,7 @@ def generate_models(input_path: Path, output_path: Path): input_=input_path, input_file_type=InputFileType.OpenAPI, output=output_path, - output_model_type=DataModelType.PydanticV2BaseModel, + output_model_type=DataModelType.DataclassesDataclass, target_python_version=PythonVersion.PY_310, reuse_model=True, use_subclass_enum=True, From d2f0e705bec3ca378cf18f81873d66b720ceb2b8 Mon Sep 17 00:00:00 2001 From: zarathustra Date: Wed, 1 Oct 2025 14:18:52 +0200 Subject: [PATCH 5/6] chore: add datamodel-code-generator to dev packages --- poetry.lock | 344 ++++++++++++++++++++++++++++++++++++++++++++++--- pyproject.toml | 1 + 2 files changed, 326 insertions(+), 19 deletions(-) diff --git a/poetry.lock b/poetry.lock index 73109b5d..961fda23 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -6,6 +6,7 @@ version = "2.6.1" description = "Happy Eyeballs for asyncio" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "aiohappyeyeballs-2.6.1-py3-none-any.whl", hash = "sha256:f349ba8f4b75cb25c99c5c2d84e997e485204d2902a9597802b0371f09331fb8"}, {file = "aiohappyeyeballs-2.6.1.tar.gz", hash = "sha256:c3f9d0113123803ccadfdf3f0faa505bc78e6a72d1cc4806cbd719826e943558"}, @@ -17,6 +18,7 @@ version = "3.12.15" description = "Async http client/server framework (asyncio)" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "aiohttp-3.12.15-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:b6fc902bff74d9b1879ad55f5404153e2b33a82e72a95c89cec5eb6cc9e92fbc"}, {file = "aiohttp-3.12.15-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:098e92835b8119b54c693f2f88a1dec690e20798ca5f5fe5f0520245253ee0af"}, @@ -117,7 +119,7 @@ propcache = ">=0.2.0" yarl = ">=1.17.0,<2.0" [package.extras] -speedups = ["Brotli", "aiodns (>=3.3.0)", "brotlicffi"] +speedups = ["Brotli ; platform_python_implementation == \"CPython\"", "aiodns (>=3.3.0)", "brotlicffi ; platform_python_implementation != \"CPython\""] [[package]] name = "aiolimiter" @@ -125,6 +127,7 @@ version = "1.2.1" description = "asyncio rate limiter, a leaky bucket implementation" optional = false python-versions = "<4.0,>=3.8" +groups = ["main"] files = [ {file = "aiolimiter-1.2.1-py3-none-any.whl", hash = "sha256:d3f249e9059a20badcb56b61601a83556133655c11d1eb3dd3e04ff069e5f3c7"}, {file = "aiolimiter-1.2.1.tar.gz", hash = "sha256:e02a37ea1a855d9e832252a105420ad4d15011505512a1a1d814647451b5cca9"}, @@ -136,6 +139,7 @@ version = "1.4.0" description = "aiosignal: a list of registered asynchronous callbacks" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "aiosignal-1.4.0-py3-none-any.whl", hash = "sha256:053243f8b92b990551949e63930a839ff0cf0b0ebbe0597b0f3fb19e1a0fe82e"}, {file = "aiosignal-1.4.0.tar.gz", hash = "sha256:f47eecd9468083c2029cc99945502cb7708b082c232f9aca65da147157b251c7"}, @@ -151,17 +155,35 @@ version = "0.7.0" description = "Reusable constraint types to use with typing.Annotated" optional = false python-versions = ">=3.8" +groups = ["main", "dev"] files = [ {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, ] +[[package]] +name = "argcomplete" +version = "3.6.2" +description = "Bash tab completion for argparse" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "argcomplete-3.6.2-py3-none-any.whl", hash = "sha256:65b3133a29ad53fb42c48cf5114752c7ab66c1c38544fdf6460f450c09b42591"}, + {file = "argcomplete-3.6.2.tar.gz", hash = "sha256:d0519b1bc867f5f4f4713c41ad0aba73a4a5f007449716b16f385f2166dc6adf"}, +] + +[package.extras] +test = ["coverage", "mypy", "pexpect", "ruff", "wheel"] + [[package]] name = "async-timeout" version = "5.0.1" description = "Timeout context manager for asyncio programs" optional = false python-versions = ">=3.8" +groups = ["main"] +markers = "python_version < \"3.11\"" files = [ {file = "async_timeout-5.0.1-py3-none-any.whl", hash = "sha256:39e3809566ff85354557ec2398b55e096c8364bacac9405a7a1fa429e77fe76c"}, {file = "async_timeout-5.0.1.tar.gz", hash = "sha256:d9321a7a3d5a6a5e187e824d2fa0793ce379a202935782d555d6e9d2735677d3"}, @@ -173,18 +195,19 @@ version = "25.3.0" description = "Classes Without Boilerplate" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "attrs-25.3.0-py3-none-any.whl", hash = "sha256:427318ce031701fea540783410126f03899a97ffc6f61596ad581ac2e40e3bc3"}, {file = "attrs-25.3.0.tar.gz", hash = "sha256:75d7cefc7fb576747b2c81b4442d4d4a1ce0900973527c011d1030fd3bf4af1b"}, ] [package.extras] -benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +benchmark = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] +cov = ["cloudpickle ; platform_python_implementation == \"CPython\"", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] +dev = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier"] -tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] +tests = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] +tests-mypy = ["mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\""] [[package]] name = "bitarray" @@ -192,6 +215,7 @@ version = "3.7.1" description = "efficient arrays of booleans -- C extension" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "bitarray-3.7.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a05982bb49c73463cb0f0f4bed2d8da82631708a2c2d1926107ba99651b419ec"}, {file = "bitarray-3.7.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d30e7daaf228e3d69cdd8b02c0dd4199cec034c4b93c80109f56f4675a6db957"}, @@ -329,12 +353,61 @@ files = [ {file = "bitarray-3.7.1.tar.gz", hash = "sha256:795b1760418ab750826420ae24f06f392c08e21dc234f0a369a69cc00444f8ec"}, ] +[[package]] +name = "black" +version = "25.9.0" +description = "The uncompromising code formatter." +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "black-25.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ce41ed2614b706fd55fd0b4a6909d06b5bab344ffbfadc6ef34ae50adba3d4f7"}, + {file = "black-25.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2ab0ce111ef026790e9b13bd216fa7bc48edd934ffc4cbf78808b235793cbc92"}, + {file = "black-25.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f96b6726d690c96c60ba682955199f8c39abc1ae0c3a494a9c62c0184049a713"}, + {file = "black-25.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:d119957b37cc641596063cd7db2656c5be3752ac17877017b2ffcdb9dfc4d2b1"}, + {file = "black-25.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:456386fe87bad41b806d53c062e2974615825c7a52159cde7ccaeb0695fa28fa"}, + {file = "black-25.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a16b14a44c1af60a210d8da28e108e13e75a284bf21a9afa6b4571f96ab8bb9d"}, + {file = "black-25.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:aaf319612536d502fdd0e88ce52d8f1352b2c0a955cc2798f79eeca9d3af0608"}, + {file = "black-25.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:c0372a93e16b3954208417bfe448e09b0de5cc721d521866cd9e0acac3c04a1f"}, + {file = "black-25.9.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1b9dc70c21ef8b43248f1d86aedd2aaf75ae110b958a7909ad8463c4aa0880b0"}, + {file = "black-25.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8e46eecf65a095fa62e53245ae2795c90bdecabd53b50c448d0a8bcd0d2e74c4"}, + {file = "black-25.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9101ee58ddc2442199a25cb648d46ba22cd580b00ca4b44234a324e3ec7a0f7e"}, + {file = "black-25.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:77e7060a00c5ec4b3367c55f39cf9b06e68965a4f2e61cecacd6d0d9b7ec945a"}, + {file = "black-25.9.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0172a012f725b792c358d57fe7b6b6e8e67375dd157f64fa7a3097b3ed3e2175"}, + {file = "black-25.9.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3bec74ee60f8dfef564b573a96b8930f7b6a538e846123d5ad77ba14a8d7a64f"}, + {file = "black-25.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b756fc75871cb1bcac5499552d771822fd9db5a2bb8db2a7247936ca48f39831"}, + {file = "black-25.9.0-cp313-cp313-win_amd64.whl", hash = "sha256:846d58e3ce7879ec1ffe816bb9df6d006cd9590515ed5d17db14e17666b2b357"}, + {file = "black-25.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ef69351df3c84485a8beb6f7b8f9721e2009e20ef80a8d619e2d1788b7816d47"}, + {file = "black-25.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e3c1f4cd5e93842774d9ee4ef6cd8d17790e65f44f7cdbaab5f2cf8ccf22a823"}, + {file = "black-25.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:154b06d618233fe468236ba1f0e40823d4eb08b26f5e9261526fde34916b9140"}, + {file = "black-25.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:e593466de7b998374ea2585a471ba90553283fb9beefcfa430d84a2651ed5933"}, + {file = "black-25.9.0-py3-none-any.whl", hash = "sha256:474b34c1342cdc157d307b56c4c65bce916480c4a8f6551fdc6bf9b486a7c4ae"}, + {file = "black-25.9.0.tar.gz", hash = "sha256:0474bca9a0dd1b51791fcc507a4e02078a1c63f6d4e4ae5544b9848c7adfb619"}, +] + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +packaging = ">=22.0" +pathspec = ">=0.9.0" +platformdirs = ">=2" +pytokens = ">=0.1.10" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.10)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + [[package]] name = "certifi" version = "2025.8.3" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.7" +groups = ["main", "dev"] files = [ {file = "certifi-2025.8.3-py3-none-any.whl", hash = "sha256:f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5"}, {file = "certifi-2025.8.3.tar.gz", hash = "sha256:e564105f78ded564e3ae7c923924435e1daa7463faeab5bb932bc53ffae63407"}, @@ -346,6 +419,7 @@ version = "3.4.3" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7" +groups = ["main", "dev"] files = [ {file = "charset_normalizer-3.4.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:fb7f67a1bfa6e40b438170ebdc8158b78dc465a5a67b6dde178a46987b244a72"}, {file = "charset_normalizer-3.4.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cc9370a2da1ac13f0153780040f465839e6cccb4a1e44810124b4e22483c93fe"}, @@ -434,6 +508,7 @@ version = "2.1.3" description = "Python bindings for C-KZG-4844" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "ckzg-2.1.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:90597d18e981dcaac1c5017ea843cc96a6b30fdbefd41e4c363e26df6cd3105f"}, {file = "ckzg-2.1.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fe8673a1778102cbea878f4be1a59a3fb24d2a615bc8d00b171d2d3c0890f3ec"}, @@ -543,6 +618,7 @@ version = "0.19.0" description = "Build Nice User Interfaces In The Terminal" optional = false python-versions = "<4.0,>=3.9" +groups = ["dev"] files = [ {file = "cli_ui-0.19.0-py3-none-any.whl", hash = "sha256:1cf1b93328f7377730db29507e10bcb29ccc1427ceef45714b522d1f2055e7cd"}, {file = "cli_ui-0.19.0.tar.gz", hash = "sha256:59cdab0c6a2a6703c61b31cb75a1943076888907f015fffe15c5a8eb41a933aa"}, @@ -559,6 +635,7 @@ version = "8.2.1" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.10" +groups = ["main", "dev"] files = [ {file = "click-8.2.1-py3-none-any.whl", hash = "sha256:61a3265b914e850b85317d0b3109c7f8cd35a670f963866005d6ef1d5175a12b"}, {file = "click-8.2.1.tar.gz", hash = "sha256:27c491cc05d968d271d5a1db13e3b5a184636d9d930f148c50b038f0d0646202"}, @@ -573,10 +650,12 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main", "dev"] files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +markers = {main = "platform_system == \"Windows\""} [[package]] name = "cytoolz" @@ -584,6 +663,8 @@ version = "1.0.1" description = "Cython implementation of Toolz: High performance functional utilities" optional = false python-versions = ">=3.8" +groups = ["main"] +markers = "implementation_name == \"cpython\"" files = [ {file = "cytoolz-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:cec9af61f71fc3853eb5dca3d42eb07d1f48a4599fa502cbe92adde85f74b042"}, {file = "cytoolz-1.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:140bbd649dbda01e91add7642149a5987a7c3ccc251f2263de894b89f50b6608"}, @@ -693,12 +774,45 @@ toolz = ">=0.8.0" [package.extras] cython = ["cython"] +[[package]] +name = "datamodel-code-generator" +version = "0.34.0" +description = "Datamodel Code Generator" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "datamodel_code_generator-0.34.0-py3-none-any.whl", hash = "sha256:74d1aaf2ab27e21b6d6e28b5236f27271b8404b7fd0e856be95c2f7562d694ff"}, + {file = "datamodel_code_generator-0.34.0.tar.gz", hash = "sha256:4695bdd2c9e85049db4bdf5791f68647518d98fd589d30bd8525e941e628acf7"}, +] + +[package.dependencies] +argcomplete = ">=2.10.1,<4" +black = ">=19.10b0" +genson = ">=1.2.1,<2" +inflect = ">=4.1,<8" +isort = ">=4.3.21,<7" +jinja2 = ">=2.10.1,<4" +packaging = "*" +pydantic = ">=1.5" +pyyaml = ">=6.0.1" +tomli = {version = ">=2.2.1,<3", markers = "python_version <= \"3.11\""} + +[package.extras] +all = ["graphql-core (>=3.2.3)", "httpx (>=0.24.1)", "openapi-spec-validator (>=0.2.8,<0.7)", "prance (>=0.18.2)", "pysnooper (>=0.4.1,<2)", "ruff (>=0.9.10)"] +debug = ["pysnooper (>=0.4.1,<2)"] +graphql = ["graphql-core (>=3.2.3)"] +http = ["httpx (>=0.24.1)"] +ruff = ["ruff (>=0.9.10)"] +validation = ["openapi-spec-validator (>=0.2.8,<0.7)", "prance (>=0.18.2)"] + [[package]] name = "derive-action-signing" version = "0.0.13" description = "Python package to sign on-chain self-custodial requests for orders, transfers, deposits, withdrawals and RFQs." optional = false python-versions = "<4.0,>=3.9" +groups = ["main"] files = [ {file = "derive_action_signing-0.0.13-py3-none-any.whl", hash = "sha256:b5fb8ad9d4888a09441da9fc97d66fc0c909d1d1268c54a65c4e8bbd141d6598"}, {file = "derive_action_signing-0.0.13.tar.gz", hash = "sha256:753b3766e4c836d4cc4b36e076b14e4b9ebf28843a6192312459f718f0236d60"}, @@ -718,6 +832,7 @@ version = "0.6.2" description = "Pythonic argument parser, that will make you smile" optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "docopt-0.6.2.tar.gz", hash = "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491"}, ] @@ -728,6 +843,7 @@ version = "5.2.0" description = "eth_abi: Python utilities for working with Ethereum ABI definitions, especially encoding and decoding" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_abi-5.2.0-py3-none-any.whl", hash = "sha256:17abe47560ad753f18054f5b3089fcb588f3e3a092136a416b6c1502cb7e8877"}, {file = "eth_abi-5.2.0.tar.gz", hash = "sha256:178703fa98c07d8eecd5ae569e7e8d159e493ebb6eeb534a8fe973fbc4e40ef0"}, @@ -750,6 +866,7 @@ version = "0.13.7" description = "eth-account: Sign Ethereum transactions and messages with local private keys" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_account-0.13.7-py3-none-any.whl", hash = "sha256:39727de8c94d004ff61d10da7587509c04d2dc7eac71e04830135300bdfc6d24"}, {file = "eth_account-0.13.7.tar.gz", hash = "sha256:5853ecbcbb22e65411176f121f5f24b8afeeaf13492359d254b16d8b18c77a46"}, @@ -778,6 +895,7 @@ version = "0.7.1" description = "eth-hash: The Ethereum hashing function, keccak256, sometimes (erroneously) called sha3" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_hash-0.7.1-py3-none-any.whl", hash = "sha256:0fb1add2adf99ef28883fd6228eb447ef519ea72933535ad1a0b28c6f65f868a"}, {file = "eth_hash-0.7.1.tar.gz", hash = "sha256:d2411a403a0b0a62e8247b4117932d900ffb4c8c64b15f92620547ca5ce46be5"}, @@ -790,7 +908,7 @@ pycryptodome = {version = ">=3.6.6,<4", optional = true, markers = "extra == \"p dev = ["build (>=0.9.0)", "bump_my_version (>=0.19.0)", "ipython", "mypy (==1.10.0)", "pre-commit (>=3.4.0)", "pytest (>=7.0.0)", "pytest-xdist (>=2.4.0)", "sphinx (>=6.0.0)", "sphinx-autobuild (>=2021.3.14)", "sphinx_rtd_theme (>=1.0.0)", "towncrier (>=24,<25)", "tox (>=4.0.0)", "twine", "wheel"] docs = ["sphinx (>=6.0.0)", "sphinx-autobuild (>=2021.3.14)", "sphinx_rtd_theme (>=1.0.0)", "towncrier (>=24,<25)"] pycryptodome = ["pycryptodome (>=3.6.6,<4)"] -pysha3 = ["pysha3 (>=1.0.0,<2.0.0)", "safe-pysha3 (>=1.0.0)"] +pysha3 = ["pysha3 (>=1.0.0,<2.0.0) ; python_version < \"3.9\"", "safe-pysha3 (>=1.0.0) ; python_version >= \"3.9\""] test = ["pytest (>=7.0.0)", "pytest-xdist (>=2.4.0)"] [[package]] @@ -799,6 +917,7 @@ version = "0.8.1" description = "eth-keyfile: A library for handling the encrypted keyfiles used to store ethereum private keys" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_keyfile-0.8.1-py3-none-any.whl", hash = "sha256:65387378b82fe7e86d7cb9f8d98e6d639142661b2f6f490629da09fddbef6d64"}, {file = "eth_keyfile-0.8.1.tar.gz", hash = "sha256:9708bc31f386b52cca0969238ff35b1ac72bd7a7186f2a84b86110d3c973bec1"}, @@ -820,6 +939,7 @@ version = "0.7.0" description = "eth-keys: Common API for Ethereum key operations" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_keys-0.7.0-py3-none-any.whl", hash = "sha256:b0cdda8ffe8e5ba69c7c5ca33f153828edcace844f67aabd4542d7de38b159cf"}, {file = "eth_keys-0.7.0.tar.gz", hash = "sha256:79d24fd876201df67741de3e3fefb3f4dbcbb6ace66e47e6fe662851a4547814"}, @@ -841,6 +961,7 @@ version = "2.2.0" description = "eth-rlp: RLP definitions for common Ethereum objects in Python" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_rlp-2.2.0-py3-none-any.whl", hash = "sha256:5692d595a741fbaef1203db6a2fedffbd2506d31455a6ad378c8449ee5985c47"}, {file = "eth_rlp-2.2.0.tar.gz", hash = "sha256:5e4b2eb1b8213e303d6a232dfe35ab8c29e2d3051b86e8d359def80cd21db83d"}, @@ -863,6 +984,7 @@ version = "4.4.0" description = "eth-typing: Common type annotations for ethereum python packages" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_typing-4.4.0-py3-none-any.whl", hash = "sha256:a5e30a6e69edda7b1d1e96e9d71bab48b9bb988a77909d8d1666242c5562f841"}, {file = "eth_typing-4.4.0.tar.gz", hash = "sha256:93848083ac6bb4c20cc209ea9153a08b0a528be23337c889f89e1e5ffbe9807d"}, @@ -882,6 +1004,7 @@ version = "4.1.1" description = "eth-utils: Common utility functions for python code that interacts with Ethereum" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "eth_utils-4.1.1-py3-none-any.whl", hash = "sha256:ccbbac68a6d65cb6e294c5bcb6c6a5cec79a241c56dc5d9c345ed788c30f8534"}, {file = "eth_utils-4.1.1.tar.gz", hash = "sha256:71c8d10dec7494aeed20fa7a4d52ec2ce4a2e52fdce80aab4f5c3c19f3648b25"}, @@ -904,6 +1027,8 @@ version = "1.3.0" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"}, {file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"}, @@ -921,6 +1046,7 @@ version = "1.7.0" description = "A list-like structure which implements collections.abc.MutableSequence" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "frozenlist-1.7.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:cc4df77d638aa2ed703b878dd093725b72a824c3c546c076e8fdf276f78ee84a"}, {file = "frozenlist-1.7.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:716a9973a2cc963160394f701964fe25012600f3d311f60c790400b00e568b61"}, @@ -1028,12 +1154,25 @@ files = [ {file = "frozenlist-1.7.0.tar.gz", hash = "sha256:2e310d81923c2437ea8670467121cc3e9b0f76d3043cc1d2331d56c7fb7a3a8f"}, ] +[[package]] +name = "genson" +version = "1.3.0" +description = "GenSON is a powerful, user-friendly JSON Schema generator." +optional = false +python-versions = "*" +groups = ["dev"] +files = [ + {file = "genson-1.3.0-py3-none-any.whl", hash = "sha256:468feccd00274cc7e4c09e84b08704270ba8d95232aa280f65b986139cec67f7"}, + {file = "genson-1.3.0.tar.gz", hash = "sha256:e02db9ac2e3fd29e65b5286f7135762e2cd8a986537c075b06fc5f1517308e37"}, +] + [[package]] name = "ghp-import" version = "2.1.0" description = "Copy your docs directly to the gh-pages branch." optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "ghp-import-2.1.0.tar.gz", hash = "sha256:9c535c4c61193c2df8871222567d7fd7e5014d835f97dc7b7439069e2413d343"}, {file = "ghp_import-2.1.0-py3-none-any.whl", hash = "sha256:8337dd7b50877f163d4c0289bc1f1c7f127550241988d568c1db512c4324a619"}, @@ -1051,6 +1190,7 @@ version = "1.3.1" description = "hexbytes: Python `bytes` subclass that decodes hex, with a readable console output" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "hexbytes-1.3.1-py3-none-any.whl", hash = "sha256:da01ff24a1a9a2b1881c4b85f0e9f9b0f51b526b379ffa23832ae7899d29c2c7"}, {file = "hexbytes-1.3.1.tar.gz", hash = "sha256:a657eebebdfe27254336f98d8af6e2236f3f83aed164b87466b6cf6c5f5a4765"}, @@ -1067,6 +1207,7 @@ version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" +groups = ["main", "dev"] files = [ {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, @@ -1075,23 +1216,65 @@ files = [ [package.extras] all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] +[[package]] +name = "inflect" +version = "7.5.0" +description = "Correctly generate plurals, singular nouns, ordinals, indefinite articles" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "inflect-7.5.0-py3-none-any.whl", hash = "sha256:2aea70e5e70c35d8350b8097396ec155ffd68def678c7ff97f51aa69c1d92344"}, + {file = "inflect-7.5.0.tar.gz", hash = "sha256:faf19801c3742ed5a05a8ce388e0d8fe1a07f8d095c82201eb904f5d27ad571f"}, +] + +[package.dependencies] +more_itertools = ">=8.5.0" +typeguard = ">=4.0.1" + +[package.extras] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\""] +cover = ["pytest-cov"] +doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +enabler = ["pytest-enabler (>=2.2)"] +test = ["pygments", "pytest (>=6,!=8.1.*)"] +type = ["pytest-mypy"] + [[package]] name = "iniconfig" version = "2.1.0" description = "brain-dead simple config-ini parsing" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"}, {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"}, ] +[[package]] +name = "isort" +version = "6.0.1" +description = "A Python utility / library to sort Python imports." +optional = false +python-versions = ">=3.9.0" +groups = ["dev"] +files = [ + {file = "isort-6.0.1-py3-none-any.whl", hash = "sha256:2dc5d7f65c9678d94c88dfc29161a320eec67328bc97aad576874cb4be1e9615"}, + {file = "isort-6.0.1.tar.gz", hash = "sha256:1cb5df28dfbc742e490c5e41bad6da41b805b0a8be7bc93cd0fb2a8a890ac450"}, +] + +[package.extras] +colors = ["colorama"] +plugins = ["setuptools"] + [[package]] name = "jinja2" version = "3.1.6" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"}, {file = "jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"}, @@ -1109,6 +1292,7 @@ version = "4.25.1" description = "An implementation of JSON Schema validation for Python" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "jsonschema-4.25.1-py3-none-any.whl", hash = "sha256:3fba0169e345c7175110351d456342c364814cfcf3b964ba4587f22915230a63"}, {file = "jsonschema-4.25.1.tar.gz", hash = "sha256:e4a9655ce0da0c0b67a085847e00a3a51449e1157f4f75e9fb5aa545e122eb85"}, @@ -1130,6 +1314,7 @@ version = "2025.9.1" description = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe"}, {file = "jsonschema_specifications-2025.9.1.tar.gz", hash = "sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d"}, @@ -1144,6 +1329,7 @@ version = "1.3.0" description = "An Dict like LRU container." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "lru-dict-1.3.0.tar.gz", hash = "sha256:54fd1966d6bd1fcde781596cb86068214edeebff1db13a2cea11079e3fd07b6b"}, {file = "lru_dict-1.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4073333894db9840f066226d50e6f914a2240711c87d60885d8c940b69a6673f"}, @@ -1237,6 +1423,7 @@ version = "3.9" description = "Python implementation of John Gruber's Markdown." optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "markdown-3.9-py3-none-any.whl", hash = "sha256:9f4d91ed810864ea88a6f32c07ba8bee1346c0cc1f6b1f9f6c822f2a9667d280"}, {file = "markdown-3.9.tar.gz", hash = "sha256:d2900fe1782bd33bdbbd56859defef70c2e78fc46668f8eb9df3128138f2cb6a"}, @@ -1252,6 +1439,7 @@ version = "4.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" optional = false python-versions = ">=3.10" +groups = ["main"] files = [ {file = "markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147"}, {file = "markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3"}, @@ -1275,6 +1463,7 @@ version = "3.0.2" description = "Safely add untrusted strings to HTML/XML markup." optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"}, {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"}, @@ -1345,6 +1534,7 @@ version = "0.1.2" description = "Markdown URL utilities" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, @@ -1356,6 +1546,7 @@ version = "1.3.4" description = "A deep merge function for 🐍." optional = false python-versions = ">=3.6" +groups = ["dev"] files = [ {file = "mergedeep-1.3.4-py3-none-any.whl", hash = "sha256:70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307"}, {file = "mergedeep-1.3.4.tar.gz", hash = "sha256:0096d52e9dad9939c3d975a774666af186eda617e6ca84df4c94dec30004f2a8"}, @@ -1367,6 +1558,7 @@ version = "1.6.1" description = "Project documentation with Markdown." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "mkdocs-1.6.1-py3-none-any.whl", hash = "sha256:db91759624d1647f3f34aa0c3f327dd2601beae39a366d6e064c03468d35c20e"}, {file = "mkdocs-1.6.1.tar.gz", hash = "sha256:7b432f01d928c084353ab39c57282f29f92136665bdd6abf7c1ec8d822ef86f2"}, @@ -1389,7 +1581,7 @@ watchdog = ">=2.0" [package.extras] i18n = ["babel (>=2.9.0)"] -min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-import (==1.0)", "importlib-metadata (==4.4)", "jinja2 (==2.11.1)", "markdown (==3.3.6)", "markupsafe (==2.0.1)", "mergedeep (==1.3.4)", "mkdocs-get-deps (==0.2.0)", "packaging (==20.5)", "pathspec (==0.11.1)", "pyyaml (==5.1)", "pyyaml-env-tag (==0.1)", "watchdog (==2.0)"] +min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4) ; platform_system == \"Windows\"", "ghp-import (==1.0)", "importlib-metadata (==4.4) ; python_version < \"3.10\"", "jinja2 (==2.11.1)", "markdown (==3.3.6)", "markupsafe (==2.0.1)", "mergedeep (==1.3.4)", "mkdocs-get-deps (==0.2.0)", "packaging (==20.5)", "pathspec (==0.11.1)", "pyyaml (==5.1)", "pyyaml-env-tag (==0.1)", "watchdog (==2.0)"] [[package]] name = "mkdocs-autorefs" @@ -1397,6 +1589,7 @@ version = "0.4.1" description = "Automatically link across pages in MkDocs." optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "mkdocs-autorefs-0.4.1.tar.gz", hash = "sha256:70748a7bd025f9ecd6d6feeba8ba63f8e891a1af55f48e366d6d6e78493aba84"}, {file = "mkdocs_autorefs-0.4.1-py3-none-any.whl", hash = "sha256:a2248a9501b29dc0cc8ba4c09f4f47ff121945f6ce33d760f145d6f89d313f5b"}, @@ -1412,6 +1605,7 @@ version = "0.2.0" description = "MkDocs extension that lists all dependencies according to a mkdocs.yml file" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "mkdocs_get_deps-0.2.0-py3-none-any.whl", hash = "sha256:2bf11d0b133e77a0dd036abeeb06dec8775e46efa526dc70667d8863eefc6134"}, {file = "mkdocs_get_deps-0.2.0.tar.gz", hash = "sha256:162b3d129c7fad9b19abfdcb9c1458a651628e4b1dea628ac68790fb3061c60c"}, @@ -1428,6 +1622,7 @@ version = "3.9.1" description = "Mkdocs Markdown includer plugin." optional = false python-versions = ">=3.6" +groups = ["dev"] files = [ {file = "mkdocs_include_markdown_plugin-3.9.1-py3-none-any.whl", hash = "sha256:f33687e29ac66d045ba181ea50f054646b0090b42b0a4318f08e7f1d1235e6f6"}, {file = "mkdocs_include_markdown_plugin-3.9.1.tar.gz", hash = "sha256:5e5698e78d7fea111be9873a456089daa333497988405acaac8eba2924a19152"}, @@ -1443,6 +1638,7 @@ version = "8.5.11" description = "Documentation that simply works" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "mkdocs_material-8.5.11-py3-none-any.whl", hash = "sha256:c907b4b052240a5778074a30a78f31a1f8ff82d7012356dc26898b97559f082e"}, {file = "mkdocs_material-8.5.11.tar.gz", hash = "sha256:b0ea0513fd8cab323e8a825d6692ea07fa83e917bb5db042e523afecc7064ab7"}, @@ -1463,17 +1659,31 @@ version = "1.3.1" description = "Extension pack for Python Markdown and MkDocs Material." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "mkdocs_material_extensions-1.3.1-py3-none-any.whl", hash = "sha256:adff8b62700b25cb77b53358dad940f3ef973dd6db797907c49e3c2ef3ab4e31"}, {file = "mkdocs_material_extensions-1.3.1.tar.gz", hash = "sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443"}, ] +[[package]] +name = "more-itertools" +version = "10.8.0" +description = "More routines for operating on iterables, beyond itertools" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "more_itertools-10.8.0-py3-none-any.whl", hash = "sha256:52d4362373dcf7c52546bc4af9a86ee7c4579df9a8dc268be0a2f949d376cc9b"}, + {file = "more_itertools-10.8.0.tar.gz", hash = "sha256:f638ddf8a1a0d134181275fb5d58b086ead7c6a72429ad725c67503f13ba30bd"}, +] + [[package]] name = "multidict" version = "6.6.4" description = "multidict implementation" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "multidict-6.6.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:b8aa6f0bd8125ddd04a6593437bad6a7e70f300ff4180a531654aa2ab3f6d58f"}, {file = "multidict-6.6.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b9e5853bbd7264baca42ffc53391b490d65fe62849bf2c690fa3f6273dbcd0cb"}, @@ -1590,12 +1800,25 @@ files = [ [package.dependencies] typing-extensions = {version = ">=4.1.0", markers = "python_version < \"3.11\""} +[[package]] +name = "mypy-extensions" +version = "1.1.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505"}, + {file = "mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"}, +] + [[package]] name = "numpy" version = "1.26.4" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "numpy-1.26.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9ff0f4f29c51e2803569d7a51c2304de5554655a60c5d776e35b4a41413830d0"}, {file = "numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2e4ee3380d6de9c9ec04745830fd9e2eccb3e6cf790d39d7b98ffd19b0dd754a"}, @@ -1641,6 +1864,7 @@ version = "25.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"}, {file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"}, @@ -1652,6 +1876,7 @@ version = "2.3.2" description = "Powerful data structures for data analysis, time series, and statistics" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "pandas-2.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:52bc29a946304c360561974c6542d1dd628ddafa69134a7131fdfd6a5d7a1a35"}, {file = "pandas-2.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:220cc5c35ffaa764dd5bb17cf42df283b5cb7fdf49e10a7b053a06c9cb48ee2b"}, @@ -1738,6 +1963,7 @@ version = "0.10.0" description = "(Soon to be) the fastest pure-Python PEG parser I could muster" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "parsimonious-0.10.0-py3-none-any.whl", hash = "sha256:982ab435fabe86519b57f6b35610aa4e4e977e9f02a14353edf4bbc75369fc0f"}, {file = "parsimonious-0.10.0.tar.gz", hash = "sha256:8281600da180ec8ae35427a4ab4f7b82bfec1e3d1e52f80cb60ea82b9512501c"}, @@ -1752,6 +1978,7 @@ version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -1763,6 +1990,7 @@ version = "4.4.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "platformdirs-4.4.0-py3-none-any.whl", hash = "sha256:abd01743f24e5287cd7a5db3752faf1a2d65353f38ec26d98e25a6db65958c85"}, {file = "platformdirs-4.4.0.tar.gz", hash = "sha256:ca753cf4d81dc309bc67b0ea38fd15dc97bc30ce419a7f58d13eb3bf14c4febf"}, @@ -1779,6 +2007,7 @@ version = "1.6.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"}, {file = "pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3"}, @@ -1794,6 +2023,7 @@ version = "0.3.2" description = "Accelerated property cache" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "propcache-0.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:22d9962a358aedbb7a2e36187ff273adeaab9743373a272976d2e348d08c7770"}, {file = "propcache-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0d0fda578d1dc3f77b6b5a5dce3b9ad69a8250a891760a548df850a5e8da87f3"}, @@ -1901,6 +2131,7 @@ version = "6.32.1" description = "" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "protobuf-6.32.1-cp310-abi3-win32.whl", hash = "sha256:a8a32a84bc9f2aad712041b8b366190f71dde248926da517bde9e832e4412085"}, {file = "protobuf-6.32.1-cp310-abi3-win_amd64.whl", hash = "sha256:b00a7d8c25fa471f16bc8153d0e53d6c9e827f0953f3c09aaa4331c718cae5e1"}, @@ -1919,6 +2150,7 @@ version = "3.23.0" description = "Cryptographic library for Python" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main"] files = [ {file = "pycryptodome-3.23.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a176b79c49af27d7f6c12e4b178b0824626f40a7b9fed08f712291b6d54bf566"}, {file = "pycryptodome-3.23.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:573a0b3017e06f2cffd27d92ef22e46aa3be87a2d317a5abf7cc0e84e321bd75"}, @@ -1969,6 +2201,7 @@ version = "2.11.9" description = "Data validation using Python type hints" optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "pydantic-2.11.9-py3-none-any.whl", hash = "sha256:c42dd626f5cfc1c6950ce6205ea58c93efa406da65f479dcb4029d5934857da2"}, {file = "pydantic-2.11.9.tar.gz", hash = "sha256:6b8ffda597a14812a7975c90b82a8a2e777d9257aba3453f973acd3c032a18e2"}, @@ -1982,7 +2215,7 @@ typing-inspection = ">=0.4.0" [package.extras] email = ["email-validator (>=2.0.0)"] -timezone = ["tzdata"] +timezone = ["tzdata ; python_version >= \"3.9\" and platform_system == \"Windows\""] [[package]] name = "pydantic-core" @@ -1990,6 +2223,7 @@ version = "2.33.2" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "pydantic_core-2.33.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:2b3d326aaef0c0399d9afffeb6367d5e26ddc24d351dbc9c636840ac355dc5d8"}, {file = "pydantic_core-2.33.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0e5b2671f05ba48b94cb90ce55d8bdcaaedb8ba00cc5359f6810fc918713983d"}, @@ -2101,6 +2335,7 @@ version = "2.19.2" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" +groups = ["main", "dev"] files = [ {file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"}, {file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"}, @@ -2115,6 +2350,7 @@ version = "10.16.1" description = "Extension pack for Python Markdown." optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "pymdown_extensions-10.16.1-py3-none-any.whl", hash = "sha256:d6ba157a6c03146a7fb122b2b9a121300056384eafeec9c9f9e584adfdb2a32d"}, {file = "pymdown_extensions-10.16.1.tar.gz", hash = "sha256:aace82bcccba3efc03e25d584e6a22d27a8e17caa3f4dd9f207e49b787aa9a91"}, @@ -2133,6 +2369,7 @@ version = "7.4.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, @@ -2155,6 +2392,7 @@ version = "13.0" description = "pytest plugin to re-run tests to eliminate flaky failures" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "pytest-rerunfailures-13.0.tar.gz", hash = "sha256:e132dbe420bc476f544b96e7036edd0a69707574209b6677263c950d19b09199"}, {file = "pytest_rerunfailures-13.0-py3-none-any.whl", hash = "sha256:34919cb3fcb1f8e5d4b940aa75ccdea9661bade925091873b7c6fa5548333069"}, @@ -2170,6 +2408,7 @@ version = "2.9.0.post0" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +groups = ["main", "dev"] files = [ {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, @@ -2184,6 +2423,7 @@ version = "1.1.1" description = "Read key-value pairs from a .env file and set them as environment variables" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc"}, {file = "python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab"}, @@ -2192,12 +2432,28 @@ files = [ [package.extras] cli = ["click (>=5.0)"] +[[package]] +name = "pytokens" +version = "0.1.10" +description = "A Fast, spec compliant Python 3.12+ tokenizer that runs on older Pythons." +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "pytokens-0.1.10-py3-none-any.whl", hash = "sha256:db7b72284e480e69fb085d9f251f66b3d2df8b7166059261258ff35f50fb711b"}, + {file = "pytokens-0.1.10.tar.gz", hash = "sha256:c9a4bfa0be1d26aebce03e6884ba454e842f186a59ea43a6d3b25af58223c044"}, +] + +[package.extras] +dev = ["black", "build", "mypy", "pytest", "pytest-cov", "setuptools", "tox", "twine", "wheel"] + [[package]] name = "pytz" version = "2025.2" description = "World timezone definitions, modern and historical" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00"}, {file = "pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3"}, @@ -2209,6 +2465,7 @@ version = "16.0.0" description = "Unicode normalization forms (NFC, NFKC, NFD, NFKD). A library independent of the Python core Unicode database." optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "pyunormalize-16.0.0-py3-none-any.whl", hash = "sha256:c647d95e5d1e2ea9a2f448d1d95d8518348df24eab5c3fd32d2b5c3300a49152"}, {file = "pyunormalize-16.0.0.tar.gz", hash = "sha256:2e1dfbb4a118154ae26f70710426a52a364b926c9191f764601f5a8cb12761f7"}, @@ -2220,6 +2477,8 @@ version = "311" description = "Python for Window Extensions" optional = false python-versions = "*" +groups = ["main"] +markers = "platform_system == \"Windows\"" files = [ {file = "pywin32-311-cp310-cp310-win32.whl", hash = "sha256:d03ff496d2a0cd4a5893504789d4a15399133fe82517455e78bad62efbb7f0a3"}, {file = "pywin32-311-cp310-cp310-win_amd64.whl", hash = "sha256:797c2772017851984b97180b0bebe4b620bb86328e8a884bb626156295a63b3b"}, @@ -2249,6 +2508,7 @@ version = "6.0.2" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, @@ -2311,6 +2571,7 @@ version = "1.1" description = "A custom YAML tag for referencing environment variables in YAML files." optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "pyyaml_env_tag-1.1-py3-none-any.whl", hash = "sha256:17109e1a528561e32f026364712fee1264bc2ea6715120891174ed1b980d2e04"}, {file = "pyyaml_env_tag-1.1.tar.gz", hash = "sha256:2eb38b75a2d21ee0475d6d97ec19c63287a7e140231e4214969d0eac923cd7ff"}, @@ -2325,6 +2586,7 @@ version = "0.36.2" description = "JSON Referencing + Python" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "referencing-0.36.2-py3-none-any.whl", hash = "sha256:e8699adbbf8b5c7de96d8ffa0eb5c158b3beafce084968e2ea8bb08c6794dcd0"}, {file = "referencing-0.36.2.tar.gz", hash = "sha256:df2e89862cd09deabbdba16944cc3f10feb6b3e6f18e902f7cc25609a34775aa"}, @@ -2341,6 +2603,7 @@ version = "2025.9.1" description = "Alternative regular expression module, to replace re." optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "regex-2025.9.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:c5aa2a6a73bf218515484b36a0d20c6ad9dc63f6339ff6224147b0e2c095ee55"}, {file = "regex-2025.9.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8c2ff5c01d5e47ad5fc9d31bcd61e78c2fa0068ed00cab86b7320214446da766"}, @@ -2437,6 +2700,7 @@ version = "2.32.5" description = "Python HTTP for Humans." optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6"}, {file = "requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf"}, @@ -2458,6 +2722,7 @@ version = "0.26.0" description = "Make your functions return something meaningful, typed, and safe!" optional = false python-versions = "<4.0,>=3.10" +groups = ["main"] files = [ {file = "returns-0.26.0-py3-none-any.whl", hash = "sha256:7cae94c730d6c56ffd9d0f583f7a2c0b32cfe17d141837150c8e6cff3eb30d71"}, {file = "returns-0.26.0.tar.gz", hash = "sha256:180320e0f6e9ea9845330ccfc020f542330f05b7250941d9b9b7c00203fcc3da"}, @@ -2476,6 +2741,7 @@ version = "14.1.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.8.0" +groups = ["main"] files = [ {file = "rich-14.1.0-py3-none-any.whl", hash = "sha256:536f5f1785986d6dbdea3c75205c473f970777b4a0d6c6dd1b696aa05a3fa04f"}, {file = "rich-14.1.0.tar.gz", hash = "sha256:e497a48b844b0320d45007cdebfeaeed8db2a4f4bcf49f15e455cfc4af11eaa8"}, @@ -2494,6 +2760,7 @@ version = "1.9.0" description = "Format click help output nicely with rich" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "rich_click-1.9.0-py3-none-any.whl", hash = "sha256:28e6eb34a99c8c45eb910259078bc54dd78cf6f18cc75cb77a50012a98458664"}, {file = "rich_click-1.9.0.tar.gz", hash = "sha256:212a19875b1e485803a5448130a9157b04c0d0befcc2bc29cb64d3577b93b005"}, @@ -2506,7 +2773,7 @@ typing-extensions = {version = ">=4", markers = "python_version < \"3.11\""} [package.extras] dev = ["inline-snapshot (>=0.24)", "jsonschema (>=4)", "mypy (>=1.14.1)", "nodeenv (>=1.9.1)", "packaging (>=25)", "pre-commit (>=3.5)", "pytest (>=8.3.5)", "pytest-cov (>=5)", "rich-codex (>=1.2.11)", "ruff (>=0.12.4)", "typer (>=0.15)", "types-setuptools (>=75.8.0.20250110)"] -docs = ["markdown-include (>=0.8.1)", "mike (>=2.1.3)", "mkdocs-github-admonitions-plugin (>=0.1.1)", "mkdocs-glightbox (>=0.4)", "mkdocs-include-markdown-plugin (>=7.1.7)", "mkdocs-material-extensions (>=1.3.1)", "mkdocs-material[imaging] (>=9.5.18,<9.6.0)", "mkdocs-redirects (>=1.2.2)", "mkdocs-rss-plugin (>=1.15)", "mkdocs[docs] (>=1.6.1)", "mkdocstrings[python] (>=0.26.1)", "rich-codex (>=1.2.11)", "typer (>=0.15)"] +docs = ["markdown-include (>=0.8.1)", "mike (>=2.1.3)", "mkdocs-github-admonitions-plugin (>=0.1.1)", "mkdocs-glightbox (>=0.4)", "mkdocs-include-markdown-plugin (>=7.1.7) ; python_version >= \"3.9\"", "mkdocs-material-extensions (>=1.3.1)", "mkdocs-material[imaging] (>=9.5.18,<9.6.0)", "mkdocs-redirects (>=1.2.2)", "mkdocs-rss-plugin (>=1.15)", "mkdocs[docs] (>=1.6.1)", "mkdocstrings[python] (>=0.26.1)", "rich-codex (>=1.2.11)", "typer (>=0.15)"] [[package]] name = "rlp" @@ -2514,6 +2781,7 @@ version = "4.1.0" description = "rlp: A package for Recursive Length Prefix encoding and decoding" optional = false python-versions = "<4,>=3.8" +groups = ["main"] files = [ {file = "rlp-4.1.0-py3-none-any.whl", hash = "sha256:8eca394c579bad34ee0b937aecb96a57052ff3716e19c7a578883e767bc5da6f"}, {file = "rlp-4.1.0.tar.gz", hash = "sha256:be07564270a96f3e225e2c107db263de96b5bc1f27722d2855bd3459a08e95a9"}, @@ -2534,6 +2802,7 @@ version = "0.27.1" description = "Python bindings to Rust's persistent data structures (rpds)" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "rpds_py-0.27.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:68afeec26d42ab3b47e541b272166a0b4400313946871cba3ed3a4fc0cab1cef"}, {file = "rpds_py-0.27.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:74e5b2f7bb6fa38b1b10546d27acbacf2a022a8b5543efb06cfebc72a59c85be"}, @@ -2698,6 +2967,7 @@ version = "0.13.0" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "ruff-0.13.0-py3-none-linux_armv6l.whl", hash = "sha256:137f3d65d58ee828ae136a12d1dc33d992773d8f7644bc6b82714570f31b2004"}, {file = "ruff-0.13.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:21ae48151b66e71fd111b7d79f9ad358814ed58c339631450c66a4be33cc28b9"}, @@ -2726,6 +2996,7 @@ version = "0.7.7" description = "Simple data validation library" optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "schema-0.7.7-py2.py3-none-any.whl", hash = "sha256:5d976a5b50f36e74e2157b47097b60002bd4d42e65425fcc9c9befadb4255dde"}, {file = "schema-0.7.7.tar.gz", hash = "sha256:7da553abd2958a19dc2547c388cde53398b39196175a9be59ea1caf5ab0a1807"}, @@ -2737,6 +3008,7 @@ version = "2.13.0" description = "Python helper for Semantic Versioning (http://semver.org/)" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +groups = ["dev"] files = [ {file = "semver-2.13.0-py2.py3-none-any.whl", hash = "sha256:ced8b23dceb22134307c1b8abfa523da14198793d9787ac838e70e29e77458d4"}, {file = "semver-2.13.0.tar.gz", hash = "sha256:fa0fe2722ee1c3f57eac478820c3a5ae2f624af8264cbdf9000c980ff7f75e3f"}, @@ -2748,19 +3020,20 @@ version = "75.9.1" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "setuptools-75.9.1-py3-none-any.whl", hash = "sha256:0a6f876d62f4d978ca1a11ab4daf728d1357731f978543ff18ecdbf9fd071f73"}, {file = "setuptools-75.9.1.tar.gz", hash = "sha256:b6eca2c3070cdc82f71b4cb4bb2946bc0760a210d11362278cf1ff394e6ea32c"}, ] [package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)", "ruff (>=0.8.0)"] -core = ["importlib_metadata (>=6)", "jaraco.collections", "jaraco.functools (>=4)", "jaraco.text (>=3.7)", "more_itertools", "more_itertools (>=8.8)", "packaging", "packaging (>=24.2)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1)", "wheel (>=0.43.0)"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\"", "ruff (>=0.8.0) ; sys_platform != \"cygwin\""] +core = ["importlib_metadata (>=6) ; python_version < \"3.10\"", "jaraco.collections", "jaraco.functools (>=4)", "jaraco.text (>=3.7)", "more_itertools", "more_itertools (>=8.8)", "packaging", "packaging (>=24.2)", "platformdirs (>=4.2.2)", "tomli (>=2.0.1) ; python_version < \"3.11\"", "wheel (>=0.43.0)"] cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier", "towncrier (<24.7)"] enabler = ["pytest-enabler (>=2.2)"] -test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.7.2)", "jaraco.test (>=5.5)", "packaging (>=24.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] -type = ["importlib_metadata (>=7.0.2)", "jaraco.develop (>=7.21)", "mypy (==1.14.*)", "pytest-mypy"] +test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21) ; python_version >= \"3.9\" and sys_platform != \"cygwin\"", "jaraco.envs (>=2.2)", "jaraco.path (>=3.7.2)", "jaraco.test (>=5.5)", "packaging (>=24.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-home (>=0.5)", "pytest-perf ; sys_platform != \"cygwin\"", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] +type = ["importlib_metadata (>=7.0.2) ; python_version < \"3.10\"", "jaraco.develop (>=7.21) ; sys_platform != \"cygwin\"", "mypy (==1.14.*)", "pytest-mypy"] [[package]] name = "six" @@ -2768,6 +3041,7 @@ version = "1.17.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +groups = ["main", "dev"] files = [ {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, @@ -2779,6 +3053,7 @@ version = "0.9.0" description = "Pretty-print tabular data" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f"}, {file = "tabulate-0.9.0.tar.gz", hash = "sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c"}, @@ -2793,6 +3068,7 @@ version = "6.11.0" description = "Bump software releases" optional = false python-versions = ">=3.7,<4.0" +groups = ["dev"] files = [ {file = "tbump-6.11.0-py3-none-any.whl", hash = "sha256:6b181fe6f3ae84ce0b9af8cc2009a8bca41ded34e73f623a7413b9684f1b4526"}, {file = "tbump-6.11.0.tar.gz", hash = "sha256:385e710eedf0a8a6ff959cf1e9f3cfd17c873617132fc0ec5f629af0c355c870"}, @@ -2810,6 +3086,8 @@ version = "2.2.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, @@ -2851,6 +3129,7 @@ version = "0.11.8" description = "Style preserving TOML library" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "tomlkit-0.11.8-py3-none-any.whl", hash = "sha256:8c726c4c202bdb148667835f68d68780b9a003a9ec34167b6c673b38eff2a171"}, {file = "tomlkit-0.11.8.tar.gz", hash = "sha256:9330fc7faa1db67b541b28e62018c17d20be733177d290a13b24c62d1614e0c3"}, @@ -2862,17 +3141,35 @@ version = "1.0.0" description = "List processing tools and functional utilities" optional = false python-versions = ">=3.8" +groups = ["main"] +markers = "implementation_name == \"cpython\" or implementation_name == \"pypy\"" files = [ {file = "toolz-1.0.0-py3-none-any.whl", hash = "sha256:292c8f1c4e7516bf9086f8850935c799a874039c8bcf959d47b600e4c44a6236"}, {file = "toolz-1.0.0.tar.gz", hash = "sha256:2c86e3d9a04798ac556793bced838816296a2f085017664e4995cb40a1047a02"}, ] +[[package]] +name = "typeguard" +version = "4.4.4" +description = "Run-time type checker for Python" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "typeguard-4.4.4-py3-none-any.whl", hash = "sha256:b5f562281b6bfa1f5492470464730ef001646128b180769880468bd84b68b09e"}, + {file = "typeguard-4.4.4.tar.gz", hash = "sha256:3a7fd2dffb705d4d0efaed4306a704c89b9dee850b688f060a8b1615a79e5f74"}, +] + +[package.dependencies] +typing_extensions = ">=4.14.0" + [[package]] name = "typing-extensions" version = "4.15.0" description = "Backported and Experimental Type Hints for Python 3.9+" optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, @@ -2884,6 +3181,7 @@ version = "0.4.1" description = "Runtime typing introspection tools" optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "typing_inspection-0.4.1-py3-none-any.whl", hash = "sha256:389055682238f53b04f7badcb49b989835495a96700ced5dab2d8feae4b26f51"}, {file = "typing_inspection-0.4.1.tar.gz", hash = "sha256:6ae134cc0203c33377d43188d4064e9b357dba58cff3185f22924610e70a9d28"}, @@ -2898,6 +3196,7 @@ version = "2025.2" description = "Provider of IANA time zone data" optional = false python-versions = ">=2" +groups = ["main"] files = [ {file = "tzdata-2025.2-py2.py3-none-any.whl", hash = "sha256:1a403fada01ff9221ca8044d701868fa132215d84beb92242d9acd2147f667a8"}, {file = "tzdata-2025.2.tar.gz", hash = "sha256:b60a638fcc0daffadf82fe0f57e53d06bdec2f36c4df66280ae79bce6bd6f2b9"}, @@ -2909,6 +3208,7 @@ version = "1.4.0" description = "ASCII transliterations of Unicode text" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "Unidecode-1.4.0-py3-none-any.whl", hash = "sha256:c3c7606c27503ad8d501270406e345ddb480a7b5f38827eafe4fa82a137f0021"}, {file = "Unidecode-1.4.0.tar.gz", hash = "sha256:ce35985008338b676573023acc382d62c264f307c8f7963733405add37ea2b23"}, @@ -2920,13 +3220,14 @@ version = "2.5.0" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.9" +groups = ["main", "dev"] files = [ {file = "urllib3-2.5.0-py3-none-any.whl", hash = "sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc"}, {file = "urllib3-2.5.0.tar.gz", hash = "sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760"}, ] [package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +brotli = ["brotli (>=1.0.9) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=0.8.0) ; platform_python_implementation != \"CPython\""] h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] @@ -2937,6 +3238,7 @@ version = "6.0.0" description = "Filesystem events monitoring" optional = false python-versions = ">=3.9" +groups = ["dev"] files = [ {file = "watchdog-6.0.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d1cdb490583ebd691c012b3d6dae011000fe42edb7a82ece80965b42abd61f26"}, {file = "watchdog-6.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:bc64ab3bdb6a04d69d4023b29422170b74681784ffb9463ed4870cf2f3e66112"}, @@ -2979,6 +3281,7 @@ version = "6.11.0" description = "web3.py" optional = false python-versions = ">=3.7.2" +groups = ["main"] files = [ {file = "web3-6.11.0-py3-none-any.whl", hash = "sha256:44e79da6a4765eacf137f2f388e37aa0c1e24a93bdfb462cffe9441d1be3d509"}, {file = "web3-6.11.0.tar.gz", hash = "sha256:050dea52ae73d787272e7ecba7249f096595938c90cce1a384c20375c6b0f720"}, @@ -3002,7 +3305,7 @@ typing-extensions = ">=4.0.1" websockets = ">=10.0.0" [package.extras] -dev = ["black (>=22.1.0)", "build (>=0.9.0)", "bumpversion", "eth-tester[py-evm] (==v0.9.1-b.1)", "flake8 (==3.8.3)", "flaky (>=3.7.0)", "hypothesis (>=3.31.2)", "importlib-metadata (<5.0)", "ipfshttpclient (==0.8.0a2)", "isort (>=5.11.0)", "mypy (==1.4.1)", "py-geth (>=3.11.0)", "pytest (>=7.0.0)", "pytest-asyncio (>=0.18.1)", "pytest-mock (>=1.10)", "pytest-watch (>=4.2)", "pytest-xdist (>=1.29)", "setuptools (>=38.6.0)", "sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.0.0)", "towncrier (>=21,<22)", "tox (>=3.18.0)", "tqdm (>4.32)", "twine (>=1.13)", "types-protobuf (==3.19.13)", "types-requests (>=2.26.1)", "types-setuptools (>=57.4.4)", "when-changed (>=0.3.0)"] +dev = ["black (>=22.1.0)", "build (>=0.9.0)", "bumpversion", "eth-tester[py-evm] (==v0.9.1-b.1)", "flake8 (==3.8.3)", "flaky (>=3.7.0)", "hypothesis (>=3.31.2)", "importlib-metadata (<5.0) ; python_version < \"3.8\"", "ipfshttpclient (==0.8.0a2)", "isort (>=5.11.0)", "mypy (==1.4.1)", "py-geth (>=3.11.0)", "pytest (>=7.0.0)", "pytest-asyncio (>=0.18.1)", "pytest-mock (>=1.10)", "pytest-watch (>=4.2)", "pytest-xdist (>=1.29)", "setuptools (>=38.6.0)", "sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.0.0)", "towncrier (>=21,<22)", "tox (>=3.18.0)", "tqdm (>4.32)", "twine (>=1.13)", "types-protobuf (==3.19.13)", "types-requests (>=2.26.1)", "types-setuptools (>=57.4.4)", "when-changed (>=0.3.0)"] docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.0.0)", "towncrier (>=21,<22)"] ipfs = ["ipfshttpclient (==0.8.0a2)"] linter = ["black (>=22.1.0)", "flake8 (==3.8.3)", "isort (>=5.11.0)", "mypy (==1.4.1)", "types-protobuf (==3.19.13)", "types-requests (>=2.26.1)", "types-setuptools (>=57.4.4)"] @@ -3014,6 +3317,7 @@ version = "0.59.0" description = "WebSocket client for Python with low level API options" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +groups = ["main"] files = [ {file = "websocket-client-0.59.0.tar.gz", hash = "sha256:d376bd60eace9d437ab6d7ee16f4ab4e821c9dae591e1b783c58ebd8aaf80c5c"}, {file = "websocket_client-0.59.0-py2.py3-none-any.whl", hash = "sha256:2e50d26ca593f70aba7b13a489435ef88b8fc3b5c5643c1ce8808ff9b40f0b32"}, @@ -3028,6 +3332,7 @@ version = "15.0.1" description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "websockets-15.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d63efaa0cd96cf0c5fe4d581521d9fa87744540d4bc999ae6e08595a1014b45b"}, {file = "websockets-15.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac60e3b188ec7574cb761b08d50fcedf9d77f1530352db4eef1707fe9dee7205"}, @@ -3106,6 +3411,7 @@ version = "1.20.1" description = "Yet another URL library" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "yarl-1.20.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:6032e6da6abd41e4acda34d75a816012717000fa6839f37124a47fcefc49bec4"}, {file = "yarl-1.20.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2c7b34d804b8cf9b214f05015c4fee2ebe7ed05cf581e7192c06555c71f4446a"}, @@ -3219,6 +3525,6 @@ multidict = ">=4.0" propcache = ">=0.2.1" [metadata] -lock-version = "2.0" +lock-version = "2.1" python-versions = ">=3.10,<=3.12" -content-hash = "c568f60f4b19074dc19a2d943b72fb392d633747f3daca2c0a7c1f6807406439" +content-hash = "a866f9946e573fcaf033f95da79733a58681ca67bdefd6223939b9770514e697" diff --git a/pyproject.toml b/pyproject.toml index ea3c25bc..3fe52c88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ mkdocs-material = "^8.4.0" mkdocs-material-extensions = "^1.0.3" mkdocs-autorefs = "^0.4.1" ruff = "^0.13.0" +datamodel-code-generator = "^0.34.0" [build-system] requires = ["poetry-core"] From 8c0a7152171cebdf868e90b78035c02395b63364 Mon Sep 17 00:00:00 2001 From: zarathustra Date: Wed, 1 Oct 2025 14:49:33 +0200 Subject: [PATCH 6/6] chore: exclude generated models file from ruff --- pyproject.toml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3fe52c88..b4d27a31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ build-backend = "poetry.core.masonry.api" line-length = 120 target-version = "py313" respect-gitignore = true -extend-exclude = [ +exclude = [ ".eggs", ".git", ".hg", @@ -62,20 +62,21 @@ extend-exclude = [ "build", "dist", "docs/conf.py", + "derive_client/_clients/models.py", ] [tool.ruff.lint] select = [ - "E", # pycodestyle errors - "W", # pycodestyle warnings - "F", # pyflakes - "I", # isort -# "B", # flake8-bugbear -# "UP", # pyupgrade -# "C4", # flake8-comprehensions -# "SIM", # flake8-simplify -# "PT", # flake8-pytest-style (if you use pytest) -# "RUF", # Ruff-specific rules + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + # "B", # flake8-bugbear + # "UP", # pyupgrade + # "C4", # flake8-comprehensions + # "SIM", # flake8-simplify + # "PT", # flake8-pytest-style (if you use pytest) + # "RUF", # Ruff-specific rules ] ignore = ["E501"] @@ -88,4 +89,3 @@ line-ending = "auto" quote-style = "preserve" indent-style = "space" skip-magic-trailing-comma = false -