Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prop 225 to v17 Upgrade Handler #1044

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) {
app.InterchainqueryKeeper,
app.RatelimitKeeper,
app.StakeibcKeeper,
app.BankKeeper,
sampocs marked this conversation as resolved.
Show resolved Hide resolved
),
)

Expand Down
22 changes: 22 additions & 0 deletions app/upgrades/v17/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

"github.com/Stride-Labs/stride/v16/utils"
icqkeeper "github.com/Stride-Labs/stride/v16/x/interchainquery/keeper"
ratelimitkeeper "github.com/Stride-Labs/stride/v16/x/ratelimit/keeper"
Expand Down Expand Up @@ -60,6 +62,12 @@ var (

// Osmo transfer channel is required for new rate limits
OsmosisTransferChannelId = "channel-5"

// Constants for Prop 225
CommunityPoolGrowthAddress = "stride1lj0m72d70qerts9ksrsphy9nmsd4h0s88ll9gfphmhemh8ewet5qj44jc9"
LiquidityReceiver = "stride1auhjs4zgp3ahvrpkspf088r2psz7wpyrypcnal"
Prop225TransferAmount = sdk.NewInt(31_572_300_000)
Ustrd = "ustrd"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v15
sampocs marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -70,6 +78,7 @@ func CreateUpgradeHandler(
icqKeeper icqkeeper.Keeper,
ratelimitKeeper ratelimitkeeper.Keeper,
stakeibcKeeper stakeibckeeper.Keeper,
bankKeeper bankkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting upgrade v17...")
Expand Down Expand Up @@ -101,6 +110,11 @@ func CreateUpgradeHandler(
return vm, errorsmod.Wrapf(err, "unable to add rate limits to Osmosis")
}

ctx.Logger().Info("Executing Prop 225, SHD Liquidity")
if err := ExecuteProp225(ctx, bankKeeper); err != nil {
return vm, errorsmod.Wrapf(err, "unable to execute prop 225")
}

return mm.RunMigrations(ctx, configurator, vm)
}
}
Expand Down Expand Up @@ -298,3 +312,11 @@ func AddRateLimitToOsmosis(ctx sdk.Context, k ratelimitkeeper.Keeper) error {

return nil
}

// Execute Prop 225, release STRD to stride1auhjs4zgp3ahvrpkspf088r2psz7wpyrypcnal
func ExecuteProp225(ctx sdk.Context, k bankkeeper.Keeper) error {
communityPoolGrowthAddress := sdk.MustAccAddressFromBech32(CommunityPoolGrowthAddress)
liquidityReceivernAddress := sdk.MustAccAddressFromBech32(LiquidityReceiver)
sampocs marked this conversation as resolved.
Show resolved Hide resolved
transferCoin := sdk.NewCoin(Ustrd, Prop225TransferAmount)
return k.SendCoins(ctx, communityPoolGrowthAddress, liquidityReceivernAddress, sdk.NewCoins(transferCoin))
sampocs marked this conversation as resolved.
Show resolved Hide resolved
}
31 changes: 31 additions & 0 deletions app/upgrades/v17/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {
checkRateLimitsAfterUpgrade := s.SetupRateLimitsBeforeUpgrade()
checkCommunityPoolTaxAfterUpgrade := s.SetupCommunityPoolTaxBeforeUpgrade()
checkQueriesAfterUpgrade := s.SetupQueriesBeforeUpgrade()
checkProp225AfterUpgrade := s.SetupProp225BeforeUpgrade()

// Submit upgrade and confirm handler succeeds
s.ConfirmUpgradeSucceededs("v17", dummyUpgradeHeight)
Expand All @@ -85,6 +86,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {
checkRateLimitsAfterUpgrade()
checkCommunityPoolTaxAfterUpgrade()
checkQueriesAfterUpgrade()
checkProp225AfterUpgrade()
}

// Helper function to check that the community pool stake and redeem holding
Expand Down Expand Up @@ -348,6 +350,35 @@ func (s *UpgradeTestSuite) SetupQueriesBeforeUpgrade() func() {
}
}

func (s *UpgradeTestSuite) SetupProp225BeforeUpgrade() func() {
// Grab the community pool growth address and balance
communityPoolGrowthAddress := sdk.MustAccAddressFromBech32(v17.CommunityPoolGrowthAddress)
// Set the balance to 3x the amount that will be transferred
newCoin := sdk.NewCoin(v17.Ustrd, v17.Prop225TransferAmount.MulRaw(3))
s.FundAccount(communityPoolGrowthAddress, newCoin)
originalCommunityGrowthBalance := s.App.BankKeeper.GetBalance(s.Ctx, communityPoolGrowthAddress, v17.Ustrd)

// Grab the liquidity receiver address and balance
liquidityReceiverAddress := sdk.MustAccAddressFromBech32(v17.LiquidityReceiver)
originalLiquidityReceiverBalance := s.App.BankKeeper.GetBalance(s.Ctx, liquidityReceiverAddress, v17.Ustrd)

// grab how much we want to transfer
transferAmount := v17.Prop225TransferAmount.Int64()

// Return callback to check store after upgrade
return func() {
// verify funds left community growth
newCommunityGrowthBalance := s.App.BankKeeper.GetBalance(s.Ctx, communityPoolGrowthAddress, v17.Ustrd)
communityGrowthBalanceChange := originalCommunityGrowthBalance.Sub(newCommunityGrowthBalance)
s.Require().Equal(transferAmount, communityGrowthBalanceChange.Amount.Int64(), "community growth decreased by correct amount")

// verify funds entered liquidity custodian
newLiquidityCustodianBalance := s.App.BankKeeper.GetBalance(s.Ctx, liquidityReceiverAddress, v17.Ustrd)
liquidityCustodianBalanceChange := newLiquidityCustodianBalance.Sub(originalLiquidityReceiverBalance).Amount.Int64()
s.Require().Equal(transferAmount, liquidityCustodianBalanceChange, "custodian balance increased by correct amount")
}
}

func (s *UpgradeTestSuite) TestRegisterCommunityPoolAddresses() {
// Create 3 host zones, with empty ICA addresses
chainIds := []string{}
Expand Down