Router: lazy update prices based on quote request direction

This commit is contained in:
Serge Farny 2024-10-08 11:43:06 +02:00
parent 6ee0ae7ee1
commit 1260eeb88c
2 changed files with 4 additions and 5 deletions

View File

@ -1896,10 +1896,11 @@ impl Routing {
chain_data: &AccountProviderView,
token_cache: &TokenCache,
price_cache: &PriceCache,
mint: &Pubkey,
input_mint: &Pubkey,
output_mint: &Pubkey,
) {
for edge in &self.edges {
if edge.input_mint.eq(mint) {
if edge.input_mint.eq(input_mint) || edge.output_mint.eq(output_mint) {
edge.update_if_needed(
chain_data,
token_cache,

View File

@ -93,9 +93,7 @@ impl RouteProvider for RoutingRouteProvider {
// ensure new hot mints are ready (edge cached_price should be available)
self.routing
.lazy_compute_prices(&self.chain_data, &self.tokens, &self.prices, &from_mint);
self.routing
.lazy_compute_prices(&self.chain_data, &self.tokens, &self.prices, &to_mint);
.lazy_compute_prices(&self.chain_data, &self.tokens, &self.prices, &from_mint, &to_mint);
let route = self.routing.find_best_route(
&self.chain_data,