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

feat(IRO): IRO module implementation #1201

Merged
merged 77 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e48ae3f
genereated proto files
mtsitrin Aug 26, 2024
b6ecec8
fixed proto
mtsitrin Aug 27, 2024
ec02a4d
scaffold
mtsitrin Aug 27, 2024
c5ee033
store keys
mtsitrin Aug 27, 2024
70f179e
initial store getters
mtsitrin Aug 27, 2024
ffbb44a
implemented create plan
mtsitrin Aug 27, 2024
4f45328
implemented trade methods and linear bonding curve
mtsitrin Aug 28, 2024
59c6fed
implemented the cur
mtsitrin Aug 28, 2024
48eb399
wired keeper, and started testing
mtsitrin Aug 28, 2024
ac7ff90
implemented bonding curve and create plan
mtsitrin Aug 28, 2024
030f450
first UT pass
mtsitrin Aug 28, 2024
abfb8c5
bond curve fix and UT
mtsitrin Aug 28, 2024
0ba4c5c
trade test
mtsitrin Aug 28, 2024
b9ebf1c
added curve params to the plan
mtsitrin Sep 1, 2024
d9a1818
using curve from plan
mtsitrin Sep 1, 2024
a6bf24f
Merge branch 'main' into feature/IRO
mtsitrin Sep 1, 2024
bca38d8
refactor genesistransfer. added transferEnabled hook
mtsitrin Sep 1, 2024
33c09d6
UT compiles
mtsitrin Sep 1, 2024
8b69ae8
genesis transfer UT
mtsitrin Sep 2, 2024
0d18586
genesis test
mtsitrin Sep 2, 2024
eb7fcf1
implemented queries
mtsitrin Sep 2, 2024
1033813
module account for plan
mtsitrin Sep 2, 2024
2e1d0c3
fixed module account
mtsitrin Sep 2, 2024
3e74625
fixed validation test
mtsitrin Sep 2, 2024
3178c9f
liquidity bootstrap wip
mtsitrin Sep 2, 2024
f55fada
fixed claim. added buying allocation limit
mtsitrin Sep 2, 2024
d1c22d6
creating pool
mtsitrin Sep 2, 2024
63e25d1
UT wip
mtsitrin Sep 3, 2024
63adb6d
IRO creation fee
mtsitrin Sep 3, 2024
35b464e
linter
mtsitrin Sep 3, 2024
7dd34d5
minor change in api
mtsitrin Sep 3, 2024
06b7341
Merge branch 'main' into feature/IRO
mtsitrin Sep 4, 2024
41f71c9
renamed rollapp.sealed to rollapp.started
mtsitrin Sep 4, 2024
0226e08
added validations for genesis transfer
mtsitrin Sep 4, 2024
49917d0
sealing after IRO creation
mtsitrin Sep 4, 2024
f3c4760
handling pre_launch_time
mtsitrin Sep 4, 2024
bc7d3ad
Merge branch 'main' into feature/IRO
mtsitrin Sep 5, 2024
bc6dd6d
fixes post main merge
mtsitrin Sep 5, 2024
2224ca1
implemented incentives
mtsitrin Sep 5, 2024
49b24eb
implemented taker fee
mtsitrin Sep 5, 2024
d5e9c32
added incentives plan to the create plan tx
mtsitrin Sep 5, 2024
e65c30a
linter
mtsitrin Sep 5, 2024
749aa3b
skipping failed test for now
mtsitrin Sep 5, 2024
c432cc3
removed pool creation fee
mtsitrin Sep 5, 2024
f453481
fixed go.mod
mtsitrin Sep 5, 2024
faf74de
Merge branch 'main' into feature/IRO
mtsitrin Sep 8, 2024
4e15d9e
pr comments
mtsitrin Sep 8, 2024
da7f1a1
renames. fixed incentives params
mtsitrin Sep 8, 2024
a0190e2
cleanup
mtsitrin Sep 8, 2024
e02399c
added min params for incentives plan
mtsitrin Sep 8, 2024
5ff0f86
enforce minimum plan duration
mtsitrin Sep 8, 2024
bc6cee8
added params validation
mtsitrin Sep 8, 2024
70a02cb
cli - create plan
mtsitrin Sep 8, 2024
d2c793b
added cli
mtsitrin Sep 8, 2024
5aa8f6a
renames
mtsitrin Sep 8, 2024
e5423d1
simplified code and added more rollapp denom validation
mtsitrin Sep 8, 2024
88bcf46
refactored seal apis
mtsitrin Sep 9, 2024
16f1d74
refactord genesistransfer
mtsitrin Sep 9, 2024
63850d5
fixed taker fee
mtsitrin Sep 9, 2024
d5321d8
fixed taker fee to be chraged from the user
mtsitrin Sep 9, 2024
902dac5
adde curve validations. fixed liquidity edge cases
mtsitrin Sep 9, 2024
155d095
Merge branch 'main' into feature/IRO
mtsitrin Sep 9, 2024
8c9c7ce
dry out some code
mtsitrin Sep 10, 2024
2b24e32
fixed sequencer creation bug. added UT
mtsitrin Sep 10, 2024
4a548cb
split params for minimal incentives values
mtsitrin Sep 10, 2024
c1c9e70
transfer genesis validated only when IRO exists. transfers enabled by…
mtsitrin Sep 10, 2024
61accb0
renames and cleanup
mtsitrin Sep 10, 2024
3a09f0d
Merge branch 'main' into feature/IRO
mtsitrin Sep 17, 2024
9a259a1
goimports
mtsitrin Sep 17, 2024
73da686
pr comments
mtsitrin Sep 23, 2024
5c0fc8d
Merge branch 'main' into feature/IRO
mtsitrin Sep 23, 2024
3fb6b06
Merge branch 'main' into feature/IRO
mtsitrin Sep 23, 2024
11789f3
fixed cli
mtsitrin Sep 24, 2024
b0cb7b0
This reverts commit 11789f395c7fee633b7bea9b869a1d8e9d6efb5d.
mtsitrin Sep 24, 2024
f6a96ee
added cli UT
mtsitrin Sep 24, 2024
2113bf6
linter
mtsitrin Sep 24, 2024
94a4add
actually fixed
mtsitrin Sep 24, 2024
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
9 changes: 3 additions & 6 deletions app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

