Skip to content

Commit

Permalink
Merge pull request #112 from gnoswap-labs/GSW-625-chore-change-chain-…
Browse files Browse the repository at this point in the history
…init-makefile-due-to-fix-of-pricing

GSW-625 chore: change chain init makefile
  • Loading branch information
notJoon authored Dec 7, 2023
2 parents 3bb00e0 + 07abef4 commit 04a0aeb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 46 deletions.
6 changes: 6 additions & 0 deletions _setup/gns/gns.gno
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func init() {
poolAddr = std.Address("g1ee305k8yk0pjz443xpwtqdyep522f9g5r7d63w")
pc01 = std.Address("g1wp3nqv2lta047h6lta047h6lta047h6ltup4ax") // Pool Creator 01

lp01 = std.Address("g1d3crqv2lta047h6lta047h6lta047h6lnjw069") // Liquidity Provider 01

stakerAddr = std.Address("g13h5s9utqcwg3a655njen0p89txusjpfrs3vxp8")
ira = std.Address("g1d9exzh6lta047h6lta047h6lta047h6l8ylkpa") // INTERNAL REWARD ACCOUNT
)
Expand All @@ -33,6 +35,10 @@ func init() {
gns.Mint(ira, 50000000000)
gns.Approve(ira, stakerAddr, 50000000000)

// PoolCreate & Mint
gns.Mint(lp01, 50000000000)
gns.Approve(lp01, poolAddr, 50000000000)

// default minter
gns.Mint(std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"), 1000000*10000)

Expand Down
84 changes: 45 additions & 39 deletions _test/_TEST_init_only_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,17 @@ func TestPoolCreatePool(t *testing.T) {

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

pl.CreatePool(gnotPath, barPath, uint16(100), 112040957517951813098925484553) // tick = 6_931, ratio = x1.99983634019692790850797337043331936001777648925781
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), 79228162514264337593543950337) // tick = 0, ratio = x1.00000000000000000000000000000000000000000000000000
pl.CreatePool(gnsPath, quxPath, uint16(100), 250541420775534450580036817218) // tick = 23_027, ratio = x9.99999779681069611569910193793475627899169921875000
/*

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

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

Expand All @@ -113,23 +119,23 @@ func TestPositionMintGnotBar(t *testing.T) {

// prepare ugnot
testBanker := std.GetBanker(std.BankerTypeRealmIssue)
testBanker.IssueCoin(std.GetOrigCaller(), "ugnot", 1000)
testBanker.IssueCoin(std.GetOrigCaller(), "ugnot", 1000000000)

// simulate transfer & decrase
std.TestSetOrigSend(std.Coins{{"ugnot", 1000}}, nil)
testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 1000)
std.TestSetOrigSend(std.Coins{{"ugnot", 1000000000}}, nil)
testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 1000000000)

tokenId, liquidity, amount0, amount1 := pos.Mint(
gnotPath, // token0 ( will be token1 )
barPath, // token1 ( will be token0 )
uint16(100), // fee
int32(5932), // tickLower
int32(7932), // tickUpper
bigint(1000), // amount0Desired
bigint(999999), // amount1Desired
0, // amount0Min
0, // amount1Min
MAX_TIMEOUT, // deadline
gnotPath, // token0 ( will be token1 )
barPath, // token1 ( will be token0 )
uint16(100), // fee
int32(-132230), // tickLower
int32(-130230), // tickUpper
bigint(1000000000), // amount0Desired
bigint(1000000000), // amount1Desired
0, // amount0Min
0, // amount1Min
MAX_TIMEOUT, // deadline
)
std.TestSetOrigSend(std.Coins{}, nil)
std.TestSkipHeights(1)
Expand Down Expand Up @@ -191,31 +197,31 @@ func TestPositionMintGnsGnot(t *testing.T) {

// prepare ugnot
testBanker := std.GetBanker(std.BankerTypeRealmIssue)
testBanker.IssueCoin(std.GetOrigCaller(), "ugnot", 1000)
testBanker.IssueCoin(std.GetOrigCaller(), "ugnot", 1000000000)

// simulate transfer & decrase
std.TestSetOrigSend(std.Coins{{"ugnot", 1000}}, nil)
testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 1000)
std.TestSetOrigSend(std.Coins{{"ugnot", 1000000000}}, nil)
testBanker.RemoveCoin(std.GetOrigCaller(), "ugnot", 1000000000)

tokenId, liquidity, amount0, amount1 := pos.Mint(
gnsPath, // token0
gnotPath, // token1
uint16(100), // fee
int32(-1000), // tickLower
int32(1000), // tickUpper
bigint(1000), // amount0Desired
bigint(1000), // amount1Desired
0, // amount0Min
0, // amount1Min
MAX_TIMEOUT, // deadline
gnsPath, // token0
gnotPath, // token1
uint16(100), // fee
int32(-139162), // tickLower
int32(-137162), // tickUpper
bigint(1000000000), // amount0Desired // gns
bigint(1000000000), // amount1Desired // 1000000000 ugnot ≈ 1000 GNOT
0, // amount0Min
0, // amount1Min
MAX_TIMEOUT, // deadline
)
std.TestSetOrigSend(std.Coins{}, nil)
std.TestSkipHeights(1)

shouldEQ(t, tokenId, 4)
println("liquidity\t", liquidity)
println("amount0(gns)\t", amount0)
println("amount1(gnot)\t", amount1)
println("amount0(gnot)\t", amount0)
println("amount1(gns)\t", amount1)
}

func TestPositionMintGnsQux(t *testing.T) {
Expand Down Expand Up @@ -246,12 +252,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\":158427515811472657639193234591}") // 1.9996363766
shouldEQ(t, jsonArr[2].String(), "{\"gno.land/r/baz\":316829103406906364771139440526}") // 3.998945493
shouldEQ(t, jsonArr[3].String(), "{\"gno.land/r/foo\":1584116397429175401616934621999}") // 19.994359924
shouldEQ(t, jsonArr[4].String(), "{\"gno.land/r/gns\":79228162514264337593543950334}") // 1
shouldEQ(t, jsonArr[5].String(), "{\"gno.land/r/qux\":792281450588003167884250659067}") // 9.9999977968
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
}

/* UTILS */
Expand Down
14 changes: 7 additions & 7 deletions _test/init_only.mk
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,18 @@ pool-init:

pool-create:
$(info ************ [POOL] create pools ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/pool -func CreatePool -args "gnot" -args "gno.land/r/bar" -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 "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 79228162514264337593543950337 -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 "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


# Position
mint-01:
$(info ************ [POSITION - 1] mint gnot & bar // tick range 5932 ~ 7932 // by lp01 ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gnot" -args "gno.land/r/bar" -args 100 -args 5932 -args 7932 -args 1000 -args 999999 -args 0 -args 0 -args $(TX_EXPIRE) -send "1000ugnot" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" lp01 > /dev/null
$(info ************ [POSITION - 1] mint gnot & bar // tick range -132230 ~ -130230 // by lp01 ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gnot" -args "gno.land/r/bar" -args 100 -args -132230 -args -130230 -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-02:
Expand All @@ -191,12 +191,12 @@ mint-02:

mint-03:
$(info ************ [POSITION - 3] mint baz & foo // tick range 15096 ~ 17096 // by lp01 ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gno.land/r/bar" -args "gno.land/r/baz" -args 100 -args 15096 -args 17096 -args 1000 -args 999999 -args 0 -args 0 -args $(TX_EXPIRE) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" lp01 > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gno.land/r/baz" -args "gno.land/r/foo" -args 100 -args 15096 -args 17096 -args 1000 -args 999999 -args 0 -args 0 -args $(TX_EXPIRE) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" lp01 > /dev/null
@echo

mint-04:
$(info ************ [POSITION - 4] mint gns & gnot // tick range -1000 ~ 1000 // by lp01 ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/position -func Mint -args "gnot" -args "gno.land/r/bar" -args 100 -args -1000 -args 1000 -args 1000 -args 1000 -args 0 -args 0 -args $(TX_EXPIRE) -send "1000ugnot" -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 -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
@echo

mint-05:
Expand Down

0 comments on commit 04a0aeb

Please sign in to comment.