pub trait StellarDexServiceTrait: Send + Sync {
// Required methods
fn supported_asset_types(&self) -> HashSet<AssetType>;
fn get_token_to_xlm_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 str,
amount: u64,
slippage: f32,
asset_decimals: Option<u8>,
) -> Pin<Box<dyn Future<Output = Result<StellarQuoteResponse, StellarDexServiceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_xlm_to_token_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 str,
amount: u64,
slippage: f32,
asset_decimals: Option<u8>,
) -> Pin<Box<dyn Future<Output = Result<StellarQuoteResponse, StellarDexServiceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn prepare_swap_transaction<'life0, 'async_trait>(
&'life0 self,
params: SwapTransactionParams,
) -> Pin<Box<dyn Future<Output = Result<(String, StellarQuoteResponse), StellarDexServiceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn execute_swap<'life0, 'async_trait>(
&'life0 self,
params: SwapTransactionParams,
) -> Pin<Box<dyn Future<Output = Result<SwapExecutionResult, StellarDexServiceError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn can_handle_asset(&self, asset_id: &str) -> bool { ... }
}Expand description
Trait for Stellar DEX services
Required Methods§
Sourcefn supported_asset_types(&self) -> HashSet<AssetType>
fn supported_asset_types(&self) -> HashSet<AssetType>
Returns the asset types this DEX service can handle
§Returns
A set of supported asset types (Native, Classic, Contract, or combinations)
Sourcefn get_token_to_xlm_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 str,
amount: u64,
slippage: f32,
asset_decimals: Option<u8>,
) -> Pin<Box<dyn Future<Output = Result<StellarQuoteResponse, StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_token_to_xlm_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 str,
amount: u64,
slippage: f32,
asset_decimals: Option<u8>,
) -> Pin<Box<dyn Future<Output = Result<StellarQuoteResponse, StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a quote for converting a token to XLM
§Arguments
asset_id- Asset identifier (e.g., “native” for XLM, or “USDC:GA5Z…” for credit assets)amount- Amount in stroops to convertslippage- Slippage percentage (e.g., 1.0 for 1%)asset_decimals- Number of decimal places for the asset (defaults to 7 if None)
§Returns
A quote response with conversion details
Sourcefn get_xlm_to_token_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 str,
amount: u64,
slippage: f32,
asset_decimals: Option<u8>,
) -> Pin<Box<dyn Future<Output = Result<StellarQuoteResponse, StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_xlm_to_token_quote<'life0, 'life1, 'async_trait>(
&'life0 self,
asset_id: &'life1 str,
amount: u64,
slippage: f32,
asset_decimals: Option<u8>,
) -> Pin<Box<dyn Future<Output = Result<StellarQuoteResponse, StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn prepare_swap_transaction<'life0, 'async_trait>(
&'life0 self,
params: SwapTransactionParams,
) -> Pin<Box<dyn Future<Output = Result<(String, StellarQuoteResponse), StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn prepare_swap_transaction<'life0, 'async_trait>(
&'life0 self,
params: SwapTransactionParams,
) -> Pin<Box<dyn Future<Output = Result<(String, StellarQuoteResponse), StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Prepare a swap transaction (get quote and build XDR) without executing it
This method creates an unsigned transaction XDR for a swap operation. The transaction can then be queued for background processing.
§Arguments
params- Swap transaction parameters including source account, assets, amounts, sequence number, and network passphrase
§Returns
A tuple containing:
String- Unsigned transaction XDR (base64 encoded)StellarQuoteResponse- Quote information including destination amount
Sourcefn execute_swap<'life0, 'async_trait>(
&'life0 self,
params: SwapTransactionParams,
) -> Pin<Box<dyn Future<Output = Result<SwapExecutionResult, StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_swap<'life0, 'async_trait>(
&'life0 self,
params: SwapTransactionParams,
) -> Pin<Box<dyn Future<Output = Result<SwapExecutionResult, StellarDexServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute a swap transaction
This method creates, signs, and submits a Stellar transaction with a path payment
operation based on the quote from get_token_to_xlm_quote or get_xlm_to_token_quote.
§Arguments
params- Swap transaction parameters including source account, assets, amounts, sequence number, and network passphrase
§Returns
A SwapExecutionResult containing the transaction hash and destination amount received