fix(calc): return 0 for zero sell amount in slippage helper
calculate_with_slippage_sell previously fell through to the branch that returned 1 when amount <= basis_points/10_000, which is true for amount=0 and typical bps values—yielding a bogus minimum of 1. Short-circuit on zero input so sell quotes stay correct. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -72,6 +72,9 @@ pub const fn calculate_with_slippage_buy(amount: u64, basis_points: u64) -> u64
|
||||
/// * basis_points = 500 -> 5% slippage
|
||||
#[inline(always)]
|
||||
pub const fn calculate_with_slippage_sell(amount: u64, basis_points: u64) -> u64 {
|
||||
if amount == 0 {
|
||||
return 0;
|
||||
}
|
||||
if amount <= basis_points / 10000 {
|
||||
1
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user