feat(core): implement core MEV bot functionality with market scanning and Uniswap V3 pricing
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -170,10 +170,10 @@ func TestPriceSymmetry(t *testing.T) {
|
||||
// TestEdgeCases tests edge cases and boundary conditions
|
||||
func TestEdgeCases(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
tick int
|
||||
shouldPass bool
|
||||
description string
|
||||
name string
|
||||
tick int
|
||||
shouldPass bool
|
||||
description string
|
||||
}{
|
||||
{"MinTick", -887272, true, "Minimum valid tick"},
|
||||
{"MaxTick", 887272, true, "Maximum valid tick"},
|
||||
@@ -196,7 +196,7 @@ func TestEdgeCases(t *testing.T) {
|
||||
// Test round-trip: tick -> sqrt -> tick
|
||||
convertedTick := uniswap.SqrtPriceX96ToTick(sqrtPriceX96)
|
||||
tickDiff := abs64(int64(tc.tick) - int64(convertedTick))
|
||||
assert.True(t, tickDiff <= 1, "Round-trip tick conversion failed for %s: original=%d, converted=%d",
|
||||
assert.True(t, tickDiff <= 1, "Round-trip tick conversion failed for %s: original=%d, converted=%d",
|
||||
tc.description, tc.tick, convertedTick)
|
||||
}
|
||||
})
|
||||
@@ -206,20 +206,20 @@ func TestEdgeCases(t *testing.T) {
|
||||
// TestPricePrecision verifies precision of price calculations
|
||||
func TestPricePrecision(t *testing.T) {
|
||||
knownCases := []struct {
|
||||
name string
|
||||
sqrtPriceX96 string
|
||||
name string
|
||||
sqrtPriceX96 string
|
||||
expectedPrice float64
|
||||
tolerance float64
|
||||
}{
|
||||
{
|
||||
name: "Price_1_ETH_USDC",
|
||||
sqrtPriceX96: "79228162514264337593543950336", // 2^96, price = 1
|
||||
name: "Price_1_ETH_USDC",
|
||||
sqrtPriceX96: "79228162514264337593543950336", // 2^96, price = 1
|
||||
expectedPrice: 1.0,
|
||||
tolerance: 0.0001,
|
||||
},
|
||||
{
|
||||
name: "Price_4_ETH_USDC",
|
||||
sqrtPriceX96: "158456325028528675187087900672", // 2 * 2^96, price = 4
|
||||
name: "Price_4_ETH_USDC",
|
||||
sqrtPriceX96: "158456325028528675187087900672", // 2 * 2^96, price = 4
|
||||
expectedPrice: 4.0,
|
||||
tolerance: 0.01,
|
||||
},
|
||||
@@ -254,4 +254,4 @@ func abs64(x int64) int64 {
|
||||
return -x
|
||||
}
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user