Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contract/r/gnoswap/v1/staker/api.gno
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func ApiGetInternalIncentivesByPoolPath(targetPoolPath string) string {
return ""
}

internalIctv := newApiInternalIncentive(targetPoolPath, tier)
internalIctv := newApiInternalIncentive(targetPoolPath, tier.Uint64())
apiInternalIncentives = append(apiInternalIncentives, internalIctv)

rsps := make([]JsonResponse, len(apiInternalIncentives))
Expand Down
12 changes: 6 additions & 6 deletions contract/r/gnoswap/v1/staker/getter.gno
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,26 @@ func GetDepositWarmUp(lpTokenId uint64) []Warmup {

// GetPoolTier returns the tier of a pool.
func GetPoolTier(poolPath string) uint64 {
return poolTier.CurrentTier(poolPath)
return poolTier.CurrentTier(poolPath).Uint64()
}

// GetPoolTierRatio returns the current reward ratio for a pool's tier.
func GetPoolTierRatio(poolPath string) uint64 {
func GetPoolTierRatio(poolPath string) int64 {
tier := GetPoolTier(poolPath)
return poolTier.tierRatio.Get(tier)
return poolTier.tierRatio.Get(TierFromUint64(tier))
}

// GetPoolTierCount returns the number of pools in a tier.
func GetPoolTierCount(tier uint64) uint64 {
func GetPoolTierCount(tier uint64) int64 {
if tier == 0 {
return 0
}
return uint64(poolTier.CurrentCount(tier))
return poolTier.CurrentCount(TierFromUint64(tier))
}

// GetPoolReward returns the current reward amount for a tier.
func GetPoolReward(tier uint64) int64 {
return poolTier.CurrentReward(tier)
return poolTier.CurrentReward(TierFromUint64(tier))
}

// GetExternalIncentiveByPoolPath returns all external incentives for a pool.
Expand Down
16 changes: 5 additions & 11 deletions contract/r/gnoswap/v1/staker/manage_pool_tier_and_warmup.gno
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
pl "gno.land/r/gnoswap/v1/pool"
)

const (
NOT_EMISSION_TARGET_TIER uint64 = 0
)

// SetPoolTier assigns a tier level to a pool for internal GNS emission rewards.
// Only admin or governance can call this function.
func SetPoolTier(cur realm, poolPath string, tier uint64) {
Expand Down Expand Up @@ -120,30 +116,28 @@ func setPoolTier(poolPath string, tier uint64, currentTime int64) {
en.MintAndDistributeGns(cross)

pools.GetOrCreate(poolPath)
poolTier.changeTier(runtime.ChainHeight(), currentTime, pools, poolPath, tier)
poolTier.changeTier(runtime.ChainHeight(), currentTime, pools, poolPath, TierFromUint64(tier))
}

// changePoolTier internally changes the pool tier and returns old and new tiers.
func changePoolTier(poolPath string, tier uint64, currentTime int64) (uint64, uint64) {
en.MintAndDistributeGns(cross)
previousTier := poolTier.CurrentTier(poolPath)

poolTier.changeTier(runtime.ChainHeight(), currentTime, pools, poolPath, tier)
previousTier := poolTier.CurrentTier(poolPath)
poolTier.changeTier(runtime.ChainHeight(), currentTime, pools, poolPath, TierFromUint64(tier))

return previousTier, tier
return previousTier.Uint64(), tier
}

// removePoolTier internally removes the pool from tier system.
func removePoolTier(poolPath string, currentTime int64) {
en.MintAndDistributeGns(cross)

poolTier.changeTier(runtime.ChainHeight(), currentTime, pools, poolPath, NOT_EMISSION_TARGET_TIER)
poolTier.changeTier(runtime.ChainHeight(), currentTime, pools, poolPath, TierNone)
}

// setWarmUp internally sets the warm-up parameters.
func setWarmUp(pct, timeDuration int64) {
en.MintAndDistributeGns(cross)

modifyWarmup(pctToIndex(pct), timeDuration)
}

Expand Down
2 changes: 1 addition & 1 deletion contract/r/gnoswap/v1/staker/query.gno
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func QueryPoolData(poolPath string) (*PoolData, error) {

return &PoolData{
PoolPath: poolPath,
Tier: tier,
Tier: tier.Uint64(),
ActiveIncentives: ictvIds,
StakedLiquidity: pool.CurrentStakedLiquidity(currentTimestamp),
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func (self *canonicalPool) InternalReward(emission uint64, ratio TierRatio, coun
case 0:
return 0
case 1:
return int64(emission * ratio.Tier1 / count / 100)
return int64(emission) * ratio.Tier1 / int64(count) / 100
case 2:
return int64(emission * ratio.Tier2 / count / 100)
return int64(emission) * ratio.Tier2 / int64(count) / 100
case 3:
return int64(emission * ratio.Tier3 / count / 100)
return int64(emission) * ratio.Tier3 / int64(count) / 100
default:
panic("invalid tier")
}
Expand Down Expand Up @@ -515,7 +515,7 @@ func (self *canonicalRewardState) ChangePoolTier(poolPath string, tier uint64) {
if !self.global.pools.Has(poolPath) {
self.global.pools.set(poolPath, NewPool(poolPath, self.CurrentTime()))
}
self.global.poolTier.changeTier(runtime.ChainHeight(), self.CurrentTime(), self.global.pools, poolPath, tier)
self.global.poolTier.changeTier(runtime.ChainHeight(), self.CurrentTime(), self.global.pools, poolPath, TierFromUint64(tier))
}

func (self *canonicalRewardState) CreatePool(poolPath string, initialTier uint64, initialTick int32) {
Expand All @@ -527,7 +527,7 @@ func (self *canonicalRewardState) CreatePool(poolPath string, initialTier uint64
tickCrossHook: self.tickCrossHook,
}
self.global.pools.set(poolPath, NewPool(poolPath, self.CurrentTime()))
self.global.poolTier.changeTier(runtime.ChainHeight(), self.CurrentTime(), self.global.pools, poolPath, initialTier)
self.global.poolTier.changeTier(runtime.ChainHeight(), self.CurrentTime(), self.global.pools, poolPath, TierFromUint64(initialTier))
}

func (self *canonicalRewardState) MoveTick(poolPath string, tick int32) {
Expand Down
Loading
Loading