Skip to content

Commit 6e6ecbf

Browse files
committed
fix: use publisher latest slot for staleness based pricing
1 parent bdcd1c1 commit 6e6ecbf

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-agent"
3-
version = "2.3.0"
3+
version = "2.3.1"
44
edition = "2021"
55

66
[[bin]]

src/agent/solana/exporter.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,12 @@ impl Default for Config {
154154
compute_unit_limit: 40000,
155155
compute_unit_price_micro_lamports: None,
156156
dynamic_compute_unit_pricing_enabled: false,
157-
maximum_total_compute_fee_micro_lamports: 1_000_000_000_000,
158-
maximum_slot_gap_for_dynamic_compute_unit_price: 25,
157+
// Maximum total compute unit fee paid for a single transaction (0.0001 SOL)
158+
maximum_total_compute_fee_micro_lamports: 100_000_000_000,
159+
// A publisher update is not included if it is 25 slots behind the current slot.
160+
// Due to the delay in the network (until a block gets confirmed) we add 5 slots
161+
// to make sure we do not overpay.
162+
maximum_slot_gap_for_dynamic_compute_unit_price: 30,
159163
}
160164
}
161165
}
@@ -722,12 +726,18 @@ impl Exporter {
722726

723727
let result = result_rx.await??;
724728

725-
// Calculate the maximum slot difference between aggregate slot and
729+
// Calculate the maximum slot difference between the publisher latest slot and
726730
// current slot amongst all the accounts. Here, the aggregate slot is
727731
// used instead of the publishers latest update to avoid overpaying.
728732
let oldest_slot = result
729733
.values()
730-
.map(|account| account.last_slot)
734+
.flat_map(|account| {
735+
account
736+
.comp
737+
.iter()
738+
.find(|c| c.publisher == publish_keypair.pubkey())
739+
.map(|c| c.latest.pub_slot)
740+
})
731741
.min()
732742
.ok_or(anyhow!("No price accounts"))?;
733743

0 commit comments

Comments
 (0)