> For the complete documentation index, see [llms.txt](https://docs.deriw.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.deriw.com/deriw-mainnet/openapi-reference.md).

# OpenAPI Reference

OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision.

## Get all available trading markets

> Returns a list of all available trading markets with real-time prices, 24h trading volume, current open interest, and position fee rates. WBTC and WETH names are displayed as BTC and ETH.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/markets":{"get":{"tags":["v1"],"summary":"Get all available trading markets","description":"Returns a list of all available trading markets with real-time prices, 24h trading volume, current open interest, and position fee rates. WBTC and WETH names are displayed as BTC and ETH.","parameters":[{"name":"status","in":"query","schema":{"type":"integer","enum":[1,2,3]},"description":"Filter by market status. 1=Delisted (no longer tradable), 2=Listed (actively trading), 3=Pending delist (will be removed soon)"},{"name":"is_meme","in":"query","schema":{"type":"boolean"},"description":"Set to true to return only meme coins"},{"name":"is_tradfi","in":"query","schema":{"type":"boolean"},"description":"Set to true to return only TradFi assets (stocks and metals)"}],"responses":{"200":{"description":"List of trading markets","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketsResponse"}}}}}}}},"components":{"schemas":{"MarketsResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"markets":{"type":"array","items":{"$ref":"#/components/schemas/MarketItem"},"description":"List of trading markets"}}}}},"MarketItem":{"type":"object","description":"A single trading market with real-time data","properties":{"address":{"type":"string","description":"Token contract address on the blockchain"},"name":{"type":"string","description":"Token display symbol. WBTC is shown as BTC, WETH as ETH"},"decimals":{"type":"integer","description":"Number of decimal places for the token (e.g., 18 for most tokens, 6 for USDT)"},"is_stable":{"type":"boolean","description":"Whether this token is a stablecoin (e.g., USDT)"},"is_shortable":{"type":"boolean","description":"Whether short positions can be opened on this token"},"is_wrapped":{"type":"boolean","description":"Whether this token is a wrapped version of another asset"},"is_meme":{"type":"boolean","description":"Whether this token is classified as a meme coin"},"is_tradfi":{"type":"boolean","description":"Whether this token is a TradFi asset (stock or precious metal)"},"coin_type":{"type":"integer","description":"Asset classification. 1=Cryptocurrency, 2=Stock, 3=Precious metal"},"fee_rate":{"type":"integer","description":"Position opening fee rate in basis points (1 bps = 0.01%). For example, 2 means 0.02% fee"},"price":{"type":"string","description":"Real-time market price with 6-decimal precision (multiplied by 1e6)"},"volume_24h":{"type":"string","description":"Total trading volume over the last 24 hours with 6-decimal precision"},"long_interest":{"type":"string","description":"Current total long position open interest with 6-decimal precision"},"short_interest":{"type":"string","description":"Current total short position open interest with 6-decimal precision"},"status":{"type":"integer","description":"Market listing status. 1=Delisted (no longer tradable), 2=Listed (actively trading), 3=Pending delist"}}}}}}
```

## Get account open positions

> Returns the current open positions for the specified wallet address. Supports pagination up to 100 records per page, with a maximum of 10,000 total accessible records. All size, collateral, and fee values use 6-decimal precision.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/account/positions":{"get":{"tags":["v1"],"summary":"Get account open positions","description":"Returns the current open positions for the specified wallet address. Supports pagination up to 100 records per page, with a maximum of 10,000 total accessible records. All size, collateral, and fee values use 6-decimal precision.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Wallet address to query positions for"},{"name":"index_token","in":"query","schema":{"type":"string"},"description":"Filter by index token contract address"},{"name":"is_long","in":"query","schema":{"type":"boolean"},"description":"Set to true for long positions, false for short positions"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of open positions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PositionsResponse"}}}},"400":{"description":"Request exceeds the maximum accessible page range"}}}}},"components":{"schemas":{"PositionsResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"positions":{"type":"array","items":{"$ref":"#/components/schemas/PositionItem"},"description":"List of open positions"},"total":{"type":"integer","description":"Total number of open positions matching the query filters"}}}}},"PositionItem":{"type":"object","description":"A single open position","properties":{"account":{"type":"string","description":"Wallet address that owns this position"},"index_token":{"type":"string","description":"Index token contract address (the traded asset)"},"token_name":{"type":"string","description":"Token display symbol. WBTC is shown as BTC, WETH as ETH"},"is_long":{"type":"boolean","description":"Position direction. true = long (expects price to rise), false = short (expects price to fall)"},"size":{"type":"string","description":"Position size in USD with 6-decimal precision"},"collateral":{"type":"string","description":"Collateral amount locked for this position with 6-decimal precision"},"leverage":{"type":"string","description":"Effective leverage ratio (size / collateral)"},"total_fees":{"type":"string","description":"Total accumulated fees paid for this position with 6-decimal precision"},"status":{"type":"integer","description":"Position status. 1=Currently open, 2=Closed"},"created_at":{"type":"integer","description":"Position creation time as Unix timestamp in seconds"},"updated_at":{"type":"integer","description":"Position last update time as Unix timestamp in seconds"}}}}}}
```

## Get account trade history

> Returns the trade history (both open and close positions) for the specified wallet address. Each record is either an 'increase' (opening) or 'decrease' (closing) trade. Supports filtering by time range and trade type. All financial fields use 6-decimal precision.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/trades":{"get":{"tags":["v1"],"summary":"Get account trade history","description":"Returns the trade history (both open and close positions) for the specified wallet address. Each record is either an 'increase' (opening) or 'decrease' (closing) trade. Supports filtering by time range and trade type. All financial fields use 6-decimal precision.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Wallet address to query trade history for"},{"name":"index_token","in":"query","schema":{"type":"string"},"description":"Filter by index token contract address"},{"name":"trade_type","in":"query","schema":{"type":"string","enum":["increase","decrease"]},"description":"Filter by trade direction. 'increase' = opening positions, 'decrease' = closing positions. Omit to return both."},{"name":"from_timestamp","in":"query","schema":{"type":"integer"},"description":"Start of time range filter (Unix timestamp in seconds)"},{"name":"to_timestamp","in":"query","schema":{"type":"integer"},"description":"End of time range filter (Unix timestamp in seconds)"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of trade records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradesResponse"}}}},"400":{"description":"Request exceeds the maximum accessible page range"}}}}},"components":{"schemas":{"TradesResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"total_volume":{"type":"string","description":"Sum of trade sizes on the current page with 6-decimal precision"},"history_volume":{"type":"string","description":"Total cumulative trading volume for this account across all history with 6-decimal precision"},"total":{"type":"integer","description":"Total number of trade records matching the query filters"},"trades":{"type":"array","items":{"$ref":"#/components/schemas/TradeItem"},"description":"List of trade records for the current page"}}}}},"TradeItem":{"type":"object","description":"A single trade record (position open or close)","properties":{"account":{"type":"string","description":"Wallet address that executed this trade"},"trade_type":{"type":"string","description":"Trade direction. 'increase' = opened a position (long or short), 'decrease' = closed a position (partially or fully)"},"index_token":{"type":"string","description":"Index token contract address (the traded asset)"},"token_name":{"type":"string","description":"Token display symbol. WBTC is shown as BTC, WETH as ETH"},"is_long":{"type":"boolean","description":"Position direction. true = long, false = short"},"size":{"type":"string","description":"Trade size in USD with 6-decimal precision"},"collateral":{"type":"string","description":"Collateral amount involved with 6-decimal precision"},"price":{"type":"string","description":"Execution price with 6-decimal precision"},"average_price":{"type":"string","description":"Average entry price of the position when it was opened, with 6-decimal precision. Only present for decrease (close) trades"},"pnl":{"type":"string","description":"Realized profit and loss for this trade with 6-decimal precision. Only present for decrease (close) trades. Positive = profit, negative = loss"},"fee":{"type":"string","description":"Fee paid for this trade with 6-decimal precision"},"tx_hash":{"type":"string","description":"Blockchain transaction hash of this trade"},"block_number":{"type":"integer","description":"Block number where this trade was executed"},"created_at":{"type":"integer","description":"Trade execution time as Unix timestamp in seconds"}}}}}}
```

## Get latest token prices

> Returns the latest real-time price and 24-hour statistics (high, low, change) for all listed tokens. Prices use 6-decimal precision (multiplied by 1e6).

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/prices":{"get":{"tags":["v1"],"summary":"Get latest token prices","description":"Returns the latest real-time price and 24-hour statistics (high, low, change) for all listed tokens. Prices use 6-decimal precision (multiplied by 1e6).","parameters":[{"name":"index_token","in":"query","schema":{"type":"string"},"description":"Filter by index token contract address"},{"name":"symbol","in":"query","schema":{"type":"string"},"description":"Filter by token display symbol (e.g., BTC, ETH, SOL)"}],"responses":{"200":{"description":"List of token prices","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PricesResponse"}}}}}}}},"components":{"schemas":{"PricesResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"prices":{"type":"array","items":{"$ref":"#/components/schemas/PriceItem"},"description":"List of token price data"}}}}},"PriceItem":{"type":"object","description":"Latest price data for a single token","properties":{"index_token":{"type":"string","description":"Index token contract address"},"symbol":{"type":"string","description":"Token display symbol (e.g., BTC, ETH, SOL). WBTC is shown as BTC, WETH as ETH"},"price":{"type":"string","description":"Latest real-time price with 6-decimal precision (multiplied by 1e6)"},"high_24h":{"type":"string","description":"Highest price in the last 24 hours with 6-decimal precision (multiplied by 1e6)"},"low_24h":{"type":"string","description":"Lowest price in the last 24 hours with 6-decimal precision (multiplied by 1e6)"},"change_24h":{"type":"string","description":"24-hour price change percentage (e.g., '2.50' means +2.50%)"}}}}}}
```

## Get all supported tokens

> Returns metadata for all supported tokens including contract address, display name, decimals, trading attributes, coin type classification, and current fee rate. WBTC and WETH names are displayed as BTC and ETH.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/tokens":{"get":{"tags":["v1"],"summary":"Get all supported tokens","description":"Returns metadata for all supported tokens including contract address, display name, decimals, trading attributes, coin type classification, and current fee rate. WBTC and WETH names are displayed as BTC and ETH.","parameters":[{"name":"status","in":"query","schema":{"type":"integer","enum":[1,2,3]},"description":"Filter by token status. 1=Delisted, 2=Listed, 3=Pending delist"},{"name":"is_meme","in":"query","schema":{"type":"boolean"},"description":"Set to true to return only meme coins"},{"name":"is_tradfi","in":"query","schema":{"type":"boolean"},"description":"Set to true to return only TradFi assets (stocks and metals)"}],"responses":{"200":{"description":"List of supported tokens","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokensResponse"}}}}}}}},"components":{"schemas":{"TokensResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"tokens":{"type":"array","items":{"$ref":"#/components/schemas/TokenItem"},"description":"List of supported tokens"}}}}},"TokenItem":{"type":"object","description":"Metadata for a single supported token","properties":{"address":{"type":"string","description":"Token contract address on the blockchain"},"name":{"type":"string","description":"Token display name. WBTC is shown as BTC, WETH as ETH"},"decimals":{"type":"integer","description":"Number of decimal places for the token (e.g., 18 for most tokens, 6 for USDT)"},"is_stable":{"type":"boolean","description":"Whether this token is a stablecoin"},"is_shortable":{"type":"boolean","description":"Whether short positions can be opened on this token"},"is_wrapped":{"type":"boolean","description":"Whether this token is a wrapped version of another asset"},"is_meme":{"type":"boolean","description":"Whether this token is classified as a meme coin"},"is_tradfi":{"type":"boolean","description":"Whether this token is a TradFi asset (stock or precious metal)"},"coin_type":{"type":"integer","description":"Asset classification. 1=Cryptocurrency, 2=Stock, 3=Precious metal"},"fee_rate":{"type":"string","description":"Position opening fee rate in basis points (1 bps = 0.01%). For example, '2' means 0.02% fee"},"price":{"type":"string","description":"Real-time market price with 6-decimal precision (multiplied by 1e6)"},"status":{"type":"integer","description":"Token listing status. 1=Delisted, 2=Listed, 3=Pending delist"}}}}}}
```

## Get protocol statistics

> Returns aggregated protocol-wide statistics including trading volume, fees, revenue, open interest, TVL, fund pool data, and unique trader count. All financial fields use 6-decimal precision. Unique traders is an integer count.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/stats":{"get":{"tags":["v1"],"summary":"Get protocol statistics","description":"Returns aggregated protocol-wide statistics including trading volume, fees, revenue, open interest, TVL, fund pool data, and unique trader count. All financial fields use 6-decimal precision. Unique traders is an integer count.","parameters":[{"name":"from_timestamp","in":"query","schema":{"type":"integer"},"description":"Start of time range filter (Unix timestamp in seconds)"},{"name":"to_timestamp","in":"query","schema":{"type":"integer"},"description":"End of time range filter (Unix timestamp in seconds)"}],"responses":{"200":{"description":"Protocol statistics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StakingResponse"}}}}}}}},"components":{"schemas":{"StakingResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"$ref":"#/components/schemas/StatsData"}}},"StatsData":{"type":"object","description":"Aggregated protocol-wide statistics","properties":{"total_volume":{"type":"string","description":"Cumulative total trading volume since inception with 6-decimal precision"},"trading_volume":{"type":"string","description":"Total trading volume with 6-decimal precision"},"long_volume":{"type":"string","description":"Total long position trading volume with 6-decimal precision"},"short_volume":{"type":"string","description":"Total short position trading volume with 6-decimal precision"},"total_fees":{"type":"string","description":"Cumulative total fees collected since inception with 6-decimal precision"},"open_fee":{"type":"string","description":"Total opening position fees with 6-decimal precision"},"close_fee":{"type":"string","description":"Total closing position fees with 6-decimal precision"},"liquidation_fee":{"type":"string","description":"Total liquidation fees with 6-decimal precision"},"manage_fee":{"type":"string","description":"Total management fees with 6-decimal precision"},"total_revenue":{"type":"string","description":"Total protocol revenue with 6-decimal precision"},"long_revenue":{"type":"string","description":"Revenue from long positions with 6-decimal precision"},"short_revenue":{"type":"string","description":"Revenue from short positions with 6-decimal precision"},"open_interest":{"type":"string","description":"Total open interest across all markets with 6-decimal precision"},"long_open_interest":{"type":"string","description":"Total long position open interest with 6-decimal precision"},"short_open_interest":{"type":"string","description":"Total short position open interest with 6-decimal precision"},"long_weighting":{"type":"string","description":"Long position weighting factor (e.g., '1661' represents 16.61%)"},"short_weighting":{"type":"string","description":"Short position weighting factor"},"tvl":{"type":"string","description":"Total Value Locked in the protocol with 6-decimal precision"},"fund_pool_volume":{"type":"string","description":"Total fund pool volume with 6-decimal precision"},"fund_pool_raised":{"type":"string","description":"Total fund pool amount raised with 6-decimal precision"},"unique_traders":{"type":"integer","description":"Total number of unique trader addresses"},"updated_at":{"type":"integer","description":"Statistics data timestamp as Unix timestamp in seconds"}}}}}}
```

