diff --git a/staker/_GET_qa_internal_emission.gnoA b/staker/_GET_qa_internal_emission.gno similarity index 94% rename from staker/_GET_qa_internal_emission.gnoA rename to staker/_GET_qa_internal_emission.gno index 4f1ce8aad..f7a8f3e8d 100644 --- a/staker/_GET_qa_internal_emission.gnoA +++ b/staker/_GET_qa_internal_emission.gno @@ -110,7 +110,6 @@ type ApiEmissionDebugPosition struct { } func GetPrintInfo() string { - /* emissionDebug := ApiEmissionDebugInfo{} emissionDebug.Height = std.GetHeight() emissionDebug.Time = time.Now().Unix() @@ -127,7 +126,7 @@ func GetPrintInfo() string { pool.PoolPath = poolPath pool.Tier = tier - numTier1, numTier2, numTier3 := getNumPoolTiers() + numTier1, numTier2, numTier3 := getNumPoolTiers(t) if tier == 1 { pool.NumPoolInSameTier = numTier1 } else if tier == 2 { @@ -136,8 +135,6 @@ func GetPrintInfo() string { pool.NumPoolInSameTier = numTier3 } - pool.PoolReward = poolGns[poolPath] - for lpTokenId, deposit := range deposits { if deposit.targetPoolPath == poolPath { position := ApiEmissionDebugPosition{} @@ -146,10 +143,7 @@ func GetPrintInfo() string { position.StakedTimestamp = deposit.stakeTimestamp position.StakedDuration = emissionDebug.Height - deposit.stakeHeight - position.FullAmount = positionGns[lpTokenId] - position.Ratio = getRewardRatio(position.StakedDuration) - position.RatioAmount = (position.FullAmount * position.Ratio) / 100 - + position.Ratio = getRewardRatio(t, position.StakedDuration) pool.Position = append(pool.Position, position) } } @@ -177,16 +171,13 @@ func GetPrintInfo() string { } return string(b) - */ - panic("SHOULD BE REIMPLEMENTED BEFORE MERGING") } func makePoolsNode(emissionPool []ApiEmissionDebugPool) []*json.Node { - /* pools := make([]*json.Node, 0) poolTiers.Iter(func(poolPath string, internalTier InternalTier) { - numTier1, numTier2, numTier3 := getNumPoolTiers() + numTier1, numTier2, numTier3 := getNumPoolTiers(t) numPoolSameTier := uint64(0) tier := internalTier.tier if tier == 1 { @@ -202,14 +193,11 @@ func makePoolsNode(emissionPool []ApiEmissionDebugPool) []*json.Node { "startTimestamp": json.NumberNode("startTimestamp", float64(internalTier.startTimestamp)), "tier": json.NumberNode("tier", float64(tier)), "numPoolSameTier": json.NumberNode("numPoolSameTier", float64(numPoolSameTier)), - "poolReward": json.NumberNode("poolReward", float64(poolGns[poolPath])), "position": json.ArrayNode("", makePositionsNode(poolPath)), })) }) return pools - */ - panic("SHOULD BE REIMPLEMENTED BEFORE MERGING") } func makePositionsNode(poolPath string) []*json.Node { diff --git a/staker/_helper_test.gno b/staker/_helper_test.gno index 79d58ccca..3a2d5dc54 100644 --- a/staker/_helper_test.gno +++ b/staker/_helper_test.gno @@ -164,6 +164,7 @@ func init() { } var ( + adminAddr = consts.ADMIN admin = pusers.AddressOrName(consts.ADMIN) alice = pusers.AddressOrName(testutils.TestAddress("alice")) pool = pusers.AddressOrName(consts.POOL_ADDR) @@ -493,6 +494,7 @@ func burnAllNFT(t *testing.T) { } func TestBeforeResetObject(t *testing.T) { + t.Skip("can not be run with other tests") // make actual data to test resetting not only position's state but also pool's state std.TestSetRealm(adminRealm) @@ -540,3 +542,38 @@ func TestBeforeResetObject(t *testing.T) { // burnAllNFT(t) // uassert.Equal(t, gnft.TotalSupply(), uint64(0), "gnft total supply should be 0") // } + +func deletePoolTier(t *testing.T, poolPath string) { + poolTier.changeTier(uint64(std.GetHeight()), poolPath, 0) +} + +func addPoolTier(t *testing.T, poolPath string, tier uint64) { + poolTier.changeTier(uint64(std.GetHeight()), poolPath, tier) + pools.GetOrCreate(poolPath) +} + +func changeWarmup(t *testing.T, index int, blockDuration int64) { + modifyWarmup(index, blockDuration) +} + +func getNumPoolTiers(t *testing.T) (uint64, uint64, uint64) { + tier1Num := poolTier.count[1].tree.Size() + tier2Num := poolTier.count[2].tree.Size() + tier3Num := poolTier.count[3].tree.Size() + + return uint64(tier1Num), uint64(tier2Num), uint64(tier3Num) +} + +func getRewardRatio(t *testing.T, height int64) uint64 { + t.Helper() + warmups := InstantiateWarmup(height) + + for _, warmup := range warmups { + if height < warmup.NextWarmupHeight { + return warmup.WarmupRatio + } + } + + // passed all warmup-periods + return 100 +}