Skip to content

Commit

Permalink
Add mainnet and testnet community params (#1753)
Browse files Browse the repository at this point in the history
  • Loading branch information
drklee3 authored Oct 25, 2023
1 parent faebe6b commit 3784791
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
41 changes: 35 additions & 6 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,50 @@ const (
UpgradeName_E2ETest = "v0.25.0-testing"
)

var CommunityParams_E2E = communitytypes.NewParams(
time.Now().Add(10*time.Second).UTC(), // relative time for testing
sdkmath.LegacyNewDec(0), // stakingRewardsPerSecond
sdkmath.LegacyNewDec(1000), // upgradeTimeSetstakingRewardsPerSecond
var (
// KAVA to ukava - 6 decimals
kavaConversionFactor = sdk.NewInt(1000_000)
secondsPerYear = sdk.NewInt(365 * 24 * 60 * 60)

// 10 Million KAVA per year in staking rewards, inflation disable time 2024-01-01T00:00:00 UTC
CommunityParams_Mainnet = communitytypes.NewParams(
time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC),
// before switchover
sdkmath.LegacyZeroDec(),
// after switchover - 10M KAVA to ukava per year / seconds per year
sdkmath.LegacyNewDec(10_000_000).
MulInt(kavaConversionFactor).
QuoInt(secondsPerYear),
)

// Testnet -- 15 Trillion KAVA per year in staking rewards, inflation disable time 2023-11-16T00:00:00 UTC
CommunityParams_Testnet = communitytypes.NewParams(
time.Date(2023, 11, 16, 0, 0, 0, 0, time.UTC),
// before switchover
sdkmath.LegacyZeroDec(),
// after switchover
sdkmath.LegacyNewDec(15_000_000).
MulInt64(1_000_000). // 15M * 1M = 15T
MulInt(kavaConversionFactor).
QuoInt(secondsPerYear),
)

CommunityParams_E2E = communitytypes.NewParams(
time.Now().Add(10*time.Second).UTC(), // relative time for testing
sdkmath.LegacyNewDec(0), // stakingRewardsPerSecond
sdkmath.LegacyNewDec(1000), // upgradeTimeSetstakingRewardsPerSecond
)
)

// RegisterUpgradeHandlers registers the upgrade handlers for the app.
func (app App) RegisterUpgradeHandlers() {
app.upgradeKeeper.SetUpgradeHandler(
UpgradeName_Mainnet,
upgradeHandler(app, UpgradeName_Mainnet, communitytypes.DefaultParams()),
upgradeHandler(app, UpgradeName_Mainnet, CommunityParams_Mainnet),
)
app.upgradeKeeper.SetUpgradeHandler(
UpgradeName_Testnet,
upgradeHandler(app, UpgradeName_Testnet, communitytypes.DefaultParams()),
upgradeHandler(app, UpgradeName_Testnet, CommunityParams_Testnet),
)
app.upgradeKeeper.SetUpgradeHandler(
UpgradeName_E2ETest,
Expand Down
41 changes: 41 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package app_test

import (
"testing"

sdkmath "cosmossdk.io/math"
"github.com/kava-labs/kava/app"
"github.com/stretchr/testify/require"
)

func TestUpgradeCommunityParams_Mainnet(t *testing.T) {
require.Equal(
t,
sdkmath.LegacyZeroDec().String(),
app.CommunityParams_Mainnet.StakingRewardsPerSecond.String(),
)

require.Equal(
t,
// Manually confirmed
"317097.919837645865043125",
app.CommunityParams_Mainnet.UpgradeTimeSetStakingRewardsPerSecond.String(),
"mainnet kava per second should be correct",
)
}

func TestUpgradeCommunityParams_Testnet(t *testing.T) {
require.Equal(
t,
sdkmath.LegacyZeroDec().String(),
app.CommunityParams_Testnet.StakingRewardsPerSecond.String(),
)

require.Equal(
t,
// Manually confirmed
"475646879756.468797564687975646",
app.CommunityParams_Testnet.UpgradeTimeSetStakingRewardsPerSecond.String(),
"testnet kava per second should be correct",
)
}

0 comments on commit 3784791

Please sign in to comment.