Skip to content

Commit

Permalink
Merge branch 'main' into feat/ojo-oracle-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond authored Feb 5, 2025
2 parents e632283 + c0189fa commit 1865f03
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 69 deletions.
81 changes: 70 additions & 11 deletions api/elys/amm/params.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions proto/elys/amm/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ message Params {
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
uint64 lp_lockup_duration = 11;
}
2 changes: 1 addition & 1 deletion x/amm/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (k Keeper) CheckBaseAssetExist(ctx sdk.Context, denom string) bool {
return found
}

func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) {
func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.Params) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))

b := store.Get([]byte(types.ParamsKey))
Expand Down
5 changes: 2 additions & 3 deletions x/amm/keeper/pool_share.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"time"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/amm/types"
Expand Down Expand Up @@ -64,7 +62,8 @@ func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.Pool, addr sd
// Commit LP token minted
lockUntil := uint64(0)
if pool.PoolParams.UseOracle {
lockUntil = uint64(ctx.BlockTime().Unix()) + uint64(time.Hour.Seconds())
params := k.GetParams(ctx)
lockUntil = uint64(ctx.BlockTime().Unix()) + params.LpLockupDuration
}

err = k.commitmentKeeper.CommitLiquidTokens(ctx, addr, poolShareDenom, amount, lockUntil)
Expand Down
13 changes: 13 additions & 0 deletions x/amm/migrations/v11_migration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package migrations

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (m Migrator) V11Migration(ctx sdk.Context) error {
legacyParams := m.keeper.GetLegacyParams(ctx)
legacyParams.LpLockupDuration = 3600

m.keeper.SetParams(ctx, legacyParams)
return nil
}
4 changes: 2 additions & 2 deletions x/amm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
m := migrations.NewMigrator(am.keeper)
err := cfg.RegisterMigration(types.ModuleName, 9, m.V10Migration)
err := cfg.RegisterMigration(types.ModuleName, 10, m.V11Migration)
if err != nil {
panic(err)
}
Expand All @@ -154,7 +154,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 10 }
func (AppModule) ConsensusVersion() uint64 { return 11 }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ context.Context) error {
Expand Down
1 change: 1 addition & 0 deletions x/amm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func NewParams(poolCreationFee math.Int, slippageTrackDuration uint64, baseAsset
ThresholdWeightDifference: math.LegacyMustNewDecFromStr("0.3"),
AllowedPoolCreators: []string{authtypes.NewModuleAddress(govtypes.ModuleName).String()},
ThresholdWeightDifferenceSwapFee: math.LegacyMustNewDecFromStr("1.0"),
LpLockupDuration: 3600,
}
}

Expand Down
Loading

0 comments on commit 1865f03

Please sign in to comment.