Refs #39
File: crates/charon-flashloan/src/router.rs — sort logic
Problem
The router sorts providers by fee_rate_bps ascending. When two providers share the same fee, Rust's stable sort preserves insertion order, which is determined by registration order — not by operational preference. When two equal-fee providers are available, the one with greater available_liquidity is strictly better: more liquidity reduces the probability of the flash loan failing mid-execution.
At v0.1 with a single Aave adapter this is dormant. The router is designed for multi-provider use (BalancerV2 and UniswapV3 variants exist in FlashLoanSource) and this ordering bug is latent from day one.
Fix
providers.sort_by(|a, b| {
a.fee_rate_bps
.cmp(&b.fee_rate_bps)
.then_with(|| b.available_liquidity.cmp(&a.available_liquidity))
});
Refs #39
File: crates/charon-flashloan/src/router.rs — sort logic
Problem
The router sorts providers by fee_rate_bps ascending. When two providers share the same fee, Rust's stable sort preserves insertion order, which is determined by registration order — not by operational preference. When two equal-fee providers are available, the one with greater available_liquidity is strictly better: more liquidity reduces the probability of the flash loan failing mid-execution.
At v0.1 with a single Aave adapter this is dormant. The router is designed for multi-provider use (BalancerV2 and UniswapV3 variants exist in FlashLoanSource) and this ordering bug is latent from day one.
Fix