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
async def place_order(
self,
wallet: Wallet,
order: Order,
tx_options: Optional[TxOptions] = None,
)
Unification Plan
- Use a convenient
Wallet
andOrder
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
order | query | Order | true | The order to place. |
tx_options | query | TxOptions | false | Options 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
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 inTypeScript
)
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
order_id | query | OrderId | true | The ID of the order to cancel. |
good_til_block | query | i32 | false | The block number until which the order is valid. Defaults to None. |
good_til_block_time | query | i32 | false | The block time until which the order is valid. Defaults to None. |
tx_options | query | TxOptions | false | Options 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
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
subaccount_id | query | SubaccountId | true | The subaccount ID for which to cancel orders. |
short_term_cancels | query | OrderBatch ⛁ | true | List of OrderBatch objects containing the orders to cancel. |
good_til_block | query | Height | true | The last block the short term order cancellations can be executed at. |
tx_options | query | TxOptions | false | Options 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
async def deposit(
self,
wallet: Wallet,
sender: str,
recipient_subaccount: SubaccountId,
asset_id: int,
quantums: int,
)
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
sender | query | string | true | The sender address. |
recipient_subaccount | query | SubaccountId | true | The recipient subaccount ID. |
asset_id | query | AssetId | true | The asset ID. |
quantums | query | int | true | The amount of quantums to deposit. See more about quantums |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | TxHash | |
400 | Bad Request | The request was malformed or invalid. | |
404 | Not Found | The subaccount was not found. |
Withdraw
Withdraw funds (USDC) from the subaccount to the address.
Method Declaration
async def withdraw(
self,
wallet: Wallet,
sender_subaccount: SubaccountId,
recipient: str,
asset_id: int,
quantums: int,
)
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
sender_subaccount | query | SubaccountId | true | The sender subaccount ID. |
recipient | query | string | true | The recipient subaccount ID. |
asset_id | query | AssetId | true | The asset ID. |
quantums | query | int | true | The amount of quantums to withdraw. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | TxHash | The transaction hash. |
400 | Bad Request | The request was malformed or invalid. | |
404 | Not Found | The subaccount was not found. |
Examples: Python | TypeScript | Rust
Transfer
Transfer funds (USDC) between subaccounts.
Method Declaration
async def transfer(
self,
wallet: Wallet,
sender_subaccount: SubaccountId,
recipient_subaccount: SubaccountId,
asset_id: int,
amount: int,
)
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
sender_subaccount | query | SubaccountId | true | The sender subaccount ID. |
recipient_subaccount | query | SubaccountId | true | The recipient subaccount ID. |
asset_id | query | AssetId | true | The asset ID. |
amount | query | int | true | The amount to transfer i USDC |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | TxHash | The transaction hash. |
400 | Bad Request | The request was malformed or invalid. | |
404 | Not Found | The 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
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
wallet | query | Wallet | true | The wallet to use for signing the transaction. |
sender | query | String | true | The sender address. |
recipient | query | String | true | The recipient address. |
quantums | query | i32 | true | The amount of quantums to send. |
denomination | query | i32 | true | The 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
async def simulate(self, transaction: Tx)
Unification Plan
- Some extra parameters in TypeScript? What to do with them?
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
transaction | query | Tx | true | The 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
Unification Plan
Parameters
Parameter | Location | Type | Mandatory | Description |
---|---|---|---|---|
account | query | Account | true | Owner's account information |
msg | query | Any | true | Message during create transaction |
auth | query | Address | false |
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
async def broadcast(self, transaction: Tx, mode=BroadcastMode.BROADCAST_MODE_SYNC)
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
transaction | query | Tx | true | The transaction to broadcast. |
mode | query | BroadcastMode | false | The 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
Unification Plan
Parameters
Parameter | Location | Type | Description |
---|---|---|---|
account | query | Account | Account information |
ticker | query | Ticker | Ticker information |
subaccount | query | SubaccountInfo | Subaccount 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
Parameters
Parameter | Location | Type | Mandatory | Description |
---|---|---|---|---|
subaccount | query | SubaccountInfo | true | Subaccount number |
delegator | query | string | true | Delegator information |
validator | query | string | true | validator information |
amount | string | string | true | Amount to delegate |
broadcastMode | query | BroadcastMode | false | Mode of broadcast |
Response
Status | Meaning | Schema |
---|---|---|
200 | [OK] | BroadcastTxAsyncResponse |
Undelegate
Undelegate coins from a delegator to a validator.
Method Declaration
Parameters
Parameter | Location | Type | Mandatory | Description |
---|---|---|---|---|
subaccount | query | SubaccountInfo | true | Subaccount number |
delegator | query | string | true | Delegator information |
validator | query | string | true | validator information |
amount | string | string | true | Amount to delegate |
broadcastMode | query | BroadcastMode | false | Mode of broadcast |
Response
Status | Meaning | Schema |
---|---|---|
200 | [OK] | BroadcastTxAsyncResponse |
Register Affiliate
Register affiliate.
Method Declaration
Parameters
Parameter | Location | Type | Mandatory | Description |
---|---|---|---|---|
subaccount | query | SubaccountInfo | true | Subaccount information |
affiliate | query | string | true | Affiliate information |
broadcastMode | query | BroadcastMode | false | Mode of broadcast |
gasAdjustment | query | int | false | Gas adjustment value |
Response
Status | Meaning | Schema |
---|---|---|
200 | OK | BroadcastTxAsyncResponse |
Withdraw Delegator Reward
Withdraw delegator reward.
Method Declaration
Parameters
Parameter | Location | Type | Mandatory | Description |
---|---|---|---|---|
subaccount | query | SubaccountInfo | true | Subaccount number |
delegator | query | string | true | Delegator information |
validator | query | string | true | validator information |
broadcastMode | query | BroadcastMode | false | Mode of broadcast |
Response
Status | Meaning | Schema |
---|---|---|
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
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
account | query | Account | true | The wallet address that owns the subaccount. |
subaccount | query | Subaccount | true | Subaccount to close |
market_params | query | OrderMarketParams | true | Market parameters |
reduced_by | query | BigDecimal | false | |
client_id | query | ClientId | true |
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
Unification Plan
Parameters
Parameter | Location | Type | Description |
---|---|---|---|
account | query | Account | Owner's account information |
subaccount | query | SubaccountInfo | Subaccount information |
amount | query | int | Amount to deposit |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | [OK] | TxHash | The transaction hash. |
400 | Bad Request | The request was malformed or invalid. | |
404 | Not Found | The subaccount was not found. |
Withdraw from MegaVault
Withdraw funds (USDC) from the subaccount to the address.
Method Declaration
Unification Plan
Parameters
Parameter | Location | Type | Description |
---|---|---|---|
account | query | Account | Owner's account |
subaccount | query | SubaccountInfo | Subaccount information |
min_amount | query | int | Minimum amount to withdraw |
shares | query | BigInt | Number of shares |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | [OK] | TxHash | The transaction hash. |
400 | Bad Request | The request was malformed or invalid. | |
404 | Not Found | The subaccount was not found. |
Get Owner Shares in MegaVault
Query the shares associated with an [Address
].
Method Declaration
Unification Plan
Parameters
Parameter | Location | Type | Description |
---|---|---|---|
address | query | Address | The 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
Unification Plan
Parameters
Parameter | Location | Type | Description |
---|---|---|---|
shares | query | BigInt | The wallet address that owns the subaccount. |
Response
| Status | Meaning | Schema |
| ------ | ------------- | -------------------------------------- | ------------------------------------- |
| 200
| OK | QueryMegavaultWithdrawalInfoResponse |
| 400
| Bad Request | | The request was malformed or invalid. |