Skip to content

Private Node API

Place Order

Execute a transaction that places an order on a market. This function takes parameters for wallet authentication, various order details, and optional transaction options to manage specific order types and behaviors.

Method Declaration

Python
async def place_order(
    self,
    wallet: Wallet,
    order: Order,
    tx_options: Optional[TxOptions] = None,
)
Unification Plan
  • Use a convenient Wallet and Order pair for all clients
  • TypeScript doesn't use authenticators
  • In Python we use them explicitly
  • Consider to do the same like in Rust (set it automatically)

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
orderqueryOrdertrueThe order to place.
tx_optionsqueryTxOptionsfalseOptions for transaction to support authenticators.

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | OK | TxHash | | 400 | Bad Request | | The request was malformed or invalid. |

Examples: Python | TypeScript | Rust | Guide - Place an order

Cancel Order

Terminate an existing order using the provided order ID and related parameters, such as block validity periods and transaction options.

Method Declaration

Python
async def cancel_order(
    self,
    wallet: Wallet,
    order_id: OrderId,
    good_til_block: int = None,
    good_til_block_time: int = None,
    tx_options: Optional[TxOptions] = None,
)
Unification Plan
  • Check the marketId is really needed (used in TypeScript)

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
order_idqueryOrderIdtrueThe ID of the order to cancel.
good_til_blockqueryi32falseThe block number until which the order is valid. Defaults to None.
good_til_block_timequeryi32falseThe block time until which the order is valid. Defaults to None.
tx_optionsqueryTxOptionsfalseOptions for transaction to support authenticators.

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | OK | TxHash | The transaction hash. | | 400 | Bad Request | | The request was malformed or invalid. | | 404 | Not Found | | The order was not found. |

Examples: Rust | Guide - Cancel an order

Batch Cancel Orders

Cancel a batch of short-terms orders.

Method Declaration

Python
async def batch_cancel_orders(
    self,
    wallet: Wallet,
    subaccount_id: SubaccountId,
    short_term_cancels: List[OrderBatch],
    good_til_block: int,
    tx_options: Optional[TxOptions] = None,
)
Unification Plan
  • TxOptions is not available in Rust

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
subaccount_idquerySubaccountIdtrueThe subaccount ID for which to cancel orders.
short_term_cancelsqueryOrderBatchtrueList of OrderBatch objects containing the orders to cancel.
good_til_blockqueryHeighttrueThe last block the short term order cancellations can be executed at.
tx_optionsqueryTxOptionsfalseOptions for transaction to support authenticators.

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | OK | [TxHash] | | 400 | Bad Request | | The request was malformed or invalid. | | 404 | Not Found | | The subaccount was not found. |

Examples: Python | TypeScript | Rust

Deposit

Deposit funds (USDC) from the address to the subaccount.

Method Declaration

Python
async def deposit(
    self,
    wallet: Wallet,
    sender: str,
    recipient_subaccount: SubaccountId,
    asset_id: int,
    quantums: int,
)
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
senderquerystringtrueThe sender address.
recipient_subaccountquerySubaccountIdtrueThe recipient subaccount ID.
asset_idqueryAssetIdtrueThe asset ID.
quantumsqueryinttrueThe amount of quantums to deposit. See more about quantums

Response

StatusMeaningSchemaDescription
200OKTxHash
400Bad RequestThe request was malformed or invalid.
404Not FoundThe subaccount was not found.

Withdraw

Withdraw funds (USDC) from the subaccount to the address.

Method Declaration

Python
async def withdraw(
    self,
    wallet: Wallet,
    sender_subaccount: SubaccountId,
    recipient: str,
    asset_id: int,
    quantums: int,
)
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
sender_subaccountquerySubaccountIdtrueThe sender subaccount ID.
recipientquerystringtrueThe recipient subaccount ID.
asset_idqueryAssetIdtrueThe asset ID.
quantumsqueryinttrueThe amount of quantums to withdraw.

Response

StatusMeaningSchemaDescription
200OKTxHashThe transaction hash.
400Bad RequestThe request was malformed or invalid.
404Not FoundThe subaccount was not found.

Examples: Python | TypeScript | Rust

Transfer

Transfer funds (USDC) between subaccounts.

Method Declaration

Python
async def transfer(
    self,
    wallet: Wallet,
    sender_subaccount: SubaccountId,
    recipient_subaccount: SubaccountId,
    asset_id: int,
    amount: int,
)
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
sender_subaccountquerySubaccountIdtrueThe sender subaccount ID.
recipient_subaccountquerySubaccountIdtrueThe recipient subaccount ID.
asset_idqueryAssetIdtrueThe asset ID.
amountqueryinttrueThe amount to transfer i USDC

Response

StatusMeaningSchemaDescription
200OKTxHashThe transaction hash.
400Bad RequestThe request was malformed or invalid.
404Not FoundThe subaccount was not found.

Examples: Python | TypeScript | Rust

Send Token

Transfer a specified token from one account/address to another.

It requires details such as the wallet for signing the transaction, sender and recipient addresses, and the quantum amount or denomination of the token.

Method Declaration

Python
async def send_token(
    self,
    wallet: Wallet,
    sender: str,
    recipient: str,
    quantums: int,
    denomination: str,
)
Unification Plan
  • All the types are different, revision is needed
  • Standard types like strings are used
  • Broadcast mode?
  • Zero fee?

Parameters

ParameterLocationTypeRequiredDescription
walletqueryWallettrueThe wallet to use for signing the transaction.
senderqueryStringtrueThe sender address.
recipientqueryStringtrueThe recipient address.
quantumsqueryi32trueThe amount of quantums to send.
denominationqueryi32trueThe denomination of the token.

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | OK | TxHash | | 400 | Bad Request | | The request was malformed or invalid. |

Examples: Rust

Simulate

Pre-execution simulation of a transaction, predicting its execution cost and resource usage without committing any changes.

This method typically returns information like estimated gas fees or other transaction-related metrics to anticipate the impact of operations before they are executed on the blockchain.

Method Declaration

Python
async def simulate(self, transaction: Tx)
Unification Plan
  • Some extra parameters in TypeScript? What to do with them?

Parameters

ParameterLocationTypeRequiredDescription
transactionqueryTxtrueThe transaction to simulate.

Response

| Status | Meaning | Schema | | ------ | ------------- | --------- | ------------------------------------- | | 200 | OK | GasInfo | | 400 | Bad Request | | The request was malformed or invalid. |

Examples: Python | TypeScript | Rust

Create Transaction

Create a transaction.

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeMandatoryDescription
accountqueryAccounttrueOwner's account information
msgqueryAnytrueMessage during create transaction
authqueryAddressfalse

Response

| Status | Meaning | Schema | | ------ | ------------- | --------- | ------------------------------------- | | 200 | OK | tx::Raw | | 400 | Bad Request | | The request was malformed or invalid. |

Broadcast Transaction

The Broadcast Transaction method is used to send a transaction to the network for processing.

The key parameters include the transaction itself and the mode of broadcasting, which is optional and defaults to synchronous broadcasting mode.

Method Declaration

Python
async def broadcast(self, transaction: Tx, mode=BroadcastMode.BROADCAST_MODE_SYNC)
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
transactionqueryTxtrueThe transaction to broadcast.
modequeryBroadcastModefalseThe broadcast mode. Defaults to BroadcastMode.BROADCAST_MODE_SYNC.

:::

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | OK | TxHash | | 400 | Bad Request | | The request was malformed or invalid. | | 404 | Not Found | | The transaction was not found. |

Examples: Rust

Create Market Permissionless

Create a market permissionless.

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeDescription
accountqueryAccountAccount information
tickerqueryTickerTicker information
subaccountquerySubaccountInfoSubaccount information

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | OK | TxHash | | 400 | Bad Request | | The request was malformed or invalid. | | 404 | Not Found | | The subaccount was not found. |

Delegate

Delegate tokens from a delegator to a validator.

Method Declaration

Python
 

Parameters

ParameterLocationTypeMandatoryDescription
subaccountquerySubaccountInfotrueSubaccount number
delegatorquerystringtrueDelegator information
validatorquerystringtruevalidator information
amountstringstringtrueAmount to delegate
broadcastModequeryBroadcastModefalseMode of broadcast

Response

StatusMeaningSchema
200[OK]BroadcastTxAsyncResponse

Undelegate

Undelegate coins from a delegator to a validator.

Method Declaration

Python
 

Parameters

ParameterLocationTypeMandatoryDescription
subaccountquerySubaccountInfotrueSubaccount number
delegatorquerystringtrueDelegator information
validatorquerystringtruevalidator information
amountstringstringtrueAmount to delegate
broadcastModequeryBroadcastModefalseMode of broadcast

Response

StatusMeaningSchema
200[OK]BroadcastTxAsyncResponse

Register Affiliate

Register affiliate.

Method Declaration

Python
 

Parameters

ParameterLocationTypeMandatoryDescription
subaccountquerySubaccountInfotrueSubaccount information
affiliatequerystringtrueAffiliate information
broadcastModequeryBroadcastModefalseMode of broadcast
gasAdjustmentqueryintfalseGas adjustment value

Response

StatusMeaningSchema
200OKBroadcastTxAsyncResponse

Withdraw Delegator Reward

Withdraw delegator reward.

Method Declaration

Python
 

Parameters

ParameterLocationTypeMandatoryDescription
subaccountquerySubaccountInfotrueSubaccount number
delegatorquerystringtrueDelegator information
validatorquerystringtruevalidator information
broadcastModequeryBroadcastModefalseMode of broadcast

Response

StatusMeaningSchema
200[OK]BroadcastTxAsyncResponse

Close Position

Close position for a given market.

Opposite short-term market orders are used. If provided, the position is only reduced by a size of reduce_by. Note that at the moment dYdX doesn’t support spot trading.

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
accountqueryAccounttrueThe wallet address that owns the subaccount.
subaccountquerySubaccounttrueSubaccount to close
market_paramsqueryOrderMarketParamstrueMarket parameters
reduced_byqueryBigDecimalfalse
client_idqueryClientIdtrue

Response

| Status | Meaning | Schema | | ------ | ------------- | -------- | ------------------------------------- | | 200 | [OK] | TxHash | | 400 | Bad Request | | The request was malformed or invalid. | | 404 | Not Found | | The subaccount was not found. |

Examples: Rust

Deposit to MegaVault

Deposit USDC into MegaVault

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeDescription
accountqueryAccountOwner's account information
subaccountquerySubaccountInfoSubaccount information
amountqueryintAmount to deposit

Response

StatusMeaningSchemaDescription
200[OK]TxHashThe transaction hash.
400Bad RequestThe request was malformed or invalid.
404Not FoundThe subaccount was not found.

Withdraw from MegaVault

Withdraw funds (USDC) from the subaccount to the address.

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeDescription
accountqueryAccountOwner's account
subaccountquerySubaccountInfoSubaccount information
min_amountqueryintMinimum amount to withdraw
sharesqueryBigIntNumber of shares

Response

StatusMeaningSchemaDescription
200[OK]TxHashThe transaction hash.
400Bad RequestThe request was malformed or invalid.
404Not FoundThe subaccount was not found.

Get Owner Shares in MegaVault

Query the shares associated with an [Address].

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeDescription
addressqueryAddressThe wallet address that owns the subaccount.

Response

| Status | Meaning | Schema | | ------ | ------------- | ----------------------------------- | ------------------------------------- | | 200 | OK | QueryMegavaultOwnerSharesResponse | | 400 | Bad Request | | The request was malformed or invalid. |

Get Withdrawal Info of MegaVault

Query the withdrawal information for a specified number of shares.

Method Declaration

Python
 
Unification Plan

Parameters

ParameterLocationTypeDescription
sharesqueryBigIntThe wallet address that owns the subaccount.

Response

| Status | Meaning | Schema | | ------ | ------------- | -------------------------------------- | ------------------------------------- | | 200 | OK | QueryMegavaultWithdrawalInfoResponse | | 400 | Bad Request | | The request was malformed or invalid. |