midway debug

This commit is contained in:
Maximilian Schneider 2024-11-07 04:01:25 +01:00
parent 6608fc804a
commit da6c08933c
7 changed files with 46 additions and 17 deletions

View File

@ -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| {

View File

@ -241,6 +241,8 @@ async fn main() -> anyhow::Result<()> {
}),
};
info!("config = {config:?}");
let dexs: Vec<Dex> = [
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
),
]

View File

@ -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 => {

View File

@ -70,6 +70,8 @@ pub async fn feed_data_geyser(
subscribed_token_accounts: &HashSet<Pubkey>,
sender: async_channel::Sender<SourceMessage>,
) -> 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() {

View File

@ -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::<spl_token_2022::state::Mint>::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);

View File

@ -192,9 +192,11 @@ where {
chain_data: &AccountProviderView,
) -> anyhow::Result<InvariantEdge> {
let pool_account_data = chain_data.account(&id.pool)?;
let pool = Self::deserialize::<Pool>(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::<HashSet<_>>();
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,
}))

View File

@ -86,6 +86,7 @@ impl BirdeyePriceFeed {
mints: &HashSet<Pubkey>,
sender: broadcast::Sender<PriceUpdate>,
) -> anyhow::Result<()> {
return Ok(());
let http_client = reqwest::Client::new();
let mut chunks: Vec<Vec<Pubkey>> = vec![];