diff --git a/__local/test/launchpad_test.mk b/__local/test/launchpad_test.mk index fdf1c1e4..30e21701 100644 --- a/__local/test/launchpad_test.mk +++ b/__local/test/launchpad_test.mk @@ -108,6 +108,8 @@ send-ugnot-must: @echo "" | gnokey maketx send -send 10000000000ugnot -to $(ADDR_TR01) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" test1 @echo +dummy-tx: + @echo "" | gnokey maketx send -send 1ugnot -to $(ADDR_GSA) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" test1 # deploy test grc20 tokens deploy-foo: @@ -404,7 +406,7 @@ launchpad-deposit: ## DEPOSIT TO PROJECT ( tier 30 ) $(info ************ deposit to project // gnoswap_admin ************) - @echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func DepositGns -args "gno.land/r/onbloc/obl:69:30" -args 1000000 -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/gnoswap/v2/launchpad -func DepositGns -args "gno.land/r/onbloc/obl:62:30" -args 1000000 -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin launchpad-collect-protocol: $(info ************ collect protocol fee by projects recipients // tr01 ************) @@ -412,7 +414,7 @@ launchpad-collect-protocol: launchpad-collect-reward: $(info ************ collect reward bt project id // gnoswap_admin ************) - @echo "" | gnokey maketx call -pkgpath gno.land/r/gnoswap/v2/launchpad -func CollectRewardByProjectId -args "gno.land/r/onbloc/obl:69" -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/gnoswap/v2/launchpad -func CollectRewardByProjectId -args "gno.land/r/onbloc/obl:62" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 100000000 -memo "" gnoswap_admin ## TRANSFER FOR QA ADDR_ROH := g16a7etgm9z2r653ucl36rj0l2yqcxgrz2jyegzx diff --git a/launchpad/_RPC_api_project.gno b/launchpad/_RPC_api_project.gno index ad163141..d3364f61 100644 --- a/launchpad/_RPC_api_project.gno +++ b/launchpad/_RPC_api_project.gno @@ -8,6 +8,46 @@ import ( "gno.land/p/demo/ufmt" ) +func ApiGetProjectAndTierStatisticsByProjectId(projectId string) string { + project, exist := projects[projectId] + if !exist { + return "" + } + + totalDepositAmount := project.totalDepositAmount + actualDepositAmount := project.actualDepositAmount + + totalParticipant := project.totalParticipant + actualParticipant := project.actualParticipant + + totalCollectedAmount := project.totalCollectedAmount + + projectObj := metaNode() + projectObj.AppendObject("projectId", json.StringNode("projectId", projectId)) + projectObj.AppendObject("totalDepositAmount", json.StringNode("totalDepositAmount", ufmt.Sprintf("%d", totalDepositAmount))) + projectObj.AppendObject("actualDepositAmount", json.StringNode("actualDepositAmount", ufmt.Sprintf("%d", actualDepositAmount))) + projectObj.AppendObject("totalParticipant", json.StringNode("totalParticipant", ufmt.Sprintf("%d", totalParticipant))) + projectObj.AppendObject("actualParticipant", json.StringNode("actualParticipant", ufmt.Sprintf("%d", actualParticipant))) + projectObj.AppendObject("totalCollectedAmount", json.StringNode("totalCollectedAmount", ufmt.Sprintf("%d", totalCollectedAmount))) + + projectObj.AppendObject("tier30TotalDepositAmount", json.StringNode("tier30TotalDepositAmount", ufmt.Sprintf("%d", project.tier30.totalDepositAmount))) + projectObj.AppendObject("tier30ActualDepositAmount", json.StringNode("tier30ActualDepositAmount", ufmt.Sprintf("%d", project.tier30.actualDepositAmount))) + projectObj.AppendObject("tier30TotalParticipant", json.StringNode("tier30TotalParticipant", ufmt.Sprintf("%d", project.tier30.totalParticipant))) + projectObj.AppendObject("tier30ActualParticipant", json.StringNode("tier30ActualParticipant", ufmt.Sprintf("%d", project.tier30.actualParticipant))) + + projectObj.AppendObject("tier90TotalDepositAmount", json.StringNode("tier90TotalDepositAmount", ufmt.Sprintf("%d", project.tier90.totalDepositAmount))) + projectObj.AppendObject("tier90ActualDepositAmount", json.StringNode("tier90ActualDepositAmount", ufmt.Sprintf("%d", project.tier90.actualDepositAmount))) + projectObj.AppendObject("tier90TotalParticipant", json.StringNode("tier90TotalParticipant", ufmt.Sprintf("%d", project.tier90.totalParticipant))) + projectObj.AppendObject("tier90ActualParticipant", json.StringNode("tier90ActualParticipant", ufmt.Sprintf("%d", project.tier90.actualParticipant))) + + projectObj.AppendObject("tier180TotalDepositAmount", json.StringNode("tier180TotalDepositAmount", ufmt.Sprintf("%d", project.tier180.totalDepositAmount))) + projectObj.AppendObject("tier180ActualDepositAmount", json.StringNode("tier180ActualDepositAmount", ufmt.Sprintf("%d", project.tier180.actualDepositAmount))) + projectObj.AppendObject("tier180TotalParticipant", json.StringNode("tier180TotalParticipant", ufmt.Sprintf("%d", project.tier180.totalParticipant))) + projectObj.AppendObject("tier180ActualParticipant", json.StringNode("tier180ActualParticipant", ufmt.Sprintf("%d", project.tier180.actualParticipant))) + + return marshal(projectObj) +} + func ApiGetProjectStatisticsByProjectId(projectId string) string { project, exist := projects[projectId] if !exist { @@ -23,6 +63,7 @@ func ApiGetProjectStatisticsByProjectId(projectId string) string { totalCollectedAmount := project.totalCollectedAmount projectObj := metaNode() + projectObj.AppendObject("projectId", json.StringNode("projectId", projectId)) projectObj.AppendObject("totalDepositAmount", json.StringNode("totalDepositAmount", ufmt.Sprintf("%d", totalDepositAmount))) projectObj.AppendObject("actualDepositAmount", json.StringNode("actualDepositAmount", ufmt.Sprintf("%d", actualDepositAmount))) projectObj.AppendObject("totalParticipant", json.StringNode("totalParticipant", ufmt.Sprintf("%d", totalParticipant))) @@ -32,6 +73,47 @@ func ApiGetProjectStatisticsByProjectId(projectId string) string { return marshal(projectObj) } +func ApiGetProjectStatisticsByProjectTierId(tierId string) string { + projectId, tierStr := getProjectIdAndTierFromTierId(tierId) + project, exist := projects[projectId] + if !exist { + println("NO PROJECT FOR THIS ID", projectId) + return "" + } + + var tier Tier + switch tierStr { + case "30": + tier = project.tier30 + case "90": + tier = project.tier90 + case "180": + tier = project.tier180 + default: + println("NO TIER FOR THIS ID", tierId) + return "" + } + + tierAmount := tier.tierAmount // project token allocation + + tierTotalDepositAmount := tier.totalDepositAmount + tierActualDepositAmount := tier.actualDepositAmount + + tierTotalParticipant := tier.totalParticipant + tierActualParticipant := tier.actualParticipant + + projectTierObj := metaNode() + projectTierObj.AppendObject("projectId", json.StringNode("projectId", projectId)) + projectTierObj.AppendObject("tierId", json.StringNode("tierId", tierId)) + projectTierObj.AppendObject("tierAmount", json.StringNode("tierAmount", ufmt.Sprintf("%d", tierAmount))) + projectTierObj.AppendObject("tierTotalDepositAmount", json.StringNode("tierTotalDepositAmount", ufmt.Sprintf("%d", tierTotalDepositAmount))) + projectTierObj.AppendObject("tierActualDepositAmount", json.StringNode("tierActualDepositAmount", ufmt.Sprintf("%d", tierActualDepositAmount))) + projectTierObj.AppendObject("tierTotalParticipant", json.StringNode("tierTotalParticipant", ufmt.Sprintf("%d", tierTotalParticipant))) + projectTierObj.AppendObject("tierActualParticipant", json.StringNode("tierActualParticipant", ufmt.Sprintf("%d", tierActualParticipant))) + + return marshal(projectTierObj) +} + func metaNode() *json.Node { height := std.GetHeight() now := time.Now().Unix() diff --git a/launchpad/launchpad_deposit.gno b/launchpad/launchpad_deposit.gno index bd162a21..f3fb7775 100644 --- a/launchpad/launchpad_deposit.gno +++ b/launchpad/launchpad_deposit.gno @@ -77,8 +77,10 @@ func DepositGns( gs.SetAmountByProjectWallet(project.recipient, amount, true) // true == add // update tier - tier.depositAmount += amount - tier.participant += 1 + tier.totalDepositAmount += amount + tier.actualDepositAmount += amount + tier.totalParticipant += 1 + tier.actualParticipant += 1 project = setTier(project, tierStr, tier) // update project @@ -179,8 +181,8 @@ func CollectDepositGns() uint64 { gs.SetAmountByProjectWallet(project.recipient, deposit.amount, false) // subtract // update tier - tier.depositAmount -= deposit.amount - tier.participant -= 1 + tier.actualDepositAmount -= deposit.amount + tier.actualParticipant -= 1 // update project project = setTier(project, deposit.tier, tier) @@ -213,7 +215,7 @@ func CollectDepositGns() uint64 { // // returns collected gns amount func CollectDepositGnsByProjectId(projectId string) uint64 { - project, exist := projects[projectId] + _, exist := projects[projectId] if !exist { println("NO PROJECT FOR THIS ID", projectId) return 0 @@ -264,8 +266,8 @@ func CollectDepositGnsByProjectId(projectId string) uint64 { gs.SetAmountByProjectWallet(project.recipient, deposit.amount, false) // subtract // update tier - tier.depositAmount -= deposit.amount - tier.participant -= 1 + tier.actualDepositAmount -= deposit.amount + tier.actualParticipant -= 1 // update project project = setTier(project, deposit.tier, tier) @@ -338,8 +340,8 @@ func CollectDepositGnsByDepositId(depositId string) uint64 { gs.SetAmountByProjectWallet(project.recipient, deposit.amount, false) // subtract // update tier - tier.depositAmount -= deposit.amount - tier.participant -= 1 + tier.actualDepositAmount -= deposit.amount + tier.actualParticipant -= 1 // update project project = setTier(project, deposit.tier, tier) @@ -351,7 +353,7 @@ func CollectDepositGnsByDepositId(depositId string) uint64 { std.Emit( "CollectDepositGns", "m_prevRealm", prevRealm(), - "depositId", depositId, + "p_depositId", depositId, "amount", ufmt.Sprintf("%d", deposit.amount), ) diff --git a/launchpad/launchpad_init.gno b/launchpad/launchpad_init.gno index 878b44b1..c0311747 100644 --- a/launchpad/launchpad_init.gno +++ b/launchpad/launchpad_init.gno @@ -186,8 +186,8 @@ func CreateProject( "p_tier30Ratio", ufmt.Sprintf("%d", tier30Ratio), "p_tier90Ratio", ufmt.Sprintf("%d", tier90Ratio), "p_tier180Ratio", ufmt.Sprintf("%d", tier180Ratio), - "p_startHeight", ufmt.Sprintf("%d", startHeight), "p_startTime", ufmt.Sprintf("%d", startTime), + "startHeight", ufmt.Sprintf("%d", startHeight), "projectId", projectId, "tier30Amount", ufmt.Sprintf("%d", tier30Amount), diff --git a/launchpad/launchpad_reward.gno b/launchpad/launchpad_reward.gno index 210d90ab..edc692e1 100644 --- a/launchpad/launchpad_reward.gno +++ b/launchpad/launchpad_reward.gno @@ -17,7 +17,7 @@ func CollectProtocolFee() { caller := std.PrevRealm().Addr() gs.CollectRewardFromLaunchPad(caller) - // XXX: emit event + // event will be emitted in gov/staker CollectRewardFromLaunchPad() } var ( @@ -28,82 +28,6 @@ func init() { lastCalculatedHeight = uint64(std.GetHeight()) } -// CollectReward collects reward from entire deposit by caller -func CollectReward() { - calculateDepositReward() - - caller := std.PrevRealm().Addr() - depositIds, exist := depositsByUser[caller] - if !exist { - println("NO DEPOSIT FOR THIS USER", caller) - return - } - - // project token -> reward amount - toUser := make(map[string]uint64) - - for _, depositId := range depositIds { - deposit := deposits[depositId] - if deposit.rewardAmount == 0 { - println("NO REWARD FOR THIS DEPOSIT", depositId) - continue - } - - project := projects[deposit.projectId] - projectToken := project.tokenPath - - if deposit.rewardAmount > 0 { // deposit has some reward - if deposit.rewardCollectTime != 0 { // this collect is not first collect - println("(N)th collect") - toUser[projectToken] += deposit.rewardAmount - } else { - // if fisrt collect, then check tier's collect wait duration - collectableAfter := uint64(0) - switch deposit.tier { - case "30": - collectableAfter = project.startHeight + project.tier30.collectWaitDuration - case "90": - collectableAfter = project.startHeight + project.tier90.collectWaitDuration - case "180": - collectableAfter = project.startHeight + project.tier180.collectWaitDuration - } - - if uint64(std.GetHeight()) < collectableAfter { - println("NOT CLAIMABLE YET") - continue - } - - println("token:", projectToken, "reward:", deposit.rewardAmount) - toUser[projectToken] += deposit.rewardAmount - } - - std.Emit( - "CollectReward", - "m_prevRealm", prevRealm(), - "depositId", depositId, - "amount", ufmt.Sprintf("%d", deposit.rewardAmount), - ) - } - - // update project - project.totalCollectedAmount += deposit.rewardAmount - projects[deposit.projectId] = project - - // update deposit - deposit.rewardAmount = 0 - deposit.rewardCollectHeight = uint64(std.GetHeight()) - deposit.rewardCollectTime = uint64(time.Now().Unix()) - deposits[depositId] = deposit - } - - // transfer reward to user - for tokenPath, amount := range toUser { - // println("tokenPath:", tokenPath) - // println("amount:", amount) - transferByRegisterCall(tokenPath, std.PrevRealm().Addr(), amount) - } -} - // CollectRewardByProjectId collects reward from entire deposit of certain project by caller // // returns collected reward amount @@ -157,7 +81,7 @@ func CollectRewardByProjectId(projectId string) uint64 { } if uint64(std.GetHeight()) < collectableAfter { - println("NOT CLAIMABLE YET") + println("NOT CLAIMABLE YET", std.GetHeight(), "<", collectableAfter) continue } @@ -185,107 +109,9 @@ func CollectRewardByProjectId(projectId string) uint64 { deposits[depositId] = deposit } - // transfer reward to user - - transferByRegisterCall(project.tokenPath, std.PrevRealm().Addr(), toUser) - - // XXX: emit event - - return toUser -} - -// CollectRewardByProjectTier collects reward from entire deposit of certain project tier by caller -// -// returns collected reward amount -func CollectRewardByProjectTier(tierId string) uint64 { - projectId, tierStr := getProjectIdAndTierFromTierId(tierId) - project, exist := projects[projectId] - if !exist { - println("NO PROJECT FOR THIS ID", projectId) - return 0 - } - - caller := std.PrevRealm().Addr() - if _, exist := depositsByUserByProject[caller]; !exist { - println("NO DEPOSIT FOR THIS USER", caller) - return 0 - } - depositIds, exist := depositsByUserByProject[caller][projectId] - if !exist { - println("NO DEPOSIT FOR THIS PROJECT", projectId) - return 0 - } - - calculateDepositReward() - - toUser := uint64(0) - for _, depositId := range depositIds { - println("depositId:", depositId) - deposit := deposits[depositId] - - // matching tier - if deposit.projectId == projectId && deposit.tier == tierStr { - if deposit.rewardAmount == 0 { - println("NO REWARD FOR THIS DEPOSIT", depositId) - continue - } - - project := projects[deposit.projectId] - if project.id != projectId { - println("PROJECT ID MISMATCH", project.id, projectId) - continue - } - - if deposit.rewardAmount > 0 { - if deposit.rewardCollectTime != 0 { - println("(N)th collect") - toUser += deposit.rewardAmount - } else { - collectableAfter := uint64(0) - switch deposit.tier { - case "30": - collectableAfter = project.startHeight + project.tier30.collectWaitDuration - case "90": - collectableAfter = project.startHeight + project.tier90.collectWaitDuration - case "180": - collectableAfter = project.startHeight + project.tier180.collectWaitDuration - } - - if uint64(std.GetHeight()) < collectableAfter { - println("NOT CLAIMABLE YET") - continue - } - - println("token:", project.tokenPath, "reward:", deposit.rewardAmount) - toUser += deposit.rewardAmount - } - } - - std.Emit( - "CollectRewardByProjectTier", - "m_prevRealm", prevRealm(), - "p_tierId", tierId, - "depositId", depositId, - "amount", ufmt.Sprintf("%d", deposit.rewardAmount), - ) - } - - // update project - project.totalCollectedAmount += deposit.rewardAmount - projects[deposit.projectId] = project - - // update deposit - deposit.rewardAmount = 0 - deposit.rewardCollectHeight = uint64(std.GetHeight()) - deposit.rewardCollectTime = uint64(time.Now().Unix()) - deposits[depositId] = deposit - } - // transfer reward to user transferByRegisterCall(project.tokenPath, std.PrevRealm().Addr(), toUser) - // XXX: emit event - return toUser } @@ -293,7 +119,6 @@ func CollectRewardByProjectTier(tierId string) uint64 { // // returns collected reward amount func CollectRewardByDepositId(depositId string) uint64 { - println("CollectRewardByDepositId", depositId) deposit, exist := deposits[depositId] if !exist { panic("deposit not found") @@ -332,7 +157,7 @@ func CollectRewardByDepositId(depositId string) uint64 { } if uint64(std.GetHeight()) < collectableAfter { - println("NOT CLAIMABLE YET") + println("NOT CLAIMABLE YET", std.GetHeight(), "<", collectableAfter) return 0 } @@ -433,9 +258,9 @@ func calculateDepositReward() { // calculate deposit ratio // loop with each tier (30 90 180) - tier30Deposit := project.tier30.depositAmount - tier90Deposit := project.tier90.depositAmount - tier180Deposit := project.tier180.depositAmount + tier30Deposit := project.tier30.actualDepositAmount + tier90Deposit := project.tier90.actualDepositAmount + tier180Deposit := project.tier180.actualDepositAmount // println("tier30.id", project.tier30.id) // println("tier30Deposit", tier30Deposit) // println("tier90Deposit", tier90Deposit) diff --git a/launchpad/tests/__TEST_RPC_api_test.gnoA b/launchpad/tests/__TEST_RPC_api_test.gnoA index 9a2be941..c726dda2 100644 --- a/launchpad/tests/__TEST_RPC_api_test.gnoA +++ b/launchpad/tests/__TEST_RPC_api_test.gnoA @@ -199,3 +199,39 @@ func TestApiGetClaimableDepositByAddress(t *testing.T) { shouldEQ(t, claimed, uint64(0)) }) } + +func TestApiGetProjectAndTierStatisticsByProjectId(t *testing.T) { + t.Run("not existing project", func(t *testing.T) { + got := ApiGetProjectAndTierStatisticsByProjectId("gno.land/r") + shouldEQ(t, got, ``) + }) + + t.Run("existing project", func(t *testing.T) { + got := ApiGetProjectAndTierStatisticsByProjectId("gno.land/r/onbloc/obl:124") + shouldEQ(t, got, `{"height":"1296142","now":"1237159928","projectId":"gno.land/r/onbloc/obl:124","totalDepositAmount":"1000000","actualDepositAmount":"0","totalParticipant":"1","actualParticipant":"0","totalCollectedAmount":"0","tier30TotalDepositAmount":"1000000","tier30ActualDepositAmount":"0","tier30TotalParticipant":"1","tier30ActualParticipant":"0","tier90TotalDepositAmount":"0","tier90ActualDepositAmount":"0","tier90TotalParticipant":"0","tier90ActualParticipant":"0","tier180TotalDepositAmount":"0","tier180ActualDepositAmount":"0","tier180TotalParticipant":"0","tier180ActualParticipant":"0"}`) + }) +} + +func TestApiGetProjectStatisticsByProjectId(t *testing.T) { + t.Run("not existing project", func(t *testing.T) { + got := ApiGetProjectStatisticsByProjectId("gno.land/r") + shouldEQ(t, got, ``) + }) + + t.Run("existing project", func(t *testing.T) { + got := ApiGetProjectStatisticsByProjectId("gno.land/r/onbloc/obl:124") + shouldEQ(t, got, `{"height":"1296142","now":"1237159928","projectId":"gno.land/r/onbloc/obl:124","totalDepositAmount":"1000000","actualDepositAmount":"0","totalParticipant":"1","actualParticipant":"0","totalCollectedAmount":"0"}`) + }) +} + +func TestApiGetProjectStatisticsByProjectTierId(t *testing.T) { + t.Run("not existing tier", func(t *testing.T) { + got := ApiGetProjectStatisticsByProjectTierId("gno.land/r/onbloc/obl:124:31") + shouldEQ(t, got, ``) + }) + + t.Run("existing tier", func(t *testing.T) { + got := ApiGetProjectStatisticsByProjectTierId("gno.land/r/onbloc/obl:124:30") + shouldEQ(t, got, `{"height":"1296142","now":"1237159928","projectId":"gno.land/r/onbloc/obl:124","tierId":"gno.land/r/onbloc/obl:124:30","tierAmount":"100000000","tierTotalDepositAmount":"1000000","tierActualDepositAmount":"0","tierTotalParticipant":"1","tierActualParticipant":"0"}`) + }) +} diff --git a/launchpad/tests/__TEST_launchpad_tier30_single_deposit_01_deposit_collect_gns_test.gnoA b/launchpad/tests/__TEST_launchpad_tier30_single_deposit_01_deposit_collect_gns_test.gnoA index 9fa3b38f..9d7f3668 100644 --- a/launchpad/tests/__TEST_launchpad_tier30_single_deposit_01_deposit_collect_gns_test.gnoA +++ b/launchpad/tests/__TEST_launchpad_tier30_single_deposit_01_deposit_collect_gns_test.gnoA @@ -76,8 +76,8 @@ func TestCreateProject(t *testing.T) { shouldEQ(t, tier30.tierAmount, uint64(100000000)) shouldNEQ(t, tier30.tierAmountPerBlockX96.ToString(), `0`) shouldEQ(t, tier30.endTime, project.startTime+TIMESTAMP_30DAYS) - shouldEQ(t, tier30.depositAmount, uint64(0)) - shouldEQ(t, tier30.participant, uint64(0)) + shouldEQ(t, tier30.actualDepositAmount, uint64(0)) + shouldEQ(t, tier30.actualParticipant, uint64(0)) shouldEQ(t, project.tier90Ratio, uint64(20)) tier90 := project.tier90 @@ -86,8 +86,8 @@ func TestCreateProject(t *testing.T) { shouldEQ(t, tier90.tierAmount, uint64(200000000)) shouldNEQ(t, tier90.tierAmountPerBlockX96.ToString(), `0`) shouldEQ(t, tier90.endTime, project.startTime+TIMESTAMP_90DAYS) - shouldEQ(t, tier90.depositAmount, uint64(0)) - shouldEQ(t, tier90.participant, uint64(0)) + shouldEQ(t, tier90.actualDepositAmount, uint64(0)) + shouldEQ(t, tier90.actualParticipant, uint64(0)) shouldEQ(t, project.tier180Ratio, uint64(70)) tier180 := project.tier180 @@ -96,8 +96,8 @@ func TestCreateProject(t *testing.T) { shouldEQ(t, tier180.tierAmount, uint64(700000000)) shouldNEQ(t, tier180.tierAmountPerBlockX96.ToString(), `0`) shouldEQ(t, tier180.endTime, project.startTime+TIMESTAMP_180DAYS) - shouldEQ(t, tier180.depositAmount, uint64(0)) - shouldEQ(t, tier180.participant, uint64(0)) + shouldEQ(t, tier180.actualDepositAmount, uint64(0)) + shouldEQ(t, tier180.actualParticipant, uint64(0)) shouldEQ(t, project.createdHeight, uint64(124)) shouldEQ(t, project.createdTime, uint64(1234567892)) @@ -135,8 +135,8 @@ func TestDepositGnsToTier30(t *testing.T) { shouldEQ(t, tier30.tierAmount, uint64(100000000)) shouldNEQ(t, tier30.tierAmountPerBlockX96.ToString(), `0`) shouldEQ(t, tier30.endTime, project.startTime+TIMESTAMP_30DAYS) - shouldEQ(t, tier30.depositAmount, uint64(0)) - shouldEQ(t, tier30.participant, uint64(0)) + shouldEQ(t, tier30.actualDepositAmount, uint64(0)) + shouldEQ(t, tier30.actualParticipant, uint64(0)) shouldEQ(t, len(deposits), 0) shouldEQ(t, len(depositsByProject), 0) @@ -162,8 +162,8 @@ func TestDepositGnsToTier30(t *testing.T) { shouldEQ(t, tier30.tierAmount, uint64(100000000)) shouldNEQ(t, tier30.tierAmountPerBlockX96.ToString(), `0`) shouldEQ(t, tier30.endTime, project.startTime+TIMESTAMP_30DAYS) - shouldEQ(t, tier30.depositAmount, uint64(1000000)) - shouldEQ(t, tier30.participant, uint64(1)) + shouldEQ(t, tier30.actualDepositAmount, uint64(1000000)) + shouldEQ(t, tier30.actualParticipant, uint64(1)) // shouldEQ(t, len(deposits), 1) @@ -247,6 +247,6 @@ func TestCollectDepositGns(t *testing.T) { tier30 := project.tier30 shouldEQ(t, tier30.id, `gno.land/r/onbloc/obl:124:30`) shouldEQ(t, tier30.tierAmount, uint64(100000000)) - shouldEQ(t, tier30.depositAmount, uint64(0)) - shouldEQ(t, tier30.participant, uint64(0)) + shouldEQ(t, tier30.actualDepositAmount, uint64(0)) + shouldEQ(t, tier30.actualParticipant, uint64(0)) } diff --git a/launchpad/type.gno b/launchpad/type.gno index 2567e34d..8e749322 100644 --- a/launchpad/type.gno +++ b/launchpad/type.gno @@ -50,11 +50,11 @@ type Tier struct { endHeight uint64 endTime uint64 - // actual data - // unlikely projects' totalDepositAmount or totalParticipant - // below data will be decreased - depositAmount uint64 - participant uint64 + totalDepositAmount uint64 + actualDepositAmount uint64 + + totalParticipant uint64 + actualParticipant uint64 } type Condition struct {