expand.network
  • Overview
  • Getting Started
  • 🔑How do I get my API Key?
  • 📑List of All Endpoints
  • ⚙️SDK
    • Overview
    • Getting Started
  • ⛓️INTEGRATIONS
    • ⚡Blockchains
      • EVM based blockchains
        • Ethereum
        • Binance Smart Chain
        • Avalanche - C
        • Avalanche - P
        • Avalanche - X
        • Polygon
        • Cronos
        • Arbitrum
        • Fantom
        • Optimism
        • Base
        • zkSync Era
        • Mantle
      • Non-EVM based chains
        • Tron
        • Solana
        • Near
        • Algorand
        • Aptos
        • Sui
        • Starknet
        • TON
        • Cosmos Hub
        • Osmosis
        • Stacks
        • Bitcoin
        • Stellar
          • Stellar RWA
        • XRP Ledger
          • XRP Ledger RWA
    • ⚡Bridges
      • Stargate
      • Stargate V2
      • Squid Router
      • Squid Router V2
      • Allbridge Classic
      • Allbridge Core
    • ⚡DEX & DEX Aggregators
      • Uniswap V2
      • Uniswap V3
      • Uniswap X
      • Sushiswap V2
      • PancakeSwap V2
      • PancakeSwap V3
      • Aerodrome
      • Camelot V3
      • Curve V2
      • Balancer V2
      • STON.fi
      • Trader Joe
      • Orca
      • Raydium
      • SDEX
      • Cetus
      • REF Finance
      • Liquidswap
      • Sologenic
      • Alex
      • 0x (Aggregator)
      • 1inch (Aggregator)
      • Kyberswap (Aggregator)
        • Kyberswap ( Limit Order Endpoints )
      • Jupiter (Aggregator)
    • ⚡Derivatives
      • dYdX V4
    • ⚡Fungible Tokens
      • ERC20
      • WETH
    • ⚡Lending Protocols
      • Aave V2
      • Aave V3
      • Compound V2
      • Compound V3
      • Morpho
    • ⚡Yield Aggregators
      • Yearn Finance V2
      • Harvest Finance
      • Pendle
    • ⚡Liquid Staking
      • Chorus One
      • Lido V2
      • Stader
      • Benqi
      • Jito
      • EigenLayer
    • ⚡Non Fungible Tokens
      • ERC721
      • ERC1155
      • Metaplex
    • ⚡Oracles
      • ChainLink
      • WinkLink
      • Pyth Network
      • RedStone
    • ⚡Stablecoins
      • EVM
    • ⚡Synthetics
      • Synthetix
    • ⚡Supported Wallets
      • MPC Wallets
        • DFNS
        • FORDEFI
        • FIREBLOCKS
        • CIRCLE
      • HD Wallets
        • PHANTOM
        • COINBASE
        • TON Wallet
      • Wallet Connect v2
  • How To
    • Execute a Local Swap
    • Execute a Cross Chain Swap
    • Use Limit Orders
    • Lend and Borrow
    • Provision Liquidity
      • Adding Liquidity
      • Removing liquidity
    • Yield Farm
    • Use Our Transaction Decoder
    • Submit an RFQ
    • Subscribe to Events
    • Stream Data (WebSocket)
      • Stream Transaction
      • Stream Trade
      • Stream Gas
      • Stream Ticker Price
    • Source Pricing
    • Track Memecoins
    • Manage Token Approvals
  • Use Cases
    • Trade Reconciliation
    • Portfolio Management
    • Trading Features
    • On-Chain Data: DEX Liquidity Pool Forensics
    • Transaction and Pool Analysis
  • Account Abstraction
    • Overview
      • User Endpoints
      • Paymaster Endpoint
      • Bundler Endpoint
    • ⚙️SDK - Overview
  • Additional Info
    • Error Messages
    • Client-Side Security Essentials
    • Compute Unit Costs
    • API Metadata
    • Audit Certificate
    • Brand Assets
    • FAQs
    • Quicknode Marketplace
      • DEX
      • Lending Protocols
  • ID's
    • Chain IDs
    • Bridge IDs
      • Internal Chain IDs for Bridges
    • DEX IDs
    • Lending Protocol IDs
    • Yield Aggregator ID
    • Liquid Staking IDs
    • Oracle IDs
    • Stablecoin IDs
    • Derivatives IDs
    • Synthetics IDs
  • Mapping
    • Blockchains
    • DEXs
      • Uniswap V2
      • Uniswap V3
      • Sushiswap
      • PancakeSwap
      • Curve
      • Balancer
    • Lending Protocols
      • Aave
      • Compound
  • Protocol Spender
    • Spender list
Powered by GitBook
On this page
  • /getorders
  • /getorder
  • /getfills
  • /getassets
  • /gethistoricalpnl
  • /getperpetualpositions
  • /getsubaccounts
  • /gettransfers
  1. INTEGRATIONS
  2. Derivatives

dYdX V4

Currently on Ethereum Testnet Goerli / dYdX V4 Testnet Only.

Additional functionalities available in expand.network SDK: onboarding user, place order, transfer, deposit, and cancel order.

/getorders

Users can fetch details for all orders corresponding to a specified address and a specified sub-account number.

GET https://api.expand.network/derivative/getorders

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

subAccountNumber*

String

Number of the sub account.

https://api.expand.network/derivative/getorders?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d&subAccountNumber=0
{
    "status": 200,
    "msg": "success",
    "data": {
      "orders": [
        {
            "id": "5724e441-654f-5dc6-ac02-e8e4a7ecda2e",
            "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
            "clientId": "3711471933",
            "clobPairId": "1",
            "side": "SELL",
            "size": "0.01",
            "totalFilled": "0",
            "price": "2600",
            "type": "LIMIT",
            "status": "CANCELED",
            "timeInForce": "GTT",
            "reduceOnly": false,
            "orderFlags": "64",
            "goodTilBlockTime": "2024-01-10T10:42:45.000Z",
            "createdAtHeight": "4993716",
            "clientMetadata": "0",
            "updatedAt": "2024-01-10T10:42:45.385Z",
            "updatedAtHeight": "4993921",
            "postOnly": true,
            "ticker": "ETH-USD"
          },
          {
            "id": "ff494eb3-d74e-5852-8aea-1ddabc4d9a37",
            "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
            "clientId": "1594632561",
            "clobPairId": "1",
            "side": "BUY",
            "size": "0.01",
            "totalFilled": "0.01",
            "price": "2600",
            "type": "LIMIT",
            "status": "FILLED",
            "timeInForce": "GTT",
            "reduceOnly": false,
            "orderFlags": "64",
            "goodTilBlockTime": "2024-01-10T10:31:42.000Z",
            "createdAtHeight": "4993244",
            "clientMetadata": "0",
            "updatedAt": "2024-01-10T10:26:43.386Z",
            "updatedAtHeight": "4993245",
            "postOnly": false,
            "ticker": "ETH-USD"
          }
      ]
    }
  }

/getorder

Users can fetch details for a specific order using the specified order id.

GET https://api.expand.network/derivative/getorder

Query Parameters

Name
Type
Description

orderId*

String

Order Id to fetch details of.

derivativeId

String

https://api.expand.network/derivative/getorder?derivativeId=1000&orderId=5724e441-654f-5dc6-ac02-e8e4a7ecda2e
{
  "status": 200,
  "msg": "success",
  "data": {
    "id": "5724e441-654f-5dc6-ac02-e8e4a7ecda2e",
    "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
    "clientId": "3711471933",
    "clobPairId": "1",
    "side": "SELL",
    "size": "0.01",
    "totalFilled": "0",
    "price": "2600",
    "type": "LIMIT",
    "status": "CANCELED",
    "timeInForce": "GTT",
    "reduceOnly": false,
    "orderFlags": "64",
    "goodTilBlockTime": "2024-01-10T10:42:45.000Z",
    "createdAtHeight": "4993716",
    "clientMetadata": "0",
    "updatedAt": "2024-01-10T10:42:45.385Z",
    "updatedAtHeight": "4993921",
    "postOnly": true,
    "ticker": "ETH-USD"
  }
}

