diff --git a/pool/_TEST_pool_router_test.gnoa b/pool/_TEST_pool_router_test.gnoa index d2f561ab6..170fec332 100644 --- a/pool/_TEST_pool_router_test.gnoa +++ b/pool/_TEST_pool_router_test.gnoa @@ -1,6 +1,7 @@ package pool import ( + "encoding/gjson" "std" "testing" @@ -90,43 +91,47 @@ func TestPositionMint3000(t *testing.T) { } func TestFindBestPoolTruePositive(t *testing.T) { - bestPath := FindBestPool( + bestPoolPathDetail := FindBestPool( "foo", // tokenA "bar", // tokenB true, // zeroForOne 500, // amountSpecified ) - shouldEQ(t, bestPath, "bar_foo_500") + jsonStr := gjson.Parse(bestPoolPathDetail) + shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 5987) } func TestFindBestPoolTrueNegative(t *testing.T) { - bestPath := FindBestPool( + bestPoolPathDetail := FindBestPool( "foo", // tokenA "bar", // tokenB true, // zeroForOne -5000, // amountSpecified ) - shouldEQ(t, bestPath, "bar_foo_500") + jsonStr := gjson.Parse(bestPoolPathDetail) + shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 5987) } func TestFindBestPoolFalsePositive(t *testing.T) { - bestPath := FindBestPool( + bestPoolPathDetail := FindBestPool( "foo", // tokenA "bar", // tokenB false, // zeroForOne 50, // amountSpecified ) - shouldEQ(t, bestPath, "bar_foo_3000") + jsonStr := gjson.Parse(bestPoolPathDetail) + shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 79) } func TestFindBestPoolFalseNegative(t *testing.T) { - bestPath := FindBestPool( + bestPoolPathDetail := FindBestPool( "foo", // tokenA "bar", // tokenB false, // zeroForOne -1234, // amountSpecified ) - shouldEQ(t, bestPath, "bar_foo_500") + jsonStr := gjson.Parse(bestPoolPathDetail) + shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 5987) } func TestFindBestPoolWrong(t *testing.T) { diff --git a/pool/pool_router.gno b/pool/pool_router.gno index 80f3d3ef4..f0a25298a 100644 --- a/pool/pool_router.gno +++ b/pool/pool_router.gno @@ -101,10 +101,10 @@ func FindBestPool( } if zeroForOne == true { // if token0 is being sold to buy token1, then we want to find the pool with the largest tick (more token1 can be bought) - return poolWithTick[maxTick] + return ApiGetPool(poolWithTick[maxTick]) } else { // if token1 is being sold to buy token0, then we want to find the pool with the smallest tick (more token0 can be bought) - return poolWithTick[minTick] + return ApiGetPool(poolWithTick[minTick]) } }