Skip to content

Commit 431aa7b

Browse files
committed
Remove price API
1 parent 621ab22 commit 431aa7b

2 files changed

Lines changed: 4 additions & 38 deletions

File tree

examples/quotes.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ async fn main() -> jup_ag::Result<()> {
1515

1616
let ui_amount = 1.;
1717

18-
for (output_token, output_decimals) in [(usdc, 6), (msol, 9), (sol, 9)] {
19-
let data = jup_ag::price(sol, output_token, ui_amount).await?;
20-
println!(
21-
"Price for {} {} is {} {}",
22-
ui_amount, data.input_symbol, data.price, data.output_symbol
23-
);
24-
18+
for (output_token, output_token_name, output_decimals) in [(usdc, "USDC", 6), (msol, "mSOL", 9)]
19+
{
2520
let slippage_bps = 100;
2621
let only_direct_routes = false;
2722
let quotes = jup_ag::quote(
@@ -44,12 +39,11 @@ async fn main() -> jup_ag::Result<()> {
4439
.label
4540
.unwrap_or_else(|| "Unknown DEX".to_string());
4641
println!(
47-
"{}. {} {} for {} {} via {} (worst case with slippage: {}). Impact: {:.2}%",
42+
"{}. {} SOL for {} {} via {} (worst case with slippage: {}). Impact: {:.2}%",
4843
i,
4944
amount_to_ui_amount(quote.swap_info.in_amount, 9),
50-
data.input_symbol,
5145
amount_to_ui_amount(quote.swap_info.out_amount, output_decimals),
52-
data.output_symbol,
46+
output_token_name,
5347
route,
5448
amount_to_ui_amount(quotes.other_amount_threshold, output_decimals),
5549
quotes.price_impact_pct * 100.

src/lib.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ fn quote_api_url() -> String {
2020
env::var("QUOTE_API_URL").unwrap_or_else(|_| "https://api.jup.ag/swap/v1".to_string())
2121
}
2222

23-
// Reference: https://quote-api.jup.ag/docs/static/index.html
24-
fn price_api_url() -> String {
25-
env::var("PRICE_API_URL").unwrap_or_else(|_| "https://api.jup.ag/price/v2".to_string())
26-
}
27-
2823
/// The Errors that may occur while using this crate
2924
#[derive(thiserror::Error, Debug)]
3025
pub enum Error {
@@ -50,20 +45,6 @@ pub enum Error {
5045
ParseSwapMode { value: String },
5146
}
5247

53-
#[derive(Clone, Debug, Deserialize)]
54-
#[serde(rename_all = "camelCase")]
55-
pub struct Price {
56-
#[serde(with = "field_as_string", rename = "id")]
57-
pub input_mint: Pubkey,
58-
#[serde(rename = "mintSymbol")]
59-
pub input_symbol: String,
60-
#[serde(with = "field_as_string", rename = "vsToken")]
61-
pub output_mint: Pubkey,
62-
#[serde(rename = "vsTokenSymbol")]
63-
pub output_symbol: String,
64-
pub price: f64,
65-
}
66-
6748
#[derive(Clone, Debug, Deserialize, Serialize)]
6849
#[serde(rename_all = "camelCase")]
6950
pub struct Quote {
@@ -172,15 +153,6 @@ where
172153
}
173154
}
174155

175-
/// Get simple price for a given input mint, output mint, and amount
176-
pub async fn price(input_mint: Pubkey, output_mint: Pubkey, ui_amount: f64) -> Result<Price> {
177-
let url = format!(
178-
"{base_url}/price?id={input_mint}&vsToken={output_mint}&amount={ui_amount}",
179-
base_url = price_api_url(),
180-
);
181-
maybe_jupiter_api_error(reqwest::get(url).await?.json().await?)
182-
}
183-
184156
#[derive(Serialize, Deserialize, Default, PartialEq, Clone, Debug)]
185157
pub enum SwapMode {
186158
#[default]

0 commit comments

Comments
 (0)