Skip to content

Commit

Permalink
Merge pull request #55 from crescent-network/cherry-pick/321
Browse files Browse the repository at this point in the history
feat: add marketmaker module #321
  • Loading branch information
crypin committed Sep 1, 2022
2 parents cb7c8b2 + c056abc commit a79db33
Show file tree
Hide file tree
Showing 80 changed files with 14,512 additions and 330 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- x/liquidstaking/**/*
"x/mint":
- x/mint/**/*
"x/marketmaker":
- x/marketmaker/**/*
"documentation":
- docs/**/*
"build":
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* (x/marketmaker) [\#55](https://github.com/crescent-network/crescent/pull/55) feat: add marketmaker module

### Bug Fixes

* (x/liquidstaking) [\#53](https://github.com/crescent-network/crescent/pull/53) fix: calculation bug of liquidstaking voting_power
Expand Down
25 changes: 24 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ import (
"github.com/crescent-network/crescent/v2/x/liquidstaking"
liquidstakingkeeper "github.com/crescent-network/crescent/v2/x/liquidstaking/keeper"
liquidstakingtypes "github.com/crescent-network/crescent/v2/x/liquidstaking/types"
"github.com/crescent-network/crescent/v2/x/marketmaker"
marketmakerclient "github.com/crescent-network/crescent/v2/x/marketmaker/client"
marketmakerkeeper "github.com/crescent-network/crescent/v2/x/marketmaker/keeper"
marketmakertypes "github.com/crescent-network/crescent/v2/x/marketmaker/types"
"github.com/crescent-network/crescent/v2/x/mint"
mintkeeper "github.com/crescent-network/crescent/v2/x/mint/keeper"
minttypes "github.com/crescent-network/crescent/v2/x/mint/types"
Expand Down Expand Up @@ -143,6 +147,7 @@ var (
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
farmingclient.ProposalHandler,
marketmakerclient.ProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
Expand All @@ -159,6 +164,7 @@ var (
liquidity.AppModuleBasic{},
liquidstaking.AppModuleBasic{},
claim.AppModuleBasic{},
marketmaker.AppModuleBasic{},
)

// module account permissions
Expand All @@ -175,6 +181,7 @@ var (
liquidstakingtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
claimtypes.ModuleName: nil,
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
marketmakertypes.ModuleName: nil,
}
)

Expand Down Expand Up @@ -222,6 +229,7 @@ type App struct {
LiquidityKeeper liquiditykeeper.Keeper
LiquidStakingKeeper liquidstakingkeeper.Keeper
ClaimKeeper claimkeeper.Keeper
MarketMakerKeeper marketmakerkeeper.Keeper

ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -289,6 +297,7 @@ func NewApp(
liquiditytypes.StoreKey,
liquidstakingtypes.StoreKey,
claimtypes.StoreKey,
marketmakertypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -429,6 +438,13 @@ func NewApp(
app.AccountKeeper,
app.BankKeeper,
)
app.MarketMakerKeeper = marketmakerkeeper.NewKeeper(
appCodec,
keys[marketmakertypes.StoreKey],
app.GetSubspace(marketmakertypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
)

// register the proposal types
govRouter := govtypes.NewRouter()
Expand All @@ -438,7 +454,8 @@ func NewApp(
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(farmingtypes.RouterKey, farming.NewPublicPlanProposalHandler(app.FarmingKeeper))
AddRoute(farmingtypes.RouterKey, farming.NewPublicPlanProposalHandler(app.FarmingKeeper)).
AddRoute(marketmakertypes.RouterKey, marketmaker.NewMarketMakerProposalHandler(app.MarketMakerKeeper))

app.GovKeeper = govkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -538,6 +555,7 @@ func NewApp(
farming.NewAppModule(appCodec, app.FarmingKeeper, app.AccountKeeper, app.BankKeeper),
liquidstaking.NewAppModule(appCodec, app.LiquidStakingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GovKeeper),
claim.NewAppModule(appCodec, app.ClaimKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.GovKeeper, app.LiquidityKeeper, app.LiquidStakingKeeper),
marketmaker.NewAppModule(appCodec, app.MarketMakerKeeper, app.AccountKeeper, app.BankKeeper),
app.transferModule,
)

Expand Down Expand Up @@ -571,6 +589,7 @@ func NewApp(
ibctransfertypes.ModuleName,
farmingtypes.ModuleName,
claimtypes.ModuleName,
marketmakertypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
// EndBlocker of crisis module called AssertInvariants
Expand Down Expand Up @@ -599,6 +618,7 @@ func NewApp(
ibctransfertypes.ModuleName,
claimtypes.ModuleName,
budgettypes.ModuleName,
marketmakertypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -626,6 +646,7 @@ func NewApp(
liquiditytypes.ModuleName,
liquidstakingtypes.ModuleName,
claimtypes.ModuleName,
marketmakertypes.ModuleName,

// empty logic modules
paramstypes.ModuleName,
Expand Down Expand Up @@ -665,6 +686,7 @@ func NewApp(
liquidity.NewAppModule(appCodec, app.LiquidityKeeper, app.AccountKeeper, app.BankKeeper),
liquidstaking.NewAppModule(appCodec, app.LiquidStakingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GovKeeper),
claim.NewAppModule(appCodec, app.ClaimKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.GovKeeper, app.LiquidityKeeper, app.LiquidStakingKeeper),
marketmaker.NewAppModule(appCodec, app.MarketMakerKeeper, app.AccountKeeper, app.BankKeeper),
ibc.NewAppModule(app.IBCKeeper),
app.transferModule,
)
Expand Down Expand Up @@ -869,6 +891,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(farmingtypes.ModuleName)
paramsKeeper.Subspace(liquiditytypes.ModuleName)
paramsKeeper.Subspace(liquidstakingtypes.ModuleName)
paramsKeeper.Subspace(marketmakertypes.ModuleName)

return paramsKeeper
}
Expand Down
4 changes: 4 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/crescent-network/crescent/v2/x/farming"
"github.com/crescent-network/crescent/v2/x/liquidity"
"github.com/crescent-network/crescent/v2/x/liquidstaking"
"github.com/crescent-network/crescent/v2/x/marketmaker"
"github.com/crescent-network/crescent/v2/x/mint"
)

Expand Down Expand Up @@ -191,6 +192,8 @@ func TestRunMigrations(t *testing.T) {
"farming": farming.AppModule{}.ConsensusVersion(),
"liquidity": liquidity.AppModule{}.ConsensusVersion(),
"liquidstaking": liquidstaking.AppModule{}.ConsensusVersion(),
"claim": claim.AppModule{}.ConsensusVersion(),
"marketmaker": marketmaker.AppModule{}.ConsensusVersion(),
"ibc": ibc.AppModule{}.ConsensusVersion(),
"transfer": transfer.AppModule{}.ConsensusVersion(),
},
Expand Down Expand Up @@ -250,6 +253,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"liquidity": liquidity.AppModule{}.ConsensusVersion(),
"liquidstaking": liquidstaking.AppModule{}.ConsensusVersion(),
"claim": claim.AppModule{}.ConsensusVersion(),
"marketmaker": marketmaker.AppModule{}.ConsensusVersion(),
"ibc": ibc.AppModule{}.ConsensusVersion(),
"transfer": transfer.AppModule{}.ConsensusVersion(),
},
Expand Down
7 changes: 7 additions & 0 deletions app/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ const (
DefaultWeightTallyWithLiquidStaking int = 30

DefaultWeightMsgClaim int = 50

DefaultWeightMsgApplyMarketMaker int = 20
DefaultWeightMsgClaimIncentives int = 10

DefaultWeightMarketMakerProposal int = 20
DefaultWeightChangeIncentivePairs int = 5
DefaultWeightChangeDepositAmount int = 2
)
2 changes: 2 additions & 0 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
farmingtypes "github.com/crescent-network/crescent/v2/x/farming/types"
liquiditytypes "github.com/crescent-network/crescent/v2/x/liquidity/types"
liquidstakingtypes "github.com/crescent-network/crescent/v2/x/liquidstaking/types"
marketmakertypes "github.com/crescent-network/crescent/v2/x/marketmaker/types"
minttypes "github.com/crescent-network/crescent/v2/x/mint/types"
)

Expand Down Expand Up @@ -191,6 +192,7 @@ func TestAppImportExport(t *testing.T) {
{app.keys[liquidstakingtypes.StoreKey], newApp.keys[liquidstakingtypes.StoreKey], [][]byte{}},
{app.keys[liquiditytypes.StoreKey], newApp.keys[liquiditytypes.StoreKey], [][]byte{}},
{app.keys[claimtypes.StoreKey], newApp.keys[claimtypes.StoreKey], [][]byte{}},
{app.keys[marketmakertypes.StoreKey], newApp.keys[marketmakertypes.StoreKey], [][]byte{}},
{app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}},
{app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}},
}
Expand Down
10 changes: 9 additions & 1 deletion client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Crescent REST and gRPC Gateway docs",
"description": "A REST interface for state queries, transactions",
"version": "2.0.0"
"version": "3.0.0"
},
"apis": [
{
Expand Down Expand Up @@ -52,6 +52,14 @@
"Params": "ClaimParams"
}
}
},
{
"url": "./tmp-swagger-gen/crescent/marketmaker/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "MarketMakerParams"
}
}
}
]
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit a79db33

Please sign in to comment.