diff --git a/sdks/hooks/assets/use-chain.mdx b/sdks/hooks/assets/use-chain.mdx index f5bbadd1..1001b8fa 100644 --- a/sdks/hooks/assets/use-chain.mdx +++ b/sdks/hooks/assets/use-chain.mdx @@ -11,3 +11,53 @@ Receive chain information for a given token. ```ts const { chains, isLoading } = useChain("USDC"); ``` + +### Return Type + +```typescript +interface ChainResponse { + chain_details: Array<{ + chain_id: string; + chain_name: string; + contract_address: string; + cross_chain_withdrawal_fee: number; + decimals: number; + display_name: string; + withdrawal_fee: number; + }>; + decimals: number; + minimum_withdraw_amount: number; + token: string; + token_hash: string; +} +``` + +### Usage + +```typescript +import { useChain } from "@orderly.network/hooks"; + +function ChainInfo() { + const { data } = useChain("USDC"); + + return ( +
+ {data.chain_details.map((chain) => ( +
+
Network: {chain.chain_name}
+
Contract: {chain.contract_address}
+
Withdrawal Fee: {chain.withdrawal_fee} USDC
+
+ ))} +
+ ); +} +``` + +### Features + +- Supports multiple chains +- Chain-specific contract addresses +- Withdrawal fee information +- Token decimals and minimums +- Cross-chain transfer details diff --git a/sdks/hooks/funding/use-funding-rate.mdx b/sdks/hooks/funding/use-funding-rate.mdx index dd488cff..2b6cc9dc 100644 --- a/sdks/hooks/funding/use-funding-rate.mdx +++ b/sdks/hooks/funding/use-funding-rate.mdx @@ -11,3 +11,59 @@ Receive funding rate for given symbol. ```ts const fundingRate = useFundingRate("PERP_ETH_USDC"); ``` + +## Return Type + +```typescript +interface FundingRateData { + // Time remaining until next funding in format "HH:MM:SS" + countDown: string; + + // Estimated funding rate for next period + est_funding_rate: string; + + // Timestamp when estimated rate was calculated + est_funding_rate_timestamp: number; + + // Last funding rate that was charged/paid + last_funding_rate: number; + + // Timestamp of last funding rate + last_funding_rate_timestamp: number; + + // Timestamp of next funding event + next_funding_time: number; + + // Cumulative funding since position opened + sum_unitary_funding: number; + + // Trading pair symbol + symbol: string; +} +``` + +## Usage + +```typescript +import { useFundingRate } from "@orderly.network/hooks"; + +function FundingRateDisplay() { + const fundingRate = useFundingRate("PERP_ETH_USDC"); + + return ( +
+
Next Funding: {fundingRate.countDown}
+
Est. Rate: {fundingRate.est_funding_rate}
+
Last Rate: {fundingRate.last_funding_rate}
+
+ ); +} +``` + +## Funding Rate Details + +- Funding occurs every 8 hours +- Rates are displayed in percentage format +- Positive rates mean longs pay shorts +- Negative rates mean shorts pay longs +- Timestamps are in Unix milliseconds diff --git a/sdks/hooks/market-data/use-index-price.mdx b/sdks/hooks/market-data/use-index-price.mdx index efc7ebf6..1e1e9193 100644 --- a/sdks/hooks/market-data/use-index-price.mdx +++ b/sdks/hooks/market-data/use-index-price.mdx @@ -9,5 +9,22 @@ Receive index price for given symbol and auto update via Websockets. ### Example ```ts -const indexPrice: number = useIndexPrice("PERP_ETH_USDC"); +import { useIndexPrice } from "@orderly.network/hooks"; + +const { data: indexPrice } = useIndexPrice("PERP_ETH_USDC"); +``` + +### Return Type + +```typescript +interface IndexPriceResponse { + data: number; // Current index price in USDC +} ``` + +### Features + +- WebSocket updates +- USDC denominated +- Used for funding calculations +- Reflects spot market price diff --git a/sdks/hooks/market-data/use-mark-price.mdx b/sdks/hooks/market-data/use-mark-price.mdx index 2e6ff033..d9a061ce 100644 --- a/sdks/hooks/market-data/use-mark-price.mdx +++ b/sdks/hooks/market-data/use-mark-price.mdx @@ -9,5 +9,32 @@ Receive mark price for given symbol and auto update via Websockets. ### Example ```ts -const markPrice: number = useMarkPrice("PERP_ETH_USDC"); +const markPrice = useMarkPrice("PERP_ETH_USDC"); ``` + +### Return Type + +```typescript +interface MarkPriceResponse { + data: number; // Current mark price in USDC +} +``` + +### Usage + +```typescript +import { useMarkPrice } from "@orderly.network/hooks"; + +function PriceDisplay() { + const { data: price } = useMarkPrice("PERP_ETH_USDC"); + + return
ETH Price: ${price}
; +} +``` + +### Features + +- Real-time updates via WebSocket +- Price in USDC terms +- Auto-reconnect on disconnect +- Efficient single pair subscription diff --git a/sdks/hooks/market-data/use-mark-prices-stream.mdx b/sdks/hooks/market-data/use-mark-prices-stream.mdx index ed7ac3a3..e3531f26 100644 --- a/sdks/hooks/market-data/use-mark-prices-stream.mdx +++ b/sdks/hooks/market-data/use-mark-prices-stream.mdx @@ -11,3 +11,44 @@ Get list of all mark prices in a `symbol` -> `price` map. ```ts const { data: markPrices }: { data: Record } = useMarkPricesStream(); ``` + +### Return + +```typescript +PERP_1000APU_USDC: 0.448 +PERP_1000BONK_USDC: 0.030194 +PERP_1000FLOKI_USDC: 0.137867 +PERP_1000PEPE_USDC: 0.015262 +PERP_1000SHIB_USDC: 0.019946 +PERP_1000000MOG_USDC: 1.5348 +... +``` + +### Usage + +```typescript +import { useMarkPricesStream } from "@orderly.network/hooks"; + +function PricesDisplay() { + const { data: markPrices } = useMarkPricesStream(); + + return ( +
+ {Object.entries(markPrices).map(([symbol, price]) => ( +
+ {symbol}: ${price} +
+ ))} +
+ ); +} +``` + +### Features + +- Real-time WebSocket stream +- Provides mark prices for all perpetual trading pairs +- Price updates on each tick +- Prices in USDC terms +- Common pairs include BTC, ETH, SOL and other major assets +- Also includes pairs with 1000x or 1000000x multipliers for low-value tokens diff --git a/sdks/hooks/market-data/use-ticker-stream.mdx b/sdks/hooks/market-data/use-ticker-stream.mdx index 824aa7c1..ef3a532a 100644 --- a/sdks/hooks/market-data/use-ticker-stream.mdx +++ b/sdks/hooks/market-data/use-ticker-stream.mdx @@ -6,25 +6,52 @@ This hooks streams [market information](/sdks/tech-doc/interfaces/orderly_networ - [Tech docs](/sdks/tech-doc/modules/orderly_network_hooks#usetickerstream) -### Example +## Usage ```tsx -const marketInfo = useTickerStream("PERP_BTC_USDC"); - -return ( - <> -
-
Mark
-
{stream.mark_price}
-
-
-
Index
-
{stream.index_price}
-
-
-
24h volume
-
{stream["24h_amount"]}
-
- -); +import { useTickerStream } from "@orderly.network/hooks"; + +function MarketInfo() { + const marketInfo = useTickerStream("PERP_BTC_USDC"); + + return ( + <> +
Mark Price: ${marketInfo.mark_price}
+
24h Change: {marketInfo["24h_change"]}%
+
24h Volume: ${marketInfo["24h_amount"]}
+ + ); +} ``` + +### Return Type + +```typescript +interface TickerStreamResponse { + "24h_amount": number; // 24h trading volume in USDC + "24h_change": number; // Price change in last 24h + "24h_close": number; // Latest price in 24h period + "24h_high": number; // Highest price in 24h + "24h_low": number; // Lowest price in 24h + "24h_open": number; // Opening price 24h ago + "24h_volume": number; // Trading volume in base currency + change: number; // Price change percentage + est_funding_rate: number; // Estimated next funding rate + index_price: number; // Current index price + last_funding_rate: number; // Last paid funding rate + mark_price: number; // Current mark price + next_funding_time: number; // Next funding timestamp + open_interest: number; // Total open interest + sum_unitary_funding: number; // Cumulative funding + symbol: string; // Trading pair symbol +} +``` + +### Features + +- Real-time WebSocket updates +- Comprehensive market data +- Price metrics and changes +- Volume information +- Funding rate details +- Open interest tracking