Last active
April 2, 2025 01:12
-
-
Save mgild/e6ceee4edd8d4c372748af17793fb6d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let in_token_account = get_associated_token_address(&user, &in_mint); | |
let out_token_account = get_associated_token_address(&user, &out_mint); | |
let atlas_in_token_account = get_associated_token_address(&ATLAS, &in_mint); | |
let atlas_out_token_account = get_associated_token_address(&ATLAS, &out_mint); | |
let swap_params = SwapParams { | |
swap_mode: jupiter_amm_interface::SwapMode::ExactIn, | |
in_amount: amount_in, | |
out_amount: 0, | |
source_mint: in_mint, | |
destination_mint: out_mint, | |
source_token_account: atlas_in_token_account, | |
destination_token_account: atlas_out_token_account, | |
token_transfer_authority: ATLAS.clone(), | |
jupiter_program_id: &Pubkey::default(), | |
open_order_address: None, | |
quote_mint_to_referrer: None, | |
missing_dynamic_accounts_as_default: false, | |
}; | |
let state = self.load_state(ctx.clone()).await?; | |
let metas = state | |
.get_swap_and_account_metas(&swap_params)? | |
.account_metas; | |
let mut remaining_accounts = vec![]; | |
remaining_accounts.push(AccountMeta::new(atlas_in_token_account, false)); | |
remaining_accounts.push(AccountMeta::new(atlas_out_token_account, false)); | |
remaining_accounts.extend(metas); | |
remaining_accounts.push(AccountMeta::new_readonly(Self::program_id(), false)); | |
let ix = titan::swap_route( | |
SwapRouteArgs { | |
amount: amount_in, | |
minimum_amount_out: 0, | |
mints: 2, | |
provider_fee_bps: 0, | |
service_fee_bps: 0, | |
swaps: vec![ | |
SwapSpecInput { | |
venue: Venue::ObricV2 { x_to_y: in_mint.eq(&self.state.mint_x) }, | |
from: 0, | |
to: 1, | |
weight_bps: 10000, | |
minimum_amount_out: 0, | |
n_accounts: 13, | |
}, | |
] | |
}, | |
SwapRouteAccounts { | |
payer: user.clone(), | |
atlas: ATLAS.clone(), | |
input_mint: in_mint, | |
input_token_account: in_token_account, | |
output_mint: out_mint, | |
output_token_account: out_token_account, | |
input_token_program: spl_token::id(), | |
output_token_program: spl_token::id(), | |
}, | |
&remaining_accounts, | |
&TITAN_PROGRAM_ID, | |
)?; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment