@@ -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 ) ]
3025pub 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" ) ]
6950pub 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 ) ]
185157pub enum SwapMode {
186158 #[ default]
0 commit comments