## Get account liquidation history

> Returns liquidation records for the specified wallet address. Each record includes liquidation type: type 2 or 3 indicates normal liquidation events, type 4 indicates forced closure due to coin delisting, and type 5 indicates ADL (Auto-Deleveraging) events. All financial fields use 6-decimal precision.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/liquidations":{"get":{"tags":["v1"],"summary":"Get account liquidation history","description":"Returns liquidation records for the specified wallet address. Each record includes liquidation type: type 2 or 3 indicates normal liquidation events, type 4 indicates forced closure due to coin delisting, and type 5 indicates ADL (Auto-Deleveraging) events. All financial fields use 6-decimal precision.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Wallet address to query liquidation history for"},{"name":"index_token","in":"query","schema":{"type":"string"},"description":"Filter by index token contract address"},{"name":"is_long","in":"query","schema":{"type":"boolean"},"description":"Set to true for long positions, false for short positions"},{"name":"from_timestamp","in":"query","schema":{"type":"integer"},"description":"Start of time range filter (Unix timestamp in seconds)"},{"name":"to_timestamp","in":"query","schema":{"type":"integer"},"description":"End of time range filter (Unix timestamp in seconds)"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of liquidation records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LiquidationsResponse"}}}},"400":{"description":"Request exceeds the maximum accessible page range"}}}}},"components":{"schemas":{"LiquidationsResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"liquidations":{"type":"array","items":{"$ref":"#/components/schemas/LiquidationItem"},"description":"List of liquidation records"},"total":{"type":"integer","description":"Total number of liquidation records matching the query filters"}}}}},"LiquidationItem":{"type":"object","description":"A single liquidation event record","properties":{"account":{"type":"string","description":"Wallet address that was liquidated"},"index_token":{"type":"string","description":"Index token contract address (the liquidated asset)"},"is_long":{"type":"boolean","description":"Position direction that was liquidated. true = long, false = short"},"size":{"type":"string","description":"Position size at the time of liquidation with 6-decimal precision"},"collateral":{"type":"string","description":"Collateral amount at the time of liquidation with 6-decimal precision"},"average_price":{"type":"string","description":"Average entry price of the position with 6-decimal precision"},"mark_price":{"type":"string","description":"Mark price at the moment of liquidation with 6-decimal precision"},"liquidation_price":{"type":"string","description":"Theoretical liquidation trigger price with 6-decimal precision"},"fee":{"type":"string","description":"Liquidation fee charged with 6-decimal precision"},"realised_pnl":{"type":"string","description":"Realized profit and loss from this liquidation with 6-decimal precision. Negative values indicate a loss"},"liquidation_type":{"type":"integer","description":"Type of liquidation event. 2 or 3=Normal liquidation (margin below maintenance), 4=Forced close due to coin delisting, 5=ADL (Auto-Deleveraging)"},"tx_hash":{"type":"string","description":"Blockchain transaction hash of this liquidation"},"block_number":{"type":"integer","description":"Block number where this liquidation was executed"},"created_at":{"type":"integer","description":"Liquidation time as Unix timestamp in seconds"}}}}}}
```

## Get current position fee rates

> Returns the current position fee rate (in basis points) for each listed token. The fee rate represents the cost to open a position, expressed in bps where 1 bps = 0.01%. Returns all listed tokens when no filter is specified.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/funding_rates":{"get":{"tags":["v1"],"summary":"Get current position fee rates","description":"Returns the current position fee rate (in basis points) for each listed token. The fee rate represents the cost to open a position, expressed in bps where 1 bps = 0.01%. Returns all listed tokens when no filter is specified.","parameters":[{"name":"index_token","in":"query","schema":{"type":"string"},"description":"Filter by index token contract address. Omit to return fee rates for all listed tokens."}],"responses":{"200":{"description":"List of current fee rates","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FundingRatesResponse"}}}}}}}},"components":{"schemas":{"FundingRatesResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"funding_rates":{"type":"array","items":{"$ref":"#/components/schemas/FundingRateItem"},"description":"List of current fee rates"}}}}},"FundingRateItem":{"type":"object","description":"Current fee rate for a single token","properties":{"index_token":{"type":"string","description":"Index token contract address"},"name":{"type":"string","description":"Token display name. WBTC is shown as BTC, WETH as ETH"},"fee_rate":{"type":"integer","description":"Position opening fee rate in basis points (1 bps = 0.01%). For example, 2 means 0.02% fee"}}}}}}
```

## Get room open positions

> Returns the current open positions of traders in the specified host's room. Data is served from a background cache and is eventually consistent; an empty list is returned when the cache has not been warmed yet. PnL is from the room (LP) perspective. All amounts are USDT-denominated decimal strings.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/open_positions":{"get":{"tags":["v1"],"summary":"Get room open positions","description":"Returns the current open positions of traders in the specified host's room. Data is served from a background cache and is eventually consistent; an empty list is returned when the cache has not been warmed yet. PnL is from the room (LP) perspective. All amounts are USDT-denominated decimal strings.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address. Note: unlike other v1 endpoints, this is the room host address, not a trader address"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of room open positions. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address or page out of range","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomOpenPositionsResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account, page_size greater than 100)"}}}}},"components":{"schemas":{"RoomOpenPositionsResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoomOpenPositionItem"},"description":"List of open positions in the room"},"total":{"type":"integer","description":"Total number of open positions in the room"},"page_index":{"type":"integer","description":"Current page number"},"page_size":{"type":"integer","description":"Current page size"}}}}},"RoomOpenPositionItem":{"type":"object","description":"A single open position inside a room. Field structure is identical to the /client/room/open-positions endpoint","properties":{"account":{"type":"string","description":"Trader wallet address"},"market":{"type":"string","description":"Market display name, e.g. BTC/USDT"},"index_token":{"type":"string","description":"Room channel index token contract address"},"direction":{"type":"string","description":"Position direction. 'long' or 'short'"},"leverage":{"type":"string","description":"Effective leverage ratio (size / collateral) as a decimal string"},"average_price":{"type":"string","description":"Average entry price as a decimal string"},"now_price":{"type":"string","description":"Current mark price as a decimal string"},"liquidation_price":{"type":"string","description":"Estimated liquidation trigger price as a decimal string. '0' when unavailable"},"collateral_size":{"type":"string","description":"Collateral amount in USDT as a decimal string"},"size_delta":{"type":"string","description":"Position size in USDT as a decimal string"},"unreleased_pnl":{"type":"string","description":"Unrealized PnL from the room (LP) perspective as a decimal string"}}}}}}
```

## Get room close position history

> Returns the closed position history of traders in the specified host's room, including force-close and liquidation flags and the room fee share. PnL is from the room (LP) perspective. All amounts are USDT-denominated decimal strings.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/close_position_history":{"get":{"tags":["v1"],"summary":"Get room close position history","description":"Returns the closed position history of traders in the specified host's room, including force-close and liquidation flags and the room fee share. PnL is from the room (LP) perspective. All amounts are USDT-denominated decimal strings.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of room closed positions. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address or page out of range","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomClosePositionHistoryResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account, page_size greater than 100)"}}}}},"components":{"schemas":{"RoomClosePositionHistoryResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoomClosePositionItem"},"description":"List of closed positions in the room"},"total":{"type":"integer","description":"Total number of closed position records"},"page_index":{"type":"integer","description":"Current page number"},"page_size":{"type":"integer","description":"Current page size"}}}}},"RoomClosePositionItem":{"type":"object","description":"A single closed position record inside a room. Field structure is identical to the /client/room/close-position-history endpoint","properties":{"account":{"type":"string","description":"Trader wallet address"},"market":{"type":"string","description":"Market display name, e.g. BTC/USDT"},"direction":{"type":"string","description":"Position direction. 'long' or 'short'"},"leverage":{"type":"string","description":"Effective leverage ratio as a decimal string"},"average_price":{"type":"string","description":"Average entry price as a decimal string"},"close_price":{"type":"string","description":"Close execution price as a decimal string"},"collateral_size":{"type":"string","description":"Collateral amount in USDT as a decimal string"},"size_delta":{"type":"string","description":"Closed position size in USDT as a decimal string"},"released_pnl":{"type":"string","description":"Realized PnL from the room (LP) perspective as a decimal string"},"fee_share":{"type":"string","description":"Room pool fee share for this close (both open and close sides) as a decimal string"},"time":{"type":"integer","description":"Close time as Unix timestamp in seconds"},"is_force_close":{"type":"boolean","description":"Whether this close was a forced close"},"is_liq":{"type":"boolean","description":"Whether this close was a liquidation"},"tx_hash":{"type":"string","description":"Blockchain transaction hash of the close"}}}}}}
```

## Get room liquidity change history

> Returns the host's liquidity deposit and withdrawal history for the room pool, sourced from on-chain liquidity events. All amounts are USDT-denominated decimal strings.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/lp_change":{"get":{"tags":["v1"],"summary":"Get room liquidity change history","description":"Returns the host's liquidity deposit and withdrawal history for the room pool, sourced from on-chain liquidity events. All amounts are USDT-denominated decimal strings.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of room liquidity changes. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address or page out of range","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomLPChangeResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account, page_size greater than 100)"}}}}},"components":{"schemas":{"RoomLPChangeResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoomLPChangeItem"},"description":"List of liquidity change records"},"total":{"type":"integer","description":"Total number of liquidity change records"},"page_index":{"type":"integer","description":"Current page number"},"page_size":{"type":"integer","description":"Current page size"}}}}},"RoomLPChangeItem":{"type":"object","description":"A single host liquidity change record. Field structure is identical to the /client/room/lp-change endpoint","properties":{"account":{"type":"string","description":"Host wallet address"},"amount":{"type":"string","description":"Liquidity change amount as a decimal string"},"type":{"type":"string","description":"Change type. 'deposit' or 'withdraw'"},"symbol":{"type":"string","description":"Token symbol, e.g. USDT"},"contract_address":{"type":"string","description":"Token contract address"},"status":{"type":"string","description":"Change status, e.g. 'succeed'"},"time":{"type":"integer","description":"Event time as Unix timestamp in seconds"}}}}}}
```

## Get room daily fee share trend

> Returns the room pool's daily fee share trend in ascending date order. The window covers the last N calendar days including today; days before the room's reopen time are returned as 0. Amounts are USDT-denominated decimal strings.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/fee":{"get":{"tags":["v1"],"summary":"Get room daily fee share trend","description":"Returns the room pool's daily fee share trend in ascending date order. The window covers the last N calendar days including today; days before the room's reopen time are returned as 0. Amounts are USDT-denominated decimal strings.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address"},{"name":"limit","in":"query","schema":{"type":"integer","default":10},"description":"Number of calendar days to return (default 10)"}],"responses":{"200":{"description":"Daily fee share trend. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address, 100009 = room pool not found for this account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomFeeResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account)"}}}}},"components":{"schemas":{"RoomFeeResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoomDailyTrendItem"},"description":"Daily fee share trend points in ascending date order"}}}}},"RoomDailyTrendItem":{"type":"object","description":"A single daily trend point. Field structure is identical to the /client/room/fee and /client/room/tvl endpoints","properties":{"day":{"type":"string","description":"Calendar day in YYYY-MM-DD format"},"volume":{"type":"string","description":"Value for the day in USDT as a decimal string (fee share for the fee endpoint, TVL for the tvl endpoint)"}}}}}}
```

## Get room daily TVL trend

> Returns the room pool's daily TVL (total value locked) trend in ascending date order. Historical days are read from daily snapshots; today's value is read from the blockchain in real time. Days before the room's reopen time are returned as 0. Amounts are USDT-denominated decimal strings.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/tvl":{"get":{"tags":["v1"],"summary":"Get room daily TVL trend","description":"Returns the room pool's daily TVL (total value locked) trend in ascending date order. Historical days are read from daily snapshots; today's value is read from the blockchain in real time. Days before the room's reopen time are returned as 0. Amounts are USDT-denominated decimal strings.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address"},{"name":"limit","in":"query","schema":{"type":"integer","default":10},"description":"Number of calendar days to return (default 10)"}],"responses":{"200":{"description":"Daily TVL trend. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address, 100009 = room pool not found for this account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomTVLResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account)"}}}}},"components":{"schemas":{"RoomTVLResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoomDailyTrendItem"},"description":"Daily TVL trend points in ascending date order"}}}}},"RoomDailyTrendItem":{"type":"object","description":"A single daily trend point. Field structure is identical to the /client/room/fee and /client/room/tvl endpoints","properties":{"day":{"type":"string","description":"Calendar day in YYYY-MM-DD format"},"volume":{"type":"string","description":"Value for the day in USDT as a decimal string (fee share for the fee endpoint, TVL for the tvl endpoint)"}}}}}}
```

## Get room detail overview

> Returns an aggregated overview of the specified host's room: deposits, pool equity, TVL, open interest capacity, active traders, 24h volume, realized PnL, net revenue, and room health. Amounts are USDT-denominated decimal strings; percentage fields are decimal ratio strings (e.g. '0.05' = 5%).

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/detail":{"get":{"tags":["v1"],"summary":"Get room detail overview","description":"Returns an aggregated overview of the specified host's room: deposits, pool equity, TVL, open interest capacity, active traders, 24h volume, realized PnL, net revenue, and room health. Amounts are USDT-denominated decimal strings; percentage fields are decimal ratio strings (e.g. '0.05' = 5%).","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address"}],"responses":{"200":{"description":"Room detail overview. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address, 100009 = room pool not found for this account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomDetailResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account)"}}}}},"components":{"schemas":{"RoomDetailResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"$ref":"#/components/schemas/RoomDetailData"}}},"RoomDetailData":{"type":"object","description":"Aggregated room overview. Field structure is identical to the /client/room/detail endpoint","properties":{"net_deposits":{"type":"string","description":"Net deposits (deposits minus withdrawals) in USDT as a decimal string"},"net_deposits_change_percent":{"type":"string","description":"Net deposits change vs. the start of the current month as a decimal ratio string"},"total_deposits":{"type":"string","description":"Total historical deposits in USDT as a decimal string"},"total_deposits_change_percent":{"type":"string","description":"Total deposits change vs. the start of the current month as a decimal ratio string"},"withdrawable_amount":{"type":"string","description":"Host's currently withdrawable amount in USDT as a decimal string"},"pool_equity":{"type":"string","description":"Current pool equity in USDT as a decimal string"},"pool_equity_change_percent":{"type":"string","description":"Pool equity change vs. the same day last month as a decimal ratio string"},"total_tvl":{"type":"string","description":"Current total value locked in USDT as a decimal string"},"total_reversed_oi":{"type":"string","description":"Current reserved open interest in USDT as a decimal string"},"total_reversed_oi_percent":{"type":"string","description":"Reserved OI as a ratio of max OI, decimal ratio string"},"max_oi":{"type":"string","description":"Maximum open interest capacity in USDT as a decimal string"},"total_available_oi":{"type":"string","description":"Remaining available open interest in USDT as a decimal string"},"active_trader":{"type":"string","description":"Number of active traders in the room as an integer string"},"total_volume":{"type":"string","description":"Trading volume over the last 24 hours in USDT as a decimal string"},"realized_pnl":{"type":"string","description":"Cumulative realized PnL from the room (LP) perspective in USDT as a decimal string"},"net_revenue":{"type":"string","description":"Net revenue over the last 24 hours (fee share + management fee + realized PnL) in USDT as a decimal string"},"room_health":{"$ref":"#/components/schemas/RoomDetailHealth"}}},"RoomDetailHealth":{"type":"object","description":"Room health indicators","properties":{"utilization_rate":{"type":"string","description":"Open interest utilization ratio (reserved OI / max OI) as a decimal ratio string"},"risk_exposure":{"type":"string","description":"Risk exposure level. One of 'low', 'medium', 'high', 'critical'"},"risk_exposure_rate":{"type":"string","description":"Risk exposure ratio (room loss / pool equity) as a decimal ratio string. '0' when the room is not losing"}}}}}}
```

