### Quick Start: Interactive Setup and REPL Source: https://docs.nado.xyz/developer-resources/cli-and-mcp-server/cli.md Initiate an interactive trading wizard for setup or launch an interactive Read-Eval-Print Loop (REPL) for command-line interaction. ```bash nado setup # 1-click trading wizard ``` ```bash nado shell # Interactive REPL ``` -------------------------------- ### Query Documentation Example Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/max-nlp-burnable.md Example of how to query the documentation itself using an HTTP GET request with 'ask' and optional 'goal' parameters. ```http GET https://docs.nado.xyz/developer-resources/api/gateway/queries/max-nlp-burnable.md?ask=&goal= ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/cancel-orders.md This example demonstrates how to query the documentation dynamically using an HTTP GET request with 'ask' and optional 'goal' query parameters. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/cancel-orders.md?ask=&goal= ``` -------------------------------- ### HTTP GET Request Example for Querying Documentation Source: https://docs.nado.xyz/developer-resources/api/integrate-via-smart-contracts.md This example shows how to query Nado's documentation dynamically using an HTTP GET request. The `ask` parameter specifies the question, and the optional `goal` parameter helps tailor the response. ```http GET https://docs.nado.xyz/developer-resources/api/integrate-via-smart-contracts.md?ask=&goal= ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/perp/get-perp-prices.md This example demonstrates how to query the documentation dynamically using an HTTP GET request. Include your question in the `ask` parameter and an optional broader goal in the `goal` parameter. ```bash GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/perp/get-perp-prices.md?ask=&goal= ``` -------------------------------- ### Querying Documentation with GET Request Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/indexer-client/paginated-queries.md This example shows how to dynamically query the documentation using an HTTP GET request. Include the 'ask' parameter for your question and optionally the 'goal' parameter for broader context. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/indexer-client/paginated-queries.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/cancel-product-orders.md This example shows how to perform an HTTP GET request to query the documentation dynamically. Use the `ask` parameter for specific questions and the optional `goal` parameter for broader objectives. The response includes answers and relevant sources. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/cancel-product-orders.md?ask=&goal= ``` -------------------------------- ### Querying Documentation with GET Request Source: https://docs.nado.xyz/developer-resources/api/archive-indexer/direct-deposit-address.md This example shows how to query the documentation dynamically using an HTTP GET request with 'ask' and optional 'goal' parameters. This is useful for retrieving information not explicitly present on the page. ```http GET https://docs.nado.xyz/developer-resources/api/archive-indexer/direct-deposit-address.md?ask=&goal= ``` -------------------------------- ### Full Example: Create and Use Nado Client Source: https://docs.nado.xyz/developer-resources/typescript-sdk/how-to/create-a-nado-client.md A complete example demonstrating the import, client creation, and initialization of the Nado client with `viem` clients. This example can be run using `ts-node`. ```typescript import { createNadoClient } from '@nadohq/client'; import { CHAIN_ENV_TO_CHAIN } from '@nadohq/shared'; import { createPublicClient, createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; function main() { const chainEnv = 'inkTestnet'; const walletClient = createWalletClient({ account: privateKeyToAccount('0x...'), chain: CHAIN_ENV_TO_CHAIN[chainEnv], transport: http(), }); const publicClient = createPublicClient({ chain: CHAIN_ENV_TO_CHAIN[chainEnv], transport: http(), }); const nadoClient = createNadoClient(chainEnv, { walletClient, publicClient, }); } main(); ``` -------------------------------- ### Query Documentation Example Source: https://docs.nado.xyz/developer-resources/api/gateway/edge.md Perform an HTTP GET request to query the documentation dynamically. Use the 'ask' parameter for your question and optionally 'goal' for the broader objective. ```http GET https://docs.nado.xyz/developer-resources/api/gateway/edge.md?ask=&goal= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/spot/withdraw.md Example of how to query the documentation dynamically using an HTTP GET request. This is useful for asking specific questions or retrieving related information. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/spot/withdraw.md?ask=&goal= ``` -------------------------------- ### Full Order Management Example Source: https://docs.nado.xyz/developer-resources/typescript-sdk/how-to/manage-orders.md A comprehensive example demonstrating the entire order lifecycle: depositing funds, placing an order, querying open orders, canceling the order, and withdrawing funds. This includes necessary setup like minting, approving, and depositing ERC20 tokens. ```typescript import { PlaceOrderParams } from '@nadohq/client'; import { nowInSeconds, addDecimals, packOrderAppendix } from '@nadohq/shared'; import { getNadoClient, prettyPrintJson } from './common'; async function main() { const nadoClient = getNadoClient(); const { walletClient, publicClient } = nadoClient.context; const address = walletClient!.account.address; const subaccountName = 'default'; const depositAmount = addDecimals(1000, 6); const mintTxHash = await nadoClient.spot._mintMockERC20({ amount: depositAmount, productId: 0, }); await publicClient.waitForTransactionReceipt({ hash: mintTxHash, }); const approveTxHash = await nadoClient.spot.approveAllowance({ amount: depositAmount, productId: 0, }); await publicClient.waitForTransactionReceipt({ hash: approveTxHash, }); const depositTxHash = await nadoClient.spot.deposit({ subaccountName: 'default', amount: depositAmount, productId: 0, }); await publicClient.waitForTransactionReceipt({ hash: depositTxHash, }); await new Promise((resolve) => setTimeout(resolve, 10000)); const orderParams: PlaceOrderParams['order'] = { subaccountName, expiration: nowInSeconds() + 60, appendix: packOrderAppendix({ orderExecutionType: 'post_only', }), price: 80000, // Setting order amount to 10**16 amount: addDecimals(0.01, 18), }; const placeOrderResult = await nadoClient.market.placeOrder({ order: orderParams, productId: 2, // Used for spot orders to enable/disable borrowing spotLeverage: undefined, }); prettyPrintJson('Place Order Result', placeOrderResult); const openOrders = await nadoClient.market.getOpenSubaccountOrders({ subaccountOwner: address, subaccountName, productId: 2, }); prettyPrintJson('Subaccount Open Orders', openOrders); const cancelOrderResult = await nadoClient.market.cancelOrders({ digests: [placeOrderResult.data.digest], productIds: [2], subaccountName: 'default', }); prettyPrintJson('Cancel Order Result', cancelOrderResult); await nadoClient.spot.withdraw({ productId: 0, amount: depositAmount - addDecimals(1, 6), subaccountName, }); } main(); ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/subaccount/get-subaccount-fee-rates.md This example shows how to perform an HTTP GET request to the documentation URL with `ask` and `goal` query parameters to dynamically query the documentation. This is useful for getting answers not explicitly present on the page or for retrieving related context. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/subaccount/get-subaccount-fee-rates.md?ask=&goal= ``` -------------------------------- ### Example HTTP GET Request for Querying Documentation Source: https://docs.nado.xyz/developer-resources/api/gateway/signing/q-and-a.md Use this HTTP GET request format to query the documentation dynamically. Replace '' with your specific query and optionally provide a '' for tailored responses. ```http GET https://docs.nado.xyz/developer-resources/api/gateway/signing/q-and-a.md?ask=&goal= ``` -------------------------------- ### Query Documentation API Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/get-max-order-size.md This example shows how to perform an HTTP GET request to the documentation URL with `ask` and optional `goal` query parameters to dynamically query the documentation. This is useful for getting answers not explicitly present on the page or for retrieving related context. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/get-max-order-size.md?ask=&goal= ``` -------------------------------- ### Query Documentation API Example Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/spot/get-max-mint-nlp-amount.md Illustrates how to query the documentation dynamically using an HTTP GET request. This is useful for retrieving information not explicitly present on the page or for clarification. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/spot/get-max-mint-nlp-amount.md?ask=&goal= ``` -------------------------------- ### Run TypeScript Example Source: https://docs.nado.xyz/developer-resources/typescript-sdk/how-to/create-a-nado-client.md Execute the TypeScript script using `ts-node` to verify the Nado client setup. Ensure no errors are thrown upon execution. ```shell ts-node test.ts ``` -------------------------------- ### Install WebSocket Client Library Source: https://docs.nado.xyz/developer-resources/api/definitions-formulas-faqs.md Install the necessary Python library for WebSocket communication. ```bash pip install websocket-client ``` -------------------------------- ### Initialize Nado Client and Get Historical Orders Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/get-historical-orders.md Demonstrates the basic setup for creating a Nado client instance and making a call to retrieve historical orders. Ensure you replace placeholder values with your actual configuration. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.market.getHistoricalOrders(...); ``` -------------------------------- ### Verify Agent CLI Installation Source: https://docs.nado.xyz/developer-resources/cli-and-mcp-server/cli.md Check the installed version and list market data in JSON format to verify the CLI is working correctly. ```bash nado --version ``` ```bash nado market list --format json ``` -------------------------------- ### Install Agent CLI with Bun Source: https://docs.nado.xyz/developer-resources/cli-and-mcp-server/cli.md Install the Agent CLI globally using Bun package manager. ```bash bun install -g @nadohq/nado-cli ``` -------------------------------- ### ROI Leaderboard Example Calculation Source: https://docs.nado.xyz/incentives-and-rewards/trading-competitions/trading-competition-2.md Demonstrates the ROI calculation with a specific example involving starting capital, deposits, and ending value. ```plaintext Net Cash Flows = $2,000 ROI = ($8,400 − $5,000 − $2,000) / ($5,000 + $2,000) = $1,400 / $7,000 = 20% ``` -------------------------------- ### Full Example: Querying Markets and Products Source: https://docs.nado.xyz/developer-resources/typescript-sdk/how-to/query-markets-and-products.md This example demonstrates how to initialize the Nado client and sequentially fetch all market states, the latest price for product ID 1, and the market liquidity for product ID 1 with a depth of 2. ```typescript import {getNadoClient, prettyPrintJson} from './common'; async function main() { const nadoClient = getNadoClient(); const allMarkets = await nadoClient.market.getAllMarkets(); prettyPrintJson('All Markets', allMarkets); const latestMarketPrice = await nadoClient.market.getLatestMarketPrice({ productId: 1, }); prettyPrintJson('Latest Market Price (Product ID 1)', latestMarketPrice); const marketLiquidity = await nadoClient.market.getMarketLiquidity({ productId: 1, // Per side of the book depth: 2, }); prettyPrintJson('Market Liquidity (Product ID 1)', marketLiquidity); } main(); ``` -------------------------------- ### REST GET Subaccount Info Request Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/subaccount-info.md This is a GET request example for retrieving subaccount information via the REST API. Transaction simulation is included in the query parameters. ```http GET [GATEWAY_REST_ENDPOINT]/query?type=subaccount_info&subaccount={subaccount}&txns=[{"apply_delta":{"product_id":2,"subaccount":"0xeae27ae6412147ed6d5692fd91709dad6dbfc34264656661756c740000000000","amount_delta":"100000000000000000","v_quote_delta":"3033500000000000000000"}}] ``` -------------------------------- ### Get Market Liquidity Usage Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/get-market-liquidity.md Example of how to import and use the `getMarketLiquidity` method from the Nado client. ```APIDOC ## Get Market Liquidity ### Description Retrieves market liquidity data. ### Method Signature `nadoClient.market.getMarketLiquidity(...);` ### Usage Example ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.market.getMarketLiquidity(...); ``` ### Related Links - [getMarketLiquidity API reference](https://nadohq.github.io/nado-typescript-sdk/classes/Nado_Client.Internal.MarketQueryAPI.html#getmarketliquidity) - [REST API > Queries > Market Liquidity](/developer-resources/api/gateway/queries/market-liquidity.md) ``` -------------------------------- ### Place Order Usage Example Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/place-order.md Demonstrates how to initialize the Nado client and place an order using the market.placeOrder method. Ensure you have the correct client initialization parameters. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.market.placeOrder(...); ``` -------------------------------- ### Time Request Example Source: https://docs.nado.xyz/developer-resources/api/gateway/edge.md Send a time request to get the current server time. The 'id' field is optional. ```json { "type": "time", "id": 2 } ``` -------------------------------- ### CLI Configuration File Example Source: https://docs.nado.xyz/developer-resources/cli-and-mcp-server/configuration.md Stores credentials and network settings for the Nado CLI. Ensure this file has restricted permissions. ```toml data_env = "nadoMainnet" # nadoMainnet | nadoTestnet subaccount_name = "default" [credentials] private_key = "0x..." subaccount_owner = "0x..." # only needed when using a linked signer ``` -------------------------------- ### Get Candlesticks Example Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/get-candlesticks.md Demonstrates how to initialize the Nado client and call the `getCandlesticks` method. Ensure you have the necessary imports and client initialization parameters. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.market.getCandlesticks(...); ``` -------------------------------- ### Trading Example: Spot Market Buy Source: https://docs.nado.xyz/developer-resources/cli-and-mcp-server/cli.md Execute a market buy order for ETH spot at a specific price. ```bash nado trade buy ETH 1.0 -p 2500 ``` -------------------------------- ### Get Linked Signer via Rust SDK Source: https://docs.nado.xyz/developer-resources/get-started/linked-signers.md Fetch the linked signer for your subaccount using the Rust SDK. This example requires importing necessary types from `nado_sdk::prelude` and `ethers::types::Address`. ```rust use nado_sdk::prelude::*; use ethers::types::Address; let subaccount = client.subaccount()?; let info = client.get_linked_signer(subaccount).await?; if info.signer == Address::zero() { println!("❌ No linked signer set (zero address)"); } else { println!("✅ Linked signer: {:?}", info.signer); } ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.nado.xyz/developer-resources/api/gateway/executes/liquidate-subaccount.md Demonstrates how to perform an HTTP GET request to query the documentation with 'ask' and optional 'goal' parameters. This is useful for retrieving specific information or clarification. ```http GET https://docs.nado.xyz/developer-resources/api/gateway/executes/liquidate-subaccount.md?ask=&goal= ``` -------------------------------- ### Trading Competition Response Structure Source: https://docs.nado.xyz/developer-resources/api/archive-indexer/trading-competitions.md This is an example of the JSON response structure when requesting trading competition data. It includes details such as contest ID, start and end times, participant count, and track information. ```json { "contests": [ { "contest_id": 1, "start_time": "1718000000", "end_time": "1718600000", "count": "1234", "last_updated": "1718500000", "product_ids": [], "active": true, "title": "Season 2 - Trading Competition #1", "description": "Week-long competition across all spot and perpetual markets.", "tracks": [ { "track_id": 1, "rank_type": "roi", "sort_order": "DESC", "threshold": "1000.0" }, { "track_id": 2, "rank_type": "volume", "sort_order": "DESC", "threshold": "10000.0" } ] } ] } ``` -------------------------------- ### Initialize Nado Client and Liquidate Subaccount Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/engine-client.md Demonstrates how to create a Nado client instance and then use it to liquidate a subaccount via the engine client. Ensure the correct network ('inkTestnet' in this example) and necessary authentication parameters are provided. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.context.engineClient.liquidateSubaccount(...) ``` -------------------------------- ### Real-Time Data via WebSocket Source: https://docs.nado.xyz/developer-resources/api/definitions-formulas-faqs.md Connect to the WebSocket endpoint to receive real-time data updates. This section provides the endpoint URL, installation instructions for the `websocket-client` library, and a Python example demonstrating how to subscribe to funding rate updates. ```APIDOC ## Real-Time Data via WebSocket ### Description Connect to the WebSocket endpoint to receive real-time data updates. This section provides the endpoint URL, installation instructions for the `websocket-client` library, and a Python example demonstrating how to subscribe to funding rate updates. ### Endpoint `wss://gateway.prod.nado.xyz/v1/subscribe` ### Installation ```bash pip install websocket-client ``` ### Request Example (Python) ```python import websocket import json def from_x18(value): return int(value) / 10**18 def on_message(ws, message): data = json.loads(message) if "funding_rate" in data: rate = from_x18(data["funding_rate"]["rate_x18"]) print(f"Funding rate update: {rate}") def on_open(ws): # Subscribe to funding rate updates after connection is established ws.send(json.dumps({ "method": "subscribe", "stream": { "type": "funding_rate", "product_id": 2 } })) ws = websocket.WebSocketApp( "wss://gateway.prod.nado.xyz/v1/subscribe", on_message=on_message, on_open=on_open ) ws.run_forever() ``` ### Available Streams `order_update`, `trade`, `best_bid_offer`, `fill`, `position_change`, `book_depth`, `liquidation`, `funding_payment`, `funding_rate` ``` -------------------------------- ### Build Agent CLI from Source Source: https://docs.nado.xyz/developer-resources/cli-and-mcp-server/cli.md Clone the repository, install dependencies, build the CLI, and link it globally to make the 'nado' command available. ```bash git clone https://github.com/nadohq/nado-cli.git cd nado-cli bun install bun run build bun link # makes `nado` available globally ``` -------------------------------- ### Query Product Snapshots API Source: https://docs.nado.xyz/developer-resources/api/archive-indexer/product-snapshots.md Perform an HTTP GET request to query the Product Snapshots API. Use the 'ask' parameter for specific questions and the optional 'goal' parameter to guide the AI's response towards a broader objective. ```HTTP GET https://docs.nado.xyz/developer-resources/api/archive-indexer/product-snapshots.md?ask=&goal= ``` -------------------------------- ### Query GitBook Documentation via HTTP GET Source: https://docs.nado.xyz/developer-resources/api/archive-indexer/interest-and-funding-payments.md Use this endpoint to dynamically query documentation. Include an 'ask' parameter for your specific question and an optional 'goal' parameter to guide the response. The response will contain a direct answer and supporting documentation excerpts. ```http GET https://docs.nado.xyz/developer-resources/api/archive-indexer/interest-and-funding-payments.md?ask=&goal= ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/contracts.md Use this GET request format to query the documentation dynamically. Include your question in the 'ask' parameter and an optional 'goal' parameter for tailored answers. ```bash GET https://docs.nado.xyz/developer-resources/api/gateway/queries/contracts.md?ask=&goal= ``` -------------------------------- ### High-Leverage Spread Weight Cap Example Source: https://docs.nado.xyz/core/subaccounts-and-health.md Illustrates how spread weight caps affect calculations at high leverage (50x). It shows the natural spread weight calculation and how it gets capped for both initial and maintenance health, resulting in a smaller health increase compared to uncapped scenarios. ```plaintext Position: +1 wBTC spot, -1 BTC-PERP BTC spot price: $90,000 BTC perp price: $90,000 Both at 50x leverage (long_weight = 0.98) Step 1 - Basis Amount: basis_amount = min(1, 1) = 1 Step 2 - Existing Weight: existing_weight = (0.98 + 0.98) / 2 = 0.98 Step 3 - Spread Weight (INITIAL HEALTH): Natural calculation: spread_weight = 1 - (1 - 0.98) / 5 = 1 - 0.02 / 5 = 1 - 0.004 = 0.996 But 0.996 > 0.99 (initial health cap) Final spread_weight = 0.99 (CAPPED!) Step 3 - Spread Weight (MAINTENANCE HEALTH): Same natural calculation: 0.996 But 0.996 > 0.994 (maintenance health cap) Final spread_weight = 0.994 (CAPPED!) Step 4 - Health Increase: Initial health boost = 1 × ($90,000 + $90,000) × (0.99 - 0.98) = $180,000 × 0.01 = $1,800 Maintenance health boost = 1 × ($90,000 + $90,000) × (0.994 - 0.98) = $180,000 × 0.014 = $2,520 What this means: - At 20x leverage (weight 0.95): Natural spread_weight = 0.99, no capping needed - At 50x leverage (weight 0.98): Natural spread_weight = 0.996, gets capped to 0.99/0.994 - The caps prevent excessive leverage on spreads while still providing significant benefit - You still get improved health, but the benefit is limited at extreme leverage levels ``` -------------------------------- ### Place Order with Linked Signer (TypeScript) Source: https://docs.nado.xyz/developer-resources/get-started/linked-signers.md This TypeScript example demonstrates placing an order using a linked signer. First, create the Nado client with your main wallet to set the context. Then, use `setLinkedSigner` to specify the linked signer's wallet client. The SDK will automatically use your main wallet's subaccount as the sender and sign with the linked signer's key. ```TypeScript import { createNadoClient } from '@nadohq/client'; import { createWalletClient, createPublicClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { ink } from 'viem/chains'; // Step 1: Create client with MAIN WALLET to set context const mainAccount = privateKeyToAccount(mainWalletPrivateKey); const mainWalletClient = createWalletClient({ account: mainAccount, chain: ink, transport: http() }); const publicClient = createPublicClient({ chain: ink, transport: http() }); const client = await createNadoClient('inkMainnet', { walletClient: mainWalletClient, publicClient }); // Step 2: Set the linked signer for signing operations const linkedAccount = privateKeyToAccount(linkedSignerPrivateKey); const linkedSignerWalletClient = createWalletClient({ account: linkedAccount, chain: ink, transport: http() }); // ⚠️ CRITICAL: Call setLinkedSigner to use linked signer for signatures client.context.engineClient.setLinkedSigner(linkedSignerWalletClient); // Step 3: Place order // SDK automatically: // 1. Uses main wallet's subaccount as sender // 2. Signs with linked signer's key await client.market.placeOrder({ subaccount: 'default', // Main wallet's subaccount productId: 2, // ... other params }); console.log('✅ Order placed for subaccount:', mainAccount.address); console.log(' Signed by linked signer:', linkedAccount.address); ``` -------------------------------- ### Query Oracle Snapshots API Source: https://docs.nado.xyz/developer-resources/api/archive-indexer/oracle-snapshots.md Perform an HTTP GET request to query the Oracle Snapshots API. Use the `ask` parameter for specific questions and the optional `goal` parameter to guide the AI towards a broader objective. The response includes direct answers and relevant documentation excerpts. ```bash GET https://docs.nado.xyz/developer-resources/api/archive-indexer/oracle-snapshots.md?ask=&goal= ``` -------------------------------- ### Connect to Nado Testnet (Python) Source: https://docs.nado.xyz/developer-resources/get-started/quickstart.md Create a Nado client using your private key and verify the connection by querying contract details. Keep your private key secret and consider using environment variables. ```Python from nado_protocol.client import create_nado_client, NadoClientMode # Replace with your private key PRIVATE_KEY = "0x..." # ⚠️ Keep this secret! # Create client (Testnet - Ink Sepolia) client = create_nado_client(NadoClientMode.TESTNET, PRIVATE_KEY) # Verify connection - query contracts contracts = client.context.engine_client.get_contracts() print(f"✅ Connected to Nado Testnet!") print(f"Chain ID: {contracts.chain_id}") # Should be 763373 for testnet print(f"Your address: {client.context.signer.address}") ``` -------------------------------- ### Verify TypeScript SDK Installation Source: https://docs.nado.xyz/developer-resources/get-started/quickstart.md Verify the successful installation of the Nado TypeScript SDK by running a Node.js command. This confirms the package is correctly installed and accessible. ```bash node -e "require('@nadohq/client'); console.log('✅ Installed successfully')" ``` -------------------------------- ### Sign Trading Requests with Main Wallet Key (TypeScript) Source: https://docs.nado.xyz/developer-resources/get-started/linked-signers.md This TypeScript example demonstrates signing trading requests using the main wallet's private key. It involves creating a viem wallet client and then initializing the Nado client with it. The signature originates from the main wallet. ```TypeScript import { createNadoClient } from '@nadohq/client'; import { createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { ink } from 'viem/chains'; // Create wallet client with MAIN WALLET key const mainAccount = privateKeyToAccount(mainWalletPrivateKey); const walletClient = createWalletClient({ account: mainAccount, chain: ink, transport: http() }); // Create Nado client const client = await createNadoClient('inkMainnet', { walletClient, publicClient }); // Place order - signed with main wallet # Sender field: main wallet's subaccount # Signature: from main wallet's key await client.market.placeOrder(orderParams); ``` -------------------------------- ### Get Subaccount Orders (REST GET) Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/orders.md Retrieve subaccount orders using a GET request to the Gateway REST endpoint. Parameters are passed as query parameters. ```APIDOC ## GET [GATEWAY_REST_ENDPOINT]/query ### Description Retrieves subaccount orders for a specific product. ### Method GET ### Endpoint `[GATEWAY_REST_ENDPOINT]/query` ### Query Parameters - **type** (string) - Required - Must be `subaccount_orders`. - **sender** (string) - Required - A `bytes32` sent as a hex string; includes the address and the subaccount identifier. - **product_id** (number) - Required - Id of spot / perp product for which to retrieve subaccount orders. ### Response #### Success Response (200) - **status** (string) - The status of the request (e.g., "success"). - **data** (object) - Contains the order details. - **sender** (string) - Subaccount that placed the order. - **product_id** (number) - Product ID for this order. - **orders** (array) - An array of order objects. - **product_id** (number) - Product ID for this order. - **sender** (string) - Subaccount that placed the order. - **price_x18** (string) - Order price, scaled by 10^18. - **amount** (string) - Original order size in base units, scaled by 10^18. Positive = buy, negative = sell. - **expiration** (string) - Unix timestamp (seconds) when the order expires. - **nonce** (string) - Order nonce. - **unfilled_amount** (string) - Remaining unfilled size, scaled by 10^18. Positive = buy, negative = sell. - **digest** (string) - Unique order identifier. - **placed_at** (number) - Unix timestamp (seconds) when the order was placed. - **appendix** (string) - Encoded order properties. - **order_type** (string) - Human-readable order type: `"default"`, `"ioc"`, `"fok"`, `"post_only"`. - **request_type** (string) - The type of request made (e.g., `"query_subaccount_orders"`). ### Response Example ```json { "status": "success", "data": { "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000", "product_id": 1, "orders": [ { "product_id": 1, "sender": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43000000000000000000000000", "price_x18": "1000000000000000000", "amount": "1000000000000000000", "expiration": "2000000000", "nonce": "1", "unfilled_amount": "1000000000000000000", "digest": "0x0000000000000000000000000000000000000000000000000000000000000000", "placed_at": 1682437739, "appendix": "1537", "order_type": "ioc" } ] }, "request_type": "query_subaccount_orders" } ``` ``` -------------------------------- ### Get Product Snapshots using TypeScript SDK Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/market/get-product-snapshots.md Demonstrates how to initialize the Nado client and call the `getProductSnapshots` method to retrieve product data. Ensure you have the necessary imports and client initialization. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.market.getProductSnapshots(...); ``` -------------------------------- ### Create Nado Client and Deposit Collateral Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/spot/deposit.md Demonstrates how to initialize the Nado client and call the deposit function. Ensure you have the correct network and credentials when creating the client. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.spot.deposit(...); ``` -------------------------------- ### Get Max Withdrawable Source: https://docs.nado.xyz/developer-resources Gets the estimated maximum withdrawable amount for a given product. ```APIDOC ## Get Max Withdrawable ### Description Gets the estimated max withdrawable amount for a product. ### Method GET ### Endpoint /client/spot/get-max-withdrawable ### Parameters #### Query Parameters - **tokenAddress** (string) - Required - The address of the token for which to check withdrawable amount. - **subaccountId** (string) - Required - The ID of the subaccount. ### Response #### Success Response (200) - **maxWithdrawableAmount** (string) - The estimated maximum amount that can be withdrawn. #### Response Example { "maxWithdrawableAmount": "950000000000000000" } ``` -------------------------------- ### Query Documentation with Ask Parameter Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/market-liquidity.md Demonstrates how to dynamically query the documentation using an HTTP GET request with the 'ask' parameter. Useful for retrieving specific information or clarifications. ```http GET https://docs.nado.xyz/developer-resources/api/gateway/queries/market-liquidity.md?ask=&goal= ``` -------------------------------- ### REST Status (GET) Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/status.md Query the gateway status using a GET request to the REST endpoint. ```APIDOC ## Get Gateway Status (REST) ### Description Retrieve the current status of the gateway via a GET request. ### Method GET ### Endpoint `[GATEWAY_REST_ENDPOINT]/query?type=status` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request, e.g., "success". - **data** (string) - Sequencer status: "active" (accepting executes) or "failed" (sequencer error state). - **request_type** (string) - The type of request made, e.g., "query_status". #### Response Example ```json { "status": "success", "data": "active", "request_type": "query_status" } ``` ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.nado.xyz/core/order-types.md Use this HTTP GET request to ask questions about the documentation. Include your specific question in the 'ask' parameter and an optional broader goal in the 'goal' parameter. ```http GET https://docs.nado.xyz/core/order-types.md?ask=&goal= ``` -------------------------------- ### Initialize Nado Client and Fetch Snapshots Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/indexer-client.md Import and initialize the Nado client, then use the indexerClient to retrieve multi-subaccount snapshots. Ensure the correct network is specified during client creation. ```typescript import { createNadoClient } from '@nadohq/client'; const nadoClient = createNadoClient('inkTestnet', ...); const res = await nadoClient.context.indexerClient.getMultiSubaccountSnapshots(...) ``` -------------------------------- ### Query Documentation with Ask and Goal Parameters Source: https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/perp.md Use this HTTP GET request to query the documentation dynamically. The 'ask' parameter specifies the question, and the optional 'goal' parameter helps tailor the answer to a broader objective. This is useful when information is not explicitly on the page or requires further context. ```http GET https://docs.nado.xyz/developer-resources/typescript-sdk/user-guide/client/perp.md?ask=&goal= ``` -------------------------------- ### REST API (GET) Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/linked-signer.md Retrieve the linked signer address using a GET request to the gateway endpoint. ```APIDOC ## REST API (GET) ### Description Use an HTTP GET request to the gateway endpoint with `type=linked_signer` and the `subaccount` parameter to retrieve the linked signer address. ### Method GET ### Endpoint `[GATEWAY_REST_ENDPOINT]/query?type=linked_signer&subaccount=` ### Query Parameters - **type** (string) - Required - Must be `linked_signer`. - **subaccount** (string) - Required - The subaccount address for which to retrieve the linked signer. ### Response Example ```json { "status": "success", "data": { "linked_signer": "0x0000000000000000000000000000000000000000" }, "request_type": "query_linked_signer" } ``` ``` -------------------------------- ### REST GET Request Source: https://docs.nado.xyz/developer-resources/api/gateway/queries/nlp-locked-balances.md Retrieve NLP locked balances using a GET request to the gateway REST endpoint. ```APIDOC ## REST GET ### Description Retrieve NLP locked balances using a GET request to the gateway REST endpoint. ### Method GET ### Endpoint `[GATEWAY_REST_ENDPOINT]/query?type=nlp_locked_balances&subaccount={subaccount}` ### Parameters #### Query Parameters - **type** (string) - Required - Must be `nlp_locked_balances`. - **subaccount** (string) - Required - A bytes32 sent as a hex string; includes the address and the subaccount identifier. ```