Skip to main content
The useExchangeAccounts hook provides functionality for managing exchange accounts and performing exchange-related operations. It allows users to retrieve their exchange accounts, view transaction history, and execute transfers between exchange accounts. This hook integrates with the Dynamic SDK to handle exchange operations across different blockchain networks and exchange platforms.
This hook supports the Fund from Exchange feature, allowing users to transfer funds directly from their exchange accounts to their wallets.

Available Methods

Methods

exchangeTransfer

Summary: Executes a transfer between exchange accounts. The method automatically finds the appropriate account based on the currency being transferred and creates the transfer request. Inputs: CreateExchangeTransferRequest Fields: Outputs: ExchangeTransferResponse Fields: Example Response:
Example:

getExchangeTransactions

Summary: Retrieves transaction history for exchange accounts. Can fetch transactions for a specific account or all accounts if no accountId is provided. Inputs: Outputs: ExchangeTransaction Fields: Example Response:
Example:

getExchangeUserAccounts

Summary: Retrieves all exchange accounts associated with the current user for a specific exchange platform. Returns accounts with their balances and currency information. Inputs: Outputs: Account Fields: Balance Fields: Example Response:
Example:

Usage Example

Error Handling

The hook throws DynamicError with specific error codes when operations fail:
  • UnprocessableEntityErrorCode.InvalidTransferCurrency: Thrown when no account is found for the specified currency during transfer operations.

Dependencies

This hook depends on:
  • useInternalDynamicContext for accessing wallet and network information
  • Dynamic SDK data layer for API calls
  • Environment configuration for API endpoints