delayedack "github.com/dymensionxyz/dymension/v3/x/delayedack"
lightclientante "github.com/dymensionxyz/dymension/v3/x/lightclient/ante"
"github.com/dymensionxyz/dymension/v3/x/rollapp/transfergenesis"
)

func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
Expand Down Expand Up @@ -74,9 +75,7 @@ func newLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
delayedack.NewIBCProofHeightDecorator(),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),

// disabled until #1208 handled (https://github.com/dymensionxyz/dymension/issues/1208)
// transfergenesis.NewTransferEnabledDecorator(options.RollappKeeper.GetRollapp, options.IBCKeeper.ChannelKeeper),
transfergenesis.NewTransferEnabledDecorator(options.RollappKeeper.GetRollapp, options.IBCKeeper.ChannelKeeper),
)
}

Expand Down Expand Up @@ -112,8 +111,6 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
lightclientante.NewIBCMessagesDecorator(*options.LightClientKeeper, options.IBCKeeper.ClientKeeper, options.IBCKeeper.ChannelKeeper, options.RollappKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),

// disabled until #1208 handled (https://github.com/dymensionxyz/dymension/issues/1208)
// transfergenesis.NewTransferEnabledDecorator(options.RollappKeeper.GetRollapp, options.IBCKeeper.ChannelKeeper),
transfergenesis.NewTransferEnabledDecorator(options.RollappKeeper.GetRollapp, options.IBCKeeper.ChannelKeeper),
)
}
22 changes: 13 additions & 9 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
app "github.com/dymensionxyz/dymension/v3/app"
incentivestypes "github.com/dymensionxyz/dymension/v3/x/incentives/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
)

