Skip to content

Commit

Permalink
feat: return poolPath too
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s committed Oct 16, 2023
1 parent d8051ee commit b7f37b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pool/_TEST_pool_router_test.gnoa
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestFindBestPoolTruePositive(t *testing.T) {
500, // amountSpecified
)
jsonStr := gjson.Parse(bestPoolPathDetail)
shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 5987)
shouldEQ(t, jsonStr.Get("response.data.pool_path").String(), "bar_foo_500")
}

func TestFindBestPoolTrueNegative(t *testing.T) {
Expand All @@ -109,7 +109,7 @@ func TestFindBestPoolTrueNegative(t *testing.T) {
-5000, // amountSpecified
)
jsonStr := gjson.Parse(bestPoolPathDetail)
shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 5987)
shouldEQ(t, jsonStr.Get("response.data.pool_path").String(), "bar_foo_500")
}

func TestFindBestPoolFalsePositive(t *testing.T) {
Expand All @@ -120,7 +120,7 @@ func TestFindBestPoolFalsePositive(t *testing.T) {
50, // amountSpecified
)
jsonStr := gjson.Parse(bestPoolPathDetail)
shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 79)
shouldEQ(t, jsonStr.Get("response.data.pool_path").String(), "bar_foo_3000")
}

func TestFindBestPoolFalseNegative(t *testing.T) {
Expand All @@ -131,7 +131,7 @@ func TestFindBestPoolFalseNegative(t *testing.T) {
-1234, // amountSpecified
)
jsonStr := gjson.Parse(bestPoolPathDetail)
shouldEQ(t, jsonStr.Get("response.data.token0_balance").Int(), 5987)
shouldEQ(t, jsonStr.Get("response.data.pool_path").String(), "bar_foo_500")
}

func TestFindBestPoolWrong(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pool/getter_api.gno
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type ApiPositionInfo struct {
}

type SinglePool struct {
PoolPath string `json:"pool_path"`
T0Balance bigint `json:"token0_balance"`
T1Balance bigint `json:"token1_balance"`
TickSpacing int32 `json:"tick_spacing"`
Expand Down Expand Up @@ -131,6 +132,7 @@ func ApiGetPool(key string) string {
Data SinglePool `json:"data"`
}{
Data: SinglePool{
PoolPath: key,
T0Balance: pool.balances.token0,
T1Balance: pool.balances.token1,
TickSpacing: pool.tickSpacing,
Expand Down

0 comments on commit b7f37b8

Please sign in to comment.