Skip to content

Commit f08a52a

Browse files
authored
fix: remove unnecessary fresh price filtering (#103)
This change removes a check in the code that does not allow multiple updates within the same timestamp to passthrough. `last_info.timestamp` is always less than or equal to `info.timestamp`. So, this condition `last_info.timestamp < info.timestamp` filters newer updates in the same timestamp and essentially caps our publishing frequency to 1s. It was intended to work for Solana but the publishing frequency itself takes care of it. This change might result in increased Sol burn but the actions to reduce it should be reducing the frequency. Please note that in some filterings after, the same update prices are ignored so most of the fee savings should remain there.
1 parent 04391be commit f08a52a

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
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.4.4"
3+
version = "2.4.5"
44
edition = "2021"
55

66
[[bin]]

src/agent/solana/exporter.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,6 @@ impl Exporter {
436436
// and to ignore stale information.
437437
let fresh_updates = local_store_contents
438438
.into_iter()
439-
.filter(|(identifier, info)| {
440-
// Filter out timestamps older than what we already published
441-
if let Some(last_info) = self.last_published_state.get(identifier) {
442-
last_info.timestamp < info.timestamp
443-
} else {
444-
true // No prior data found, letting the price through
445-
}
446-
})
447439
.filter(|(_identifier, info)| {
448440
// Filter out timestamps that are old
449441
(now - info.timestamp) < self.config.staleness_threshold.as_secs() as i64
@@ -452,7 +444,7 @@ impl Exporter {
452444
// Filter out unchanged price data if the max delay wasn't reached
453445

454446
if let Some(last_info) = self.last_published_state.get(identifier) {
455-
if (info.timestamp - last_info.timestamp)
447+
if info.timestamp.saturating_sub(last_info.timestamp)
456448
> self.config.unchanged_publish_threshold.as_secs() as i64
457449
{
458450
true // max delay since last published state reached, we publish anyway

0 commit comments

Comments
 (0)