Skip to content

Commit 9769b77

Browse files
authored
Merge pull request #17 from thrishank/main
update readme
2 parents 1d01b84 + d58964f commit 9769b77

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

README.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,48 @@ use jup_ag_sdk::{
3434

3535
#[tokio::main]
3636
async fn main() {
37-
// initalize the client
37+
// Initialize the Jupiter client with the Lite API endpoint
3838
let client = JupiterClient::new("https://lite-api.jup.ag");
3939

40-
// Create an ultra order request to swap 10 USDC to SOL
41-
let ultra = UltraOrderRequest::new(
42-
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
43-
"So11111111111111111111111111111111111111112",
44-
10_000_000, // 6 decimals (USDC)
45-
).add_taker("your wallet address");
40+
// Example: swap: 10 USDC (6 decimals) to SOL
41+
let input_token = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
42+
let output_token = "So11111111111111111111111111111111111111112"; // SOL
43+
let amount = 10_000_000; // 10 USDC (in micro units)
4644

47-
// fetch the quote
48-
let quote = client.get_ultra_order(&ultra).await
49-
.expect("Failed to get ultra order");
45+
// Create an order request and specify the taker's wallet address
46+
let order_request = UltraOrderRequest::new(input_token, output_token, amount)
47+
.add_taker("your taker wallet address");
48+
49+
// Fetch the unsigned transaction and request ID from Jupiter
50+
let order_response = client
51+
.get_ultra_order(&order_request)
52+
.await
53+
.expect("Failed to fetch ultra order");
54+
55+
let unsigned_tx_base64 = order_response
56+
.transaction
57+
.expect("No transaction found in ultra order response");
5058

5159
// sign the transaction. Checkout examples/src/lib.rs on how to sign the transaction
5260

5361
// execute the signed transaction
54-
let execute = UltraExecuteOrderRequest {
55-
signed_transaction: base64_signed_tx,
62+
let execute_request = UltraExecuteOrderRequest {
63+
signed_transaction: signed_tx_base64,
5664
request_id: quote.request_id,
5765
};
5866

59-
// Execute the transaction
60-
let response = client.ultra_execute_order(&execute).await
67+
// Send the signed transaction to Jupiter for execution
68+
let execute_response = client
69+
.ultra_execute_order(&execute_request)
70+
.await
6171
.expect("Failed to execute transaction");
6272

63-
println!("Transaction: {}", response.signature);
73+
// Print the transaction signature
74+
let tx_signature = execute_response
75+
.signature
76+
.expect("No signature found in execution response");
77+
78+
println!("✅ Transaction submitted: {}", tx_signature);
6479
}
6580
```
6681

0 commit comments

Comments
 (0)