Skip to content

[PR #27] LiquidationOpportunity missing Ord/PartialOrd — cannot be inserted into BinaryHeap #65

@obchain

Description

@obchain

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

LiquidationOpportunity will be inserted into profit-ordered BinaryHeap in PR #40. Type currently derives only Debug, Clone, Serialize, Deserialize. Without PartialOrd + Ord, std::collections::BinaryHeap<LiquidationOpportunity> will not compile.

Risk: Downstream crate fails to compile on priority-queue insertion. Blocks PR #40.

Fix: Implement Ord by net_profit descending. Manual impl preferred over derive (derive uses lexicographic field order, not profit semantics).

impl Ord for LiquidationOpportunity {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.net_profit_wei.cmp(&other.net_profit_wei)
    }
}
impl PartialOrd for LiquidationOpportunity {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

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