Skip to content

Commit

Permalink
Merge pull request #114 from gnoswap-labs/GSW-631-fix-token-price
Browse files Browse the repository at this point in the history
GSW-631: fix token price(old value)
  • Loading branch information
r3v4s authored Dec 7, 2023
2 parents 2bc0fc6 + e43436e commit 9397b1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
32 changes: 13 additions & 19 deletions _test/_TEST_init_only_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,11 @@ func TestPoolCreatePool(t *testing.T) {

gsaOldGnsBalance := gns.BalanceOf(a2u(gsa))

/*

1 GNOT = 1_000_000 UGNOT = 2 BAR

*/

pl.CreatePool(gnotPath, barPath, uint16(100), 112046633483750523682330982) // tick = 131_230, ratio = x0.00000200003896770816773820374223635809585175593384
pl.CreatePool(barPath, bazPath, uint16(100), 112040957517951813098925484553) // tick = 6_931, ratio = x1.99983634019692790850797337043331936001777648925781
pl.CreatePool(bazPath, fooPath, uint16(100), 177157928842132501967358423881) // tick = 16_095, ratio = x4.99990809049723150536692628520540893077850341796875
pl.CreatePool(gnsPath, gnotPath, uint16(100), 79228214880679474632347256) // tick = -138_162, ratio = x0.00000100000132191460138283848127493946833510563010
pl.CreatePool(gnsPath, quxPath, uint16(100), 250541420775534450580036817218) // tick = 23_027, ratio = x9.99999779681069611569910193793475627899169921875000
pl.CreatePool(gnotPath, barPath, uint16(100), 112046633483750523682330982) // tick = 131_230, ratio = x0.00000200003896770816773820374223635809585175593384
pl.CreatePool(barPath, bazPath, uint16(100), 112040957517951813098925484553) // tick = 6_931, ratio = x1.99983634019692790850797337043331936001777648925781
pl.CreatePool(bazPath, fooPath, uint16(100), 177157928842132501967358423881) // tick = 16_095, ratio = x4.99990809049723150536692628520540893077850341796875
pl.CreatePool(gnsPath, gnotPath, uint16(100), 79228110147883812484826847210100) // tick = 138_162, ratio = x999998.67808714578859508037567138671875000000000000000000
pl.CreatePool(gnsPath, quxPath, uint16(100), 250541420775534450580036817218) // tick = 23_027, ratio = x9.99999779681069611569910193793475627899169921875000

gsaNewGnsBalance := gns.BalanceOf(a2u(gsa))

Expand Down Expand Up @@ -207,8 +201,8 @@ func TestPositionMintGnsGnot(t *testing.T) {
gnsPath, // token0
gnotPath, // token1
uint16(100), // fee
int32(-139162), // tickLower
int32(-137162), // tickUpper
int32(137162), // tickLower
int32(139162), // tickUpper
bigint(1000000000), // amount0Desired // gns
bigint(1000000000), // amount1Desired // 1000000000 ugnot ≈ 1000 GNOT
0, // amount0Min
Expand Down Expand Up @@ -252,12 +246,12 @@ func TestRouterApiGetRatiosFromBase(t *testing.T) {
jsonStr := gjson.Parse(rou.ApiGetRatiosFromBase())
jsonArr := jsonStr.Get("response.data").Array()

shouldEQ(t, jsonArr[0].String(), "{\"gnot\":79228162514264337593543950336}") // 1
shouldEQ(t, jsonArr[1].String(), "{\"gno.land/r/bar\":158443568011643016923643}") // 0.0000019998
shouldEQ(t, jsonArr[2].String(), "{\"gno.land/r/baz\":316861205180147164580763}") // 0.0000039994
shouldEQ(t, jsonArr[3].String(), "{\"gno.land/r/foo\":1584276903344921384146016}") // 0.0000199964
shouldEQ(t, jsonArr[4].String(), "{\"gno.land/r/gns\":79228057781537899283319724790391326}") // 999998.6780871458
shouldEQ(t, jsonArr[5].String(), "{\"gno.land/r/qux\":792280403260969530804650996818393284}") // 9999984.5776850672
shouldEQ(t, jsonArr[0].String(), "{\"gnot\":79228162514264337593543950336}") // 1
shouldEQ(t, jsonArr[1].String(), "{\"gno.land/r/bar\":158443568011643016923643}") // 0.0000019998 ≈ 1.9998
shouldEQ(t, jsonArr[2].String(), "{\"gno.land/r/baz\":316861205180147164580763}") // 0.0000039994 ≈ 3.9994
shouldEQ(t, jsonArr[3].String(), "{\"gno.land/r/foo\":1584276903344921384146016}") // 0.0000199964 ≈ 19.9964
shouldEQ(t, jsonArr[4].String(), "{\"gno.land/r/gns\":79228267247129223624113}") // 0.000001 ≈ 1
shouldEQ(t, jsonArr[5].String(), "{\"gno.land/r/qux\":792282497916421281862272}") // 0.00001 ≈ 10
}

/* UTILS */
Expand Down
6 changes: 3 additions & 3 deletions _test/init_only.mk
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pool-create:
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gnot" -args "gno.land/r/bar" -args 100 -args 112046633483750523682330982 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gsa > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gno.land/r/bar" -args "gno.land/r/baz" -args 100 -args 112040957517951813098925484553 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gsa > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gno.land/r/baz" -args "gno.land/r/foo" -args 100 -args 177157928842132501967358423881 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gsa > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gno.land/r/gns" -args "gnot" -args 100 -args 79228214880679474632347256 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gsa > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gno.land/r/gns" -args "gnot" -args 100 -args 79228110147883812484826847210100 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gsa > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gno.land/r/gns" -args "gno.land/r/qux" -args 100 -args 250541420775534450580036817218 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gsa > /dev/null
@echo

Expand All @@ -206,8 +206,8 @@ mint-03:
@echo

mint-04:
$(info ************ [POSITION - 4] mint gns & gnot // tick range -139162 ~ -137162 // by lp01 ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gno.land/r/gns" -args "gnot" -args 100 -args -139162 -args -137162 -args 1000000000 -args 1000000000 -args 0 -args 0 -args $(TX_EXPIRE) -send "1000000000ugnot" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" lp01 > /dev/null
$(info ************ [POSITION - 4] mint gns & gnot // tick range 137162 ~ 139162 // by lp01 ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gno.land/r/gns" -args "gnot" -args 100 -args 137162 -args 139162 -args 1000000000 -args 1000000000 -args 0 -args 0 -args $(TX_EXPIRE) -send "1000000000ugnot" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" lp01 > /dev/null
@echo

mint-05:
Expand Down

0 comments on commit 9397b1b

Please sign in to comment.