/getfills

Users can fetch the fill details of the order corresponding to the specified address and the specified sub-account number.

GET https://api.expand.network/derivative/getfills

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

subAccountNumber*

String

Number of the sub account.

https://api.expand.network/derivative/getfills?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d&subAccountNumber=0
{
    "status": 200,
        "msg": "success",
            "data": {
        "fills": [
            {
                "id": "025d1daa-3b12-5a65-a59a-fb57fefb6233",
                "side": "BUY",
                "liquidity": "TAKER",
                "type": "LIMIT",
                "market": "ETH-USD",
                "marketType": "PERPETUAL",
                "price": "2413.9",
                "size": "0.01",
                "fee": "0.01207",
                "createdAt": "2024-01-10T10:41:20.668Z",
                "createdAtHeight": "4993859",
                "orderId": "25432d45-2ac7-5476-991e-5c37a5d53cf7",
                "clientMetadata": "0"
            },
            {
                "id": "1017f858-a126-520e-bf3f-a579f5cc6c40",
                "side": "BUY",
                "liquidity": "TAKER",
                "type": "LIMIT",
                "market": "ETH-USD",
                "marketType": "PERPETUAL",
                "price": "2413.9",
                "size": "0.01",
                "fee": "0.01207",
                "createdAt": "2024-01-10T10:41:10.957Z",
                "createdAtHeight": "4993853",
                "orderId": "64900bdb-a4af-597f-897e-7d1ee7b3f9c5",
                "clientMetadata": "0"
            },
            {
                "id": "daae86a4-e125-5231-97e6-b1ea46174e3b",
                "side": "BUY",
                "liquidity": "TAKER",
                "type": "LIMIT",
                "market": "ETH-USD",
                "marketType": "PERPETUAL",
                "price": "2500",
                "size": "0.01",
                "fee": "0.0125",
                "createdAt": "2024-01-10T10:40:55.682Z",
                "createdAtHeight": "4993842",
                "orderId": "e2d931c4-7236-50dd-853e-72db64c7c67a",
                "clientMetadata": "0"
            }
        ]
    }
}

/getassets

Users can fetch a list of their assets deposited in dYdX corresponding to the specified address and the specified sub-account number.

GET https://api.expand.network/derivative/getassets

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

subAccountNumber*

String

Number of the sub account.

https://api.expand.network/derivative/getassets?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d&subAccountNumber=0
{
  "status": 200,
  "msg": "success",
  "data": {
    "assets": [
      {
        "size": "189.229062",
        "symbol": "USDC",
        "side": "SHORT",
        "assetId": "0"
      }
    ]
  }
}

/gethistoricalpnl

Users can fetch the historical profit and loss corresponding to the specified address and the specified sub-account number.

GET https://api.expand.network/derivative/gethistoricalpnl

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

subAccountNumber*

String

Number of the sub account.