## Get room trader summary

> Returns aggregated per-trader statistics for the specified host's room: total volume, win rate, fees, and PnL from the room (LP) perspective. All amounts are USDT-denominated decimal strings.

```json
{"openapi":"3.0.3","info":{"title":"DEX Server OpenAPI","version":"1.0.0"},"tags":[{"name":"v1","description":"OpenAPI v1 — Public market data, account positions, trade history, token metadata, protocol statistics, liquidation records, and current funding rates. All financial fields are returned as decimal string values. Price and position-related fields use 6-decimal precision."}],"servers":[{"url":"https://api.deriw.com/openapi","description":"Production"},{"url":"https://api.test.deriw.com/openapi","description":"Test"}],"paths":{"/v1/rooms/traders":{"get":{"tags":["v1"],"summary":"Get room trader summary","description":"Returns aggregated per-trader statistics for the specified host's room: total volume, win rate, fees, and PnL from the room (LP) perspective. All amounts are USDT-denominated decimal strings.","parameters":[{"name":"account","in":"query","schema":{"type":"string"},"required":true,"description":"Room host (creator) wallet address"},{"name":"page_index","in":"query","schema":{"type":"integer","minimum":1,"default":1},"description":"Page number, starting from 1"},{"name":"page_size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"description":"Number of records per page (max 100)"}],"responses":{"200":{"description":"List of room trader statistics. Business errors are also returned with HTTP 200 and a non-zero code: 100438 = invalid account address or page out of range","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomTradersResponse"}}}},"400":{"description":"Malformed query parameters (e.g. missing account, page_size greater than 100)"}}}}},"components":{"schemas":{"RoomTradersResponse":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code. 0 = success"},"msg":{"type":"string","description":"Response message. 'success' on success"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoomTraderItem"},"description":"List of per-trader statistics"},"total":{"type":"integer","description":"Total number of traders in the room"},"page_index":{"type":"integer","description":"Current page number"},"page_size":{"type":"integer","description":"Current page size"}}}}},"RoomTraderItem":{"type":"object","description":"Aggregated statistics for a single trader in the room. Field structure is identical to the /client/room/traders endpoint","properties":{"account":{"type":"string","description":"Trader wallet address"},"total_volume":{"type":"string","description":"Trader's total trading volume in USDT as a decimal string"},"win_rate":{"type":"string","description":"Trader's win rate from the room (LP) perspective as a decimal ratio string"},"total_fee":{"type":"string","description":"Total fees generated by this trader in USDT as a decimal string"},"unreleased_pnl":{"type":"string","description":"Unrealized PnL from the room (LP) perspective in USDT as a decimal string"},"released_pnl":{"type":"string","description":"Realized PnL from the room (LP) perspective in USDT as a decimal string"},"managed_fee":{"type":"string","description":"Management fee income attributed to this trader in USDT as a decimal string"}}}}}}
```
