|
1 | | -use jup_ag_sdk::{JupiterClient, types::TokenPriceRequest}; |
| 1 | +use jup_ag_sdk::{JupiterClient, client}; |
2 | 2 |
|
3 | 3 | pub async fn token_balances() { |
4 | 4 | let client = JupiterClient::new("https://lite-api.jup.ag"); |
@@ -31,48 +31,22 @@ pub async fn token_price() { |
31 | 31 | "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN".to_string(), |
32 | 32 | ]; |
33 | 33 |
|
34 | | - let params = TokenPriceRequest::new(&token_mints); |
35 | | - |
36 | | - let price = client |
37 | | - .get_token_price(¶ms) |
38 | | - .await |
39 | | - .expect("Failed to get token price"); |
40 | | - |
41 | | - let sol_price = price |
42 | | - .data |
43 | | - .get(token_mints[0].as_str()) |
44 | | - .expect("SOL price not found"); |
45 | | - |
46 | | - println!("1 SOL price in USDC: {}", sol_price.price); |
47 | | - |
48 | | - let jup_price = price |
49 | | - .data |
50 | | - .get(token_mints[1].as_str()) |
51 | | - .expect("Jup Token price not found"); |
52 | | - |
53 | | - println!("1 JUP price USDC: {}", jup_price.price); |
54 | | - |
55 | | - let params = TokenPriceRequest::new(&token_mints) |
56 | | - .with_vs_token("So11111111111111111111111111111111111111112"); |
57 | | - |
58 | 34 | let price = client |
59 | | - .get_token_price(¶ms) |
| 35 | + .get_tokens_price(&token_mints) |
60 | 36 | .await |
61 | 37 | .expect("Failed to get token price"); |
62 | 38 |
|
63 | 39 | let sol_price = price |
64 | | - .data |
65 | 40 | .get(token_mints[0].as_str()) |
66 | 41 | .expect("SOL price not found"); |
67 | 42 |
|
68 | | - println!("1 SOL price in SOL: {}", sol_price.price); |
| 43 | + println!("1 SOL price in USDC: {}", sol_price.usd_price); |
69 | 44 |
|
70 | 45 | let jup_price = price |
71 | | - .data |
72 | 46 | .get(token_mints[1].as_str()) |
73 | 47 | .expect("Jup Token price not found"); |
74 | 48 |
|
75 | | - println!("1 JUP price in SOL: {}", jup_price.price); |
| 49 | + println!("1 JUP price USDC: {}", jup_price.usd_price); |
76 | 50 | } |
77 | 51 |
|
78 | 52 | pub async fn token_info() { |
@@ -115,3 +89,18 @@ pub async fn get_tokens_from_tags() { |
115 | 89 |
|
116 | 90 | println!("mints: {}", mints.len()) |
117 | 91 | } |
| 92 | + |
| 93 | +pub async fn get_trending_tokens() { |
| 94 | + let client = JupiterClient::new("https:://lite-api.jup.ag"); |
| 95 | + |
| 96 | + let tokens = client |
| 97 | + .get_tokens_by_category( |
| 98 | + jup_ag_sdk::types::Category::TopTrending, |
| 99 | + jup_ag_sdk::types::Interval::TwentyFourHours, |
| 100 | + Some(10), |
| 101 | + ) |
| 102 | + .await |
| 103 | + .expect("failed to get trending tokens"); |
| 104 | + |
| 105 | + println!("trending tokens: {:?}", tokens.len()); |
| 106 | +} |
0 commit comments