https://api.expand.network/derivative/gethistoricalpnl?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d&subAccountNumber=0
{
    "status": 200,
        "msg": "success",
        "data": {
        "historicalPnL": [
            {
                "id": "4c3e3f94-ea28-5d34-8c60-95acc0e975fc",
                "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
                "equity": "509.314640",
                "totalPnl": "19.086934",
                "netTransfers": "0.000000",
                "createdAt": "2024-01-16T09:03:28.508Z",
                "blockHeight": "5355500",
                "blockTime": "2024-01-16T09:03:21.614Z"
            },
            {
                "id": "ee9d8bc8-af28-5f91-8edd-2982c6ff42ee",
                "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
                "equity": "509.314640",
                "totalPnl": "19.086934",
                "netTransfers": "0.000000",
                "createdAt": "2024-01-16T09:02:58.369Z",
                "blockHeight": "5355479",
                "blockTime": "2024-01-16T09:02:52.074Z"
            },
            {
                "id": "35420152-944c-5898-9465-42f4ec55bed4",
                "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
                "equity": "509.314640",
                "totalPnl": "19.086934",
                "netTransfers": "0.000000",
                "createdAt": "2024-01-16T09:02:28.204Z",
                "blockHeight": "5355457",
                "blockTime": "2024-01-16T09:02:21.962Z"
            },
            {
                "id": "b7b5f39a-47d4-55f2-b46f-48795dd83be9",
                "subaccountId": "8845f855-4943-5f72-9ad2-d0a2a416c5bd",
                "equity": "509.314640",
                "totalPnl": "19.086934",
                "netTransfers": "0.000000",
                "createdAt": "2024-01-16T09:01:58.165Z",
                "blockHeight": "5355434",
                "blockTime": "2024-01-16T09:01:51.006Z"
            }
        ]
    }
}

/getperpetualpositions

Users can fetch the position corresponding to the specified address and the specified sub-account number.

GET https://api.expand.network/derivative/getperpetualpositions

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

subAccountNumber*

String

Number of the sub account.

https://api.expand.network/derivative/getperpetualpositions?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d&subAccountNumber=0
{
    "status": 200,
        "msg": "success",
        "data": {
        "positions": [
            {
                "market": "ETH-USD",
                "status": "OPEN",
                "side": "LONG",
                "size": "0.275",
                "maxSize": "0.275",
                "entryPrice": "2446.92727272727272727273",
                "exitPrice": null,
                "realizedPnl": "-0.30197",
                "unrealizedPnl": "24.92914112499999999999925",
                "createdAt": "2023-11-01T09:40:35.893Z",
                "createdAtHeight": "882343",
                "closedAt": null,
                "sumOpen": "0.275",
                "sumClose": "0",
                "netFunding": "-0.30197"
            },
            {
                "market": "ETH-USD",
                "status": "CLOSED",
                "side": "LONG",
                "size": "0",
                "maxSize": "0.01",
                "entryPrice": "1851.3",
                "exitPrice": "1849.8",
                "realizedPnl": "-0.015",
                "unrealizedPnl": "0",
                "createdAt": "2023-10-26T08:22:15.515Z",
                "createdAtHeight": "532122",
                "closedAt": "2023-10-26T08:22:23.632Z",
                "sumOpen": "0.01",
                "sumClose": "0.01",
                "netFunding": "0"
            },
            {
                "market": "ETH-USD",
                "status": "CLOSED",
                "side": "SHORT",
                "size": "0",
                "maxSize": "-0.005",
                "entryPrice": "1847.1",
                "exitPrice": "1851.2",
                "realizedPnl": "-0.0205",
                "unrealizedPnl": "0",
                "createdAt": "2023-10-26T07:52:16.125Z",
                "createdAtHeight": "531124",
                "closedAt": "2023-10-26T07:59:24.633Z",
                "sumOpen": "0.005",
                "sumClose": "0.005",
                "netFunding": "0"
            }
        ]
    }
}

/getsubaccounts

Users can fetch the details of a sub-account corresponding to the specified address.

GET https://api.expand.network/derivative/getsubaccounts

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