Expand Down Expand Up @@ -80,17 +81,20 @@ func SetupTestingApp() (*app.App, app.GenesisState) {
params.SetAddressPrefixes()

newApp := app.New(log.NewNopLogger(), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, 5, encCdc, EmptyAppOptions{}, bam.SetChainID(TestChainID))

defaultGenesisState := app.NewDefaultGenesisState(encCdc.Codec)

// set EnableCreate to false
if evmGenesisStateJson, found := defaultGenesisState[evmtypes.ModuleName]; found {
// force disable Enable Create of x/evm
var evmGenesisState evmtypes.GenesisState
encCdc.Codec.MustUnmarshalJSON(evmGenesisStateJson, &evmGenesisState)
evmGenesisState.Params.EnableCreate = false
defaultGenesisState[evmtypes.ModuleName] = encCdc.Codec.MustMarshalJSON(&evmGenesisState)
}
incentivesGenesisStateJson := defaultGenesisState[incentivestypes.ModuleName]
var incentivesGenesisState incentivestypes.GenesisState
encCdc.Codec.MustUnmarshalJSON(incentivesGenesisStateJson, &incentivesGenesisState)
incentivesGenesisState.LockableDurations = append(incentivesGenesisState.LockableDurations, time.Second*60)
defaultGenesisState[incentivestypes.ModuleName] = encCdc.Codec.MustMarshalJSON(&incentivesGenesisState)

// force disable EnableCreate of x/evm
evmGenesisStateJson := defaultGenesisState[evmtypes.ModuleName]
var evmGenesisState evmtypes.GenesisState
encCdc.Codec.MustUnmarshalJSON(evmGenesisStateJson, &evmGenesisState)
evmGenesisState.Params.EnableCreate = false
defaultGenesisState[evmtypes.ModuleName] = encCdc.Codec.MustMarshalJSON(&evmGenesisState)

return newApp, defaultGenesisState
}
Expand Down
2 changes: 1 addition & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *KeeperTestHelper) CreateRollappByName(name string) {
Bech32Prefix: strings.ToLower(rand.Str(3)),
GenesisChecksum: "1234567890abcdefg",
InitialSupply: sdk.NewInt(1000),
NativeDenom: &rollapptypes.DenomMetadata{
NativeDenom: rollapptypes.DenomMetadata{
Display: "DEN",
Base: "aden",
Exponent: 18,
Expand Down
20 changes: 17 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@ import (
eibcmoduletypes "github.com/dymensionxyz/dymension/v3/x/eibc/types"
incentiveskeeper "github.com/dymensionxyz/dymension/v3/x/incentives/keeper"
incentivestypes "github.com/dymensionxyz/dymension/v3/x/incentives/types"
irokeeper "github.com/dymensionxyz/dymension/v3/x/iro/keeper"
irotypes "github.com/dymensionxyz/dymension/v3/x/iro/types"
lightclientmodulekeeper "github.com/dymensionxyz/dymension/v3/x/lightclient/keeper"
lightclientmoduletypes "github.com/dymensionxyz/dymension/v3/x/lightclient/types"
lockupkeeper "github.com/dymensionxyz/dymension/v3/x/lockup/keeper"
lockuptypes "github.com/dymensionxyz/dymension/v3/x/lockup/types"
rollappmodule "github.com/dymensionxyz/dymension/v3/x/rollapp"
rollappmodulekeeper "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper"
"github.com/dymensionxyz/dymension/v3/x/rollapp/transfergenesis"
rollappmoduletypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
sequencermodulekeeper "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper"
sequencermoduletypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"
Expand Down Expand Up @@ -121,6 +124,7 @@ type AppKeepers struct {
FeeGrantKeeper feegrantkeeper.Keeper
PacketForwardMiddlewareKeeper *packetforwardkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
IROKeeper *irokeeper.Keeper

// Ethermint keepers
EvmKeeper *evmkeeper.Keeper
Expand Down Expand Up @@ -383,6 +387,17 @@ func (a *AppKeepers) InitKeepers(
a.RollappKeeper,
)

a.IROKeeper = irokeeper.NewKeeper(
appCodec,
a.keys[irotypes.StoreKey],
&a.AccountKeeper,
a.BankKeeper,
a.RollappKeeper,
a.GAMMKeeper,
a.IncentivesKeeper,
a.PoolManagerKeeper,
)

a.SponsorshipKeeper = sponsorshipkeeper.NewKeeper(
appCodec,
a.keys[sponsorshiptypes.StoreKey],
Expand Down Expand Up @@ -511,9 +526,7 @@ func (a *AppKeepers) InitTransferStack() {
delayedackmodule.WithRollappKeeper(a.RollappKeeper),
)
a.TransferStack = a.delayedAckMiddleware

// disabled until #1208 handled (https://github.com/dymensionxyz/dymension/issues/1208)
// a.TransferStack = transfergenesis.NewIBCModule(a.TransferStack, a.DelayedAckKeeper, *a.RollappKeeper, a.TransferKeeper, a.DenomMetadataKeeper)
a.TransferStack = transfergenesis.NewIBCModule(a.TransferStack, a.RollappKeeper, a.TransferKeeper, a.DenomMetadataKeeper, a.IROKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down Expand Up @@ -589,6 +602,7 @@ func (a *AppKeepers) SetupHooks() {
a.StreamerKeeper.Hooks(),
a.DymNSKeeper.GetRollAppHooks(),
a.LightClientKeeper.RollappHooks(),
a.IROKeeper,
))
}

Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
irotypes "github.com/dymensionxyz/dymension/v3/x/iro/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
epochstypes "github.com/osmosis-labs/osmosis/v15/x/epochs/types"
Expand Down Expand Up @@ -114,6 +115,7 @@ var KVStoreKeys = sdk.NewKVStoreKeys(
capabilitytypes.StoreKey,
crisistypes.StoreKey,
consensusparamtypes.StoreKey,
irotypes.StoreKey,
rollappmoduletypes.StoreKey,
sequencermoduletypes.StoreKey,
sponsorshiptypes.StoreKey,
Expand Down
12 changes: 10 additions & 2 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ import (
"github.com/dymensionxyz/dymension/v3/x/eibc"
eibcmoduletypes "github.com/dymensionxyz/dymension/v3/x/eibc/types"
incentivestypes "github.com/dymensionxyz/dymension/v3/x/incentives/types"
"github.com/dymensionxyz/dymension/v3/x/rollapp"

"github.com/dymensionxyz/dymension/v3/x/iro"
irotypes "github.com/dymensionxyz/dymension/v3/x/iro/types"
lightclientmodule "github.com/dymensionxyz/dymension/v3/x/lightclient"
lightclientmoduletypes "github.com/dymensionxyz/dymension/v3/x/lightclient/types"
"github.com/dymensionxyz/dymension/v3/x/rollapp"
rollappmoduleclient "github.com/dymensionxyz/dymension/v3/x/rollapp/client"
rollappmoduletypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
"github.com/dymensionxyz/dymension/v3/x/sequencer"
Expand Down Expand Up @@ -150,6 +151,7 @@ var ModuleBasics = module.NewBasicManager(
streamer.AppModuleBasic{},
denommetadata.AppModuleBasic{},
packetforward.AppModuleBasic{},
iro.AppModuleBasic{},
delayedack.AppModuleBasic{},
eibc.AppModuleBasic{},
dymnsmodule.AppModuleBasic{},
Expand Down Expand Up @@ -199,6 +201,7 @@ func (a *AppKeepers) SetupModules(
packetforwardmiddleware.NewAppModule(a.PacketForwardMiddlewareKeeper, a.GetSubspace(packetforwardtypes.ModuleName)),
ibctransfer.NewAppModule(a.TransferKeeper),
rollappmodule.NewAppModule(appCodec, a.RollappKeeper, a.AccountKeeper, a.BankKeeper),
iro.NewAppModule(appCodec, *a.IROKeeper),
sequencermodule.NewAppModule(appCodec, a.SequencerKeeper, a.AccountKeeper, a.BankKeeper, a.GetSubspace(sequencertypes.ModuleName)),
sponsorship.NewAppModule(a.SponsorshipKeeper),
streamermodule.NewAppModule(a.StreamerKeeper, a.AccountKeeper, a.BankKeeper, a.EpochsKeeper),
Expand Down Expand Up @@ -232,6 +235,7 @@ func (*AppKeepers) ModuleAccountAddrs() map[string]bool {
// exclude the streamer as we want him to be able to get external incentives
modAccAddrs[authtypes.NewModuleAddress(streamermoduletypes.ModuleName).String()] = false
modAccAddrs[authtypes.NewModuleAddress(txfeestypes.ModuleName).String()] = false
modAccAddrs[authtypes.NewModuleAddress(irotypes.ModuleName).String()] = false
return modAccAddrs
}

Expand All @@ -255,6 +259,7 @@ var maccPerms = map[string][]string{
incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner},
txfeestypes.ModuleName: {authtypes.Burner},
dymnstypes.ModuleName: {authtypes.Minter, authtypes.Burner},
irotypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

var BeginBlockers = []string{
Expand Down Expand Up @@ -294,6 +299,7 @@ var BeginBlockers = []string{
incentivestypes.ModuleName,
txfeestypes.ModuleName,
consensusparamtypes.ModuleName,
irotypes.ModuleName,
lightclientmoduletypes.ModuleName,
}

Expand Down Expand Up @@ -333,6 +339,7 @@ var EndBlockers = []string{
incentivestypes.ModuleName,
txfeestypes.ModuleName,
consensusparamtypes.ModuleName,
irotypes.ModuleName,
lightclientmoduletypes.ModuleName,
crisistypes.ModuleName,
}
Expand Down Expand Up @@ -373,6 +380,7 @@ var InitGenesis = []string{
incentivestypes.ModuleName,
txfeestypes.ModuleName,
consensusparamtypes.ModuleName,
irotypes.ModuleName,
lightclientmoduletypes.ModuleName,
crisistypes.ModuleName,
}
4 changes: 2 additions & 2 deletions app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollap
GenesisInfo: rollapptypes.GenesisInfo{
Bech32Prefix: oldRollapp.RollappId[:5], // placeholder data
GenesisChecksum: string(crypto.Sha256([]byte(oldRollapp.RollappId))), // placeholder data
NativeDenom: &rollapptypes.DenomMetadata{
NativeDenom: rollapptypes.DenomMetadata{
Display: "DEN", // placeholder data
Base: "aden", // placeholder data
Exponent: 6, // placeholder data
Exponent: 18, // placeholder data
},
InitialSupply: sdk.NewInt(100000), // placeholder data
Sealed: true,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/osmosis-labs/osmosis/osmomath v0.0.4
github.com/osmosis-labs/osmosis/v15 v15.2.0
github.com/pkg/errors v0.9.1
github.com/spf13/cast v1.6.0
Expand Down Expand Up @@ -169,7 +170,6 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/osmosis-labs/osmosis/osmomath v0.0.4 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand Down
Loading
Loading