diff --git a/Cargo.lock b/Cargo.lock index a78d7398..50e201fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2761,7 +2761,7 @@ dependencies = [ [[package]] name = "pyth-agent" -version = "2.3.0" +version = "2.3.1" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index cfead40e..00c3fc20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-agent" -version = "2.3.0" +version = "2.3.1" edition = "2021" [[bin]] diff --git a/src/agent/solana/exporter.rs b/src/agent/solana/exporter.rs index d4aeab8f..056dc0cf 100644 --- a/src/agent/solana/exporter.rs +++ b/src/agent/solana/exporter.rs @@ -154,8 +154,12 @@ impl Default for Config { compute_unit_limit: 40000, compute_unit_price_micro_lamports: None, dynamic_compute_unit_pricing_enabled: false, - maximum_total_compute_fee_micro_lamports: 1_000_000_000_000, - maximum_slot_gap_for_dynamic_compute_unit_price: 25, + // Maximum total compute unit fee paid for a single transaction (0.0001 SOL) + maximum_total_compute_fee_micro_lamports: 100_000_000_000, + // A publisher update is not included if it is 25 slots behind the current slot. + // Due to the delay in the network (until a block gets confirmed) we add 5 slots + // to make sure we do not overpay. + maximum_slot_gap_for_dynamic_compute_unit_price: 30, } } } @@ -722,12 +726,18 @@ impl Exporter { let result = result_rx.await??; - // Calculate the maximum slot difference between aggregate slot and + // Calculate the maximum slot difference between the publisher latest slot and // current slot amongst all the accounts. Here, the aggregate slot is // used instead of the publishers latest update to avoid overpaying. let oldest_slot = result .values() - .map(|account| account.last_slot) + .flat_map(|account| { + account + .comp + .iter() + .find(|c| c.publisher == publish_keypair.pubkey()) + .map(|c| c.latest.pub_slot) + }) .min() .ok_or(anyhow!("No price accounts"))?;