Skip to content

Restore liquidity-aware weighting for centralized exchange prices - #73

Closed
micahkendall wants to merge 1 commit into
mainfrom
codex/propose-fix-for-cex-price-weighting-vulnerability
Closed

Restore liquidity-aware weighting for centralized exchange prices#73
micahkendall wants to merge 1 commit into
mainfrom
codex/propose-fix-for-cex-price-weighting-vulnerability

Conversation

@micahkendall

Copy link
Copy Markdown
Member

Motivation

  • A recent change emitted reliability: Decimal::ONE for multiple CEX feeds, which removed liquidity/volume weighting used by the aggregator and allowed thin or compromised exchanges to skew the aggregated price.
  • The aggregator computes weighted averages using reliability, so feeds must report a liquidity-derived weight rather than a constant to preserve robustness.

Description

  • Restored volume-derived reliability for Binance by parsing v (volume_base) and setting PriceInfo.reliability to that value in src/sources/binance.rs.
  • Restored Bybit to use volume_24h (with a cached last-volume fallback) as reliability in src/sources/bybit.rs.
  • Restored Coinbase, Crypto.com, Kucoin, and Maestro to forward their reported volume fields as reliability in src/sources/coinbase.rs, src/sources/crypto_com.rs, src/sources/kucoin.rs, and src/sources/maestro.rs respectively.
  • Performed small cleanup (removed unnecessary imports) and formatted the code with cargo fmt.

Testing

  • Ran cargo fmt --all which completed successfully.
  • Ran cargo test --all --quiet and all automated tests passed (94 tests passed, 0 failed).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant