rango_sdk/client/
quote.rs

1use crate::{
2    error::SdkErr,
3    quote::{QuoteRequest, QuoteResponse},
4};
5
6impl super::Client {
7    /// Getting a quote for requested swap
8    /// Rango will find the best route from available DEX or bridges for doing the swap. Quote is a preview of route, if the quote confirmed by the user, you will need to use `swap` for getting the actual swap and complete the swap.
9    pub async fn quote(&self, request: QuoteRequest) -> Result<QuoteResponse, SdkErr> {
10        let qs = request.into_qs()?;
11
12        let url = format!(
13            "{}/{}?apiKey={}&{}",
14            self.config.api_url, "basic/quote", self.config.api_key, qs
15        );
16
17        let body: QuoteResponse = ureq::get(&url).call()?.into_json()?;
18        Ok(body)
19    }
20}