Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/amm/ffi/src/api/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,8 @@ mod tests {
.unwrap();
assert_eq!(ab["amountA"], "100000"); // floor(1_000_000 * 100_000 / 1_000_000)
assert_eq!(ab["amountB"], "200000"); // floor(2_000_000 * 100_000 / 1_000_000)
// minimum = floor(withdraw * (10000 - 50) / 10000) — the slippage floor per side.
// minimum = floor(withdraw * (10000 - 50) / 10000) —
// the slippage floor per side.
assert_eq!(ab["minimumAmountA"], "99500");
assert_eq!(ab["minimumAmountB"], "199000");
assert_eq!(
Expand Down
3 changes: 2 additions & 1 deletion programs/amm/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,8 @@ mod tests {
// 1e20 * 2e20 = 2e40 overflows u128 (max ~3.4e38); the U256 intermediate keeps it exact.
let a = 100_000_000_000_000_000_000u128; // 1e20
let b = 200_000_000_000_000_000_000u128; // 2e20
// floor(sqrt(2e40)) computed independently in U256.
// floor(sqrt(2e40)) computed independently in
// U256.
let expected = {
use alloy_primitives::U256;
let product = U256::from(a).checked_mul(U256::from(b)).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion programs/amm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3687,7 +3687,8 @@ fn add_liquidity_overflow_protection() {
fn remove_liquidity_overflow_protection() {
let large_reserve: u128 = u128::MAX / 2 + 1; // 2^127
let reserve_b: u128 = 1_000;
let lp_supply: u128 = 1_002; // must exceed MINIMUM_LIQUIDITY so remove_amount=2 passes the lock check
let lp_supply: u128 = 1_002; // must exceed MINIMUM_LIQUIDITY so remove_amount=2 passes the lock
// check

let pool = AccountWithMetadata {
account: Account {
Expand Down
Loading