use async_trait::async_trait;
use serde_json::Value;
use crate::core::types::{
AccountType, ExchangeResult, Order,
AmendRequest, CancelScope, CancelAllResponse, OrderRequest, OrderResult,
TransferRequest, TransferHistoryFilter, TransferResponse,
DepositAddress, WithdrawRequest, WithdrawResponse, FundsRecord,
FundsHistoryFilter, SubAccountOperation, SubAccountResult,
MarginBorrowResponse, MarginRepayResponse, MarginInterestRecord,
EarnProduct, EarnPosition, ConvertQuote,
FundingPayment, FundingFilter,
LedgerEntry, LedgerFilter,
};
use super::{Trading, Account};
#[async_trait]
pub trait CancelAll: Trading {
async fn cancel_all_orders(
&self,
scope: CancelScope,
account_type: AccountType,
) -> ExchangeResult<CancelAllResponse>;
}
#[async_trait]
pub trait AmendOrder: Trading {
async fn amend_order(&self, req: AmendRequest) -> ExchangeResult<Order>;
}
#[async_trait]
pub trait BatchOrders: Trading {
async fn place_orders_batch(
&self,
orders: Vec<OrderRequest>,
) -> ExchangeResult<Vec<OrderResult>>;
async fn cancel_orders_batch(
&self,
order_ids: Vec<String>,
symbol: Option<&str>,
account_type: AccountType,
) -> ExchangeResult<Vec<OrderResult>>;
fn max_batch_place_size(&self) -> usize;
fn max_batch_cancel_size(&self) -> usize;
}
#[async_trait]
pub trait AccountTransfers: Account {
async fn transfer(&self, req: TransferRequest) -> ExchangeResult<TransferResponse>;
async fn get_transfer_history(
&self,
filter: TransferHistoryFilter,
) -> ExchangeResult<Vec<TransferResponse>>;
}
#[async_trait]
pub trait CustodialFunds: Account {
async fn get_deposit_address(
&self,
asset: &str,
network: Option<&str>,
) -> ExchangeResult<DepositAddress>;
async fn withdraw(&self, req: WithdrawRequest) -> ExchangeResult<WithdrawResponse>;
async fn get_funds_history(
&self,
filter: FundsHistoryFilter,
) -> ExchangeResult<Vec<FundsRecord>>;
}
#[async_trait]
pub trait SubAccounts: Account {
async fn sub_account_operation(
&self,
op: SubAccountOperation,
) -> ExchangeResult<SubAccountResult>;
}
#[async_trait]
pub trait MarginTrading: Send + Sync {
async fn margin_borrow(
&self,
asset: &str,
amount: f64,
account_type: AccountType,
) -> ExchangeResult<MarginBorrowResponse> {
let _ = (asset, amount, account_type);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"margin_borrow".to_string(),
))
}
async fn margin_repay(
&self,
asset: &str,
amount: f64,
account_type: AccountType,
) -> ExchangeResult<MarginRepayResponse> {
let _ = (asset, amount, account_type);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"margin_repay".to_string(),
))
}
async fn get_margin_interest(
&self,
asset: Option<&str>,
) -> ExchangeResult<Vec<MarginInterestRecord>> {
let _ = asset;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_margin_interest".to_string(),
))
}
async fn get_margin_account(
&self,
account_type: AccountType,
) -> ExchangeResult<Value> {
let _ = account_type;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_margin_account".to_string(),
))
}
}
#[async_trait]
pub trait EarnStaking: Send + Sync {
async fn get_earn_products(
&self,
asset: Option<&str>,
) -> ExchangeResult<Vec<EarnProduct>> {
let _ = asset;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_earn_products".to_string(),
))
}
async fn subscribe_earn(
&self,
product_id: &str,
amount: f64,
) -> ExchangeResult<Value> {
let _ = (product_id, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"subscribe_earn".to_string(),
))
}
async fn redeem_earn(
&self,
product_id: &str,
amount: f64,
) -> ExchangeResult<Value> {
let _ = (product_id, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"redeem_earn".to_string(),
))
}
async fn get_earn_positions(&self) -> ExchangeResult<Vec<EarnPosition>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_earn_positions".to_string(),
))
}
}
#[async_trait]
pub trait ConvertSwap: Send + Sync {
async fn get_convert_quote(
&self,
from_asset: &str,
to_asset: &str,
amount: f64,
) -> ExchangeResult<ConvertQuote> {
let _ = (from_asset, to_asset, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_convert_quote".to_string(),
))
}
async fn accept_convert_quote(&self, quote_id: &str) -> ExchangeResult<Value> {
let _ = quote_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"accept_convert_quote".to_string(),
))
}
async fn get_convert_history(
&self,
start_time: Option<u64>,
end_time: Option<u64>,
) -> ExchangeResult<Vec<Value>> {
let _ = (start_time, end_time);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_convert_history".to_string(),
))
}
async fn convert_dust(&self, assets: Vec<String>) -> ExchangeResult<Value> {
let _ = assets;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"convert_dust".to_string(),
))
}
}
#[async_trait]
pub trait CopyTrading: Send + Sync {
async fn get_lead_traders(&self, limit: Option<u32>) -> ExchangeResult<Vec<Value>> {
let _ = limit;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_lead_traders".to_string(),
))
}
async fn follow_trader(&self, trader_id: &str) -> ExchangeResult<Value> {
let _ = trader_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"follow_trader".to_string(),
))
}
async fn stop_following(&self, trader_id: &str) -> ExchangeResult<()> {
let _ = trader_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"stop_following".to_string(),
))
}
async fn get_copy_positions(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_copy_positions".to_string(),
))
}
}
#[async_trait]
pub trait LiquidityProvider: Send + Sync {
async fn create_lp_position(
&self,
pool_id: &str,
amount_a: f64,
amount_b: f64,
) -> ExchangeResult<Value> {
let _ = (pool_id, amount_a, amount_b);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"create_lp_position".to_string(),
))
}
async fn add_liquidity(
&self,
position_id: &str,
amount_a: f64,
amount_b: f64,
) -> ExchangeResult<Value> {
let _ = (position_id, amount_a, amount_b);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"add_liquidity".to_string(),
))
}
async fn remove_liquidity(
&self,
position_id: &str,
percentage: f64,
) -> ExchangeResult<Value> {
let _ = (position_id, percentage);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"remove_liquidity".to_string(),
))
}
async fn collect_fees(&self, position_id: &str) -> ExchangeResult<Value> {
let _ = position_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"collect_fees".to_string(),
))
}
async fn get_lp_positions(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_lp_positions".to_string(),
))
}
}
#[async_trait]
pub trait VaultManager: Send + Sync {
async fn get_vaults(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_vaults".to_string(),
))
}
async fn deposit_vault(&self, vault_id: &str, amount: f64) -> ExchangeResult<Value> {
let _ = (vault_id, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"deposit_vault".to_string(),
))
}
async fn withdraw_vault(&self, vault_id: &str, amount: f64) -> ExchangeResult<Value> {
let _ = (vault_id, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"withdraw_vault".to_string(),
))
}
async fn get_vault_positions(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_vault_positions".to_string(),
))
}
}
#[async_trait]
pub trait StakingDelegation: Send + Sync {
async fn delegate(&self, validator: &str, amount: f64) -> ExchangeResult<Value> {
let _ = (validator, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"delegate".to_string(),
))
}
async fn undelegate(&self, validator: &str, amount: f64) -> ExchangeResult<Value> {
let _ = (validator, amount);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"undelegate".to_string(),
))
}
async fn get_delegations(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_delegations".to_string(),
))
}
async fn claim_staking_rewards(&self) -> ExchangeResult<Value> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"claim_staking_rewards".to_string(),
))
}
}
#[async_trait]
pub trait BlockTradeOtc: Send + Sync {
async fn create_block_trade(&self, params: Value) -> ExchangeResult<Value> {
let _ = params;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"create_block_trade".to_string(),
))
}
async fn verify_block_trade(&self, params: Value) -> ExchangeResult<Value> {
let _ = params;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"verify_block_trade".to_string(),
))
}
async fn execute_block_trade(&self, trade_id: &str) -> ExchangeResult<Value> {
let _ = trade_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"execute_block_trade".to_string(),
))
}
async fn get_block_trades(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_block_trades".to_string(),
))
}
}
#[async_trait]
pub trait MarketMakerProtection: Send + Sync {
async fn get_mmp_config(&self) -> ExchangeResult<Value> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_mmp_config".to_string(),
))
}
async fn set_mmp_config(&self, config: Value) -> ExchangeResult<()> {
let _ = config;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"set_mmp_config".to_string(),
))
}
async fn reset_mmp(&self) -> ExchangeResult<()> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"reset_mmp".to_string(),
))
}
async fn mass_quote(&self, quotes: Vec<Value>) -> ExchangeResult<Vec<Value>> {
let _ = quotes;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"mass_quote".to_string(),
))
}
}
#[async_trait]
pub trait TriggerOrders: Send + Sync {
async fn place_trigger_order(&self, params: Value) -> ExchangeResult<Value> {
let _ = params;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"place_trigger_order".to_string(),
))
}
async fn cancel_trigger_order(&self, order_id: &str) -> ExchangeResult<()> {
let _ = order_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"cancel_trigger_order".to_string(),
))
}
async fn get_trigger_orders(
&self,
symbol: Option<&str>,
) -> ExchangeResult<Vec<Value>> {
let _ = symbol;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_trigger_orders".to_string(),
))
}
}
#[async_trait]
pub trait PredictionMarket: Send + Sync {
async fn get_prediction_events(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_prediction_events".to_string(),
))
}
async fn get_event_orderbook(&self, event_id: &str) -> ExchangeResult<Value> {
let _ = event_id;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_event_orderbook".to_string(),
))
}
async fn place_prediction_order(&self, params: Value) -> ExchangeResult<Value> {
let _ = params;
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"place_prediction_order".to_string(),
))
}
async fn get_prediction_positions(&self) -> ExchangeResult<Vec<Value>> {
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_prediction_positions".to_string(),
))
}
}
#[async_trait]
pub trait FundingHistory: Send + Sync {
async fn get_funding_payments(
&self,
filter: FundingFilter,
account_type: AccountType,
) -> ExchangeResult<Vec<FundingPayment>> {
let _ = (filter, account_type);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_funding_payments not implemented".into(),
))
}
}
#[async_trait]
pub trait AccountLedger: Send + Sync {
async fn get_ledger(
&self,
filter: LedgerFilter,
account_type: AccountType,
) -> ExchangeResult<Vec<LedgerEntry>> {
let _ = (filter, account_type);
Err(crate::core::types::ExchangeError::UnsupportedOperation(
"get_ledger not implemented".into(),
))
}
}