Skip to content

Commit

Permalink
fix: use publisher latest slot for staleness based pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Nov 16, 2023
1 parent bdcd1c1 commit 6e6ecbf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-agent"
version = "2.3.0"
version = "2.3.1"
edition = "2021"

[[bin]]
Expand Down
18 changes: 14 additions & 4 deletions src/agent/solana/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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"))?;

Expand Down

0 comments on commit 6e6ecbf

Please sign in to comment.