diff --git a/lib/math/concentrated-liq_test.go b/lib/math/concentrated-liq_test.go index 475ff42e..f5fc263e 100644 --- a/lib/math/concentrated-liq_test.go +++ b/lib/math/concentrated-liq_test.go @@ -87,7 +87,7 @@ func TestGetSqrtRatioAtTick(t *testing.T) { } func TestGetPriceAtSqrtRatio(t *testing.T) { - t.Fatal("unimplemented") + t.Skip("unimplemented") } var getAmountsForLiqTestTable = map[string]struct { @@ -121,16 +121,16 @@ var getAmountsForLiqTestTable = map[string]struct { GetSqrtRatioAtTick(new(big.Int).SetInt64(2100)), // Lower tick GetSqrtRatioAtTick(new(big.Int).SetInt64(4080)), // Upper tick 18117952900, // Liquidity (delta) - new(big.Rat).SetInt64(842893567), // Amount0 - new(big.Rat).SetInt64(842893567), // Amount1 + new(big.Rat).SetInt64(843131960), // Amount0 + new(big.Rat).SetInt64(894653736), // Amount1 }, "contract alex_0f08c379a without tick conversion in the go code": { mustIntFromStr("91911338314972375132734921679"), // Current tick mustIntFromStr("87999098777895760865233273050"), // Lower tick mustIntFromStr("97156358459122590463153608088"), // Upper tick 18117952900, // Liquidity (delta) - new(big.Rat).SetInt64(842893567), // Amount0 - new(big.Rat).SetInt64(842893567), // Amount1 + new(big.Rat).SetInt64(843131960), // Amount0 + new(big.Rat).SetInt64(894653736), // Amount1 }, } diff --git a/pkg/seawater/src/maths/sqrt_price_math.rs b/pkg/seawater/src/maths/sqrt_price_math.rs index 02764fca..f433b33f 100644 --- a/pkg/seawater/src/maths/sqrt_price_math.rs +++ b/pkg/seawater/src/maths/sqrt_price_math.rs @@ -603,6 +603,35 @@ mod test { ); } + // These differ from the Go tests by +1 as we use mul_div_rounding_up here + #[test] + fn test_get_amount_1_delta_go() { + use std::str::FromStr; + assert_eq!( + get_amount_1_delta( + U256::from_str("87999098777895760865233273050").unwrap(), + U256::from_str("91911338314972375132734921679").unwrap(), + 18117952900 + ) + .unwrap(), + I256::from_str("894653737").unwrap() + ); + } + + #[test] + fn test_get_amount_0_delta_go() { + use std::str::FromStr; + assert_eq!( + get_amount_0_delta( + U256::from_str("97156358459122590463153608088").unwrap(), + U256::from_str("91911338314972375132734921679").unwrap(), + 18117952900 + ) + .unwrap(), + I256::from_str("843131961").unwrap() + ); + } + #[test] fn test_get_amount_1_delta_weird() { use std::str::FromStr; diff --git a/pkg/seawater/tests/lib-end-to-end-proptest.rs b/pkg/seawater/tests/lib-end-to-end-proptest.rs index f8c664c8..63902b4d 100644 --- a/pkg/seawater/tests/lib-end-to-end-proptest.rs +++ b/pkg/seawater/tests/lib-end-to-end-proptest.rs @@ -133,7 +133,7 @@ proptest! { let pool = Address::from([1_u8; 20]); contract.ctor(msg::sender(), Address::ZERO, Address::ZERO).unwrap(); let fee = fee_of_spacing(spacing); - contract.create_pool_D650_E2_D0( + contract.create_pool_653_F_395_E( pool, U256::from_limbs([9433916063688681729, 246222, 0, 0]), //4542003653232976906676481 fee,