Skip to content

Commit

Permalink
GSW-1677 hotfix: need to exception logic to check xGNS (#350)
Browse files Browse the repository at this point in the history
* GSW-1677 hotfix: need to exception logic to check xGNS

- xGNS has different specification
- Need to exception log to check condition for launchpad

* test: add launchpad test script
  • Loading branch information
onlyhyde authored Oct 15, 2024
1 parent 63fe0b7 commit 3361e99
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
64 changes: 58 additions & 6 deletions __local/test/launchpad_test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ ADDR_LP02 := g1ta0w7j4f586kwqu584z5h5sjurzywz3na7qg0a

ADDR_TR01 := g14m6fj3t8005u77ku6zyzazq9vd9hwhl00ppt8j # use this as project's recipient for testing launchpad

# use this as project's recipient for testing launchpad
ADDR_QA01 := g1kcdd3n0d472g2p5l8svyg9t0wq6h5857nq992f
ADDR_QA02 := g1d598tyfatprdstalqutk62cnzpm3thvyy9mypg
ADDR_QA03 := g1w4qqmxdk59xsh3x5hnp2z78s4ymyva8pnenfem
ADDR_QA04 := g14supzhx0v5sza947sdh4x74wnws9xvcfwdecef
ADDR_QA05 := g1apl4u79zhexrxcf4h48y5qlyjncskdlrxtz6vg
ADDR_QA06 := g12g569s05c293zu2kxk0z426yylxmmthx8hcudd

ADDR_POOL := g126swhfaq2vyvvjywevhgw7lv9hg8qan93dasu8
ADDR_POSITION := g1vsm68lq9cpn7x507s6gh59anmx86kxfhzyszu2
ADDR_ROUTER := g1cnz5gm2l09pm2k6rknjjar9a2w53fdhk4yjzy5
Expand All @@ -31,11 +39,11 @@ TX_EXPIRE := 9999999999

MAKEFILE := $(shell realpath $(firstword $(MAKEFILE_LIST)))

GNOLAND_RPC_URL ?= http://localhost:26657
CHAINID ?= dev
#GNOLAND_RPC_URL ?= http://localhost:26657
#CHAINID ?= dev

# GNOLAND_RPC_URL ?= https://dev.rpc.gnoswap.io:443
# CHAINID ?= dev.gnoswap
GNOLAND_RPC_URL ?= https://dev.rpc.gnoswap.io:443
CHAINID ?= dev.gnoswap

ROOT_DIR:=$(shell dirname $(MAKEFILE))/../../

Expand Down Expand Up @@ -390,10 +398,54 @@ gov-reconfigure:
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/gov/governance -func Reconfigure -args 123 -args 456 -args 789 -args 1234 -args 5678 -args 9012 -args 3456 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin
@echo

## LAUNCHPAD QA
launchpad-qa:
## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/obl -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
$(info ************ create project // gnoswap_admin ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CreateProject -args "gno.land/r/onbloc/obl" -args $(ADDR_QA01) -args 1000000000000 -args "" -args "" -args 50 -args 30 -args 20 -args 1728975600 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/foo -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
$(info ************ create project // gnoswap_admin ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CreateProject -args "gno.land/r/onbloc/foo" -args $(ADDR_QA02) -args 2000000000000 -args "" -args "" -args 50 -args 25 -args 25 -args 1728975600 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/baz -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
$(info ************ create project // gnoswap_admin ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CreateProject -args "gno.land/r/onbloc/baz" -args $(ADDR_QA03) -args 2500000000000 -args "" -args "" -args 60 -args 25 -args 15 -args 1728975600 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/bar -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
$(info ************ create project // gnoswap_admin ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CreateProject -args "gno.land/r/onbloc/bar" -args $(ADDR_QA04) -args 1000000000000 -args "" -args "" -args 40 -args 40 -args 20 -args 1728975600 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/qux -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
$(info ************ create project // gnoswap_admin ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CreateProject -args "gno.land/r/onbloc/qux" -args $(ADDR_QA05) -args 2000000000000 -args "" -args "" -args 50 -args 30 -args 20 -args 1729040400 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/qux -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
$(info ************ create project // gnoswap_admin ************)
@echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CreateProject -args "gno.land/r/onbloc/qux" -args $(ADDR_QA06) -args 5000000000000 -args "gno.land/r/gnoswap/v2/gov/xgns*PAD*gno.land/r/onbloc/usdc" -args "100000000*PAD*200000000" -args 50 -args 30 -args 20 -args 1729047600 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin


## LAUNCHPAD
launchpad-create-project:
## APPROVE
## APPROVE
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/obl -func Approve -args $(ADDR_LAUNCHPAD) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin

## CREATE PROJECT
Expand Down Expand Up @@ -439,4 +491,4 @@ transfer-test1:
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/obl -func Transfer -args $(ADDR_TEST1) -args "1000000000" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/qux -func Transfer -args $(ADDR_TEST1) -args "1000000000" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin
@echo "" | gnokey maketx call -pkgpath gno.land/r/onbloc/usdc -func Transfer -args $(ADDR_TEST1) -args "1000000000" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin
@echo ""
@echo ""
7 changes: 6 additions & 1 deletion launchpad/launchpad_deposit.gno
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,12 @@ func checkDepositConditions(project Project) {
continue
} else {
// check balance
balance := balanceOfByRegisterCall(condition.tokenPath, std.PrevRealm().Addr())
var balance uint64
if condition.tokenPath == consts.GOV_XGNS_PATH {
balance = xgns.BalanceOf(a2u(std.PrevRealm().Addr()))
} else {
balance = balanceOfByRegisterCall(condition.tokenPath, std.PrevRealm().Addr())
}
if balance < condition.minAmount {
panic(ufmt.Sprintf("insufficient balance(%d) for token(%s)", balance, condition.tokenPath))
}
Expand Down
3 changes: 3 additions & 0 deletions launchpad/launchpad_init.gno
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func CreateProject(
if strings.Contains(conditionsToken, "*PAD*") {
tokensToCheck := strings.Split(conditionsToken, "*PAD*")
for _, token := range tokensToCheck {
if token == consts.GOV_XGNS_PATH {
continue
}
if _, exist := registered[token]; !exist {
panic(ufmt.Sprintf("condition token(%s) not registered", token))
}
Expand Down

0 comments on commit 3361e99

Please sign in to comment.