Skip to content

Commit

Permalink
feat(x/incentives): Remove 1day 7day Lock Duration (#7677) (#7909)
Browse files Browse the repository at this point in the history
* Remove 1day 7day liquidity bonds

* Add changelog

* Add test from adam

* Some logs for e2e

* This should fix e2e

* log e2e

* Remove logs

* Fix e2e

* Add more tests

* name

---------

Co-authored-by: Adam Tucker <adamleetucker@outlook.com>
(cherry picked from commit 57358d6)

Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>
  • Loading branch information
mergify[bot] and mattverse authored Apr 2, 2024
1 parent 9bf7c74 commit 7892e2f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7622](https://github.com/osmosis-labs/osmosis/pull/7622) Create/remove tick events.
* [#7623](https://github.com/osmosis-labs/osmosis/pull/7623) Add query for querying all before send hooks
* [#7622](https://github.com/osmosis-labs/osmosis/pull/7622) Remove duplicate CL accumulator update logic.
* [#7503](https://github.com/osmosis-labs/osmosis/pull/7677) feat(x/incentives): Restrict lockable durations to 2 weeks.
* [#7665](https://github.com/osmosis-labs/osmosis/pull/7665) feat(x/protorev): Use Transient store to store swap backruns.
* [#7685](https://github.com/osmosis-labs/osmosis/pull/7685) Speedup CL actions by only marshalling for CL hooks if they will be used.
* [#7503](https://github.com/osmosis-labs/osmosis/pull/7503) Add IBC wasm light clients module
Expand Down
15 changes: 14 additions & 1 deletion app/upgrades/v24/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v24

import (
"sort"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -55,11 +56,23 @@ func CreateUpgradeHandler(
// and spread the pruning time across multiple blocks to avoid a single block taking too long.
keepers.TwapKeeper.SetDeprecatedHistoricalTWAPsIsPruning(ctx)

// restrict lockable durations to 2 weeks per
// https://wallet.keplr.app/chains/osmosis/proposals/400
chainID := ctx.ChainID()

if chainID == mainnetChainID || chainID == edgenetChainID {
keepers.IncentivesKeeper.SetLockableDurations(ctx, []time.Duration{
time.Hour * 24 * 14,
})
keepers.PoolIncentivesKeeper.SetLockableDurations(ctx, []time.Duration{
time.Hour * 24 * 14,
})
}

// Set the new min value for distribution for the incentives module.
// https://www.mintscan.io/osmosis/proposals/733
keepers.IncentivesKeeper.SetParam(ctx, incentivestypes.KeyMinValueForDistr, incentivestypes.DefaultMinValueForDistr)

chainID := ctx.ChainID()
// We only perform the migration on mainnet pools since we hard-coded the pool IDs to migrate
// in the types package. And the testnet was migrated in v24
if chainID == mainnetChainID || chainID == edgenetChainID {
Expand Down
44 changes: 43 additions & 1 deletion app/upgrades/v24/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
v24 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v24"
concentratedtypes "github.com/osmosis-labs/osmosis/v24/x/concentrated-liquidity/types"
incentivestypes "github.com/osmosis-labs/osmosis/v24/x/incentives/types"
lockuptypes "github.com/osmosis-labs/osmosis/v24/x/lockup/types"
protorevtypes "github.com/osmosis-labs/osmosis/v24/x/protorev/types"
twap "github.com/osmosis-labs/osmosis/v24/x/twap"
"github.com/osmosis-labs/osmosis/v24/x/twap/types"
Expand Down Expand Up @@ -178,6 +179,36 @@ func (s *UpgradeTestSuite) TestUpgrade() {
s.Require().NoError(err)
s.Require().Equal(protorevtypes.DefaultBaseDenoms, newBaseDenoms)

// INCENTIVE Setup
//

// check that old lockable durations were not single param
oldLockableDurations := s.App.IncentivesKeeper.GetLockableDurations(s.Ctx)
s.Require().Equal(len(oldLockableDurations), 4)
oldLockableDurations = s.App.PoolIncentivesKeeper.GetLockableDurations(s.Ctx)
s.Require().Equal(len(oldLockableDurations), 3)

// fund test acc and create non-perpetual gauge
lockDuration := time.Hour
incentive := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000)))
expectedShareDenom := "foo"
s.FundAcc(s.TestAccs[1], incentive)

shareLock := sdk.NewCoins(sdk.NewCoin(expectedShareDenom, osmomath.NewInt(1_000_000)))
s.FundAcc(s.TestAccs[1], shareLock)
shareCoins := sdk.NewCoins(sdk.NewInt64Coin(expectedShareDenom, int64(1_000_000)))
_, err = s.App.LockupKeeper.CreateLock(s.Ctx, s.TestAccs[1], shareCoins, lockDuration)
s.Require().NoError(err)

gaugeId, err := s.App.IncentivesKeeper.CreateGauge(s.Ctx, true, s.TestAccs[1], incentive, lockuptypes.QueryCondition{
LockQueryType: lockuptypes.ByDuration,
Denom: expectedShareDenom,
Duration: lockDuration,
}, s.Ctx.BlockTime(), 1, 0)
s.Require().NoError(err)
gauge, err := s.App.IncentivesKeeper.GetGaugeByID(s.Ctx, gaugeId)
s.Require().NoError(err)

whiteWhalePoolIds := []uint64{1463, 1462, 1461}
for _, poolId := range whiteWhalePoolIds {
s.App.CosmwasmPoolKeeper.SetPool(s.Ctx, &model.CosmWasmPool{
Expand Down Expand Up @@ -235,6 +266,18 @@ func (s *UpgradeTestSuite) TestUpgrade() {
// INCENTIVES Tests
//

coins, err := s.App.IncentivesKeeper.Distribute(s.Ctx, []incentivestypes.Gauge{*gauge})
s.Require().NoError(err)
s.Require().Equal(incentive.String(), coins.String())

lockableDurations := s.App.IncentivesKeeper.GetLockableDurations(s.Ctx)
s.Require().Equal(len(lockableDurations), 1)
s.Require().Equal(lockableDurations[0], time.Hour*24*14)

lockableDurations = s.App.PoolIncentivesKeeper.GetLockableDurations(s.Ctx)
s.Require().Equal(len(lockableDurations), 1)
s.Require().Equal(lockableDurations[0], time.Hour*24*14)

// Migrated pool: ensure that the claimable incentives are the same before and after migration
migratedPoolAfterUpgradeIncentives, _, err := s.App.ConcentratedLiquidityKeeper.GetClaimableIncentives(s.Ctx, lastPoolPositionID)
s.Require().NoError(err)
Expand All @@ -243,7 +286,6 @@ func (s *UpgradeTestSuite) TestUpgrade() {

// Non-migrated pool: ensure that the claimable incentives are the same before and after migration
nonMigratedPoolAfterUpgradeIncentives, _, err := s.App.ConcentratedLiquidityKeeper.GetClaimableIncentives(s.Ctx, lastPoolPositionID-1)

s.Require().NoError(err)
s.Require().Equal(nonMigratedPoolBeforeUpgradeIncentives.String(), nonMigratedPoolAfterUpgradeIncentives.String())

Expand Down

0 comments on commit 7892e2f

Please sign in to comment.