https://api.expand.network/derivative/getsubaccounts?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d
{
  "status": 200,
  "msg": "success",
  "data": {
    "subaccounts": [
      {
        "address": "dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d",
        "subaccountNumber": 0,
        "equity": "507.190302025",
        "freeCollateral": "472.36933382375",
        "openPerpetualPositions": {
          "ETH-USD": {
            "market": "ETH-USD",
            "status": "OPEN",
            "side": "LONG",
            "size": "0.275",
            "maxSize": "0.275",
            "entryPrice": "2446.92727272727272727273",
            "exitPrice": null,
            "realizedPnl": "-0.30197",
            "unrealizedPnl": "23.51436402499999999999925",
            "createdAt": "2023-11-01T09:40:35.893Z",
            "createdAtHeight": "882343",
            "closedAt": null,
            "sumOpen": "0.275",
            "sumClose": "0",
            "netFunding": "-0.30197"
          }
        },
        "assetPositions": {
          "USDC": {
            "size": "189.229062",
            "symbol": "USDC",
            "side": "SHORT",
            "assetId": "0"
          }
        },
        "marginEnabled": true
      }
    ]
  }
}

/gettransfers

Users can fetch the details of the transfer transaction corresponding to the specified address and the specified sub-account number.

GET https://api.expand.network/derivative/gettransfers

Query Parameters

Name
Type
Description

address*

String

User's dydx address.

derivativeId

String

subAccountNumber*

String

Number of the sub account.

https://api.expand.network/derivative/gettransfers?derivativeId=1000&address=dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d&subAccountNumber=0
{
    "status": 200,
        "msg": "success",
        "data": {
        "transfers": [
            {
                "id": "a5a2714e-d9c9-5484-8bc4-8617b0c99954",
                "sender": {
                    "address": "dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d",
                    "subaccountNumber": 0
                },
                "recipient": {
                    "address": "dydx1eym66guf6xet6zl8c7h2h4c5hn4pglc75t2fem"
                },
                "size": "0.007239",
                "createdAt": "2024-01-15T15:42:48.451Z",
                "createdAtHeight": "5309897",
                "symbol": "USDC",
                "type": "WITHDRAWAL",
                "transactionHash": "B61FCF59F5AAE8E7F4D6C72D91B82050A825E41634DF457D9C2B90CDDCA20D2C"
            },
            {
                "id": "64b0c1f2-c8d8-529c-b2ee-f6a9617159b1",
                "sender": {
                    "address": "dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d",
                    "subaccountNumber": 0
                },
                "recipient": {
                    "address": "dydx150c8hssycjem2p9yfs9pa2xm4jjuvkn6t6w3v6"
                },
                "size": "0.007401",
                "createdAt": "2024-01-15T15:39:57.986Z",
                "createdAtHeight": "5309772",
                "symbol": "USDC",
                "type": "WITHDRAWAL",
                "transactionHash": "2F53FEAD71475DDA345AE2566851A6CEA10126047D0BDDC29D147DE47DCCDCB7"
            },
            {
                "id": "bee619f9-04bd-5756-b095-39a35078b6da",
                "sender": {
                    "address": "dydx13uxwm6gyyggdz92z47h0h2xdfqdfa0wrtykp2d",
                    "subaccountNumber": 0
                },
                "recipient": {
                    "address": "dydx1yt75rda3x7zxun8pcf3gtpt7mp5ultg0u9z43e"
                },
                "size": "0.00724",
                "createdAt": "2024-01-09T18:38:12.582Z",
                "createdAtHeight": "4954546",
                "symbol": "USDC",
                "type": "WITHDRAWAL",
                "transactionHash": "B8FCB72797B3C8772478A3B05D1DCE63A1BA96B99B359144A8DA8ADF2739EECE"
            }
        ]
    }
}
PreviousDerivativesNextFungible Tokens

Last updated 4 months ago

Refer to the page for details.

Refer to the page for details.

Refer to the page for details.

Refer to the page for details.

Refer to the page for details.

Refer to the page for details.

Refer to the page for details.

Refer to the page for details.

⛓️
⚡
Derivative Id
Derivative Id
Derivative Id
Derivative Id
Derivative Id
Derivative Id
Derivative Id
Derivative Id