Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use publisher latest slot for staleness based pricing #91

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading