From da6c08933c00b5abdcd000e05551e8765d4cb1c7 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 7 Nov 2024 04:01:25 +0100 Subject: [PATCH 01/12] midway debug --- .../src/dex/generic/generic_adapter.rs | 6 +++- bin/autobahn-router/src/main.rs | 4 ++- bin/autobahn-router/src/routing.rs | 11 ++++--- .../src/source/grpc_plugin_source.rs | 2 ++ .../src/source/mint_accounts_source.rs | 30 ++++++++++++------- lib/dex-invariant/src/invariant_dex.rs | 9 ++++++ lib/router-lib/src/price_feeds/birdeye.rs | 1 + 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/bin/autobahn-router/src/dex/generic/generic_adapter.rs b/bin/autobahn-router/src/dex/generic/generic_adapter.rs index 4be7b4d..f214167 100644 --- a/bin/autobahn-router/src/dex/generic/generic_adapter.rs +++ b/bin/autobahn-router/src/dex/generic/generic_adapter.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use itertools::Itertools; use router_lib::dex::{DexInterface, DexSubscriptionMode}; use router_lib::mango::mango_fetcher::MangoMetadata; -use tracing::info; +use tracing::{info, trace}; use crate::edge::Edge; use crate::edge_updater::Dex; @@ -46,7 +46,11 @@ pub async fn build_dex_internal( let edges_per_pk_src = dex.edges_per_pk(); let mut edges_per_pk = HashMap::new(); + info!("build_dex_internal {} enabled={enabled} add_mango_tokens={add_mango_tokens} take_all_mints={take_all_mints} mints={mints:?}", dex.name()); + for (key, edges) in edges_per_pk_src { + trace!("build_dex_internal key={key:?} edges={}", edges.len()); + let edges = edges .into_iter() .filter(|x| { diff --git a/bin/autobahn-router/src/main.rs b/bin/autobahn-router/src/main.rs index 020974e..2ff4377 100644 --- a/bin/autobahn-router/src/main.rs +++ b/bin/autobahn-router/src/main.rs @@ -241,6 +241,8 @@ async fn main() -> anyhow::Result<()> { }), }; + + info!("config = {config:?}"); let dexs: Vec = [ dex::generic::build_dex!( OrcaDex::initialize(&mut router_rpc, orca_config).await?, @@ -302,8 +304,8 @@ async fn main() -> anyhow::Result<()> { dex_invariant::InvariantDex::initialize(&mut router_rpc, HashMap::new()).await?, &mango_data, config.invariant.enabled, - config.invariant.take_all_mints, config.invariant.add_mango_tokens, + config.invariant.take_all_mints, &config.invariant.mints ), ] diff --git a/bin/autobahn-router/src/routing.rs b/bin/autobahn-router/src/routing.rs index 48528d8..16c7b6b 100644 --- a/bin/autobahn-router/src/routing.rs +++ b/bin/autobahn-router/src/routing.rs @@ -693,12 +693,15 @@ impl Routing { let mut best = HashMap::<(Pubkey, Pubkey), Vec<(EdgeIndex, f64)>>::new(); for (edge_index, edge) in all_edges.iter().enumerate() { + trace!("ix:{edge_index} edge:{edge:?}"); if swap_mode == SwapMode::ExactOut && !edge.supports_exact_out() { continue; } let edge_index: EdgeIndex = edge_index.into(); let state = edge.state.read().unwrap(); + trace!("ix:{edge_index} edge:{edge:?} {:?}", state.cached_prices); + if !state.is_valid() || state.cached_prices.len() < i { continue; } @@ -778,10 +781,10 @@ impl Routing { price_impact, ); - if price_impact > 0.25 { - skipped_bad_price_impact += 1; - continue; - } + // if price_impact > 0.25 { + // skipped_bad_price_impact += 1; + // continue; + // } match swap_mode { SwapMode::ExactIn => { diff --git a/bin/autobahn-router/src/source/grpc_plugin_source.rs b/bin/autobahn-router/src/source/grpc_plugin_source.rs index 11bbe89..951a95d 100644 --- a/bin/autobahn-router/src/source/grpc_plugin_source.rs +++ b/bin/autobahn-router/src/source/grpc_plugin_source.rs @@ -70,6 +70,8 @@ pub async fn feed_data_geyser( subscribed_token_accounts: &HashSet, sender: async_channel::Sender, ) -> anyhow::Result<()> { + + println!("feed_data_geyser a:{subscribed_accounts:?} p:{subscribed_programs:?} t:{subscribed_token_accounts:?}"); let use_compression = snapshot_config.rpc_support_compression.unwrap_or(false); let number_of_accounts_per_gma = snapshot_config.number_of_accounts_per_gma.unwrap_or(100); let grpc_connection_string = match &grpc_config.connection_string.chars().next().unwrap() { diff --git a/bin/autobahn-router/src/source/mint_accounts_source.rs b/bin/autobahn-router/src/source/mint_accounts_source.rs index 84f9155..75c41cc 100644 --- a/bin/autobahn-router/src/source/mint_accounts_source.rs +++ b/bin/autobahn-router/src/source/mint_accounts_source.rs @@ -1,5 +1,7 @@ use anchor_lang::AccountDeserialize; -use anchor_spl::token::Mint; +use anchor_spl::token::{spl_token, Mint}; +use anchor_spl::token_2022::spl_token_2022; +use anchor_spl::token_2022::spl_token_2022::extension::StateWithExtensions; use futures_util::future::join_all; use itertools::Itertools; use jsonrpc_core_client::transports::http; @@ -7,8 +9,9 @@ use router_feed_lib::solana_rpc_minimal::rpc_accounts_scan::RpcAccountsScanClien use solana_account_decoder::UiAccountEncoding; use solana_client::rpc_config::RpcAccountInfoConfig; use solana_program::pubkey::Pubkey; -use solana_sdk::account::Account; +use solana_sdk::account::{Account, ReadableAccount}; use solana_sdk::commitment_config::CommitmentConfig; +use solana_sdk::program_pack::Pack; use std::collections::{HashMap, HashSet}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; @@ -43,7 +46,7 @@ pub async fn request_mint_metadata( .unwrap(); let rpc_client = Arc::new(rpc_client); let account_info_config = RpcAccountInfoConfig { - encoding: Some(UiAccountEncoding::Binary), + encoding: Some(UiAccountEncoding::Base64), commitment: Some(CommitmentConfig::finalized()), data_slice: None, min_context_slot: None, @@ -71,18 +74,23 @@ pub async fn request_mint_metadata( for (account_pk, ui_account) in accounts { if let Some(ui_account) = ui_account { let mut account: Account = ui_account.decode().unwrap(); - let data = account.data.as_mut_slice(); - let mint_account = Mint::try_deserialize(&mut &*data).unwrap(); - trace!( - "Mint Account {}: decimals={}", - account_pk.to_string(), - mint_account.decimals - ); + + let decimals = match account.owner { + spl_token::ID => { + let mint = spl_token::state::Mint::unpack(account.data()).unwrap(); + mint.decimals + }, + spl_token_2022::ID => { + let mint = StateWithExtensions::::unpack(&account.data()).unwrap(); + mint.base.decimals + } + _ => panic!("could not parse mint {:?}", account_pk) + }; mint_accounts.insert( account_pk, Token { mint: account_pk, - decimals: mint_account.decimals, + decimals, }, ); count.fetch_add(1, Ordering::Relaxed); diff --git a/lib/dex-invariant/src/invariant_dex.rs b/lib/dex-invariant/src/invariant_dex.rs index d904965..e791cde 100644 --- a/lib/dex-invariant/src/invariant_dex.rs +++ b/lib/dex-invariant/src/invariant_dex.rs @@ -192,9 +192,11 @@ where { chain_data: &AccountProviderView, ) -> anyhow::Result { let pool_account_data = chain_data.account(&id.pool)?; + let pool = Self::deserialize::(pool_account_data.account.data())?; let tickmap_account_data = chain_data.account(&pool.tickmap)?; + let tickmap = Self::deserialize_tickmap_view( &tickmap_account_data.account.data(), pool.current_tick_index, @@ -254,6 +256,8 @@ impl DexInterface for InvariantDex { .map(|(pk, _)| pk) .collect::>(); + info!("Number of banned Invariant reserves {}", banned_reserves.len()); + pools.retain(|p| { !(banned_reserves.contains(&p.1.token_x_reserve) || banned_reserves.contains(&p.1.token_y_reserve)) @@ -281,7 +285,9 @@ impl DexInterface for InvariantDex { }) .into_iter() .collect(); + let tickmaps = pools.iter().map(|p| p.1.tickmap).collect(); + info!("gMA tickmaps {tickmaps:?}"); let tickmaps = rpc.get_multiple_accounts(&tickmaps).await?; let edges_per_pk = { @@ -305,6 +311,9 @@ impl DexInterface for InvariantDex { map }; + info!("inv init done"); + + Ok(Arc::new(InvariantDex { edges: edges_per_pk, })) diff --git a/lib/router-lib/src/price_feeds/birdeye.rs b/lib/router-lib/src/price_feeds/birdeye.rs index 696623b..71e99df 100644 --- a/lib/router-lib/src/price_feeds/birdeye.rs +++ b/lib/router-lib/src/price_feeds/birdeye.rs @@ -86,6 +86,7 @@ impl BirdeyePriceFeed { mints: &HashSet, sender: broadcast::Sender, ) -> anyhow::Result<()> { + return Ok(()); let http_client = reqwest::Client::new(); let mut chunks: Vec> = vec![]; From 645939455ab8c5755ebdb503f795454bc15b6265 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 7 Nov 2024 12:45:08 +0100 Subject: [PATCH 02/12] try to get USDC quotes --- bin/autobahn-router/src/debug_tools.rs | 2 ++ bin/autobahn-router/src/edge.rs | 4 ++-- bin/autobahn-router/src/edge_updater.rs | 3 +++ bin/autobahn-router/src/path_warmer.rs | 10 ++++++++-- bin/autobahn-router/src/source/grpc_plugin_source.rs | 4 ++-- lib/dex-invariant/src/internal/swap.rs | 2 +- lib/dex-invariant/src/invariant_dex.rs | 12 +++++++++--- lib/router-lib/src/price_feeds/price_cache.rs | 6 ++++-- 8 files changed, 31 insertions(+), 12 deletions(-) diff --git a/bin/autobahn-router/src/debug_tools.rs b/bin/autobahn-router/src/debug_tools.rs index 4fec3e1..43f8333 100644 --- a/bin/autobahn-router/src/debug_tools.rs +++ b/bin/autobahn-router/src/debug_tools.rs @@ -71,6 +71,8 @@ pub fn name(mint: &Pubkey) -> String { "BOME".to_string() } else if m == "3S8qX1MsMqRbiwKg2cQyx7nis1oHMgaCuc9c4VfvVdPN" { "MOTHER".to_string() + } else if m == "AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE" { + "USDC (hyperlane)".to_string() } else { m } diff --git a/bin/autobahn-router/src/edge.rs b/bin/autobahn-router/src/edge.rs index eebb229..822b186 100644 --- a/bin/autobahn-router/src/edge.rs +++ b/bin/autobahn-router/src/edge.rs @@ -240,14 +240,14 @@ impl Edge { let Ok(decimals) = token_cache.token(self.input_mint).map(|x| x.decimals) else { let mut state = self.state.write().unwrap(); - trace!("no decimals for {}", self.input_mint); + info!("update_internal no decimals for {}", self.input_mint); state.is_valid = false; return; }; let Some(price) = price_cache.price_ui(self.input_mint) else { let mut state = self.state.write().unwrap(); state.is_valid = false; - trace!("no price for {}", self.input_mint); + info!("update_internal no price for {}", self.input_mint); return; }; diff --git a/bin/autobahn-router/src/edge_updater.rs b/bin/autobahn-router/src/edge_updater.rs index d452aa0..c3c27ed 100644 --- a/bin/autobahn-router/src/edge_updater.rs +++ b/bin/autobahn-router/src/edge_updater.rs @@ -209,6 +209,7 @@ pub fn spawn_updater_job( impl EdgeUpdater { fn detect_and_handle_slot_lag(&mut self, slot: Result) { + info!("detect_and_handle_slot_lag {slot:?}"); let state = &mut self.state; if state.latest_slot_processed == 0 { return; @@ -282,6 +283,7 @@ impl EdgeUpdater { } fn on_metadata_update(&mut self, res: Result) { + info!("metadata_update {res:?}"); let state = &mut self.state; match res { Ok(v) => match v { @@ -293,6 +295,7 @@ impl EdgeUpdater { FeedMetadata::SnapshotEnd(x) => { if let Some(x) = x { if x == spl_token::ID { + // TODO: token2022 support for CP style amms // TODO Handle multiples owners state.dirty_token_accounts_for_owners = true; } else { diff --git a/bin/autobahn-router/src/path_warmer.rs b/bin/autobahn-router/src/path_warmer.rs index e7ea662..f81782a 100644 --- a/bin/autobahn-router/src/path_warmer.rs +++ b/bin/autobahn-router/src/path_warmer.rs @@ -63,6 +63,7 @@ where }; let sol_mint = Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(); + let usdc_mint = Pubkey::from_str("AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE").unwrap(); let config = config.clone(); let start = Instant::now(); let job = tokio::spawn(async move { @@ -83,6 +84,8 @@ where let mut all_mints = token_cache.tokens(); all_mints.insert(sol_mint); + all_mints.insert(usdc_mint); + let hot_mints = hot_mints_cache.read().unwrap().get(); let mints = match generate_mints( @@ -96,7 +99,7 @@ where None => break, }; - debug!("Running a path warmup loop for {} mints", mints.len()); + info!("Running a path warmup loop for {} mints", mints.len()); let mut counter = 0; let mut skipped = 0; let time = Instant::now(); @@ -118,10 +121,13 @@ where continue; }; if price_ui <= 0.000001 { + info!("skipped {from_mint:?} price is low {price_ui}"); skipped += 1; continue; } let Ok(token) = token_cache.token(*from_mint) else { + info!("skipped {from_mint:?} no token cache entry"); + skipped += 1; continue; }; @@ -129,7 +135,7 @@ where let decimals = token.decimals; let multiplier = 10u64.pow(decimals as u32) as f64; - trace!("Warming up {}", debug_tools::name(&from_mint),); + info!("Warming up {}", debug_tools::name(&from_mint),); for amount_ui in &path_warming_amounts { let amount_native = diff --git a/bin/autobahn-router/src/source/grpc_plugin_source.rs b/bin/autobahn-router/src/source/grpc_plugin_source.rs index 951a95d..ec28fbe 100644 --- a/bin/autobahn-router/src/source/grpc_plugin_source.rs +++ b/bin/autobahn-router/src/source/grpc_plugin_source.rs @@ -746,7 +746,7 @@ async fn process_account_updated_from_sources( metrics::ACCOUNT_SNAPSHOTS .with_label_values(&[&label]) .inc(); - debug!( + info!( "processing snapshot for program_id {} -> size={} & missing size={}...", update .program_id @@ -780,7 +780,7 @@ async fn process_account_updated_from_sources( warn!("failed to send feed matadata event: {}", e); } } - debug!("processing snapshot done"); + info!("processing snapshot done"); if let Err(e) = metadata_sender(FeedMetadata::SnapshotEnd(update.program_id)) { warn!("failed to send feed matadata event: {}", e); } diff --git a/lib/dex-invariant/src/internal/swap.rs b/lib/dex-invariant/src/internal/swap.rs index dace76f..b969d0f 100644 --- a/lib/dex-invariant/src/internal/swap.rs +++ b/lib/dex-invariant/src/internal/swap.rs @@ -16,7 +16,7 @@ pub struct InvariantSimulationParams { pub sqrt_price_limit: Price, } -#[derive(Clone, Default)] +#[derive(Clone, Default, Debug)] pub struct InvariantSwapResult { pub in_amount: u64, pub out_amount: u64, diff --git a/lib/dex-invariant/src/invariant_dex.rs b/lib/dex-invariant/src/invariant_dex.rs index e791cde..f401e78 100644 --- a/lib/dex-invariant/src/invariant_dex.rs +++ b/lib/dex-invariant/src/invariant_dex.rs @@ -26,7 +26,7 @@ use solana_client::{ rpc_filter::RpcFilterType, }; use solana_sdk::{account::ReadableAccount, program_pack::Pack, pubkey::Pubkey}; -use tracing::info; +use tracing::{error, info}; use crate::{ invariant_edge::{InvariantEdge, InvariantEdgeIdentifier, InvariantSimulationParams}, @@ -287,7 +287,6 @@ impl DexInterface for InvariantDex { .collect(); let tickmaps = pools.iter().map(|p| p.1.tickmap).collect(); - info!("gMA tickmaps {tickmaps:?}"); let tickmaps = rpc.get_multiple_accounts(&tickmaps).await?; let edges_per_pk = { @@ -346,6 +345,7 @@ impl DexInterface for InvariantDex { .unwrap(); let edge = Self::load_edge(id, chain_data)?; + info!("load edge with id={id:?} -> {edge:?}"); Ok(Arc::new(edge)) } @@ -369,6 +369,9 @@ impl DexInterface for InvariantDex { calculate_price_sqrt(get_max_tick(edge.pool.tick_spacing)?) }; + info!("quote edge with id={id:?} amount={in_amount} -> {edge:?}"); + + let simulation = edge .simulate_invariant_swap(&InvariantSimulationParams { x_to_y, @@ -376,11 +379,14 @@ impl DexInterface for InvariantDex { sqrt_price_limit, by_amount_in: true, }) - .map_err(|e| anyhow::format_err!(e)) + .map_err(|e| { error!("quote id={id:?} error: {:?}", e); anyhow::format_err!(e) }) .with_context(|| format!("pool {} x_to_y {}", id.pool, id.x_to_y))?; let fee_mint = if x_to_y { id.token_x } else { id.token_y }; + info!("quote edge with id={id:?} amount={in_amount} -> {simulation:?}"); + + Ok(Quote { in_amount: simulation.in_amount, out_amount: simulation.out_amount, diff --git a/lib/router-lib/src/price_feeds/price_cache.rs b/lib/router-lib/src/price_feeds/price_cache.rs index 1fef4c5..6b2e07f 100644 --- a/lib/router-lib/src/price_feeds/price_cache.rs +++ b/lib/router-lib/src/price_feeds/price_cache.rs @@ -1,7 +1,7 @@ use crate::price_feeds::price_feed::PriceUpdate; use dashmap::DashMap; use solana_sdk::pubkey::Pubkey; -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; use tokio::task::JoinHandle; use tracing::info; @@ -14,8 +14,10 @@ impl PriceCache { pub fn new( mut exit: tokio::sync::broadcast::Receiver<()>, mut receiver: tokio::sync::broadcast::Receiver, - ) -> (PriceCache, JoinHandle<()>) { + ) -> (PriceCache, JoinHandle<()>) { let latest_prices = Arc::new(DashMap::new()); + //latest_prices.insert(Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(), 2500.0); + latest_prices.insert(Pubkey::from_str("AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE").unwrap(), 1.0); let latest_prices_write = latest_prices.clone(); let job = tokio::spawn(async move { From 56340afd6dc87a368623861662bb6d41336d7740 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 7 Nov 2024 17:34:35 +0100 Subject: [PATCH 03/12] include mints in chain data so swap instructions can be built --- bin/autobahn-router/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/autobahn-router/src/main.rs b/bin/autobahn-router/src/main.rs index 2ff4377..6e3f8fd 100644 --- a/bin/autobahn-router/src/main.rs +++ b/bin/autobahn-router/src/main.rs @@ -241,7 +241,6 @@ async fn main() -> anyhow::Result<()> { }), }; - info!("config = {config:?}"); let dexs: Vec = [ dex::generic::build_dex!( @@ -442,6 +441,17 @@ async fn main() -> anyhow::Result<()> { ) .collect::>(); + // collect all mints traded so their token program owner can be checked + let mut mints = HashSet::new(); + for d in dexs.iter() { + for es in d.edges_per_pk.values() { + for e in es { + mints.insert(e.input_mint); + mints.insert(e.output_mint); + } + } + } + debug_tools::set_global_filters(&filters); info!( @@ -457,6 +467,7 @@ async fn main() -> anyhow::Result<()> { DexSubscriptionMode::Mixed(m) => m.accounts.clone().into_iter(), DexSubscriptionMode::Disabled => HashSet::new().into_iter(), }) + .chain(mints.into_iter()) .collect(); let subscribed_programs = dexs From 5149b5871ad751463461316554b7933e6f6b1bbd Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 7 Nov 2024 17:35:25 +0100 Subject: [PATCH 04/12] enable more logs --- .../src/dex/generic/generic_adapter.rs | 10 ++++--- bin/autobahn-router/src/edge.rs | 2 +- bin/autobahn-router/src/routing.rs | 20 ++++++++----- bin/autobahn-router/src/server/http_server.rs | 22 +++++++++++++++ .../src/source/grpc_plugin_source.rs | 9 +++--- lib/dex-invariant/src/invariant_dex.rs | 28 +++++++------------ lib/dex-invariant/src/invariant_ix_builder.rs | 1 + 7 files changed, 58 insertions(+), 34 deletions(-) diff --git a/bin/autobahn-router/src/dex/generic/generic_adapter.rs b/bin/autobahn-router/src/dex/generic/generic_adapter.rs index f214167..d9736df 100644 --- a/bin/autobahn-router/src/dex/generic/generic_adapter.rs +++ b/bin/autobahn-router/src/dex/generic/generic_adapter.rs @@ -46,12 +46,11 @@ pub async fn build_dex_internal( let edges_per_pk_src = dex.edges_per_pk(); let mut edges_per_pk = HashMap::new(); - info!("build_dex_internal {} enabled={enabled} add_mango_tokens={add_mango_tokens} take_all_mints={take_all_mints} mints={mints:?}", dex.name()); + info!("dex {} enabled={enabled} add_mango_tokens={add_mango_tokens} take_all_mints={take_all_mints} mints={mints:?} edges={}", dex.name(), edges_per_pk_src.len()); - for (key, edges) in edges_per_pk_src { - trace!("build_dex_internal key={key:?} edges={}", edges.len()); + for (key, edge_ids) in edges_per_pk_src { - let edges = edges + let edges = edge_ids.clone() .into_iter() .filter(|x| { let keep = take_all_mints @@ -69,6 +68,9 @@ pub async fn build_dex_internal( }) }) .collect_vec(); + + trace!("build_dex_internal key={key:?} edge_ids={} edges={}", edge_ids.len(), edges.len()); + if edges.len() > 0 { edges_per_pk.insert(key, edges); } diff --git a/bin/autobahn-router/src/edge.rs b/bin/autobahn-router/src/edge.rs index 822b186..53404b9 100644 --- a/bin/autobahn-router/src/edge.rs +++ b/bin/autobahn-router/src/edge.rs @@ -247,7 +247,7 @@ impl Edge { let Some(price) = price_cache.price_ui(self.input_mint) else { let mut state = self.state.write().unwrap(); state.is_valid = false; - info!("update_internal no price for {}", self.input_mint); + // info!("update_internal no price for {}", self.input_mint); return; }; diff --git a/bin/autobahn-router/src/routing.rs b/bin/autobahn-router/src/routing.rs index 16c7b6b..8e063c6 100644 --- a/bin/autobahn-router/src/routing.rs +++ b/bin/autobahn-router/src/routing.rs @@ -1249,7 +1249,7 @@ impl Routing { bail!(RoutingError::UnsupportedOutputMint(output_mint.clone())); }; - trace!( + info!( input_index = input_index.idx_raw(), output_index = output_index.idx_raw(), max_path_length, @@ -1270,6 +1270,7 @@ impl Routing { .map(|paths| self.lookup_edge_index_paths(paths.iter())); if (p1.is_none() && p2.is_none()) || ignore_cache { + info!("no cache"); None } else { let cached_paths = p1 @@ -1277,6 +1278,7 @@ impl Routing { .into_iter() .chain(p2.unwrap_or(vec![]).into_iter()) .collect_vec(); + info!("cached {}", cached_paths.len()); Some(cached_paths) } }; @@ -1394,9 +1396,9 @@ impl Routing { } // Debug - if tracing::event_enabled!(Level::TRACE) { + if true { for (path, out_amount, out_amount_dumb) in &path_and_output { - trace!( + info!( "potential path: [out={}] [dumb={}] {}", out_amount, out_amount_dumb, @@ -1451,7 +1453,7 @@ impl Routing { let price_impact = expected_ratio / actual_ratio * 10_000.0 - 10_000.0; let price_impact_bps = price_impact.round() as u64; - trace!( + info!( price_impact_bps, out_amount_for_small_amount, out_amount_for_request, @@ -1487,7 +1489,7 @@ impl Routing { } if self.overquote > 0.0 { - debug!( + info!( actual_in_amount, actual_out_amount, overquote_in_amount, @@ -1502,6 +1504,7 @@ impl Routing { let accounts = self .capture_accounts(chain_data, &out_path, original_amount) .ok(); + return Ok(Route { input_mint: *input_mint, @@ -1547,16 +1550,19 @@ impl Routing { output_index: MintNodeIndex, used_cached_paths: bool, ) -> anyhow::Result { + + + info!("failsafe triggered"); // It is possible for cache path to became invalid after some account write or failed tx (cooldown) // If we used cache but can't find any valid path, try again without the cache let can_try_one_more_hop = max_path_length != self.max_path_length; if !ignore_cache && (used_cached_paths || can_try_one_more_hop) { if used_cached_paths { - debug!("Invalid cached path, retrying without cache"); + info!("Invalid cached path, retrying without cache"); let mut cache = self.path_discovery_cache.write().unwrap(); cache.invalidate(input_index, output_index, max_accounts); } else { - debug!("No path within boundaries, retrying with +1 hop"); + info!("No path within boundaries, retrying with +1 hop"); } return self.find_best_route( chain_data, diff --git a/bin/autobahn-router/src/server/http_server.rs b/bin/autobahn-router/src/server/http_server.rs index 73acbc5..8854edf 100644 --- a/bin/autobahn-router/src/server/http_server.rs +++ b/bin/autobahn-router/src/server/http_server.rs @@ -168,6 +168,8 @@ impl HttpServer { swap_mode, )?; + info!("best route found"); + let (bytes, accounts_count) = Self::build_swap_tx( address_lookup_table_addresses.clone(), hash_provider.clone(), @@ -184,6 +186,9 @@ impl HttpServer { ) .await?; + info!("tx encoded"); + + let tx_size = bytes.len(); if accounts_count <= MAX_ACCOUNTS_PER_TX && tx_size < MAX_TX_SIZE { break Ok(route_candidate); @@ -197,6 +202,8 @@ impl HttpServer { } }; + info!("quote -> err ? {}", route.is_err()); + let route: Route = route?; Self::log_repriced_amount(live_account_provider, reprice_probability, &route); @@ -209,6 +216,8 @@ impl HttpServer { .floor() as u64 }; + info!("serialize plan"); + let route_plan = route .steps .iter() @@ -227,6 +236,9 @@ impl HttpServer { }) .collect_vec(); + info!("encode accounts"); + + let accounts = match route.accounts { None => None, Some(a) => Some( @@ -368,6 +380,8 @@ impl HttpServer { ) -> Result<(Vec, usize), AppError> { let wallet_pk = Pubkey::from_str(&wallet_pk)?; + info!("build_ixs"); + let ixs = ix_builder.build_ixs( &wallet_pk, route_plan, @@ -383,6 +397,8 @@ impl HttpServer { ComputeBudgetInstruction::set_compute_unit_limit(ixs.cu_estimate), ]; + info!("serialize ixs"); + let transaction_addresses = ixs.accounts().into_iter().collect(); let instructions = compute_budget_ixs .into_iter() @@ -391,11 +407,16 @@ impl HttpServer { .chain(ixs.cleanup_instructions.into_iter()) .collect_vec(); + + info!("load alts"); let all_alts = Self::load_all_alts(address_lookup_table_addresses, alt_provider).await; + info!("optimize alts"); let alts = alt_optimizer::get_best_alt(&all_alts, &transaction_addresses)?; let accounts = transaction_addresses.iter().unique().count() + alts.iter().map(|x| x.key).unique().count(); + info!("compile message"); + let v0_message = solana_sdk::message::v0::Message::try_compile( &wallet_pk, instructions.as_slice(), @@ -405,6 +426,7 @@ impl HttpServer { let message = VersionedMessage::V0(v0_message); let tx = VersionedTransaction::try_new(message, &[&NullSigner::new(&wallet_pk)])?; + info!("serialize message"); let bytes = bincode::serialize(&tx)?; Ok((bytes, accounts)) diff --git a/bin/autobahn-router/src/source/grpc_plugin_source.rs b/bin/autobahn-router/src/source/grpc_plugin_source.rs index ec28fbe..68aacde 100644 --- a/bin/autobahn-router/src/source/grpc_plugin_source.rs +++ b/bin/autobahn-router/src/source/grpc_plugin_source.rs @@ -764,10 +764,11 @@ async fn process_account_updated_from_sources( metrics::GRPC_SNAPSHOT_ACCOUNT_WRITES.inc(); metrics::GRPC_ACCOUNT_WRITE_QUEUE.set(account_write_queue_sender.len() as i64); - if !filters.contains(&account.pubkey) { - continue; - } - + // if !filters.contains(&account.pubkey) && update.program_id.is_none() { + // info!("filtered account {:?}", account.pubkey); + // continue; + // } + updated_accounts.push(account); } account_write_queue_sender diff --git a/lib/dex-invariant/src/invariant_dex.rs b/lib/dex-invariant/src/invariant_dex.rs index f401e78..2a0f47e 100644 --- a/lib/dex-invariant/src/invariant_dex.rs +++ b/lib/dex-invariant/src/invariant_dex.rs @@ -1,6 +1,5 @@ use std::{ - collections::{HashMap, HashSet}, - sync::Arc, + collections::{HashMap, HashSet}, str::FromStr, sync::Arc }; use anchor_lang::{AnchorDeserialize, Id}; @@ -15,6 +14,7 @@ use invariant_types::{ structs::{Pool, Tick, Tickmap, TickmapView, TICK_CROSSES_PER_IX, TICK_LIMIT}, ANCHOR_DISCRIMINATOR_SIZE, TICK_SEED, }; +use itertools::Itertools; use router_feed_lib::router_rpc_client::{RouterRpcClient, RouterRpcClientTrait}; use router_lib::dex::{ AccountProviderView, DexEdge, DexEdgeIdentifier, DexInterface, DexSubscriptionMode, Quote, @@ -26,7 +26,7 @@ use solana_client::{ rpc_filter::RpcFilterType, }; use solana_sdk::{account::ReadableAccount, program_pack::Pack, pubkey::Pubkey}; -use tracing::{error, info}; +use tracing::{debug, error, info}; use crate::{ invariant_edge::{InvariantEdge, InvariantEdgeIdentifier, InvariantSimulationParams}, @@ -256,15 +256,11 @@ impl DexInterface for InvariantDex { .map(|(pk, _)| pk) .collect::>(); - info!("Number of banned Invariant reserves {}", banned_reserves.len()); - pools.retain(|p| { !(banned_reserves.contains(&p.1.token_x_reserve) || banned_reserves.contains(&p.1.token_y_reserve)) }); - info!("Number of Invariant Pools: {:?}", pools.len()); - let edge_pairs: Vec<(Arc, Arc)> = pools .iter() .map(|(pool_pk, pool)| { @@ -297,6 +293,7 @@ impl DexInterface for InvariantDex { { let entry: Vec> = vec![edge_x_to_y.clone(), edge_y_to_x.clone()]; + map.insert(*pool_pk, entry.clone()); map.insert(*tickmap_pk, entry.clone()); @@ -311,6 +308,8 @@ impl DexInterface for InvariantDex { }; info!("inv init done"); + let poolpk = Pubkey::from_str("G8Skt6kgqVL9ocYn4aYVGs3gUg8EfQrTJAkA2qt3gcs8").unwrap(); + info!("pool edges: {:?}", edges_per_pk.get(&poolpk).map(|ids| ids.iter().map(|id| vec![id.input_mint(), id.output_mint()]).collect_vec())); Ok(Arc::new(InvariantDex { @@ -343,10 +342,9 @@ impl DexInterface for InvariantDex { .as_any() .downcast_ref::() .unwrap(); - let edge = Self::load_edge(id, chain_data)?; - - info!("load edge with id={id:?} -> {edge:?}"); - Ok(Arc::new(edge)) + let edge: Result = Self::load_edge(id, chain_data); + debug!("load edge with id={id:?} -> {edge:?}"); + Ok(Arc::new(edge?)) } fn quote( @@ -368,9 +366,6 @@ impl DexInterface for InvariantDex { } else { calculate_price_sqrt(get_max_tick(edge.pool.tick_spacing)?) }; - - info!("quote edge with id={id:?} amount={in_amount} -> {edge:?}"); - let simulation = edge .simulate_invariant_swap(&InvariantSimulationParams { @@ -379,14 +374,11 @@ impl DexInterface for InvariantDex { sqrt_price_limit, by_amount_in: true, }) - .map_err(|e| { error!("quote id={id:?} error: {:?}", e); anyhow::format_err!(e) }) + .map_err(|e| { debug!("quote id={id:?} error: {:?}", e); anyhow::format_err!(e) }) .with_context(|| format!("pool {} x_to_y {}", id.pool, id.x_to_y))?; let fee_mint = if x_to_y { id.token_x } else { id.token_y }; - info!("quote edge with id={id:?} amount={in_amount} -> {simulation:?}"); - - Ok(Quote { in_amount: simulation.in_amount, out_amount: simulation.out_amount, diff --git a/lib/dex-invariant/src/invariant_ix_builder.rs b/lib/dex-invariant/src/invariant_ix_builder.rs index 6351642..715da29 100644 --- a/lib/dex-invariant/src/invariant_ix_builder.rs +++ b/lib/dex-invariant/src/invariant_ix_builder.rs @@ -8,6 +8,7 @@ use sha2::{Digest, Sha256}; use solana_program::instruction::Instruction; use solana_program::pubkey::Pubkey; use solana_sdk::account::ReadableAccount; +use tracing::info; pub fn build_swap_ix( id: &InvariantEdgeIdentifier, From ad4d6f1d799910f854067d4afecbb421579c331a Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 00:12:44 +0100 Subject: [PATCH 05/12] initialize ata based on token program of mint --- bin/autobahn-router/src/ix_builder.rs | 41 +++++++++++++++---- bin/autobahn-router/src/server/http_server.rs | 14 ++++++- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/bin/autobahn-router/src/ix_builder.rs b/bin/autobahn-router/src/ix_builder.rs index 71841ba..1d13eba 100644 --- a/bin/autobahn-router/src/ix_builder.rs +++ b/bin/autobahn-router/src/ix_builder.rs @@ -2,12 +2,15 @@ use crate::routing_types::{Route, RouteStep}; use crate::swap::Swap; use anchor_lang::Id; use anchor_spl::associated_token::get_associated_token_address; -use anchor_spl::token::Token; +use anchor_spl::token::{spl_token, Token}; +use anchor_spl::token_2022::spl_token_2022; use autobahn_executor::swap_ix::generate_swap_ix_data; -use router_lib::dex::{AccountProviderView, SwapInstruction, SwapMode}; +use router_lib::dex::{AccountProvider, AccountProviderView, SwapInstruction, SwapMode}; use solana_program::instruction::Instruction; use solana_program::pubkey::Pubkey; +use solana_sdk::account::ReadableAccount; use std::str::FromStr; +use std::sync::Arc; const CU_PER_HOP_DEFAULT: u32 = 80_000; const CU_BASE: u32 = 150_000; @@ -26,6 +29,7 @@ pub trait SwapStepInstructionBuilder { pub trait SwapInstructionsBuilder { fn build_ixs( &self, + live_account_provider: Arc, wallet_pk: &Pubkey, route: &Route, wrap_and_unwrap_sol: bool, @@ -81,6 +85,7 @@ impl SwapInstructionsBuilderImpl { impl SwapInstructionsBuilder for SwapInstructionsBuilderImpl { fn build_ixs( &self, + live_account_provider: Arc, wallet_pk: &Pubkey, route: &Route, auto_wrap_sol: bool, @@ -101,7 +106,7 @@ impl SwapInstructionsBuilder for SwapInstructions Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(); if auto_wrap_sol && route.input_mint == sol_mint { - Self::create_ata(&wallet_pk, &mut setup_instructions, &sol_mint); + Self::create_ata(&wallet_pk, &mut setup_instructions, &sol_mint, false); let wsol_account = get_associated_token_address(wallet_pk, &sol_mint); let in_amount = match swap_mode { @@ -145,13 +150,24 @@ impl SwapInstructionsBuilder for SwapInstructions for step in &swap_instructions { if auto_create_out || (step.out_mint == sol_mint && auto_wrap_sol) { - Self::create_ata(&wallet_pk, &mut setup_instructions, &step.out_mint); + let out_is_token_2022 = (step.out_mint != sol_mint) + && spl_token_2022::ID.eq(live_account_provider + .account(&step.out_mint)? + .account + .owner()); + Self::create_ata( + wallet_pk, + &mut setup_instructions, + &step.out_mint, + out_is_token_2022, + ); + cu_estimate += 12_000; } if step.out_mint == sol_mint && auto_wrap_sol { let wsol_account = get_associated_token_address(wallet_pk, &sol_mint); - Self::close_wsol_ata(&wallet_pk, &mut cleanup_instructions, &wsol_account)?; + Self::close_wsol_ata(wallet_pk, &mut cleanup_instructions, &wsol_account)?; cu_estimate += 12_000; } @@ -190,7 +206,7 @@ impl SwapInstructionsBuilder for SwapInstructions impl SwapInstructionsBuilderImpl { fn close_wsol_ata( - wallet_pk: &&Pubkey, + wallet_pk: &Pubkey, cleanup_instructions: &mut Vec, wsol_account: &Pubkey, ) -> anyhow::Result<()> { @@ -204,13 +220,22 @@ impl SwapInstructionsBuilderImpl { Ok(()) } - fn create_ata(wallet_pk: &&Pubkey, setup_instructions: &mut Vec, mint: &Pubkey) { + fn create_ata( + wallet_pk: &Pubkey, + setup_instructions: &mut Vec, + mint: &Pubkey, + token_program_is_2022: bool, + ) { setup_instructions.push( spl_associated_token_account::instruction::create_associated_token_account_idempotent( &wallet_pk, &wallet_pk, &mint, - &Token::id(), + if token_program_is_2022 { + &spl_token_2022::ID + } else { + &spl_token::ID + }, ), ); } diff --git a/bin/autobahn-router/src/server/http_server.rs b/bin/autobahn-router/src/server/http_server.rs index 8854edf..e760281 100644 --- a/bin/autobahn-router/src/server/http_server.rs +++ b/bin/autobahn-router/src/server/http_server.rs @@ -1,6 +1,7 @@ use crate::prelude::*; use crate::server::errors::*; use crate::server::route_provider::RouteProvider; +use anchor_spl::token_2022::spl_token_2022; use axum::extract::Query; use axum::response::Html; use axum::{extract::Form, http::header::HeaderMap, routing, Json, Router}; @@ -174,6 +175,7 @@ impl HttpServer { address_lookup_table_addresses.clone(), hash_provider.clone(), alt_provider.clone(), + live_account_provider.clone(), ix_builder.clone(), &route_candidate, Pubkey::new_unique().to_string(), @@ -291,7 +293,7 @@ impl HttpServer { ) -> Result, AppError> { let route = route_provider.try_from(&input.quote_response)?; - Self::log_repriced_amount(live_account_provider, reprice_probability, &route); + Self::log_repriced_amount(live_account_provider.clone(), reprice_probability, &route); let swap_mode: SwapMode = SwapMode::from_str(&input.quote_response.swap_mode) .map_err(|_| anyhow::Error::msg("Invalid SwapMode"))?; @@ -305,6 +307,7 @@ impl HttpServer { address_lookup_table_addresses, hash_provider, alt_provider, + live_account_provider, ix_builder, &route, input.user_public_key, @@ -363,11 +366,13 @@ impl HttpServer { async fn build_swap_tx< THashProvider: HashProvider + Send + Sync + 'static, TAltProvider: AltProvider + Send + Sync + 'static, + TAccountProvider: AccountProvider + Send + Sync + 'static, TIxBuilder: SwapInstructionsBuilder + Send + Sync + 'static, >( address_lookup_table_addresses: Vec, hash_provider: Arc, alt_provider: Arc, + live_account_provider: Arc, ix_builder: Arc, route_plan: &Route, wallet_pk: String, @@ -383,6 +388,7 @@ impl HttpServer { info!("build_ixs"); let ixs = ix_builder.build_ixs( + live_account_provider, &wallet_pk, route_plan, wrap_unwrap_sol, @@ -435,11 +441,13 @@ impl HttpServer { async fn swap_ix_handler< TRouteProvider: RouteProvider + Send + Sync + 'static, TAltProvider: AltProvider + Send + Sync + 'static, + TAccountProvider: AccountProvider + Send + Sync + 'static, TIxBuilder: SwapInstructionsBuilder + Send + Sync + 'static, >( address_lookup_table_addresses: Vec, route_provider: Arc, alt_provider: Arc, + live_account_provider: Arc, ix_builder: Arc, Query(_query): Query, Json(input): Json, @@ -456,6 +464,7 @@ impl HttpServer { }; let ixs = ix_builder.build_ixs( + live_account_provider, &wallet_pk, &route_plan, input.wrap_and_unwrap_sol, @@ -650,6 +659,7 @@ impl HttpServer { let alt = address_lookup_tables.clone(); let rp = route_provider.clone(); let altp = alt_provider.clone(); + let lap = live_account_provider.clone(); let ixb = ix_builder.clone(); router = router.route( "/swap-instructions", @@ -659,7 +669,7 @@ impl HttpServer { .with_label_values(&["swap-ix", client_key]) .start_timer(); - let response = Self::swap_ix_handler(alt, rp, altp, ixb, query, form).await; + let response = Self::swap_ix_handler(alt, rp, altp, lap, ixb, query, form).await; match response { Ok(_) => { From d7a67a67b84b5b07d5e72ca06edbbb49ab1b05ce Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 00:13:37 +0100 Subject: [PATCH 06/12] correctly parse token 2022 --- .../src/instructions/execute_swap_v3.rs | 1 + programs/autobahn-executor/src/token.rs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/programs/autobahn-executor/src/instructions/execute_swap_v3.rs b/programs/autobahn-executor/src/instructions/execute_swap_v3.rs index 10f294c..ef8d90b 100644 --- a/programs/autobahn-executor/src/instructions/execute_swap_v3.rs +++ b/programs/autobahn-executor/src/instructions/execute_swap_v3.rs @@ -86,6 +86,7 @@ pub fn execute_swap_v3( let out_amount = balance_after - balance_before; let out_mint = token::get_mint(ix_token_account)?; + if ix_index == 0 { input_amount = input_token_account_balance - token::get_balance(&accounts[0])?; input_mint = in_mint; diff --git a/programs/autobahn-executor/src/token.rs b/programs/autobahn-executor/src/token.rs index 40c535e..f6bbd01 100644 --- a/programs/autobahn-executor/src/token.rs +++ b/programs/autobahn-executor/src/token.rs @@ -16,8 +16,9 @@ pub fn get_balance(account: &AccountInfo) -> Result { Ok(token.amount) } spl_token_2022::ID => { - let token = spl_token_2022::state::Account::unpack(&account.try_borrow_data()?)?; - Ok(token.amount) + let data = account.data.borrow(); + let token = StateWithExtensions::::unpack(&data)?; + Ok(token.base.amount) } _ => Err(ProgramError::IllegalOwner), } @@ -30,9 +31,9 @@ pub fn get_mint(account: &AccountInfo) -> Result { Ok(token.mint) } spl_token_2022::ID => { - let token: spl_token_2022::state::Account = - spl_token_2022::state::Account::unpack(&account.try_borrow_data()?)?; - Ok(token.mint) + let data = account.data.borrow(); + let token = StateWithExtensions::::unpack(&data)?; + Ok(token.base.mint) } _ => Err(ProgramError::IllegalOwner), } @@ -45,9 +46,9 @@ pub fn get_owner(account: &AccountInfo) -> Result { Ok(token.owner) } spl_token_2022::ID => { - let token: spl_token_2022::state::Account = - spl_token_2022::state::Account::unpack(&account.try_borrow_data()?)?; - Ok(token.owner) + let data = account.data.borrow(); + let token = StateWithExtensions::::unpack(&data)?; + Ok(token.base.owner) } _ => Err(ProgramError::IllegalOwner), } From dcb11690fd707dd85326a8b8c318b0d74721f5b8 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 00:28:35 +0100 Subject: [PATCH 07/12] cleanup all logging --- .../src/dex/generic/generic_adapter.rs | 12 ++------ bin/autobahn-router/src/edge.rs | 4 +-- bin/autobahn-router/src/edge_updater.rs | 3 -- bin/autobahn-router/src/main.rs | 1 - bin/autobahn-router/src/path_warmer.rs | 8 ++--- bin/autobahn-router/src/routing.rs | 24 +++++---------- bin/autobahn-router/src/server/http_server.rs | 30 ++----------------- .../src/source/grpc_plugin_source.rs | 13 ++++---- lib/dex-invariant/src/invariant_dex.rs | 27 +++++++---------- lib/dex-invariant/src/invariant_ix_builder.rs | 1 - lib/router-lib/src/price_feeds/birdeye.rs | 3 ++ lib/router-lib/src/price_feeds/price_cache.rs | 10 +++++-- .../src/instructions/execute_swap_v3.rs | 1 - 13 files changed, 44 insertions(+), 93 deletions(-) diff --git a/bin/autobahn-router/src/dex/generic/generic_adapter.rs b/bin/autobahn-router/src/dex/generic/generic_adapter.rs index d9736df..4be7b4d 100644 --- a/bin/autobahn-router/src/dex/generic/generic_adapter.rs +++ b/bin/autobahn-router/src/dex/generic/generic_adapter.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use itertools::Itertools; use router_lib::dex::{DexInterface, DexSubscriptionMode}; use router_lib::mango::mango_fetcher::MangoMetadata; -use tracing::{info, trace}; +use tracing::info; use crate::edge::Edge; use crate::edge_updater::Dex; @@ -46,11 +46,8 @@ pub async fn build_dex_internal( let edges_per_pk_src = dex.edges_per_pk(); let mut edges_per_pk = HashMap::new(); - info!("dex {} enabled={enabled} add_mango_tokens={add_mango_tokens} take_all_mints={take_all_mints} mints={mints:?} edges={}", dex.name(), edges_per_pk_src.len()); - - for (key, edge_ids) in edges_per_pk_src { - - let edges = edge_ids.clone() + for (key, edges) in edges_per_pk_src { + let edges = edges .into_iter() .filter(|x| { let keep = take_all_mints @@ -68,9 +65,6 @@ pub async fn build_dex_internal( }) }) .collect_vec(); - - trace!("build_dex_internal key={key:?} edge_ids={} edges={}", edge_ids.len(), edges.len()); - if edges.len() > 0 { edges_per_pk.insert(key, edges); } diff --git a/bin/autobahn-router/src/edge.rs b/bin/autobahn-router/src/edge.rs index 53404b9..eebb229 100644 --- a/bin/autobahn-router/src/edge.rs +++ b/bin/autobahn-router/src/edge.rs @@ -240,14 +240,14 @@ impl Edge { let Ok(decimals) = token_cache.token(self.input_mint).map(|x| x.decimals) else { let mut state = self.state.write().unwrap(); - info!("update_internal no decimals for {}", self.input_mint); + trace!("no decimals for {}", self.input_mint); state.is_valid = false; return; }; let Some(price) = price_cache.price_ui(self.input_mint) else { let mut state = self.state.write().unwrap(); state.is_valid = false; - // info!("update_internal no price for {}", self.input_mint); + trace!("no price for {}", self.input_mint); return; }; diff --git a/bin/autobahn-router/src/edge_updater.rs b/bin/autobahn-router/src/edge_updater.rs index c3c27ed..d452aa0 100644 --- a/bin/autobahn-router/src/edge_updater.rs +++ b/bin/autobahn-router/src/edge_updater.rs @@ -209,7 +209,6 @@ pub fn spawn_updater_job( impl EdgeUpdater { fn detect_and_handle_slot_lag(&mut self, slot: Result) { - info!("detect_and_handle_slot_lag {slot:?}"); let state = &mut self.state; if state.latest_slot_processed == 0 { return; @@ -283,7 +282,6 @@ impl EdgeUpdater { } fn on_metadata_update(&mut self, res: Result) { - info!("metadata_update {res:?}"); let state = &mut self.state; match res { Ok(v) => match v { @@ -295,7 +293,6 @@ impl EdgeUpdater { FeedMetadata::SnapshotEnd(x) => { if let Some(x) = x { if x == spl_token::ID { - // TODO: token2022 support for CP style amms // TODO Handle multiples owners state.dirty_token_accounts_for_owners = true; } else { diff --git a/bin/autobahn-router/src/main.rs b/bin/autobahn-router/src/main.rs index 6e3f8fd..5b5043d 100644 --- a/bin/autobahn-router/src/main.rs +++ b/bin/autobahn-router/src/main.rs @@ -241,7 +241,6 @@ async fn main() -> anyhow::Result<()> { }), }; - info!("config = {config:?}"); let dexs: Vec = [ dex::generic::build_dex!( OrcaDex::initialize(&mut router_rpc, orca_config).await?, diff --git a/bin/autobahn-router/src/path_warmer.rs b/bin/autobahn-router/src/path_warmer.rs index f81782a..b51fcfa 100644 --- a/bin/autobahn-router/src/path_warmer.rs +++ b/bin/autobahn-router/src/path_warmer.rs @@ -86,7 +86,6 @@ where all_mints.insert(sol_mint); all_mints.insert(usdc_mint); - let hot_mints = hot_mints_cache.read().unwrap().get(); let mints = match generate_mints( &mode, @@ -99,7 +98,7 @@ where None => break, }; - info!("Running a path warmup loop for {} mints", mints.len()); + debug!("Running a path warmup loop for {} mints", mints.len()); let mut counter = 0; let mut skipped = 0; let time = Instant::now(); @@ -121,13 +120,10 @@ where continue; }; if price_ui <= 0.000001 { - info!("skipped {from_mint:?} price is low {price_ui}"); skipped += 1; continue; } let Ok(token) = token_cache.token(*from_mint) else { - info!("skipped {from_mint:?} no token cache entry"); - skipped += 1; continue; }; @@ -135,7 +131,7 @@ where let decimals = token.decimals; let multiplier = 10u64.pow(decimals as u32) as f64; - info!("Warming up {}", debug_tools::name(&from_mint),); + trace!("Warming up {}", debug_tools::name(&from_mint),); for amount_ui in &path_warming_amounts { let amount_native = diff --git a/bin/autobahn-router/src/routing.rs b/bin/autobahn-router/src/routing.rs index 8e063c6..5682f0d 100644 --- a/bin/autobahn-router/src/routing.rs +++ b/bin/autobahn-router/src/routing.rs @@ -693,15 +693,12 @@ impl Routing { let mut best = HashMap::<(Pubkey, Pubkey), Vec<(EdgeIndex, f64)>>::new(); for (edge_index, edge) in all_edges.iter().enumerate() { - trace!("ix:{edge_index} edge:{edge:?}"); if swap_mode == SwapMode::ExactOut && !edge.supports_exact_out() { continue; } let edge_index: EdgeIndex = edge_index.into(); let state = edge.state.read().unwrap(); - trace!("ix:{edge_index} edge:{edge:?} {:?}", state.cached_prices); - if !state.is_valid() || state.cached_prices.len() < i { continue; } @@ -781,6 +778,7 @@ impl Routing { price_impact, ); + // TODO: make this a config variable for reach network // if price_impact > 0.25 { // skipped_bad_price_impact += 1; // continue; @@ -1249,7 +1247,7 @@ impl Routing { bail!(RoutingError::UnsupportedOutputMint(output_mint.clone())); }; - info!( + trace!( input_index = input_index.idx_raw(), output_index = output_index.idx_raw(), max_path_length, @@ -1270,7 +1268,6 @@ impl Routing { .map(|paths| self.lookup_edge_index_paths(paths.iter())); if (p1.is_none() && p2.is_none()) || ignore_cache { - info!("no cache"); None } else { let cached_paths = p1 @@ -1278,7 +1275,6 @@ impl Routing { .into_iter() .chain(p2.unwrap_or(vec![]).into_iter()) .collect_vec(); - info!("cached {}", cached_paths.len()); Some(cached_paths) } }; @@ -1396,9 +1392,9 @@ impl Routing { } // Debug - if true { + if tracing::event_enabled!(Level::TRACE) { for (path, out_amount, out_amount_dumb) in &path_and_output { - info!( + trace!( "potential path: [out={}] [dumb={}] {}", out_amount, out_amount_dumb, @@ -1453,7 +1449,7 @@ impl Routing { let price_impact = expected_ratio / actual_ratio * 10_000.0 - 10_000.0; let price_impact_bps = price_impact.round() as u64; - info!( + trace!( price_impact_bps, out_amount_for_small_amount, out_amount_for_request, @@ -1489,7 +1485,7 @@ impl Routing { } if self.overquote > 0.0 { - info!( + debug!( actual_in_amount, actual_out_amount, overquote_in_amount, @@ -1504,7 +1500,6 @@ impl Routing { let accounts = self .capture_accounts(chain_data, &out_path, original_amount) .ok(); - return Ok(Route { input_mint: *input_mint, @@ -1550,19 +1545,16 @@ impl Routing { output_index: MintNodeIndex, used_cached_paths: bool, ) -> anyhow::Result { - - - info!("failsafe triggered"); // It is possible for cache path to became invalid after some account write or failed tx (cooldown) // If we used cache but can't find any valid path, try again without the cache let can_try_one_more_hop = max_path_length != self.max_path_length; if !ignore_cache && (used_cached_paths || can_try_one_more_hop) { if used_cached_paths { - info!("Invalid cached path, retrying without cache"); + debug!("Invalid cached path, retrying without cache"); let mut cache = self.path_discovery_cache.write().unwrap(); cache.invalidate(input_index, output_index, max_accounts); } else { - info!("No path within boundaries, retrying with +1 hop"); + debug!("No path within boundaries, retrying with +1 hop"); } return self.find_best_route( chain_data, diff --git a/bin/autobahn-router/src/server/http_server.rs b/bin/autobahn-router/src/server/http_server.rs index e760281..e97ce91 100644 --- a/bin/autobahn-router/src/server/http_server.rs +++ b/bin/autobahn-router/src/server/http_server.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::server::errors::*; use crate::server::route_provider::RouteProvider; -use anchor_spl::token_2022::spl_token_2022; use axum::extract::Query; use axum::response::Html; use axum::{extract::Form, http::header::HeaderMap, routing, Json, Router}; @@ -169,8 +168,6 @@ impl HttpServer { swap_mode, )?; - info!("best route found"); - let (bytes, accounts_count) = Self::build_swap_tx( address_lookup_table_addresses.clone(), hash_provider.clone(), @@ -188,9 +185,6 @@ impl HttpServer { ) .await?; - info!("tx encoded"); - - let tx_size = bytes.len(); if accounts_count <= MAX_ACCOUNTS_PER_TX && tx_size < MAX_TX_SIZE { break Ok(route_candidate); @@ -204,11 +198,9 @@ impl HttpServer { } }; - info!("quote -> err ? {}", route.is_err()); - let route: Route = route?; - Self::log_repriced_amount(live_account_provider, reprice_probability, &route); + Self::log_repriced_amount(live_account_provider.clone(), reprice_probability, &route); let other_amount_threshold = if swap_mode == SwapMode::ExactOut { (route.in_amount as f64 * (10_000f64 + input.slippage_bps as f64) / 10_000f64).floor() @@ -218,8 +210,6 @@ impl HttpServer { .floor() as u64 }; - info!("serialize plan"); - let route_plan = route .steps .iter() @@ -238,9 +228,6 @@ impl HttpServer { }) .collect_vec(); - info!("encode accounts"); - - let accounts = match route.accounts { None => None, Some(a) => Some( @@ -293,7 +280,7 @@ impl HttpServer { ) -> Result, AppError> { let route = route_provider.try_from(&input.quote_response)?; - Self::log_repriced_amount(live_account_provider.clone(), reprice_probability, &route); + Self::log_repriced_amount(live_account_provider, reprice_probability, &route); let swap_mode: SwapMode = SwapMode::from_str(&input.quote_response.swap_mode) .map_err(|_| anyhow::Error::msg("Invalid SwapMode"))?; @@ -307,7 +294,6 @@ impl HttpServer { address_lookup_table_addresses, hash_provider, alt_provider, - live_account_provider, ix_builder, &route, input.user_public_key, @@ -366,8 +352,8 @@ impl HttpServer { async fn build_swap_tx< THashProvider: HashProvider + Send + Sync + 'static, TAltProvider: AltProvider + Send + Sync + 'static, - TAccountProvider: AccountProvider + Send + Sync + 'static, TIxBuilder: SwapInstructionsBuilder + Send + Sync + 'static, + TAccountProvider: AccountProvider + Send + Sync + 'static, >( address_lookup_table_addresses: Vec, hash_provider: Arc, @@ -385,8 +371,6 @@ impl HttpServer { ) -> Result<(Vec, usize), AppError> { let wallet_pk = Pubkey::from_str(&wallet_pk)?; - info!("build_ixs"); - let ixs = ix_builder.build_ixs( live_account_provider, &wallet_pk, @@ -403,8 +387,6 @@ impl HttpServer { ComputeBudgetInstruction::set_compute_unit_limit(ixs.cu_estimate), ]; - info!("serialize ixs"); - let transaction_addresses = ixs.accounts().into_iter().collect(); let instructions = compute_budget_ixs .into_iter() @@ -413,16 +395,11 @@ impl HttpServer { .chain(ixs.cleanup_instructions.into_iter()) .collect_vec(); - - info!("load alts"); let all_alts = Self::load_all_alts(address_lookup_table_addresses, alt_provider).await; - info!("optimize alts"); let alts = alt_optimizer::get_best_alt(&all_alts, &transaction_addresses)?; let accounts = transaction_addresses.iter().unique().count() + alts.iter().map(|x| x.key).unique().count(); - info!("compile message"); - let v0_message = solana_sdk::message::v0::Message::try_compile( &wallet_pk, instructions.as_slice(), @@ -432,7 +409,6 @@ impl HttpServer { let message = VersionedMessage::V0(v0_message); let tx = VersionedTransaction::try_new(message, &[&NullSigner::new(&wallet_pk)])?; - info!("serialize message"); let bytes = bincode::serialize(&tx)?; Ok((bytes, accounts)) diff --git a/bin/autobahn-router/src/source/grpc_plugin_source.rs b/bin/autobahn-router/src/source/grpc_plugin_source.rs index 68aacde..1effc22 100644 --- a/bin/autobahn-router/src/source/grpc_plugin_source.rs +++ b/bin/autobahn-router/src/source/grpc_plugin_source.rs @@ -70,8 +70,6 @@ pub async fn feed_data_geyser( subscribed_token_accounts: &HashSet, sender: async_channel::Sender, ) -> anyhow::Result<()> { - - println!("feed_data_geyser a:{subscribed_accounts:?} p:{subscribed_programs:?} t:{subscribed_token_accounts:?}"); let use_compression = snapshot_config.rpc_support_compression.unwrap_or(false); let number_of_accounts_per_gma = snapshot_config.number_of_accounts_per_gma.unwrap_or(100); let grpc_connection_string = match &grpc_config.connection_string.chars().next().unwrap() { @@ -746,7 +744,7 @@ async fn process_account_updated_from_sources( metrics::ACCOUNT_SNAPSHOTS .with_label_values(&[&label]) .inc(); - info!( + debug!( "processing snapshot for program_id {} -> size={} & missing size={}...", update .program_id @@ -764,11 +762,12 @@ async fn process_account_updated_from_sources( metrics::GRPC_SNAPSHOT_ACCOUNT_WRITES.inc(); metrics::GRPC_ACCOUNT_WRITE_QUEUE.set(account_write_queue_sender.len() as i64); - // if !filters.contains(&account.pubkey) && update.program_id.is_none() { - // info!("filtered account {:?}", account.pubkey); + // TODO: disabled for eclipse launch, was causing issues with the program id + // subscription for invariant + // if !filters.contains(&account.pubkey) { // continue; // } - + updated_accounts.push(account); } account_write_queue_sender @@ -781,7 +780,7 @@ async fn process_account_updated_from_sources( warn!("failed to send feed matadata event: {}", e); } } - info!("processing snapshot done"); + debug!("processing snapshot done"); if let Err(e) = metadata_sender(FeedMetadata::SnapshotEnd(update.program_id)) { warn!("failed to send feed matadata event: {}", e); } diff --git a/lib/dex-invariant/src/invariant_dex.rs b/lib/dex-invariant/src/invariant_dex.rs index 2a0f47e..d904965 100644 --- a/lib/dex-invariant/src/invariant_dex.rs +++ b/lib/dex-invariant/src/invariant_dex.rs @@ -1,5 +1,6 @@ use std::{ - collections::{HashMap, HashSet}, str::FromStr, sync::Arc + collections::{HashMap, HashSet}, + sync::Arc, }; use anchor_lang::{AnchorDeserialize, Id}; @@ -14,7 +15,6 @@ use invariant_types::{ structs::{Pool, Tick, Tickmap, TickmapView, TICK_CROSSES_PER_IX, TICK_LIMIT}, ANCHOR_DISCRIMINATOR_SIZE, TICK_SEED, }; -use itertools::Itertools; use router_feed_lib::router_rpc_client::{RouterRpcClient, RouterRpcClientTrait}; use router_lib::dex::{ AccountProviderView, DexEdge, DexEdgeIdentifier, DexInterface, DexSubscriptionMode, Quote, @@ -26,7 +26,7 @@ use solana_client::{ rpc_filter::RpcFilterType, }; use solana_sdk::{account::ReadableAccount, program_pack::Pack, pubkey::Pubkey}; -use tracing::{debug, error, info}; +use tracing::info; use crate::{ invariant_edge::{InvariantEdge, InvariantEdgeIdentifier, InvariantSimulationParams}, @@ -192,11 +192,9 @@ where { chain_data: &AccountProviderView, ) -> anyhow::Result { let pool_account_data = chain_data.account(&id.pool)?; - let pool = Self::deserialize::(pool_account_data.account.data())?; let tickmap_account_data = chain_data.account(&pool.tickmap)?; - let tickmap = Self::deserialize_tickmap_view( &tickmap_account_data.account.data(), pool.current_tick_index, @@ -261,6 +259,8 @@ impl DexInterface for InvariantDex { || banned_reserves.contains(&p.1.token_y_reserve)) }); + info!("Number of Invariant Pools: {:?}", pools.len()); + let edge_pairs: Vec<(Arc, Arc)> = pools .iter() .map(|(pool_pk, pool)| { @@ -281,7 +281,6 @@ impl DexInterface for InvariantDex { }) .into_iter() .collect(); - let tickmaps = pools.iter().map(|p| p.1.tickmap).collect(); let tickmaps = rpc.get_multiple_accounts(&tickmaps).await?; @@ -293,7 +292,6 @@ impl DexInterface for InvariantDex { { let entry: Vec> = vec![edge_x_to_y.clone(), edge_y_to_x.clone()]; - map.insert(*pool_pk, entry.clone()); map.insert(*tickmap_pk, entry.clone()); @@ -307,11 +305,6 @@ impl DexInterface for InvariantDex { map }; - info!("inv init done"); - let poolpk = Pubkey::from_str("G8Skt6kgqVL9ocYn4aYVGs3gUg8EfQrTJAkA2qt3gcs8").unwrap(); - info!("pool edges: {:?}", edges_per_pk.get(&poolpk).map(|ids| ids.iter().map(|id| vec![id.input_mint(), id.output_mint()]).collect_vec())); - - Ok(Arc::new(InvariantDex { edges: edges_per_pk, })) @@ -342,9 +335,9 @@ impl DexInterface for InvariantDex { .as_any() .downcast_ref::() .unwrap(); - let edge: Result = Self::load_edge(id, chain_data); - debug!("load edge with id={id:?} -> {edge:?}"); - Ok(Arc::new(edge?)) + let edge = Self::load_edge(id, chain_data)?; + + Ok(Arc::new(edge)) } fn quote( @@ -366,7 +359,7 @@ impl DexInterface for InvariantDex { } else { calculate_price_sqrt(get_max_tick(edge.pool.tick_spacing)?) }; - + let simulation = edge .simulate_invariant_swap(&InvariantSimulationParams { x_to_y, @@ -374,7 +367,7 @@ impl DexInterface for InvariantDex { sqrt_price_limit, by_amount_in: true, }) - .map_err(|e| { debug!("quote id={id:?} error: {:?}", e); anyhow::format_err!(e) }) + .map_err(|e| anyhow::format_err!(e)) .with_context(|| format!("pool {} x_to_y {}", id.pool, id.x_to_y))?; let fee_mint = if x_to_y { id.token_x } else { id.token_y }; diff --git a/lib/dex-invariant/src/invariant_ix_builder.rs b/lib/dex-invariant/src/invariant_ix_builder.rs index 715da29..6351642 100644 --- a/lib/dex-invariant/src/invariant_ix_builder.rs +++ b/lib/dex-invariant/src/invariant_ix_builder.rs @@ -8,7 +8,6 @@ use sha2::{Digest, Sha256}; use solana_program::instruction::Instruction; use solana_program::pubkey::Pubkey; use solana_sdk::account::ReadableAccount; -use tracing::info; pub fn build_swap_ix( id: &InvariantEdgeIdentifier, diff --git a/lib/router-lib/src/price_feeds/birdeye.rs b/lib/router-lib/src/price_feeds/birdeye.rs index 71e99df..27eabb7 100644 --- a/lib/router-lib/src/price_feeds/birdeye.rs +++ b/lib/router-lib/src/price_feeds/birdeye.rs @@ -86,7 +86,10 @@ impl BirdeyePriceFeed { mints: &HashSet, sender: broadcast::Sender, ) -> anyhow::Result<()> { + + // TODO: disabled for eclipse launch until traffic is live return Ok(()); + let http_client = reqwest::Client::new(); let mut chunks: Vec> = vec![]; diff --git a/lib/router-lib/src/price_feeds/price_cache.rs b/lib/router-lib/src/price_feeds/price_cache.rs index 6b2e07f..a909b95 100644 --- a/lib/router-lib/src/price_feeds/price_cache.rs +++ b/lib/router-lib/src/price_feeds/price_cache.rs @@ -14,10 +14,14 @@ impl PriceCache { pub fn new( mut exit: tokio::sync::broadcast::Receiver<()>, mut receiver: tokio::sync::broadcast::Receiver, - ) -> (PriceCache, JoinHandle<()>) { + ) -> (PriceCache, JoinHandle<()>) { let latest_prices = Arc::new(DashMap::new()); - //latest_prices.insert(Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(), 2500.0); - latest_prices.insert(Pubkey::from_str("AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE").unwrap(), 1.0); + // seed price cache with stable coin prices, as a point of reference + latest_prices.insert( + Pubkey::from_str("AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE").unwrap(), + 1.0, + ); + let latest_prices_write = latest_prices.clone(); let job = tokio::spawn(async move { diff --git a/programs/autobahn-executor/src/instructions/execute_swap_v3.rs b/programs/autobahn-executor/src/instructions/execute_swap_v3.rs index ef8d90b..10f294c 100644 --- a/programs/autobahn-executor/src/instructions/execute_swap_v3.rs +++ b/programs/autobahn-executor/src/instructions/execute_swap_v3.rs @@ -86,7 +86,6 @@ pub fn execute_swap_v3( let out_amount = balance_after - balance_before; let out_mint = token::get_mint(ix_token_account)?; - if ix_index == 0 { input_amount = input_token_account_balance - token::get_balance(&accounts[0])?; input_mint = in_mint; From 050415a86c8a5f38f14a9023e5203994f0cd2ba2 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 10:33:29 +0100 Subject: [PATCH 08/12] cleanup --- bin/autobahn-router/src/ix_builder.rs | 1 + bin/autobahn-router/src/main.rs | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/autobahn-router/src/ix_builder.rs b/bin/autobahn-router/src/ix_builder.rs index 1d13eba..9c828fd 100644 --- a/bin/autobahn-router/src/ix_builder.rs +++ b/bin/autobahn-router/src/ix_builder.rs @@ -150,6 +150,7 @@ impl SwapInstructionsBuilder for SwapInstructions for step in &swap_instructions { if auto_create_out || (step.out_mint == sol_mint && auto_wrap_sol) { + // wrapped SOL is always legacy token not 2022 let out_is_token_2022 = (step.out_mint != sol_mint) && spl_token_2022::ID.eq(live_account_provider .account(&step.out_mint)? diff --git a/bin/autobahn-router/src/main.rs b/bin/autobahn-router/src/main.rs index 5b5043d..6c6d1b9 100644 --- a/bin/autobahn-router/src/main.rs +++ b/bin/autobahn-router/src/main.rs @@ -443,11 +443,9 @@ async fn main() -> anyhow::Result<()> { // collect all mints traded so their token program owner can be checked let mut mints = HashSet::new(); for d in dexs.iter() { - for es in d.edges_per_pk.values() { - for e in es { - mints.insert(e.input_mint); - mints.insert(e.output_mint); - } + for e in d.edges_per_pk.values().flatten() { + mints.insert(e.input_mint); + mints.insert(e.output_mint); } } From 54e9f8b183c63cd7f16d98161acff2e06dbbb1cf Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 10:35:51 +0100 Subject: [PATCH 09/12] update price feed config for eclipse --- bin/autobahn-router/template-config-eclipse.toml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/autobahn-router/template-config-eclipse.toml b/bin/autobahn-router/template-config-eclipse.toml index 8312cec..350627a 100644 --- a/bin/autobahn-router/template-config-eclipse.toml +++ b/bin/autobahn-router/template-config-eclipse.toml @@ -47,11 +47,11 @@ add_mango_tokens = false [routing] path_cache_validity_ms = 30000 -path_warming_mode = "ConfiguredMints" -#path_warming_mode = "HotMints" +path_warming_mode = "All" path_warming_amounts = [100, 1000, 10_000] path_warming_for_mints = [ - "So11111111111111111111111111111111111111112", # SOL + "So11111111111111111111111111111111111111112", # ETH + "AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE", # USDC ] path_warming_interval_secs = 5 path_warming_max_accounts = [20, 30, 40, 64] @@ -95,7 +95,8 @@ min_quote_out_to_in_amount_ratio = 0.65 [hot_mints] always_hot_mints = [ - "So11111111111111111111111111111111111111112", # SOL + "So11111111111111111111111111111111111111112", # ETH + "AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE", # USDC ] keep_latest_count = 50 From 89733a0c863b12809e00793d8e1d593b0371ddb8 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 11:28:18 +0100 Subject: [PATCH 10/12] fix compile error --- bin/autobahn-router/src/server/http_server.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/autobahn-router/src/server/http_server.rs b/bin/autobahn-router/src/server/http_server.rs index e97ce91..d9df706 100644 --- a/bin/autobahn-router/src/server/http_server.rs +++ b/bin/autobahn-router/src/server/http_server.rs @@ -280,7 +280,7 @@ impl HttpServer { ) -> Result, AppError> { let route = route_provider.try_from(&input.quote_response)?; - Self::log_repriced_amount(live_account_provider, reprice_probability, &route); + Self::log_repriced_amount(live_account_provider.clone(), reprice_probability, &route); let swap_mode: SwapMode = SwapMode::from_str(&input.quote_response.swap_mode) .map_err(|_| anyhow::Error::msg("Invalid SwapMode"))?; @@ -294,6 +294,7 @@ impl HttpServer { address_lookup_table_addresses, hash_provider, alt_provider, + live_account_provider, ix_builder, &route, input.user_public_key, From 092d6da2aaa2cfa0f7b08534fe4e62244ca1380a Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 14:30:04 +0100 Subject: [PATCH 11/12] reduce path warming amounts --- bin/autobahn-router/template-config-eclipse.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/autobahn-router/template-config-eclipse.toml b/bin/autobahn-router/template-config-eclipse.toml index 350627a..2b39554 100644 --- a/bin/autobahn-router/template-config-eclipse.toml +++ b/bin/autobahn-router/template-config-eclipse.toml @@ -48,7 +48,7 @@ add_mango_tokens = false [routing] path_cache_validity_ms = 30000 path_warming_mode = "All" -path_warming_amounts = [100, 1000, 10_000] +path_warming_amounts = [1, 3, 10] path_warming_for_mints = [ "So11111111111111111111111111111111111111112", # ETH "AKEWE7Bgh87GPp171b4cJPSSZfmZwQ3KaqYqXoKLNAEE", # USDC From 16feea9995d41201bdcdd11151eb67f632e87e2c Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Fri, 8 Nov 2024 15:35:16 +0100 Subject: [PATCH 12/12] pass mint to transfer --- programs/autobahn-executor/src/token.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/autobahn-executor/src/token.rs b/programs/autobahn-executor/src/token.rs index f6bbd01..29a1de3 100644 --- a/programs/autobahn-executor/src/token.rs +++ b/programs/autobahn-executor/src/token.rs @@ -119,7 +119,7 @@ pub fn transfer<'a>( &[], amount, )?; - let transfer_account_infos = [source.clone(), destination.clone(), program.clone()]; + let transfer_account_infos = [source.clone(), destination.clone(), program.clone(), authority.clone()]; if signer_seeds.is_empty() { invoke(&transfer_ix, &transfer_account_infos) } else { @@ -140,7 +140,7 @@ pub fn transfer<'a>( amount, mint_parsed.base.decimals, )?; - let transfer_account_infos = [source.clone(), destination.clone(), program.clone()]; + let transfer_account_infos = [source.clone(), destination.clone(), mint.clone(), program.clone(), authority.clone()]; if signer_seeds.is_empty() { invoke(&transfer_ix, &transfer_account_infos) } else {