diff --git a/pool/_TEST_/z1_single_lp_filetest.gno b/pool/_TEST_/z1_single_lp_filetest.gno index 4abaeb10..5d7e0530 100644 --- a/pool/_TEST_/z1_single_lp_filetest.gno +++ b/pool/_TEST_/z1_single_lp_filetest.gno @@ -186,7 +186,6 @@ func init() { pl.RegisterGRC20Interface("gno.land/r/demo/obl", OBLToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/wugnot", WugnotToken{}) pl.RegisterGRC20Interface("gno.land/r/demo/gns", GNSToken{}) - } /* START TEST */ @@ -221,7 +220,6 @@ func createBarFooPool() { std.TestSkipHeights(1) } func mint() { - panic("TEST") std.TestSetPrevAddr(test1) bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) diff --git a/position/_TEST_/_TEST_position_increase_decrease_test.gn b/position/_TEST_/_TEST_position_increase_decrease_test.gn index b65302b6..f3ee37db 100644 --- a/position/_TEST_/_TEST_position_increase_decrease_test.gn +++ b/position/_TEST_/_TEST_position_increase_decrease_test.gn @@ -59,7 +59,7 @@ func TestIncreaseLiquidity(t *testing.T) { pool := getPoolFromLpTokenId(uint64(1)) oldLiquidity := pool.PoolGetLiquidity() - _, _, m0, m1 := IncreaseLiquidity( + _, _, m0, m1, _ := IncreaseLiquidity( uint64(1), // tokenId "10000000", // amount0Desired "10000000", // amount1Desired diff --git a/router/_TEST_/_TEST_router_ratio_test.gn b/router/_TEST_/_TEST_router_ratio_test.gn index 6c3005f1..337e4f2e 100644 --- a/router/_TEST_/_TEST_router_ratio_test.gn +++ b/router/_TEST_/_TEST_router_ratio_test.gn @@ -116,8 +116,8 @@ func TestApiGetRatiosFromBase(t *testing.T) { shouldEQ(t, token0.String(), "{\"token\":\"gno.land/r/demo/wugnot\",\"ratio\":\"79228162514264337593543950336\"}") shouldEQ(t, token1.String(), "{\"token\":\"gno.land/r/demo/bar\",\"ratio\":\"19935653721785907863909200771\"}") shouldEQ(t, token2.String(), "{\"token\":\"gno.land/r/demo/qux\",\"ratio\":\"79228162514264337593543950338\"}") - shouldEQ(t, token3.String(), "{\"token\":\"gno.land/r/demo/foo\",\"ratio\":\"21827358772679825007021358318119\"}") + shouldEQ(t, token3.String(), "{\"token\":\"gno.land/r/demo/foo\",\"ratio\":\"10796452559328726350\"}") shouldEQ(t, token4.String(), "{\"token\":\"gno.land/r/demo/baz\",\"ratio\":\"158459202898910110285447649633\"}") - shouldEQ(t, token5.String(), "{\"token\":\"gno.land/r/demo/obl\",\"ratio\":\"316918405797820220570895299266\"}") - shouldEQ(t, token6.String(), "{\"token\":\"gno.land/r/demo/gns\",\"ratio\":\"633836811595640441141790598532\"}") + shouldEQ(t, token5.String(), "{\"token\":\"gno.land/r/demo/obl\",\"ratio\":\"6102283613564175414\"}") + shouldEQ(t, token6.String(), "{\"token\":\"gno.land/r/demo/gns\",\"ratio\":\"12204788885446722546\"}") } diff --git a/router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gn b/router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gn index 9a4e8816..8c2ea393 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gn +++ b/router/_TEST_/_TEST_router_swap_route_1route_1hop_test.gn @@ -1,7 +1,6 @@ package router import ( - // @notJoon JSON "std" "testing" @@ -64,7 +63,7 @@ func TestSwapRouteBarBazExactIn(t *testing.T) { bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( barPath, // inputToken bazPath, // outputToken "1000", // amountSpecified @@ -73,7 +72,8 @@ func TestSwapRouteBarBazExactIn(t *testing.T) { "100", // quoteArr "2700", // tokenAmountLimit ) - shouldEQ(t, swapResult, "2707") + shouldEQ(t, amountIn, "1000") + shouldEQ(t, amountOut, "-2707") } func TestDrySwapRouteBarBazExactOut(t *testing.T) { @@ -97,7 +97,7 @@ func TestSwapRouteBarBazExactOut(t *testing.T) { bar.Approve(a2u(consts.POOL_ADDR), uint64(1000)) baz.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( barPath, // inputToken bazPath, // outputToken "1000", // amountSpecified @@ -107,7 +107,8 @@ func TestSwapRouteBarBazExactOut(t *testing.T) { "370", // tokenAmountLimit ) - shouldEQ(t, swapResult, "370") + shouldEQ(t, amountIn, "370") + shouldEQ(t, amountOut, "-999") } func TestDrySwapRouteBazBarExactIn(t *testing.T) { @@ -131,7 +132,7 @@ func TestSwapRouteBazBarExactIn(t *testing.T) { baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX) bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) // ITS FOR 0.15% fee - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( bazPath, // inputToken barPath, // outputToken "1000", // amountSpecified @@ -141,37 +142,39 @@ func TestSwapRouteBazBarExactIn(t *testing.T) { "360", // tokenAmountLimit ) - shouldEQ(t, swapResult, "368") + shouldEQ(t, amountIn, "1000") + shouldEQ(t, amountOut, "-368") } func TestDrySwapRouteBazBarExactOut(t *testing.T) { std.TestSetPrevAddr(test1) dryResult := DrySwapRoute( - bazPath, // inputToken - barPath, // outputToken - "3000", // amountSpecified - "EXACT_IN", // swapType + bazPath, // inputToken + barPath, // outputToken + "3000", // amountSpecified + "EXACT_OUT", // swapType "gno.land/r/demo/baz:gno.land/r/demo/bar:500", // strRouteArr "100", // quoteArr ) - shouldEQ(t, dryResult, "1104") + shouldEQ(t, dryResult, "8169") } func TestSwapRouteBazBarExactOut(t *testing.T) { std.TestSetPrevAddr(test1) bar.Approve(a2u(consts.ROUTER_ADDR), consts.UINT64_MAX) - swapResult := SwapRoute( - bazPath, // inputToken - barPath, // outputToken - "3000", // amountSpecified - "EXACT_IN", // swapType + amountIn, amountOut := SwapRoute( + bazPath, // inputToken + barPath, // outputToken + "3000", // amountSpecified + "EXACT_OUT", // swapType "gno.land/r/demo/baz:gno.land/r/demo/bar:500", // strRouteArr "100", // quoteArr - "1100", // tokenAmountLimit + "8200", // tokenAmountLimit ) - shouldEQ(t, swapResult, "1103") + shouldEQ(t, amountIn, "8169") + shouldEQ(t, amountOut, "-2996") } diff --git a/router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gn b/router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gn index 3cfc89f1..7c699fe5 100644 --- a/router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gn +++ b/router/_TEST_/_TEST_router_swap_route_1route_3hop_wrapped_native_middle_test.gn @@ -98,7 +98,7 @@ func TestSwapRouteGnsBarExactIn(t *testing.T) { gns.Approve(a2u(consts.POOL_ADDR), 1000) // swap input amount bar.Approve(a2u(consts.ROUTER_ADDR), 7328) // 0.15% fee - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( consts.GNS_PATH, // inputToken barPath, // outputToken "1000", // amountSpecified @@ -107,5 +107,6 @@ func TestSwapRouteGnsBarExactIn(t *testing.T) { "100", // quoteArr "0", // tokenAmountLimit ) - shouldEQ(t, swapResult, "7328") + shouldEQ(t, amountIn, "1000") + shouldEQ(t, amountOut, "-7328") } diff --git a/router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gn b/router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gn index 49299bed..b5a1c044 100644 --- a/router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gn +++ b/router/_TEST_/_TEST_router_swap_route_2route_2hop_test.gn @@ -65,7 +65,7 @@ func TestSwapRouteBarQuxExactIn(t *testing.T) { bar.Approve(a2u(consts.POOL_ADDR), 10000) qux.Approve(a2u(consts.ROUTER_ADDR), 10000) - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( barPath, // inputToken quxPath, // outputToken "1000", // amountSpecified @@ -75,7 +75,8 @@ func TestSwapRouteBarQuxExactIn(t *testing.T) { "1", // tokenAmountLimit ) - shouldEQ(t, swapResult, "7318") + shouldEQ(t, amountIn, "1000") + shouldEQ(t, amountOut, "-7318") } func TestDrySwapRouteBarQuxExactOut(t *testing.T) { @@ -96,7 +97,7 @@ func TestDrySwapRouteBarQuxExactOut(t *testing.T) { func TestSwapRouteBarQuxExactOut(t *testing.T) { std.TestSetPrevAddr(test1) - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( barPath, // inputToken quxPath, // outputToken "1000", // amountSpecified @@ -106,7 +107,8 @@ func TestSwapRouteBarQuxExactOut(t *testing.T) { "99999", // tokenAmountLimit ) - shouldEQ(t, swapResult, "138") + shouldEQ(t, amountIn, "138") + shouldEQ(t, amountOut, "-996") } func TestDrySwapRouteQuxBarExactIn(t *testing.T) { @@ -127,7 +129,7 @@ func TestDrySwapRouteQuxBarExactIn(t *testing.T) { func TestSwapRouteQuxBarExactIn(t *testing.T) { std.TestSetPrevAddr(test1) - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( quxPath, // inputToken barPath, // outputToken "1000", // amountSpecified @@ -137,7 +139,8 @@ func TestSwapRouteQuxBarExactIn(t *testing.T) { "1", // tokenAmountLimit ) - shouldEQ(t, swapResult, "135") + shouldEQ(t, amountIn, "1000") + shouldEQ(t, amountOut, "-135") } func TestDrySwapRouteQuxBarExactOut(t *testing.T) { @@ -161,7 +164,7 @@ func TestwapRouteQuxBarExactOut(t *testing.T) { qux.Approve(a2u(consts.POOL_ADDR), 10000) bar.Approve(a2u(consts.ROUTER_ADDR), 10000) - swapResult := SwapRoute( + amountIn, amountOut := SwapRoute( quxPath, // inputToken barPath, // outputToken "1000", // amountSpecified @@ -171,5 +174,6 @@ func TestwapRouteQuxBarExactOut(t *testing.T) { "99999", // tokenAmountLimit ) - shouldEQ(t, swapResult, "7350") + shouldEQ(t, amountIn, "7350") + shouldEQ(t, amountOut, "-997") }