diff --git a/app/package.json b/app/package.json index eb7acdf..6454ebf 100644 --- a/app/package.json +++ b/app/package.json @@ -25,6 +25,7 @@ "@ethersproject/providers": "^5.7.2", "@ethersproject/units": "^5.7.0", "@lyrafinance/lyra-js": "^0.0.26", + "api": "6.1.1", "axios": "^1.3.2", "cross-fetch": "^3.1.5", "dayjs": "^1.11.7", @@ -33,10 +34,12 @@ "ethers": "5.6.0", "graphql": "^16.6.0", "graphql-tag": "^2.12.6", + "json-schema-to-ts": "2.8.0-beta.0", "lodash": "^4.17.21", "moment": "^2.29.4", "node-schedule": "^2.1.1", "nullthrows": "^1.1.1", + "oas": "20.10.3", "react": "^18.2.0", "rimraf": "^4.1.2", "rpc-websocket-client": "^1.1.4", diff --git a/app/src/api/index.ts b/app/src/api/index.ts new file mode 100644 index 0000000..7ea2a89 --- /dev/null +++ b/app/src/api/index.ts @@ -0,0 +1,839 @@ +import type * as types from './types' +import type { ConfigOptions, FetchResponse } from 'api/dist/core' +import Oas from 'oas' +import APICore from 'api/dist/core' +import definition from './openapi.json' + +class SDK { + spec: Oas + core: APICore + + constructor() { + this.spec = Oas.init(definition) + this.core = new APICore(this.spec, 'lyra-api/1.0.0 (api/6.1.1)') + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config) + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values) + return this + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables) + } + + /** + * Create a new account + * + * @summary Create Account + */ + // tsignore + postPublicCreate_account( + body: types.PostPublicCreateAccountBodyParam, + ): Promise> { + return this.core.fetch('/public/create_account', 'post', body) + } + + /** + * Build a signable transaction params dictionary. + * + * @summary Build Register Session Key Tx + */ + postPublicBuild_register_session_key_tx( + body: types.PostPublicBuildRegisterSessionKeyTxBodyParam, + ): Promise> { + return this.core.fetch('/public/build_register_session_key_tx', 'post', body) + } + + /** + * Register or update expiry of an existing session key. + * + * @summary Register Session Key + */ + postPublicRegister_session_key( + body: types.PostPublicRegisterSessionKeyBodyParam, + ): Promise> { + return this.core.fetch('/public/register_session_key', 'post', body) + } + + /** + * Deregister Session Key + * + */ + postPublicDeregister_session_key( + body: types.PostPublicDeregisterSessionKeyBodyParam, + ): Promise> { + return this.core.fetch('/public/deregister_session_key', 'post', body) + } + + /** + * Authenticate a websocket connection. Unavailable via HTTP. + * + * @summary Login + */ + postPublicLogin(body: types.PostPublicLoginBodyParam): Promise> { + return this.core.fetch('/public/login', 'post', body) + } + + /** + * Get single instrument by asset name + * + * @summary Get Instrument + */ + postPublicGet_instrument( + body: types.PostPublicGetInstrumentBodyParam, + ): Promise> { + return this.core.fetch('/public/get_instrument', 'post', body) + } + + /** + * Get all active instruments for a given `currency` and `type` + * + * @summary Get Instruments + */ + postPublicGet_instruments( + body: types.PostPublicGetInstrumentsBodyParam, + ): Promise> { + return this.core.fetch('/public/get_instruments', 'post', body) + } + + /** + * Get all active instrument tickers for a given `currency` and `type` + * + * @summary Get Ticker + */ + postPublicGet_ticker( + body: types.PostPublicGetTickerBodyParam, + ): Promise> { + return this.core.fetch('/public/get_ticker', 'post', body) + } + + /** + * Get latest signed data feeds + * + * @summary Get Latest Signed Feeds + */ + postPublicGet_latest_signed_feeds( + body: types.PostPublicGetLatestSignedFeedsBodyParam, + ): Promise> { + return this.core.fetch('/public/get_latest_signed_feeds', 'post', body) + } + + /** + * Get spot feed history by currency + * + * @summary Get Spot Feed History + */ + postPublicGet_spot_feed_history( + body: types.PostPublicGetSpotFeedHistoryBodyParam, + ): Promise> { + return this.core.fetch('/public/get_spot_feed_history', 'post', body) + } + + /** + * Get trade history for a subaccount, with filter parameters. + * + * @summary Get Trade History + */ + postPublicGet_trade_history( + body: types.PostPublicGetTradeHistoryBodyParam, + ): Promise> { + return this.core.fetch('/public/get_trade_history', 'post', body) + } + + /** + * Used for getting a transaction by its transaction id + * + * @summary Get Transaction + */ + postPublicGet_transaction( + body: types.PostPublicGetTransactionBodyParam, + ): Promise> { + return this.core.fetch('/public/get_transaction', 'post', body) + } + + /** + * Calculates margin for a given portfolio and (optionally) a simulated state change. Does + * not take into account + * open orders margin requirements. + * + * @summary Get Margin + */ + postPublicGet_margin( + body: types.PostPublicGetMarginBodyParam, + ): Promise> { + return this.core.fetch('/public/get_margin', 'post', body) + } + + /** + * Calculates MtM and maintenance margin for a given subaccount. + * + * @summary Margin Watch + */ + postPublicMargin_watch( + body: types.PostPublicMarginWatchBodyParam, + ): Promise> { + return this.core.fetch('/public/margin_watch', 'post', body) + } + + /** + * Account details getter + * + * @summary Get Account + */ + postPrivateGet_account( + body: types.PostPrivateGetAccountBodyParam, + ): Promise> { + return this.core.fetch('/private/get_account', 'post', body) + } + + /** + * Create a new subaccount under a given wallet, and deposit an asset into that subaccount. + * + * @summary Create Subaccount + */ + postPrivateCreate_subaccount( + body: types.PostPrivateCreateSubaccountBodyParam, + ): Promise> { + return this.core.fetch('/private/create_subaccount', 'post', body) + } + + /** + * Used for debugging only, do not use in production. Will return the incremental encoded + * and hashed data. + * + * @summary Create Subaccount Debug + */ + postPublicCreate_subaccount_debug( + body: types.PostPublicCreateSubaccountDebugBodyParam, + ): Promise> { + return this.core.fetch('/public/create_subaccount_debug', 'post', body) + } + + /** + * Get open orders, active positions, and collaterals of a subaccount + * + * @summary Get Subaccount + */ + postPrivateGet_subaccount( + body: types.PostPrivateGetSubaccountBodyParam, + ): Promise> { + return this.core.fetch('/private/get_subaccount', 'post', body) + } + + /** + * Get all subaccounts of an account / wallet + * + * @summary Get Subaccounts + */ + postPrivateGet_subaccounts( + body: types.PostPrivateGetSubaccountsBodyParam, + ): Promise> { + return this.core.fetch('/private/get_subaccounts', 'post', body) + } + + /** + * Change a user defined label for given subaccount + * + * @summary Change Subaccount Label + */ + postPrivateChange_subaccount_label( + body: types.PostPrivateChangeSubaccountLabelBodyParam, + ): Promise> { + return this.core.fetch('/private/change_subaccount_label', 'post', body) + } + + /** + * Get the notifications related to a subaccount. + * + * @summary Get Notifications + */ + postPrivateGet_notifications( + body: types.PostPrivateGetNotificationsBodyParam, + ): Promise> { + return this.core.fetch('/private/get_notifications', 'post', body) + } + + /** + * RPC to mark specified notifications as seen for a given subaccount. + * + * @summary Update Notifications + */ + postPrivateUpdate_notifications( + body: types.PostPrivateUpdateNotificationsBodyParam, + ): Promise> { + return this.core.fetch('/private/update_notifications', 'post', body) + } + + /** + * Deposit an asset to a subaccount. + * + * @summary Deposit + */ + postPrivateDeposit( + body: types.PostPrivateDepositBodyParam, + ): Promise> { + return this.core.fetch('/private/deposit', 'post', body) + } + + /** + * Withdraw an asset to wallet. + * + * @summary Withdraw + */ + postPrivateWithdraw( + body: types.PostPrivateWithdrawBodyParam, + ): Promise> { + return this.core.fetch('/private/withdraw', 'post', body) + } + + /** + * Transfer ERC20 assets from one subaccount to another (e.g. USDC or ETH). + * + * For transfering positions (e.g. options or perps), use `private/transfer_position` + * instead. + * + * @summary Transfer Erc20 + */ + postPrivateTransfer_erc20( + body: types.PostPrivateTransferErc20BodyParam, + ): Promise> { + return this.core.fetch('/private/transfer_erc20', 'post', body) + } + + /** + * Transfers a positions from one subaccount to another, owned by the same wallet. + * + * The transfer is executed as a pair of orders crossing each other. + * The maker order is created first, followed by a taker order crossing it. + * The order amounts, limit prices and instrument name must be the same for both orders. + * Fee is not charged and a zero `max_fee` must be signed. + * The maker order is forcibly considered to be `reduce_only`, meaning it can only reduce + * the position size. + * + * History: For position transfer history, use the `private/get_trade_history` RPC (not + * `private/get_erc20_transfer_history`). + * + * @summary Transfer Position + */ + postPrivateTransfer_position( + body: types.PostPrivateTransferPositionBodyParam, + ): Promise> { + return this.core.fetch('/private/transfer_position', 'post', body) + } + + /** + * Create a new order + * + * @summary Order + */ + postPrivateOrder( + body: types.PostPrivateOrderBodyParam, + ): Promise> { + return this.core.fetch('/private/order', 'post', body) + } + + /** + * Debug a new order + * + * @summary Order Debug + */ + postPrivateOrder_debug( + body: types.PostPrivateOrderDebugBodyParam, + ): Promise> { + return this.core.fetch('/private/order_debug', 'post', body) + } + + /** + * Get state of an order by order id + * + * @summary Get Order + */ + postPrivateGet_order( + body: types.PostPrivateGetOrderBodyParam, + ): Promise> { + return this.core.fetch('/private/get_order', 'post', body) + } + + /** + * Get orders for a subaccount, with optional filtering. + * + * @summary Get Orders + */ + postPrivateGet_orders( + body: types.PostPrivateGetOrdersBodyParam, + ): Promise> { + return this.core.fetch('/private/get_orders', 'post', body) + } + + /** + * Get all open orders of a subacccount + * + * @summary Get Open Orders + */ + postPrivateGet_open_orders( + body: types.PostPrivateGetOpenOrdersBodyParam, + ): Promise> { + return this.core.fetch('/private/get_open_orders', 'post', body) + } + + /** + * Cancel a single order. + * + * @summary Cancel + */ + postPrivateCancel( + body: types.PostPrivateCancelBodyParam, + ): Promise> { + return this.core.fetch('/private/cancel', 'post', body) + } + + /** + * Cancel all open orders for a given subaccount and a given label. + * + * @summary Cancel By Label + */ + postPrivateCancel_by_label( + body: types.PostPrivateCancelByLabelBodyParam, + ): Promise> { + return this.core.fetch('/private/cancel_by_label', 'post', body) + } + + /** + * Cancel an order with a given subaccount and a given nonce. + * + * @summary Cancel By Nonce + */ + postPrivateCancel_by_nonce( + body: types.PostPrivateCancelByNonceBodyParam, + ): Promise> { + return this.core.fetch('/private/cancel_by_nonce', 'post', body) + } + + /** + * Cancel all open orders for a given subaccount and a given instrument. + * + * @summary Cancel By Instrument + */ + postPrivateCancel_by_instrument( + body: types.PostPrivateCancelByInstrumentBodyParam, + ): Promise> { + return this.core.fetch('/private/cancel_by_instrument', 'post', body) + } + + /** + * Cancel all open orders for a given subaccount. + * + * @summary Cancel All + */ + postPrivateCancel_all( + body: types.PostPrivateCancelAllBodyParam, + ): Promise> { + return this.core.fetch('/private/cancel_all', 'post', body) + } + + /** + * Get order history for a subaccount + * + * @summary Get Order History + */ + postPrivateGet_order_history( + body: types.PostPrivateGetOrderHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_order_history', 'post', body) + } + + /** + * Get trade history for a subaccount, with filter parameters. + * + * @summary Get Trade History + */ + postPrivateGet_trade_history( + body: types.PostPrivateGetTradeHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_trade_history', 'post', body) + } + + /** + * Get subaccount deposit history. + * + * @summary Get Deposit History + */ + postPrivateGet_deposit_history( + body: types.PostPrivateGetDepositHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_deposit_history', 'post', body) + } + + /** + * Get subaccount withdrawal history. + * + * @summary Get Withdrawal History + */ + postPrivateGet_withdrawal_history( + body: types.PostPrivateGetWithdrawalHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_withdrawal_history', 'post', body) + } + + /** + * Calculates margin for a given subaccount and (optionally) a simulated state change. Does + * not take into account + * open orders margin requirements. + * + * @summary Get Margin + */ + postPrivateGet_margin( + body: types.PostPrivateGetMarginBodyParam, + ): Promise> { + return this.core.fetch('/private/get_margin', 'post', body) + } + + /** + * Get collaterals of a subaccount + * + * @summary Get Collaterals + */ + postPrivateGet_collaterals( + body: types.PostPrivateGetCollateralsBodyParam, + ): Promise> { + return this.core.fetch('/private/get_collaterals', 'post', body) + } + + /** + * Get active positions of a subaccount + * + * @summary Get Positions + */ + postPrivateGet_positions( + body: types.PostPrivateGetPositionsBodyParam, + ): Promise> { + return this.core.fetch('/private/get_positions', 'post', body) + } + + /** + * Get expired option settlement history for a subaccount + * + * @summary Get Option Settlement History + */ + postPrivateGet_option_settlement_history( + body: types.PostPrivateGetOptionSettlementHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_option_settlement_history', 'post', body) + } + + /** + * Get the value history of a subaccount + * + * @summary Get Subaccount Value History + */ + postPrivateGet_subaccount_value_history( + body: types.PostPrivateGetSubaccountValueHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_subaccount_value_history', 'post', body) + } + + /** + * Generate a list of URLs to retrieve archived orders + * + * @summary Expired And Cancelled History + */ + postPrivateExpired_and_cancelled_history( + body: types.PostPrivateExpiredAndCancelledHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/expired_and_cancelled_history', 'post', body) + } + + /** + * Get subaccount funding history. + * + * @summary Get Funding History + */ + postPrivateGet_funding_history( + body: types.PostPrivateGetFundingHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_funding_history', 'post', body) + } + + /** + * Get subaccount interest payment history. + * + * @summary Get Interest History + */ + postPrivateGet_interest_history( + body: types.PostPrivateGetInterestHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_interest_history', 'post', body) + } + + /** + * Get subaccount erc20 transfer history. + * + * Position transfers (e.g. options or perps) are treated as trades. Use + * `private/get_trade_history` for position transfer history. + * + * @summary Get Erc20 Transfer History + */ + postPrivateGet_erc20_transfer_history( + body: types.PostPrivateGetErc20TransferHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_erc20_transfer_history', 'post', body) + } + + /** + * Get Liquidation History + * + */ + postPrivateGet_liquidation_history( + body: types.PostPrivateGetLiquidationHistoryBodyParam, + ): Promise> { + return this.core.fetch('/private/get_liquidation_history', 'post', body) + } + + /** + * Session Keys + * + */ + postPrivateSession_keys( + body: types.PostPrivateSessionKeysBodyParam, + ): Promise> { + return this.core.fetch('/private/session_keys', 'post', body) + } + + /** + * Change Session Key Label + * + */ + postPrivateChange_session_key_label( + body: types.PostPrivateChangeSessionKeyLabelBodyParam, + ): Promise> { + return this.core.fetch('/private/change_session_key_label', 'post', body) + } + + /** + * Get the current mmp config for a subaccount (optionally filtered by currency) + * + * @summary Get Mmp Config + */ + postPrivateGet_mmp_config( + body: types.PostPrivateGetMmpConfigBodyParam, + ): Promise> { + return this.core.fetch('/private/get_mmp_config', 'post', body) + } + + /** + * Set the mmp config for the subaccount and currency + * + * @summary Set Mmp Config + */ + postPrivateSet_mmp_config( + body: types.PostPrivateSetMmpConfigBodyParam, + ): Promise> { + return this.core.fetch('/private/set_mmp_config', 'post', body) + } + + /** + * Resets (unfreezes) the mmp state for a subaccount (optionally filtered by currency) + * + * @summary Reset Mmp + */ + postPrivateReset_mmp( + body: types.PostPrivateResetMmpBodyParam, + ): Promise> { + return this.core.fetch('/private/reset_mmp', 'post', body) + } + + /** + * Enables cancel on disconnect for the account + * + * @summary Set Cancel On Disconnect + */ + postPrivateSet_cancel_on_disconnect( + body: types.PostPrivateSetCancelOnDisconnectBodyParam, + ): Promise> { + return this.core.fetch('/private/set_cancel_on_disconnect', 'post', body) + } + + /** + * Get Time + * + */ + postPublicGet_time( + body: types.PostPublicGetTimeBodyParam, + ): Promise> { + return this.core.fetch('/public/get_time', 'post', body) + } +} + +const createSDK = (() => { + return new SDK() +})() +export default createSDK + +export type { + PostPrivateCancelAllBodyParam, + PostPrivateCancelAllResponse200, + PostPrivateCancelBodyParam, + PostPrivateCancelByInstrumentBodyParam, + PostPrivateCancelByInstrumentResponse200, + PostPrivateCancelByLabelBodyParam, + PostPrivateCancelByLabelResponse200, + PostPrivateCancelByNonceBodyParam, + PostPrivateCancelByNonceResponse200, + PostPrivateCancelResponse200, + PostPrivateChangeSessionKeyLabelBodyParam, + PostPrivateChangeSessionKeyLabelResponse200, + PostPrivateChangeSubaccountLabelBodyParam, + PostPrivateChangeSubaccountLabelResponse200, + PostPrivateCreateSubaccountBodyParam, + PostPrivateCreateSubaccountResponse200, + PostPrivateDepositBodyParam, + PostPrivateDepositResponse200, + PostPrivateExpiredAndCancelledHistoryBodyParam, + PostPrivateExpiredAndCancelledHistoryResponse200, + PostPrivateGetAccountBodyParam, + PostPrivateGetAccountResponse200, + PostPrivateGetCollateralsBodyParam, + PostPrivateGetCollateralsResponse200, + PostPrivateGetDepositHistoryBodyParam, + PostPrivateGetDepositHistoryResponse200, + PostPrivateGetErc20TransferHistoryBodyParam, + PostPrivateGetErc20TransferHistoryResponse200, + PostPrivateGetFundingHistoryBodyParam, + PostPrivateGetFundingHistoryResponse200, + PostPrivateGetInterestHistoryBodyParam, + PostPrivateGetInterestHistoryResponse200, + PostPrivateGetLiquidationHistoryBodyParam, + PostPrivateGetLiquidationHistoryResponse200, + PostPrivateGetMarginBodyParam, + PostPrivateGetMarginResponse200, + PostPrivateGetMmpConfigBodyParam, + PostPrivateGetMmpConfigResponse200, + PostPrivateGetNotificationsBodyParam, + PostPrivateGetNotificationsResponse200, + PostPrivateGetOpenOrdersBodyParam, + PostPrivateGetOpenOrdersResponse200, + PostPrivateGetOptionSettlementHistoryBodyParam, + PostPrivateGetOptionSettlementHistoryResponse200, + PostPrivateGetOrderBodyParam, + PostPrivateGetOrderHistoryBodyParam, + PostPrivateGetOrderHistoryResponse200, + PostPrivateGetOrderResponse200, + PostPrivateGetOrdersBodyParam, + PostPrivateGetOrdersResponse200, + PostPrivateGetPositionsBodyParam, + PostPrivateGetPositionsResponse200, + PostPrivateGetSubaccountBodyParam, + PostPrivateGetSubaccountResponse200, + PostPrivateGetSubaccountValueHistoryBodyParam, + PostPrivateGetSubaccountValueHistoryResponse200, + PostPrivateGetSubaccountsBodyParam, + PostPrivateGetSubaccountsResponse200, + PostPrivateGetTradeHistoryBodyParam, + PostPrivateGetTradeHistoryResponse200, + PostPrivateGetWithdrawalHistoryBodyParam, + PostPrivateGetWithdrawalHistoryResponse200, + PostPrivateOrderBodyParam, + PostPrivateOrderDebugBodyParam, + PostPrivateOrderDebugResponse200, + PostPrivateOrderResponse200, + PostPrivateResetMmpBodyParam, + PostPrivateResetMmpResponse200, + PostPrivateSessionKeysBodyParam, + PostPrivateSessionKeysResponse200, + PostPrivateSetCancelOnDisconnectBodyParam, + PostPrivateSetCancelOnDisconnectResponse200, + PostPrivateSetMmpConfigBodyParam, + PostPrivateSetMmpConfigResponse200, + PostPrivateTransferErc20BodyParam, + PostPrivateTransferErc20Response200, + PostPrivateTransferPositionBodyParam, + PostPrivateTransferPositionResponse200, + PostPrivateUpdateNotificationsBodyParam, + PostPrivateUpdateNotificationsResponse200, + PostPrivateWithdrawBodyParam, + PostPrivateWithdrawResponse200, + PostPublicBuildRegisterSessionKeyTxBodyParam, + PostPublicBuildRegisterSessionKeyTxResponse200, + PostPublicCreateAccountBodyParam, + PostPublicCreateAccountResponse200, + PostPublicCreateSubaccountDebugBodyParam, + PostPublicCreateSubaccountDebugResponse200, + PostPublicDeregisterSessionKeyBodyParam, + PostPublicDeregisterSessionKeyResponse200, + PostPublicGetInstrumentBodyParam, + PostPublicGetInstrumentResponse200, + PostPublicGetInstrumentsBodyParam, + PostPublicGetInstrumentsResponse200, + PostPublicGetLatestSignedFeedsBodyParam, + PostPublicGetLatestSignedFeedsResponse200, + PostPublicGetMarginBodyParam, + PostPublicGetMarginResponse200, + PostPublicGetSpotFeedHistoryBodyParam, + PostPublicGetSpotFeedHistoryResponse200, + PostPublicGetTickerBodyParam, + PostPublicGetTickerResponse200, + PostPublicGetTimeBodyParam, + PostPublicGetTimeResponse200, + PostPublicGetTradeHistoryBodyParam, + PostPublicGetTradeHistoryResponse200, + PostPublicGetTransactionBodyParam, + PostPublicGetTransactionResponse200, + PostPublicLoginBodyParam, + PostPublicLoginResponse200, + PostPublicMarginWatchBodyParam, + PostPublicMarginWatchResponse200, + PostPublicRegisterSessionKeyBodyParam, + PostPublicRegisterSessionKeyResponse200, +} from './types' diff --git a/app/src/api/openapi.json b/app/src/api/openapi.json new file mode 100644 index 0000000..6a7fb76 --- /dev/null +++ b/app/src/api/openapi.json @@ -0,0 +1,25032 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "REST API" + }, + "servers": [ + { + "url": "https://api.lyra.finance" + } + ], + "paths": { + "/public/create_account": { + "post": { + "tags": ["Public"], + "summary": "Create Account", + "description": "Create a new account", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "wallet"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`created` or `exists`" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/build_register_session_key_tx": { + "post": { + "tags": ["Public"], + "summary": "Build Register Session Key Tx", + "description": "Build a signable transaction params dictionary.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["tx_params"], + "properties": { + "tx_params": { + "title": "tx_params", + "type": "object", + "description": "Transaction params in dictionary form, same as `TxParams` in `web3.py`", + "additionalProperties": {} + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["expiry_sec", "gas", "nonce", "public_session_key", "wallet"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Expiry of the session key" + }, + "gas": { + "title": "gas", + "type": "integer", + "default": null, + "description": "Gas allowance for transaction. If none, will use estimateGas * 150%", + "nullable": true + }, + "nonce": { + "title": "nonce", + "type": "integer", + "default": null, + "description": "Wallet's transaction count, If none, will use eth.getTransactionCount()", + "nullable": true + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/register_session_key": { + "post": { + "tags": ["Public"], + "summary": "Register Session Key", + "description": "Register or update expiry of an existing session key.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["label", "public_session_key", "transaction_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "ID to lookup status of transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["expiry_sec", "label", "public_session_key", "signed_raw_tx", "wallet"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Expiry of the session key" + }, + "label": { + "title": "label", + "type": "string", + "description": "Ethereum wallet address" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "signed_raw_tx": { + "title": "signed_raw_tx", + "type": "string", + "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()`)" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/deregister_session_key": { + "post": { + "tags": ["Public"], + "summary": "Deregister Session Key", + "description": "", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["public_session_key", "transaction_id"], + "properties": { + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "ID to lookup status of transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["public_session_key", "signed_raw_tx", "wallet"], + "properties": { + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "signed_raw_tx": { + "title": "signed_raw_tx", + "type": "string", + "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()`)" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/login": { + "post": { + "tags": ["Public"], + "summary": "Login", + "description": "Authenticate a websocket connection. Unavailable via HTTP.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "List of subaccount IDs that have been authenticated", + "items": { + "title": "result", + "type": "integer" + } + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["signature", "timestamp", "wallet"], + "properties": { + "signature": { + "title": "signature", + "type": "string", + "description": "Signature of the timestamp, signed with the wallet's private key or a session key" + }, + "timestamp": { + "title": "timestamp", + "type": "string", + "description": "Message that was signed, in the form of a timestamp in ms since Unix epoch" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Public key (wallet) of the account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_instrument": { + "post": { + "tags": ["Public"], + "summary": "Get Instrument", + "description": "Get single instrument by asset name", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "maximum_amount", + "minimum_amount", + "option_details", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "taker_fee_rate", + "tick_size" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["instrument_name"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_instruments": { + "post": { + "tags": ["Public"], + "summary": "Get Instruments", + "description": "Get all active instruments for a given `currency` and `type`", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "", + "items": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "maximum_amount", + "minimum_amount", + "option_details", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "taker_fee_rate", + "tick_size" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["currency", "expired", "instrument_type"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "expired": { + "title": "expired", + "type": "boolean", + "description": "If `True`: include expired assets" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_ticker": { + "post": { + "tags": ["Public"], + "summary": "Get Ticker", + "description": "Get all active instrument tickers for a given `currency` and `type`", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "best_ask_amount", + "best_ask_price", + "best_bid_amount", + "best_bid_price", + "index_price", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "mark_price", + "max_price", + "maximum_amount", + "min_price", + "minimum_amount", + "option_details", + "option_pricing", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "stats", + "taker_fee_rate", + "tick_size", + "timestamp" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "best_ask_amount": { + "title": "best_ask_amount", + "type": "string", + "format": "decimal", + "description": "Amount of contracts / tokens available at best ask price" + }, + "best_ask_price": { + "title": "best_ask_price", + "type": "string", + "format": "decimal", + "description": "Best ask price" + }, + "best_bid_amount": { + "title": "best_bid_amount", + "type": "string", + "format": "decimal", + "description": "Amount of contracts / tokens available at best bid price" + }, + "best_bid_price": { + "title": "best_bid_price", + "type": "string", + "format": "decimal", + "description": "Best bid price" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "max_price": { + "title": "max_price", + "type": "string", + "format": "decimal", + "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)." + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "min_price": { + "title": "min_price", + "type": "string", + "format": "decimal", + "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)." + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "option_pricing": { + "required": [ + "ask_iv", + "bid_iv", + "delta", + "forward_price", + "gamma", + "iv", + "mark_price", + "rho", + "theta", + "vega" + ], + "properties": { + "ask_iv": { + "title": "ask_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best ask" + }, + "bid_iv": { + "title": "bid_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best bid" + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Delta of the option" + }, + "forward_price": { + "title": "forward_price", + "type": "string", + "format": "decimal", + "description": "Forward price used to calculate option premium" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Gamma of the option" + }, + "iv": { + "title": "iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the option" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the option" + }, + "rho": { + "title": "rho", + "type": "string", + "format": "decimal", + "description": "Rho of the option" + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Theta of the option" + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Vega of the option" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "stats": { + "required": [ + "contract_volume", + "high", + "low", + "num_trades", + "open_interest", + "percent_change", + "usd_change" + ], + "properties": { + "contract_volume": { + "title": "contract_volume", + "type": "string", + "format": "decimal", + "description": "Number of contracts traded during last 24 hours" + }, + "high": { + "title": "high", + "type": "string", + "format": "decimal", + "description": "Highest trade price during last 24h" + }, + "low": { + "title": "low", + "type": "string", + "format": "decimal", + "description": "Lowest trade price during last 24h" + }, + "num_trades": { + "title": "num_trades", + "type": "string", + "format": "decimal", + "description": "Number of trades during last 24h " + }, + "open_interest": { + "title": "open_interest", + "type": "string", + "format": "decimal", + "description": "Current total open interest" + }, + "percent_change": { + "title": "percent_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price" + }, + "usd_change": { + "title": "usd_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change in USD." + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the ticker feed snapshot" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["instrument_name"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_latest_signed_feeds": { + "post": { + "tags": ["Public"], + "summary": "Get Latest Signed Feeds", + "description": "Get latest signed data feeds", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["fwd_data", "perp_data", "spot_data", "vol_data"], + "properties": { + "fwd_data": { + "title": "fwd_data", + "type": "object", + "description": "currency -> expiry -> latest forward feed data", + "additionalProperties": { + "title": "fwd_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "expiry", + "fwd_diff", + "signatures", + "spot_aggregate_latest", + "spot_aggregate_start", + "timestamp" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the forward feed" + }, + "fwd_diff": { + "title": "fwd_diff", + "type": "string", + "format": "decimal", + "description": "difference of forward price from current spot price" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_aggregate_latest": { + "title": "spot_aggregate_latest", + "type": "string", + "format": "decimal", + "description": "expiry -> spot * time value at the latest timestamp" + }, + "spot_aggregate_start": { + "title": "spot_aggregate_start", + "type": "string", + "format": "decimal", + "description": "spot * time value at the start of the settlement period" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "perp_data": { + "title": "perp_data", + "type": "object", + "description": "currency -> feed type -> latest perp feed data", + "additionalProperties": { + "title": "perp_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "signatures", + "spot_diff_value", + "timestamp", + "type" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_diff_value": { + "title": "spot_diff_value", + "type": "string", + "format": "decimal", + "description": "The difference between the spot price and the perp price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "type": { + "title": "type", + "type": "string", + "enum": ["P", "A", "B"], + "description": "The type of perp feed; mid price, ask impact or bid impact" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "spot_data": { + "title": "spot_data", + "type": "object", + "description": "currency -> latest spot feed data", + "additionalProperties": { + "required": ["confidence", "currency", "deadline", "price", "signatures", "timestamp"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "The price of the currency in USD" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "vol_data": { + "title": "vol_data", + "type": "object", + "description": "currency -> expiry -> latest vol feed data", + "additionalProperties": { + "title": "vol_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "expiry", + "signatures", + "timestamp", + "vol_data" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the options for the vol feed" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "vol_data": { + "required": [ + "SVI_a", + "SVI_b", + "SVI_fwd", + "SVI_m", + "SVI_refTau", + "SVI_rho", + "SVI_sigma" + ], + "properties": { + "SVI_a": { + "title": "SVI_a", + "type": "string", + "format": "decimal" + }, + "SVI_b": { + "title": "SVI_b", + "type": "string", + "format": "decimal" + }, + "SVI_fwd": { + "title": "SVI_fwd", + "type": "string", + "format": "decimal" + }, + "SVI_m": { + "title": "SVI_m", + "type": "string", + "format": "decimal" + }, + "SVI_refTau": { + "title": "SVI_refTau", + "type": "string", + "format": "decimal" + }, + "SVI_rho": { + "title": "SVI_rho", + "type": "string", + "format": "decimal" + }, + "SVI_sigma": { + "title": "SVI_sigma", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency filter, (defaults to all currencies)", + "nullable": true + }, + "expiry": { + "title": "expiry", + "type": "integer", + "default": null, + "description": "Expiry filter for options and forward data (defaults to all expiries). Use `0` to get data only for spot and perpetuals", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_spot_feed_history": { + "post": { + "tags": ["Public"], + "summary": "Get Spot Feed History", + "description": "Get spot feed history by currency", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["currency", "spot_feed_history"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency" + }, + "spot_feed_history": { + "title": "spot_feed_history", + "type": "array", + "description": "Spot feed history", + "items": { + "required": ["confidence", "price", "timestamp", "timestamp_bucket"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "Confidence score of the spot price" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "Spot price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the spot price was recored into the database" + }, + "timestamp_bucket": { + "title": "timestamp_bucket", + "type": "integer", + "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" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["currency", "end_timestamp", "period", "start_timestamp"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency" + }, + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "description": "End timestamp" + }, + "period": { + "title": "period", + "type": "integer", + "description": "Period" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Start timestamp" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_trade_history": { + "post": { + "tags": ["Public"], + "summary": "Get Trade History", + "description": "Get trade history for a subaccount, with filter parameters.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["pagination", "trades"], + "properties": { + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "trades": { + "title": "trades", + "type": "array", + "description": "List of trades", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "liquidity_role", + "mark_price", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status", + "wallet" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Blockchain transaction hash" + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["settled", "reverted"], + "description": "Blockchain transaction status" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Wallet address (owner) of the subaccount" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency to filter by (defaults to all)", + "nullable": true + }, + "from_timestamp": { + "title": "from_timestamp", + "type": "integer", + "default": 0, + "description": "Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0." + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Instrument name to filter by (defaults to all)", + "nullable": true + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "default": null, + "enum": ["erc20", "option", "perp"], + "description": "Instrument type to filter by (defaults to all)", + "nullable": true + }, + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return (default 1, returns last if above `num_pages`)" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 100, + "description": "Number of results per page (default 100, max 1000)" + }, + "to_timestamp": { + "title": "to_timestamp", + "type": "integer", + "default": 18446744073709552000, + "description": "Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time." + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "default": "settled", + "enum": ["settled", "reverted"], + "description": "Transaction status to filter by (default `settled`)." + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_transaction": { + "post": { + "tags": ["Public"], + "summary": "Get Transaction", + "description": "Used for getting a transaction by its transaction id", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_hash"], + "properties": { + "status": { + "title": "status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Status of the transaction" + }, + "transaction_hash": { + "title": "transaction_hash", + "type": "string", + "default": null, + "description": "Transaction hash of a pending tx", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["transaction_id"], + "properties": { + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "transaction_id of the transaction to get" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_margin": { + "post": { + "tags": ["Public"], + "summary": "Get Margin", + "description": "Calculates margin for a given portfolio and (optionally) a simulated state change. Does not take into account\nopen orders margin requirements.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "is_valid_trade", + "post_initial_margin", + "post_maintenance_margin", + "pre_initial_margin", + "pre_maintenance_margin", + "subaccount_id" + ], + "properties": { + "is_valid_trade": { + "title": "is_valid_trade", + "type": "boolean", + "description": "True if trade passes margin requirement" + }, + "post_initial_margin": { + "title": "post_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement post trade" + }, + "post_maintenance_margin": { + "title": "post_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement post trade" + }, + "pre_initial_margin": { + "title": "pre_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement before trade" + }, + "pre_maintenance_margin": { + "title": "pre_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement before trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["margin_type", "simulated_positions"], + "properties": { + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "`PM` (Portfolio Margin) or `SM` (Standard Margin)" + }, + "simulated_position_changes": { + "title": "simulated_position_changes", + "type": "array", + "default": null, + "description": "Optional, add positions to simulate a trade", + "items": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "nullable": true + }, + "simulated_positions": { + "title": "simulated_positions", + "type": "array", + "description": "List of positions in a simulated portfolio", + "items": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/margin_watch": { + "post": { + "tags": ["Public"], + "summary": "Margin Watch", + "description": "Calculates MtM and maintenance margin for a given subaccount.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "currency", + "maintenance_margin", + "margin_type", + "subaccount_id", + "subaccount_value", + "valuation_timestamp" + ], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of subaccount" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation." + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "valuation_timestamp": { + "title": "valuation_timestamp", + "type": "integer", + "description": "Timestamp (in seconds since epoch) of when margin and MtM were computed." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID to get margin for." + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_account": { + "post": { + "tags": ["Private"], + "summary": "Get Account", + "description": "Account details getter", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "cancel_on_disconnect", + "subaccount_ids", + "wallet", + "websocket_matching_tps", + "websocket_non_matching_tps" + ], + "properties": { + "cancel_on_disconnect": { + "title": "cancel_on_disconnect", + "type": "boolean", + "description": "Whether cancel on disconnect is enabled for the account" + }, + "subaccount_ids": { + "title": "subaccount_ids", + "type": "array", + "description": "List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + "items": { + "title": "subaccount_ids", + "type": "integer" + } + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + }, + "websocket_matching_tps": { + "title": "websocket_matching_tps", + "type": "integer", + "description": "Max transactions per second for matching requests over websocket (see `Rate Limiting` in docs)" + }, + "websocket_non_matching_tps": { + "title": "websocket_non_matching_tps", + "type": "integer", + "description": "Max transactions per second for non-matching requests over websocket (see `Rate Limiting` in docs)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/create_subaccount": { + "post": { + "tags": ["Private"], + "summary": "Create Subaccount", + "description": "Create a new subaccount under a given wallet, and deposit an asset into that subaccount.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the request" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "amount", + "asset_name", + "margin_type", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "wallet" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to deposit" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to deposit" + }, + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Base currency of the subaccount (only for `PM`)", + "nullable": true + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "`PM` (Portfolio Margin) or `SM` (Standard Margin)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the deposit" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the deposit" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/create_subaccount_debug": { + "post": { + "tags": ["Public"], + "summary": "Create Subaccount Debug", + "description": "Used for debugging only, do not use in production. Will return the incremental encoded and hashed data.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["action_hash", "encoded_data", "encoded_data_hashed", "typed_data_hash"], + "properties": { + "action_hash": { + "title": "action_hash", + "type": "string", + "description": "Keccak hashed action data" + }, + "encoded_data": { + "title": "encoded_data", + "type": "string", + "description": "ABI encoded deposit data" + }, + "encoded_data_hashed": { + "title": "encoded_data_hashed", + "type": "string", + "description": "Keccak hashed encoded_data" + }, + "typed_data_hash": { + "title": "typed_data_hash", + "type": "string", + "description": "EIP 712 typed data hash" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "amount", + "asset_name", + "margin_type", + "nonce", + "signature_expiry_sec", + "signer", + "wallet" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to deposit" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to deposit" + }, + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Base currency of the subaccount (only for `PM`)", + "nullable": true + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "`PM` (Portfolio Margin) or `SM` (Standard Margin)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the deposit" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_subaccount": { + "post": { + "tags": ["Private"], + "summary": "Get Subaccount", + "description": "Get open orders, active positions, and collaterals of a subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "collaterals", + "collaterals_initial_margin", + "collaterals_maintenance_margin", + "collaterals_value", + "currency", + "initial_margin", + "maintenance_margin", + "margin_type", + "open_orders", + "open_orders_margin", + "positions", + "positions_initial_margin", + "positions_maintenance_margin", + "positions_value", + "subaccount_id", + "subaccount_value" + ], + "properties": { + "collaterals": { + "title": "collaterals", + "type": "array", + "description": "All collaterals that count towards margin of subaccount", + "items": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "collaterals_initial_margin": { + "title": "collaterals_initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin credit contributed by collaterals" + }, + "collaterals_maintenance_margin": { + "title": "collaterals_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin credit contributed by collaterals" + }, + "collaterals_value": { + "title": "collaterals_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all collaterals" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of subaccount" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin requirement of all positions and collaterals.Trades will be rejected if this value falls below zero after the trade." + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation." + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))" + }, + "open_orders": { + "title": "open_orders", + "type": "array", + "description": "All open orders of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "Total margin requirement of all open orders.Orders will be rejected if this value plus initial margin are below zero after the order." + }, + "positions": { + "title": "positions", + "type": "array", + "description": "All active positions of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "positions_initial_margin": { + "title": "positions_initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin requirement of all positions" + }, + "positions_maintenance_margin": { + "title": "positions_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions" + }, + "positions_value": { + "title": "positions_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_subaccounts": { + "post": { + "tags": ["Private"], + "summary": "Get Subaccounts", + "description": "Get all subaccounts of an account / wallet", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["subaccount_ids", "wallet"], + "properties": { + "subaccount_ids": { + "title": "subaccount_ids", + "type": "array", + "description": "List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + "items": { + "title": "subaccount_ids", + "type": "integer" + } + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/change_subaccount_label": { + "post": { + "tags": ["Private"], + "summary": "Change Subaccount Label", + "description": "Change a user defined label for given subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User defined label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User defined label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_notifications": { + "post": { + "tags": ["Private"], + "summary": "Get Notifications", + "description": "Get the notifications related to a subaccount.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["notifications", "subaccount_id"], + "properties": { + "notifications": { + "title": "notifications", + "type": "array", + "description": "Notification response", + "items": { + "required": ["event", "event_details", "id", "status", "subaccount_id", "timestamp"], + "properties": { + "event": { + "title": "event", + "type": "string", + "description": "The specific event leading to the notification." + }, + "event_details": { + "title": "event_details", + "type": "object", + "description": "A JSON-structured dictionary containing detailed data or context about the event.", + "additionalProperties": {} + }, + "id": { + "title": "id", + "type": "integer", + "description": "The unique identifier for the notification." + }, + "status": { + "title": "status", + "type": "string", + "description": "The status of the notification, indicating if it has been read, pending, or processed." + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "The subaccount_id associated with the notification." + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp indicating when the notification was created or triggered." + }, + "transaction_id": { + "title": "transaction_id", + "type": "integer", + "default": null, + "description": "The transaction id associated with the notification.", + "nullable": true + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "The transaction hash associated with the notification.", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 20, + "description": "Number of results per page" + }, + "status": { + "title": "status", + "type": "string", + "default": null, + "enum": ["unseen", "seen", "hidden"], + "description": "Status of the notification", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "type": { + "title": "type", + "type": "string", + "default": null, + "enum": ["deposit", "withdraw", "transfer", "trade", "settlement", "liquidation", "custom"], + "description": "Status of the notification", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/update_notifications": { + "post": { + "tags": ["Private"], + "summary": "Update Notifications", + "description": "RPC to mark specified notifications as seen for a given subaccount.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["updated_count"], + "properties": { + "updated_count": { + "title": "updated_count", + "type": "integer", + "description": "Number of notifications marked as seen" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["notification_ids", "subaccount_id"], + "properties": { + "notification_ids": { + "title": "notification_ids", + "type": "array", + "description": "List of notification IDs to be marked as seen", + "items": { + "title": "notification_ids", + "type": "integer" + } + }, + "status": { + "title": "status", + "type": "string", + "default": "seen", + "enum": ["unseen", "seen", "hidden"], + "description": "Status of the notification" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/deposit": { + "post": { + "tags": ["Private"], + "summary": "Deposit", + "description": "Deposit an asset to a subaccount.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the deposit" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "amount", + "asset_name", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to deposit" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to deposit" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the deposit" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the deposit" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/withdraw": { + "post": { + "tags": ["Private"], + "summary": "Withdraw", + "description": "Withdraw an asset to wallet.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the withdrawal" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "amount", + "asset_name", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to withdraw" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to withdraw" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the withdraw" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the withdraw" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/transfer_erc20": { + "post": { + "tags": ["Private"], + "summary": "Transfer Erc20", + "description": "Transfer ERC20 assets from one subaccount to another (e.g. USDC or ETH).\n\nFor transfering positions (e.g. options or perps), use `private/transfer_position` instead.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the transfer" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "recipient_details", + "recipient_subaccount_id", + "sender_details", + "subaccount_id", + "transfer" + ], + "properties": { + "recipient_details": { + "required": ["nonce", "signature", "signature_expiry_sec", "signer"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the transfer" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the transfer" + } + }, + "type": "object", + "additionalProperties": false + }, + "recipient_subaccount_id": { + "title": "recipient_subaccount_id", + "type": "integer", + "description": "Subaccount_id of the recipient" + }, + "sender_details": { + "required": ["nonce", "signature", "signature_expiry_sec", "signer"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the transfer" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the transfer" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "transfer": { + "required": ["address", "amount", "sub_id"], + "properties": { + "address": { + "title": "address", + "type": "string", + "description": "Ethereum address of the asset being transferred" + }, + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount to transfer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer", + "description": "Sub ID of the asset being transferred" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/transfer_position": { + "post": { + "tags": ["Private"], + "summary": "Transfer Position", + "description": "Transfers a positions from one subaccount to another, owned by the same wallet.\n\nThe transfer is executed as a pair of orders crossing each other.\nThe maker order is created first, followed by a taker order crossing it.\nThe order amounts, limit prices and instrument name must be the same for both orders.\nFee is not charged and a zero `max_fee` must be signed.\nThe maker order is forcibly considered to be `reduce_only`, meaning it can only reduce the position size.\n\nHistory: For position transfer history, use the `private/get_trade_history` RPC (not `private/get_erc20_transfer_history`).", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["maker_order", "maker_trade", "taker_order", "taker_trade"], + "properties": { + "maker_order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "maker_trade": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_trade": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["maker_params", "taker_params", "wallet"], + "properties": { + "maker_params": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_params": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Public key (wallet) of the account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/order": { + "post": { + "tags": ["Private"], + "summary": "Order", + "description": "Create a new order", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["order", "trades"], + "properties": { + "order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "trades": { + "title": "trades", + "type": "array", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "Optional user-defined label for the order" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "default": false, + "description": "Whether the order is tagged for market maker protections (default false)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_type": { + "title": "order_type", + "type": "string", + "default": "limit", + "enum": ["limit", "market"], + "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" + }, + "reduce_only": { + "title": "reduce_only", + "type": "boolean", + "default": 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)" + }, + "referral_code": { + "title": "referral_code", + "type": "string", + "default": "", + "description": "Optional referral code for the order" + }, + "reject_timestamp": { + "title": "reject_timestamp", + "type": "integer", + "default": 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." + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "default": "gtc", + "enum": ["gtc", "post_only", "fok", "ioc"], + "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." + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/order_debug": { + "post": { + "tags": ["Private"], + "summary": "Order Debug", + "description": "Debug a new order", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["action_hash", "encoded_data", "encoded_data_hashed", "raw_data", "typed_data_hash"], + "properties": { + "action_hash": { + "title": "action_hash", + "type": "string", + "description": "Keccak hashed action data" + }, + "encoded_data": { + "title": "encoded_data", + "type": "string", + "description": "ABI encoded order data" + }, + "encoded_data_hashed": { + "title": "encoded_data_hashed", + "type": "string", + "description": "Keccak hashed encoded_data" + }, + "raw_data": { + "required": [ + "data", + "expiry", + "module", + "nonce", + "owner", + "signature", + "signer", + "subaccount_id" + ], + "properties": { + "data": { + "required": [ + "asset", + "desired_amount", + "is_bid", + "limit_price", + "recipient_id", + "sub_id", + "trade_id", + "worst_fee" + ], + "properties": { + "asset": { + "title": "asset", + "type": "string" + }, + "desired_amount": { + "title": "desired_amount", + "type": "string", + "format": "decimal" + }, + "is_bid": { + "title": "is_bid", + "type": "boolean" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal" + }, + "recipient_id": { + "title": "recipient_id", + "type": "integer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer" + }, + "trade_id": { + "title": "trade_id", + "type": "string" + }, + "worst_fee": { + "title": "worst_fee", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "expiry": { + "title": "expiry", + "type": "integer" + }, + "module": { + "title": "module", + "type": "string" + }, + "nonce": { + "title": "nonce", + "type": "integer" + }, + "owner": { + "title": "owner", + "type": "string" + }, + "signature": { + "title": "signature", + "type": "string" + }, + "signer": { + "title": "signer", + "type": "string" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer" + } + }, + "type": "object", + "additionalProperties": false + }, + "typed_data_hash": { + "title": "typed_data_hash", + "type": "string", + "description": "EIP 712 typed data hash" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "Optional user-defined label for the order" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "default": false, + "description": "Whether the order is tagged for market maker protections (default false)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_type": { + "title": "order_type", + "type": "string", + "default": "limit", + "enum": ["limit", "market"], + "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" + }, + "reduce_only": { + "title": "reduce_only", + "type": "boolean", + "default": 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)" + }, + "referral_code": { + "title": "referral_code", + "type": "string", + "default": "", + "description": "Optional referral code for the order" + }, + "reject_timestamp": { + "title": "reject_timestamp", + "type": "integer", + "default": 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." + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "default": "gtc", + "enum": ["gtc", "post_only", "fok", "ioc"], + "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." + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_order": { + "post": { + "tags": ["Private"], + "summary": "Get Order", + "description": "Get state of an order by order id", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["order_id", "subaccount_id"], + "properties": { + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_orders": { + "post": { + "tags": ["Private"], + "summary": "Get Orders", + "description": "Get orders for a subaccount, with optional filtering.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["orders", "pagination", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Filter by instrument name", + "nullable": true + }, + "label": { + "title": "label", + "type": "string", + "default": null, + "description": "Filter by label", + "nullable": true + }, + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return (default 1, returns last if above `num_pages`)" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 100, + "description": "Number of results per page (default 100, max 1000)" + }, + "status": { + "title": "status", + "type": "string", + "default": null, + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Filter by order status", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_open_orders": { + "post": { + "tags": ["Private"], + "summary": "Get Open Orders", + "description": "Get all open orders of a subacccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["orders", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/cancel": { + "post": { + "tags": ["Private"], + "summary": "Cancel", + "description": "Cancel a single order.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["instrument_name", "order_id", "subaccount_id"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string" + }, + "order_id": { + "title": "order_id", + "type": "string", + "format": "uuid" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/cancel_by_label": { + "post": { + "tags": ["Private"], + "summary": "Cancel By Label", + "description": "Cancel all open orders for a given subaccount and a given label.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "Cancel all orders for this label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/cancel_by_nonce": { + "post": { + "tags": ["Private"], + "summary": "Cancel By Nonce", + "description": "Cancel an order with a given subaccount and a given nonce.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["nonce", "subaccount_id"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Cancel an order with this nonce" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/cancel_by_instrument": { + "post": { + "tags": ["Private"], + "summary": "Cancel By Instrument", + "description": "Cancel all open orders for a given subaccount and a given instrument.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["instrument_name", "subaccount_id"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Cancel all orders for this instrument" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/cancel_all": { + "post": { + "tags": ["Private"], + "summary": "Cancel All", + "description": "Cancel all open orders for a given subaccount.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_order_history": { + "post": { + "tags": ["Private"], + "summary": "Get Order History", + "description": "Get order history for a subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["orders", "pagination", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return (default 1, returns last if above `num_pages`)" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 100, + "description": "Number of results per page (default 100, max 1000)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get order history" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_trade_history": { + "post": { + "tags": ["Private"], + "summary": "Get Trade History", + "description": "Get trade history for a subaccount, with filter parameters.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["subaccount_id", "trades"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get the trade history" + }, + "trades": { + "title": "trades", + "type": "array", + "description": "List of trades", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "from_timestamp": { + "title": "from_timestamp", + "type": "integer", + "default": 0, + "description": "Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0." + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Instrument name to filter by", + "nullable": true + }, + "order_id": { + "title": "order_id", + "type": "string", + "default": null, + "description": "Order id to filter by", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get trades" + }, + "to_timestamp": { + "title": "to_timestamp", + "type": "integer", + "default": 18446744073709552000, + "description": "Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time." + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_deposit_history": { + "post": { + "tags": ["Private"], + "summary": "Get Deposit History", + "description": "Get subaccount deposit history.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of deposit payments", + "items": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount deposited by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset deposited" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the deposit (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that deposited the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_withdrawal_history": { + "post": { + "tags": ["Private"], + "summary": "Get Withdrawal History", + "description": "Get subaccount withdrawal history.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of withdrawals", + "items": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the withdrawal (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_margin": { + "post": { + "tags": ["Private"], + "summary": "Get Margin", + "description": "Calculates margin for a given subaccount and (optionally) a simulated state change. Does not take into account\nopen orders margin requirements.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "is_valid_trade", + "post_initial_margin", + "post_maintenance_margin", + "pre_initial_margin", + "pre_maintenance_margin", + "subaccount_id" + ], + "properties": { + "is_valid_trade": { + "title": "is_valid_trade", + "type": "boolean", + "description": "True if trade passes margin requirement" + }, + "post_initial_margin": { + "title": "post_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement post trade" + }, + "post_maintenance_margin": { + "title": "post_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement post trade" + }, + "pre_initial_margin": { + "title": "pre_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement before trade" + }, + "pre_maintenance_margin": { + "title": "pre_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement before trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "simulated_position_changes": { + "title": "simulated_position_changes", + "type": "array", + "default": null, + "description": "Optional, add positions to simulate a trade", + "items": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_collaterals": { + "post": { + "tags": ["Private"], + "summary": "Get Collaterals", + "description": "Get collaterals of a subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["collaterals", "subaccount_id"], + "properties": { + "collaterals": { + "title": "collaterals", + "type": "array", + "description": "All collaterals that count towards margin of subaccount", + "items": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_positions": { + "post": { + "tags": ["Private"], + "summary": "Get Positions", + "description": "Get active positions of a subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["positions", "subaccount_id"], + "properties": { + "positions": { + "title": "positions", + "type": "array", + "description": "All active positions of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_option_settlement_history": { + "post": { + "tags": ["Private"], + "summary": "Get Option Settlement History", + "description": "Get expired option settlement history for a subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["settlements", "subaccount_id"], + "properties": { + "settlements": { + "title": "settlements", + "type": "array", + "description": "List of expired option settlements", + "items": { + "required": [ + "amount", + "expiry", + "instrument_name", + "option_settlement_pnl", + "settlement_price" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount that was settled" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Expiry timestamp of the option" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "option_settlement_pnl": { + "title": "option_settlement_pnl", + "type": "string", + "format": "decimal", + "description": "USD profit or loss from option settlements calculated as: settlement value - (average price x amount)" + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "description": "Price of option settlement" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get expired option settlement history" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get expired option settlement history" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_subaccount_value_history": { + "post": { + "tags": ["Private"], + "summary": "Get Subaccount Value History", + "description": "Get the value history of a subaccount", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["subaccount_id", "subaccount_value_history"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value_history": { + "title": "subaccount_value_history", + "type": "array", + "description": "Subaccount value history", + "items": { + "required": ["subaccount_value", "timestamp"], + "properties": { + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the subaccount value was recorded into the database" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["end_timestamp", "period", "start_timestamp", "subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "description": "End timestamp" + }, + "period": { + "title": "period", + "type": "integer", + "description": "Period" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Start timestamp" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/expired_and_cancelled_history": { + "post": { + "tags": ["Private"], + "summary": "Expired And Cancelled History", + "description": "Generate a list of URLs to retrieve archived orders", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["presigned_urls"], + "properties": { + "presigned_urls": { + "title": "presigned_urls", + "type": "array", + "description": "List of presigned URLs to the snapshots", + "items": { + "title": "presigned_urls", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["end_timestamp", "expiry", "start_timestamp", "subaccount_id", "wallet"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "description": "End Unix timestamp" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Expiry of download link in seconds. Maximum of 604800." + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Start Unix timestamp" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount to download data for" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Wallet to download data for" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_funding_history": { + "post": { + "tags": ["Private"], + "summary": "Get Funding History", + "description": "Get subaccount funding history.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of funding payments", + "items": { + "required": ["funding", "instrument_name", "timestamp"], + "properties": { + "funding": { + "title": "funding", + "type": "string", + "format": "decimal", + "description": "Dollar funding paid (if negative) or received (if positive) by the subaccount" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the funding payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Instrument name (returns history for all perpetuals if not provided)", + "nullable": true + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_interest_history": { + "post": { + "tags": ["Private"], + "summary": "Get Interest History", + "description": "Get subaccount interest payment history.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of interest payments", + "items": { + "required": ["interest", "timestamp"], + "properties": { + "interest": { + "title": "interest", + "type": "string", + "format": "decimal", + "description": "Dollar interest paid (if negative) or received (if positive) by the subaccount" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the interest payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_erc20_transfer_history": { + "post": { + "tags": ["Private"], + "summary": "Get Erc20 Transfer History", + "description": "Get subaccount erc20 transfer history.\n\nPosition transfers (e.g. options or perps) are treated as trades. Use `private/get_trade_history` for position transfer history.", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of erc20 transfers", + "items": { + "required": [ + "amount", + "asset", + "counterparty_subaccount_id", + "is_outgoing", + "timestamp", + "tx_hash" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "counterparty_subaccount_id": { + "title": "counterparty_subaccount_id", + "type": "integer", + "description": "Recipient or sender subaccount_id of transfer" + }, + "is_outgoing": { + "title": "is_outgoing", + "type": "boolean", + "description": "True if the transfer was initiated by the subaccount, False otherwise" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the transfer (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_liquidation_history": { + "post": { + "tags": ["Private"], + "summary": "Get Liquidation History", + "description": "", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "", + "items": { + "required": [ + "auction_id", + "auction_type", + "bids", + "end_timestamp", + "fee", + "start_timestamp", + "tx_hash" + ], + "properties": { + "auction_id": { + "title": "auction_id", + "type": "string", + "description": "Unique ID of the auction" + }, + "auction_type": { + "title": "auction_type", + "type": "string", + "enum": ["solvent", "insolvent"], + "description": "Type of auction" + }, + "bids": { + "title": "bids", + "type": "array", + "description": "List of auction bid events", + "items": { + "required": [ + "amounts_liquidated", + "cash_received", + "discount_pnl", + "percent_liquidated", + "positions_realized_pnl", + "realized_pnl", + "timestamp", + "tx_hash" + ], + "properties": { + "amounts_liquidated": { + "title": "amounts_liquidated", + "type": "object", + "description": "Amounts of each asset that were closed", + "additionalProperties": { + "title": "amounts_liquidated", + "type": "string", + "format": "decimal" + } + }, + "cash_received": { + "title": "cash_received", + "type": "string", + "format": "decimal", + "description": "Cash received for auctioning off the percentage of the subaccount" + }, + "discount_pnl": { + "title": "discount_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL due to being liquidated at a discount to mark portfolio value" + }, + "percent_liquidated": { + "title": "percent_liquidated", + "type": "string", + "format": "decimal", + "description": "Percent of the subaccount that was liquidated" + }, + "positions_realized_pnl": { + "title": "positions_realized_pnl", + "type": "object", + "description": "Realized PnL of each position that was closed", + "additionalProperties": { + "title": "positions_realized_pnl", + "type": "string", + "format": "decimal" + } + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the bid (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the bid transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": null, + "description": "Timestamp of the auction end (in ms since UNIX epoch), or `null` if not ended", + "nullable": true + }, + "fee": { + "title": "fee", + "type": "string", + "format": "decimal", + "description": "Fee paid by the subaccount" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Timestamp of the auction start (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that started the auction" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/session_keys": { + "post": { + "tags": ["Private"], + "summary": "Session Keys", + "description": "", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["public_session_keys"], + "properties": { + "public_session_keys": { + "title": "public_session_keys", + "type": "array", + "description": "List of session keys (includes unactivated and expired keys)", + "items": { + "required": ["expiry_sec", "public_session_key"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Session key expiry timestamp in sec" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Public session key address (Ethereum EOA)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/change_session_key_label": { + "post": { + "tags": ["Private"], + "summary": "Change Session Key Label", + "description": "", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["label"], + "properties": { + "label": { + "title": "label", + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["label"], + "properties": { + "label": { + "title": "label", + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/get_mmp_config": { + "post": { + "tags": ["Private"], + "summary": "Get Mmp Config", + "description": "Get the current mmp config for a subaccount (optionally filtered by currency)", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "", + "items": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency to get the config for. If not provided, returns all configs for the subaccount", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get the config" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/set_mmp_config": { + "post": { + "tags": ["Private"], + "summary": "Set Mmp Config", + "description": "Set the mmp config for the subaccount and currency", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/reset_mmp": { + "post": { + "tags": ["Private"], + "summary": "Reset Mmp", + "description": "Resets (unfreezes) the mmp state for a subaccount (optionally filtered by currency)", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "string", + "enum": ["ok"], + "description": "The result of this method call, `ok` if successful" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency to reset the mmp for. If not provided, resets all configs for the subaccount", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to reset the mmp state" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/private/set_cancel_on_disconnect": { + "post": { + "tags": ["Private"], + "summary": "Set Cancel On Disconnect", + "description": "Enables cancel on disconnect for the account", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "string", + "enum": ["ok"], + "description": "" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "required": ["enabled", "wallet"], + "properties": { + "enabled": { + "title": "enabled", + "type": "boolean", + "description": "Whether to enable or disable cancel on disconnect" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Public key (wallet) of the account" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + } + }, + "/public/get_time": { + "post": { + "tags": ["Public"], + "summary": "Get Time", + "description": "", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "integer", + "description": "Current time in milliseconds since UNIX epoch" + } + }, + "type": "object", + "additionalProperties": false + } + } + } + } + }, + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "properties": {}, + "type": "object", + "additionalProperties": false + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PrivateTransferPositionParamsSchema": { + "required": ["maker_params", "taker_params", "wallet"], + "properties": { + "maker_params": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_params": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Public key (wallet) of the account" + } + }, + "type": "object", + "additionalProperties": false + }, + "TradeModuleParamsSchema": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateTransferPositionResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["maker_order", "maker_trade", "taker_order", "taker_trade"], + "properties": { + "maker_order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "maker_trade": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_trade": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateTransferPositionResultSchema": { + "required": ["maker_order", "maker_trade", "taker_order", "taker_trade"], + "properties": { + "maker_order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "maker_trade": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_trade": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "OrderResponseSchema": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "TradeResponseSchema": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicMarginWatchParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID to get margin for." + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicMarginWatchResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "currency", + "maintenance_margin", + "margin_type", + "subaccount_id", + "subaccount_value", + "valuation_timestamp" + ], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of subaccount" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation." + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "valuation_timestamp": { + "title": "valuation_timestamp", + "type": "integer", + "description": "Timestamp (in seconds since epoch) of when margin and MtM were computed." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicMarginWatchResultSchema": { + "required": [ + "currency", + "maintenance_margin", + "margin_type", + "subaccount_id", + "subaccount_value", + "valuation_timestamp" + ], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of subaccount" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation." + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "valuation_timestamp": { + "title": "valuation_timestamp", + "type": "integer", + "description": "Timestamp (in seconds since epoch) of when margin and MtM were computed." + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetLiquidationHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetLiquidationHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "", + "items": { + "required": ["auction_id", "auction_type", "bids", "end_timestamp", "fee", "start_timestamp", "tx_hash"], + "properties": { + "auction_id": { + "title": "auction_id", + "type": "string", + "description": "Unique ID of the auction" + }, + "auction_type": { + "title": "auction_type", + "type": "string", + "enum": ["solvent", "insolvent"], + "description": "Type of auction" + }, + "bids": { + "title": "bids", + "type": "array", + "description": "List of auction bid events", + "items": { + "required": [ + "amounts_liquidated", + "cash_received", + "discount_pnl", + "percent_liquidated", + "positions_realized_pnl", + "realized_pnl", + "timestamp", + "tx_hash" + ], + "properties": { + "amounts_liquidated": { + "title": "amounts_liquidated", + "type": "object", + "description": "Amounts of each asset that were closed", + "additionalProperties": { + "title": "amounts_liquidated", + "type": "string", + "format": "decimal" + } + }, + "cash_received": { + "title": "cash_received", + "type": "string", + "format": "decimal", + "description": "Cash received for auctioning off the percentage of the subaccount" + }, + "discount_pnl": { + "title": "discount_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL due to being liquidated at a discount to mark portfolio value" + }, + "percent_liquidated": { + "title": "percent_liquidated", + "type": "string", + "format": "decimal", + "description": "Percent of the subaccount that was liquidated" + }, + "positions_realized_pnl": { + "title": "positions_realized_pnl", + "type": "object", + "description": "Realized PnL of each position that was closed", + "additionalProperties": { + "title": "positions_realized_pnl", + "type": "string", + "format": "decimal" + } + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the bid (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the bid transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": null, + "description": "Timestamp of the auction end (in ms since UNIX epoch), or `null` if not ended", + "nullable": true + }, + "fee": { + "title": "fee", + "type": "string", + "format": "decimal", + "description": "Fee paid by the subaccount" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Timestamp of the auction start (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that started the auction" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "AuctionResultSchema": { + "required": ["auction_id", "auction_type", "bids", "end_timestamp", "fee", "start_timestamp", "tx_hash"], + "properties": { + "auction_id": { + "title": "auction_id", + "type": "string", + "description": "Unique ID of the auction" + }, + "auction_type": { + "title": "auction_type", + "type": "string", + "enum": ["solvent", "insolvent"], + "description": "Type of auction" + }, + "bids": { + "title": "bids", + "type": "array", + "description": "List of auction bid events", + "items": { + "required": [ + "amounts_liquidated", + "cash_received", + "discount_pnl", + "percent_liquidated", + "positions_realized_pnl", + "realized_pnl", + "timestamp", + "tx_hash" + ], + "properties": { + "amounts_liquidated": { + "title": "amounts_liquidated", + "type": "object", + "description": "Amounts of each asset that were closed", + "additionalProperties": { + "title": "amounts_liquidated", + "type": "string", + "format": "decimal" + } + }, + "cash_received": { + "title": "cash_received", + "type": "string", + "format": "decimal", + "description": "Cash received for auctioning off the percentage of the subaccount" + }, + "discount_pnl": { + "title": "discount_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL due to being liquidated at a discount to mark portfolio value" + }, + "percent_liquidated": { + "title": "percent_liquidated", + "type": "string", + "format": "decimal", + "description": "Percent of the subaccount that was liquidated" + }, + "positions_realized_pnl": { + "title": "positions_realized_pnl", + "type": "object", + "description": "Realized PnL of each position that was closed", + "additionalProperties": { + "title": "positions_realized_pnl", + "type": "string", + "format": "decimal" + } + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the bid (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the bid transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": null, + "description": "Timestamp of the auction end (in ms since UNIX epoch), or `null` if not ended", + "nullable": true + }, + "fee": { + "title": "fee", + "type": "string", + "format": "decimal", + "description": "Fee paid by the subaccount" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Timestamp of the auction start (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that started the auction" + } + }, + "type": "object", + "additionalProperties": false + }, + "AuctionBidEventSchema": { + "required": [ + "amounts_liquidated", + "cash_received", + "discount_pnl", + "percent_liquidated", + "positions_realized_pnl", + "realized_pnl", + "timestamp", + "tx_hash" + ], + "properties": { + "amounts_liquidated": { + "title": "amounts_liquidated", + "type": "object", + "description": "Amounts of each asset that were closed", + "additionalProperties": { + "title": "amounts_liquidated", + "type": "string", + "format": "decimal" + } + }, + "cash_received": { + "title": "cash_received", + "type": "string", + "format": "decimal", + "description": "Cash received for auctioning off the percentage of the subaccount" + }, + "discount_pnl": { + "title": "discount_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL due to being liquidated at a discount to mark portfolio value" + }, + "percent_liquidated": { + "title": "percent_liquidated", + "type": "string", + "format": "decimal", + "description": "Percent of the subaccount that was liquidated" + }, + "positions_realized_pnl": { + "title": "positions_realized_pnl", + "type": "object", + "description": "Realized PnL of each position that was closed", + "additionalProperties": { + "title": "positions_realized_pnl", + "type": "string", + "format": "decimal" + } + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the bid (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the bid transaction" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetPositionsParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetPositionsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["positions", "subaccount_id"], + "properties": { + "positions": { + "title": "positions", + "type": "array", + "description": "All active positions of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetPositionsResultSchema": { + "required": ["positions", "subaccount_id"], + "properties": { + "positions": { + "title": "positions", + "type": "array", + "description": "All active positions of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PositionResponseSchema": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetFundingHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Instrument name (returns history for all perpetuals if not provided)", + "nullable": true + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetFundingHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of funding payments", + "items": { + "required": ["funding", "instrument_name", "timestamp"], + "properties": { + "funding": { + "title": "funding", + "type": "string", + "format": "decimal", + "description": "Dollar funding paid (if negative) or received (if positive) by the subaccount" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the funding payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetFundingHistoryResultSchema": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of funding payments", + "items": { + "required": ["funding", "instrument_name", "timestamp"], + "properties": { + "funding": { + "title": "funding", + "type": "string", + "format": "decimal", + "description": "Dollar funding paid (if negative) or received (if positive) by the subaccount" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the funding payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "FundingPaymentSchema": { + "required": ["funding", "instrument_name", "timestamp"], + "properties": { + "funding": { + "title": "funding", + "type": "string", + "format": "decimal", + "description": "Dollar funding paid (if negative) or received (if positive) by the subaccount" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the funding payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateOrderParamsSchema": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "Optional user-defined label for the order" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "default": false, + "description": "Whether the order is tagged for market maker protections (default false)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_type": { + "title": "order_type", + "type": "string", + "default": "limit", + "enum": ["limit", "market"], + "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" + }, + "reduce_only": { + "title": "reduce_only", + "type": "boolean", + "default": 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)" + }, + "referral_code": { + "title": "referral_code", + "type": "string", + "default": "", + "description": "Optional referral code for the order" + }, + "reject_timestamp": { + "title": "reject_timestamp", + "type": "integer", + "default": 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." + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "default": "gtc", + "enum": ["gtc", "post_only", "fok", "ioc"], + "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." + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateOrderResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["order", "trades"], + "properties": { + "order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "trades": { + "title": "trades", + "type": "array", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateOrderResultSchema": { + "required": ["order", "trades"], + "properties": { + "order": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "trades": { + "title": "trades", + "type": "array", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateChangeSubaccountLabelParamsSchema": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User defined label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateChangeSubaccountLabelResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User defined label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateChangeSubaccountLabelResultSchema": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User defined label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetMarginParamsSchema": { + "required": ["margin_type", "simulated_positions"], + "properties": { + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "`PM` (Portfolio Margin) or `SM` (Standard Margin)" + }, + "simulated_position_changes": { + "title": "simulated_position_changes", + "type": "array", + "default": null, + "description": "Optional, add positions to simulate a trade", + "items": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "nullable": true + }, + "simulated_positions": { + "title": "simulated_positions", + "type": "array", + "description": "List of positions in a simulated portfolio", + "items": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "SimulatedPositionSchema": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetMarginResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "is_valid_trade", + "post_initial_margin", + "post_maintenance_margin", + "pre_initial_margin", + "pre_maintenance_margin", + "subaccount_id" + ], + "properties": { + "is_valid_trade": { + "title": "is_valid_trade", + "type": "boolean", + "description": "True if trade passes margin requirement" + }, + "post_initial_margin": { + "title": "post_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement post trade" + }, + "post_maintenance_margin": { + "title": "post_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement post trade" + }, + "pre_initial_margin": { + "title": "pre_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement before trade" + }, + "pre_maintenance_margin": { + "title": "pre_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement before trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetMarginResultSchema": { + "required": [ + "is_valid_trade", + "post_initial_margin", + "post_maintenance_margin", + "pre_initial_margin", + "pre_maintenance_margin", + "subaccount_id" + ], + "properties": { + "is_valid_trade": { + "title": "is_valid_trade", + "type": "boolean", + "description": "True if trade passes margin requirement" + }, + "post_initial_margin": { + "title": "post_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement post trade" + }, + "post_maintenance_margin": { + "title": "post_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement post trade" + }, + "pre_initial_margin": { + "title": "pre_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement before trade" + }, + "pre_maintenance_margin": { + "title": "pre_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement before trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTransactionParamsSchema": { + "required": ["transaction_id"], + "properties": { + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "transaction_id of the transaction to get" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTransactionResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_hash"], + "properties": { + "status": { + "title": "status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Status of the transaction" + }, + "transaction_hash": { + "title": "transaction_hash", + "type": "string", + "default": null, + "description": "Transaction hash of a pending tx", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTransactionResultSchema": { + "required": ["status", "transaction_hash"], + "properties": { + "status": { + "title": "status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Status of the transaction" + }, + "transaction_hash": { + "title": "transaction_hash", + "type": "string", + "default": null, + "description": "Transaction hash of a pending tx", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "collaterals", + "collaterals_initial_margin", + "collaterals_maintenance_margin", + "collaterals_value", + "currency", + "initial_margin", + "maintenance_margin", + "margin_type", + "open_orders", + "open_orders_margin", + "positions", + "positions_initial_margin", + "positions_maintenance_margin", + "positions_value", + "subaccount_id", + "subaccount_value" + ], + "properties": { + "collaterals": { + "title": "collaterals", + "type": "array", + "description": "All collaterals that count towards margin of subaccount", + "items": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "collaterals_initial_margin": { + "title": "collaterals_initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin credit contributed by collaterals" + }, + "collaterals_maintenance_margin": { + "title": "collaterals_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin credit contributed by collaterals" + }, + "collaterals_value": { + "title": "collaterals_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all collaterals" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of subaccount" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin requirement of all positions and collaterals.Trades will be rejected if this value falls below zero after the trade." + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation." + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))" + }, + "open_orders": { + "title": "open_orders", + "type": "array", + "description": "All open orders of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "Total margin requirement of all open orders.Orders will be rejected if this value plus initial margin are below zero after the order." + }, + "positions": { + "title": "positions", + "type": "array", + "description": "All active positions of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "positions_initial_margin": { + "title": "positions_initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin requirement of all positions" + }, + "positions_maintenance_margin": { + "title": "positions_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions" + }, + "positions_value": { + "title": "positions_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountResultSchema": { + "required": [ + "collaterals", + "collaterals_initial_margin", + "collaterals_maintenance_margin", + "collaterals_value", + "currency", + "initial_margin", + "maintenance_margin", + "margin_type", + "open_orders", + "open_orders_margin", + "positions", + "positions_initial_margin", + "positions_maintenance_margin", + "positions_value", + "subaccount_id", + "subaccount_value" + ], + "properties": { + "collaterals": { + "title": "collaterals", + "type": "array", + "description": "All collaterals that count towards margin of subaccount", + "items": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "collaterals_initial_margin": { + "title": "collaterals_initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin credit contributed by collaterals" + }, + "collaterals_maintenance_margin": { + "title": "collaterals_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin credit contributed by collaterals" + }, + "collaterals_value": { + "title": "collaterals_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all collaterals" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of subaccount" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin requirement of all positions and collaterals.Trades will be rejected if this value falls below zero after the trade." + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation." + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))" + }, + "open_orders": { + "title": "open_orders", + "type": "array", + "description": "All open orders of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "Total margin requirement of all open orders.Orders will be rejected if this value plus initial margin are below zero after the order." + }, + "positions": { + "title": "positions", + "type": "array", + "description": "All active positions of subaccount", + "items": { + "required": [ + "amount", + "average_price", + "cumulative_funding", + "delta", + "gamma", + "index_price", + "initial_margin", + "instrument_name", + "instrument_type", + "leverage", + "liquidation_price", + "maintenance_margin", + "mark_price", + "mark_value", + "net_settlements", + "open_orders_margin", + "pending_funding", + "realized_pnl", + "theta", + "unrealized_pnl", + "vega" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount held by subaccount" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average price of whole position" + }, + "cumulative_funding": { + "title": "cumulative_funding", + "type": "string", + "format": "decimal", + "description": "Cumulative funding for the position (only for perpetuals)." + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Asset delta (w.r.t. forward price for options, `1.0` for perps)" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Asset gamma (zero for non-options)" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Current index (oracle) price for position's currency" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD initial margin requirement for this position" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name (same as the base Asset name)" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "leverage": { + "title": "leverage", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`", + "nullable": true + }, + "liquidation_price": { + "title": "liquidation_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Index price at which position will be liquidated", + "nullable": true + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD maintenance margin requirement for this position" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price for position's instrument" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price" + }, + "net_settlements": { + "title": "net_settlements", + "type": "string", + "format": "decimal", + "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." + }, + "open_orders_margin": { + "title": "open_orders_margin", + "type": "string", + "format": "decimal", + "description": "USD margin requirement for all open orders for this asset / instrument" + }, + "pending_funding": { + "title": "pending_funding", + "type": "string", + "format": "decimal", + "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." + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized trading profit or loss of the position." + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Asset theta (zero for non-options)" + }, + "unrealized_pnl": { + "title": "unrealized_pnl", + "type": "string", + "format": "decimal", + "description": "Unrealized trading profit or loss of the position." + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Asset vega (zero for non-options)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "positions_initial_margin": { + "title": "positions_initial_margin", + "type": "string", + "format": "decimal", + "description": "Total initial margin requirement of all positions" + }, + "positions_maintenance_margin": { + "title": "positions_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Total maintenance margin requirement of all positions" + }, + "positions_value": { + "title": "positions_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + } + }, + "type": "object", + "additionalProperties": false + }, + "CollateralResponseSchema": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrderParamsSchema": { + "required": ["order_id", "subaccount_id"], + "properties": { + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrderResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrderResultSchema": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateResetMmpParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency to reset the mmp for. If not provided, resets all configs for the subaccount", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to reset the mmp state" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateResetMmpResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "string", + "enum": ["ok"], + "description": "The result of this method call, `ok` if successful" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTickerParamsSchema": { + "required": ["instrument_name"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTickerResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "best_ask_amount", + "best_ask_price", + "best_bid_amount", + "best_bid_price", + "index_price", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "mark_price", + "max_price", + "maximum_amount", + "min_price", + "minimum_amount", + "option_details", + "option_pricing", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "stats", + "taker_fee_rate", + "tick_size", + "timestamp" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "best_ask_amount": { + "title": "best_ask_amount", + "type": "string", + "format": "decimal", + "description": "Amount of contracts / tokens available at best ask price" + }, + "best_ask_price": { + "title": "best_ask_price", + "type": "string", + "format": "decimal", + "description": "Best ask price" + }, + "best_bid_amount": { + "title": "best_bid_amount", + "type": "string", + "format": "decimal", + "description": "Amount of contracts / tokens available at best bid price" + }, + "best_bid_price": { + "title": "best_bid_price", + "type": "string", + "format": "decimal", + "description": "Best bid price" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "max_price": { + "title": "max_price", + "type": "string", + "format": "decimal", + "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)." + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "min_price": { + "title": "min_price", + "type": "string", + "format": "decimal", + "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)." + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "option_pricing": { + "required": [ + "ask_iv", + "bid_iv", + "delta", + "forward_price", + "gamma", + "iv", + "mark_price", + "rho", + "theta", + "vega" + ], + "properties": { + "ask_iv": { + "title": "ask_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best ask" + }, + "bid_iv": { + "title": "bid_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best bid" + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Delta of the option" + }, + "forward_price": { + "title": "forward_price", + "type": "string", + "format": "decimal", + "description": "Forward price used to calculate option premium" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Gamma of the option" + }, + "iv": { + "title": "iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the option" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the option" + }, + "rho": { + "title": "rho", + "type": "string", + "format": "decimal", + "description": "Rho of the option" + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Theta of the option" + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Vega of the option" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "stats": { + "required": [ + "contract_volume", + "high", + "low", + "num_trades", + "open_interest", + "percent_change", + "usd_change" + ], + "properties": { + "contract_volume": { + "title": "contract_volume", + "type": "string", + "format": "decimal", + "description": "Number of contracts traded during last 24 hours" + }, + "high": { + "title": "high", + "type": "string", + "format": "decimal", + "description": "Highest trade price during last 24h" + }, + "low": { + "title": "low", + "type": "string", + "format": "decimal", + "description": "Lowest trade price during last 24h" + }, + "num_trades": { + "title": "num_trades", + "type": "string", + "format": "decimal", + "description": "Number of trades during last 24h " + }, + "open_interest": { + "title": "open_interest", + "type": "string", + "format": "decimal", + "description": "Current total open interest" + }, + "percent_change": { + "title": "percent_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price" + }, + "usd_change": { + "title": "usd_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change in USD." + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the ticker feed snapshot" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTickerResultSchema": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "best_ask_amount", + "best_ask_price", + "best_bid_amount", + "best_bid_price", + "index_price", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "mark_price", + "max_price", + "maximum_amount", + "min_price", + "minimum_amount", + "option_details", + "option_pricing", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "stats", + "taker_fee_rate", + "tick_size", + "timestamp" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "best_ask_amount": { + "title": "best_ask_amount", + "type": "string", + "format": "decimal", + "description": "Amount of contracts / tokens available at best ask price" + }, + "best_ask_price": { + "title": "best_ask_price", + "type": "string", + "format": "decimal", + "description": "Best ask price" + }, + "best_bid_amount": { + "title": "best_bid_amount", + "type": "string", + "format": "decimal", + "description": "Amount of contracts / tokens available at best bid price" + }, + "best_bid_price": { + "title": "best_bid_price", + "type": "string", + "format": "decimal", + "description": "Best bid price" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "max_price": { + "title": "max_price", + "type": "string", + "format": "decimal", + "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)." + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "min_price": { + "title": "min_price", + "type": "string", + "format": "decimal", + "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)." + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "option_pricing": { + "required": [ + "ask_iv", + "bid_iv", + "delta", + "forward_price", + "gamma", + "iv", + "mark_price", + "rho", + "theta", + "vega" + ], + "properties": { + "ask_iv": { + "title": "ask_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best ask" + }, + "bid_iv": { + "title": "bid_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best bid" + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Delta of the option" + }, + "forward_price": { + "title": "forward_price", + "type": "string", + "format": "decimal", + "description": "Forward price used to calculate option premium" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Gamma of the option" + }, + "iv": { + "title": "iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the option" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the option" + }, + "rho": { + "title": "rho", + "type": "string", + "format": "decimal", + "description": "Rho of the option" + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Theta of the option" + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Vega of the option" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "stats": { + "required": [ + "contract_volume", + "high", + "low", + "num_trades", + "open_interest", + "percent_change", + "usd_change" + ], + "properties": { + "contract_volume": { + "title": "contract_volume", + "type": "string", + "format": "decimal", + "description": "Number of contracts traded during last 24 hours" + }, + "high": { + "title": "high", + "type": "string", + "format": "decimal", + "description": "Highest trade price during last 24h" + }, + "low": { + "title": "low", + "type": "string", + "format": "decimal", + "description": "Lowest trade price during last 24h" + }, + "num_trades": { + "title": "num_trades", + "type": "string", + "format": "decimal", + "description": "Number of trades during last 24h " + }, + "open_interest": { + "title": "open_interest", + "type": "string", + "format": "decimal", + "description": "Current total open interest" + }, + "percent_change": { + "title": "percent_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price" + }, + "usd_change": { + "title": "usd_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change in USD." + } + }, + "type": "object", + "additionalProperties": false + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the ticker feed snapshot" + } + }, + "type": "object", + "additionalProperties": false + }, + "OptionPublicDetailsSchema": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "OptionPricingSchema": { + "required": ["ask_iv", "bid_iv", "delta", "forward_price", "gamma", "iv", "mark_price", "rho", "theta", "vega"], + "properties": { + "ask_iv": { + "title": "ask_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best ask" + }, + "bid_iv": { + "title": "bid_iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the current best bid" + }, + "delta": { + "title": "delta", + "type": "string", + "format": "decimal", + "description": "Delta of the option" + }, + "forward_price": { + "title": "forward_price", + "type": "string", + "format": "decimal", + "description": "Forward price used to calculate option premium" + }, + "gamma": { + "title": "gamma", + "type": "string", + "format": "decimal", + "description": "Gamma of the option" + }, + "iv": { + "title": "iv", + "type": "string", + "format": "decimal", + "description": "Implied volatility of the option" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the option" + }, + "rho": { + "title": "rho", + "type": "string", + "format": "decimal", + "description": "Rho of the option" + }, + "theta": { + "title": "theta", + "type": "string", + "format": "decimal", + "description": "Theta of the option" + }, + "vega": { + "title": "vega", + "type": "string", + "format": "decimal", + "description": "Vega of the option" + } + }, + "type": "object", + "additionalProperties": false + }, + "PerpPublicDetailsSchema": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "AggregateTradingStatsSchema": { + "required": ["contract_volume", "high", "low", "num_trades", "open_interest", "percent_change", "usd_change"], + "properties": { + "contract_volume": { + "title": "contract_volume", + "type": "string", + "format": "decimal", + "description": "Number of contracts traded during last 24 hours" + }, + "high": { + "title": "high", + "type": "string", + "format": "decimal", + "description": "Highest trade price during last 24h" + }, + "low": { + "title": "low", + "type": "string", + "format": "decimal", + "description": "Lowest trade price during last 24h" + }, + "num_trades": { + "title": "num_trades", + "type": "string", + "format": "decimal", + "description": "Number of trades during last 24h " + }, + "open_interest": { + "title": "open_interest", + "type": "string", + "format": "decimal", + "description": "Current total open interest" + }, + "percent_change": { + "title": "percent_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price" + }, + "usd_change": { + "title": "usd_change", + "type": "string", + "format": "decimal", + "description": "24-hour price change in USD." + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSetMmpConfigParamsSchema": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSetMmpConfigResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSetMmpConfigResultSchema": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelParamsSchema": { + "required": ["instrument_name", "order_id", "subaccount_id"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string" + }, + "order_id": { + "title": "order_id", + "type": "string", + "format": "uuid" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelResultSchema": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateOrderDebugParamsSchema": { + "required": [ + "amount", + "direction", + "instrument_name", + "limit_price", + "max_fee", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "Optional user-defined label for the order" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "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." + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order." + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "default": false, + "description": "Whether the order is tagged for market maker protections (default false)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_type": { + "title": "order_type", + "type": "string", + "default": "limit", + "enum": ["limit", "market"], + "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" + }, + "reduce_only": { + "title": "reduce_only", + "type": "boolean", + "default": 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)" + }, + "referral_code": { + "title": "referral_code", + "type": "string", + "default": "", + "description": "Optional referral code for the order" + }, + "reject_timestamp": { + "title": "reject_timestamp", + "type": "integer", + "default": 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." + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Etherium signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "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." + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "default": "gtc", + "enum": ["gtc", "post_only", "fok", "ioc"], + "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." + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateOrderDebugResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["action_hash", "encoded_data", "encoded_data_hashed", "raw_data", "typed_data_hash"], + "properties": { + "action_hash": { + "title": "action_hash", + "type": "string", + "description": "Keccak hashed action data" + }, + "encoded_data": { + "title": "encoded_data", + "type": "string", + "description": "ABI encoded order data" + }, + "encoded_data_hashed": { + "title": "encoded_data_hashed", + "type": "string", + "description": "Keccak hashed encoded_data" + }, + "raw_data": { + "required": ["data", "expiry", "module", "nonce", "owner", "signature", "signer", "subaccount_id"], + "properties": { + "data": { + "required": [ + "asset", + "desired_amount", + "is_bid", + "limit_price", + "recipient_id", + "sub_id", + "trade_id", + "worst_fee" + ], + "properties": { + "asset": { + "title": "asset", + "type": "string" + }, + "desired_amount": { + "title": "desired_amount", + "type": "string", + "format": "decimal" + }, + "is_bid": { + "title": "is_bid", + "type": "boolean" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal" + }, + "recipient_id": { + "title": "recipient_id", + "type": "integer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer" + }, + "trade_id": { + "title": "trade_id", + "type": "string" + }, + "worst_fee": { + "title": "worst_fee", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "expiry": { + "title": "expiry", + "type": "integer" + }, + "module": { + "title": "module", + "type": "string" + }, + "nonce": { + "title": "nonce", + "type": "integer" + }, + "owner": { + "title": "owner", + "type": "string" + }, + "signature": { + "title": "signature", + "type": "string" + }, + "signer": { + "title": "signer", + "type": "string" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer" + } + }, + "type": "object", + "additionalProperties": false + }, + "typed_data_hash": { + "title": "typed_data_hash", + "type": "string", + "description": "EIP 712 typed data hash" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateOrderDebugResultSchema": { + "required": ["action_hash", "encoded_data", "encoded_data_hashed", "raw_data", "typed_data_hash"], + "properties": { + "action_hash": { + "title": "action_hash", + "type": "string", + "description": "Keccak hashed action data" + }, + "encoded_data": { + "title": "encoded_data", + "type": "string", + "description": "ABI encoded order data" + }, + "encoded_data_hashed": { + "title": "encoded_data_hashed", + "type": "string", + "description": "Keccak hashed encoded_data" + }, + "raw_data": { + "required": ["data", "expiry", "module", "nonce", "owner", "signature", "signer", "subaccount_id"], + "properties": { + "data": { + "required": [ + "asset", + "desired_amount", + "is_bid", + "limit_price", + "recipient_id", + "sub_id", + "trade_id", + "worst_fee" + ], + "properties": { + "asset": { + "title": "asset", + "type": "string" + }, + "desired_amount": { + "title": "desired_amount", + "type": "string", + "format": "decimal" + }, + "is_bid": { + "title": "is_bid", + "type": "boolean" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal" + }, + "recipient_id": { + "title": "recipient_id", + "type": "integer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer" + }, + "trade_id": { + "title": "trade_id", + "type": "string" + }, + "worst_fee": { + "title": "worst_fee", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "expiry": { + "title": "expiry", + "type": "integer" + }, + "module": { + "title": "module", + "type": "string" + }, + "nonce": { + "title": "nonce", + "type": "integer" + }, + "owner": { + "title": "owner", + "type": "string" + }, + "signature": { + "title": "signature", + "type": "string" + }, + "signer": { + "title": "signer", + "type": "string" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer" + } + }, + "type": "object", + "additionalProperties": false + }, + "typed_data_hash": { + "title": "typed_data_hash", + "type": "string", + "description": "EIP 712 typed data hash" + } + }, + "type": "object", + "additionalProperties": false + }, + "SignedTradeOrderSchema": { + "required": ["data", "expiry", "module", "nonce", "owner", "signature", "signer", "subaccount_id"], + "properties": { + "data": { + "required": [ + "asset", + "desired_amount", + "is_bid", + "limit_price", + "recipient_id", + "sub_id", + "trade_id", + "worst_fee" + ], + "properties": { + "asset": { + "title": "asset", + "type": "string" + }, + "desired_amount": { + "title": "desired_amount", + "type": "string", + "format": "decimal" + }, + "is_bid": { + "title": "is_bid", + "type": "boolean" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal" + }, + "recipient_id": { + "title": "recipient_id", + "type": "integer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer" + }, + "trade_id": { + "title": "trade_id", + "type": "string" + }, + "worst_fee": { + "title": "worst_fee", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "expiry": { + "title": "expiry", + "type": "integer" + }, + "module": { + "title": "module", + "type": "string" + }, + "nonce": { + "title": "nonce", + "type": "integer" + }, + "owner": { + "title": "owner", + "type": "string" + }, + "signature": { + "title": "signature", + "type": "string" + }, + "signer": { + "title": "signer", + "type": "string" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer" + } + }, + "type": "object", + "additionalProperties": false + }, + "TradeModuleDataSchema": { + "required": [ + "asset", + "desired_amount", + "is_bid", + "limit_price", + "recipient_id", + "sub_id", + "trade_id", + "worst_fee" + ], + "properties": { + "asset": { + "title": "asset", + "type": "string" + }, + "desired_amount": { + "title": "desired_amount", + "type": "string", + "format": "decimal" + }, + "is_bid": { + "title": "is_bid", + "type": "boolean" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal" + }, + "recipient_id": { + "title": "recipient_id", + "type": "integer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer" + }, + "trade_id": { + "title": "trade_id", + "type": "string" + }, + "worst_fee": { + "title": "worst_fee", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelAllParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelAllResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelAllResultSchema": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTimeParamsSchema": { + "properties": {}, + "type": "object", + "additionalProperties": false + }, + "PublicGetTimeResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "integer", + "description": "Current time in milliseconds since UNIX epoch" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountValueHistoryParamsSchema": { + "required": ["end_timestamp", "period", "start_timestamp", "subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "description": "End timestamp" + }, + "period": { + "title": "period", + "type": "integer", + "description": "Period" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Start timestamp" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountValueHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["subaccount_id", "subaccount_value_history"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value_history": { + "title": "subaccount_value_history", + "type": "array", + "description": "Subaccount value history", + "items": { + "required": ["subaccount_value", "timestamp"], + "properties": { + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the subaccount value was recorded into the database" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountValueHistoryResultSchema": { + "required": ["subaccount_id", "subaccount_value_history"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "subaccount_value_history": { + "title": "subaccount_value_history", + "type": "array", + "description": "Subaccount value history", + "items": { + "required": ["subaccount_value", "timestamp"], + "properties": { + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the subaccount value was recorded into the database" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "SubAccountValueHistoryResponseSchema": { + "required": ["subaccount_value", "timestamp"], + "properties": { + "subaccount_value": { + "title": "subaccount_value", + "type": "string", + "format": "decimal", + "description": "Total mark-to-market value of all positions and collaterals" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the subaccount value was recorded into the database" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByInstrumentParamsSchema": { + "required": ["instrument_name", "subaccount_id"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Cancel all orders for this instrument" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByInstrumentResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByInstrumentResultSchema": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrdersParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Filter by instrument name", + "nullable": true + }, + "label": { + "title": "label", + "type": "string", + "default": null, + "description": "Filter by label", + "nullable": true + }, + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return (default 1, returns last if above `num_pages`)" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 100, + "description": "Number of results per page (default 100, max 1000)" + }, + "status": { + "title": "status", + "type": "string", + "default": null, + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Filter by order status", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrdersResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["orders", "pagination", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrdersResultSchema": { + "required": ["orders", "pagination", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PaginationInfoSchema": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCreateSubaccountParamsSchema": { + "required": [ + "amount", + "asset_name", + "margin_type", + "nonce", + "signature", + "signature_expiry_sec", + "signer", + "wallet" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to deposit" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to deposit" + }, + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Base currency of the subaccount (only for `PM`)", + "nullable": true + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "`PM` (Portfolio Margin) or `SM` (Standard Margin)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the deposit" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the deposit" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCreateSubaccountResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the request" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCreateSubaccountResultSchema": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the request" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetErc20TransferHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetErc20TransferHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of erc20 transfers", + "items": { + "required": ["amount", "asset", "counterparty_subaccount_id", "is_outgoing", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "counterparty_subaccount_id": { + "title": "counterparty_subaccount_id", + "type": "integer", + "description": "Recipient or sender subaccount_id of transfer" + }, + "is_outgoing": { + "title": "is_outgoing", + "type": "boolean", + "description": "True if the transfer was initiated by the subaccount, False otherwise" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the transfer (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetErc20TransferHistoryResultSchema": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of erc20 transfers", + "items": { + "required": ["amount", "asset", "counterparty_subaccount_id", "is_outgoing", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "counterparty_subaccount_id": { + "title": "counterparty_subaccount_id", + "type": "integer", + "description": "Recipient or sender subaccount_id of transfer" + }, + "is_outgoing": { + "title": "is_outgoing", + "type": "boolean", + "description": "True if the transfer was initiated by the subaccount, False otherwise" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the transfer (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "ERC20TransferSchema": { + "required": ["amount", "asset", "counterparty_subaccount_id", "is_outgoing", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "counterparty_subaccount_id": { + "title": "counterparty_subaccount_id", + "type": "integer", + "description": "Recipient or sender subaccount_id of transfer" + }, + "is_outgoing": { + "title": "is_outgoing", + "type": "boolean", + "description": "True if the transfer was initiated by the subaccount, False otherwise" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the transfer (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSetCancelOnDisconnectParamsSchema": { + "required": ["enabled", "wallet"], + "properties": { + "enabled": { + "title": "enabled", + "type": "boolean", + "description": "Whether to enable or disable cancel on disconnect" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Public key (wallet) of the account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSetCancelOnDisconnectResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "string", + "enum": ["ok"], + "description": "" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetMmpConfigParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency to get the config for. If not provided, returns all configs for the subaccount", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get the config" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetMmpConfigResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "", + "items": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "MMPConfigParamsSchema": { + "required": ["currency", "mmp_frozen_time", "mmp_interval", "subaccount_id"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency of this mmp config" + }, + "mmp_amount_limit": { + "title": "mmp_amount_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_delta_limit": { + "title": "mmp_delta_limit", + "type": "string", + "format": "decimal", + "default": "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)" + }, + "mmp_frozen_time": { + "title": "mmp_frozen_time", + "type": "integer", + "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" + }, + "mmp_interval": { + "title": "mmp_interval", + "type": "integer", + "description": "Time interval in ms over which the limits are monotored, if 0 then mmp is disabled" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to set the config" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateUpdateNotificationsParamsSchema": { + "required": ["notification_ids", "subaccount_id"], + "properties": { + "notification_ids": { + "title": "notification_ids", + "type": "array", + "description": "List of notification IDs to be marked as seen", + "items": { + "title": "notification_ids", + "type": "integer" + } + }, + "status": { + "title": "status", + "type": "string", + "default": "seen", + "enum": ["unseen", "seen", "hidden"], + "description": "Status of the notification" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateUpdateNotificationsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["updated_count"], + "properties": { + "updated_count": { + "title": "updated_count", + "type": "integer", + "description": "Number of notifications marked as seen" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateUpdateNotificationsResultSchema": { + "required": ["updated_count"], + "properties": { + "updated_count": { + "title": "updated_count", + "type": "integer", + "description": "Number of notifications marked as seen" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateExpiredAndCancelledHistoryParamsSchema": { + "required": ["end_timestamp", "expiry", "start_timestamp", "subaccount_id", "wallet"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "description": "End Unix timestamp" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Expiry of download link in seconds. Maximum of 604800." + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Start Unix timestamp" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount to download data for" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Wallet to download data for" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateExpiredAndCancelledHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["presigned_urls"], + "properties": { + "presigned_urls": { + "title": "presigned_urls", + "type": "array", + "description": "List of presigned URLs to the snapshots", + "items": { + "title": "presigned_urls", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateExpiredAndCancelledHistoryResultSchema": { + "required": ["presigned_urls"], + "properties": { + "presigned_urls": { + "title": "presigned_urls", + "type": "array", + "description": "List of presigned URLs to the snapshots", + "items": { + "title": "presigned_urls", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateWithdrawParamsSchema": { + "required": ["amount", "asset_name", "nonce", "signature", "signature_expiry_sec", "signer", "subaccount_id"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to withdraw" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to withdraw" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the withdraw" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the withdraw" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateWithdrawResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the withdrawal" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateWithdrawResultSchema": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the withdrawal" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicDeregisterSessionKeyParamsSchema": { + "required": ["public_session_key", "signed_raw_tx", "wallet"], + "properties": { + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "signed_raw_tx": { + "title": "signed_raw_tx", + "type": "string", + "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()`)" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicDeregisterSessionKeyResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["public_session_key", "transaction_id"], + "properties": { + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "ID to lookup status of transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicDeregisterSessionKeyResultSchema": { + "required": ["public_session_key", "transaction_id"], + "properties": { + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "ID to lookup status of transaction" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetNotificationsParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 20, + "description": "Number of results per page" + }, + "status": { + "title": "status", + "type": "string", + "default": null, + "enum": ["unseen", "seen", "hidden"], + "description": "Status of the notification", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "type": { + "title": "type", + "type": "string", + "default": null, + "enum": ["deposit", "withdraw", "transfer", "trade", "settlement", "liquidation", "custom"], + "description": "Status of the notification", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetNotificationsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["notifications", "subaccount_id"], + "properties": { + "notifications": { + "title": "notifications", + "type": "array", + "description": "Notification response", + "items": { + "required": ["event", "event_details", "id", "status", "subaccount_id", "timestamp"], + "properties": { + "event": { + "title": "event", + "type": "string", + "description": "The specific event leading to the notification." + }, + "event_details": { + "title": "event_details", + "type": "object", + "description": "A JSON-structured dictionary containing detailed data or context about the event.", + "additionalProperties": {} + }, + "id": { + "title": "id", + "type": "integer", + "description": "The unique identifier for the notification." + }, + "status": { + "title": "status", + "type": "string", + "description": "The status of the notification, indicating if it has been read, pending, or processed." + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "The subaccount_id associated with the notification." + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp indicating when the notification was created or triggered." + }, + "transaction_id": { + "title": "transaction_id", + "type": "integer", + "default": null, + "description": "The transaction id associated with the notification.", + "nullable": true + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "The transaction hash associated with the notification.", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetNotificationsResultSchema": { + "required": ["notifications", "subaccount_id"], + "properties": { + "notifications": { + "title": "notifications", + "type": "array", + "description": "Notification response", + "items": { + "required": ["event", "event_details", "id", "status", "subaccount_id", "timestamp"], + "properties": { + "event": { + "title": "event", + "type": "string", + "description": "The specific event leading to the notification." + }, + "event_details": { + "title": "event_details", + "type": "object", + "description": "A JSON-structured dictionary containing detailed data or context about the event.", + "additionalProperties": {} + }, + "id": { + "title": "id", + "type": "integer", + "description": "The unique identifier for the notification." + }, + "status": { + "title": "status", + "type": "string", + "description": "The status of the notification, indicating if it has been read, pending, or processed." + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "The subaccount_id associated with the notification." + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp indicating when the notification was created or triggered." + }, + "transaction_id": { + "title": "transaction_id", + "type": "integer", + "default": null, + "description": "The transaction id associated with the notification.", + "nullable": true + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "The transaction hash associated with the notification.", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "NotificationResponseSchema": { + "required": ["event", "event_details", "id", "status", "subaccount_id", "timestamp"], + "properties": { + "event": { + "title": "event", + "type": "string", + "description": "The specific event leading to the notification." + }, + "event_details": { + "title": "event_details", + "type": "object", + "description": "A JSON-structured dictionary containing detailed data or context about the event.", + "additionalProperties": {} + }, + "id": { + "title": "id", + "type": "integer", + "description": "The unique identifier for the notification." + }, + "status": { + "title": "status", + "type": "string", + "description": "The status of the notification, indicating if it has been read, pending, or processed." + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "The subaccount_id associated with the notification." + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp indicating when the notification was created or triggered." + }, + "transaction_id": { + "title": "transaction_id", + "type": "integer", + "default": null, + "description": "The transaction id associated with the notification.", + "nullable": true + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "The transaction hash associated with the notification.", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateDepositParamsSchema": { + "required": ["amount", "asset_name", "nonce", "signature", "signature_expiry_sec", "signer", "subaccount_id"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to deposit" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to deposit" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the deposit" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the deposit" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateDepositResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the deposit" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateDepositResultSchema": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the deposit" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOpenOrdersParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOpenOrdersResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["orders", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOpenOrdersResultSchema": { + "required": ["orders", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetInterestHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetInterestHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of interest payments", + "items": { + "required": ["interest", "timestamp"], + "properties": { + "interest": { + "title": "interest", + "type": "string", + "format": "decimal", + "description": "Dollar interest paid (if negative) or received (if positive) by the subaccount" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the interest payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetInterestHistoryResultSchema": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of interest payments", + "items": { + "required": ["interest", "timestamp"], + "properties": { + "interest": { + "title": "interest", + "type": "string", + "format": "decimal", + "description": "Dollar interest paid (if negative) or received (if positive) by the subaccount" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the interest payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "InterestPaymentSchema": { + "required": ["interest", "timestamp"], + "properties": { + "interest": { + "title": "interest", + "type": "string", + "format": "decimal", + "description": "Dollar interest paid (if negative) or received (if positive) by the subaccount" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the interest payment (in ms since UNIX epoch)" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetInstrumentParamsSchema": { + "required": ["instrument_name"], + "properties": { + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetInstrumentResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "maximum_amount", + "minimum_amount", + "option_details", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "taker_fee_rate", + "tick_size" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetInstrumentResultSchema": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "maximum_amount", + "minimum_amount", + "option_details", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "taker_fee_rate", + "tick_size" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrderHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return (default 1, returns last if above `num_pages`)" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 100, + "description": "Number of results per page (default 100, max 1000)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get order history" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrderHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["orders", "pagination", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOrderHistoryResultSchema": { + "required": ["orders", "pagination", "subaccount_id"], + "properties": { + "orders": { + "title": "orders", + "type": "array", + "description": "List of open orders", + "items": { + "required": [ + "amount", + "average_price", + "cancel_reason", + "creation_timestamp", + "direction", + "filled_amount", + "instrument_name", + "is_transfer", + "label", + "last_update_timestamp", + "limit_price", + "max_fee", + "mmp", + "nonce", + "order_fee", + "order_id", + "order_status", + "order_type", + "signature", + "signature_expiry_sec", + "signer", + "subaccount_id", + "time_in_force" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Order amount in units of the base" + }, + "average_price": { + "title": "average_price", + "type": "string", + "format": "decimal", + "description": "Average fill price" + }, + "cancel_reason": { + "title": "cancel_reason", + "type": "string", + "enum": [ + "", + "user_request", + "mmp_trigger", + "insufficient_margin", + "signed_max_fee_too_low", + "cancel_on_disconnect", + "ioc_or_market_partial_fill", + "session_key_deregistered", + "subaccount_withdrawn", + "compliance" + ], + "description": "If cancelled, reason behind order cancellation" + }, + "creation_timestamp": { + "title": "creation_timestamp", + "type": "integer", + "description": "Creation timestamp (in ms since Unix epoch)" + }, + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "filled_amount": { + "title": "filled_amount", + "type": "string", + "format": "decimal", + "description": "Total filled amount for the order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the order was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "last_update_timestamp": { + "title": "last_update_timestamp", + "type": "integer", + "description": "Last update timestamp (in ms since Unix epoch)" + }, + "limit_price": { + "title": "limit_price", + "type": "string", + "format": "decimal", + "description": "Limit price in quote currency" + }, + "max_fee": { + "title": "max_fee", + "type": "string", + "format": "decimal", + "description": "Max fee in units of the quote currency" + }, + "mmp": { + "title": "mmp", + "type": "boolean", + "description": "Whether the order is tagged for market maker protections" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "order_fee": { + "title": "order_fee", + "type": "string", + "format": "decimal", + "description": "Total order fee paid so far" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "order_status": { + "title": "order_status", + "type": "string", + "enum": ["open", "filled", "rejected", "cancelled", "expired"], + "description": "Order status" + }, + "order_type": { + "title": "order_type", + "type": "string", + "enum": ["limit", "market"], + "description": "Order type" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the order" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Signature expiry timestamp" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Owner wallet address or registered session key that signed order" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "time_in_force": { + "title": "time_in_force", + "type": "string", + "enum": ["gtc", "post_only", "fok", "ioc"], + "description": "Time in force" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get open orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetTradeHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "from_timestamp": { + "title": "from_timestamp", + "type": "integer", + "default": 0, + "description": "Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0." + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Instrument name to filter by", + "nullable": true + }, + "order_id": { + "title": "order_id", + "type": "string", + "default": null, + "description": "Order id to filter by", + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get trades" + }, + "to_timestamp": { + "title": "to_timestamp", + "type": "integer", + "default": 18446744073709552000, + "description": "Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time." + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetTradeHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["subaccount_id", "trades"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get the trade history" + }, + "trades": { + "title": "trades", + "type": "array", + "description": "List of trades", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetTradeHistoryResultSchema": { + "required": ["subaccount_id", "trades"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get the trade history" + }, + "trades": { + "title": "trades", + "type": "array", + "description": "List of trades", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "is_transfer", + "label", + "liquidity_role", + "mark_price", + "order_id", + "realized_pnl", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "is_transfer": { + "title": "is_transfer", + "type": "boolean", + "description": "Whether the trade was generated through `private/transfer_position`" + }, + "label": { + "title": "label", + "type": "string", + "description": "Optional user-defined label for the order" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "order_id": { + "title": "order_id", + "type": "string", + "description": "Order ID" + }, + "realized_pnl": { + "title": "realized_pnl", + "type": "string", + "format": "decimal", + "description": "Realized PnL for this trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "default": null, + "description": "Blockchain transaction hash", + "nullable": true + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["requested", "pending", "settled", "reverted", "ignored"], + "description": "Blockchain transaction status" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetWithdrawalHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetWithdrawalHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of withdrawals", + "items": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the withdrawal (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetWithdrawalHistoryResultSchema": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of withdrawals", + "items": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the withdrawal (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "WithdrawalSchema": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount withdrawn by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset withdrawn" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the withdrawal (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that withdrew the funds" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetMarginParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "simulated_position_changes": { + "title": "simulated_position_changes", + "type": "array", + "default": null, + "description": "Optional, add positions to simulate a trade", + "items": { + "required": ["amount", "instrument_name"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Position amount to simulate" + }, + "entry_price": { + "title": "entry_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Only for perps. Entry price to use in the simulation. Mark price is used if not provided.", + "nullable": true + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + } + }, + "type": "object", + "additionalProperties": false + }, + "nullable": true + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetMarginResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "is_valid_trade", + "post_initial_margin", + "post_maintenance_margin", + "pre_initial_margin", + "pre_maintenance_margin", + "subaccount_id" + ], + "properties": { + "is_valid_trade": { + "title": "is_valid_trade", + "type": "boolean", + "description": "True if trade passes margin requirement" + }, + "post_initial_margin": { + "title": "post_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement post trade" + }, + "post_maintenance_margin": { + "title": "post_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement post trade" + }, + "pre_initial_margin": { + "title": "pre_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement before trade" + }, + "pre_maintenance_margin": { + "title": "pre_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement before trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetMarginResultSchema": { + "required": [ + "is_valid_trade", + "post_initial_margin", + "post_maintenance_margin", + "pre_initial_margin", + "pre_maintenance_margin", + "subaccount_id" + ], + "properties": { + "is_valid_trade": { + "title": "is_valid_trade", + "type": "boolean", + "description": "True if trade passes margin requirement" + }, + "post_initial_margin": { + "title": "post_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement post trade" + }, + "post_maintenance_margin": { + "title": "post_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement post trade" + }, + "pre_initial_margin": { + "title": "pre_initial_margin", + "type": "string", + "format": "decimal", + "description": "Initial margin requirement before trade" + }, + "pre_maintenance_margin": { + "title": "pre_maintenance_margin", + "type": "string", + "format": "decimal", + "description": "Maintenance margin requirement before trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateTransferErc20ParamsSchema": { + "required": ["recipient_details", "recipient_subaccount_id", "sender_details", "subaccount_id", "transfer"], + "properties": { + "recipient_details": { + "required": ["nonce", "signature", "signature_expiry_sec", "signer"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the transfer" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the transfer" + } + }, + "type": "object", + "additionalProperties": false + }, + "recipient_subaccount_id": { + "title": "recipient_subaccount_id", + "type": "integer", + "description": "Subaccount_id of the recipient" + }, + "sender_details": { + "required": ["nonce", "signature", "signature_expiry_sec", "signer"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the transfer" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the transfer" + } + }, + "type": "object", + "additionalProperties": false + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + }, + "transfer": { + "required": ["address", "amount", "sub_id"], + "properties": { + "address": { + "title": "address", + "type": "string", + "description": "Ethereum address of the asset being transferred" + }, + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount to transfer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer", + "description": "Sub ID of the asset being transferred" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "SignatureDetailsSchema": { + "required": ["nonce", "signature", "signature_expiry_sec", "signer"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature": { + "title": "signature", + "type": "string", + "description": "Ethereum signature of the transfer" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the transfer" + } + }, + "type": "object", + "additionalProperties": false + }, + "TransferDetailsSchema": { + "required": ["address", "amount", "sub_id"], + "properties": { + "address": { + "title": "address", + "type": "string", + "description": "Ethereum address of the asset being transferred" + }, + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount to transfer" + }, + "sub_id": { + "title": "sub_id", + "type": "integer", + "description": "Sub ID of the asset being transferred" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateTransferErc20ResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the transfer" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateTransferErc20ResultSchema": { + "required": ["status", "transaction_id"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`requested`" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "Transaction id of the transfer" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicRegisterSessionKeyParamsSchema": { + "required": ["expiry_sec", "label", "public_session_key", "signed_raw_tx", "wallet"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Expiry of the session key" + }, + "label": { + "title": "label", + "type": "string", + "description": "Ethereum wallet address" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "signed_raw_tx": { + "title": "signed_raw_tx", + "type": "string", + "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()`)" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicRegisterSessionKeyResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["label", "public_session_key", "transaction_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "ID to lookup status of transaction" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicRegisterSessionKeyResultSchema": { + "required": ["label", "public_session_key", "transaction_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "transaction_id": { + "title": "transaction_id", + "type": "string", + "format": "uuid", + "description": "ID to lookup status of transaction" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetCollateralsParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetCollateralsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["collaterals", "subaccount_id"], + "properties": { + "collaterals": { + "title": "collaterals", + "type": "array", + "description": "All collaterals that count towards margin of subaccount", + "items": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetCollateralsResultSchema": { + "required": ["collaterals", "subaccount_id"], + "properties": { + "collaterals": { + "title": "collaterals", + "type": "array", + "description": "All collaterals that count towards margin of subaccount", + "items": { + "required": [ + "amount", + "asset_name", + "asset_type", + "cumulative_interest", + "currency", + "initial_margin", + "maintenance_margin", + "mark_price", + "mark_value", + "pending_interest" + ], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Asset amount of given collateral" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Asset name" + }, + "asset_type": { + "title": "asset_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "Type of asset collateral (currently always `erc20`)" + }, + "cumulative_interest": { + "title": "cumulative_interest", + "type": "string", + "format": "decimal", + "description": "Cumulative interest earned on supplying collateral or paid for borrowing" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "initial_margin": { + "title": "initial_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to initial margin" + }, + "maintenance_margin": { + "title": "maintenance_margin", + "type": "string", + "format": "decimal", + "description": "USD value of collateral that contributes to maintenance margin" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Current mark price of the asset" + }, + "mark_value": { + "title": "mark_value", + "type": "string", + "format": "decimal", + "description": "USD value of the collateral (amount * mark price)" + }, + "pending_interest": { + "title": "pending_interest", + "type": "string", + "format": "decimal", + "description": "Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes." + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetSpotFeedHistoryParamsSchema": { + "required": ["currency", "end_timestamp", "period", "start_timestamp"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency" + }, + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "description": "End timestamp" + }, + "period": { + "title": "period", + "type": "integer", + "description": "Period" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "description": "Start timestamp" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetSpotFeedHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["currency", "spot_feed_history"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency" + }, + "spot_feed_history": { + "title": "spot_feed_history", + "type": "array", + "description": "Spot feed history", + "items": { + "required": ["confidence", "price", "timestamp", "timestamp_bucket"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "Confidence score of the spot price" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "Spot price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the spot price was recored into the database" + }, + "timestamp_bucket": { + "title": "timestamp_bucket", + "type": "integer", + "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" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetSpotFeedHistoryResultSchema": { + "required": ["currency", "spot_feed_history"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Currency" + }, + "spot_feed_history": { + "title": "spot_feed_history", + "type": "array", + "description": "Spot feed history", + "items": { + "required": ["confidence", "price", "timestamp", "timestamp_bucket"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "Confidence score of the spot price" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "Spot price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the spot price was recored into the database" + }, + "timestamp_bucket": { + "title": "timestamp_bucket", + "type": "integer", + "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" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "SpotFeedHistoryResponseSchema": { + "required": ["confidence", "price", "timestamp", "timestamp_bucket"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "Confidence score of the spot price" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "Spot price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of when the spot price was recored into the database" + }, + "timestamp_bucket": { + "title": "timestamp_bucket", + "type": "integer", + "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" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByLabelParamsSchema": { + "required": ["label", "subaccount_id"], + "properties": { + "label": { + "title": "label", + "type": "string", + "description": "Cancel all orders for this label" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByLabelResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByLabelResultSchema": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicBuildRegisterSessionKeyTxParamsSchema": { + "required": ["expiry_sec", "gas", "nonce", "public_session_key", "wallet"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Expiry of the session key" + }, + "gas": { + "title": "gas", + "type": "integer", + "default": null, + "description": "Gas allowance for transaction. If none, will use estimateGas * 150%", + "nullable": true + }, + "nonce": { + "title": "nonce", + "type": "integer", + "default": null, + "description": "Wallet's transaction count, If none, will use eth.getTransactionCount()", + "nullable": true + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Session key in the form of an Ethereum EOA" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicBuildRegisterSessionKeyTxResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["tx_params"], + "properties": { + "tx_params": { + "title": "tx_params", + "type": "object", + "description": "Transaction params in dictionary form, same as `TxParams` in `web3.py`", + "additionalProperties": {} + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicBuildRegisterSessionKeyTxResultSchema": { + "required": ["tx_params"], + "properties": { + "tx_params": { + "title": "tx_params", + "type": "object", + "description": "Transaction params in dictionary form, same as `TxParams` in `web3.py`", + "additionalProperties": {} + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetInstrumentsParamsSchema": { + "required": ["currency", "expired", "instrument_type"], + "properties": { + "currency": { + "title": "currency", + "type": "string", + "description": "Underlying currency of asset (`ETH`, `BTC`, etc)" + }, + "expired": { + "title": "expired", + "type": "boolean", + "description": "If `True`: include expired assets" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetInstrumentsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "", + "items": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "maximum_amount", + "minimum_amount", + "option_details", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "taker_fee_rate", + "tick_size" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "InstrumentPublicResponseSchema": { + "required": [ + "amount_step", + "base_asset_address", + "base_asset_sub_id", + "base_currency", + "base_fee", + "instrument_name", + "instrument_type", + "is_active", + "maker_fee_rate", + "maximum_amount", + "minimum_amount", + "option_details", + "perp_details", + "quote_currency", + "scheduled_activation", + "scheduled_deactivation", + "taker_fee_rate", + "tick_size" + ], + "properties": { + "amount_step": { + "title": "amount_step", + "type": "string", + "format": "decimal", + "description": "Minimum valid increment of order amount" + }, + "base_asset_address": { + "title": "base_asset_address", + "type": "string", + "description": "Blockchain address of the base asset" + }, + "base_asset_sub_id": { + "title": "base_asset_sub_id", + "type": "string", + "description": "Sub ID of the specific base asset as defined in Asset.sol" + }, + "base_currency": { + "title": "base_currency", + "type": "string", + "description": "Underlying currency of base asset (`ETH`, `BTC`, etc)" + }, + "base_fee": { + "title": "base_fee", + "type": "string", + "format": "decimal", + "description": "$ base fee added to every taker order" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "enum": ["erc20", "option", "perp"], + "description": "`erc20`, `option`, or `perp`" + }, + "is_active": { + "title": "is_active", + "type": "boolean", + "description": "If `True`: instrument is tradeable within `activation` and `deactivation` timestamps" + }, + "maker_fee_rate": { + "title": "maker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for makers" + }, + "mark_price_fee_rate_cap": { + "title": "mark_price_fee_rate_cap", + "type": "string", + "format": "decimal", + "default": null, + "description": "Percent of option price fee cap, e.g. 12.5%, null if not applicable", + "nullable": true + }, + "maximum_amount": { + "title": "maximum_amount", + "type": "string", + "format": "decimal", + "description": "Maximum valid amount of contracts / tokens per trade" + }, + "minimum_amount": { + "title": "minimum_amount", + "type": "string", + "format": "decimal", + "description": "Minimum valid amount of contracts / tokens per trade" + }, + "option_details": { + "required": ["expiry", "index", "option_type", "strike"], + "properties": { + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Unix timestamp of expiry date (in seconds)" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying settlement price index" + }, + "option_type": { + "title": "option_type", + "type": "string", + "enum": ["C", "P"] + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "default": null, + "description": "Settlement price of the option", + "nullable": true + }, + "strike": { + "title": "strike", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + }, + "perp_details": { + "required": [ + "aggregate_funding", + "funding_rate", + "index", + "max_rate_per_hour", + "min_rate_per_hour", + "static_interest_rate" + ], + "properties": { + "aggregate_funding": { + "title": "aggregate_funding", + "type": "string", + "format": "decimal", + "description": "Latest aggregated funding as per `PerpAsset.sol`" + }, + "funding_rate": { + "title": "funding_rate", + "type": "string", + "format": "decimal", + "description": "Current hourly funding rate as per `PerpAsset.sol`" + }, + "index": { + "title": "index", + "type": "string", + "description": "Underlying spot price index for funding rate" + }, + "max_rate_per_hour": { + "title": "max_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Max rate per hour as per `PerpAsset.sol`" + }, + "min_rate_per_hour": { + "title": "min_rate_per_hour", + "type": "string", + "format": "decimal", + "description": "Min rate per hour as per `PerpAsset.sol`" + }, + "static_interest_rate": { + "title": "static_interest_rate", + "type": "string", + "format": "decimal", + "description": "Static interest rate as per `PerpAsset.sol`" + } + }, + "type": "object", + "additionalProperties": false + }, + "quote_currency": { + "title": "quote_currency", + "type": "string", + "description": "Quote currency (`USD` for perps, `USDC` for options)" + }, + "scheduled_activation": { + "title": "scheduled_activation", + "type": "integer", + "description": "Timestamp at which became or will become active (if applicable)" + }, + "scheduled_deactivation": { + "title": "scheduled_deactivation", + "type": "integer", + "description": "Scheduled deactivation time for instrument (if applicable)" + }, + "taker_fee_rate": { + "title": "taker_fee_rate", + "type": "string", + "format": "decimal", + "description": "Percent of spot price fee rate for takers" + }, + "tick_size": { + "title": "tick_size", + "type": "string", + "format": "decimal", + "description": "Tick size of the instrument, i.e. minimum price increment" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicCreateAccountParamsSchema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicCreateAccountResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["status", "wallet"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`created` or `exists`" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicCreateAccountResultSchema": { + "required": ["status", "wallet"], + "properties": { + "status": { + "title": "status", + "type": "string", + "description": "`created` or `exists`" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicLoginParamsSchema": { + "required": ["signature", "timestamp", "wallet"], + "properties": { + "signature": { + "title": "signature", + "type": "string", + "description": "Signature of the timestamp, signed with the wallet's private key or a session key" + }, + "timestamp": { + "title": "timestamp", + "type": "string", + "description": "Message that was signed, in the form of a timestamp in ms since Unix epoch" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Public key (wallet) of the account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicLoginResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "title": "result", + "type": "array", + "description": "List of subaccount IDs that have been authenticated", + "items": { + "title": "result", + "type": "integer" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicCreateSubaccountDebugParamsSchema": { + "required": ["amount", "asset_name", "margin_type", "nonce", "signature_expiry_sec", "signer", "wallet"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount of the asset to deposit" + }, + "asset_name": { + "title": "asset_name", + "type": "string", + "description": "Name of asset to deposit" + }, + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Base currency of the subaccount (only for `PM`)", + "nullable": true + }, + "margin_type": { + "title": "margin_type", + "type": "string", + "enum": ["PM", "SM"], + "description": "`PM` (Portfolio Margin) or `SM` (Standard Margin)" + }, + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)" + }, + "signature_expiry_sec": { + "title": "signature_expiry_sec", + "type": "integer", + "description": "Unix timestamp in seconds. Expiry MUST be >5min from now" + }, + "signer": { + "title": "signer", + "type": "string", + "description": "Ethereum wallet address that is signing the deposit" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicCreateSubaccountDebugResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["action_hash", "encoded_data", "encoded_data_hashed", "typed_data_hash"], + "properties": { + "action_hash": { + "title": "action_hash", + "type": "string", + "description": "Keccak hashed action data" + }, + "encoded_data": { + "title": "encoded_data", + "type": "string", + "description": "ABI encoded deposit data" + }, + "encoded_data_hashed": { + "title": "encoded_data_hashed", + "type": "string", + "description": "Keccak hashed encoded_data" + }, + "typed_data_hash": { + "title": "typed_data_hash", + "type": "string", + "description": "EIP 712 typed data hash" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicCreateSubaccountDebugResultSchema": { + "required": ["action_hash", "encoded_data", "encoded_data_hashed", "typed_data_hash"], + "properties": { + "action_hash": { + "title": "action_hash", + "type": "string", + "description": "Keccak hashed action data" + }, + "encoded_data": { + "title": "encoded_data", + "type": "string", + "description": "ABI encoded deposit data" + }, + "encoded_data_hashed": { + "title": "encoded_data_hashed", + "type": "string", + "description": "Keccak hashed encoded_data" + }, + "typed_data_hash": { + "title": "typed_data_hash", + "type": "string", + "description": "EIP 712 typed data hash" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByNonceParamsSchema": { + "required": ["nonce", "subaccount_id"], + "properties": { + "nonce": { + "title": "nonce", + "type": "integer", + "description": "Cancel an order with this nonce" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByNonceResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateCancelByNonceResultSchema": { + "required": ["cancelled_orders"], + "properties": { + "cancelled_orders": { + "title": "cancelled_orders", + "type": "integer", + "description": "Number of cancelled orders" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetDepositHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "end_timestamp": { + "title": "end_timestamp", + "type": "integer", + "default": 9223372036854776000, + "description": "End timestamp of the event history (default current time)" + }, + "start_timestamp": { + "title": "start_timestamp", + "type": "integer", + "default": 0, + "description": "Start timestamp of the event history (default 0)" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount id" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetDepositHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of deposit payments", + "items": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount deposited by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset deposited" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the deposit (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that deposited the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetDepositHistoryResultSchema": { + "required": ["events"], + "properties": { + "events": { + "title": "events", + "type": "array", + "description": "List of deposit payments", + "items": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount deposited by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset deposited" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the deposit (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that deposited the funds" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "DepositSchema": { + "required": ["amount", "asset", "timestamp", "tx_hash"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount deposited by the subaccount" + }, + "asset": { + "title": "asset", + "type": "string", + "description": "Asset deposited" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Timestamp of the deposit (in ms since UNIX epoch)" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Hash of the transaction that deposited the funds" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountsParamsSchema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["subaccount_ids", "wallet"], + "properties": { + "subaccount_ids": { + "title": "subaccount_ids", + "type": "array", + "description": "List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + "items": { + "title": "subaccount_ids", + "type": "integer" + } + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetSubaccountsResultSchema": { + "required": ["subaccount_ids", "wallet"], + "properties": { + "subaccount_ids": { + "title": "subaccount_ids", + "type": "array", + "description": "List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + "items": { + "title": "subaccount_ids", + "type": "integer" + } + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSessionKeysParamsSchema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSessionKeysResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["public_session_keys"], + "properties": { + "public_session_keys": { + "title": "public_session_keys", + "type": "array", + "description": "List of session keys (includes unactivated and expired keys)", + "items": { + "required": ["expiry_sec", "public_session_key"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Session key expiry timestamp in sec" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Public session key address (Ethereum EOA)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateSessionKeysResultSchema": { + "required": ["public_session_keys"], + "properties": { + "public_session_keys": { + "title": "public_session_keys", + "type": "array", + "description": "List of session keys (includes unactivated and expired keys)", + "items": { + "required": ["expiry_sec", "public_session_key"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Session key expiry timestamp in sec" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Public session key address (Ethereum EOA)" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "SessionKeyResponseSchema": { + "required": ["expiry_sec", "public_session_key"], + "properties": { + "expiry_sec": { + "title": "expiry_sec", + "type": "integer", + "description": "Session key expiry timestamp in sec" + }, + "label": { + "title": "label", + "type": "string", + "default": "", + "description": "User-defined session key label" + }, + "public_session_key": { + "title": "public_session_key", + "type": "string", + "description": "Public session key address (Ethereum EOA)" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateChangeSessionKeyLabelParamsSchema": { + "required": ["label"], + "properties": { + "label": { + "title": "label", + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateChangeSessionKeyLabelResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["label"], + "properties": { + "label": { + "title": "label", + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateChangeSessionKeyLabelResultSchema": { + "required": ["label"], + "properties": { + "label": { + "title": "label", + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetAccountParamsSchema": { + "required": ["wallet"], + "properties": { + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address of account" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetAccountResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": [ + "cancel_on_disconnect", + "subaccount_ids", + "wallet", + "websocket_matching_tps", + "websocket_non_matching_tps" + ], + "properties": { + "cancel_on_disconnect": { + "title": "cancel_on_disconnect", + "type": "boolean", + "description": "Whether cancel on disconnect is enabled for the account" + }, + "subaccount_ids": { + "title": "subaccount_ids", + "type": "array", + "description": "List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + "items": { + "title": "subaccount_ids", + "type": "integer" + } + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + }, + "websocket_matching_tps": { + "title": "websocket_matching_tps", + "type": "integer", + "description": "Max transactions per second for matching requests over websocket (see `Rate Limiting` in docs)" + }, + "websocket_non_matching_tps": { + "title": "websocket_non_matching_tps", + "type": "integer", + "description": "Max transactions per second for non-matching requests over websocket (see `Rate Limiting` in docs)" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetAccountResultSchema": { + "required": [ + "cancel_on_disconnect", + "subaccount_ids", + "wallet", + "websocket_matching_tps", + "websocket_non_matching_tps" + ], + "properties": { + "cancel_on_disconnect": { + "title": "cancel_on_disconnect", + "type": "boolean", + "description": "Whether cancel on disconnect is enabled for the account" + }, + "subaccount_ids": { + "title": "subaccount_ids", + "type": "array", + "description": "List of subaccount_ids owned by the wallet in `SubAccounts.sol`", + "items": { + "title": "subaccount_ids", + "type": "integer" + } + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Ethereum wallet address" + }, + "websocket_matching_tps": { + "title": "websocket_matching_tps", + "type": "integer", + "description": "Max transactions per second for matching requests over websocket (see `Rate Limiting` in docs)" + }, + "websocket_non_matching_tps": { + "title": "websocket_non_matching_tps", + "type": "integer", + "description": "Max transactions per second for non-matching requests over websocket (see `Rate Limiting` in docs)" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOptionSettlementHistoryParamsSchema": { + "required": ["subaccount_id"], + "properties": { + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get expired option settlement history" + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOptionSettlementHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["settlements", "subaccount_id"], + "properties": { + "settlements": { + "title": "settlements", + "type": "array", + "description": "List of expired option settlements", + "items": { + "required": ["amount", "expiry", "instrument_name", "option_settlement_pnl", "settlement_price"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount that was settled" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Expiry timestamp of the option" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "option_settlement_pnl": { + "title": "option_settlement_pnl", + "type": "string", + "format": "decimal", + "description": "USD profit or loss from option settlements calculated as: settlement value - (average price x amount)" + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "description": "Price of option settlement" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get expired option settlement history" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PrivateGetOptionSettlementHistoryResultSchema": { + "required": ["settlements", "subaccount_id"], + "properties": { + "settlements": { + "title": "settlements", + "type": "array", + "description": "List of expired option settlements", + "items": { + "required": ["amount", "expiry", "instrument_name", "option_settlement_pnl", "settlement_price"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount that was settled" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Expiry timestamp of the option" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "option_settlement_pnl": { + "title": "option_settlement_pnl", + "type": "string", + "format": "decimal", + "description": "USD profit or loss from option settlements calculated as: settlement value - (average price x amount)" + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "description": "Price of option settlement" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount_id for which to get expired option settlement history" + } + }, + "type": "object", + "additionalProperties": false + }, + "OptionSettlementResponseSchema": { + "required": ["amount", "expiry", "instrument_name", "option_settlement_pnl", "settlement_price"], + "properties": { + "amount": { + "title": "amount", + "type": "string", + "format": "decimal", + "description": "Amount that was settled" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "Expiry timestamp of the option" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "option_settlement_pnl": { + "title": "option_settlement_pnl", + "type": "string", + "format": "decimal", + "description": "USD profit or loss from option settlements calculated as: settlement value - (average price x amount)" + }, + "settlement_price": { + "title": "settlement_price", + "type": "string", + "format": "decimal", + "description": "Price of option settlement" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTradeHistoryParamsSchema": { + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency to filter by (defaults to all)", + "nullable": true + }, + "from_timestamp": { + "title": "from_timestamp", + "type": "integer", + "default": 0, + "description": "Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0." + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "default": null, + "description": "Instrument name to filter by (defaults to all)", + "nullable": true + }, + "instrument_type": { + "title": "instrument_type", + "type": "string", + "default": null, + "enum": ["erc20", "option", "perp"], + "description": "Instrument type to filter by (defaults to all)", + "nullable": true + }, + "page": { + "title": "page", + "type": "integer", + "default": 1, + "description": "Page number of results to return (default 1, returns last if above `num_pages`)" + }, + "page_size": { + "title": "page_size", + "type": "integer", + "default": 100, + "description": "Number of results per page (default 100, max 1000)" + }, + "to_timestamp": { + "title": "to_timestamp", + "type": "integer", + "default": 18446744073709552000, + "description": "Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time." + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "default": "settled", + "enum": ["settled", "reverted"], + "description": "Transaction status to filter by (default `settled`)." + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTradeHistoryResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["pagination", "trades"], + "properties": { + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "trades": { + "title": "trades", + "type": "array", + "description": "List of trades", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "liquidity_role", + "mark_price", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status", + "wallet" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Blockchain transaction hash" + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["settled", "reverted"], + "description": "Blockchain transaction status" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Wallet address (owner) of the subaccount" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetTradeHistoryResultSchema": { + "required": ["pagination", "trades"], + "properties": { + "pagination": { + "required": ["count", "num_pages"], + "properties": { + "count": { + "title": "count", + "type": "integer", + "description": "Total number of items, across all pages" + }, + "num_pages": { + "title": "num_pages", + "type": "integer", + "description": "Number of pages" + } + }, + "type": "object", + "additionalProperties": false + }, + "trades": { + "title": "trades", + "type": "array", + "description": "List of trades", + "items": { + "required": [ + "direction", + "index_price", + "instrument_name", + "liquidity_role", + "mark_price", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status", + "wallet" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Blockchain transaction hash" + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["settled", "reverted"], + "description": "Blockchain transaction status" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Wallet address (owner) of the subaccount" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "type": "object", + "additionalProperties": false + }, + "TradeSettledPublicResponseSchema": { + "required": [ + "direction", + "index_price", + "instrument_name", + "liquidity_role", + "mark_price", + "subaccount_id", + "timestamp", + "trade_amount", + "trade_fee", + "trade_id", + "trade_price", + "tx_hash", + "tx_status", + "wallet" + ], + "properties": { + "direction": { + "title": "direction", + "type": "string", + "enum": ["buy", "sell"], + "description": "Order direction" + }, + "index_price": { + "title": "index_price", + "type": "string", + "format": "decimal", + "description": "Index price of the underlying at the time of the trade" + }, + "instrument_name": { + "title": "instrument_name", + "type": "string", + "description": "Instrument name" + }, + "liquidity_role": { + "title": "liquidity_role", + "type": "string", + "enum": ["maker", "taker"], + "description": "Role of the user in the trade" + }, + "mark_price": { + "title": "mark_price", + "type": "string", + "format": "decimal", + "description": "Mark price of the instrument at the time of the trade" + }, + "subaccount_id": { + "title": "subaccount_id", + "type": "integer", + "description": "Subaccount ID" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "Trade timestamp (in ms since Unix epoch)" + }, + "trade_amount": { + "title": "trade_amount", + "type": "string", + "format": "decimal", + "description": "Amount filled in this trade" + }, + "trade_fee": { + "title": "trade_fee", + "type": "string", + "format": "decimal", + "description": "Fee for this trade" + }, + "trade_id": { + "title": "trade_id", + "type": "string", + "description": "Trade ID" + }, + "trade_price": { + "title": "trade_price", + "type": "string", + "format": "decimal", + "description": "Price at which the trade was filled" + }, + "tx_hash": { + "title": "tx_hash", + "type": "string", + "description": "Blockchain transaction hash" + }, + "tx_status": { + "title": "tx_status", + "type": "string", + "enum": ["settled", "reverted"], + "description": "Blockchain transaction status" + }, + "wallet": { + "title": "wallet", + "type": "string", + "description": "Wallet address (owner) of the subaccount" + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetLatestSignedFeedsParamsSchema": { + "properties": { + "currency": { + "title": "currency", + "type": "string", + "default": null, + "description": "Currency filter, (defaults to all currencies)", + "nullable": true + }, + "expiry": { + "title": "expiry", + "type": "integer", + "default": null, + "description": "Expiry filter for options and forward data (defaults to all expiries). Use `0` to get data only for spot and perpetuals", + "nullable": true + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetLatestSignedFeedsResponseSchema": { + "required": ["id", "result"], + "properties": { + "id": { + "anyOf": [ + { + "title": "", + "type": "string" + }, + { + "title": "", + "type": "integer" + } + ] + }, + "result": { + "required": ["fwd_data", "perp_data", "spot_data", "vol_data"], + "properties": { + "fwd_data": { + "title": "fwd_data", + "type": "object", + "description": "currency -> expiry -> latest forward feed data", + "additionalProperties": { + "title": "fwd_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "expiry", + "fwd_diff", + "signatures", + "spot_aggregate_latest", + "spot_aggregate_start", + "timestamp" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the forward feed" + }, + "fwd_diff": { + "title": "fwd_diff", + "type": "string", + "format": "decimal", + "description": "difference of forward price from current spot price" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_aggregate_latest": { + "title": "spot_aggregate_latest", + "type": "string", + "format": "decimal", + "description": "expiry -> spot * time value at the latest timestamp" + }, + "spot_aggregate_start": { + "title": "spot_aggregate_start", + "type": "string", + "format": "decimal", + "description": "spot * time value at the start of the settlement period" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "perp_data": { + "title": "perp_data", + "type": "object", + "description": "currency -> feed type -> latest perp feed data", + "additionalProperties": { + "title": "perp_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "signatures", + "spot_diff_value", + "timestamp", + "type" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_diff_value": { + "title": "spot_diff_value", + "type": "string", + "format": "decimal", + "description": "The difference between the spot price and the perp price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "type": { + "title": "type", + "type": "string", + "enum": ["P", "A", "B"], + "description": "The type of perp feed; mid price, ask impact or bid impact" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "spot_data": { + "title": "spot_data", + "type": "object", + "description": "currency -> latest spot feed data", + "additionalProperties": { + "required": ["confidence", "currency", "deadline", "price", "signatures", "timestamp"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "The price of the currency in USD" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "vol_data": { + "title": "vol_data", + "type": "object", + "description": "currency -> expiry -> latest vol feed data", + "additionalProperties": { + "title": "vol_data", + "type": "object", + "additionalProperties": { + "required": ["confidence", "currency", "deadline", "expiry", "signatures", "timestamp", "vol_data"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the options for the vol feed" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "vol_data": { + "required": ["SVI_a", "SVI_b", "SVI_fwd", "SVI_m", "SVI_refTau", "SVI_rho", "SVI_sigma"], + "properties": { + "SVI_a": { + "title": "SVI_a", + "type": "string", + "format": "decimal" + }, + "SVI_b": { + "title": "SVI_b", + "type": "string", + "format": "decimal" + }, + "SVI_fwd": { + "title": "SVI_fwd", + "type": "string", + "format": "decimal" + }, + "SVI_m": { + "title": "SVI_m", + "type": "string", + "format": "decimal" + }, + "SVI_refTau": { + "title": "SVI_refTau", + "type": "string", + "format": "decimal" + }, + "SVI_rho": { + "title": "SVI_rho", + "type": "string", + "format": "decimal" + }, + "SVI_sigma": { + "title": "SVI_sigma", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "PublicGetLatestSignedFeedsResultSchema": { + "required": ["fwd_data", "perp_data", "spot_data", "vol_data"], + "properties": { + "fwd_data": { + "title": "fwd_data", + "type": "object", + "description": "currency -> expiry -> latest forward feed data", + "additionalProperties": { + "title": "fwd_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "expiry", + "fwd_diff", + "signatures", + "spot_aggregate_latest", + "spot_aggregate_start", + "timestamp" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the forward feed" + }, + "fwd_diff": { + "title": "fwd_diff", + "type": "string", + "format": "decimal", + "description": "difference of forward price from current spot price" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_aggregate_latest": { + "title": "spot_aggregate_latest", + "type": "string", + "format": "decimal", + "description": "expiry -> spot * time value at the latest timestamp" + }, + "spot_aggregate_start": { + "title": "spot_aggregate_start", + "type": "string", + "format": "decimal", + "description": "spot * time value at the start of the settlement period" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "perp_data": { + "title": "perp_data", + "type": "object", + "description": "currency -> feed type -> latest perp feed data", + "additionalProperties": { + "title": "perp_data", + "type": "object", + "additionalProperties": { + "required": [ + "confidence", + "currency", + "deadline", + "signatures", + "spot_diff_value", + "timestamp", + "type" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_diff_value": { + "title": "spot_diff_value", + "type": "string", + "format": "decimal", + "description": "The difference between the spot price and the perp price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "type": { + "title": "type", + "type": "string", + "enum": ["P", "A", "B"], + "description": "The type of perp feed; mid price, ask impact or bid impact" + } + }, + "type": "object", + "additionalProperties": false + } + } + }, + "spot_data": { + "title": "spot_data", + "type": "object", + "description": "currency -> latest spot feed data", + "additionalProperties": { + "required": ["confidence", "currency", "deadline", "price", "signatures", "timestamp"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "The price of the currency in USD" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "vol_data": { + "title": "vol_data", + "type": "object", + "description": "currency -> expiry -> latest vol feed data", + "additionalProperties": { + "title": "vol_data", + "type": "object", + "additionalProperties": { + "required": ["confidence", "currency", "deadline", "expiry", "signatures", "timestamp", "vol_data"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the options for the vol feed" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "vol_data": { + "required": ["SVI_a", "SVI_b", "SVI_fwd", "SVI_m", "SVI_refTau", "SVI_rho", "SVI_sigma"], + "properties": { + "SVI_a": { + "title": "SVI_a", + "type": "string", + "format": "decimal" + }, + "SVI_b": { + "title": "SVI_b", + "type": "string", + "format": "decimal" + }, + "SVI_fwd": { + "title": "SVI_fwd", + "type": "string", + "format": "decimal" + }, + "SVI_m": { + "title": "SVI_m", + "type": "string", + "format": "decimal" + }, + "SVI_refTau": { + "title": "SVI_refTau", + "type": "string", + "format": "decimal" + }, + "SVI_rho": { + "title": "SVI_rho", + "type": "string", + "format": "decimal" + }, + "SVI_sigma": { + "title": "SVI_sigma", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + } + } + } + }, + "type": "object", + "additionalProperties": false + }, + "ForwardFeedDataSchema": { + "required": [ + "confidence", + "currency", + "deadline", + "expiry", + "fwd_diff", + "signatures", + "spot_aggregate_latest", + "spot_aggregate_start", + "timestamp" + ], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the forward feed" + }, + "fwd_diff": { + "title": "fwd_diff", + "type": "string", + "format": "decimal", + "description": "difference of forward price from current spot price" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_aggregate_latest": { + "title": "spot_aggregate_latest", + "type": "string", + "format": "decimal", + "description": "expiry -> spot * time value at the latest timestamp" + }, + "spot_aggregate_start": { + "title": "spot_aggregate_start", + "type": "string", + "format": "decimal", + "description": "spot * time value at the start of the settlement period" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + }, + "OracleSignatureDataSchema": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "PerpFeedDataSchema": { + "required": ["confidence", "currency", "deadline", "signatures", "spot_diff_value", "timestamp", "type"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "spot_diff_value": { + "title": "spot_diff_value", + "type": "string", + "format": "decimal", + "description": "The difference between the spot price and the perp price" + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "type": { + "title": "type", + "type": "string", + "enum": ["P", "A", "B"], + "description": "The type of perp feed; mid price, ask impact or bid impact" + } + }, + "type": "object", + "additionalProperties": false + }, + "SpotFeedDataSchema": { + "required": ["confidence", "currency", "deadline", "price", "signatures", "timestamp"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "price": { + "title": "price", + "type": "string", + "format": "decimal", + "description": "The price of the currency in USD" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + } + }, + "type": "object", + "additionalProperties": false + }, + "VolFeedDataSchema": { + "required": ["confidence", "currency", "deadline", "expiry", "signatures", "timestamp", "vol_data"], + "properties": { + "confidence": { + "title": "confidence", + "type": "string", + "format": "decimal", + "description": "The confidence score of the price" + }, + "currency": { + "title": "currency", + "type": "string", + "description": "The currency for which the spot feed represents" + }, + "deadline": { + "title": "deadline", + "type": "integer", + "description": "The latest time the data can be submitted on chain" + }, + "expiry": { + "title": "expiry", + "type": "integer", + "description": "The expiry for the options for the vol feed" + }, + "signatures": { + "properties": { + "signatures": { + "title": "signatures", + "type": "array", + "description": "The signatures of the given signers", + "items": { + "title": "signatures", + "type": "string" + } + }, + "signers": { + "title": "signers", + "type": "array", + "description": "The signers who verify the data integrity", + "items": { + "title": "signers", + "type": "string" + } + } + }, + "type": "object", + "additionalProperties": false + }, + "timestamp": { + "title": "timestamp", + "type": "integer", + "description": "The timestamp for which the data was created" + }, + "vol_data": { + "required": ["SVI_a", "SVI_b", "SVI_fwd", "SVI_m", "SVI_refTau", "SVI_rho", "SVI_sigma"], + "properties": { + "SVI_a": { + "title": "SVI_a", + "type": "string", + "format": "decimal" + }, + "SVI_b": { + "title": "SVI_b", + "type": "string", + "format": "decimal" + }, + "SVI_fwd": { + "title": "SVI_fwd", + "type": "string", + "format": "decimal" + }, + "SVI_m": { + "title": "SVI_m", + "type": "string", + "format": "decimal" + }, + "SVI_refTau": { + "title": "SVI_refTau", + "type": "string", + "format": "decimal" + }, + "SVI_rho": { + "title": "SVI_rho", + "type": "string", + "format": "decimal" + }, + "SVI_sigma": { + "title": "SVI_sigma", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + } + }, + "type": "object", + "additionalProperties": false + }, + "VolSVIParamDataSchema": { + "required": ["SVI_a", "SVI_b", "SVI_fwd", "SVI_m", "SVI_refTau", "SVI_rho", "SVI_sigma"], + "properties": { + "SVI_a": { + "title": "SVI_a", + "type": "string", + "format": "decimal" + }, + "SVI_b": { + "title": "SVI_b", + "type": "string", + "format": "decimal" + }, + "SVI_fwd": { + "title": "SVI_fwd", + "type": "string", + "format": "decimal" + }, + "SVI_m": { + "title": "SVI_m", + "type": "string", + "format": "decimal" + }, + "SVI_refTau": { + "title": "SVI_refTau", + "type": "string", + "format": "decimal" + }, + "SVI_rho": { + "title": "SVI_rho", + "type": "string", + "format": "decimal" + }, + "SVI_sigma": { + "title": "SVI_sigma", + "type": "string", + "format": "decimal" + } + }, + "type": "object", + "additionalProperties": false + } + } + } +} diff --git a/app/src/api/schemas.ts b/app/src/api/schemas.ts new file mode 100644 index 0000000..ff142e7 --- /dev/null +++ b/app/src/api/schemas.ts @@ -0,0 +1,115 @@ +const PostPrivateCancel = {"body":{"required":["instrument_name","order_id","subaccount_id"],"properties":{"instrument_name":{"title":"instrument_name","type":"string"},"order_id":{"title":"order_id","type":"string","format":"uuid"},"subaccount_id":{"title":"subaccount_id","type":"integer"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateCancelAll = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["cancelled_orders"],"properties":{"cancelled_orders":{"title":"cancelled_orders","type":"integer","description":"Number of cancelled orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateCancelByInstrument = {"body":{"required":["instrument_name","subaccount_id"],"properties":{"instrument_name":{"title":"instrument_name","type":"string","description":"Cancel all orders for this instrument"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["cancelled_orders"],"properties":{"cancelled_orders":{"title":"cancelled_orders","type":"integer","description":"Number of cancelled orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateCancelByLabel = {"body":{"required":["label","subaccount_id"],"properties":{"label":{"title":"label","type":"string","description":"Cancel all orders for this label"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["cancelled_orders"],"properties":{"cancelled_orders":{"title":"cancelled_orders","type":"integer","description":"Number of cancelled orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateCancelByNonce = {"body":{"required":["nonce","subaccount_id"],"properties":{"nonce":{"title":"nonce","type":"integer","description":"Cancel an order with this nonce"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["cancelled_orders"],"properties":{"cancelled_orders":{"title":"cancelled_orders","type":"integer","description":"Number of cancelled orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateChangeSessionKeyLabel = {"body":{"required":["label"],"properties":{"label":{"title":"label","type":"string"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["label"],"properties":{"label":{"title":"label","type":"string"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateChangeSubaccountLabel = {"body":{"required":["label","subaccount_id"],"properties":{"label":{"title":"label","type":"string","description":"User defined label"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["label","subaccount_id"],"properties":{"label":{"title":"label","type":"string","description":"User defined label"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateCreateSubaccount = {"body":{"required":["amount","asset_name","margin_type","nonce","signature","signature_expiry_sec","signer","wallet"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount of the asset to deposit"},"asset_name":{"title":"asset_name","type":"string","description":"Name of asset to deposit"},"currency":{"title":"currency","type":["string","null"],"default":null,"description":"Base currency of the subaccount (only for `PM`)"},"margin_type":{"title":"margin_type","type":"string","enum":["PM","SM"],"description":"`PM` (Portfolio Margin) or `SM` (Standard Margin)"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the deposit"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Unix timestamp in seconds. Expiry MUST be >5min from now"},"signer":{"title":"signer","type":"string","description":"Ethereum wallet address that is signing the deposit"},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["status","transaction_id"],"properties":{"status":{"title":"status","type":"string","description":"`requested`"},"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"Transaction id of the request"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateDeposit = {"body":{"required":["amount","asset_name","nonce","signature","signature_expiry_sec","signer","subaccount_id"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount of the asset to deposit"},"asset_name":{"title":"asset_name","type":"string","description":"Name of asset to deposit"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the deposit"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Unix timestamp in seconds. Expiry MUST be >5min from now"},"signer":{"title":"signer","type":"string","description":"Ethereum wallet address that is signing the deposit"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["status","transaction_id"],"properties":{"status":{"title":"status","type":"string","description":"`requested`"},"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"Transaction id of the deposit"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateExpiredAndCancelledHistory = {"body":{"required":["end_timestamp","expiry","start_timestamp","subaccount_id","wallet"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","description":"End Unix timestamp"},"expiry":{"title":"expiry","type":"integer","description":"Expiry of download link in seconds. Maximum of 604800."},"start_timestamp":{"title":"start_timestamp","type":"integer","description":"Start Unix timestamp"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount to download data for"},"wallet":{"title":"wallet","type":"string","description":"Wallet to download data for"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["presigned_urls"],"properties":{"presigned_urls":{"title":"presigned_urls","type":"array","description":"List of presigned URLs to the snapshots","items":{"title":"presigned_urls","type":"string"}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetAccount = {"body":{"required":["wallet"],"properties":{"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address of account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["cancel_on_disconnect","subaccount_ids","wallet","websocket_matching_tps","websocket_non_matching_tps"],"properties":{"cancel_on_disconnect":{"title":"cancel_on_disconnect","type":"boolean","description":"Whether cancel on disconnect is enabled for the account"},"subaccount_ids":{"title":"subaccount_ids","type":"array","description":"List of subaccount_ids owned by the wallet in `SubAccounts.sol`","items":{"title":"subaccount_ids","type":"integer"}},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address"},"websocket_matching_tps":{"title":"websocket_matching_tps","type":"integer","description":"Max transactions per second for matching requests over websocket (see `Rate Limiting` in docs)"},"websocket_non_matching_tps":{"title":"websocket_non_matching_tps","type":"integer","description":"Max transactions per second for non-matching requests over websocket (see `Rate Limiting` in docs)"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetCollaterals = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["collaterals","subaccount_id"],"properties":{"collaterals":{"title":"collaterals","type":"array","description":"All collaterals that count towards margin of subaccount","items":{"required":["amount","asset_name","asset_type","cumulative_interest","currency","initial_margin","maintenance_margin","mark_price","mark_value","pending_interest"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Asset amount of given collateral"},"asset_name":{"title":"asset_name","type":"string","description":"Asset name"},"asset_type":{"title":"asset_type","type":"string","enum":["erc20","option","perp"],"description":"Type of asset collateral (currently always `erc20`)\n\n`erc20` `option` `perp`"},"cumulative_interest":{"title":"cumulative_interest","type":"string","format":"decimal","description":"Cumulative interest earned on supplying collateral or paid for borrowing"},"currency":{"title":"currency","type":"string","description":"Underlying currency of asset (`ETH`, `BTC`, etc)"},"initial_margin":{"title":"initial_margin","type":"string","format":"decimal","description":"USD value of collateral that contributes to initial margin"},"maintenance_margin":{"title":"maintenance_margin","type":"string","format":"decimal","description":"USD value of collateral that contributes to maintenance margin"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Current mark price of the asset"},"mark_value":{"title":"mark_value","type":"string","format":"decimal","description":"USD value of the collateral (amount * mark price)"},"pending_interest":{"title":"pending_interest","type":"string","format":"decimal","description":"Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes."}},"type":"object","additionalProperties":false}},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetDepositHistory = {"body":{"required":["subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","default":9223372036854776000,"description":"End timestamp of the event history (default current time)"},"start_timestamp":{"title":"start_timestamp","type":"integer","default":0,"description":"Start timestamp of the event history (default 0)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["events"],"properties":{"events":{"title":"events","type":"array","description":"List of deposit payments","items":{"required":["amount","asset","timestamp","tx_hash"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount deposited by the subaccount"},"asset":{"title":"asset","type":"string","description":"Asset deposited"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the deposit (in ms since UNIX epoch)"},"tx_hash":{"title":"tx_hash","type":"string","description":"Hash of the transaction that deposited the funds"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetErc20TransferHistory = {"body":{"required":["subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","default":9223372036854776000,"description":"End timestamp of the event history (default current time)"},"start_timestamp":{"title":"start_timestamp","type":"integer","default":0,"description":"Start timestamp of the event history (default 0)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["events"],"properties":{"events":{"title":"events","type":"array","description":"List of erc20 transfers","items":{"required":["amount","asset","counterparty_subaccount_id","is_outgoing","timestamp","tx_hash"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount withdrawn by the subaccount"},"asset":{"title":"asset","type":"string","description":"Asset withdrawn"},"counterparty_subaccount_id":{"title":"counterparty_subaccount_id","type":"integer","description":"Recipient or sender subaccount_id of transfer"},"is_outgoing":{"title":"is_outgoing","type":"boolean","description":"True if the transfer was initiated by the subaccount, False otherwise"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the transfer (in ms since UNIX epoch)"},"tx_hash":{"title":"tx_hash","type":"string","description":"Hash of the transaction that withdrew the funds"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetFundingHistory = {"body":{"required":["subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","default":9223372036854776000,"description":"End timestamp of the event history (default current time)"},"instrument_name":{"title":"instrument_name","type":["string","null"],"default":null,"description":"Instrument name (returns history for all perpetuals if not provided)"},"start_timestamp":{"title":"start_timestamp","type":"integer","default":0,"description":"Start timestamp of the event history (default 0)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["events"],"properties":{"events":{"title":"events","type":"array","description":"List of funding payments","items":{"required":["funding","instrument_name","timestamp"],"properties":{"funding":{"title":"funding","type":"string","format":"decimal","description":"Dollar funding paid (if negative) or received (if positive) by the subaccount"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the funding payment (in ms since UNIX epoch)"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetInterestHistory = {"body":{"required":["subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","default":9223372036854776000,"description":"End timestamp of the event history (default current time)"},"start_timestamp":{"title":"start_timestamp","type":"integer","default":0,"description":"Start timestamp of the event history (default 0)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["events"],"properties":{"events":{"title":"events","type":"array","description":"List of interest payments","items":{"required":["interest","timestamp"],"properties":{"interest":{"title":"interest","type":"string","format":"decimal","description":"Dollar interest paid (if negative) or received (if positive) by the subaccount"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the interest payment (in ms since UNIX epoch)"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetLiquidationHistory = {"body":{"required":["subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","default":9223372036854776000,"description":"End timestamp of the event history (default current time)"},"start_timestamp":{"title":"start_timestamp","type":"integer","default":0,"description":"Start timestamp of the event history (default 0)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"array","description":"","items":{"required":["auction_id","auction_type","bids","end_timestamp","fee","start_timestamp","tx_hash"],"properties":{"auction_id":{"title":"auction_id","type":"string","description":"Unique ID of the auction"},"auction_type":{"title":"auction_type","type":"string","enum":["solvent","insolvent"],"description":"Type of auction\n\n`solvent` `insolvent`"},"bids":{"title":"bids","type":"array","description":"List of auction bid events","items":{"required":["amounts_liquidated","cash_received","discount_pnl","percent_liquidated","positions_realized_pnl","realized_pnl","timestamp","tx_hash"],"properties":{"amounts_liquidated":{"title":"amounts_liquidated","type":"object","description":"Amounts of each asset that were closed","additionalProperties":{"title":"amounts_liquidated","type":"string","format":"decimal"}},"cash_received":{"title":"cash_received","type":"string","format":"decimal","description":"Cash received for auctioning off the percentage of the subaccount"},"discount_pnl":{"title":"discount_pnl","type":"string","format":"decimal","description":"Realized PnL due to being liquidated at a discount to mark portfolio value"},"percent_liquidated":{"title":"percent_liquidated","type":"string","format":"decimal","description":"Percent of the subaccount that was liquidated"},"positions_realized_pnl":{"title":"positions_realized_pnl","type":"object","description":"Realized PnL of each position that was closed","additionalProperties":{"title":"positions_realized_pnl","type":"string","format":"decimal"}},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized PnL of the auction bid, assuming positions are closed at mark price at the time of the liquidation"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the bid (in ms since UNIX epoch)"},"tx_hash":{"title":"tx_hash","type":"string","description":"Hash of the bid transaction"}},"type":"object","additionalProperties":false}},"end_timestamp":{"title":"end_timestamp","type":["integer","null"],"default":null,"description":"Timestamp of the auction end (in ms since UNIX epoch), or `null` if not ended"},"fee":{"title":"fee","type":"string","format":"decimal","description":"Fee paid by the subaccount"},"start_timestamp":{"title":"start_timestamp","type":"integer","description":"Timestamp of the auction start (in ms since UNIX epoch)"},"tx_hash":{"title":"tx_hash","type":"string","description":"Hash of the transaction that started the auction"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetMargin = {"body":{"required":["subaccount_id"],"properties":{"simulated_position_changes":{"title":"simulated_position_changes","type":["array","null"],"default":null,"description":"Optional, add positions to simulate a trade","items":{"required":["amount","instrument_name"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Position amount to simulate"},"entry_price":{"title":"entry_price","type":["string","null"],"format":"decimal","default":null,"description":"Only for perps. Entry price to use in the simulation. Mark price is used if not provided."},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"}},"type":"object","additionalProperties":false}},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["is_valid_trade","post_initial_margin","post_maintenance_margin","pre_initial_margin","pre_maintenance_margin","subaccount_id"],"properties":{"is_valid_trade":{"title":"is_valid_trade","type":"boolean","description":"True if trade passes margin requirement"},"post_initial_margin":{"title":"post_initial_margin","type":"string","format":"decimal","description":"Initial margin requirement post trade"},"post_maintenance_margin":{"title":"post_maintenance_margin","type":"string","format":"decimal","description":"Maintenance margin requirement post trade"},"pre_initial_margin":{"title":"pre_initial_margin","type":"string","format":"decimal","description":"Initial margin requirement before trade"},"pre_maintenance_margin":{"title":"pre_maintenance_margin","type":"string","format":"decimal","description":"Maintenance margin requirement before trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetMmpConfig = {"body":{"required":["subaccount_id"],"properties":{"currency":{"title":"currency","type":["string","null"],"default":null,"description":"Currency to get the config for. If not provided, returns all configs for the subaccount"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get the config"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"array","description":"","items":{"required":["currency","mmp_frozen_time","mmp_interval","subaccount_id"],"properties":{"currency":{"title":"currency","type":"string","description":"Currency of this mmp config"},"mmp_amount_limit":{"title":"mmp_amount_limit","type":"string","format":"decimal","default":"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)"},"mmp_delta_limit":{"title":"mmp_delta_limit","type":"string","format":"decimal","default":"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)"},"mmp_frozen_time":{"title":"mmp_frozen_time","type":"integer","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"},"mmp_interval":{"title":"mmp_interval","type":"integer","description":"Time interval in ms over which the limits are monotored, if 0 then mmp is disabled"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to set the config"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetNotifications = {"body":{"required":["subaccount_id"],"properties":{"page":{"title":"page","type":"integer","default":1,"description":"Page number of results to return"},"page_size":{"title":"page_size","type":"integer","default":20,"description":"Number of results per page"},"status":{"title":"status","type":["string","null"],"default":null,"enum":["unseen","seen","hidden"],"description":"Status of the notification\n\nDefault: `null`"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"},"type":{"title":"type","type":["string","null"],"default":null,"enum":["deposit","withdraw","transfer","trade","settlement","liquidation","custom"],"description":"Status of the notification\n\nDefault: `null`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["notifications","subaccount_id"],"properties":{"notifications":{"title":"notifications","type":"array","description":"Notification response","items":{"required":["event","event_details","id","status","subaccount_id","timestamp"],"properties":{"event":{"title":"event","type":"string","description":"The specific event leading to the notification."},"event_details":{"title":"event_details","type":"object","description":"A JSON-structured dictionary containing detailed data or context about the event.","additionalProperties":true},"id":{"title":"id","type":"integer","description":"The unique identifier for the notification."},"status":{"title":"status","type":"string","description":"The status of the notification, indicating if it has been read, pending, or processed."},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"The subaccount_id associated with the notification."},"timestamp":{"title":"timestamp","type":"integer","description":"The timestamp indicating when the notification was created or triggered."},"transaction_id":{"title":"transaction_id","type":["integer","null"],"default":null,"description":"The transaction id associated with the notification."},"tx_hash":{"title":"tx_hash","type":["string","null"],"default":null,"description":"The transaction hash associated with the notification."}},"type":"object","additionalProperties":false}},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetOpenOrders = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get open orders"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["orders","subaccount_id"],"properties":{"orders":{"title":"orders","type":"array","description":"List of open orders","items":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false}},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get open orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetOptionSettlementHistory = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get expired option settlement history"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["settlements","subaccount_id"],"properties":{"settlements":{"title":"settlements","type":"array","description":"List of expired option settlements","items":{"required":["amount","expiry","instrument_name","option_settlement_pnl","settlement_price"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount that was settled"},"expiry":{"title":"expiry","type":"integer","description":"Expiry timestamp of the option"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"option_settlement_pnl":{"title":"option_settlement_pnl","type":"string","format":"decimal","description":"USD profit or loss from option settlements calculated as: settlement value - (average price x amount)"},"settlement_price":{"title":"settlement_price","type":"string","format":"decimal","description":"Price of option settlement"}},"type":"object","additionalProperties":false}},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get expired option settlement history"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetOrder = {"body":{"required":["order_id","subaccount_id"],"properties":{"order_id":{"title":"order_id","type":"string","description":"Order ID"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetOrderHistory = {"body":{"required":["subaccount_id"],"properties":{"page":{"title":"page","type":"integer","default":1,"description":"Page number of results to return (default 1, returns last if above `num_pages`)"},"page_size":{"title":"page_size","type":"integer","default":100,"description":"Number of results per page (default 100, max 1000)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get order history"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["orders","pagination","subaccount_id"],"properties":{"orders":{"title":"orders","type":"array","description":"List of open orders","items":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false}},"pagination":{"required":["count","num_pages"],"properties":{"count":{"title":"count","type":"integer","description":"Total number of items, across all pages"},"num_pages":{"title":"num_pages","type":"integer","description":"Number of pages"}},"type":"object","additionalProperties":false},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get open orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetOrders = {"body":{"required":["subaccount_id"],"properties":{"instrument_name":{"title":"instrument_name","type":["string","null"],"default":null,"description":"Filter by instrument name"},"label":{"title":"label","type":["string","null"],"default":null,"description":"Filter by label"},"page":{"title":"page","type":"integer","default":1,"description":"Page number of results to return (default 1, returns last if above `num_pages`)"},"page_size":{"title":"page_size","type":"integer","default":100,"description":"Number of results per page (default 100, max 1000)"},"status":{"title":"status","type":["string","null"],"default":null,"enum":["open","filled","rejected","cancelled","expired"],"description":"Filter by order status\n\nDefault: `null`"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get open orders"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["orders","pagination","subaccount_id"],"properties":{"orders":{"title":"orders","type":"array","description":"List of open orders","items":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false}},"pagination":{"required":["count","num_pages"],"properties":{"count":{"title":"count","type":"integer","description":"Total number of items, across all pages"},"num_pages":{"title":"num_pages","type":"integer","description":"Number of pages"}},"type":"object","additionalProperties":false},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get open orders"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetPositions = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["positions","subaccount_id"],"properties":{"positions":{"title":"positions","type":"array","description":"All active positions of subaccount","items":{"required":["amount","average_price","cumulative_funding","delta","gamma","index_price","initial_margin","instrument_name","instrument_type","leverage","liquidation_price","maintenance_margin","mark_price","mark_value","net_settlements","open_orders_margin","pending_funding","realized_pnl","theta","unrealized_pnl","vega"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Position amount held by subaccount"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average price of whole position"},"cumulative_funding":{"title":"cumulative_funding","type":"string","format":"decimal","description":"Cumulative funding for the position (only for perpetuals)."},"delta":{"title":"delta","type":"string","format":"decimal","description":"Asset delta (w.r.t. forward price for options, `1.0` for perps)"},"gamma":{"title":"gamma","type":"string","format":"decimal","description":"Asset gamma (zero for non-options)"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Current index (oracle) price for position's currency"},"initial_margin":{"title":"initial_margin","type":"string","format":"decimal","description":"USD initial margin requirement for this position"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name (same as the base Asset name)"},"instrument_type":{"title":"instrument_type","type":"string","enum":["erc20","option","perp"],"description":"`erc20`, `option`, or `perp`\n\n`erc20` `option` `perp`"},"leverage":{"title":"leverage","type":["string","null"],"format":"decimal","default":null,"description":"Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`"},"liquidation_price":{"title":"liquidation_price","type":["string","null"],"format":"decimal","default":null,"description":"Index price at which position will be liquidated"},"maintenance_margin":{"title":"maintenance_margin","type":"string","format":"decimal","description":"USD maintenance margin requirement for this position"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Current mark price for position's instrument"},"mark_value":{"title":"mark_value","type":"string","format":"decimal","description":"USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price"},"net_settlements":{"title":"net_settlements","type":"string","format":"decimal","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."},"open_orders_margin":{"title":"open_orders_margin","type":"string","format":"decimal","description":"USD margin requirement for all open orders for this asset / instrument"},"pending_funding":{"title":"pending_funding","type":"string","format":"decimal","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."},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized trading profit or loss of the position."},"theta":{"title":"theta","type":"string","format":"decimal","description":"Asset theta (zero for non-options)"},"unrealized_pnl":{"title":"unrealized_pnl","type":"string","format":"decimal","description":"Unrealized trading profit or loss of the position."},"vega":{"title":"vega","type":"string","format":"decimal","description":"Asset vega (zero for non-options)"}},"type":"object","additionalProperties":false}},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetSubaccount = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["collaterals","collaterals_initial_margin","collaterals_maintenance_margin","collaterals_value","currency","initial_margin","maintenance_margin","margin_type","open_orders","open_orders_margin","positions","positions_initial_margin","positions_maintenance_margin","positions_value","subaccount_id","subaccount_value"],"properties":{"collaterals":{"title":"collaterals","type":"array","description":"All collaterals that count towards margin of subaccount","items":{"required":["amount","asset_name","asset_type","cumulative_interest","currency","initial_margin","maintenance_margin","mark_price","mark_value","pending_interest"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Asset amount of given collateral"},"asset_name":{"title":"asset_name","type":"string","description":"Asset name"},"asset_type":{"title":"asset_type","type":"string","enum":["erc20","option","perp"],"description":"Type of asset collateral (currently always `erc20`)\n\n`erc20` `option` `perp`"},"cumulative_interest":{"title":"cumulative_interest","type":"string","format":"decimal","description":"Cumulative interest earned on supplying collateral or paid for borrowing"},"currency":{"title":"currency","type":"string","description":"Underlying currency of asset (`ETH`, `BTC`, etc)"},"initial_margin":{"title":"initial_margin","type":"string","format":"decimal","description":"USD value of collateral that contributes to initial margin"},"maintenance_margin":{"title":"maintenance_margin","type":"string","format":"decimal","description":"USD value of collateral that contributes to maintenance margin"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Current mark price of the asset"},"mark_value":{"title":"mark_value","type":"string","format":"decimal","description":"USD value of the collateral (amount * mark price)"},"pending_interest":{"title":"pending_interest","type":"string","format":"decimal","description":"Portion of interest that has not yet been settled on-chain. This number is added to the portfolio value for margin calculations purposes."}},"type":"object","additionalProperties":false}},"collaterals_initial_margin":{"title":"collaterals_initial_margin","type":"string","format":"decimal","description":"Total initial margin credit contributed by collaterals"},"collaterals_maintenance_margin":{"title":"collaterals_maintenance_margin","type":"string","format":"decimal","description":"Total maintenance margin credit contributed by collaterals"},"collaterals_value":{"title":"collaterals_value","type":"string","format":"decimal","description":"Total mark-to-market value of all collaterals"},"currency":{"title":"currency","type":"string","description":"Currency of subaccount"},"initial_margin":{"title":"initial_margin","type":"string","format":"decimal","description":"Total initial margin requirement of all positions and collaterals.Trades will be rejected if this value falls below zero after the trade."},"maintenance_margin":{"title":"maintenance_margin","type":"string","format":"decimal","description":"Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation."},"margin_type":{"title":"margin_type","type":"string","enum":["PM","SM"],"description":"Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))\n\n`PM` `SM`"},"open_orders":{"title":"open_orders","type":"array","description":"All open orders of subaccount","items":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false}},"open_orders_margin":{"title":"open_orders_margin","type":"string","format":"decimal","description":"Total margin requirement of all open orders.Orders will be rejected if this value plus initial margin are below zero after the order."},"positions":{"title":"positions","type":"array","description":"All active positions of subaccount","items":{"required":["amount","average_price","cumulative_funding","delta","gamma","index_price","initial_margin","instrument_name","instrument_type","leverage","liquidation_price","maintenance_margin","mark_price","mark_value","net_settlements","open_orders_margin","pending_funding","realized_pnl","theta","unrealized_pnl","vega"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Position amount held by subaccount"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average price of whole position"},"cumulative_funding":{"title":"cumulative_funding","type":"string","format":"decimal","description":"Cumulative funding for the position (only for perpetuals)."},"delta":{"title":"delta","type":"string","format":"decimal","description":"Asset delta (w.r.t. forward price for options, `1.0` for perps)"},"gamma":{"title":"gamma","type":"string","format":"decimal","description":"Asset gamma (zero for non-options)"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Current index (oracle) price for position's currency"},"initial_margin":{"title":"initial_margin","type":"string","format":"decimal","description":"USD initial margin requirement for this position"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name (same as the base Asset name)"},"instrument_type":{"title":"instrument_type","type":"string","enum":["erc20","option","perp"],"description":"`erc20`, `option`, or `perp`\n\n`erc20` `option` `perp`"},"leverage":{"title":"leverage","type":["string","null"],"format":"decimal","default":null,"description":"Only for perps. Leverage of the position, defined as `abs(notional) / collateral net of options margin`"},"liquidation_price":{"title":"liquidation_price","type":["string","null"],"format":"decimal","default":null,"description":"Index price at which position will be liquidated"},"maintenance_margin":{"title":"maintenance_margin","type":"string","format":"decimal","description":"USD maintenance margin requirement for this position"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Current mark price for position's instrument"},"mark_value":{"title":"mark_value","type":"string","format":"decimal","description":"USD value of the position; this represents how much USD can be recieved by fully closing the position at the current oracle price"},"net_settlements":{"title":"net_settlements","type":"string","format":"decimal","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."},"open_orders_margin":{"title":"open_orders_margin","type":"string","format":"decimal","description":"USD margin requirement for all open orders for this asset / instrument"},"pending_funding":{"title":"pending_funding","type":"string","format":"decimal","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."},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized trading profit or loss of the position."},"theta":{"title":"theta","type":"string","format":"decimal","description":"Asset theta (zero for non-options)"},"unrealized_pnl":{"title":"unrealized_pnl","type":"string","format":"decimal","description":"Unrealized trading profit or loss of the position."},"vega":{"title":"vega","type":"string","format":"decimal","description":"Asset vega (zero for non-options)"}},"type":"object","additionalProperties":false}},"positions_initial_margin":{"title":"positions_initial_margin","type":"string","format":"decimal","description":"Total initial margin requirement of all positions"},"positions_maintenance_margin":{"title":"positions_maintenance_margin","type":"string","format":"decimal","description":"Total maintenance margin requirement of all positions"},"positions_value":{"title":"positions_value","type":"string","format":"decimal","description":"Total mark-to-market value of all positions"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"},"subaccount_value":{"title":"subaccount_value","type":"string","format":"decimal","description":"Total mark-to-market value of all positions and collaterals"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetSubaccountValueHistory = {"body":{"required":["end_timestamp","period","start_timestamp","subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","description":"End timestamp"},"period":{"title":"period","type":"integer","description":"Period"},"start_timestamp":{"title":"start_timestamp","type":"integer","description":"Start timestamp"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["subaccount_id","subaccount_value_history"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"},"subaccount_value_history":{"title":"subaccount_value_history","type":"array","description":"Subaccount value history","items":{"required":["subaccount_value","timestamp"],"properties":{"subaccount_value":{"title":"subaccount_value","type":"string","format":"decimal","description":"Total mark-to-market value of all positions and collaterals"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of when the subaccount value was recorded into the database"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetSubaccounts = {"body":{"required":["wallet"],"properties":{"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address of account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["subaccount_ids","wallet"],"properties":{"subaccount_ids":{"title":"subaccount_ids","type":"array","description":"List of subaccount_ids owned by the wallet in `SubAccounts.sol`","items":{"title":"subaccount_ids","type":"integer"}},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetTradeHistory = {"body":{"required":["subaccount_id"],"properties":{"from_timestamp":{"title":"from_timestamp","type":"integer","default":0,"description":"Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0."},"instrument_name":{"title":"instrument_name","type":["string","null"],"default":null,"description":"Instrument name to filter by"},"order_id":{"title":"order_id","type":["string","null"],"default":null,"description":"Order id to filter by"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get trades"},"to_timestamp":{"title":"to_timestamp","type":"integer","default":18446744073709552000,"description":"Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time."}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["subaccount_id","trades"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to get the trade history"},"trades":{"title":"trades","type":"array","description":"List of trades","items":{"required":["direction","index_price","instrument_name","is_transfer","label","liquidity_role","mark_price","order_id","realized_pnl","subaccount_id","timestamp","trade_amount","trade_fee","trade_id","trade_price","tx_hash","tx_status"],"properties":{"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Index price of the underlying at the time of the trade"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the trade was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"liquidity_role":{"title":"liquidity_role","type":"string","enum":["maker","taker"],"description":"Role of the user in the trade\n\n`maker` `taker`"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price of the instrument at the time of the trade"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized PnL for this trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"timestamp":{"title":"timestamp","type":"integer","description":"Trade timestamp (in ms since Unix epoch)"},"trade_amount":{"title":"trade_amount","type":"string","format":"decimal","description":"Amount filled in this trade"},"trade_fee":{"title":"trade_fee","type":"string","format":"decimal","description":"Fee for this trade"},"trade_id":{"title":"trade_id","type":"string","description":"Trade ID"},"trade_price":{"title":"trade_price","type":"string","format":"decimal","description":"Price at which the trade was filled"},"tx_hash":{"title":"tx_hash","type":["string","null"],"default":null,"description":"Blockchain transaction hash"},"tx_status":{"title":"tx_status","type":"string","enum":["requested","pending","settled","reverted","ignored"],"description":"Blockchain transaction status\n\n`requested` `pending` `settled` `reverted` `ignored`"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateGetWithdrawalHistory = {"body":{"required":["subaccount_id"],"properties":{"end_timestamp":{"title":"end_timestamp","type":"integer","default":9223372036854776000,"description":"End timestamp of the event history (default current time)"},"start_timestamp":{"title":"start_timestamp","type":"integer","default":0,"description":"Start timestamp of the event history (default 0)"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["events"],"properties":{"events":{"title":"events","type":"array","description":"List of withdrawals","items":{"required":["amount","asset","timestamp","tx_hash"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount withdrawn by the subaccount"},"asset":{"title":"asset","type":"string","description":"Asset withdrawn"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the withdrawal (in ms since UNIX epoch)"},"tx_hash":{"title":"tx_hash","type":"string","description":"Hash of the transaction that withdrew the funds"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateOrder = {"body":{"required":["amount","direction","instrument_name","limit_price","max_fee","nonce","signature","signature_expiry_sec","signer","subaccount_id"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","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."},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order."},"mmp":{"title":"mmp","type":"boolean","default":false,"description":"Whether the order is tagged for market maker protections (default false)"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_type":{"title":"order_type","type":"string","default":"limit","enum":["limit","market"],"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\n\nDefault: `limit`"},"reduce_only":{"title":"reduce_only","type":"boolean","default":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)"},"referral_code":{"title":"referral_code","type":"string","description":"Optional referral code for the order"},"reject_timestamp":{"title":"reject_timestamp","type":"integer","default":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."},"signature":{"title":"signature","type":"string","description":"Etherium signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","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."},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","default":"gtc","enum":["gtc","post_only","fok","ioc"],"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.\n\nDefault: `gtc`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["order","trades"],"properties":{"order":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false},"trades":{"title":"trades","type":"array","items":{"required":["direction","index_price","instrument_name","is_transfer","label","liquidity_role","mark_price","order_id","realized_pnl","subaccount_id","timestamp","trade_amount","trade_fee","trade_id","trade_price","tx_hash","tx_status"],"properties":{"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Index price of the underlying at the time of the trade"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the trade was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"liquidity_role":{"title":"liquidity_role","type":"string","enum":["maker","taker"],"description":"Role of the user in the trade\n\n`maker` `taker`"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price of the instrument at the time of the trade"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized PnL for this trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"timestamp":{"title":"timestamp","type":"integer","description":"Trade timestamp (in ms since Unix epoch)"},"trade_amount":{"title":"trade_amount","type":"string","format":"decimal","description":"Amount filled in this trade"},"trade_fee":{"title":"trade_fee","type":"string","format":"decimal","description":"Fee for this trade"},"trade_id":{"title":"trade_id","type":"string","description":"Trade ID"},"trade_price":{"title":"trade_price","type":"string","format":"decimal","description":"Price at which the trade was filled"},"tx_hash":{"title":"tx_hash","type":["string","null"],"default":null,"description":"Blockchain transaction hash"},"tx_status":{"title":"tx_status","type":"string","enum":["requested","pending","settled","reverted","ignored"],"description":"Blockchain transaction status\n\n`requested` `pending` `settled` `reverted` `ignored`"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateOrderDebug = {"body":{"required":["amount","direction","instrument_name","limit_price","max_fee","nonce","signature","signature_expiry_sec","signer","subaccount_id"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","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."},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order."},"mmp":{"title":"mmp","type":"boolean","default":false,"description":"Whether the order is tagged for market maker protections (default false)"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_type":{"title":"order_type","type":"string","default":"limit","enum":["limit","market"],"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\n\nDefault: `limit`"},"reduce_only":{"title":"reduce_only","type":"boolean","default":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)"},"referral_code":{"title":"referral_code","type":"string","description":"Optional referral code for the order"},"reject_timestamp":{"title":"reject_timestamp","type":"integer","default":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."},"signature":{"title":"signature","type":"string","description":"Etherium signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","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."},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","default":"gtc","enum":["gtc","post_only","fok","ioc"],"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.\n\nDefault: `gtc`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["action_hash","encoded_data","encoded_data_hashed","raw_data","typed_data_hash"],"properties":{"action_hash":{"title":"action_hash","type":"string","description":"Keccak hashed action data"},"encoded_data":{"title":"encoded_data","type":"string","description":"ABI encoded order data"},"encoded_data_hashed":{"title":"encoded_data_hashed","type":"string","description":"Keccak hashed encoded_data"},"raw_data":{"required":["data","expiry","module","nonce","owner","signature","signer","subaccount_id"],"properties":{"data":{"required":["asset","desired_amount","is_bid","limit_price","recipient_id","sub_id","trade_id","worst_fee"],"properties":{"asset":{"title":"asset","type":"string"},"desired_amount":{"title":"desired_amount","type":"string","format":"decimal"},"is_bid":{"title":"is_bid","type":"boolean"},"limit_price":{"title":"limit_price","type":"string","format":"decimal"},"recipient_id":{"title":"recipient_id","type":"integer"},"sub_id":{"title":"sub_id","type":"integer"},"trade_id":{"title":"trade_id","type":"string"},"worst_fee":{"title":"worst_fee","type":"string","format":"decimal"}},"type":"object","additionalProperties":false},"expiry":{"title":"expiry","type":"integer"},"module":{"title":"module","type":"string"},"nonce":{"title":"nonce","type":"integer"},"owner":{"title":"owner","type":"string"},"signature":{"title":"signature","type":"string"},"signer":{"title":"signer","type":"string"},"subaccount_id":{"title":"subaccount_id","type":"integer"}},"type":"object","additionalProperties":false},"typed_data_hash":{"title":"typed_data_hash","type":"string","description":"EIP 712 typed data hash"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateResetMmp = {"body":{"required":["subaccount_id"],"properties":{"currency":{"title":"currency","type":["string","null"],"default":null,"description":"Currency to reset the mmp for. If not provided, resets all configs for the subaccount"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to reset the mmp state"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"string","enum":["ok"],"description":"The result of this method call, `ok` if successful\n\n`ok`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateSessionKeys = {"body":{"required":["wallet"],"properties":{"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address of account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["public_session_keys"],"properties":{"public_session_keys":{"title":"public_session_keys","type":"array","description":"List of session keys (includes unactivated and expired keys)","items":{"required":["expiry_sec","public_session_key"],"properties":{"expiry_sec":{"title":"expiry_sec","type":"integer","description":"Session key expiry timestamp in sec"},"label":{"title":"label","type":"string","description":"User-defined session key label"},"public_session_key":{"title":"public_session_key","type":"string","description":"Public session key address (Ethereum EOA)"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateSetCancelOnDisconnect = {"body":{"required":["enabled","wallet"],"properties":{"enabled":{"title":"enabled","type":"boolean","description":"Whether to enable or disable cancel on disconnect"},"wallet":{"title":"wallet","type":"string","description":"Public key (wallet) of the account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"string","enum":["ok"],"description":"\n\n`ok`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateSetMmpConfig = {"body":{"required":["currency","mmp_frozen_time","mmp_interval","subaccount_id"],"properties":{"currency":{"title":"currency","type":"string","description":"Currency of this mmp config"},"mmp_amount_limit":{"title":"mmp_amount_limit","type":"string","format":"decimal","default":"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)"},"mmp_delta_limit":{"title":"mmp_delta_limit","type":"string","format":"decimal","default":"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)"},"mmp_frozen_time":{"title":"mmp_frozen_time","type":"integer","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"},"mmp_interval":{"title":"mmp_interval","type":"integer","description":"Time interval in ms over which the limits are monotored, if 0 then mmp is disabled"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to set the config"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["currency","mmp_frozen_time","mmp_interval","subaccount_id"],"properties":{"currency":{"title":"currency","type":"string","description":"Currency of this mmp config"},"mmp_amount_limit":{"title":"mmp_amount_limit","type":"string","format":"decimal","default":"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)"},"mmp_delta_limit":{"title":"mmp_delta_limit","type":"string","format":"decimal","default":"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)"},"mmp_frozen_time":{"title":"mmp_frozen_time","type":"integer","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"},"mmp_interval":{"title":"mmp_interval","type":"integer","description":"Time interval in ms over which the limits are monotored, if 0 then mmp is disabled"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id for which to set the config"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateTransferErc20 = {"body":{"required":["recipient_details","recipient_subaccount_id","sender_details","subaccount_id","transfer"],"properties":{"recipient_details":{"required":["nonce","signature","signature_expiry_sec","signer"],"properties":{"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the transfer"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Unix timestamp in seconds. Expiry MUST be >5min from now"},"signer":{"title":"signer","type":"string","description":"Ethereum wallet address that is signing the transfer"}},"type":"object","additionalProperties":false},"recipient_subaccount_id":{"title":"recipient_subaccount_id","type":"integer","description":"Subaccount_id of the recipient"},"sender_details":{"required":["nonce","signature","signature_expiry_sec","signer"],"properties":{"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the transfer"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Unix timestamp in seconds. Expiry MUST be >5min from now"},"signer":{"title":"signer","type":"string","description":"Ethereum wallet address that is signing the transfer"}},"type":"object","additionalProperties":false},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"},"transfer":{"required":["address","amount","sub_id"],"properties":{"address":{"title":"address","type":"string","description":"Ethereum address of the asset being transferred"},"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount to transfer"},"sub_id":{"title":"sub_id","type":"integer","description":"Sub ID of the asset being transferred"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["status","transaction_id"],"properties":{"status":{"title":"status","type":"string","description":"`requested`"},"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"Transaction id of the transfer"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateTransferPosition = {"body":{"required":["maker_params","taker_params","wallet"],"properties":{"maker_params":{"required":["amount","direction","instrument_name","limit_price","max_fee","nonce","signature","signature_expiry_sec","signer","subaccount_id"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","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."},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order."},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Etherium signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","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."},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false},"taker_params":{"required":["amount","direction","instrument_name","limit_price","max_fee","nonce","signature","signature_expiry_sec","signer","subaccount_id"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","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."},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency. Order will be rejected if the supplied max fee is below the estimated fee for this order."},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Etherium signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","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."},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"}},"type":"object","additionalProperties":false},"wallet":{"title":"wallet","type":"string","description":"Public key (wallet) of the account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["maker_order","maker_trade","taker_order","taker_trade"],"properties":{"maker_order":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false},"maker_trade":{"required":["direction","index_price","instrument_name","is_transfer","label","liquidity_role","mark_price","order_id","realized_pnl","subaccount_id","timestamp","trade_amount","trade_fee","trade_id","trade_price","tx_hash","tx_status"],"properties":{"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Index price of the underlying at the time of the trade"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the trade was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"liquidity_role":{"title":"liquidity_role","type":"string","enum":["maker","taker"],"description":"Role of the user in the trade\n\n`maker` `taker`"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price of the instrument at the time of the trade"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized PnL for this trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"timestamp":{"title":"timestamp","type":"integer","description":"Trade timestamp (in ms since Unix epoch)"},"trade_amount":{"title":"trade_amount","type":"string","format":"decimal","description":"Amount filled in this trade"},"trade_fee":{"title":"trade_fee","type":"string","format":"decimal","description":"Fee for this trade"},"trade_id":{"title":"trade_id","type":"string","description":"Trade ID"},"trade_price":{"title":"trade_price","type":"string","format":"decimal","description":"Price at which the trade was filled"},"tx_hash":{"title":"tx_hash","type":["string","null"],"default":null,"description":"Blockchain transaction hash"},"tx_status":{"title":"tx_status","type":"string","enum":["requested","pending","settled","reverted","ignored"],"description":"Blockchain transaction status\n\n`requested` `pending` `settled` `reverted` `ignored`"}},"type":"object","additionalProperties":false},"taker_order":{"required":["amount","average_price","cancel_reason","creation_timestamp","direction","filled_amount","instrument_name","is_transfer","label","last_update_timestamp","limit_price","max_fee","mmp","nonce","order_fee","order_id","order_status","order_type","signature","signature_expiry_sec","signer","subaccount_id","time_in_force"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Order amount in units of the base"},"average_price":{"title":"average_price","type":"string","format":"decimal","description":"Average fill price"},"cancel_reason":{"title":"cancel_reason","type":"string","enum":["","user_request","mmp_trigger","insufficient_margin","signed_max_fee_too_low","cancel_on_disconnect","ioc_or_market_partial_fill","session_key_deregistered","subaccount_withdrawn","compliance"],"description":"If cancelled, reason behind order cancellation\n\n`user_request` `mmp_trigger` `insufficient_margin` `signed_max_fee_too_low` `cancel_on_disconnect` `ioc_or_market_partial_fill` `session_key_deregistered` `subaccount_withdrawn` `compliance`"},"creation_timestamp":{"title":"creation_timestamp","type":"integer","description":"Creation timestamp (in ms since Unix epoch)"},"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"filled_amount":{"title":"filled_amount","type":"string","format":"decimal","description":"Total filled amount for the order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the order was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"last_update_timestamp":{"title":"last_update_timestamp","type":"integer","description":"Last update timestamp (in ms since Unix epoch)"},"limit_price":{"title":"limit_price","type":"string","format":"decimal","description":"Limit price in quote currency"},"max_fee":{"title":"max_fee","type":"string","format":"decimal","description":"Max fee in units of the quote currency"},"mmp":{"title":"mmp","type":"boolean","description":"Whether the order is tagged for market maker protections"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"order_fee":{"title":"order_fee","type":"string","format":"decimal","description":"Total order fee paid so far"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"order_status":{"title":"order_status","type":"string","enum":["open","filled","rejected","cancelled","expired"],"description":"Order status\n\n`open` `filled` `rejected` `cancelled` `expired`"},"order_type":{"title":"order_type","type":"string","enum":["limit","market"],"description":"Order type\n\n`limit` `market`"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the order"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Signature expiry timestamp"},"signer":{"title":"signer","type":"string","description":"Owner wallet address or registered session key that signed order"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"time_in_force":{"title":"time_in_force","type":"string","enum":["gtc","post_only","fok","ioc"],"description":"Time in force\n\n`gtc` `post_only` `fok` `ioc`"}},"type":"object","additionalProperties":false},"taker_trade":{"required":["direction","index_price","instrument_name","is_transfer","label","liquidity_role","mark_price","order_id","realized_pnl","subaccount_id","timestamp","trade_amount","trade_fee","trade_id","trade_price","tx_hash","tx_status"],"properties":{"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Index price of the underlying at the time of the trade"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"is_transfer":{"title":"is_transfer","type":"boolean","description":"Whether the trade was generated through `private/transfer_position`"},"label":{"title":"label","type":"string","description":"Optional user-defined label for the order"},"liquidity_role":{"title":"liquidity_role","type":"string","enum":["maker","taker"],"description":"Role of the user in the trade\n\n`maker` `taker`"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price of the instrument at the time of the trade"},"order_id":{"title":"order_id","type":"string","description":"Order ID"},"realized_pnl":{"title":"realized_pnl","type":"string","format":"decimal","description":"Realized PnL for this trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"timestamp":{"title":"timestamp","type":"integer","description":"Trade timestamp (in ms since Unix epoch)"},"trade_amount":{"title":"trade_amount","type":"string","format":"decimal","description":"Amount filled in this trade"},"trade_fee":{"title":"trade_fee","type":"string","format":"decimal","description":"Fee for this trade"},"trade_id":{"title":"trade_id","type":"string","description":"Trade ID"},"trade_price":{"title":"trade_price","type":"string","format":"decimal","description":"Price at which the trade was filled"},"tx_hash":{"title":"tx_hash","type":["string","null"],"default":null,"description":"Blockchain transaction hash"},"tx_status":{"title":"tx_status","type":"string","enum":["requested","pending","settled","reverted","ignored"],"description":"Blockchain transaction status\n\n`requested` `pending` `settled` `reverted` `ignored`"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateUpdateNotifications = {"body":{"required":["notification_ids","subaccount_id"],"properties":{"notification_ids":{"title":"notification_ids","type":"array","description":"List of notification IDs to be marked as seen","items":{"title":"notification_ids","type":"integer"}},"status":{"title":"status","type":"string","default":"seen","enum":["unseen","seen","hidden"],"description":"Status of the notification\n\nDefault: `seen`"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["updated_count"],"properties":{"updated_count":{"title":"updated_count","type":"integer","description":"Number of notifications marked as seen"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPrivateWithdraw = {"body":{"required":["amount","asset_name","nonce","signature","signature_expiry_sec","signer","subaccount_id"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount of the asset to withdraw"},"asset_name":{"title":"asset_name","type":"string","description":"Name of asset to withdraw"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature":{"title":"signature","type":"string","description":"Ethereum signature of the withdraw"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Unix timestamp in seconds. Expiry MUST be >5min from now"},"signer":{"title":"signer","type":"string","description":"Ethereum wallet address that is signing the withdraw"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["status","transaction_id"],"properties":{"status":{"title":"status","type":"string","description":"`requested`"},"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"Transaction id of the withdrawal"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicBuildRegisterSessionKeyTx = {"body":{"required":["expiry_sec","gas","nonce","public_session_key","wallet"],"properties":{"expiry_sec":{"title":"expiry_sec","type":"integer","description":"Expiry of the session key"},"gas":{"title":"gas","type":["integer","null"],"default":null,"description":"Gas allowance for transaction. If none, will use estimateGas * 150%"},"nonce":{"title":"nonce","type":["integer","null"],"default":null,"description":"Wallet's transaction count, If none, will use eth.getTransactionCount()"},"public_session_key":{"title":"public_session_key","type":"string","description":"Session key in the form of an Ethereum EOA"},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address of account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["tx_params"],"properties":{"tx_params":{"title":"tx_params","type":"object","description":"Transaction params in dictionary form, same as `TxParams` in `web3.py`","additionalProperties":true}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicCreateAccount = {"body":{"required":["wallet"],"properties":{"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["status","wallet"],"properties":{"status":{"title":"status","type":"string","description":"`created` or `exists`"},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicCreateSubaccountDebug = {"body":{"required":["amount","asset_name","margin_type","nonce","signature_expiry_sec","signer","wallet"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Amount of the asset to deposit"},"asset_name":{"title":"asset_name","type":"string","description":"Name of asset to deposit"},"currency":{"title":"currency","type":["string","null"],"default":null,"description":"Base currency of the subaccount (only for `PM`)"},"margin_type":{"title":"margin_type","type":"string","enum":["PM","SM"],"description":"`PM` (Portfolio Margin) or `SM` (Standard Margin)"},"nonce":{"title":"nonce","type":"integer","description":"Unique nonce defined as (e.g. 1695836058725001, where 001 is the random number)"},"signature_expiry_sec":{"title":"signature_expiry_sec","type":"integer","description":"Unix timestamp in seconds. Expiry MUST be >5min from now"},"signer":{"title":"signer","type":"string","description":"Ethereum wallet address that is signing the deposit"},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["action_hash","encoded_data","encoded_data_hashed","typed_data_hash"],"properties":{"action_hash":{"title":"action_hash","type":"string","description":"Keccak hashed action data"},"encoded_data":{"title":"encoded_data","type":"string","description":"ABI encoded deposit data"},"encoded_data_hashed":{"title":"encoded_data_hashed","type":"string","description":"Keccak hashed encoded_data"},"typed_data_hash":{"title":"typed_data_hash","type":"string","description":"EIP 712 typed data hash"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicDeregisterSessionKey = {"body":{"required":["public_session_key","signed_raw_tx","wallet"],"properties":{"public_session_key":{"title":"public_session_key","type":"string","description":"Session key in the form of an Ethereum EOA"},"signed_raw_tx":{"title":"signed_raw_tx","type":"string","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()`)"},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address of account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["public_session_key","transaction_id"],"properties":{"public_session_key":{"title":"public_session_key","type":"string","description":"Session key in the form of an Ethereum EOA"},"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"ID to lookup status of transaction"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetInstrument = {"body":{"required":["instrument_name"],"properties":{"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["amount_step","base_asset_address","base_asset_sub_id","base_currency","base_fee","instrument_name","instrument_type","is_active","maker_fee_rate","maximum_amount","minimum_amount","option_details","perp_details","quote_currency","scheduled_activation","scheduled_deactivation","taker_fee_rate","tick_size"],"properties":{"amount_step":{"title":"amount_step","type":"string","format":"decimal","description":"Minimum valid increment of order amount"},"base_asset_address":{"title":"base_asset_address","type":"string","description":"Blockchain address of the base asset"},"base_asset_sub_id":{"title":"base_asset_sub_id","type":"string","description":"Sub ID of the specific base asset as defined in Asset.sol"},"base_currency":{"title":"base_currency","type":"string","description":"Underlying currency of base asset (`ETH`, `BTC`, etc)"},"base_fee":{"title":"base_fee","type":"string","format":"decimal","description":"$ base fee added to every taker order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"instrument_type":{"title":"instrument_type","type":"string","enum":["erc20","option","perp"],"description":"`erc20`, `option`, or `perp`\n\n`erc20` `option` `perp`"},"is_active":{"title":"is_active","type":"boolean","description":"If `True`: instrument is tradeable within `activation` and `deactivation` timestamps"},"maker_fee_rate":{"title":"maker_fee_rate","type":"string","format":"decimal","description":"Percent of spot price fee rate for makers"},"mark_price_fee_rate_cap":{"title":"mark_price_fee_rate_cap","type":["string","null"],"format":"decimal","default":null,"description":"Percent of option price fee cap, e.g. 12.5%, null if not applicable"},"maximum_amount":{"title":"maximum_amount","type":"string","format":"decimal","description":"Maximum valid amount of contracts / tokens per trade"},"minimum_amount":{"title":"minimum_amount","type":"string","format":"decimal","description":"Minimum valid amount of contracts / tokens per trade"},"option_details":{"required":["expiry","index","option_type","strike"],"properties":{"expiry":{"title":"expiry","type":"integer","description":"Unix timestamp of expiry date (in seconds)"},"index":{"title":"index","type":"string","description":"Underlying settlement price index"},"option_type":{"title":"option_type","type":"string","enum":["C","P"],"description":"`C` `P`"},"settlement_price":{"title":"settlement_price","type":["string","null"],"format":"decimal","default":null,"description":"Settlement price of the option"},"strike":{"title":"strike","type":"string","format":"decimal"}},"type":"object","additionalProperties":false},"perp_details":{"required":["aggregate_funding","funding_rate","index","max_rate_per_hour","min_rate_per_hour","static_interest_rate"],"properties":{"aggregate_funding":{"title":"aggregate_funding","type":"string","format":"decimal","description":"Latest aggregated funding as per `PerpAsset.sol`"},"funding_rate":{"title":"funding_rate","type":"string","format":"decimal","description":"Current hourly funding rate as per `PerpAsset.sol`"},"index":{"title":"index","type":"string","description":"Underlying spot price index for funding rate"},"max_rate_per_hour":{"title":"max_rate_per_hour","type":"string","format":"decimal","description":"Max rate per hour as per `PerpAsset.sol`"},"min_rate_per_hour":{"title":"min_rate_per_hour","type":"string","format":"decimal","description":"Min rate per hour as per `PerpAsset.sol`"},"static_interest_rate":{"title":"static_interest_rate","type":"string","format":"decimal","description":"Static interest rate as per `PerpAsset.sol`"}},"type":"object","additionalProperties":false},"quote_currency":{"title":"quote_currency","type":"string","description":"Quote currency (`USD` for perps, `USDC` for options)"},"scheduled_activation":{"title":"scheduled_activation","type":"integer","description":"Timestamp at which became or will become active (if applicable)"},"scheduled_deactivation":{"title":"scheduled_deactivation","type":"integer","description":"Scheduled deactivation time for instrument (if applicable)"},"taker_fee_rate":{"title":"taker_fee_rate","type":"string","format":"decimal","description":"Percent of spot price fee rate for takers"},"tick_size":{"title":"tick_size","type":"string","format":"decimal","description":"Tick size of the instrument, i.e. minimum price increment"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetInstruments = {"body":{"required":["currency","expired","instrument_type"],"properties":{"currency":{"title":"currency","type":"string","description":"Underlying currency of asset (`ETH`, `BTC`, etc)"},"expired":{"title":"expired","type":"boolean","description":"If `True`: include expired assets"},"instrument_type":{"title":"instrument_type","type":"string","enum":["erc20","option","perp"],"description":"`erc20`, `option`, or `perp`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"array","description":"","items":{"required":["amount_step","base_asset_address","base_asset_sub_id","base_currency","base_fee","instrument_name","instrument_type","is_active","maker_fee_rate","maximum_amount","minimum_amount","option_details","perp_details","quote_currency","scheduled_activation","scheduled_deactivation","taker_fee_rate","tick_size"],"properties":{"amount_step":{"title":"amount_step","type":"string","format":"decimal","description":"Minimum valid increment of order amount"},"base_asset_address":{"title":"base_asset_address","type":"string","description":"Blockchain address of the base asset"},"base_asset_sub_id":{"title":"base_asset_sub_id","type":"string","description":"Sub ID of the specific base asset as defined in Asset.sol"},"base_currency":{"title":"base_currency","type":"string","description":"Underlying currency of base asset (`ETH`, `BTC`, etc)"},"base_fee":{"title":"base_fee","type":"string","format":"decimal","description":"$ base fee added to every taker order"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"instrument_type":{"title":"instrument_type","type":"string","enum":["erc20","option","perp"],"description":"`erc20`, `option`, or `perp`\n\n`erc20` `option` `perp`"},"is_active":{"title":"is_active","type":"boolean","description":"If `True`: instrument is tradeable within `activation` and `deactivation` timestamps"},"maker_fee_rate":{"title":"maker_fee_rate","type":"string","format":"decimal","description":"Percent of spot price fee rate for makers"},"mark_price_fee_rate_cap":{"title":"mark_price_fee_rate_cap","type":["string","null"],"format":"decimal","default":null,"description":"Percent of option price fee cap, e.g. 12.5%, null if not applicable"},"maximum_amount":{"title":"maximum_amount","type":"string","format":"decimal","description":"Maximum valid amount of contracts / tokens per trade"},"minimum_amount":{"title":"minimum_amount","type":"string","format":"decimal","description":"Minimum valid amount of contracts / tokens per trade"},"option_details":{"required":["expiry","index","option_type","strike"],"properties":{"expiry":{"title":"expiry","type":"integer","description":"Unix timestamp of expiry date (in seconds)"},"index":{"title":"index","type":"string","description":"Underlying settlement price index"},"option_type":{"title":"option_type","type":"string","enum":["C","P"],"description":"`C` `P`"},"settlement_price":{"title":"settlement_price","type":["string","null"],"format":"decimal","default":null,"description":"Settlement price of the option"},"strike":{"title":"strike","type":"string","format":"decimal"}},"type":"object","additionalProperties":false},"perp_details":{"required":["aggregate_funding","funding_rate","index","max_rate_per_hour","min_rate_per_hour","static_interest_rate"],"properties":{"aggregate_funding":{"title":"aggregate_funding","type":"string","format":"decimal","description":"Latest aggregated funding as per `PerpAsset.sol`"},"funding_rate":{"title":"funding_rate","type":"string","format":"decimal","description":"Current hourly funding rate as per `PerpAsset.sol`"},"index":{"title":"index","type":"string","description":"Underlying spot price index for funding rate"},"max_rate_per_hour":{"title":"max_rate_per_hour","type":"string","format":"decimal","description":"Max rate per hour as per `PerpAsset.sol`"},"min_rate_per_hour":{"title":"min_rate_per_hour","type":"string","format":"decimal","description":"Min rate per hour as per `PerpAsset.sol`"},"static_interest_rate":{"title":"static_interest_rate","type":"string","format":"decimal","description":"Static interest rate as per `PerpAsset.sol`"}},"type":"object","additionalProperties":false},"quote_currency":{"title":"quote_currency","type":"string","description":"Quote currency (`USD` for perps, `USDC` for options)"},"scheduled_activation":{"title":"scheduled_activation","type":"integer","description":"Timestamp at which became or will become active (if applicable)"},"scheduled_deactivation":{"title":"scheduled_deactivation","type":"integer","description":"Scheduled deactivation time for instrument (if applicable)"},"taker_fee_rate":{"title":"taker_fee_rate","type":"string","format":"decimal","description":"Percent of spot price fee rate for takers"},"tick_size":{"title":"tick_size","type":"string","format":"decimal","description":"Tick size of the instrument, i.e. minimum price increment"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetLatestSignedFeeds = {"body":{"properties":{"currency":{"title":"currency","type":["string","null"],"default":null,"description":"Currency filter, (defaults to all currencies)"},"expiry":{"title":"expiry","type":["integer","null"],"default":null,"description":"Expiry filter for options and forward data (defaults to all expiries). Use `0` to get data only for spot and perpetuals"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["fwd_data","perp_data","spot_data","vol_data"],"properties":{"fwd_data":{"title":"fwd_data","type":"object","description":"currency -> expiry -> latest forward feed data","additionalProperties":{"title":"fwd_data","type":"object","additionalProperties":{"required":["confidence","currency","deadline","expiry","fwd_diff","signatures","spot_aggregate_latest","spot_aggregate_start","timestamp"],"properties":{"confidence":{"title":"confidence","type":"string","format":"decimal","description":"The confidence score of the price"},"currency":{"title":"currency","type":"string","description":"The currency for which the spot feed represents"},"deadline":{"title":"deadline","type":"integer","description":"The latest time the data can be submitted on chain"},"expiry":{"title":"expiry","type":"integer","description":"The expiry for the forward feed"},"fwd_diff":{"title":"fwd_diff","type":"string","format":"decimal","description":"difference of forward price from current spot price"},"signatures":{"properties":{"signatures":{"title":"signatures","type":"array","description":"The signatures of the given signers","items":{"title":"signatures","type":"string"}},"signers":{"title":"signers","type":"array","description":"The signers who verify the data integrity","items":{"title":"signers","type":"string"}}},"type":"object","additionalProperties":false},"spot_aggregate_latest":{"title":"spot_aggregate_latest","type":"string","format":"decimal","description":"expiry -> spot * time value at the latest timestamp"},"spot_aggregate_start":{"title":"spot_aggregate_start","type":"string","format":"decimal","description":"spot * time value at the start of the settlement period"},"timestamp":{"title":"timestamp","type":"integer","description":"The timestamp for which the data was created"}},"type":"object","additionalProperties":false}}},"perp_data":{"title":"perp_data","type":"object","description":"currency -> feed type -> latest perp feed data","additionalProperties":{"title":"perp_data","type":"object","additionalProperties":{"required":["confidence","currency","deadline","signatures","spot_diff_value","timestamp","type"],"properties":{"confidence":{"title":"confidence","type":"string","format":"decimal","description":"The confidence score of the price"},"currency":{"title":"currency","type":"string","description":"The currency for which the spot feed represents"},"deadline":{"title":"deadline","type":"integer","description":"The latest time the data can be submitted on chain"},"signatures":{"properties":{"signatures":{"title":"signatures","type":"array","description":"The signatures of the given signers","items":{"title":"signatures","type":"string"}},"signers":{"title":"signers","type":"array","description":"The signers who verify the data integrity","items":{"title":"signers","type":"string"}}},"type":"object","additionalProperties":false},"spot_diff_value":{"title":"spot_diff_value","type":"string","format":"decimal","description":"The difference between the spot price and the perp price"},"timestamp":{"title":"timestamp","type":"integer","description":"The timestamp for which the data was created"},"type":{"title":"type","type":"string","enum":["P","A","B"],"description":"The type of perp feed; mid price, ask impact or bid impact\n\n`P` `A` `B`"}},"type":"object","additionalProperties":false}}},"spot_data":{"title":"spot_data","type":"object","description":"currency -> latest spot feed data","additionalProperties":{"required":["confidence","currency","deadline","price","signatures","timestamp"],"properties":{"confidence":{"title":"confidence","type":"string","format":"decimal","description":"The confidence score of the price"},"currency":{"title":"currency","type":"string","description":"The currency for which the spot feed represents"},"deadline":{"title":"deadline","type":"integer","description":"The latest time the data can be submitted on chain"},"price":{"title":"price","type":"string","format":"decimal","description":"The price of the currency in USD"},"signatures":{"properties":{"signatures":{"title":"signatures","type":"array","description":"The signatures of the given signers","items":{"title":"signatures","type":"string"}},"signers":{"title":"signers","type":"array","description":"The signers who verify the data integrity","items":{"title":"signers","type":"string"}}},"type":"object","additionalProperties":false},"timestamp":{"title":"timestamp","type":"integer","description":"The timestamp for which the data was created"}},"type":"object","additionalProperties":false}},"vol_data":{"title":"vol_data","type":"object","description":"currency -> expiry -> latest vol feed data","additionalProperties":{"title":"vol_data","type":"object","additionalProperties":{"required":["confidence","currency","deadline","expiry","signatures","timestamp","vol_data"],"properties":{"confidence":{"title":"confidence","type":"string","format":"decimal","description":"The confidence score of the price"},"currency":{"title":"currency","type":"string","description":"The currency for which the spot feed represents"},"deadline":{"title":"deadline","type":"integer","description":"The latest time the data can be submitted on chain"},"expiry":{"title":"expiry","type":"integer","description":"The expiry for the options for the vol feed"},"signatures":{"properties":{"signatures":{"title":"signatures","type":"array","description":"The signatures of the given signers","items":{"title":"signatures","type":"string"}},"signers":{"title":"signers","type":"array","description":"The signers who verify the data integrity","items":{"title":"signers","type":"string"}}},"type":"object","additionalProperties":false},"timestamp":{"title":"timestamp","type":"integer","description":"The timestamp for which the data was created"},"vol_data":{"required":["SVI_a","SVI_b","SVI_fwd","SVI_m","SVI_refTau","SVI_rho","SVI_sigma"],"properties":{"SVI_a":{"title":"SVI_a","type":"string","format":"decimal"},"SVI_b":{"title":"SVI_b","type":"string","format":"decimal"},"SVI_fwd":{"title":"SVI_fwd","type":"string","format":"decimal"},"SVI_m":{"title":"SVI_m","type":"string","format":"decimal"},"SVI_refTau":{"title":"SVI_refTau","type":"string","format":"decimal"},"SVI_rho":{"title":"SVI_rho","type":"string","format":"decimal"},"SVI_sigma":{"title":"SVI_sigma","type":"string","format":"decimal"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false}}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetMargin = {"body":{"required":["margin_type","simulated_positions"],"properties":{"margin_type":{"title":"margin_type","type":"string","enum":["PM","SM"],"description":"`PM` (Portfolio Margin) or `SM` (Standard Margin)"},"simulated_position_changes":{"title":"simulated_position_changes","type":["array","null"],"default":null,"description":"Optional, add positions to simulate a trade","items":{"required":["amount","instrument_name"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Position amount to simulate"},"entry_price":{"title":"entry_price","type":["string","null"],"format":"decimal","default":null,"description":"Only for perps. Entry price to use in the simulation. Mark price is used if not provided."},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"}},"type":"object","additionalProperties":false}},"simulated_positions":{"title":"simulated_positions","type":"array","description":"List of positions in a simulated portfolio","items":{"required":["amount","instrument_name"],"properties":{"amount":{"title":"amount","type":"string","format":"decimal","description":"Position amount to simulate"},"entry_price":{"title":"entry_price","type":["string","null"],"format":"decimal","default":null,"description":"Only for perps. Entry price to use in the simulation. Mark price is used if not provided."},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["is_valid_trade","post_initial_margin","post_maintenance_margin","pre_initial_margin","pre_maintenance_margin","subaccount_id"],"properties":{"is_valid_trade":{"title":"is_valid_trade","type":"boolean","description":"True if trade passes margin requirement"},"post_initial_margin":{"title":"post_initial_margin","type":"string","format":"decimal","description":"Initial margin requirement post trade"},"post_maintenance_margin":{"title":"post_maintenance_margin","type":"string","format":"decimal","description":"Maintenance margin requirement post trade"},"pre_initial_margin":{"title":"pre_initial_margin","type":"string","format":"decimal","description":"Initial margin requirement before trade"},"pre_maintenance_margin":{"title":"pre_maintenance_margin","type":"string","format":"decimal","description":"Maintenance margin requirement before trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetSpotFeedHistory = {"body":{"required":["currency","end_timestamp","period","start_timestamp"],"properties":{"currency":{"title":"currency","type":"string","description":"Currency"},"end_timestamp":{"title":"end_timestamp","type":"integer","description":"End timestamp"},"period":{"title":"period","type":"integer","description":"Period"},"start_timestamp":{"title":"start_timestamp","type":"integer","description":"Start timestamp"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["currency","spot_feed_history"],"properties":{"currency":{"title":"currency","type":"string","description":"Currency"},"spot_feed_history":{"title":"spot_feed_history","type":"array","description":"Spot feed history","items":{"required":["confidence","price","timestamp","timestamp_bucket"],"properties":{"confidence":{"title":"confidence","type":"string","format":"decimal","description":"Confidence score of the spot price"},"price":{"title":"price","type":"string","format":"decimal","description":"Spot price"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of when the spot price was recored into the database"},"timestamp_bucket":{"title":"timestamp_bucket","type":"integer","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"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetTicker = {"body":{"required":["instrument_name"],"properties":{"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["amount_step","base_asset_address","base_asset_sub_id","base_currency","base_fee","best_ask_amount","best_ask_price","best_bid_amount","best_bid_price","index_price","instrument_name","instrument_type","is_active","maker_fee_rate","mark_price","max_price","maximum_amount","min_price","minimum_amount","option_details","option_pricing","perp_details","quote_currency","scheduled_activation","scheduled_deactivation","stats","taker_fee_rate","tick_size","timestamp"],"properties":{"amount_step":{"title":"amount_step","type":"string","format":"decimal","description":"Minimum valid increment of order amount"},"base_asset_address":{"title":"base_asset_address","type":"string","description":"Blockchain address of the base asset"},"base_asset_sub_id":{"title":"base_asset_sub_id","type":"string","description":"Sub ID of the specific base asset as defined in Asset.sol"},"base_currency":{"title":"base_currency","type":"string","description":"Underlying currency of base asset (`ETH`, `BTC`, etc)"},"base_fee":{"title":"base_fee","type":"string","format":"decimal","description":"$ base fee added to every taker order"},"best_ask_amount":{"title":"best_ask_amount","type":"string","format":"decimal","description":"Amount of contracts / tokens available at best ask price"},"best_ask_price":{"title":"best_ask_price","type":"string","format":"decimal","description":"Best ask price"},"best_bid_amount":{"title":"best_bid_amount","type":"string","format":"decimal","description":"Amount of contracts / tokens available at best bid price"},"best_bid_price":{"title":"best_bid_price","type":"string","format":"decimal","description":"Best bid price"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Index price"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"instrument_type":{"title":"instrument_type","type":"string","enum":["erc20","option","perp"],"description":"`erc20`, `option`, or `perp`\n\n`erc20` `option` `perp`"},"is_active":{"title":"is_active","type":"boolean","description":"If `True`: instrument is tradeable within `activation` and `deactivation` timestamps"},"maker_fee_rate":{"title":"maker_fee_rate","type":"string","format":"decimal","description":"Percent of spot price fee rate for makers"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price"},"mark_price_fee_rate_cap":{"title":"mark_price_fee_rate_cap","type":["string","null"],"format":"decimal","default":null,"description":"Percent of option price fee cap, e.g. 12.5%, null if not applicable"},"max_price":{"title":"max_price","type":"string","format":"decimal","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)."},"maximum_amount":{"title":"maximum_amount","type":"string","format":"decimal","description":"Maximum valid amount of contracts / tokens per trade"},"min_price":{"title":"min_price","type":"string","format":"decimal","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)."},"minimum_amount":{"title":"minimum_amount","type":"string","format":"decimal","description":"Minimum valid amount of contracts / tokens per trade"},"option_details":{"required":["expiry","index","option_type","strike"],"properties":{"expiry":{"title":"expiry","type":"integer","description":"Unix timestamp of expiry date (in seconds)"},"index":{"title":"index","type":"string","description":"Underlying settlement price index"},"option_type":{"title":"option_type","type":"string","enum":["C","P"],"description":"`C` `P`"},"settlement_price":{"title":"settlement_price","type":["string","null"],"format":"decimal","default":null,"description":"Settlement price of the option"},"strike":{"title":"strike","type":"string","format":"decimal"}},"type":"object","additionalProperties":false},"option_pricing":{"required":["ask_iv","bid_iv","delta","forward_price","gamma","iv","mark_price","rho","theta","vega"],"properties":{"ask_iv":{"title":"ask_iv","type":"string","format":"decimal","description":"Implied volatility of the current best ask"},"bid_iv":{"title":"bid_iv","type":"string","format":"decimal","description":"Implied volatility of the current best bid"},"delta":{"title":"delta","type":"string","format":"decimal","description":"Delta of the option"},"forward_price":{"title":"forward_price","type":"string","format":"decimal","description":"Forward price used to calculate option premium"},"gamma":{"title":"gamma","type":"string","format":"decimal","description":"Gamma of the option"},"iv":{"title":"iv","type":"string","format":"decimal","description":"Implied volatility of the option"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price of the option"},"rho":{"title":"rho","type":"string","format":"decimal","description":"Rho of the option"},"theta":{"title":"theta","type":"string","format":"decimal","description":"Theta of the option"},"vega":{"title":"vega","type":"string","format":"decimal","description":"Vega of the option"}},"type":"object","additionalProperties":false},"perp_details":{"required":["aggregate_funding","funding_rate","index","max_rate_per_hour","min_rate_per_hour","static_interest_rate"],"properties":{"aggregate_funding":{"title":"aggregate_funding","type":"string","format":"decimal","description":"Latest aggregated funding as per `PerpAsset.sol`"},"funding_rate":{"title":"funding_rate","type":"string","format":"decimal","description":"Current hourly funding rate as per `PerpAsset.sol`"},"index":{"title":"index","type":"string","description":"Underlying spot price index for funding rate"},"max_rate_per_hour":{"title":"max_rate_per_hour","type":"string","format":"decimal","description":"Max rate per hour as per `PerpAsset.sol`"},"min_rate_per_hour":{"title":"min_rate_per_hour","type":"string","format":"decimal","description":"Min rate per hour as per `PerpAsset.sol`"},"static_interest_rate":{"title":"static_interest_rate","type":"string","format":"decimal","description":"Static interest rate as per `PerpAsset.sol`"}},"type":"object","additionalProperties":false},"quote_currency":{"title":"quote_currency","type":"string","description":"Quote currency (`USD` for perps, `USDC` for options)"},"scheduled_activation":{"title":"scheduled_activation","type":"integer","description":"Timestamp at which became or will become active (if applicable)"},"scheduled_deactivation":{"title":"scheduled_deactivation","type":"integer","description":"Scheduled deactivation time for instrument (if applicable)"},"stats":{"required":["contract_volume","high","low","num_trades","open_interest","percent_change","usd_change"],"properties":{"contract_volume":{"title":"contract_volume","type":"string","format":"decimal","description":"Number of contracts traded during last 24 hours"},"high":{"title":"high","type":"string","format":"decimal","description":"Highest trade price during last 24h"},"low":{"title":"low","type":"string","format":"decimal","description":"Lowest trade price during last 24h"},"num_trades":{"title":"num_trades","type":"string","format":"decimal","description":"Number of trades during last 24h "},"open_interest":{"title":"open_interest","type":"string","format":"decimal","description":"Current total open interest"},"percent_change":{"title":"percent_change","type":"string","format":"decimal","description":"24-hour price change expressed as a percentage. Options: percent change in vol; Perps: percent change in mark price"},"usd_change":{"title":"usd_change","type":"string","format":"decimal","description":"24-hour price change in USD."}},"type":"object","additionalProperties":false},"taker_fee_rate":{"title":"taker_fee_rate","type":"string","format":"decimal","description":"Percent of spot price fee rate for takers"},"tick_size":{"title":"tick_size","type":"string","format":"decimal","description":"Tick size of the instrument, i.e. minimum price increment"},"timestamp":{"title":"timestamp","type":"integer","description":"Timestamp of the ticker feed snapshot"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetTime = {"body":{"properties":{},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"integer","description":"Current time in milliseconds since UNIX epoch"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetTradeHistory = {"body":{"properties":{"currency":{"title":"currency","type":["string","null"],"default":null,"description":"Currency to filter by (defaults to all)"},"from_timestamp":{"title":"from_timestamp","type":"integer","default":0,"description":"Earliest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to 0."},"instrument_name":{"title":"instrument_name","type":["string","null"],"default":null,"description":"Instrument name to filter by (defaults to all)"},"instrument_type":{"title":"instrument_type","type":["string","null"],"default":null,"enum":["erc20","option","perp"],"description":"Instrument type to filter by (defaults to all)\n\nDefault: `null`"},"page":{"title":"page","type":"integer","default":1,"description":"Page number of results to return (default 1, returns last if above `num_pages`)"},"page_size":{"title":"page_size","type":"integer","default":100,"description":"Number of results per page (default 100, max 1000)"},"to_timestamp":{"title":"to_timestamp","type":"integer","default":18446744073709552000,"description":"Latest timestamp to filter by (in ms since Unix epoch). If not provied, defaults to returning all data up to current time."},"tx_status":{"title":"tx_status","type":"string","default":"settled","enum":["settled","reverted"],"description":"Transaction status to filter by (default `settled`).\n\nDefault: `settled`"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["pagination","trades"],"properties":{"pagination":{"required":["count","num_pages"],"properties":{"count":{"title":"count","type":"integer","description":"Total number of items, across all pages"},"num_pages":{"title":"num_pages","type":"integer","description":"Number of pages"}},"type":"object","additionalProperties":false},"trades":{"title":"trades","type":"array","description":"List of trades","items":{"required":["direction","index_price","instrument_name","liquidity_role","mark_price","subaccount_id","timestamp","trade_amount","trade_fee","trade_id","trade_price","tx_hash","tx_status","wallet"],"properties":{"direction":{"title":"direction","type":"string","enum":["buy","sell"],"description":"Order direction\n\n`buy` `sell`"},"index_price":{"title":"index_price","type":"string","format":"decimal","description":"Index price of the underlying at the time of the trade"},"instrument_name":{"title":"instrument_name","type":"string","description":"Instrument name"},"liquidity_role":{"title":"liquidity_role","type":"string","enum":["maker","taker"],"description":"Role of the user in the trade\n\n`maker` `taker`"},"mark_price":{"title":"mark_price","type":"string","format":"decimal","description":"Mark price of the instrument at the time of the trade"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID"},"timestamp":{"title":"timestamp","type":"integer","description":"Trade timestamp (in ms since Unix epoch)"},"trade_amount":{"title":"trade_amount","type":"string","format":"decimal","description":"Amount filled in this trade"},"trade_fee":{"title":"trade_fee","type":"string","format":"decimal","description":"Fee for this trade"},"trade_id":{"title":"trade_id","type":"string","description":"Trade ID"},"trade_price":{"title":"trade_price","type":"string","format":"decimal","description":"Price at which the trade was filled"},"tx_hash":{"title":"tx_hash","type":"string","description":"Blockchain transaction hash"},"tx_status":{"title":"tx_status","type":"string","enum":["settled","reverted"],"description":"Blockchain transaction status\n\n`settled` `reverted`"},"wallet":{"title":"wallet","type":"string","description":"Wallet address (owner) of the subaccount"}},"type":"object","additionalProperties":false}}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicGetTransaction = {"body":{"required":["transaction_id"],"properties":{"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"transaction_id of the transaction to get"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["status","transaction_hash"],"properties":{"status":{"title":"status","type":"string","enum":["requested","pending","settled","reverted","ignored"],"description":"Status of the transaction\n\n`requested` `pending` `settled` `reverted` `ignored`"},"transaction_hash":{"title":"transaction_hash","type":["string","null"],"default":null,"description":"Transaction hash of a pending tx"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicLogin = {"body":{"required":["signature","timestamp","wallet"],"properties":{"signature":{"title":"signature","type":"string","description":"Signature of the timestamp, signed with the wallet's private key or a session key"},"timestamp":{"title":"timestamp","type":"string","description":"Message that was signed, in the form of a timestamp in ms since Unix epoch"},"wallet":{"title":"wallet","type":"string","description":"Public key (wallet) of the account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"title":"result","type":"array","description":"List of subaccount IDs that have been authenticated","items":{"title":"result","type":"integer"}}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicMarginWatch = {"body":{"required":["subaccount_id"],"properties":{"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount ID to get margin for."}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["currency","maintenance_margin","margin_type","subaccount_id","subaccount_value","valuation_timestamp"],"properties":{"currency":{"title":"currency","type":"string","description":"Currency of subaccount"},"maintenance_margin":{"title":"maintenance_margin","type":"string","format":"decimal","description":"Total maintenance margin requirement of all positions and collaterals.If this value falls below zero, the subaccount will be flagged for liquidation."},"margin_type":{"title":"margin_type","type":"string","enum":["PM","SM"],"description":"Margin type of subaccount (`PM` (Portfolio Margin) or `SM` (Standard Margin))\n\n`PM` `SM`"},"subaccount_id":{"title":"subaccount_id","type":"integer","description":"Subaccount_id"},"subaccount_value":{"title":"subaccount_value","type":"string","format":"decimal","description":"Total mark-to-market value of all positions and collaterals"},"valuation_timestamp":{"title":"valuation_timestamp","type":"integer","description":"Timestamp (in seconds since epoch) of when margin and MtM were computed."}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +const PostPublicRegisterSessionKey = {"body":{"required":["expiry_sec","label","public_session_key","signed_raw_tx","wallet"],"properties":{"expiry_sec":{"title":"expiry_sec","type":"integer","description":"Expiry of the session key"},"label":{"title":"label","type":"string","description":"Ethereum wallet address"},"public_session_key":{"title":"public_session_key","type":"string","description":"Session key in the form of an Ethereum EOA"},"signed_raw_tx":{"title":"signed_raw_tx","type":"string","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()`)"},"wallet":{"title":"wallet","type":"string","description":"Ethereum wallet address of account"}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"},"response":{"200":{"required":["id","result"],"properties":{"id":{"anyOf":[{"title":"","type":"string"},{"title":"","type":"integer"}]},"result":{"required":["label","public_session_key","transaction_id"],"properties":{"label":{"title":"label","type":"string","description":"User-defined session key label"},"public_session_key":{"title":"public_session_key","type":"string","description":"Session key in the form of an Ethereum EOA"},"transaction_id":{"title":"transaction_id","type":"string","format":"uuid","description":"ID to lookup status of transaction"}},"type":"object","additionalProperties":false}},"type":"object","additionalProperties":false,"$schema":"http://json-schema.org/draft-04/schema#"}}} as const +; +export { PostPrivateCancel, PostPrivateCancelAll, PostPrivateCancelByInstrument, PostPrivateCancelByLabel, PostPrivateCancelByNonce, PostPrivateChangeSessionKeyLabel, PostPrivateChangeSubaccountLabel, PostPrivateCreateSubaccount, PostPrivateDeposit, PostPrivateExpiredAndCancelledHistory, PostPrivateGetAccount, PostPrivateGetCollaterals, PostPrivateGetDepositHistory, PostPrivateGetErc20TransferHistory, PostPrivateGetFundingHistory, PostPrivateGetInterestHistory, PostPrivateGetLiquidationHistory, PostPrivateGetMargin, PostPrivateGetMmpConfig, PostPrivateGetNotifications, PostPrivateGetOpenOrders, PostPrivateGetOptionSettlementHistory, PostPrivateGetOrder, PostPrivateGetOrderHistory, PostPrivateGetOrders, PostPrivateGetPositions, PostPrivateGetSubaccount, PostPrivateGetSubaccountValueHistory, PostPrivateGetSubaccounts, PostPrivateGetTradeHistory, PostPrivateGetWithdrawalHistory, PostPrivateOrder, PostPrivateOrderDebug, PostPrivateResetMmp, PostPrivateSessionKeys, PostPrivateSetCancelOnDisconnect, PostPrivateSetMmpConfig, PostPrivateTransferErc20, PostPrivateTransferPosition, PostPrivateUpdateNotifications, PostPrivateWithdraw, PostPublicBuildRegisterSessionKeyTx, PostPublicCreateAccount, PostPublicCreateSubaccountDebug, PostPublicDeregisterSessionKey, PostPublicGetInstrument, PostPublicGetInstruments, PostPublicGetLatestSignedFeeds, PostPublicGetMargin, PostPublicGetSpotFeedHistory, PostPublicGetTicker, PostPublicGetTime, PostPublicGetTradeHistory, PostPublicGetTransaction, PostPublicLogin, PostPublicMarginWatch, PostPublicRegisterSessionKey } diff --git a/app/src/api/types.ts b/app/src/api/types.ts new file mode 100644 index 0000000..6c650b4 --- /dev/null +++ b/app/src/api/types.ts @@ -0,0 +1,117 @@ +import type { FromSchema } from 'json-schema-to-ts'; +import * as schemas from './schemas'; + +export type PostPrivateCancelAllBodyParam = FromSchema; +export type PostPrivateCancelAllResponse200 = FromSchema; +export type PostPrivateCancelBodyParam = FromSchema; +export type PostPrivateCancelByInstrumentBodyParam = FromSchema; +export type PostPrivateCancelByInstrumentResponse200 = FromSchema; +export type PostPrivateCancelByLabelBodyParam = FromSchema; +export type PostPrivateCancelByLabelResponse200 = FromSchema; +export type PostPrivateCancelByNonceBodyParam = FromSchema; +export type PostPrivateCancelByNonceResponse200 = FromSchema; +export type PostPrivateCancelResponse200 = FromSchema; +export type PostPrivateChangeSessionKeyLabelBodyParam = FromSchema; +export type PostPrivateChangeSessionKeyLabelResponse200 = FromSchema; +export type PostPrivateChangeSubaccountLabelBodyParam = FromSchema; +export type PostPrivateChangeSubaccountLabelResponse200 = FromSchema; +export type PostPrivateCreateSubaccountBodyParam = FromSchema; +export type PostPrivateCreateSubaccountResponse200 = FromSchema; +export type PostPrivateDepositBodyParam = FromSchema; +export type PostPrivateDepositResponse200 = FromSchema; +export type PostPrivateExpiredAndCancelledHistoryBodyParam = FromSchema; +export type PostPrivateExpiredAndCancelledHistoryResponse200 = FromSchema; +export type PostPrivateGetAccountBodyParam = FromSchema; +export type PostPrivateGetAccountResponse200 = FromSchema; +export type PostPrivateGetCollateralsBodyParam = FromSchema; +export type PostPrivateGetCollateralsResponse200 = FromSchema; +export type PostPrivateGetDepositHistoryBodyParam = FromSchema; +export type PostPrivateGetDepositHistoryResponse200 = FromSchema; +export type PostPrivateGetErc20TransferHistoryBodyParam = FromSchema; +export type PostPrivateGetErc20TransferHistoryResponse200 = FromSchema; +export type PostPrivateGetFundingHistoryBodyParam = FromSchema; +export type PostPrivateGetFundingHistoryResponse200 = FromSchema; +export type PostPrivateGetInterestHistoryBodyParam = FromSchema; +export type PostPrivateGetInterestHistoryResponse200 = FromSchema; +export type PostPrivateGetLiquidationHistoryBodyParam = FromSchema; +export type PostPrivateGetLiquidationHistoryResponse200 = FromSchema; +export type PostPrivateGetMarginBodyParam = FromSchema; +export type PostPrivateGetMarginResponse200 = FromSchema; +export type PostPrivateGetMmpConfigBodyParam = FromSchema; +export type PostPrivateGetMmpConfigResponse200 = FromSchema; +export type PostPrivateGetNotificationsBodyParam = FromSchema; +export type PostPrivateGetNotificationsResponse200 = FromSchema; +export type PostPrivateGetOpenOrdersBodyParam = FromSchema; +export type PostPrivateGetOpenOrdersResponse200 = FromSchema; +export type PostPrivateGetOptionSettlementHistoryBodyParam = FromSchema; +export type PostPrivateGetOptionSettlementHistoryResponse200 = FromSchema; +export type PostPrivateGetOrderBodyParam = FromSchema; +export type PostPrivateGetOrderHistoryBodyParam = FromSchema; +export type PostPrivateGetOrderHistoryResponse200 = FromSchema; +export type PostPrivateGetOrderResponse200 = FromSchema; +export type PostPrivateGetOrdersBodyParam = FromSchema; +export type PostPrivateGetOrdersResponse200 = FromSchema; +export type PostPrivateGetPositionsBodyParam = FromSchema; +export type PostPrivateGetPositionsResponse200 = FromSchema; +export type PostPrivateGetSubaccountBodyParam = FromSchema; +export type PostPrivateGetSubaccountResponse200 = FromSchema; +export type PostPrivateGetSubaccountValueHistoryBodyParam = FromSchema; +export type PostPrivateGetSubaccountValueHistoryResponse200 = FromSchema; +export type PostPrivateGetSubaccountsBodyParam = FromSchema; +export type PostPrivateGetSubaccountsResponse200 = FromSchema; +export type PostPrivateGetTradeHistoryBodyParam = FromSchema; +export type PostPrivateGetTradeHistoryResponse200 = FromSchema; +export type PostPrivateGetWithdrawalHistoryBodyParam = FromSchema; +export type PostPrivateGetWithdrawalHistoryResponse200 = FromSchema; +export type PostPrivateOrderBodyParam = FromSchema; +export type PostPrivateOrderDebugBodyParam = FromSchema; +export type PostPrivateOrderDebugResponse200 = FromSchema; +export type PostPrivateOrderResponse200 = FromSchema; +export type PostPrivateResetMmpBodyParam = FromSchema; +export type PostPrivateResetMmpResponse200 = FromSchema; +export type PostPrivateSessionKeysBodyParam = FromSchema; +export type PostPrivateSessionKeysResponse200 = FromSchema; +export type PostPrivateSetCancelOnDisconnectBodyParam = FromSchema; +export type PostPrivateSetCancelOnDisconnectResponse200 = FromSchema; +export type PostPrivateSetMmpConfigBodyParam = FromSchema; +export type PostPrivateSetMmpConfigResponse200 = FromSchema; +export type PostPrivateTransferErc20BodyParam = FromSchema; +export type PostPrivateTransferErc20Response200 = FromSchema; +export type PostPrivateTransferPositionBodyParam = FromSchema; +export type PostPrivateTransferPositionResponse200 = FromSchema; +export type PostPrivateUpdateNotificationsBodyParam = FromSchema; +export type PostPrivateUpdateNotificationsResponse200 = FromSchema; +export type PostPrivateWithdrawBodyParam = FromSchema; +export type PostPrivateWithdrawResponse200 = FromSchema; +export type PostPublicBuildRegisterSessionKeyTxBodyParam = FromSchema; +export type PostPublicBuildRegisterSessionKeyTxResponse200 = FromSchema; +export type PostPublicCreateAccountBodyParam = FromSchema; +export type PostPublicCreateAccountResponse200 = FromSchema; +export type PostPublicCreateSubaccountDebugBodyParam = FromSchema; +export type PostPublicCreateSubaccountDebugResponse200 = FromSchema; +export type PostPublicDeregisterSessionKeyBodyParam = FromSchema; +export type PostPublicDeregisterSessionKeyResponse200 = FromSchema; +export type PostPublicGetInstrumentBodyParam = FromSchema; +export type PostPublicGetInstrumentResponse200 = FromSchema; +export type PostPublicGetInstrumentsBodyParam = FromSchema; +export type PostPublicGetInstrumentsResponse200 = FromSchema; +export type PostPublicGetLatestSignedFeedsBodyParam = FromSchema; +export type PostPublicGetLatestSignedFeedsResponse200 = FromSchema; +export type PostPublicGetMarginBodyParam = FromSchema; +export type PostPublicGetMarginResponse200 = FromSchema; +export type PostPublicGetSpotFeedHistoryBodyParam = FromSchema; +export type PostPublicGetSpotFeedHistoryResponse200 = FromSchema; +export type PostPublicGetTickerBodyParam = FromSchema; +export type PostPublicGetTickerResponse200 = FromSchema; +export type PostPublicGetTimeBodyParam = FromSchema; +export type PostPublicGetTimeResponse200 = FromSchema; +export type PostPublicGetTradeHistoryBodyParam = FromSchema; +export type PostPublicGetTradeHistoryResponse200 = FromSchema; +export type PostPublicGetTransactionBodyParam = FromSchema; +export type PostPublicGetTransactionResponse200 = FromSchema; +export type PostPublicLoginBodyParam = FromSchema; +export type PostPublicLoginResponse200 = FromSchema; +export type PostPublicMarginWatchBodyParam = FromSchema; +export type PostPublicMarginWatchResponse200 = FromSchema; +export type PostPublicRegisterSessionKeyBodyParam = FromSchema; +export type PostPublicRegisterSessionKeyResponse200 = FromSchema; diff --git a/app/src/bot.ts b/app/src/bot.ts index 702bce7..3b420ba 100644 --- a/app/src/bot.ts +++ b/app/src/bot.ts @@ -1,5 +1,4 @@ -import { RunTradeBot } from './lyra/trades' -import { FetchLeaderBoard } from './lyra/leaderboard' +import { RunTradeBot } from './lyra/tradesv2' import { DISCORD_ACCESS_TOKEN_ARB, DISCORD_ACCESS_TOKEN_BTC, @@ -16,12 +15,9 @@ import { TwitterApi } from 'twitter-api-v2' import { Telegraf } from 'telegraf' import { TwitterClient, TwitterClient1 } from './clients/twitterClient' import { TelegramClient } from './clients/telegramClient' -import { Network } from '@lyrafinance/lyra-js' import { GetPrices } from './integrations/prices' -import { TrackEvents } from './event/blockEvent' -import { ArbitrageJob, LeaderBoardFillJob, LeaderboardSendJob, OneMinuteJob, StatsJob } from './schedule' +import { OneMinuteJob } from './schedule' import { SetUpDiscord } from './discord' -import getLyraSDK from './utils/getLyraSDK' let discordClientEth: Client let discordClientBtc: Client @@ -33,8 +29,6 @@ let twitterClient: TwitterApi let twitterClient1: TwitterApi let telegramClient: Telegraf -const networks = [Network.Arbitrum, Network.Optimism] // Network.Arbitrum] - export async function Run() { InitVariables() @@ -50,36 +44,32 @@ export async function Run() { SetUpDiscord((discordClientLyra = DiscordClient()), 'lyra', DISCORD_ACCESS_TOKEN_LYRA), SetUpTwitter(), SetUpTelegram(), - FetchLeaderBoard(), + //FetchLeaderBoard(), ]) //listen to events - networks.map(async (network) => { - await runBot(network) - }) + + await runBot() + OneMinuteJob(discordClientEth, discordClientBtc, discordClientOp, discordClientArb, discordClientLyra) // periodic jobs if (!TESTNET) { - LeaderBoardFillJob() - LeaderboardSendJob(discordClientLyra, twitterClient, telegramClient, networks) - StatsJob(discordClientLyra, twitterClient, telegramClient, networks) - ArbitrageJob(discordClientLyra, twitterClient, telegramClient, networks) + // LeaderBoardFillJob() + // LeaderboardSendJob(discordClientLyra, twitterClient, telegramClient, networks) + // StatsJob(discordClientLyra, twitterClient, telegramClient, networks) + // ArbitrageJob(discordClientLyra, twitterClient, telegramClient, networks) } } function InitVariables() { global.LYRA_ENS = {} - global.LEADERBOARD_OPT = [] - global.LEADERBOARD_ARB = [] global.PRICES = [] global.FREN = {} - global.LYRA_ARB = getLyraSDK(Network.Arbitrum) - global.LYRA_OPT = getLyraSDK(Network.Optimism) } -export async function runBot(network: Network) { - await RunTradeBot(discordClientLyra, twitterClient, telegramClient, network) - await TrackEvents(discordClientLyra, telegramClient, twitterClient, twitterClient1, network) +export async function runBot() { + await RunTradeBot(discordClientLyra, twitterClient, telegramClient) + //await TrackEvents(discordClientLyra, telegramClient, twitterClient, twitterClient1, network) } export async function SetUpTwitter() { diff --git a/app/src/constants/networks.ts b/app/src/constants/networks.ts deleted file mode 100644 index e679844..0000000 --- a/app/src/constants/networks.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Chain, Network } from '@lyrafinance/lyra-js' -import { - ALCHEMY_PROJECT_ID_ARBITRUM, - ALCHEMY_PROJECT_ID_ARBITRUM_TESTNET, - ALCHEMY_PROJECT_ID_OPTIMISM, - ALCHEMY_PROJECT_ID_OPTIMISM_TESTNET, -} from '../config' - -export enum WalletType { - MetaMask = 'MetaMask', - WalletConnect = 'WalletConnect', - CoinbaseWallet = 'CoinbaseWallet', - GnosisSafe = 'GnosisSafe', -} - -export type NetworkConfig = { - name: string - shortName: string - chainId: number - network: Network - walletRpcUrl: string - readRpcUrls: string[] - blockExplorerUrl: string - iconUrls: string[] -} - -export const NETWORK_CONFIGS: Record = { - [Chain.Optimism]: { - name: 'Optimistic Ethereum', - shortName: 'Optimism', - chainId: 10, - network: Network.Optimism, - walletRpcUrl: 'https://mainnet.optimism.io', - readRpcUrls: [`https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_PROJECT_ID_OPTIMISM}`], - blockExplorerUrl: 'https://optimistic.etherscan.io', - iconUrls: ['https://optimism.io/images/metamask_icon.svg', 'https://optimism.io/images/metamask_icon.png'], - }, - [Chain.OptimismGoerli]: { - name: 'Optimistic Ethereum (Goerli)', - shortName: 'Optimistic Goerli', - chainId: 420, - network: Network.Optimism, - walletRpcUrl: 'https://goerli.optimism.io', - readRpcUrls: [`https://opt-goerli.g.alchemy.com/v2/${ALCHEMY_PROJECT_ID_OPTIMISM_TESTNET}`], - blockExplorerUrl: 'https://goerli-optimism.etherscan.io/', - iconUrls: ['https://optimism.io/images/metamask_icon.svg', 'https://optimism.io/images/metamask_icon.png'], - }, - [Chain.Arbitrum]: { - name: 'Arbitrum One', - shortName: 'Arbitrum', - chainId: 42161, - network: Network.Arbitrum, - walletRpcUrl: 'https://arb1.arbitrum.io/rpc', - readRpcUrls: [`https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_PROJECT_ID_ARBITRUM}`], - blockExplorerUrl: 'https://arbiscan.io/', - iconUrls: ['https://optimism.io/images/metamask_icon.svg', 'https://optimism.io/images/metamask_icon.png'], - }, - [Chain.ArbitrumGoerli]: { - name: 'Arbitrum Nitro Goerli Rollup Testnet', - shortName: 'Arbitrum Goerli', - chainId: 421613, - network: Network.Arbitrum, - walletRpcUrl: 'https://goerli-rollup.arbitrum.io/rpc', - readRpcUrls: [`https://arb-goerli.g.alchemy.com/v2/${ALCHEMY_PROJECT_ID_ARBITRUM_TESTNET}`], - blockExplorerUrl: 'https://goerli.arbiscan.io/', - iconUrls: ['https://optimism.io/images/metamask_icon.svg', 'https://optimism.io/images/metamask_icon.png'], - }, -} diff --git a/app/src/discord/index.ts b/app/src/discord/index.ts index b27aafc..f1603e7 100644 --- a/app/src/discord/index.ts +++ b/app/src/discord/index.ts @@ -1,32 +1,11 @@ -import { GetLeaderBoard, ParsePositionLeaderboard } from '../lyra/leaderboard' import { DISCORD_ENABLED, TESTNET } from '../config' -import { - ActionRowBuilder, - ActivityType, - ButtonBuilder, - EmbedBuilder, - ChatInputCommandInteraction, - Client, - GuildBasedChannel, - TextChannel, -} from 'discord.js' -import { Network } from '@lyrafinance/lyra-js' -import { LeaderboardDiscord } from '../templates/leaderboard' -import { GetStats } from '../lyra/stats' -import { StatDiscord } from '../templates/stats' -import { ARBS_CHANNEL, STATS_CHANNEL, TRADE_CHANNEL } from '../constants/discordChannels' -import { HelpDiscord } from '../templates/help' -import { GetArbitrageDeals } from '../lyra/arbitrage' -import { ArbDiscord } from '../templates/arb' -import { GetTrader } from '../lyra/trader' -import { TraderDiscord } from '../templates/trader' +import { ActionRowBuilder, ActivityType, ButtonBuilder, EmbedBuilder, Client, TextChannel } from 'discord.js' import {} from 'discord.js' import printObject from '../utils/printObject' import formatNumber from '../utils/formatNumber' import { Pair } from '../types/dexscreener' import { ARB_OP, BTC_OP, ETH_OP, LYRA_OP, OP_OP } from '../constants/contractAddresses' import { GetPrices } from '../integrations/prices' -import { titleCaseWord } from '../utils/utils' export async function SetUpDiscord( discordClient: Client, @@ -63,158 +42,158 @@ export async function SetUpDiscord( } }) - discordClient.on('interactionCreate', async (interaction) => { - if (!interaction.isCommand()) { - return - } - const tradeChannel = interaction?.guild?.channels.cache.find((channel) => channel.name === TRADE_CHANNEL) - const statsChannel = interaction?.guild?.channels.cache.find((channel) => channel.name === STATS_CHANNEL) - const arbChannel = interaction?.guild?.channels?.cache?.find((channel) => channel.name === ARBS_CHANNEL) - const channelName = (interaction?.channel as TextChannel).name - const { commandName } = interaction - - if (market == 'lyra') { - if (commandName === 'leaderboard') { - await LeaderBoardInteraction( - channelName, - interaction as ChatInputCommandInteraction, - tradeChannel as GuildBasedChannel, - 10, - commandName, - ) - } - if (commandName === 'top30') { - await LeaderBoardInteraction( - channelName, - interaction as ChatInputCommandInteraction, - tradeChannel as GuildBasedChannel, - 30, - commandName, - ) - } - if (commandName === 'help') { - if (channelName === STATS_CHANNEL || channelName === TRADE_CHANNEL) { - const help = HelpDiscord() - await interaction.reply(help) - } else { - await interaction.reply( - `Command 'help' only available in <#${statsChannel?.id}> or <#${tradeChannel?.id}> `, - ) - } - } - if (commandName === 'trader') { - await TraderInteraction( - channelName, - interaction as ChatInputCommandInteraction, - tradeChannel as GuildBasedChannel, - ) - } - if (commandName === 'arbs') { - await ArbInteraction(channelName, interaction as ChatInputCommandInteraction, arbChannel as GuildBasedChannel) - } - if (commandName === 'stats') { - await StatsInteraction( - channelName, - interaction as ChatInputCommandInteraction, - statsChannel as GuildBasedChannel, - ) - } - } - }) + // discordClient.on('interactionCreate', async (interaction) => { + // if (!interaction.isCommand()) { + // return + // } + // const tradeChannel = interaction?.guild?.channels.cache.find((channel) => channel.name === TRADE_CHANNEL) + // const statsChannel = interaction?.guild?.channels.cache.find((channel) => channel.name === STATS_CHANNEL) + // const arbChannel = interaction?.guild?.channels?.cache?.find((channel) => channel.name === ARBS_CHANNEL) + // const channelName = (interaction?.channel as TextChannel).name + // const { commandName } = interaction + + // if (market == 'lyra') { + // if (commandName === 'leaderboard') { + // await LeaderBoardInteraction( + // channelName, + // interaction as ChatInputCommandInteraction, + // tradeChannel as GuildBasedChannel, + // 10, + // commandName, + // ) + // } + // if (commandName === 'top30') { + // await LeaderBoardInteraction( + // channelName, + // interaction as ChatInputCommandInteraction, + // tradeChannel as GuildBasedChannel, + // 30, + // commandName, + // ) + // } + // if (commandName === 'help') { + // if (channelName === STATS_CHANNEL || channelName === TRADE_CHANNEL) { + // const help = HelpDiscord() + // await interaction.reply(help) + // } else { + // await interaction.reply( + // `Command 'help' only available in <#${statsChannel?.id}> or <#${tradeChannel?.id}> `, + // ) + // } + // } + // if (commandName === 'trader') { + // await TraderInteraction( + // channelName, + // interaction as ChatInputCommandInteraction, + // tradeChannel as GuildBasedChannel, + // ) + // } + // if (commandName === 'arbs') { + // await ArbInteraction(channelName, interaction as ChatInputCommandInteraction, arbChannel as GuildBasedChannel) + // } + // if (commandName === 'stats') { + // await StatsInteraction( + // channelName, + // interaction as ChatInputCommandInteraction, + // statsChannel as GuildBasedChannel, + // ) + // } + // } + // }) await discordClient.login(accessToken) } return discordClient } -async function LeaderBoardInteraction( - channelName: string, - interaction: ChatInputCommandInteraction, - channel: GuildBasedChannel, - take: number, - commandName: string, -) { - if (channelName === TRADE_CHANNEL) { - await interaction.deferReply() - const network = interaction.options.getString('chain') as Network - const leaderBoard = await GetLeaderBoard(network) - const traders = await Promise.all( - leaderBoard.slice(0, take).map(async (x, index) => await ParsePositionLeaderboard(x, index + 1)), - ) - const embeds = LeaderboardDiscord(traders, network) - await interaction.editReply({ embeds: embeds }) - } else { - await interaction.reply(`Command ${commandName} only available in <#${channel?.id}>`) - } -} - -async function StatsInteraction( - channelName: string, - interaction: ChatInputCommandInteraction, - channel: GuildBasedChannel, -) { - if (channelName === STATS_CHANNEL) { - await interaction.deferReply() - const network = interaction.options.getString('chain') as Network - const market = interaction.options.getString('market') as string - - if (network == Network.Arbitrum) { - if (market == 'op' || market == 'arb') { - await interaction.editReply(`${market.toUpperCase()} not available on ${titleCaseWord(Network.Arbitrum)}`) - return - } - } - - const statsDto = await GetStats(market, network) - const stats = StatDiscord(statsDto, network) - await interaction.editReply({ embeds: stats }) - } else { - await interaction.reply(`Command 'stats' only available in <#${channel?.id}>`) - } -} - -async function ArbInteraction( - channelName: string, - interaction: ChatInputCommandInteraction, - channel: GuildBasedChannel, -) { - if (channelName === ARBS_CHANNEL) { - await interaction.deferReply() - const network = interaction.options.getString('chain') as Network - const market = interaction.options.getString('market') as string - - const arbs = await GetArbitrageDeals(market, network) - if (arbs.arbs.length > 0) { - const { embeds, rows } = ArbDiscord(arbs, network) - await interaction.editReply({ embeds: embeds, components: rows }) - } else { - await interaction.editReply(`No ${market} arbs found on ${network}.`) - } - } else { - await interaction.reply(`Command 'arbs' only available in <#${channel?.id}>`) - } -} - -async function TraderInteraction( - channelName: string, - interaction: ChatInputCommandInteraction, - channel: GuildBasedChannel, -) { - if (channelName === TRADE_CHANNEL) { - await interaction.deferReply() - const account = interaction.options.getString('account') as string - // todo support both networks - const trader = await GetTrader(account, Network.Optimism) - if (trader.account != '') { - const embed = TraderDiscord(trader) - await interaction.editReply({ embeds: embed }) - } else { - await interaction.editReply(`No trader '${account}' found.`) - } - } else { - await interaction.reply(`Command 'trader' only available in <#${channel?.id}>`) - } -} +// async function LeaderBoardInteraction( +// channelName: string, +// interaction: ChatInputCommandInteraction, +// channel: GuildBasedChannel, +// take: number, +// commandName: string, +// ) { +// if (channelName === TRADE_CHANNEL) { +// await interaction.deferReply() +// const network = interaction.options.getString('chain') as Network +// const leaderBoard = await GetLeaderBoard(network) +// const traders = await Promise.all( +// leaderBoard.slice(0, take).map(async (x, index) => await ParsePositionLeaderboard(x, index + 1)), +// ) +// const embeds = LeaderboardDiscord(traders, network) +// await interaction.editReply({ embeds: embeds }) +// } else { +// await interaction.reply(`Command ${commandName} only available in <#${channel?.id}>`) +// } +// } + +// async function StatsInteraction( +// channelName: string, +// interaction: ChatInputCommandInteraction, +// channel: GuildBasedChannel, +// ) { +// if (channelName === STATS_CHANNEL) { +// await interaction.deferReply() +// const network = interaction.options.getString('chain') as Network +// const market = interaction.options.getString('market') as string + +// if (network == Network.Arbitrum) { +// if (market == 'op' || market == 'arb') { +// await interaction.editReply(`${market.toUpperCase()} not available on ${titleCaseWord(Network.Arbitrum)}`) +// return +// } +// } + +// const statsDto = await GetStats(market, network) +// const stats = StatDiscord(statsDto, network) +// await interaction.editReply({ embeds: stats }) +// } else { +// await interaction.reply(`Command 'stats' only available in <#${channel?.id}>`) +// } +// } + +// async function ArbInteraction( +// channelName: string, +// interaction: ChatInputCommandInteraction, +// channel: GuildBasedChannel, +// ) { +// if (channelName === ARBS_CHANNEL) { +// await interaction.deferReply() +// const network = interaction.options.getString('chain') as Network +// const market = interaction.options.getString('market') as string + +// const arbs = await GetArbitrageDeals(market, network) +// if (arbs.arbs.length > 0) { +// const { embeds, rows } = ArbDiscord(arbs, network) +// await interaction.editReply({ embeds: embeds, components: rows }) +// } else { +// await interaction.editReply(`No ${market} arbs found on ${network}.`) +// } +// } else { +// await interaction.reply(`Command 'arbs' only available in <#${channel?.id}>`) +// } +// } + +// async function TraderInteraction( +// channelName: string, +// interaction: ChatInputCommandInteraction, +// channel: GuildBasedChannel, +// ) { +// if (channelName === TRADE_CHANNEL) { +// await interaction.deferReply() +// const account = interaction.options.getString('account') as string +// // todo support both networks +// const trader = await GetTrader(account, Network.Optimism) +// if (trader.account != '') { +// const embed = TraderDiscord(trader) +// await interaction.editReply({ embeds: embed }) +// } else { +// await interaction.editReply(`No trader '${account}' found.`) +// } +// } else { +// await interaction.reply(`Command 'trader' only available in <#${channel?.id}>`) +// } +// } export async function PostDiscord( embed: EmbedBuilder[], diff --git a/app/src/event/blockEvent.ts b/app/src/event/blockEvent.ts index d7d8f64..9027285 100644 --- a/app/src/event/blockEvent.ts +++ b/app/src/event/blockEvent.ts @@ -1,50 +1,44 @@ import { TESTNET } from '../config' import { Client } from 'discord.js' -import { BlockEvent } from '../event' import { Telegraf } from 'telegraf' import { TwitterApi } from 'twitter-api-v2' import { DEPOSIT_PROCESSED, STRIKE_ADDED, TRANSFER_TOPIC } from '../constants/topics' import { CONTRACT_ADDRESSES } from '../constants/contractAddresses' -import { Network } from '@lyrafinance/lyra-js' -import { TrackTransfer } from '../lyra/tracker' -import { TrackDeposits } from '../lyra/deposits' -import getLyraSDK from '../utils/getLyraSDK' -import { TrackStrikeAdded } from '../lyra/expiries' -export async function TrackEvents( - discordClient: Client, - telegramClient: Telegraf, - twitterClient: TwitterApi, - twitterClient1: TwitterApi, - network: Network, -): Promise { - console.log('### Polling for Events - Deposits | Transfers | Strikes ###') - const lyra = getLyraSDK(network) - let blockNumber: number | undefined = undefined - let pollInterval = 60000 - if (TESTNET) { - blockNumber = lyra.provider.blockNumber - 5000 - pollInterval = 3000 - } +// export async function TrackEvents( +// discordClient: Client, +// telegramClient: Telegraf, +// twitterClient: TwitterApi, +// twitterClient1: TwitterApi, +// network: Network, +// ): Promise { +// console.log('### Polling for Events - Deposits | Transfers | Strikes ###') +// const lyra = getLyraSDK(network) +// let blockNumber: number | undefined = undefined +// let pollInterval = 60000 +// if (TESTNET) { +// blockNumber = lyra.provider.blockNumber - 5000 +// pollInterval = 3000 +// } - BlockEvent.on( - lyra, - async (event) => { - if (event[0].topics[0].toLowerCase() === TRANSFER_TOPIC.toLowerCase()) { - await TrackTransfer(discordClient, twitterClient1, event[0], network) - } - if (event[0].topics[0].toLowerCase() === DEPOSIT_PROCESSED.toLowerCase()) { - await TrackDeposits(discordClient, twitterClient1, event[0], network) - } - if (event[0].topics[0].toLowerCase() === STRIKE_ADDED.toLowerCase()) { - await TrackStrikeAdded(discordClient, telegramClient, twitterClient, network, event) - } - }, - { - startBlockNumber: blockNumber, - addresses: CONTRACT_ADDRESSES, - topics: [STRIKE_ADDED, DEPOSIT_PROCESSED, TRANSFER_TOPIC], //STRIKE_ADDED, ,DEPOSIT_PROCESSED //TRANSFER_TOPIC - pollInterval: pollInterval, - }, - ) -} +// BlockEvent.on( +// lyra, +// async (event) => { +// if (event[0].topics[0].toLowerCase() === TRANSFER_TOPIC.toLowerCase()) { +// await TrackTransfer(discordClient, twitterClient1, event[0], network) +// } +// if (event[0].topics[0].toLowerCase() === DEPOSIT_PROCESSED.toLowerCase()) { +// await TrackDeposits(discordClient, twitterClient1, event[0], network) +// } +// if (event[0].topics[0].toLowerCase() === STRIKE_ADDED.toLowerCase()) { +// await TrackStrikeAdded(discordClient, telegramClient, twitterClient, network, event) +// } +// }, +// { +// startBlockNumber: blockNumber, +// addresses: CONTRACT_ADDRESSES, +// topics: [STRIKE_ADDED, DEPOSIT_PROCESSED, TRANSFER_TOPIC], //STRIKE_ADDED, ,DEPOSIT_PROCESSED //TRANSFER_TOPIC +// pollInterval: pollInterval, +// }, +// ) +// } diff --git a/app/src/event/broadcast.ts b/app/src/event/broadcast.ts index 076be9b..53fe71b 100644 --- a/app/src/event/broadcast.ts +++ b/app/src/event/broadcast.ts @@ -1,4 +1,3 @@ -import { Network } from '@lyrafinance/lyra-js' import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, Client, EmbedBuilder } from 'discord.js' import { Telegraf } from 'telegraf' import { TwitterApi } from 'twitter-api-v2' @@ -8,64 +7,63 @@ import { PostDiscord } from '..//discord' import { PostTelegram } from '../integrations/telegram' import { SendTweet } from '../integrations/twitter' import { TWITTER_ENABLED, TESTNET, DISCORD_ENABLED, TELEGRAM_ENABLED } from '../config' -import { ArbDiscord, ArbTelegram, ArbTwitter } from '../templates/arb' -import { ArbDto, BaseEvent } from '../types/lyra' +import { BaseEvent } from '../types/trade' -export async function BroadCast( - dto: T, - twitterClient: TwitterApi, - telegramClient: Telegraf, - discordClient: Client, - network: Network, -): Promise { - if (TWITTER_ENABLED) { - let post = '' - if (dto.eventType == EventType.Arb) { - const arbDto = dto as unknown as ArbDto - if (arbDto.arbs.length > 0) { - post = ArbTwitter(dto as unknown as ArbDto, network) - } - } - if (post != '') { - await SendTweet(post, twitterClient) - } - } +// export async function BroadCast( +// dto: T, +// twitterClient: TwitterApi, +// telegramClient: Telegraf, +// discordClient: Client, +// network: Network, +// ): Promise { +// if (TWITTER_ENABLED) { +// let post = '' +// if (dto.eventType == EventType.Arb) { +// const arbDto = dto as unknown as ArbDto +// if (arbDto.arbs.length > 0) { +// post = ArbTwitter(dto as unknown as ArbDto, network) +// } +// } +// if (post != '') { +// await SendTweet(post, twitterClient) +// } +// } - if (TELEGRAM_ENABLED) { - let post = '' - if (dto.eventType == EventType.Arb) { - const arbDto = dto as unknown as ArbDto - if (arbDto.arbs.length > 0) { - post = ArbTelegram(dto as unknown as ArbDto, network) - } - } +// if (TELEGRAM_ENABLED) { +// let post = '' +// if (dto.eventType == EventType.Arb) { +// const arbDto = dto as unknown as ArbDto +// if (arbDto.arbs.length > 0) { +// post = ArbTelegram(dto as unknown as ArbDto, network) +// } +// } - if (TESTNET) { - console.log(post) - } else { - if (post != '') { - await PostTelegram(post, telegramClient) - } - } - } +// if (TESTNET) { +// console.log(post) +// } else { +// if (post != '') { +// await PostTelegram(post, telegramClient) +// } +// } +// } - if (DISCORD_ENABLED) { - let embeds: EmbedBuilder[] = [] - let rows: ActionRowBuilder[] = [] +// if (DISCORD_ENABLED) { +// let embeds: EmbedBuilder[] = [] +// let rows: ActionRowBuilder[] = [] - const att: AttachmentBuilder[] = [] - let channel = '' +// const att: AttachmentBuilder[] = [] +// let channel = '' - if (dto.eventType == EventType.Arb) { - const arbDto = dto as unknown as ArbDto - if (arbDto.arbs.length > 0) { - ;({ embeds, rows } = ArbDiscord(dto as unknown as ArbDto, network)) - } - channel = ARBS_CHANNEL - } +// if (dto.eventType == EventType.Arb) { +// const arbDto = dto as unknown as ArbDto +// if (arbDto.arbs.length > 0) { +// ;({ embeds, rows } = ArbDiscord(dto as unknown as ArbDto, network)) +// } +// channel = ARBS_CHANNEL +// } - if (embeds.length > 0 && channel != '') { - await PostDiscord(embeds, rows, discordClient, channel) - } - } -} +// if (embeds.length > 0 && channel != '') { +// await PostDiscord(embeds, rows, discordClient, channel) +// } +// } +// } diff --git a/app/src/event/index.ts b/app/src/event/index.ts index 083c1e0..32eb879 100644 --- a/app/src/event/index.ts +++ b/app/src/event/index.ts @@ -1,81 +1,80 @@ import { BigNumber } from '@ethersproject/bignumber' import { BlockTag } from '@ethersproject/providers' -import Lyra from '@lyrafinance/lyra-js' import { Event as GenericEvent } from 'ethers' import { groupBy } from '../utils/utils' -export type EventListener = { - off: () => void -} +// export type EventListener = { +// off: () => void +// } -export type EventListenerCallback = (transfer: GenericEvent[]) => void +// export type EventListenerCallback = (transfer: GenericEvent[]) => void -export type EventListenerOptions = { - pollInterval?: number - startBlockNumber?: BlockTag - addresses: string[] - topics: string[] -} -export class BlockEvent { - static on(rpcClient: Lyra, callback: EventListenerCallback, options?: EventListenerOptions): EventListener { - const ms = options?.pollInterval ?? 30 * 1000 - const startBlockTag = options?.startBlockNumber ?? 'latest' - let timeout: NodeJS.Timeout | null +// export type EventListenerOptions = { +// pollInterval?: number +// startBlockNumber?: BlockTag +// addresses: string[] +// topics: string[] +// } +// export class BlockEvent { +// static on(rpcClient: Lyra, callback: EventListenerCallback, options?: EventListenerOptions): EventListener { +// const ms = options?.pollInterval ?? 30 * 1000 +// const startBlockTag = options?.startBlockNumber ?? 'latest' +// let timeout: NodeJS.Timeout | null - rpcClient.provider.getBlock(startBlockTag).then(async (block) => { - console.debug(`Polling from block ${block.number} every ${ms}ms`) - let prevBlock = block +// rpcClient.provider.getBlock(startBlockTag).then(async (block) => { +// console.debug(`Polling from block ${block.number} every ${ms}ms`) +// let prevBlock = block - const poll = async () => { - try { - const latestBlock = await rpcClient.provider.getBlock('latest') - const fromBlockNumber = prevBlock.number + 1 - const toBlockNumber = latestBlock.number - if (fromBlockNumber >= toBlockNumber) { - setTimeout(poll, ms) - return - } - console.debug( - `Querying block range: ${fromBlockNumber} to ${toBlockNumber} (${toBlockNumber - fromBlockNumber} blocks)`, - ) +// const poll = async () => { +// try { +// const latestBlock = await rpcClient.provider.getBlock('latest') +// const fromBlockNumber = prevBlock.number + 1 +// const toBlockNumber = latestBlock.number +// if (fromBlockNumber >= toBlockNumber) { +// setTimeout(poll, ms) +// return +// } +// console.debug( +// `Querying block range: ${fromBlockNumber} to ${toBlockNumber} (${toBlockNumber - fromBlockNumber} blocks)`, +// ) - try { - const events: GenericEvent[] = await rpcClient.provider.send('eth_getLogs', [ - { - fromBlock: BigNumber.from(fromBlockNumber).toHexString(), - toBlock: BigNumber.from(toBlockNumber).toHexString(), - address: options?.addresses, - topics: [options?.topics], - }, - ]) +// try { +// const events: GenericEvent[] = await rpcClient.provider.send('eth_getLogs', [ +// { +// fromBlock: BigNumber.from(fromBlockNumber).toHexString(), +// toBlock: BigNumber.from(toBlockNumber).toHexString(), +// address: options?.addresses, +// topics: [options?.topics], +// }, +// ]) - // group the events by trx hash - const groupedEvents = groupBy(events, (i) => i.transactionHash) +// // group the events by trx hash +// const groupedEvents = groupBy(events, (i) => i.transactionHash) - if (Object.keys(groupedEvents).length > 0) { - console.debug(`Found ${Object.keys(groupedEvents).length} grouped events`) - } - await Promise.all(Object.keys(groupedEvents).map((x) => callback(groupedEvents[x]))) - } catch (e) { - console.warn('Failed to get eth_logs') - } +// if (Object.keys(groupedEvents).length > 0) { +// console.debug(`Found ${Object.keys(groupedEvents).length} grouped events`) +// } +// await Promise.all(Object.keys(groupedEvents).map((x) => callback(groupedEvents[x]))) +// } catch (e) { +// console.warn('Failed to get eth_logs') +// } - prevBlock = latestBlock - } catch (error) { - // catch any error - console.log(error) - } - setTimeout(poll, ms) - } - timeout = setTimeout(poll, ms) - }) +// prevBlock = latestBlock +// } catch (error) { +// // catch any error +// console.log(error) +// } +// setTimeout(poll, ms) +// } +// timeout = setTimeout(poll, ms) +// }) - return { - off: () => { - if (timeout) { - clearTimeout(timeout) - } - }, - } - } -} +// return { +// off: () => { +// if (timeout) { +// clearTimeout(timeout) +// } +// }, +// } +// } +// } diff --git a/app/src/integrations/leaderboard.ts b/app/src/integrations/leaderboard.ts deleted file mode 100644 index f053f5d..0000000 --- a/app/src/integrations/leaderboard.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import axios from 'axios' -import { urls } from '../constants/urls' -import { LeaderboardData } from '../types/leaderboardAPI' - -export const GetLeaderboardAPI = async () => { - const networks = [Network.Arbitrum, Network.Optimism] - networks.map(async (network) => { - if (network == Network.Arbitrum) { - try { - const leaderboardData = (await axios.get(`${urls.leaderboardApiUrl}?chain=arbitrum-mainnet`)) - .data as LeaderboardData - global.LEADERBOARD_ARB = leaderboardData.leaderboard - } catch (ex) { - global.LEADERBOARD_ARB = [] - console.log(ex) - } - } else { - try { - const leaderboardData = (await axios.get(`${urls.leaderboardApiUrl}`)).data as LeaderboardData - global.LEADERBOARD_OPT = leaderboardData.leaderboard - } catch (ex) { - global.LEADERBOARD_OPT = [] - console.log(ex) - } - } - }) -} diff --git a/app/src/lyra/arbitrage.ts b/app/src/lyra/arbitrage.ts index 3885b5a..03dae80 100644 --- a/app/src/lyra/arbitrage.ts +++ b/app/src/lyra/arbitrage.ts @@ -1,87 +1,85 @@ -import { Network } from '@lyrafinance/lyra-js' import { Deal, OptionType, ProviderType } from '../types/arbs' -import { useRatesData } from '../utils/arbUtils' +//import { useRatesData } from '../utils/arbUtils' import { maxBy, minBy } from 'lodash' import moment from 'moment' -import { Arb, ArbDto } from '../types/lyra' import { EventType } from '../constants/eventType' import { GetPrice } from '../integrations/prices' -export async function GetArbitrageDeals(market: string, network: Network) { - const price = GetPrice(market) - const deals = await useDeals(market, network) +// export async function GetArbitrageDeals(market: string, network: string) { +// const price = GetPrice(market) +// const deals = await useDeals(market, network) - const data = deals.map((deal) => { - const momentExp = moment(deal?.expiration) - const duration = moment.duration(momentExp.diff(moment())).asYears() - const arb: Arb = { - ...deal, - apy: (deal.amount / price / duration) * 100, - discount: (deal.amount / (deal.sell?.bidPrice as number)) * 100, - } - return arb - }) +// const data = deals.map((deal) => { +// const momentExp = moment(deal?.expiration) +// const duration = moment.duration(momentExp.diff(moment())).asYears() +// const arb: Arb = { +// ...deal, +// apy: (deal.amount / price / duration) * 100, +// discount: (deal.amount / (deal.sell?.bidPrice as number)) * 100, +// } +// return arb +// }) - data.sort((a, b) => b.apy - a.apy) +// data.sort((a, b) => b.apy - a.apy) - const event: ArbDto = { - arbs: data, - eventType: EventType.Arb, - market: market, - } +// const event: ArbDto = { +// arbs: data, +// eventType: EventType.Arb, +// market: market, +// } - return event -} +// return event +// } -export async function useDeals(marketName: string, network: Network) { - const { allRates } = await useRatesData(marketName, network) - const res: Deal[] = [] - const providers = [ProviderType.LYRA, ProviderType.DERIBIT] - const profit_threshold = 3 +// export async function useDeals(marketName: string, network: string) { +// const { allRates } = await useRatesData(marketName, network) +// const res: Deal[] = [] +// const providers = [ProviderType.LYRA, ProviderType.DERIBIT] +// const profit_threshold = 3 - Object.values(allRates).forEach((strike) => - Object.values(strike).forEach((interception) => { - const providerFiltered = providers - ? interception.filter((option) => option && providers.includes(option.provider)) - : interception - if (providerFiltered?.length < 2) return +// Object.values(allRates).forEach((strike) => +// Object.values(strike).forEach((interception) => { +// const providerFiltered = providers +// ? interception.filter((option) => option && providers.includes(option.provider)) +// : interception +// if (providerFiltered?.length < 2) return - const maxCall = maxBy(providerFiltered, (o) => o[OptionType.CALL]?.bidPrice)?.CALL - const minCall = minBy(providerFiltered, (o) => o[OptionType.CALL]?.askPrice)?.CALL - const maxPut = maxBy(providerFiltered, (o) => o[OptionType.PUT]?.bidPrice)?.PUT - const minPut = minBy(providerFiltered, (o) => o[OptionType.PUT]?.askPrice)?.PUT - const callDeal = - maxCall?.bidPrice && - minCall?.askPrice && - maxCall.provider !== minCall.provider && - maxCall.bidPrice - minCall.askPrice - const putDeal = - maxPut?.bidPrice && minPut?.askPrice && maxPut.provider !== minPut.provider && maxPut.bidPrice - minPut.askPrice +// const maxCall = maxBy(providerFiltered, (o) => o[OptionType.CALL]?.bidPrice)?.CALL +// const minCall = minBy(providerFiltered, (o) => o[OptionType.CALL]?.askPrice)?.CALL +// const maxPut = maxBy(providerFiltered, (o) => o[OptionType.PUT]?.bidPrice)?.PUT +// const minPut = minBy(providerFiltered, (o) => o[OptionType.PUT]?.askPrice)?.PUT +// const callDeal = +// maxCall?.bidPrice && +// minCall?.askPrice && +// maxCall.provider !== minCall.provider && +// maxCall.bidPrice - minCall.askPrice +// const putDeal = +// maxPut?.bidPrice && minPut?.askPrice && maxPut.provider !== minPut.provider && maxPut.bidPrice - minPut.askPrice - if (callDeal && callDeal > profit_threshold) { - res.push({ - type: OptionType.CALL, - term: maxCall.term, - strike: maxCall.strike, - expiration: maxCall.expiration, - amount: callDeal, - buy: minCall, - sell: maxCall, - }) - } - if (putDeal && putDeal > profit_threshold) { - res.push({ - type: OptionType.PUT, - term: maxPut.term, - strike: maxPut.strike, - expiration: maxPut.expiration, - amount: putDeal, - buy: minPut, - sell: maxPut, - }) - } - }), - ) +// if (callDeal && callDeal > profit_threshold) { +// res.push({ +// type: OptionType.CALL, +// term: maxCall.term, +// strike: maxCall.strike, +// expiration: maxCall.expiration, +// amount: callDeal, +// buy: minCall, +// sell: maxCall, +// }) +// } +// if (putDeal && putDeal > profit_threshold) { +// res.push({ +// type: OptionType.PUT, +// term: maxPut.term, +// strike: maxPut.strike, +// expiration: maxPut.expiration, +// amount: putDeal, +// buy: minPut, +// sell: maxPut, +// }) +// } +// }), +// ) - return res -} +// return res +// } diff --git a/app/src/lyra/deposits.ts b/app/src/lyra/deposits.ts deleted file mode 100644 index f77a35e..0000000 --- a/app/src/lyra/deposits.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { DEPOSIT_THRESHOLD } from '../config' -import fromBigNumber from '../utils/fromBigNumber' -import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' -import { PostDiscord } from '../discord' -import { GetEns } from '../integrations/ens' -import { GetNotableAddress } from '../utils/notableAddresses' -import { SendTweet } from '../integrations/twitter' -import { Event as GenericEvent } from 'ethers' -import { TwitterApi } from 'twitter-api-v2' -import { DEPOSITS_CHANNEL } from '../constants/discordChannels' -import { Network, NewportLiquidityPool__factory } from '@lyrafinance/lyra-js' -import { DepositDto } from '../types/lyra' -import { DepositDiscord, DepositTwitter } from '../templates/deposit' -import { GetAsset, GetMarket } from '../templates/common' -import { GetUrl } from '../utils/utils' -import { - DepositProcessedEvent, - DepositQueuedEvent, -} from '@lyrafinance/lyra-js/src/contracts/avalon/typechain/AvalonLiquidityPool' - -export async function TrackDeposits( - discordClient: Client, - twitterClient: TwitterApi, - genericEvent: GenericEvent, - network: Network, -): Promise { - const event = parseProcessedEvent(genericEvent as DepositProcessedEvent) - const amount = fromBigNumber(event.args.amountDeposited) - const value = amount - const from = GetNotableAddress(event.args.caller.toLowerCase()) - const fromAddress = event.args.caller - const to = GetNotableAddress(event.args.beneficiary.toLowerCase()) - const toAddress = event.args.beneficiary.toLowerCase() - const toEns = await GetEns(event.args.beneficiary.toLowerCase()) - const isNotable = from !== '' - - console.log(`Deposit Value: ${value}, threshold: ${DEPOSIT_THRESHOLD}`) - - if (value >= Number(DEPOSIT_THRESHOLD)) { - try { - const dto: DepositDto = { - account: toAddress, - ens: toEns, - asset: GetAsset(genericEvent.address), - market: GetMarket(genericEvent.address), - notableAddress: from, - to: to === '' ? toAddress : to, - amount: amount, - value: value, - notableTo: to !== '', - isNotable: isNotable, - fromAddress: fromAddress, - toAddress: toAddress, - totalQueued: 0, - url: GetUrl(event.args.beneficiary.toLowerCase(), isNotable), - transactionHash: event.transactionHash, - blockNumber: event.blockNumber, - } - await BroadCastDeposit(dto, discordClient, twitterClient, network) - } catch (ex) { - console.log(ex) - } - } else { - console.log(`Deposit less than $${DEPOSIT_THRESHOLD} threshold value`) - } -} - -export async function BroadCastDeposit( - dto: DepositDto, - discordClient: Client, - twitterClient: TwitterApi, - network: Network, -): Promise { - const post = DepositDiscord(dto, network) - const rows: ActionRowBuilder[] = [] - await PostDiscord(post, rows, discordClient, DEPOSITS_CHANNEL) - - const postTwitter = DepositTwitter(dto, network) - await SendTweet(postTwitter, twitterClient) -} - -export function parseEvent(event: DepositQueuedEvent): DepositQueuedEvent { - const parsedEvent = NewportLiquidityPool__factory.createInterface().parseLog(event) - - if ((parsedEvent.args as DepositQueuedEvent['args']).length > 0) { - event.args = parsedEvent.args as DepositQueuedEvent['args'] - } - return event -} - -export function parseProcessedEvent(event: DepositProcessedEvent): DepositProcessedEvent { - const parsedEvent = NewportLiquidityPool__factory.createInterface().parseLog(event) - - if ((parsedEvent.args as DepositProcessedEvent['args']).length > 0) { - event.args = parsedEvent.args as DepositProcessedEvent['args'] - } - return event -} diff --git a/app/src/lyra/expiries.ts b/app/src/lyra/expiries.ts deleted file mode 100644 index c4bcce8..0000000 --- a/app/src/lyra/expiries.ts +++ /dev/null @@ -1,97 +0,0 @@ -import fromBigNumber from '../utils/fromBigNumber' -import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' -import { BoardDto, StrikeDto } from '../types/lyra' -import { groupBy, toDate } from '../utils/utils' -import { Telegraf } from 'telegraf' -import { SendTweet } from '../integrations/twitter' -import { Event as GenericEvent } from 'ethers' -import { TwitterApi } from 'twitter-api-v2' -import { EXPIRY_CHANNEL } from '../constants/discordChannels' -import { AvalonFactories, Network } from '@lyrafinance/lyra-js' -import { BoardDiscord, BoardTelegram, BoardTwitter } from '../templates/strike' -import { PostDiscord } from '../discord' -import { PostTelegram } from '../integrations/telegram' -import { StrikeAddedEvent } from '@lyrafinance/lyra-js/src/contracts/avalon/typechain/AvalonOptionMarket' -import { GetAsset } from '../templates/common' -import getLyraSDK from '../utils/getLyraSDK' - -export async function TrackStrikeAdded( - discordClient: Client, - telegramClient: Telegraf, - twitterClient: TwitterApi, - network: Network, - genericEvents: GenericEvent[], -): Promise { - const events = parseEvents(genericEvents as StrikeAddedEvent[]) - const boardEvents = groupBy(events, (i) => i.args.boardId.toNumber() as unknown as string) - - Object.keys(boardEvents).map( - async (x) => await processBoardStrikes(discordClient, telegramClient, twitterClient, boardEvents[x], network), - ) -} -export async function processBoardStrikes( - discordClient: Client, - telegramClient: Telegraf, - twitterClient: TwitterApi, - events: StrikeAddedEvent[], - network: Network, -) { - const lyra = getLyraSDK(network) - const board = await lyra.board(events[0].address, events[0].args.boardId.toNumber()) - const event = events[0] - const market = board.market() - const marketName = market.name - const asset = GetAsset(market.address) - const boardDto: BoardDto = { - blockNumber: event.blockNumber, - transactionHash: event.transactionHash, - expiry: toDate(board.expiryTimestamp), - expiryString: board.expiryTimestamp as unknown as string, - market: marketName, - asset: asset, - strikes: events.map((event) => { - const dto: StrikeDto = { - strikeId: event.args.strikeId.toNumber(), - strikePrice: fromBigNumber(event.args.strikePrice), - skew: fromBigNumber(event.args.skew), - } - return dto - }), - } - console.log(boardDto) - try { - BroadCastStrike(boardDto, discordClient, telegramClient, twitterClient, network) - } catch (ex) { - console.log(ex) - } -} - -export async function BroadCastStrike( - dto: BoardDto, - discordClient: Client, - telegramClient: Telegraf, - twitterClient: TwitterApi, - network: Network, -): Promise { - const embed = BoardDiscord(dto, network) - const rows: ActionRowBuilder[] = [] - await PostDiscord(embed, rows, discordClient, EXPIRY_CHANNEL) - - const post = BoardTelegram(dto, network) - await PostTelegram(post, telegramClient) - - const postTwitter = BoardTwitter(dto, network) - await SendTweet(postTwitter, twitterClient) -} - -export function parseEvents(events: StrikeAddedEvent[]): StrikeAddedEvent[] { - const result = events.map((x) => { - const parsedEvent = AvalonFactories.AvalonOptionMarket__factory.createInterface().parseLog(x) - - if ((parsedEvent.args as StrikeAddedEvent['args']).length > 0) { - x.args = parsedEvent.args as StrikeAddedEvent['args'] - } - return x - }) - return result -} diff --git a/app/src/lyra/leaderboard.ts b/app/src/lyra/leaderboard.ts deleted file mode 100644 index 87dddff..0000000 --- a/app/src/lyra/leaderboard.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' -import { Telegraf } from 'telegraf' -import { TwitterApi } from 'twitter-api-v2' -import { PostDiscord } from '../discord' -import { SendTweet } from '../integrations/twitter' -import { GetEns } from '../integrations/ens' -import { Trader } from '../types/lyra' -import { PostTelegram } from '../integrations/telegram' -import { LeaderboardDiscord, LeaderboardTwitter, LeaderboardTelegram } from '../templates/leaderboard' -import { TRADE_CHANNEL } from '../constants/discordChannels' -import { Network } from '@lyrafinance/lyra-js' -import { GetNotableAddress } from '../utils/notableAddresses' -import { GetUrl } from '../utils/utils' -import { GetFren } from '../integrations/fren' -import { GetLeaderboardAPI } from '../integrations/leaderboard' -import { LeaderboardElement } from '../types/leaderboardAPI' - -export async function GetLeaderBoard(network: Network) { - if (network == Network.Arbitrum) { - return LEADERBOARD_ARB - } - return LEADERBOARD_OPT -} - -export async function FindOnLeaderBoard(traderAddress: string, network: Network): Promise { - const EMPTY: Trader = { - account: '', - longPnl: 0, - shortPnl: 0, - longPnlPercentage: 0, - shortPnlPercentage: 0, - realizedPnl: 0, - unrealizedPnl: 0, - unrealizedPnlPercentage: 0, - initialCostOfOpen: 0, - isProfitable: false, - ens: '', - position: 0, - isNotable: false, - notableAddress: '', - url: '', - fren: undefined, - } - - const leaderBoardData = await GetLeaderBoard(network) - - const index = leaderBoardData.findIndex( - (leaderboard) => leaderboard.owner.toLowerCase() === traderAddress.toLowerCase(), - ) - - if (index === -1) { - console.log(`Trader not on ${network} leaderboard`) - return EMPTY - } - - const trader = await ParsePositionLeaderboard(leaderBoardData[index], index + 1) - return trader -} - -export async function ParsePositionLeaderboard(positionLeaderBoard: LeaderboardElement, position: number) { - const notableAddress = GetNotableAddress(positionLeaderBoard.owner.toLowerCase()) - const isNotable = notableAddress != '' - const ens = await GetEns(positionLeaderBoard.owner) - - const result: Trader = { - account: positionLeaderBoard.owner.toLowerCase(), - longPnl: positionLeaderBoard.long_pnl, - shortPnl: positionLeaderBoard.short_pnl, - longPnlPercentage: positionLeaderBoard.long_pnl_percent, - shortPnlPercentage: positionLeaderBoard.short_pnl_percent, - realizedPnl: positionLeaderBoard.realized_pnl, - unrealizedPnl: positionLeaderBoard.unrealized_pnl, - unrealizedPnlPercentage: positionLeaderBoard.unrealized_pnl_percent, - initialCostOfOpen: positionLeaderBoard.initial_cost_of_open, - isProfitable: positionLeaderBoard.realized_pnl > 0, - ens: await GetEns(positionLeaderBoard.owner), - position: position, - notableAddress: notableAddress, - isNotable: isNotable, - url: GetUrl(positionLeaderBoard.owner.toLowerCase(), isNotable), - fren: await GetFren(ens), - } - - return result -} - -export async function FetchLeaderBoard() { - await GetLeaderboardAPI() -} - -export async function BroadcastLeaderBoard( - discordClient: Client, - twitterClient: TwitterApi, - telegramClient: Telegraf, - network: Network, -) { - console.log('### Broadcast Leaderboard ###') - - const leaderBoard = await GetLeaderBoard(network) - - const traders = await Promise.all( - leaderBoard.slice(0, 10).map(async (x, index) => await ParsePositionLeaderboard(x, index + 1)), - ) - - const channelName = TRADE_CHANNEL - const embeds = LeaderboardDiscord(traders.slice(0, 10), network) - const rows: ActionRowBuilder[] = [] - await PostDiscord(embeds, rows, discordClient, channelName) - - const twitterPost = LeaderboardTwitter(traders.slice(0, 5)) - await SendTweet(twitterPost, twitterClient) - - const post = LeaderboardTelegram(traders.slice(0, 10)) - await PostTelegram(post, telegramClient) -} diff --git a/app/src/lyra/stats.ts b/app/src/lyra/stats.ts deleted file mode 100644 index 94d4e28..0000000 --- a/app/src/lyra/stats.ts +++ /dev/null @@ -1,88 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' -import { Telegraf } from 'telegraf' -import { TwitterApi } from 'twitter-api-v2' -import { ZERO_BN } from '../constants/bn' -import { STATS_CHANNEL } from '../constants/discordChannels' -import { SECONDS_IN_MONTH, SECONDS_IN_YEAR } from '../constants/timeAgo' -import { PostDiscord } from '../discord' -import { PostTelegram } from '../integrations/telegram' -import { SendTweet } from '../integrations/twitter' -import { StatDiscord, StatTelegram, StatTwitter } from '../templates/stats' -import { VaultStats } from '../types/lyra' -import fromBigNumber from '../utils/fromBigNumber' -import getLyraSDK from '../utils/getLyraSDK' - -export async function GetStats(marketName: string, network: Network): Promise { - // get timestamp from month ago - console.log(`Getting stats for ${marketName} on ${network}`) - const lyra = getLyraSDK(network) - const market = await lyra.market(marketName) - - const period = SECONDS_IN_MONTH - const [tradingVolumeHistory, liquidityHistory, netGreeksHistory] = await Promise.all([ - market.tradingVolumeHistory({ startTimestamp: market.block.timestamp - period }), - market.liquidityHistory({ startTimestamp: market.block.timestamp - period }), - market.netGreeksHistory({ startTimestamp: market.block.timestamp - period }), - ]) - - const liquidity = liquidityHistory[liquidityHistory.length - 1] - const netGreeks = netGreeksHistory[netGreeksHistory.length - 1] - const tradingVolume = tradingVolumeHistory[tradingVolumeHistory.length - 1] - - const tvl = fromBigNumber(liquidity.tvl) - const tvlOld = fromBigNumber(liquidityHistory[0].tvl) - const tvlChange = tvlOld > 0 ? (tvl - tvlOld) / tvlOld : 0 - - const tokenPrice = fromBigNumber(liquidity.tokenPrice) - const tokenPriceOld = fromBigNumber(liquidityHistory[0].tokenPrice) - const tokenPriceChange = tokenPriceOld > 0 ? (tokenPrice - tokenPriceOld) / tokenPriceOld : 0 - const tokenPriceChangeAnnualized = tokenPriceChange / (period / SECONDS_IN_YEAR) - - const totalNotionalVolumeNew = fromBigNumber(tradingVolume.totalNotionalVolume) - const totalNotionalVolumeOld = fromBigNumber(tradingVolumeHistory[0].totalNotionalVolume) - const totalNotionalVolume = totalNotionalVolumeNew - totalNotionalVolumeOld - const totalNotionalVolumeChange = - totalNotionalVolumeOld > 0 ? (totalNotionalVolumeNew - totalNotionalVolumeOld) / totalNotionalVolumeOld : 0 - - const totalFees = fromBigNumber(tradingVolumeHistory.reduce((sum, { vaultFees }) => sum.add(vaultFees), ZERO_BN)) - - const openInterest = fromBigNumber(market.openInterest) * fromBigNumber(market.spotPrice) - return { - asset: marketName, - market, - liquidity, - netGreeks, - tradingVolume, - liquidityHistory, - netGreeksHistory, - tradingVolumeHistory, - tvl, - tvlChange, - tokenPrice, - tokenPriceChange, - tokenPriceChangeAnnualized, - totalNotionalVolume, - totalNotionalVolumeChange, - totalFees, - openInterest, - } -} - -export async function BroadCastStats( - dto: VaultStats, - twitterClient: TwitterApi, - telegramClient: Telegraf, - discordClient: Client, - network: Network, -): Promise { - const twitterPost = StatTwitter(dto, network) - await SendTweet(twitterPost, twitterClient) - - const post = StatTelegram(dto, network) - await PostTelegram(post, telegramClient) - - const embeds = StatDiscord(dto, network) - const rows: ActionRowBuilder[] = [] - await PostDiscord(embeds, rows, discordClient, STATS_CHANNEL) -} diff --git a/app/src/lyra/tracker.ts b/app/src/lyra/tracker.ts index f3a69f1..a454aeb 100644 --- a/app/src/lyra/tracker.ts +++ b/app/src/lyra/tracker.ts @@ -1,91 +1,88 @@ import { TOKEN_THRESHOLD } from '../config' import fromBigNumber from '../utils/fromBigNumber' import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' -import { TransferDto } from '../types/lyra' +import { TransferDto } from '../types/trade' import { PostDiscord } from '../discord' -import { TransferDiscord, TransferTwitter } from '../templates/transfer' import { GetEns } from '../integrations/ens' import { GetNotableAddress } from '../utils/notableAddresses' import { SendTweet } from '../integrations/twitter' -import { ERC20__factory } from '@lyrafinance/lyra-js' +//import { ERC20__factory } from '@lyrafinance/lyra-js' import { Event as GenericEvent } from 'ethers' import { TwitterApi } from 'twitter-api-v2' import { TOKEN_CHANNEL } from '../constants/discordChannels' -import { TransferEvent } from '@lyrafinance/lyra-js/src/contracts/common/typechain/ERC20' -import { Network } from '@lyrafinance/lyra-js' +//import { TransferEvent } from '@lyrafinance/lyra-js/src/contracts/common/typechain/ERC20'' import { getTokenName } from '../utils/getTokenName' import { GetPrice } from '../integrations/prices' // exclude g-uni -const excludeAddresses = ['0x70535c46ce04181adf749f34b65b6365164d6b6e'] +// const excludeAddresses = ['0x70535c46ce04181adf749f34b65b6365164d6b6e'] -export async function TrackTransfer( - discordClient: Client, - twitterClient: TwitterApi, - genericEvent: GenericEvent, - network: Network, -): Promise { - const event = parseEvent(genericEvent as TransferEvent) - const amount = fromBigNumber(event.args.value) - const price = GetPrice('lyra') - const value = price * amount +// export async function TrackTransfer( +// discordClient: Client, +// twitterClient: TwitterApi, +// genericEvent: GenericEvent, +// network: string, +// ): Promise { +// const event = parseEvent(genericEvent as TransferEvent) +// const amount = fromBigNumber(event.args.value) +// const price = GetPrice('lyra') +// const value = price * amount - console.log(`Transfer Value: ${value}`) +// console.log(`Transfer Value: ${value}`) - if ( - value >= Number(TOKEN_THRESHOLD) && - !excludeAddresses.includes(event.args.to.toLowerCase()) && - !excludeAddresses.includes(event.args.from.toLowerCase()) - ) { - try { - const from = GetNotableAddress(event.args.from) - const to = GetNotableAddress(event.args.to) - const fromEns = await GetEns(event.args.from) - const toEns = await GetEns(event.args.to) +// if ( +// value >= Number(TOKEN_THRESHOLD) && +// !excludeAddresses.includes(event.args.to.toLowerCase()) && +// !excludeAddresses.includes(event.args.from.toLowerCase()) +// ) { +// try { +// const from = GetNotableAddress(event.args.from) +// const to = GetNotableAddress(event.args.to) +// const fromEns = await GetEns(event.args.from) +// const toEns = await GetEns(event.args.to) - const transferDto: TransferDto = { - from: from === '' ? event.args.from : from, - to: to === '' ? event.args.to : to, - amount: amount, - transactionHash: event.transactionHash, - fromEns: fromEns, - toEns: toEns, - blockNumber: event.blockNumber, - value: value, - notableTo: to !== '', - notableFrom: from !== '', - fromAddress: event.args.from, - toAddress: event.args.to, - token: getTokenName(event.address), - } - BroadCastTransfer(transferDto, discordClient, twitterClient, network) - } catch (ex) { - console.log(ex) - } - } else { - console.log(`Transfer less than $${TOKEN_THRESHOLD} threshold value`) - } -} +// const transferDto: TransferDto = { +// from: from === '' ? event.args.from : from, +// to: to === '' ? event.args.to : to, +// amount: amount, +// transactionHash: event.transactionHash, +// fromEns: fromEns, +// toEns: toEns, +// value: value, +// notableTo: to !== '', +// notableFrom: from !== '', +// fromAddress: event.args.from, +// toAddress: event.args.to, +// token: getTokenName(event.address), +// } +// BroadCastTransfer(transferDto, discordClient, twitterClient, network) +// } catch (ex) { +// console.log(ex) +// } +// } else { +// console.log(`Transfer less than $${TOKEN_THRESHOLD} threshold value`) +// } +// } -export async function BroadCastTransfer( - transferDto: TransferDto, - discordClient: Client, - twitterClient: TwitterApi, - network: Network, -): Promise { - const post = TransferDiscord(transferDto, network) - const rows: ActionRowBuilder[] = [] - await PostDiscord(post, rows, discordClient, TOKEN_CHANNEL) +// export async function BroadCastTransfer( +// transferDto: TransferDto, +// discordClient: Client, +// twitterClient: TwitterApi, +// network: Network, +// ): Promise { +// const post = TransferDiscord(transferDto, network) +// const rows: ActionRowBuilder[] = [] +// await PostDiscord(post, rows, discordClient, TOKEN_CHANNEL) - const twitter = TransferTwitter(transferDto, network) - await SendTweet(twitter, twitterClient) -} +// const twitter = TransferTwitter(transferDto, network) +// await SendTweet(twitter, twitterClient) +// } -export function parseEvent(event: TransferEvent): TransferEvent { - const parsedEvent = ERC20__factory.createInterface().parseLog(event) +// export function parseEvent(event: TransferEvent): TransferEvent { +// const parsedEvent = ERC20__factory.createInterface().parseLog(event) - if ((parsedEvent.args as TransferEvent['args']).length > 0) { - event.args = parsedEvent.args as TransferEvent['args'] - } - return event -} +// if ((parsedEvent.args as TransferEvent['args']).length > 0) { +// event.args = parsedEvent.args as TransferEvent['args'] +// } +// return event +// } diff --git a/app/src/lyra/trader.ts b/app/src/lyra/trader.ts deleted file mode 100644 index 5c843f7..0000000 --- a/app/src/lyra/trader.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { ResolveEns } from '../integrations/ens' -import { Trader } from '../types/lyra' -import { FindOnLeaderBoard } from './leaderboard' - -export async function GetTrader(account: string, network: Network): Promise { - let trader = await FindOnLeaderBoard(account.toLowerCase(), network) - - if (trader.account == '') { - const ensAcc = await ResolveEns(account) - if (ensAcc != '') { - trader = await FindOnLeaderBoard(ensAcc.toLowerCase(), network) - } - } - - return trader -} diff --git a/app/src/lyra/trades.ts b/app/src/lyra/trades.ts deleted file mode 100644 index 1b055b6..0000000 --- a/app/src/lyra/trades.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { SendTweet } from '../integrations/twitter' -import { TradeDto } from '../types/lyra' -import { TWITTER_THRESHOLD, TELEGRAM_THRESHOLD, DISCORD_THRESHOLD, TESTNET } from '../config' -import { GetUrl, signed, toDate } from '../utils/utils' -import { TradeEvent } from '@lyrafinance/lyra-js' -import { FindOnLeaderBoard } from './leaderboard' -import { GetEns } from '../integrations/ens' -import { PostTelegram } from '../integrations/telegram' -import { PostDiscord } from '../discord' -import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' -import { TwitterApi } from 'twitter-api-v2' -import { Telegraf } from 'telegraf' -import { TradeDiscord, TradeTelegram, TradeTwitter } from '../templates/trade' -import fromBigNumber from '../utils/fromBigNumber' -import { TRADE_CHANNEL } from '../constants/discordChannels' -import { GetNotableAddress } from '../utils/notableAddresses' -import { GetFren } from '../integrations/fren' -import { FN } from '../templates/common' -import getLyra from '../utils/getLyra' -import printObject from '../utils/printObject' -import formatUSD from '../utils/formatUSD' - -export async function RunTradeBot( - discordClient: Client, - twitterClient: TwitterApi, - telegramClient: Telegraf, - network: Network, -) { - console.log('### Polling for Trades ###') - const lyra = getLyra(network) - - // eslint-disable-next-line prefer-const - let blockNumber: number | undefined = undefined - let pollInterval = 60000 // 1 min - - if (TESTNET) { - blockNumber = lyra.provider.blockNumber - 5000 - pollInterval = 20000 // 20 secs - } - - lyra.onTrade( - async (trade) => { - try { - const tradeDto = await MapToTradeDto(trade, network) - await BroadCastTrade(tradeDto, network, twitterClient, telegramClient, discordClient) - } catch (e: any) { - console.log(e) - } - }, - { startBlockNumber: blockNumber, pollInterval: pollInterval }, - ) -} - -export async function MapToTradeDto(trade: TradeEvent, network: Network): Promise { - const position = await trade.position() - //const tradePnl = fromBigNumber(trade.pnl(position)) - const positionPnl = position.pnl() - const unrealizedPnl = fromBigNumber(positionPnl.unrealizedPnl) - const unrealizedPnlPercent = fromBigNumber(positionPnl.unrealizedPnlPercentage) - const pnl = fromBigNumber(positionPnl.realizedPnl) - const pnlPercent = fromBigNumber(positionPnl.realizedPnlPercentage) - - const trades = position.trades() - const totalPremiumPaid = fromBigNumber(trade.premium) - const market = await trade.market() - const noTrades = trades.length - const from = GetNotableAddress(trade.trader) - const ens = await GetEns(trade.trader) - const isNotable = from != '' - const asset = market.name.split('-')[0] - - const tradeDto: TradeDto = { - account: trade.trader.toLowerCase(), - asset: asset, - market: market.name, - isLong: trade.isLong, - isCall: trade.isCall, - isBuy: trade.isBuy, - strike: fromBigNumber(trade.strikePrice), - expiry: toDate(trade.expiryTimestamp), - size: fromBigNumber(trade.size), - premium: fromBigNumber(trade.premium), - transactionHash: trade.transactionHash, - isOpen: trade.isOpen, - ens: ens, - leaderBoard: await FindOnLeaderBoard(trade.trader, network), - pnl: pnl, - pnlPercent: pnlPercent, - totalPremiumPaid: totalPremiumPaid, - isProfitable: pnl > 0, - positionId: trade.positionId, - positionTradeCount: noTrades, - pnlFormatted: formatUSD(pnl), - pnlPercentFormatted: `(${signed(pnlPercent)}%)`, - isLiquidation: trade.isLiquidation, - setCollateralTo: trade.collateralValue ? fromBigNumber(trade.collateralValue) : undefined, - pricePerOption: fromBigNumber(trade.pricePerOption), - lpFees: trade.liquidation ? fromBigNumber(trade.liquidation.lpFee) : undefined, - premiumFormatted: formatUSD( - AmountWording(fromBigNumber(trade.premium), trade.isLong, trade.isOpen, trade.isLiquidation), - ), - isBaseCollateral: trade.isBaseCollateral, - baseCollateralFormatted: BaseCollateral(trade, asset), - iv: fromBigNumber(trade.iv) * 100, - fee: fromBigNumber(trade.fee), - optionPrice: fromBigNumber(trade.pricePerOption), - spot: fromBigNumber(trade.spotPrice), - blockNumber: trade.blockNumber, - notableAddress: from, - isNotable: isNotable, - unrealizedPnl: unrealizedPnl, - unrealizedPnlPercent: unrealizedPnlPercent, - unrealizedPnlFormatted: formatUSD(unrealizedPnl), - unrealizedPnlPercentFormatted: `(${signed(pnlPercent)}%)`, - fren: await GetFren(ens), - url: GetUrl(trade.trader.toLowerCase(), isNotable), - } - return tradeDto -} - -export function AmountWording(amount: number, isLong: boolean, isOpen: boolean, isLiquidation: boolean): number { - if (isLiquidation) { - return amount * -1 - } - - if (isOpen) { - return isLong ? amount * -1 : amount - } - - return isLong ? amount : amount * -1 -} - -export function BaseCollateral(trade: TradeEvent, asset: string) { - const collateralValue = trade.collateralValue ? fromBigNumber(trade.collateralValue) : undefined - const collateralAmount = trade.collateralAmount ? fromBigNumber(trade.collateralAmount) : undefined - - if (collateralAmount == undefined) { - return '' - } - - if (!trade.isBaseCollateral && collateralValue) { - return `${formatUSD(collateralValue)}` - } - - return `${FN(collateralAmount, 4)} ${asset}` -} - -export async function BroadCastTrade( - trade: TradeDto, - network: Network, - twitterClient: TwitterApi, - telegramClient: Telegraf, - discordClient: Client, -): Promise { - if ( - trade.premium >= Number(TWITTER_THRESHOLD) || - trade.isNotable || - (trade?.leaderBoard?.position > 0 && trade?.leaderBoard?.position < 21) - ) { - await SendTweet(TradeTwitter(trade, network), twitterClient) - } - - if ( - trade.premium >= Number(TELEGRAM_THRESHOLD) || - trade.isNotable || - (trade?.leaderBoard?.position > 0 && trade?.leaderBoard?.position < 21) - ) { - await PostTelegram(TradeTelegram(trade, network), telegramClient) - } - - if ( - trade.premium >= Number(DISCORD_THRESHOLD) || - trade.isNotable || - (trade?.leaderBoard?.position > 0 && trade?.leaderBoard?.position < 21) - ) { - const embeds = [TradeDiscord(trade, network)] - const rows: ActionRowBuilder[] = [] - await PostDiscord(embeds, rows, discordClient, TRADE_CHANNEL) - } -} diff --git a/app/src/lyra/tradesv2.ts b/app/src/lyra/tradesv2.ts new file mode 100644 index 0000000..8e76cfc --- /dev/null +++ b/app/src/lyra/tradesv2.ts @@ -0,0 +1,177 @@ +import sdk from '../api' +import { LiquidityRole, Trade } from '../types/api' +import { SendTweet } from '../integrations/twitter' +import { TradeDto } from '../types/trade' +import { TWITTER_THRESHOLD, TELEGRAM_THRESHOLD, DISCORD_THRESHOLD } from '../config' +import { toDate } from '../utils/utils' +import { PostTelegram } from '../integrations/telegram' +import { PostDiscord } from '../discord' +import { ActionRowBuilder, ButtonBuilder, Client } from 'discord.js' +import { TwitterApi } from 'twitter-api-v2' +import { Telegraf } from 'telegraf' +import { TradeDiscord, TradeTelegram, TradeTwitter } from '../templates/trade' +import { TRADE_CHANNEL } from '../constants/discordChannels' +import { ProviderType } from '../types/arbs' +import { ChainType } from '../types/chain' +import { MarketName } from '../types/market' +import { dateToYYYYMMDDHHMM } from '../utils/date' +import { mapStringToEnum } from '../utils/enumMapper' + +export type EventListener = { + off: () => void +} + +export type EventListenerCallback = (trades: Trade[]) => void + +export type EventListenerOptions = { + pollInterval?: number + startTime?: number +} + +export async function RunTradeBot(discordClient: Client, twitterClient: TwitterApi, telegramClient: Telegraf) { + TradeListener.on(async (trades) => { + const tradeDtos = trades.map(async (trade) => { + return mapToTradeDto(trade, 'LYRA') + }) + + const tradeObjects = await Promise.all(tradeDtos) + tradeObjects.map(async (tradeDto) => { + await BroadCastTrade(tradeDto, twitterClient, telegramClient, discordClient) + }) + }) +} + +export class TradeListener { + static on(callback: EventListenerCallback, options?: EventListenerOptions): EventListener { + const ms = options?.pollInterval ?? 30 * 1000 + let startTime = options?.startTime ?? Math.floor(Date.now()) + let timeout: NodeJS.Timeout | null + + const poll = async () => { + try { + const toTime = Math.floor(Date.now()) + const fromTime = startTime + + console.debug(`POLLING FROM ${fromTime} TO ${toTime} `) + const response = await sdk.postPublicGet_trade_history({ + from_timestamp: fromTime, + instrument_type: 'option', + page: 1, + page_size: 100, + to_timestamp: toTime, + tx_status: 'settled', + }) + + const trades = (response.data.result.trades as Trade[]).filter((x) => x.liquidity_role == 'taker') + // console.log(trades) + + if (trades.length > 0) { + console.debug(`Found ${trades.length} trades`) + callback(trades) + } + + startTime = toTime + } catch (error) { + console.error('Error in polling', error) + } + + timeout = setTimeout(poll, ms) + } + + timeout = setTimeout(poll, ms) + + return { + off: () => { + if (timeout) { + clearTimeout(timeout) + } + }, + } + } +} + +function parseOptionString(optionString: string): { + market: string + expiryDate: Date + strikePrice: number + optionType: string +} { + // Split the string by the '-' character + const parts = optionString.split('-') + + if (parts.length !== 4) { + throw new Error('Invalid option string format') + } + + const market = parts[0] + const expiryDateString = parts[1] + const strikePrice = parseFloat(parts[2]) + const optionType = parts[3] + + // Convert expiryDateString into a Date object + const year = parseInt(expiryDateString.substring(0, 4), 10) + const month = parseInt(expiryDateString.substring(4, 6), 10) - 1 // month is 0-indexed in JavaScript Date + const day = parseInt(expiryDateString.substring(6, 8), 10) + 1 + const expiryDate = new Date(year, month, day) + + // Validate the extracted values (additional validation can be added as needed) + if (!market || !expiryDate || isNaN(strikePrice) || (optionType !== 'C' && optionType !== 'P')) { + throw new Error('Invalid values extracted from option string') + } + + return { market, expiryDate, strikePrice, optionType } +} + +export async function mapToTradeDto(trade: Trade, network: string) { + const parsed = parseOptionString(trade.instrument_name) + const date = toDate(trade.timestamp) + const utcDate = dateToYYYYMMDDHHMM(date) + const expiryDate = parsed.expiryDate + const utcExpiry = dateToYYYYMMDDHHMM(expiryDate) + + const tradeDto: TradeDto = { + tradeKey: `${trade.trade_id}-${trade.liquidity_role}`, + tradeId: trade.trade_id, + instrument: trade.instrument_name, + account: trade.wallet.toLowerCase(), + market: mapStringToEnum(parsed.market, MarketName), + isCall: parsed.optionType == 'C', + isBuy: trade.direction == 'buy', + strike: parsed.strikePrice, + expiry: utcExpiry, + expiryTimestamp: Math.floor(parsed.expiryDate.getTime()), + size: Number(trade.trade_amount), + transactionHash: trade.tx_hash, + fee: Number(trade.trade_fee), + optionPrice: Number(trade.trade_price), + spot: Number(trade.index_price), + provider: ProviderType.LYRA, + timestamp: trade.timestamp, + date: utcDate, + chain: mapStringToEnum((network as string).toUpperCase(), ChainType), + liquidityRole: mapStringToEnum(trade.liquidity_role.toUpperCase(), LiquidityRole), + premium: Number(trade.trade_amount) * Number(trade.trade_price), + } + + return tradeDto +} +export async function BroadCastTrade( + trade: TradeDto, + twitterClient: TwitterApi, + telegramClient: Telegraf, + discordClient: Client, +): Promise { + if (trade.premium >= Number(TWITTER_THRESHOLD)) { + await SendTweet(TradeTwitter(trade), twitterClient) + } + + if (trade.premium >= Number(TELEGRAM_THRESHOLD)) { + await PostTelegram(TradeTelegram(trade), telegramClient) + } + + if (trade.premium >= Number(DISCORD_THRESHOLD)) { + const embeds = [TradeDiscord(trade)] + const rows: ActionRowBuilder[] = [] + await PostDiscord(embeds, rows, discordClient, TRADE_CHANNEL) + } +} diff --git a/app/src/providers/Lyra/index.ts b/app/src/providers/Lyra/index.ts index 14822b2..dbc67e9 100644 --- a/app/src/providers/Lyra/index.ts +++ b/app/src/providers/Lyra/index.ts @@ -1,73 +1,71 @@ -import { Network, Market } from '@lyrafinance/lyra-js' import { UNIT } from '../../constants/bn' import { OptionsMap, OptionType, ProviderType } from '../../types/arbs' import fromBigNumber from '../../utils/fromBigNumber' -import { getExpirationTerm } from '../../utils/arbUtils' -import getLyraSDK from '../../utils/getLyraSDK' +//import { getExpirationTerm } from '../../utils/arbUtils' import filterNulls from '../../utils/filterNulls' -export async function getMarket(market: Market) { - const options = market.liveBoards().map((board) => { - const expiration = board.expiryTimestamp * 1000 - const term = getExpirationTerm(expiration) +// export async function getMarket(market: Market) { +// const options = market.liveBoards().map((board) => { +// const expiration = board.expiryTimestamp * 1000 +// const term = getExpirationTerm(expiration) - return board.strikes().map(async (strike) => { - try { - if (!strike.isDeltaInRange) { - return - } - const strikePrice = fromBigNumber(strike.strikePrice) - const allQuotes = await strike.quoteAll(UNIT) - const callBuyPrice = fromBigNumber(allQuotes.callAsk.pricePerOption) - const callSellPrice = fromBigNumber(allQuotes.callBid.pricePerOption) - const putBuyPrice = fromBigNumber(allQuotes.putAsk.pricePerOption) - const putSellPrice = fromBigNumber(allQuotes.putBid.pricePerOption) +// return board.strikes().map(async (strike) => { +// try { +// if (!strike.isDeltaInRange) { +// return +// } +// const strikePrice = fromBigNumber(strike.strikePrice) +// const allQuotes = await strike.quoteAll(UNIT) +// const callBuyPrice = fromBigNumber(allQuotes.callAsk.pricePerOption) +// const callSellPrice = fromBigNumber(allQuotes.callBid.pricePerOption) +// const putBuyPrice = fromBigNumber(allQuotes.putAsk.pricePerOption) +// const putSellPrice = fromBigNumber(allQuotes.putBid.pricePerOption) - if ([callBuyPrice, callSellPrice, putBuyPrice, putSellPrice].every((val) => !val)) { - return - } +// if ([callBuyPrice, callSellPrice, putBuyPrice, putSellPrice].every((val) => !val)) { +// return +// } - const instrumentMeta = { - strike: strikePrice, - term, - expiration, - provider: ProviderType.LYRA, - } +// const instrumentMeta = { +// strike: strikePrice, +// term, +// expiration, +// provider: ProviderType.LYRA, +// } - return { - ...instrumentMeta, - [OptionType.CALL]: { - ...instrumentMeta, - type: OptionType.CALL, - askPrice: callBuyPrice, - bidPrice: callSellPrice, - midPrice: (callBuyPrice + callSellPrice) / 2, - }, - [OptionType.PUT]: { - ...instrumentMeta, - type: OptionType.PUT, - askPrice: putBuyPrice, - bidPrice: putSellPrice, - midPrice: (putBuyPrice + putSellPrice) / 2, - }, - } - } catch (error) { - console.log(error) - return - } - }) - }) +// return { +// ...instrumentMeta, +// [OptionType.CALL]: { +// ...instrumentMeta, +// type: OptionType.CALL, +// askPrice: callBuyPrice, +// bidPrice: callSellPrice, +// midPrice: (callBuyPrice + callSellPrice) / 2, +// }, +// [OptionType.PUT]: { +// ...instrumentMeta, +// type: OptionType.PUT, +// askPrice: putBuyPrice, +// bidPrice: putSellPrice, +// midPrice: (putBuyPrice + putSellPrice) / 2, +// }, +// } +// } catch (error) { +// console.log(error) +// return +// } +// }) +// }) - const flatOptions = options?.flat() - const optionsFound = await Promise.all(flatOptions) - const result = filterNulls(optionsFound) as OptionsMap[] - return result -} +// const flatOptions = options?.flat() +// const optionsFound = await Promise.all(flatOptions) +// const result = filterNulls(optionsFound) as OptionsMap[] +// return result +// } -export async function getLyraRates(marketName: string, network: Network): Promise { - console.log(`Getting market ${marketName}`) - const lyra = getLyraSDK(network) - const market = await lyra.market(marketName) - const rates = await getMarket(market) - return rates -} +// export async function getLyraRates(marketName: string, network: Network): Promise { +// console.log(`Getting market ${marketName}`) +// const lyra = getLyraSDK(network) +// const market = await lyra.market(marketName) +// const rates = await getMarket(market) +// return rates +// } diff --git a/app/src/providers/premia/index.ts b/app/src/providers/premia/index.ts index 1d878a2..e19fad7 100644 --- a/app/src/providers/premia/index.ts +++ b/app/src/providers/premia/index.ts @@ -1,71 +1,70 @@ import { BigNumber, Contract } from 'ethers' -import { useExpirations, useStrikes } from '../../utils/arbUtils' +//import { useExpirations, useStrikes } from '../../utils/arbUtils' import { fixedFromFloat, fixedToNumber } from '../../utils/fixedMath' import premiaPoolAbi from './premiaPoolAbi.json' -import { arbitrumProvider } from '../../utils/lyra' import { OptionsMap, OptionType, ProviderType } from '../../types/arbs' import printObject from '../../utils/printObject' -const ethPoolContract = new Contract('0xE5DbC4EDf467B609A063c7ea7fAb976C6b9BAa1a', premiaPoolAbi, arbitrumProvider) +// // const ethPoolContract = new Contract('0xE5DbC4EDf467B609A063c7ea7fAb976C6b9BAa1a', premiaPoolAbi, arbitrumProvider) -const convertPrice = ([price, fee]: [price: BigNumber, fee: BigNumber]) => fixedToNumber(price) + fixedToNumber(fee) +// const convertPrice = ([price, fee]: [price: BigNumber, fee: BigNumber]) => fixedToNumber(price) + fixedToNumber(fee) -const reqOption = async (strike: number, expiration: number, call: boolean) => { - const expSecs = Math.floor(expiration / 1000) +// const reqOption = async (strike: number, expiration: number, call: boolean) => { +// const expSecs = Math.floor(expiration / 1000) - return ethPoolContract - .quote( - '0x0000000000000000000000000000000000000000', - BigNumber.from(expSecs), - fixedFromFloat(strike), - '1000000000000000000', - call, - ) - .then(convertPrice) - .catch(console.error) -} +// return ethPoolContract +// .quote( +// '0x0000000000000000000000000000000000000000', +// BigNumber.from(expSecs), +// fixedFromFloat(strike), +// '1000000000000000000', +// call, +// ) +// .then(convertPrice) +// .catch(console.error) +// } -export async function getPremiaRates(lyraRates?: OptionsMap[]): Promise { - const [expirations] = useExpirations(lyraRates, 1) - console.log(expirations) - const { allStrikes = [], callStrikes = [], putStrikes = [], basePrice = 0 } = useStrikes() +// export async function getPremiaRates(lyraRates?: OptionsMap[]): Promise { +// const [expirations] = useExpirations(lyraRates, 1) +// console.log(expirations) +// const { allStrikes = [], callStrikes = [], putStrikes = [], basePrice = 0 } = useStrikes() - const toEth = (val: number) => basePrice * val - console.log(toEth) +// const toEth = (val: number) => basePrice * val +// console.log(toEth) - if (!(callStrikes && putStrikes && allStrikes)) return undefined +// if (!(callStrikes && putStrikes && allStrikes)) return undefined - const requests = expirations.map(([term, exp]) => - allStrikes.map(async (strike) => { - const instrumentMeta = { - provider: ProviderType.PREMIA, - expiration: exp, - term, - strike: strike, - } +// const requests = expirations.map(([term, exp]) => +// allStrikes.map(async (strike) => { +// const instrumentMeta = { +// provider: ProviderType.PREMIA, +// expiration: exp, +// term, +// strike: strike, +// } - console.log(instrumentMeta) - return { - ...instrumentMeta, - [OptionType.CALL]: callStrikes.includes(strike) - ? { - ...instrumentMeta, - type: OptionType.CALL, - askPrice: await reqOption(strike, exp, true).then(toEth), - } - : undefined, - [OptionType.PUT]: putStrikes.includes(strike) - ? { - ...instrumentMeta, - type: OptionType.PUT, - askPrice: await reqOption(strike, exp, false), - } - : undefined, - } as OptionsMap - }), - ) +// console.log(instrumentMeta) +// return { +// ...instrumentMeta, +// [OptionType.CALL]: callStrikes.includes(strike) +// ? { +// ...instrumentMeta, +// type: OptionType.CALL, +// askPrice: await reqOption(strike, exp, true).then(toEth), +// } +// : undefined, +// [OptionType.PUT]: putStrikes.includes(strike) +// ? { +// ...instrumentMeta, +// type: OptionType.PUT, +// askPrice: await reqOption(strike, exp, false), +// } +// : undefined, +// } as OptionsMap +// }), +// ) - const data = await Promise.all(requests.flat()) - printObject(data) - return data -} +// const data = await Promise.all(requests.flat()) +// printObject(data) +// return data +// } diff --git a/app/src/schedule/index.ts b/app/src/schedule/index.ts index eb15bad..2b537a3 100644 --- a/app/src/schedule/index.ts +++ b/app/src/schedule/index.ts @@ -1,14 +1,7 @@ -import { Network } from '@lyrafinance/lyra-js' import { Client } from 'discord.js' import { scheduleJob } from 'node-schedule' -import { Telegraf } from 'telegraf' -import { TwitterApi } from 'twitter-api-v2' -import { BroadCast } from '../event/broadcast' import { GetPrices } from '../integrations/prices' import { setNameActivityPrice } from '../discord' -import { GetArbitrageDeals } from '../lyra/arbitrage' -import { BroadcastLeaderBoard, FetchLeaderBoard } from '../lyra/leaderboard' -import { GetStats, BroadCastStats } from '../lyra/stats' import { ETH_OP, BTC_OP, ARB_OP, OP_OP, LYRA_OP } from '../constants/contractAddresses' const markets = ['eth', 'btc'] @@ -65,56 +58,56 @@ export function OneMinuteJob( }) } -export function LeaderBoardFillJob(): void { - console.log('On the hour job running') - scheduleJob('* 0 * * *', async () => { - await FetchLeaderBoard() - }) -} +// export function LeaderBoardFillJob(): void { +// console.log('On the hour job running') +// scheduleJob('* 0 * * *', async () => { +// await FetchLeaderBoard() +// }) +// } -export function LeaderboardSendJob( - discordClient: Client, - twitterClient: TwitterApi, - telegramClient: Telegraf, - networks: Network[], -): void { - console.log('Mon Wed Fri leaderboard job') - scheduleJob('0 0 * * 1,3,5', async () => { - networks.map(async (network) => { - await BroadcastLeaderBoard(discordClient, twitterClient, telegramClient, network) - }) - }) -} +// export function LeaderboardSendJob( +// discordClient: Client, +// twitterClient: TwitterApi, +// telegramClient: Telegraf, +// networks: Network[], +// ): void { +// console.log('Mon Wed Fri leaderboard job') +// scheduleJob('0 0 * * 1,3,5', async () => { +// networks.map(async (network) => { +// await BroadcastLeaderBoard(discordClient, twitterClient, telegramClient, network) +// }) +// }) +// } -export function StatsJob( - discordClient: Client, - twitterClient: TwitterApi, - telegramClient: Telegraf, - networks: Network[], -): void { - console.log('Mon Wed Fri Stats job') - scheduleJob('0 1 * * 1,3,5', async () => { - networks.map(async (network) => { - markets.map(async (market) => { - const statsDto = await GetStats(market, network) - await BroadCastStats(statsDto, twitterClient, telegramClient, discordClient, network) - }) - }) - }) -} +// export function StatsJob( +// discordClient: Client, +// twitterClient: TwitterApi, +// telegramClient: Telegraf, +// networks: Network[], +// ): void { +// console.log('Mon Wed Fri Stats job') +// scheduleJob('0 1 * * 1,3,5', async () => { +// networks.map(async (network) => { +// markets.map(async (market) => { +// const statsDto = await GetStats(market, network) +// await BroadCastStats(statsDto, twitterClient, telegramClient, discordClient, network) +// }) +// }) +// }) +// } -export function ArbitrageJob( - discordClient: Client, - twitterClient: TwitterApi, - telegramClient: Telegraf, - networks: Network[], -): void { - scheduleJob('0 4 * * 1,3,5', async () => { - networks.map(async (network) => { - markets.map(async (market) => { - const arbDto = await GetArbitrageDeals(market, network) - await BroadCast(arbDto, twitterClient, telegramClient, discordClient, network) - }) - }) - }) -} +// export function ArbitrageJob( +// discordClient: Client, +// twitterClient: TwitterApi, +// telegramClient: Telegraf, +// networks: Network[], +// ): void { +// scheduleJob('0 4 * * 1,3,5', async () => { +// networks.map(async (network) => { +// markets.map(async (market) => { +// const arbDto = await GetArbitrageDeals(market, network) +// await BroadCast(arbDto, twitterClient, telegramClient, discordClient, network) +// }) +// }) +// }) +// } diff --git a/app/src/templates/arb.ts b/app/src/templates/arb.ts deleted file mode 100644 index 649e0db..0000000 --- a/app/src/templates/arb.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { ActionRowBuilder, ButtonBuilder, EmbedBuilder } from 'discord.js' -import { ArbDto, Arb } from '../types/lyra' -import { ProviderType } from '../types/arbs' -import { FN, FormattedDate, FormattedDateShort, MarketColor, Footer, StatSymbol, getThumb } from './common' -import { Network } from '@lyrafinance/lyra-js' -import { titleCaseWord } from '../utils/utils' - -const deribitUrl = 'https://www.deribit.com/?reg=17349.7477' - -export function ArbTelegram(dto: ArbDto, network: Network) { - const post: string[] = [] - post.push(`${StatSymbol(dto.market)} $${dto.market.toUpperCase()} Arbs Deribit | Lyra\n\n`) - post.push(`⛓️ Network: ${network}\n`) - dto.arbs.slice(0, 10).map((arb) => { - post.push(`✨ $${FN(arb.strike, 0)} ${FormattedDateShort(new Date(arb.expiration))} ${arb.type}\n`) - post.push( - `🔹 Buy $${FN(arb.buy.askPrice as number, 2)} ${ - arb.buy.provider === ProviderType.DERIBIT ? 'DB' : `LYRA ${network}` - }\n`, - ) - post.push( - `🔸 Sell $${FN(arb.sell.bidPrice as number, 2)} ${ - arb.sell.provider === ProviderType.DERIBIT ? 'DB' : `LYRA ${network}` - }\n`, - ) - post.push(`Discount $${FN(arb.amount, 2)} (${FN(arb.discount, 2)}%)\n`) - post.push(`APY ${FN(arb.apy, 2)}%\n\n`) - }) - post.push(`============================\n`) - post.push(`👉 10% Deribit trading discount 👈\n`) - post.push(`============================\n`) - return post.join('') -} - -// TWITTER -export function ArbTwitter(dto: ArbDto, network: Network) { - const post: string[] = [] - post.push(`$${dto.market.toUpperCase()} Arbs Deribit | Lyra\n\n`) - dto.arbs.slice(0, 3).map((arb) => { - post.push(`$${FN(arb.strike, 0)} ${FormattedDateShort(new Date(arb.expiration))} ${arb.type}\n`) - post.push(`⛓️ Network: ${network}\n`) - post.push( - `🔹 Buy $${FN(arb.buy.askPrice as number, 2)} ${ - arb.buy.provider === ProviderType.DERIBIT ? 'DB' : `LYRA ${network}` - }\n🔸 Sell $${FN(arb.sell.bidPrice as number, 2)} ${ - arb.sell.provider === ProviderType.DERIBIT ? 'DB' : `LYRA ${network}` - }\nAPY: ${FN(arb.apy, 2)}%\n\n`, - ) - }) - post.push(`10% trading discount👇\n`) - post.push(`${deribitUrl}\n`) - return post.join('') -} - -// 25 fields // 10 embeds -// DISCORD -export function ArbDiscord(dto: ArbDto, network: Network) { - const embeds: EmbedBuilder[] = [] - const rows: ActionRowBuilder[] = [] - const embed = new EmbedBuilder() - .setColor(`${MarketColor(dto.market)}`) - .setTitle(`$${dto.market.toUpperCase()} Arbitrage: DERIBIT | LYRA`) - const assetThumb = getThumb(dto.market.toLowerCase()) - - if (assetThumb) { - embed.setThumbnail(assetThumb) - } - embed.addFields({ - name: `⛓️ Network`, - value: `> ${titleCaseWord(network)}`, - inline: false, - }) - - dto.arbs.slice(0, 10).map((arb) => { - Arb(arb, dto.market, network, embed) - }) - - // const buttons = new ActionRowBuilder().addComponents( - // new ButtonBuilder().setCustomId('arb-deribit1').setLabel('Arb Deribit 1').setStyle(ButtonStyle.Primary), - // new ButtonBuilder().setCustomId('arb-deribit2').setLabel('Arb Deribit 2').setStyle(ButtonStyle.Danger), - // new ButtonBuilder().setLabel('Arb Deribit 3').setStyle(ButtonStyle.Link).setURL(deribitUrl), - // new ButtonBuilder().setCustomId('arb-deribit4').setLabel('Arb Deribit 4').setStyle(ButtonStyle.Secondary), - // new ButtonBuilder().setCustomId('arb-deribit5').setLabel('Arb Deribit 5').setStyle(ButtonStyle.Success), - // ) - - Footer(embed) - embeds.push(embed) - //rows.push(buttons) - - return { embeds, rows } -} - -function Arb(dto: Arb, market: string, network: Network, embed: EmbedBuilder) { - embed.addFields({ - name: `✨ $${FN(dto.strike, 0)} ${FormattedDate(new Date(dto.expiration))} ${dto.type}`, - value: `> 🔹 **Buy** [$${FN(dto.buy.askPrice as number, 2)} ${dto.buy.provider}](${ProviderUrl( - dto.buy.provider, - market, - network, - )})\n > 🔸 **Sell** [$${FN(dto.sell.bidPrice as number, 2)} ${dto.sell.provider}](${ProviderUrl( - dto.sell.provider, - market, - network, - )})\n > **Discount** $${FN(dto.amount, 2)} (${FN(dto.discount, 2)}%)\n > **APY** ${FN(dto.apy, 2)}%`, - inline: false, - }) -} - -function ProviderUrl(provider: ProviderType, market: string, network: Network) { - if (provider === ProviderType.DERIBIT) { - return deribitUrl - } - - return `https://app.lyra.finance/#/trade/${network}/${market}` -} diff --git a/app/src/templates/common.ts b/app/src/templates/common.ts index da4b90b..4e8584b 100644 --- a/app/src/templates/common.ts +++ b/app/src/templates/common.ts @@ -1,4 +1,3 @@ -import { Network } from '@lyrafinance/lyra-js' import dayjs from 'dayjs' import dayjsPluginUTC from 'dayjs/plugin/utc' import { EmbedBuilder } from 'discord.js' @@ -17,7 +16,7 @@ import { OP_OPTION_MARKET_OP, } from '../constants/contractAddresses' import { AssetType, bannerUrls, iconUrls, thumbUrls } from '../constants/urls' -import { TradeDto, TraderAddress } from '../types/lyra' +import { TradeDto, TraderAddress } from '../types/trade' import { shortAddress } from '../utils/utils' export const zapperUrl = 'https://zapper.xyz/account/' @@ -40,10 +39,7 @@ export function Medal(position: number): string { return '🏅' } -export function AmountWording(isLong: boolean, isOpen: boolean, isLiquidation: boolean): string { - if (isLiquidation) { - return 'Amount' - } +export function AmountWording(isLong: boolean, isOpen: boolean): string { const paid = 'Premium Paid' const received = "Premium Rec'd" @@ -54,13 +50,9 @@ export function AmountWording(isLong: boolean, isOpen: boolean, isLiquidation: b return isLong ? received : paid } -export function VaultLink(market: string, network: Network) { - return `${LyraDappUrl()}/#/vaults/${network}/${market.toLowerCase()}` -} - -export function PositionLink(trade: TradeDto, network: Network): string { - return `${LyraDappUrl()}/#/position/${network}/${trade.market.toLowerCase()}/${trade.positionId}?see=${trade.account}` -} +// export function PositionLink(trade: TradeDto, network: Network): string { +// return `${LyraDappUrl()}/#/position/${network}/${trade.market.toLowerCase()}/${trade.positionId}?see=${trade.account}` +// } export function PortfolioLink(account: string) { return `${LyraDappUrl()}/#/portfolio?see=${account}` @@ -93,36 +85,16 @@ export function getThumb(market: string): string | undefined { return undefined } -export function ExpiryLink(market: string, network: Network, date: string) { - return `${LyraDappUrl()}/#/trade/${network}/${market.toLowerCase()}?expiry=${date}` -} - export function TradeHistoryLink(trade: TraderAddress) { return `${LyraDappUrl()}/#/portfolio/history?see=${trade.account}` } -export function BlockExplorerLink(transactionHash: string, network: Network, mainnet = false) { - if (mainnet) { - return `https://etherscan.io/tx/${transactionHash}` - } - - if (network == Network.Arbitrum) { - return `https://arbiscan.io/tx/${transactionHash}` - } - - return `https://optimistic.etherscan.io/tx/${transactionHash}` +export function TransactionLink(transactionHash: string) { + return `https://explorer.lyra.finance/tx/${transactionHash}` } -export function BlockExplorerAddress(address: string, network: Network, mainnet = false) { - if (mainnet) { - return `https://etherscan.io/address/${address}` - } - - if (network == Network.Arbitrum) { - return `https://arbiscan.io/address/${address}` - } - - return `https://optimistic.etherscan.io/address/${address}` +export function TraderLink(account: string) { + return `https://explorer.lyra.finance/address/${account}` } export function FormattedDate(date: Date) { @@ -144,10 +116,6 @@ export const LyraDappUrl = () => { return 'https://app.lyra.finance' } -export function TradeShareImage(trade: TradeDto) { - return `${LyraDappUrl()}/position/image/${trade.asset}/${trade.positionId}` -} - export function FN(value: number, decimals: number) { return value.toLocaleString('en-US', { minimumFractionDigits: decimals, @@ -214,13 +182,13 @@ export function GetMarket(address: string) { return market } -export function DisplayTrader(trade: TraderAddress, useShortAddress = false) { - if (trade.isNotable) { - return trade.notableAddress - } - if (trade.ens) { - return `👨‍ ${trade.ens}` - } +export function DisplayTrader(trade: TradeDto, useShortAddress = false) { + // if (trade.isNotable) { + // return trade.notableAddress + // } + // if (trade.ens) { + // return `👨‍ ${trade.ens}` + // } if (useShortAddress) { return `👨‍ ${shortAddress(trade.account)}` } @@ -239,8 +207,9 @@ export function DisplayTraderNoEmoji(trade: TraderAddress) { return `${trade.account}` } -export function MarketColor(marketName: string) { +export function MarketColor() { return '#1AF7C0' + const marketName = '' if ( marketName.toLowerCase() == 'eth' || marketName.toLowerCase() == 'seth-susd' || @@ -262,26 +231,3 @@ export function MarketColor(marketName: string) { return '#FF0420' } } - -export function StatSymbol(marketName: string) { - if ( - marketName.toLowerCase() == 'eth' || - marketName.toLowerCase() == 'seth-susd' || - marketName.toLowerCase() == 'eth-usdc' - ) { - return '🔷' - } - if ( - marketName.toLowerCase() == 'btc' || - marketName.toLowerCase() == 'sbtc-susd' || - marketName.toLowerCase() == 'wbtc-usdc' - ) { - return '🔶' - } - if (marketName.toLowerCase() == 'op' || marketName.toLowerCase() == 'op-usdc') { - return '🔴' - } - if (marketName.toLowerCase() == 'arb' || marketName.toLowerCase() == 'arb-usdc') { - return '🟦' - } -} diff --git a/app/src/templates/deposit.ts b/app/src/templates/deposit.ts deleted file mode 100644 index b49e849..0000000 --- a/app/src/templates/deposit.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { EmbedBuilder } from 'discord.js' -import { DepositDto } from '../types/lyra' -import formatUSD from '../utils/formatUSD' -import { - DisplayTrader, - DisplayTraderNoEmoji, - BlockExplorerLink, - LyraDappUrl, - StatSymbol, - Footer, - PortfolioLink, - MarketColor, - getThumb, -} from './common' -import { titleCaseWord } from '../utils/utils' - -export function DepositTwitter(dto: DepositDto, network: Network) { - const post: string[] = [] - post.push(`💵 ${formatUSD(dto.amount)} Deposit\n\n`) - post.push(`from ${DisplayTrader(dto)}\n`) - post.push(`to ${StatSymbol(dto.market)} ${dto.market} Market Vault\n\n`) - if (dto.totalQueued > 0) { - post.push(`🏦 Total queued: ${formatUSD(dto.totalQueued)}\n`) - } - post.push(`\nOptions for everyone, start trading 👇\n`) - post.push(`${LyraDappUrl()}`) - return post.join('') -} - -export function DepositDiscord(dto: DepositDto, network: Network): EmbedBuilder[] { - const embeds: EmbedBuilder[] = [] - const embed = new EmbedBuilder() - .setColor(`${MarketColor(dto.market)}`) - .setURL(`${BlockExplorerLink(dto.transactionHash, network)}`) - .setTitle(`Deposit: ${dto.market} Market Vault`) - .addFields( - { - name: `⛓️ Network`, - value: `> ${titleCaseWord(network)}`, - inline: false, - }, - { - name: `💵 Amount:`, - value: `> ${formatUSD(dto.value)}`, - inline: false, - }, - { - name: `From:`, - value: `> [${DisplayTraderNoEmoji(dto)}](${PortfolioLink(dto.account)})`, - inline: false, - }, - ) - - if (dto.totalQueued > 0) { - embed.addFields({ - name: `🏦 Total Queued:`, - value: `> ${formatUSD(dto.value)}`, - inline: false, - }) - } - - const assetThumb = getThumb(dto.asset.toLowerCase()) - - if (assetThumb) { - embed.setThumbnail(assetThumb) - } - Footer(embed) - embeds.push(embed) - return embeds -} diff --git a/app/src/templates/leaderboard.ts b/app/src/templates/leaderboard.ts deleted file mode 100644 index c3281a7..0000000 --- a/app/src/templates/leaderboard.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { EmbedBuilder } from 'discord.js' -import { bannerUrls } from '../constants/urls' -import { Trader } from '../types/lyra' -import formatUSD from '../utils/formatUSD' -import { DisplayTrader, LyraDappUrl, Medal, Footer, PortfolioLink } from './common' -import { titleCaseWord } from '../utils/utils' - -export function LeaderboardDiscord(leaderBoard: Trader[], network: Network): EmbedBuilder[] { - const messageEmbeds: EmbedBuilder[] = [] - - const tradeEmbed = new EmbedBuilder() - .setColor('#0099ff') - .setTitle(`Top ${leaderBoard.length} Profitable Traders ${titleCaseWord(network)}`) - .addFields( - { name: 'Trader', value: '-------------', inline: true }, - { name: `\u200b`, value: '-------------', inline: true }, - { name: '💵 Profit', value: '-------------', inline: true }, - ) - - leaderBoard.slice(0, 5).map((trader) => { - return leaderBoardRow(tradeEmbed, trader) - }) - messageEmbeds.push(tradeEmbed) - - const traders: Trader[] = [] - - // skip 5 until end - leaderBoard.slice(5).reduce((group, trader, index) => { - group.push(trader) - if (index % 5 === 4) { - const embed = new EmbedBuilder().setColor('#0099ff') - - group.map((trader) => { - return leaderBoardRow(embed, trader) - }) - messageEmbeds.push(embed) - group = [] - } - return group - }, traders) - - messageEmbeds.map((embed) => embed.setImage(bannerUrls.spacer)) - - if (messageEmbeds.length > 0) { - const embedLast = messageEmbeds.pop() - if (embedLast) { - Footer(embedLast) - messageEmbeds.push(embedLast) - } - } - return messageEmbeds -} - -export function leaderBoardRow(tradeEmbed: EmbedBuilder, trader: Trader): EmbedBuilder { - return tradeEmbed.addFields( - { - name: `${Medal(trader.position)} ${trader.position}.`, - value: `${DisplayTrader(trader, true)}`, - inline: true, - }, - { - name: `Open Trade`, - value: `${trader.unrealizedPnl != 0 ? '✅' : '❌'}`, - inline: true, - }, - { - name: `${formatUSD(trader.realizedPnl)}`, - value: `[view account](${PortfolioLink(trader.account)})`, - inline: true, - }, - ) -} - -export function LeaderboardTwitter(leaderBoard: Trader[]) { - const post: string[] = [] - post.push(`✅ Top 5 Lyra Profitable Traders 💵 💰 🤑\n`) - leaderBoard.slice(0, 5).map((trader) => { - post.push( - `${Medal(trader.position)} ${trader.position}. ${DisplayTrader(trader, false)} 💵 ${formatUSD( - trader.realizedPnl, - )}\n`, - ) - }) - post.push(`\nOptions for everyone, start trading 👇\n`) - post.push(`${LyraDappUrl()}`) - return post.join('') -} - -export function LeaderboardTelegram(leaderBoard: Trader[]) { - const post: string[] = [] - post.push(`✅ Top 10 Lyra Traders 💵 💰 🤑\n`) - post.push(`============================\n`) - leaderBoard.slice(0, 10).map((trader) => { - post.push( - `${Medal(trader.position)} ${trader.position}. ${DisplayTrader( - trader, - false, - )} ${formatUSD(trader.realizedPnl)}\n`, - ) - }) - post.push(`============================\n`) - return post.join('') -} diff --git a/app/src/templates/stats.ts b/app/src/templates/stats.ts deleted file mode 100644 index 88657d6..0000000 --- a/app/src/templates/stats.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { EmbedBuilder } from 'discord.js' -import { VaultStats } from '../types/lyra' -import fromBigNumber from '../utils/fromBigNumber' -import { FN, FNS, MarketColor, Footer, StatSymbol, VaultLink, getThumb } from './common' -import { titleCaseWord } from '../utils/utils' - -export function StatDiscord(stat: VaultStats, network: Network): EmbedBuilder[] { - const messageEmbeds: EmbedBuilder[] = [] - const tradeEmbed = new EmbedBuilder() - .setColor(`${MarketColor(stat.market.name)}`) - .setURL(`${VaultLink(stat.market.name, network)}`) - .setTitle(`${stat.market.name} Market Vault`) - .addFields( - { name: `⛓️ Network`, value: `> ${titleCaseWord(network)}`, inline: true }, - { name: '🏦 TVL', value: `> $${FN(stat.tvl, 0)}`, inline: true }, - { name: '💸 TVL Change', value: `> ${FNS(stat.tvlChange * 100, 2)}%`, inline: true }, - { name: `📊 Volume 30d`, value: `> $${FN(stat.totalNotionalVolume, 2)}`, inline: true }, - { name: '🪙 Token Value', value: `> $${FN(stat.tokenPrice, 4)}`, inline: true }, - { name: `💰 Fees 30d`, value: `> $${FN(stat.totalFees, 2)}`, inline: true }, - { name: '📈 Open Inter.', value: `> $${FN(stat.openInterest, 2)}`, inline: true }, - { name: '💵 Annual Perf', value: `> ${FNS(stat.tokenPriceChangeAnnualized * 100, 2)}%`, inline: true }, - { name: '🧮 Net Delta', value: `> ${FNS(fromBigNumber(stat.netGreeks.netDelta), 3)}`, inline: true }, - { name: '〽️ Net Vega', value: `> ${FNS(fromBigNumber(stat.netGreeks.netStdVega), 3)}`, inline: true }, - { name: '🔒 Utilization', value: `> ${FN(stat.liquidity.utilization * 100, 2)}%`, inline: true }, - { - name: '📥 Deposits', - value: `> $${FN(fromBigNumber(stat.liquidity.pendingDeposits), 2)}`, - inline: true, - }, - { - name: '📤 Withdrawals', - value: `> $${FN(fromBigNumber(stat.liquidity.pendingWithdrawals), 2)}`, - inline: true, - }, - ) - const assetThumb = getThumb(stat.asset.toLowerCase()) - - if (assetThumb) { - tradeEmbed.setThumbnail(assetThumb) - } - Footer(tradeEmbed) - messageEmbeds.push(tradeEmbed) - return messageEmbeds -} - -export function StatTwitter(stat: VaultStats, network: Network) { - const post: string[] = [] - post.push(`${StatSymbol(stat.market.name)} ${stat.market.name} Market Vault\n`) - post.push(`⛓️ Network: ${titleCaseWord(network)}\n`) - post.push(`💵 30d Perf (Annualized) ${FNS(stat.tokenPriceChangeAnnualized * 100, 4)}%\n`) - post.push(`🏦 TVL $${FN(stat.tvl, 0)}\n`) - post.push(`📊 Volume (30d) $${FN(stat.totalNotionalVolume, 2)}\n`) - post.push(`🪙 Token Value $${FN(stat.tokenPrice, 4)}\n`) - post.push(`💰 Fees (30d) $${FN(stat.totalFees, 2)}\n`) - post.push(`📈 Open Interest $${FN(stat.openInterest, 2)}\n`) - post.push(`🔒 Utilization ${FN(stat.liquidity.utilization * 100, 2)}%\n`) - post.push(`\nOptions for everyone, start trading 👇\n`) - post.push(`${VaultLink(stat.market.name, network)}\n`) - return post.join('') -} - -export function StatTelegram(stat: VaultStats, network: Network) { - const post: string[] = [] - post.push( - `${StatSymbol(stat.market.name)} ${ - stat.market.name - } Market Vault\n`, - ) - post.push(`⛓️ Network: ${titleCaseWord(network)}\n`) - post.push(`💵 30d Perf (Annualized) ${FNS(stat.tokenPriceChangeAnnualized, 4)}%\n`) - post.push(`🏦 TVL $${FN(stat.tvl, 0)}\n`) - post.push(`📊 Volume (30d) $${FN(stat.totalNotionalVolume, 2)}\n`) - post.push(`🪙 Token Value $${FN(stat.tokenPrice, 4)}\n`) - post.push(`💰 Fees (30d) $${FN(stat.totalFees, 2)}\n`) - post.push(`📈 Open Interest $${FN(stat.openInterest, 2)}\n`) - post.push(`🧮 Net Delta ${FNS(fromBigNumber(stat.netGreeks.netDelta), 3)}\n`) - post.push(`〽️ Net Std. Vega ${FNS(fromBigNumber(stat.netGreeks.netStdVega), 3)}\n`) - post.push(`🔒 Utilization ${FN(stat.liquidity.utilization * 100, 2)}%\n`) - return post.join('') -} diff --git a/app/src/templates/strike.ts b/app/src/templates/strike.ts index e7a3f49..3c907da 100644 --- a/app/src/templates/strike.ts +++ b/app/src/templates/strike.ts @@ -1,66 +1,65 @@ -import { Network } from '@lyrafinance/lyra-js' import { EmbedBuilder } from 'discord.js' -import { BoardDto } from '../types/lyra' +import { BoardDto } from '../types/trade' import formatUSD from '../utils/formatUSD' import { titleCaseWord } from '../utils/utils' -import { ExpiryLink, FormattedDate, MarketColor, Footer, StatSymbol, getThumb } from './common' +import { FormattedDate, MarketColor, Footer, StatSymbol, getThumb } from './common' -// TWITTER -export function BoardTwitter(dto: BoardDto, network: Network) { - const post: string[] = [] - post.push(`New strike${dto.strikes.length > 1 ? 's' : ''} listed!\n`) - post.push(`${dto.market} Market\n`) - post.push(`${titleCaseWord(network)}\n`) - post.push(`⏰ Exp ${FormattedDate(dto.expiry)}\n\n`) - dto.strikes.map((strike) => { - post.push(`🎯 ${formatUSD(strike.strikePrice)}\n`) - }) - post.push(`\nOptions for everyone, start trading 👇\n`) - post.push(`${ExpiryLink(dto.market, network, dto.expiryString)}`) - return post.join('') -} +// // TWITTER +// export function BoardTwitter(dto: BoardDto, network: Network) { +// const post: string[] = [] +// post.push(`New strike${dto.strikes.length > 1 ? 's' : ''} listed!\n`) +// post.push(`${dto.market} Market\n`) +// post.push(`${titleCaseWord(network)}\n`) +// post.push(`⏰ Exp ${FormattedDate(dto.expiry)}\n\n`) +// dto.strikes.map((strike) => { +// post.push(`🎯 ${formatUSD(strike.strikePrice)}\n`) +// }) +// post.push(`\nOptions for everyone, start trading 👇\n`) +// post.push(`${ExpiryLink(dto.market, network, dto.expiryString)}`) +// return post.join('') +// } -// TELEGRAM -export function BoardTelegram(dto: BoardDto, network: Network) { - const post: string[] = [] - post.push(`New strike${dto.strikes.length > 1 ? 's' : ''} listed!\n`) - post.push(`${StatSymbol(dto.market)} ${dto.market} Market\n`) - post.push(`${titleCaseWord(network)}\n`) - post.push(`⏰ Exp ${FormattedDate(dto.expiry)}\n\n`) - dto.strikes.map((strike) => { - post.push(`🎯 ${formatUSD(strike.strikePrice)}\n`) - }) - post.push(`\nOptions for everyone, start trading 👇\n`) - post.push(`Open trade`) - return post.join('') -} +// // TELEGRAM +// export function BoardTelegram(dto: BoardDto, network: Network) { +// const post: string[] = [] +// post.push(`New strike${dto.strikes.length > 1 ? 's' : ''} listed!\n`) +// post.push(`${StatSymbol(dto.market)} ${dto.market} Market\n`) +// post.push(`${titleCaseWord(network)}\n`) +// post.push(`⏰ Exp ${FormattedDate(dto.expiry)}\n\n`) +// dto.strikes.map((strike) => { +// post.push(`🎯 ${formatUSD(strike.strikePrice)}\n`) +// }) +// post.push(`\nOptions for everyone, start trading 👇\n`) +// post.push(`Open trade`) +// return post.join('') +// } -// DISCORD -export function BoardDiscord(dto: BoardDto, network: Network): EmbedBuilder[] { - const embeds: EmbedBuilder[] = [] - const embed = new EmbedBuilder() - .setColor(MarketColor(dto.asset)) - .setURL(`${ExpiryLink(dto.market, network, dto.expiryString)}`) - .setTitle(`Strike${dto.strikes.length > 1 ? 's' : ''}: ${dto.market} Market | ${FormattedDate(dto.expiry)}`) - embed.addFields({ - name: `⛓️ Network`, - value: `> ${titleCaseWord(network)}`, - inline: false, - }) - const assetThumb = getThumb(dto.asset.toLowerCase()) +// // DISCORD +// export function BoardDiscord(dto: BoardDto, network: Network): EmbedBuilder[] { +// const embeds: EmbedBuilder[] = [] +// const embed = new EmbedBuilder() +// .setColor(MarketColor()) +// .setURL(`${ExpiryLink(dto.market, network, dto.expiryString)}`) +// .setTitle(`Strike${dto.strikes.length > 1 ? 's' : ''}: ${dto.market} Market | ${FormattedDate(dto.expiry)}`) +// embed.addFields({ +// name: `⛓️ Network`, +// value: `> ${titleCaseWord(network)}`, +// inline: false, +// }) +// const assetThumb = getThumb(dto.asset.toLowerCase()) - if (assetThumb) { - embed.setThumbnail(assetThumb) - } - dto.strikes.map((strike) => { - embed.addFields({ - name: `🎯 ${formatUSD(strike.strikePrice)}`, - value: `> ----------`, - inline: false, - }) - }) +// if (assetThumb) { +// embed.setThumbnail(assetThumb) +// } +// dto.strikes.map((strike) => { +// embed.addFields({ +// name: `🎯 ${formatUSD(strike.strikePrice)}`, +// value: `> ----------`, +// inline: false, +// }) +// }) - Footer(embed) - embeds.push(embed) - return embeds -} +// Footer(embed) +// embeds.push(embed) +// return embeds +// } diff --git a/app/src/templates/trade.ts b/app/src/templates/trade.ts index 30062f6..a9f570c 100644 --- a/app/src/templates/trade.ts +++ b/app/src/templates/trade.ts @@ -1,200 +1,56 @@ -import { TradeDto } from '../types/lyra' +import { TradeDto } from '../types/trade' import { EmbedBuilder } from 'discord.js' -import { - AmountWording, - DisplayTrader, - DisplayTraderNoEmoji, - BlockExplorerLink, - FN, - FormattedDate, - Medal, - Footer, - PortfolioLink, - PositionLink, - ShowProfitAndLoss, - TradeHistoryLink, - TradeShareImage, - TwitterLink, - MarketColor, - BlockExplorerAddress, - getThumb, -} from './common' -import { Network } from '@lyrafinance/lyra-js' -import formatUSD from '../utils/formatUSD' -import { titleCaseWord } from '../utils/utils' +import { DisplayTrader, TransactionLink, FN, Footer, MarketColor, getThumb, TraderLink } from './common' +import { shortAddress } from '../utils/utils' -export function TradeTwitter(trade: TradeDto, network: Network) { +export function TradeTwitter(trade: TradeDto) { const post: string[] = [] - - if (!trade.isLiquidation) { - post.push( - `📈 ${trade.isLong ? 'Long' : 'Short'} ${trade.size} $${trade.asset} $${FN(trade.strike, 0)} ${ - trade.isCall ? 'Call' : 'Put' - }\n`, - ) - post.push(`${trade.isOpen ? '✅ Opened' : '🚫 Closed'}\n`) - post.push(`💵 ${AmountWording(trade.isLong, trade.isOpen, trade.isLiquidation)} ${trade.premiumFormatted}\n`) - if (trade.setCollateralTo != undefined) { - post.push(`💰 Collateral ${trade.baseCollateralFormatted}\n`) - } - } else { - post.push(`🔥 Liquidation ${trade.size} $${trade.asset} $${FN(trade.strike, 0)} ${trade.isCall ? 'Call' : 'Put'}\n`) - post.push(`💵 Amount ${trade.premiumFormatted}\n`) - post.push(`🔥 LP Fees $${trade.lpFees?.toFixed(2)}\n`) - } - post.push(`⛓️ Network: ${network}\n`) - post.push(`⚡ IV ${FN(trade.iv, 2)}%\n`) - post.push(`⏰ Exp ${FormattedDate(trade.expiry)}\n`) - if (ShowProfitAndLoss(trade.positionTradeCount, trade.pnl)) { - post.push( - `${trade.isProfitable ? '🟢' : '🔴'} ${trade.pnlFormatted} ${trade.pnlPercentFormatted} ${ - trade.isProfitable ? 'Profit' : 'Loss' - }\n`, - ) - } - if (trade.leaderBoard.account !== '') { - post.push( - `${Medal(trade.leaderBoard.position)} ${trade.leaderBoard.position}. Trader ${formatUSD( - trade.leaderBoard.realizedPnl, - )}\n`, - ) - } - post.push(`${DisplayTrader(trade)}\n`) - post.push(`${PositionLink(trade, network)}\n`) - if (trade.url) { - post.push(`${trade.url}\n`) - } + post.push(`📈 ${trade.isBuy ? 'BUY' : 'SELL'} ${trade.instrument}\n`) + post.push(`💰 Size ${trade.size}\n`) + post.push(`💵 Premium $${FN(trade.premium, 2)}\n`) + post.push(`💸 Fees $${FN(trade.fee, 2)}\n`) + post.push(`${DisplayTrader(trade, true)}\n\n`) + post.push(`#lyra #options #trading $BTC $ETH \n\n`) + post.push(`Start trading on Lyra 👇\n`) + post.push(`https://v2.lyra.finance`) return post.join('') } -export function TradeTelegram(trade: TradeDto, network: Network) { - //const img = TradeShareImage(trade) +export function TradeTelegram(trade: TradeDto) { const post: string[] = [] - if (!trade.isLiquidation) { - post.push( - `📈 ${trade.isLong ? 'Long' : 'Short'} ${trade.size} $${trade.asset} $${FN(trade.strike, 0)} ${ - trade.isCall ? 'Call' : 'Put' - }\n`, - ) - post.push(`${trade.isOpen ? '✅ Opened' : '🚫 Closed'}\n`) - post.push(`💵 ${AmountWording(trade.isLong, trade.isOpen, trade.isLiquidation)} ${trade.premiumFormatted}\n`) - if (trade.setCollateralTo != undefined) { - post.push(`💰 Collateral ${trade.baseCollateralFormatted}\n`) - } - } else { - post.push(`🔥 Liquidation ${trade.size} $${trade.asset} $${FN(trade.strike, 0)} ${trade.isCall ? 'Call' : 'Put'}\n`) - post.push(`💵 Amount ${trade.premiumFormatted}\n`) - post.push(`🔥 LP Fees $${trade.lpFees?.toFixed(2)}\n`) - } - post.push(`⛓️ Network: ${network}\n`) - post.push(`⚡ IV ${FN(trade.iv, 2)}%\n`) - post.push(`⏰ Exp ${FormattedDate(trade.expiry)}\n`) - if (ShowProfitAndLoss(trade.positionTradeCount, trade.pnl)) { - post.push( - `${trade.isProfitable ? '🟢' : '🔴'} ${trade.pnlFormatted} ${trade.pnlPercentFormatted} ${ - trade.isProfitable ? 'Profit' : 'Loss' - }\n`, - ) - } - if (trade.leaderBoard.account !== '') { - post.push( - `${Medal(trade.leaderBoard.position)} #${trade.leaderBoard.position} Trader ${formatUSD( - trade.leaderBoard.realizedPnl, - )}\n`, - ) - } - if (trade.fren && trade.fren.name) { - post.push(`🐦 ${trade.fren.name}\n`) - } - if (trade.url) { - post.push(`Go to Vault\n`) - } - post.push(`${DisplayTrader(trade, true)}\n`) + post.push(`📈 ${trade.isBuy ? 'BUY' : 'SELL'} ${trade.instrument}\n`) + post.push(`💰 Size ${trade.size}\n`) + post.push(`💵 Premium $${FN(trade.premium, 2)}\n`) + post.push(`💸 Fees $${FN(trade.fee, 2)}\n`) + post.push(`${DisplayTrader(trade, true)}\n`) post.push(`============================\n`) - post.push( - `Trxn | History | Portfolio | Position\n`, - ) + post.push(`Transaction\n`) post.push(`============================\n`) - // post.push(``) return post.join('') } -export function TradeDiscord(trade: TradeDto, network: Network): EmbedBuilder { - const url = PositionLink(trade, network) - const tradeEmbed = new EmbedBuilder().setURL(`${url}`) - const assetThumb = getThumb(trade.asset.toLowerCase()) +export function TradeDiscord(trade: TradeDto): EmbedBuilder { + const tradeEmbed = new EmbedBuilder() + const assetThumb = getThumb((trade.market as string).toLowerCase()) if (assetThumb) { tradeEmbed.setThumbnail(assetThumb) } - - let decimals = 0 - - if (trade.asset == 'OP' || trade.asset == 'ARB') { - decimals = 2 - } - - if (!trade.isLiquidation) { - tradeEmbed - .setTitle( - `${trade.isOpen ? '✅ Opened:' : '🚫 Closed:'} ${trade.isLong ? 'Long' : 'Short'} ${trade.size} ${ - trade.asset - } $${FN(trade.strike, decimals)} ${trade.isCall ? 'Call' : 'Put'}`, - ) - .setColor(`${MarketColor(trade.market)}`) - } else { - tradeEmbed - .setTitle(`🔥 Liquidation ${trade.size} $${trade.asset} $${FN(trade.strike, 0)} ${trade.isCall ? 'Call' : 'Put'}`) - .setColor('#ffa500') - } - + tradeEmbed + .setTitle(`${trade.isBuy ? 'BUY' : 'SELL'} ${trade.size} | ${trade.instrument}`) + .setColor(`${MarketColor()}`) tradeEmbed.addFields( { - name: `🪙 Market`, - value: `> ${trade.market}`, - inline: false, - }, - { - name: `⏰ Expiry`, - value: `> ${FormattedDate(trade.expiry)}`, - inline: false, - }, - { - name: `💵 ${AmountWording(trade.isLong, trade.isOpen, trade.isLiquidation)}`, - value: `> ${trade.premiumFormatted}`, + name: `💵 Premium`, + value: `> $${FN(trade.premium, 2)}`, inline: false, }, - { - name: `⛓️ Network`, - value: `> ${titleCaseWord(network)}`, - inline: false, - }, - ) - - if (trade.setCollateralTo != undefined && trade.setCollateralTo > 0) { - tradeEmbed.addFields({ - name: `💰 Collateral`, - value: `> ${trade.baseCollateralFormatted}`, - inline: false, - }) - } - - tradeEmbed.addFields( { name: `🏷️ Prices`, value: `> Option: $${FN(trade.optionPrice, 2)}\n > Spot: $${FN(trade.spot, 2)}`, inline: false, }, - { - name: `⚡ IV`, - value: `> ${FN(trade.iv, 2)}%`, - inline: false, - }, + { name: `💸 Fees`, value: `> $${FN(trade.fee, 2)}`, @@ -202,42 +58,11 @@ export function TradeDiscord(trade: TradeDto, network: Network): EmbedBuilder { }, { name: '👨 Trader', - value: `> [${DisplayTraderNoEmoji(trade)}](${BlockExplorerAddress(trade.account, network)})`, + value: `> [${shortAddress(trade.account)}](${TraderLink(trade.account)})`, inline: false, }, ) - if (ShowProfitAndLoss(trade.positionTradeCount, trade.pnl)) { - tradeEmbed.addFields({ - name: `${trade.isProfitable ? '🟢' : '🔴'} ${trade.isProfitable ? 'Profit' : 'Loss'}`, - value: `> ${trade.pnlFormatted} ${trade.pnlPercentFormatted}`, - inline: false, - }) - } - - if (trade.leaderBoard.account !== '') { - tradeEmbed.addFields({ - name: `${Medal(trade.leaderBoard.position)} Leaderboard`, - value: `> #${trade.leaderBoard.position} ${formatUSD(trade.leaderBoard.realizedPnl)}`, - inline: false, - }) - } - - if (trade.fren && trade.fren.name) { - tradeEmbed.addFields({ - name: `🐦 ${trade.fren.name}`, - value: `> [view twitter profile](${TwitterLink(trade.fren.handle)})`, - inline: false, - }) - if (trade.fren.pfp) { - tradeEmbed.setThumbnail(`${trade.fren.pfp}`) - } - } - - if (trade.url) { - tradeEmbed.addFields({ name: '🏦 Vault', value: `> [deposit into vault](${trade.url})`, inline: false }) - } - Footer(tradeEmbed) return tradeEmbed } diff --git a/app/src/templates/trader.ts b/app/src/templates/trader.ts index 6f22838..b2b8079 100644 --- a/app/src/templates/trader.ts +++ b/app/src/templates/trader.ts @@ -1,5 +1,5 @@ import { EmbedBuilder } from 'discord.js' -import { Trader } from '../types/lyra' +import { Trader } from '../types/trade' import formatUSD from '../utils/formatUSD' import { DisplayTraderNoEmoji, FNS, Medal, PortfolioLink, TwitterLink } from './common' import formatNumber from '../utils/formatNumber' diff --git a/app/src/templates/transfer.ts b/app/src/templates/transfer.ts index 8ef2202..b3acad9 100644 --- a/app/src/templates/transfer.ts +++ b/app/src/templates/transfer.ts @@ -1,47 +1,46 @@ -import { Network } from '@lyrafinance/lyra-js' import { EmbedBuilder } from 'discord.js' -import { TransferDto } from '../types/lyra' +import { TransferDto } from '../types/trade' import formatUSD from '../utils/formatUSD' -import { BlockExplorerAddress, BlockExplorerLink, FN, LyraDappUrl, Footer } from './common' +import { BlockExplorerLink, FN, LyraDappUrl, Footer } from './common' import { titleCaseWord } from '../utils/utils' // TWITTER -export function TransferTwitter(dto: TransferDto, network: Network) { - const post: string[] = [] - post.push(`${FN(dto.amount, 2)} $${dto.token} (${formatUSD(dto.value)}) transfer \n\n`) - post.push(`from ${dto.fromEns ? dto.fromEns : dto.notableFrom ? dto.from : '🧑 ' + dto.fromAddress}\n`) - post.push(`to ${dto.toEns ? dto.toEns : dto.notableTo ? dto.to : '🧑 ' + dto.toAddress}\n\n`) - post.push(`🔗 ${BlockExplorerLink(dto.transactionHash, network)}\n\n`) - post.push(`\nOptions for everyone, start trading 👇\n`) - post.push(`${LyraDappUrl()}`) - return post.join('') -} +// export function TransferTwitter(dto: TransferDto, network: string) { +// const post: string[] = [] +// post.push(`${FN(dto.amount, 2)} $${dto.token} (${formatUSD(dto.value)}) transfer \n\n`) +// post.push(`from ${dto.fromEns ? dto.fromEns : dto.notableFrom ? dto.from : '🧑 ' + dto.fromAddress}\n`) +// post.push(`to ${dto.toEns ? dto.toEns : dto.notableTo ? dto.to : '🧑 ' + dto.toAddress}\n\n`) +// post.push(`🔗 ${BlockExplorerLink(dto.transactionHash, network)}\n\n`) +// post.push(`\nOptions for everyone, start trading 👇\n`) +// post.push(`${LyraDappUrl()}`) +// return post.join('') +// } -// DISCORD -export function TransferDiscord(dto: TransferDto, network: Network): EmbedBuilder[] { - const messageEmbeds: EmbedBuilder[] = [] - const tradeEmbed = new EmbedBuilder() - .setColor('#00ff7f') - .setURL(`${BlockExplorerLink(dto.transactionHash, network)}`) - .setTitle(`✅ Transfer: ${FN(dto.amount, 2)} $${dto.token} (${formatUSD(dto.value)})`) - .addFields( - { - name: `⛓️ Network`, - value: `> ${titleCaseWord(network)}`, - inline: false, - }, - { - name: `📤 From:`, - value: `> [${dto.fromEns ? dto.fromEns : dto.from}](${BlockExplorerAddress(dto.fromAddress, network)})`, - inline: false, - }, - { - name: `📥 To:`, - value: `> [${dto.toEns ? dto.toEns : dto.to}](${BlockExplorerAddress(dto.toAddress, network)})`, - inline: false, - }, - ) - Footer(tradeEmbed) - messageEmbeds.push(tradeEmbed) - return messageEmbeds -} +// // DISCORD +// export function TransferDiscord(dto: TransferDto, network: Network): EmbedBuilder[] { +// const messageEmbeds: EmbedBuilder[] = [] +// const tradeEmbed = new EmbedBuilder() +// .setColor('#00ff7f') +// .setURL(`${BlockExplorerLink(dto.transactionHash)}`) +// .setTitle(`✅ Transfer: ${FN(dto.amount, 2)} $${dto.token} (${formatUSD(dto.value)})`) +// .addFields( +// { +// name: `⛓️ Network`, +// value: `> ${titleCaseWord(network)}`, +// inline: false, +// }, +// { +// name: `📤 From:`, +// value: `> [${dto.fromEns ? dto.fromEns : dto.from}](${BlockExplorerAddress(dto.fromAddress, network)})`, +// inline: false, +// }, +// { +// name: `📥 To:`, +// value: `> [${dto.toEns ? dto.toEns : dto.to}](${BlockExplorerAddress(dto.toAddress, network)})`, +// inline: false, +// }, +// ) +// Footer(tradeEmbed) +// messageEmbeds.push(tradeEmbed) +// return messageEmbeds +// } diff --git a/app/src/types/api.ts b/app/src/types/api.ts new file mode 100644 index 0000000..de9647e --- /dev/null +++ b/app/src/types/api.ts @@ -0,0 +1,53 @@ +export interface LyraApi { + data: ApiData +} + +export interface ApiData { + result: Result + id: string +} + +export interface Result { + trades: Trade[] + pagination: Pagination +} + +export interface Pagination { + num_pages: number + count: number +} + +export interface Trade { + trade_id: string + instrument_name: InstrumentName + timestamp: number + trade_price: string + trade_amount: string + mark_price: string + index_price: string + direction: Direction + wallet: string + subaccount_id: number + tx_status: TxStatus + tx_hash: string + trade_fee: string + liquidity_role: LiquidityRole +} + +export enum Direction { + Buy = 'buy', + Sell = 'sell', +} + +export enum InstrumentName { + EthPerp = 'ETH-PERP', +} + +export enum LiquidityRole { + Maker = 'maker', + Taker = 'taker', +} + +export enum TxStatus { + Settled = 'settled', +} diff --git a/app/src/types/chain.ts b/app/src/types/chain.ts new file mode 100644 index 0000000..c0ca8ba --- /dev/null +++ b/app/src/types/chain.ts @@ -0,0 +1,6 @@ +export enum ChainType { + OPTIMISM = 'OPTIMISM', + ARBITRUM = 'ARBITRUM', + MAINNET = 'MAINNET', + LYRA = 'LYRA', +} diff --git a/app/src/types/lyra.ts b/app/src/types/lyra.ts deleted file mode 100644 index d6226cc..0000000 --- a/app/src/types/lyra.ts +++ /dev/null @@ -1,173 +0,0 @@ -import { - Market, - MarketLiquiditySnapshot, - MarketNetGreeksSnapshot, - MarketTradingVolumeSnapshot, -} from '@lyrafinance/lyra-js' -import { OptionType } from 'dayjs' -import { EventType } from '../constants/eventType' -import { Instrument } from './arbs' -import { Fren } from './fren' - -export type BaseEvent = { - eventType: EventType -} - -export type BaseDto = { - transactionHash: string - blockNumber: number -} - -export type Arb = { - apy: number - discount: number - term: string - strike: number - amount: number - expiration: number - type: OptionType - buy: Instrument - sell: Instrument -} - -export type ArbDto = BaseEvent & { - arbs: Arb[] - market: string -} - -export type DepositDto = BaseDto & - TraderAddress & { - to: string - amount: number - value: number - notableTo: boolean - fromAddress: string - toAddress: string - totalQueued: number - market: string - asset: string - } - -export type TraderAddress = { - ens: string - notableAddress: string - isNotable: boolean - account: string - url: string -} - -export type TradeDto = BaseDto & - TraderAddress & { - asset: string - market: string - isOpen: boolean - isLong: boolean - isCall: boolean - isBuy: boolean - strike: number - expiry: Date - size: number - premium: number - leaderBoard: Trader - pnl: number - pnlPercent: number - unrealizedPnl: number - unrealizedPnlPercent: number - totalPremiumPaid: number - isProfitable: boolean - positionId: number - positionTradeCount: number - pnlFormatted: string - pnlPercentFormatted: string - unrealizedPnlFormatted: string - unrealizedPnlPercentFormatted: string - isLiquidation: boolean - lpFees: number | undefined - setCollateralTo: number | undefined - pricePerOption: number - premiumFormatted: string - isBaseCollateral: boolean | undefined - baseCollateralFormatted: string - iv: number - fee: number - optionPrice: number - spot: number - fren: Fren | undefined - url: string - } - -export type LyraDto = BaseEvent & { - price: number - marketCap: number - totalSupply: number - marketCapRank: number - tvl: number - fdv: number - price_24h: number - fdv_tvl_ratio: number - mc_tvl_ratio: number - circSupply: number - maxSupply: number -} - -export type VaultStats = { - asset: string - market: Market - liquidity: MarketLiquiditySnapshot - netGreeks: MarketNetGreeksSnapshot - tradingVolume: MarketTradingVolumeSnapshot - liquidityHistory: MarketLiquiditySnapshot[] - netGreeksHistory: MarketNetGreeksSnapshot[] - tradingVolumeHistory: MarketTradingVolumeSnapshot[] - tvl: number - tvlChange: number - tokenPrice: number - tokenPriceChange: number - tokenPriceChangeAnnualized: number - totalNotionalVolume: number - totalNotionalVolumeChange: number - totalFees: number - openInterest: number -} - -export type Trader = TraderAddress & { - longPnl: number - shortPnl: number - longPnlPercentage: number - shortPnlPercentage: number - realizedPnl: number - unrealizedPnl: number - unrealizedPnlPercentage: number - initialCostOfOpen: number - isProfitable: boolean - position: number - fren: Fren | undefined -} - -export type TransferDto = BaseDto & { - from: string - to: string - amount: number - value: number - fromEns: string - toEns: string - notableTo: boolean - notableFrom: boolean - fromAddress: string - toAddress: string - token: string -} - -export type StrikeDto = { - strikeId: number - strikePrice: number - skew: number -} - -export type BoardDto = BaseDto & { - expiry: Date - strikes: StrikeDto[] - market: string - expiryString: string - asset: string -} diff --git a/app/src/types/market.ts b/app/src/types/market.ts new file mode 100644 index 0000000..3f1df0b --- /dev/null +++ b/app/src/types/market.ts @@ -0,0 +1,13 @@ +export enum MarketName { + BTC = 'BTC', + ETH = 'ETH', + OP = 'OP', + ARB = 'ARB', + LINK = 'LINK', + XRP = 'XRP', +} + +export enum LiquidityRole { + MAKER = 'MAKER', + TAKER = 'TAKER', +} diff --git a/app/src/types/trade.ts b/app/src/types/trade.ts new file mode 100644 index 0000000..8fa93db --- /dev/null +++ b/app/src/types/trade.ts @@ -0,0 +1,108 @@ +import { OptionType } from 'dayjs' +import { EventType } from '../constants/eventType' +import { Instrument, ProviderType } from './arbs' +import { Fren } from './fren' +import { LiquidityRole } from './api' +import { MarketName } from './market' +import { ChainType } from './chain' + +export type BaseEvent = { + eventType: EventType +} + +export type BaseDto = { + transactionHash: string +} + +export type DepositDto = BaseDto & + TraderAddress & { + to: string + amount: number + value: number + notableTo: boolean + fromAddress: string + toAddress: string + totalQueued: number + market: string + asset: string + } + +export type TraderAddress = { + ens: string + notableAddress: string + isNotable: boolean + account: string + url: string +} + +export type TradeDto = BaseDto & { + tradeId: string + instrument: string + account: string + market: MarketName | undefined + isCall: boolean + isBuy: boolean + strike: number + expiryTimestamp: number + expiry: string + size: number + fee: number + optionPrice: number + spot: number + date: string + provider: ProviderType + timestamp: number + chain: ChainType | undefined + liquidityRole: LiquidityRole | undefined + premium: number + tradeKey: string +} + +export type TradeParams = { + market: MarketName | undefined + timestamp: number | undefined + chain: ChainType | undefined + account: string | undefined +} + +export type Trader = TraderAddress & { + longPnl: number + shortPnl: number + longPnlPercentage: number + shortPnlPercentage: number + realizedPnl: number + unrealizedPnl: number + unrealizedPnlPercentage: number + initialCostOfOpen: number + isProfitable: boolean + position: number + fren: Fren | undefined +} + +export type TransferDto = BaseDto & { + from: string + to: string + amount: number + value: number + fromEns: string + toEns: string + notableTo: boolean + notableFrom: boolean + fromAddress: string + toAddress: string + token: string +} + +export type StrikeDto = { + strikeId: number + strikePrice: number + skew: number +} + +export type BoardDto = BaseDto & { + expiry: Date + strikes: StrikeDto[] + market: string + expiryString: string + asset: string +} diff --git a/app/src/utils/arbUtils.ts b/app/src/utils/arbUtils.ts index 461d639..8a7a120 100644 --- a/app/src/utils/arbUtils.ts +++ b/app/src/utils/arbUtils.ts @@ -3,98 +3,96 @@ import { chain, groupBy, pick } from 'lodash' import { STRIKE_CUTOFF } from '../constants/arbConstants' import { OptionsMap, OptionType, ProviderType } from '../types/arbs' import { getDeribitRates } from '../providers/deribit' -import { getLyraRates } from '../providers/Lyra' -import { Network } from '@lyrafinance/lyra-js' import { GetPrice } from '../integrations/prices' -type Strikes = { - allStrikes?: number[] - callStrikes?: number[] - putStrikes?: number[] - basePrice?: number -} - -export const useStrikes = (): Strikes => { - const basePrice = GetPrice('eth') - // Call : 0.8x spot -> 2x spot - // Put : 0.5x spot -> 1.2x spot - - if (!basePrice) return {} - - const roundedBase = Math.floor(basePrice / 100) * 100 - const callStart = Math.ceil((roundedBase * 0.9) / 100) * 100 - const callEnd = roundedBase * STRIKE_CUTOFF - const putStart = Math.ceil(roundedBase / STRIKE_CUTOFF / 100) * 100 - const putEnd = Math.floor((roundedBase * 1.1) / 100) * 100 - - const callStrikes: number[] = [] - const putStrikes: number[] = [] - const allStrikes: number[] = [] - - for (let i = callStart; i <= callEnd; i += 100) callStrikes.push(i) - for (let i = putStart; i <= putEnd; i += 100) putStrikes.push(i) - for (let i = putStart; i <= callEnd; i += 100) allStrikes.push(i) - - return { allStrikes, callStrikes, putStrikes, basePrice } -} - -export const useExpirations = (deribitRates?: OptionsMap[], minDays = 0, maxMonths = 3) => { - const currentDate = moment(new Date()) - - const deribitTerms = chain(deribitRates) - .uniqBy('term') - .sortBy('expiration') - .filter(({ term, expiration }) => { - const momentExpiration = moment(expiration) - const duration = moment.duration(momentExpiration.diff(currentDate)) - const monthsPassed = duration.asMonths() - const daysPassed = duration.asDays() - - return monthsPassed <= maxMonths && daysPassed > minDays - }) - .map(({ term, expiration }) => [term, +moment(expiration).set('hour', 8)] as [string, number]) - .value() - - return [deribitTerms] -} - -export const getExpirationTerm = (expiration: number) => { - const term = moment(expiration).format('DDMMMYY').toUpperCase() - - return term.startsWith('0') ? term.slice(1) : term -} - -type TermStrikesOptions = { - [term: string]: { [strike: string]: OptionsMap[] } -} - -export async function useRatesData(marketName: string, network: Network, filterSell = false) { - const providers: ProviderType[] = [ProviderType.LYRA, ProviderType.DERIBIT] - - const deribit = await getDeribitRates(marketName) - const lyra = await getLyraRates(marketName, network) - - const rates = { - [ProviderType.DERIBIT]: deribit, - [ProviderType.LYRA]: lyra, - } - - const allRates = chain(rates) - .values() - .flatten() - .filter((optionsMap: OptionsMap) => - filterSell ? Object.values(pick(optionsMap, Object.values(OptionType))).some((option) => option?.bidPrice) : true, - ) - .groupBy('term') - .mapValues((optionsMap: OptionsMap) => groupBy(optionsMap, 'strike')) - .value() as unknown as TermStrikesOptions - - const termProviders = chain(allRates) - .mapValues((strikeOptions) => { - const termProviders = chain(strikeOptions).values().max().map('provider').value() - return providers.filter((provider) => termProviders.includes(provider)) - }) - .value() - - return { allRates, termProviders } -} +// type Strikes = { +// allStrikes?: number[] +// callStrikes?: number[] +// putStrikes?: number[] +// basePrice?: number +// } + +// export const useStrikes = (): Strikes => { +// const basePrice = GetPrice('eth') +// // Call : 0.8x spot -> 2x spot +// // Put : 0.5x spot -> 1.2x spot + +// if (!basePrice) return {} + +// const roundedBase = Math.floor(basePrice / 100) * 100 +// const callStart = Math.ceil((roundedBase * 0.9) / 100) * 100 +// const callEnd = roundedBase * STRIKE_CUTOFF +// const putStart = Math.ceil(roundedBase / STRIKE_CUTOFF / 100) * 100 +// const putEnd = Math.floor((roundedBase * 1.1) / 100) * 100 + +// const callStrikes: number[] = [] +// const putStrikes: number[] = [] +// const allStrikes: number[] = [] + +// for (let i = callStart; i <= callEnd; i += 100) callStrikes.push(i) +// for (let i = putStart; i <= putEnd; i += 100) putStrikes.push(i) +// for (let i = putStart; i <= callEnd; i += 100) allStrikes.push(i) + +// return { allStrikes, callStrikes, putStrikes, basePrice } +// } + +// export const useExpirations = (deribitRates?: OptionsMap[], minDays = 0, maxMonths = 3) => { +// const currentDate = moment(new Date()) + +// const deribitTerms = chain(deribitRates) +// .uniqBy('term') +// .sortBy('expiration') +// .filter(({ term, expiration }) => { +// const momentExpiration = moment(expiration) +// const duration = moment.duration(momentExpiration.diff(currentDate)) +// const monthsPassed = duration.asMonths() +// const daysPassed = duration.asDays() + +// return monthsPassed <= maxMonths && daysPassed > minDays +// }) +// .map(({ term, expiration }) => [term, +moment(expiration).set('hour', 8)] as [string, number]) +// .value() + +// return [deribitTerms] +// } + +// export const getExpirationTerm = (expiration: number) => { +// const term = moment(expiration).format('DDMMMYY').toUpperCase() + +// return term.startsWith('0') ? term.slice(1) : term +// } + +// type TermStrikesOptions = { +// [term: string]: { [strike: string]: OptionsMap[] } +// } + +// export async function useRatesData(marketName: string, network: string, filterSell = false) { +// const providers: ProviderType[] = [ProviderType.LYRA, ProviderType.DERIBIT] + +// const deribit = await getDeribitRates(marketName) +// const lyra = await getLyraRates(marketName, network) + +// const rates = { +// [ProviderType.DERIBIT]: deribit, +// [ProviderType.LYRA]: lyra, +// } + +// const allRates = chain(rates) +// .values() +// .flatten() +// .filter((optionsMap: OptionsMap) => +// filterSell ? Object.values(pick(optionsMap, Object.values(OptionType))).some((option) => option?.bidPrice) : true, +// ) +// .groupBy('term') +// .mapValues((optionsMap: OptionsMap) => groupBy(optionsMap, 'strike')) +// .value() as unknown as TermStrikesOptions + +// const termProviders = chain(allRates) +// .mapValues((strikeOptions) => { +// const termProviders = chain(strikeOptions).values().max().map('provider').value() +// return providers.filter((provider) => termProviders.includes(provider)) +// }) +// .value() + +// return { allRates, termProviders } +// } diff --git a/app/src/utils/date.ts b/app/src/utils/date.ts new file mode 100644 index 0000000..0a9c8bb --- /dev/null +++ b/app/src/utils/date.ts @@ -0,0 +1,8 @@ +export function dateToYYYYMMDDHHMM(date: Date): string { + const year = date.getUTCFullYear() + const month = (1 + date.getUTCMonth()).toString().padStart(2, '0') // Months are 0-based, so add 1 and make it two digits + const day = date.getUTCDate().toString().padStart(2, '0') // Make it two digits + const hours = date.getUTCHours().toString().padStart(2, '0') // Make it two digits + const minutes = date.getUTCMinutes().toString().padStart(2, '0') // Make it two digits + return `${year}-${month}-${day}:${hours}:${minutes}` +} diff --git a/app/src/utils/enumMapper.ts b/app/src/utils/enumMapper.ts new file mode 100644 index 0000000..8bdcaaa --- /dev/null +++ b/app/src/utils/enumMapper.ts @@ -0,0 +1,7 @@ +export function mapStringToEnum(input: string, enumObject: T): T[keyof T] | undefined { + if (!(input.toUpperCase() in (enumObject as unknown as object))) { + console.log(`"${input}" is not a valid enum key.`) + return undefined + } + return enumObject[input as keyof T] +} diff --git a/app/src/utils/getArbitrumChainId.ts b/app/src/utils/getArbitrumChainId.ts deleted file mode 100644 index f46a693..0000000 --- a/app/src/utils/getArbitrumChainId.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Chain } from '@lyrafinance/lyra-js' -import getNetworkConfig from './getNetworkConfig' - -export default function getArbitrumChainId(): number { - return getNetworkConfig(Chain.Arbitrum).chainId -} diff --git a/app/src/utils/getChainForChainId.ts b/app/src/utils/getChainForChainId.ts deleted file mode 100644 index 4eefed5..0000000 --- a/app/src/utils/getChainForChainId.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Chain } from '@lyrafinance/lyra-js' - -const getChainForChainId = (chainId: number): Chain => { - switch (chainId) { - case 420: - return Chain.OptimismGoerli - case 42161: - return Chain.Arbitrum - case 421613: - return Chain.ArbitrumGoerli - case 10: - return Chain.Optimism - default: - throw new Error('Chain ID is not supported by Lyra') - } -} - -export default getChainForChainId diff --git a/app/src/utils/getLyra.ts b/app/src/utils/getLyra.ts deleted file mode 100644 index ca20e21..0000000 --- a/app/src/utils/getLyra.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' - -const getLyra = (network: Network) => { - switch (network) { - case Network.Arbitrum: - return global.LYRA_ARB - case Network.Optimism: - return global.LYRA_OPT - } -} - -export default getLyra diff --git a/app/src/utils/getLyraSDK.ts b/app/src/utils/getLyraSDK.ts deleted file mode 100644 index 6cb442e..0000000 --- a/app/src/utils/getLyraSDK.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Network } from '@lyrafinance/lyra-js' -import { lyraArbitrum, lyraOptimism } from './lyra' - -const getLyraSDK = (network: Network) => { - switch (network) { - case Network.Arbitrum: - return lyraArbitrum - case Network.Optimism: - return lyraOptimism - } -} - -export default getLyraSDK diff --git a/app/src/utils/getNetworkConfig.ts b/app/src/utils/getNetworkConfig.ts deleted file mode 100644 index 6d4dc6d..0000000 --- a/app/src/utils/getNetworkConfig.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Chain } from '@lyrafinance/lyra-js' -import nullthrows from 'nullthrows' - -import { NETWORK_CONFIGS, NetworkConfig } from '../constants/networks' - -// TODO: Support Ethereum network -export default function getNetworkConfig(chain: Chain): NetworkConfig { - const networkConfig = NETWORK_CONFIGS[chain] - return nullthrows(networkConfig, `No network config for chain: ${chain}`) -} diff --git a/app/src/utils/getOptimismChainId.ts b/app/src/utils/getOptimismChainId.ts deleted file mode 100644 index 96b67cd..0000000 --- a/app/src/utils/getOptimismChainId.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Chain } from '@lyrafinance/lyra-js' -import getNetworkConfig from './getNetworkConfig' - -export default function getOptimismChainId(): number { - return getNetworkConfig(Chain.Optimism).chainId -} diff --git a/app/src/utils/lyra.ts b/app/src/utils/lyra.ts deleted file mode 100644 index ecf60fd..0000000 --- a/app/src/utils/lyra.ts +++ /dev/null @@ -1,58 +0,0 @@ -import Lyra, { Version, Network } from '@lyrafinance/lyra-js' -import { NETWORK_CONFIGS } from '../constants/networks' -import getArbitrumChainId from './getArbitrumChainId' -import getChainForChainId from './getChainForChainId' -import getOptimismChainId from './getOptimismChainId' -import { SATSUMA_API_KEY } from '../config' -import { StaticJsonRpcProvider } from '@ethersproject/providers' - -const optimismChainId = getOptimismChainId() -const optimismNetworkConfig = NETWORK_CONFIGS[getChainForChainId(optimismChainId)] - -export const optimismProvider = new StaticJsonRpcProvider( - optimismNetworkConfig.readRpcUrls[0], - optimismNetworkConfig.chainId, -) - -const arbitrumChainId = getArbitrumChainId() -const arbitrumNetworkConfig = NETWORK_CONFIGS[getChainForChainId(arbitrumChainId)] - -const getLyraSubgraphURI = (network: Network): string | undefined => { - switch (network) { - case Network.Optimism: - return `https://subgraph.satsuma-prod.com/${SATSUMA_API_KEY}/lyra/optimism-mainnet-newport/api` - - case Network.Arbitrum: - return `https://subgraph.satsuma-prod.com/${SATSUMA_API_KEY}/lyra/arbitrum-mainnet/api` - } -} - -const getLyraGovSubgraphURI = (network: Network): string | undefined => { - switch (network) { - case Network.Optimism: - return `https://subgraph.satsuma-prod.com/${SATSUMA_API_KEY}/lyra/optimism-governance/api` - case Network.Arbitrum: - return `https://subgraph.satsuma-prod.com/${SATSUMA_API_KEY}/lyra/arbitrum-governance/api` - } -} - -export const arbitrumProvider = new StaticJsonRpcProvider( - arbitrumNetworkConfig.readRpcUrls[0], - arbitrumNetworkConfig.chainId, -) - -export const lyraOptimism = new Lyra({ - provider: optimismProvider, - apiUri: process.env.REACT_APP_API_URL, - subgraphUri: getLyraSubgraphURI(Network.Optimism), - govSubgraphUri: getLyraGovSubgraphURI(Network.Optimism), - version: Version.Newport, -}) - -export const lyraArbitrum = new Lyra({ - provider: arbitrumProvider, - apiUri: process.env.REACT_APP_API_URL, - subgraphUri: getLyraSubgraphURI(Network.Arbitrum), - govSubgraphUri: getLyraGovSubgraphURI(Network.Arbitrum), - version: Version.Newport, -}) diff --git a/package.json b/package.json index e7be47d..c847df0 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,10 @@ "version": "1.0.0", "private": true, "scripts": { - "build": "yarn workspace @lyrafinance/lyra-js build && yarn workspace @lyra-grants/app build", + "build": "yarn workspace @lyra-grants/app build", "start": "yarn workspace @lyra-grants/app start" }, "workspaces": [ - "app", - "sdk" + "app" ] } diff --git a/sdk/.eslintignore b/sdk/.eslintignore deleted file mode 100644 index 53c37a1..0000000 --- a/sdk/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist \ No newline at end of file diff --git a/sdk/.eslintrc.js b/sdk/.eslintrc.js deleted file mode 100644 index 15c2d99..0000000 --- a/sdk/.eslintrc.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], - env: { - node: true, - browser: true, - commonjs: true, - es6: true, - }, - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint', 'simple-import-sort', 'unused-imports'], - rules: { - '@typescript-eslint/no-inferrable-types': 0, - 'simple-import-sort/imports': 'error', - 'unused-imports/no-unused-imports': 'error', - 'unused-imports/no-unused-vars': [ - 'warn', - { - vars: 'all', - varsIgnorePattern: '^_', - args: 'after-used', - argsIgnorePattern: '^_', - }, - ], - }, - settings: {}, -} diff --git a/sdk/.gitignore b/sdk/.gitignore deleted file mode 100644 index 6652f74..0000000 --- a/sdk/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# dependencies -node_modules -.yarn/* -!.yarn/patches -!.yarn/releases -!.yarn/plugins -!.yarn/sdks -!.yarn/versions -.pnp.* - -# misc -.DS_Store -.idea -.vscode - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -**/tsconfig.tsbuildinfo - -# local env files -.env.local -.env.**.local - -# builds -/dist -/build \ No newline at end of file diff --git a/sdk/.npmignore b/sdk/.npmignore deleted file mode 100644 index e81171d..0000000 --- a/sdk/.npmignore +++ /dev/null @@ -1,24 +0,0 @@ -# dependencies -node_modules -.yarn/* -!.yarn/patches -!.yarn/releases -!.yarn/plugins -!.yarn/sdks -!.yarn/versions -.pnp.* - -# misc -.DS_Store -.idea -.vscode - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -**/tsconfig.tsbuildinfo - -# local env files -.env.local -.env.**.local \ No newline at end of file diff --git a/sdk/.prettierignore b/sdk/.prettierignore deleted file mode 100644 index 0301bb6..0000000 --- a/sdk/.prettierignore +++ /dev/null @@ -1,39 +0,0 @@ -# dependencies -node_modules -/.pnp -.pnp.js - -# testing -coverage - -# next.js -.next/ -out/ - -# production -/build - -# misc -.DS_Store -.idea - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.**.local - -# Files generated by next-on-netlify command -out_publish/ -out_functions/ - -# local dev files -**/constants/addresses/local-* -generated -typechain - -robots.txt -sitemap.xml \ No newline at end of file diff --git a/sdk/.prettierrc b/sdk/.prettierrc deleted file mode 100644 index 3db1e0f..0000000 --- a/sdk/.prettierrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "printWidth": 120, - "proseWrap": "preserve", - "semi": false, - "singleQuote": true, - "useTabs": false, - "tabWidth": 2, - "arrowParens": "avoid", - "trailingComma": "es5" -} diff --git a/sdk/README.md b/sdk/README.md deleted file mode 100644 index 1ab435f..0000000 --- a/sdk/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# Lyra.js - -A JavaScript SDK for the [Lyra Protocol](https://docs.lyra.finance/). Wraps around [Ethers.js](https://docs.ethers.io/v5/). Works in the web browser and Node.js. - -[Documentation](https://docs.lyra.finance/developers/tools/lyra.js) - -[Guides](https://docs.lyra.finance/developers/guides/execute-a-trade-off-chain) - -⚠️ This SDK is in open alpha and is constantly under development. USE AT YOUR OWN RISK. - -## Install - -``` -yarn add @lyrafinance/lyra-js -``` - -## Quickstart - -Read Lyra's market data. - -```typescript -import Lyra, { Chain } from '@lyrafinance/lyra-js' - -const lyra = new Lyra(Chain.Optimism) - -// Fetch all markets -const markets = await lyra.markets() - -console.log( - markets.map(market => ({ - address: market.address, - name: market.name, - // List all live boards (expiries) - expiries: market.liveBoards().map(board => ({ - id: board.id, - expiryTimestamp: board.expiryTimestamp, - // List all strikes - strikes: board.strikes().map(strike => ({ - id: strike.id, - strikePrice: strike.strikePrice, - })), - })), - })) -) -``` - -## Executing trades - -Prepare and execute trades with a simple interface. - -```typescript -import Lyra, { Chain, TradeEvent } from '@lyrafinance/lyra-js' - -const lyra = new Lyra(Chain.Arbitrum) - -// Initialize account -const signer = new ethers.Wallet(process.env.PRIVATE_KEY, lyra.provider) -const account = lyra.account(signer.address) - -const market = await lyra.market('eth') - -// Select most recent expiry -const board = market.liveBoards()[0] - -// Select first strike in delta range -const strike = board.strikes().find(strike => strike.isDeltaInRange) -if (!strike) { - throw new Error('No strike in delta range') -} - -// Prepare trade (Open 1.0 Long ETH Call with 0.1% slippage) -const trade = await lyra.trade(account.address, 'eth', strike.id, true, true, ONE_BN, 0.1 / 100) - -// Approve USDC -const approveTx = await trade.approveQuote(signer.address, MAX_BN) -const approveResponse = await signer.sendTransaction(approveTx) -await approveResponse.wait() -console.log('Approved USDC:', approveResponse.hash) - -// Execute trade -const tradeResponse = await signer.sendTransaction(trade.tx) -console.log('Executed trade:', tradeResponse.hash) -const tradeReceipt = await tradeResponse.wait() - -// Get trade result -const tradeEvent = (await TradeEvent.getByHash(lyra, tradeReceipt.transactionHash))[0] - -printObject('Trade Result', { - blockNumber: tradeEvent.blockNumber, - positionId: tradeEvent.positionId, - premium: tradeEvent.premium, - fee: tradeEvent.fee, -}) -``` - -## Listeners - -Create trade feeds across all markets with a simple listener - -```typescript -import Lyra, { Chain } from '@lyrafinance/lyra-js' - -const lyra = new Lyra(Chain.Arbitrum) - -lyra.onTrade(trade => { - console.log({ - trader: trade.trader, - positionId: trade.positionId, - market: trade.marketName, - size: trade.size, - isBuy: trade.isBuy, - isLong: trade.isLong, - premium: trade.premium, - setCollateralTo: trade.setCollateralTo, - isLiquidation: trade.isLiquidation, - }) -}) -``` - -## Examples - -See the `src/scripts` directory for more examples of SDK interactions. - -### Run Script - -To run a script, first clone the lyra-js repository - -``` -git clone https://github.com/lyra-finance/lyra-js.git -cd lyra-js -``` - -Install dependencies locally - -``` -yarn install -``` - -Choose a script and run - -``` -yarn script