Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ or Add this to your `Cargo.toml`:

```toml
[dependencies]
jup-ag-sdk = "1.0.3"
jup-ag-sdk = "1.0.4"
```

## Features
Expand Down Expand Up @@ -83,6 +83,7 @@ async fn main() {

- [API Documentation](https://dev.jup.ag/)
- [Discord](https://discord.gg/jup)
- [crates.io](https://crates.io/crates/jup-ag-sdk)

## Local

Expand Down
12 changes: 10 additions & 2 deletions examples/src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ pub async fn swap() {

let quote_res = client.get_quote(&quote).await.expect("Failed to get quote");

let payload = SwapRequest::new("input_your_wallet_address", quote_res);
let payload = SwapRequest::new(
"input_your_wallet_address",
"payer_wallet_address",
quote_res,
);
let swap_res: SwapResponse = client
.get_swap_transaction(&payload)
.await
Expand Down Expand Up @@ -96,7 +100,11 @@ pub async fn swap_with_instructions() {
let quote_res = client.get_quote(&quote).await.expect("Failed to get quote");

// get swap instructions
let payload = SwapRequest::new("EXBdeRCdiNChKyD7akt64n9HgSXEpUtpPEhmbnm4L6iH", quote_res);
let payload = SwapRequest::new(
"EXBdeRCdiNChKyD7akt64n9HgSXEpUtpPEhmbnm4L6iH",
"payer_wallet_address",
quote_res,
);

let swap_instructions = client
.get_swap_instructions(&payload)
Expand Down
2 changes: 1 addition & 1 deletion jup-ag-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jup-ag-sdk"
version = "1.0.3"
version = "1.0.4"
edition = "2024"
license-file = "../LICENSE"
readme = "../README.md"
Expand Down
13 changes: 11 additions & 2 deletions jup-ag-sdk/src/types/swap_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub struct SwapRequest {
/// Rquired. The public key of the user initiating the swap.
pub user_public_key: String,

/// Allow a custom payer to pay for the transaction
pub payer: String,

/// Automatically wrap/unwrap native SOL to/from WSOL Default (true)
/// When true, uses SOL and unwraps WSOL post-swap.
/// When false, uses WSOL only and leaves it wrapped.
Expand Down Expand Up @@ -113,6 +116,7 @@ impl SwapRequest {
///
/// # Arguments
/// * `input_wallet` - The user's public key as a string.
/// * `payer` - payer to pay for the transaction
/// * `quote` - The `QuoteResponse` obtained from a quoting endpoint.
///
/// # Returns
Expand All @@ -122,9 +126,14 @@ impl SwapRequest {
/// ```
/// let payload = SwapRequest::new("YourPubKey...", quote);
/// ```
pub fn new(input_wallet: &str, quote: QuoteResponse) -> Self {
pub fn new(
input_wallet: impl Into<String>,
payer: impl Into<String>,
quote: QuoteResponse,
) -> Self {
Self {
user_public_key: input_wallet.to_string(),
user_public_key: input_wallet.into(),
payer: payer.into(),
wrap_and_unwrap_sol: None,
use_shared_accounts: None,
fee_account: None,
Expand Down
4 changes: 2 additions & 2 deletions tests/src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod swap_tests {

match client.get_quote(&quote).await {
Ok(quote_res) => {
let swap = SwapRequest::new(TEST_USER_PUBKEY, quote_res);
let swap = SwapRequest::new(TEST_USER_PUBKEY, TEST_USER_PUBKEY, quote_res);

assert_eq!(
swap.user_public_key, TEST_USER_PUBKEY,
Expand Down Expand Up @@ -163,7 +163,7 @@ mod swap_tests {
Err(err) => panic!("Failed to get quote for swap test: {:?}", err),
};

let swap = SwapRequest::new(TEST_USER_PUBKEY, quote_res);
let swap = SwapRequest::new(TEST_USER_PUBKEY, TEST_USER_PUBKEY, quote_res);

match client.get_swap_transaction(&swap).await {
Ok(swap_res) => {
Expand Down
Loading