Skip to content

[PR #27] net_profit_usd_cents: u64 is lossy USD denomination — use U256 token-native #66

@obchain

Description

@obchain

PR: #27 (commit 4a9a6d3)
File: crates/charon-core/src/types.rs, line 74

net_profit_usd_cents: u64 introduces two problems:

  1. USD conversion requires oracle price at type layer, before business logic runs. Authoritative profit representation is in debt token base unit (e.g., USDT wei). Storing USD cents discards sub-cent precision that matters when profit window is narrow and gas is tight.
  2. Profit ranking in priority queue will be wrong for positions whose token-native profit rounds to same cent bucket but differ in actual value.

Risk: Bot deprioritizes a more profitable liquidation because its USD-cent representation ties with a less profitable one.

Fix: Replace net_profit_usd_cents: u64 with net_profit_wei: U256 denominated in debt token base unit. USD display conversion belongs in metrics/reporting layer only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scope

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions