Skip to main content

Funding

Trait Funding 

Source
pub trait Funding: PublicExchange {
    // Required methods
    fn fetch_deposit_address<'life0, 'life1, 'async_trait>(
        &'life0 self,
        code: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<DepositAddress>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_deposit_address_on_network<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        code: &'life1 str,
        network: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<DepositAddress>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn withdraw<'life0, 'async_trait>(
        &'life0 self,
        params: WithdrawParams,
    ) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn transfer<'life0, 'async_trait>(
        &'life0 self,
        params: TransferParams,
    ) -> Pin<Box<dyn Future<Output = Result<Transfer>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_deposits<'life0, 'life1, 'async_trait>(
        &'life0 self,
        code: Option<&'life1 str>,
        since: Option<i64>,
        limit: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fetch_withdrawals<'life0, 'life1, 'async_trait>(
        &'life0 self,
        code: Option<&'life1 str>,
        since: Option<i64>,
        limit: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn fetch_deposits_u64<'life0, 'life1, 'async_trait>(
        &'life0 self,
        code: Option<&'life1 str>,
        since: Option<u64>,
        limit: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn fetch_withdrawals_u64<'life0, 'life1, 'async_trait>(
        &'life0 self,
        code: Option<&'life1 str>,
        since: Option<u64>,
        limit: Option<u32>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for deposit and withdrawal operations.

This trait provides methods for managing deposits, withdrawals, and inter-account transfers. All methods require authentication and are async.

§Timestamp Format

All timestamp parameters and fields in returned data structures use:

  • Type: i64
  • Unit: Milliseconds since Unix epoch (January 1, 1970, 00:00:00 UTC)
  • Example: 1609459200000 represents January 1, 2021, 00:00:00 UTC

§Supertrait

Requires PublicExchange as a supertrait to access exchange metadata and capabilities.

§Thread Safety

This trait requires Send + Sync bounds (inherited from PublicExchange) to ensure safe usage across thread boundaries in async contexts.

Required Methods§

Source

fn fetch_deposit_address<'life0, 'life1, 'async_trait>( &'life0 self, code: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<DepositAddress>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch deposit address for a currency.

Returns the deposit address for the specified currency on the default network.

§Arguments
  • code - Currency code (e.g., “BTC”, “USDT”)
§Example
let address = exchange.fetch_deposit_address("USDT").await?;
println!("Deposit to: {}", address.address);
Source

fn fetch_deposit_address_on_network<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, code: &'life1 str, network: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<DepositAddress>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetch deposit address for a specific network.

§Arguments
  • code - Currency code (e.g., “USDT”)
  • network - Network name (e.g., “TRC20”, “ERC20”, “BEP20”)
§Example
let address = exchange.fetch_deposit_address_on_network("USDT", "TRC20").await?;
println!("TRC20 address: {}", address.address);
Source

fn withdraw<'life0, 'async_trait>( &'life0 self, params: WithdrawParams, ) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Withdraw funds to an external address.

§Arguments
  • params - Withdrawal parameters including currency, amount, address, and optional network
§Example
use ccxt_core::types::params::WithdrawParams;
use rust_decimal_macros::dec;

let tx = exchange.withdraw(
    WithdrawParams::new("USDT", dec!(100), "TAddress...")
        .network("TRC20")
).await?;
println!("Withdrawal ID: {}", tx.id);
Source

fn transfer<'life0, 'async_trait>( &'life0 self, params: TransferParams, ) -> Pin<Box<dyn Future<Output = Result<Transfer>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Transfer funds between accounts.

§Arguments
  • params - Transfer parameters including currency, amount, source and destination accounts
§Example
use ccxt_core::types::params::TransferParams;
use rust_decimal_macros::dec;

// Transfer USDT from spot to futures
let transfer = exchange.transfer(
    TransferParams::spot_to_futures("USDT", dec!(1000))
).await?;
Source

fn fetch_deposits<'life0, 'life1, 'async_trait>( &'life0 self, code: Option<&'life1 str>, since: Option<i64>, limit: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch deposit history.

§Arguments
  • code - Optional currency code to filter by (e.g., “USDT”, “BTC”)
  • since - Optional start timestamp in milliseconds (i64) since Unix epoch
  • limit - Optional maximum number of records to return
§Timestamp Format

The since parameter uses i64 milliseconds since Unix epoch:

  • 1609459200000 = January 1, 2021, 00:00:00 UTC
  • chrono::Utc::now().timestamp_millis() = Current time
  • chrono::Utc::now().timestamp_millis() - 2592000000 = 30 days ago
§Example
// All deposits (no filters)
let deposits = exchange.fetch_deposits(None, None, None).await?;

// USDT deposits from the last 30 days
let since = chrono::Utc::now().timestamp_millis() - 2592000000;
let deposits = exchange.fetch_deposits(Some("USDT"), Some(since), Some(100)).await?;
Source

fn fetch_withdrawals<'life0, 'life1, 'async_trait>( &'life0 self, code: Option<&'life1 str>, since: Option<i64>, limit: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch withdrawal history.

§Arguments
  • code - Optional currency code to filter by (e.g., “BTC”, “ETH”)
  • since - Optional start timestamp in milliseconds (i64) since Unix epoch
  • limit - Optional maximum number of records to return
§Timestamp Format

The since parameter uses i64 milliseconds since Unix epoch:

  • 1609459200000 = January 1, 2021, 00:00:00 UTC
  • chrono::Utc::now().timestamp_millis() = Current time
  • chrono::Utc::now().timestamp_millis() - 604800000 = 7 days ago
§Example
// All withdrawals (no filters)
let withdrawals = exchange.fetch_withdrawals(None, None, None).await?;

// Recent BTC withdrawals from the last 7 days
let since = chrono::Utc::now().timestamp_millis() - 604800000;
let withdrawals = exchange.fetch_withdrawals(Some("BTC"), Some(since), Some(50)).await?;

Provided Methods§

Source

fn fetch_deposits_u64<'life0, 'life1, 'async_trait>( &'life0 self, code: Option<&'life1 str>, since: Option<u64>, limit: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

👎Deprecated since 0.1.0: Use fetch_deposits with i64 timestamps. Convert using TimestampUtils::u64_to_i64()

Fetch deposit history with u64 timestamp filtering (deprecated).

DEPRECATED: Use fetch_deposits with i64 timestamps instead. This method is provided for backward compatibility during migration.

§Migration
// Old code (deprecated)
let deposits = exchange.fetch_deposits_u64(Some("USDT"), Some(1609459200000u64), Some(100)).await?;

// New code (recommended)
let deposits = exchange.fetch_deposits(Some("USDT"), Some(1609459200000i64), Some(100)).await?;
Source

fn fetch_withdrawals_u64<'life0, 'life1, 'async_trait>( &'life0 self, code: Option<&'life1 str>, since: Option<u64>, limit: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

👎Deprecated since 0.1.0: Use fetch_withdrawals with i64 timestamps. Convert using TimestampUtils::u64_to_i64()

Fetch withdrawal history with u64 timestamp filtering (deprecated).

DEPRECATED: Use fetch_withdrawals with i64 timestamps instead. This method is provided for backward compatibility during migration.

§Migration
// Old code (deprecated)
let withdrawals = exchange.fetch_withdrawals_u64(Some("BTC"), Some(1609459200000u64), Some(50)).await?;

// New code (recommended)
let withdrawals = exchange.fetch_withdrawals(Some("BTC"), Some(1609459200000i64), Some(50)).await?;

Implementors§