Skip to content

Commit

Permalink
add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik340 committed Jun 2, 2022
2 parents ef6d198 + 8aa903c commit 0031eeb
Show file tree
Hide file tree
Showing 239 changed files with 56,052 additions and 4,053 deletions.
45 changes: 40 additions & 5 deletions .scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,45 @@ rm -rf ~/.comdex
mkdir ~/.comdex

comdex init --chain-id test test
comdex keys add test --recover<<<"y
comdex keys add test --recover --keyring-backend test<<<"y
wage thunder live sense resemble foil apple course spin horse glass mansion midnight laundry acoustic rhythm loan scale talent push green direct brick please"
comdex add-genesis-account test 100000000000000stake
comdex gentx test 1000000000stake --chain-id test
comdex add-genesis-account test 100000000000000stake --keyring-backend test
comdex gentx test 1000000000stake --chain-id test --keyring-backend test
comdex collect-gentxs
# Make sure to add the admin account address in params after running this script and before starting the chain.
# use this account to generate assets and asset pairs
comdex start

comdex tx gov submit-proposal add-app-mapping composite com 10000 1000000 --title "Adding New Assets" --description "adding cmdx and atom" --deposit 1000000000stake --from test --chain-id test --keyring-backend test --gas auto -y

comdex tx gov vote 1 --from test --chain-id test --keyring-backend test --gas auto -y

# wait for proposal to pass
comdex tx gov submit-proposal add-assets CMDX,OSMO,ATOM,CMST,HARBOR ucmdx,uosmo,uatom,ucmst,uharbor 1000000,1000000,1000000,1000000,1000000 1,1,1,1,0 --title "Adding New Assets" --description "adding cmdx and atom" --deposit 1000000000stake --from test --chain-id test --keyring-backend test --gas auto -y

comdex tx gov vote 2 --from test --chain-id test --keyring-backend test --gas auto -y

# wait for proposal to pass
comdex tx gov submit-proposal add-pairs 1,1,1,1 2,3,4,5 --title "Adding New Assets" --description "adding cmdx and atom" --deposit 1000000000stake --from test --chain-id test --keyring-backend test --gas auto -y

comdex tx gov vote 3 --from test --chain-id test --keyring-backend test --gas auto -y

# wait for proposal to pass
comdex tx gov submit-proposal add-pairs-vault 1 1 1.4 0.1 0.01 0.0013 0.01 1 1000000 10000 0 1.5 CMDX-A 0 1 --title addAsset --description addingAsset --from test --deposit 10000000stake --chain-id test --keyring-backend test -y

comdex tx gov vote 4 --from test --chain-id test --keyring-backend test --gas auto -y

# wait for proposal to pass
comdex tx gov submit-proposal add-asset-mapping 1 1 10000 1 comdex1pkkayn066msg6kn33wnl5srhdt3tnu2v9jjqu0 --title "Adding New Assets" --description "adding cmdx and atom" --deposit 1000000000stake --from test --chain-id test --keyring-backend test --gas auto

comdex tx gov vote 5 --from test --chain-id test --keyring-backend test --gas auto -y

# wait for proposal to pass
comdex tx liquidation whitelist-app-id 1 --from test --chain-id test --keyring-backend test -y

# create vault
comdex tx locker whitelist-asset-locker 0 1 --from test --chain-id test --keyring-backend test -y

# whitelist asset locker
comdex tx vault create 1 1 5000 10000 --from test --chain-id test --keyring-backend test -y

#mint cmst
comdex tx tokenmint tokenmint 1 1 --from test --chain-id test --keyring-backend test -y
101 changes: 73 additions & 28 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package app

import (
"io"
"os"
"path/filepath"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/comdex-official/comdex/x/liquidation"
liquidationkeeper "github.com/comdex-official/comdex/x/liquidation/keeper"
Expand Down Expand Up @@ -43,6 +47,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
freegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
Expand Down Expand Up @@ -84,9 +89,6 @@ import (
tmos "github.com/tendermint/tendermint/libs/os"
tmprototypes "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"
"io"
"os"
"path/filepath"

"github.com/comdex-official/comdex/x/asset"
assetclient "github.com/comdex-official/comdex/x/asset/client"
Expand Down Expand Up @@ -133,6 +135,14 @@ import (
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"

"github.com/comdex-official/comdex/x/liquidity"
liquiditykeeper "github.com/comdex-official/comdex/x/liquidity/keeper"
liquiditytypes "github.com/comdex-official/comdex/x/liquidity/types"

"github.com/comdex-official/comdex/x/locking"
lockingkeeper "github.com/comdex-official/comdex/x/locking/keeper"
lockingtypes "github.com/comdex-official/comdex/x/locking/types"

cwasm "github.com/comdex-official/comdex/app/wasm"
)

Expand Down Expand Up @@ -183,14 +193,16 @@ var (
lend.AppModuleBasic{},

market.AppModuleBasic{},
rewards.AppModuleBasic{},
locker.AppModuleBasic{},
bandoraclemodule.AppModuleBasic{},
collector.AppModuleBasic{},
liquidation.AppModuleBasic{},
auction.AppModuleBasic{},
tokenmint.AppModuleBasic{},
wasm.AppModuleBasic{},
liquidity.AppModuleBasic{},
locking.AppModuleBasic{},
rewards.AppModuleBasic{},
)
)

Expand Down Expand Up @@ -256,12 +268,14 @@ type App struct {

marketKeeper marketkeeper.Keeper
liquidationKeeper liquidationkeeper.Keeper
rewardskeeper rewardskeeper.Keeper
lockerKeeper lockerkeeper.Keeper
lendKeeper lendkeeper.Keeper
scopedWasmKeeper capabilitykeeper.ScopedKeeper
auctionKeeper auctionkeeper.Keeper
tokenmintKeeper tokenmintkeeper.Keeper
liquidityKeeper liquiditykeeper.Keeper
lockingKeeper lockingkeeper.Keeper
rewardskeeper rewardskeeper.Keeper

wasmKeeper wasm.Keeper
// the module manager
Expand Down Expand Up @@ -294,8 +308,9 @@ func New(
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
vaulttypes.StoreKey, assettypes.StoreKey, collectortypes.StoreKey, liquidationtypes.StoreKey,
lendtypes.StoreKey, markettypes.StoreKey, rewardstypes.StoreKey, bandoraclemoduletypes.StoreKey, lockertypes.StoreKey, wasm.StoreKey, authzkeeper.StoreKey,
auctiontypes.StoreKey, tokenminttypes.StoreKey,
lendtypes.StoreKey, markettypes.StoreKey, bandoraclemoduletypes.StoreKey, lockertypes.StoreKey,
wasm.StoreKey, authzkeeper.StoreKey, auctiontypes.StoreKey, tokenminttypes.StoreKey,
liquiditytypes.StoreKey, lockingtypes.StoreKey, rewardstypes.StoreKey, feegrant.StoreKey,
)
)

Expand Down Expand Up @@ -340,12 +355,14 @@ func New(
app.paramsKeeper.Subspace(lendtypes.ModuleName)
app.paramsKeeper.Subspace(markettypes.ModuleName)
app.paramsKeeper.Subspace(liquidationtypes.ModuleName)
app.paramsKeeper.Subspace(rewardstypes.ModuleName)
app.paramsKeeper.Subspace(lockertypes.ModuleName)
app.paramsKeeper.Subspace(bandoraclemoduletypes.ModuleName)
app.paramsKeeper.Subspace(wasmtypes.ModuleName)
app.paramsKeeper.Subspace(auctiontypes.ModuleName)
app.paramsKeeper.Subspace(tokenminttypes.ModuleName)
app.paramsKeeper.Subspace(liquiditytypes.ModuleName)
app.paramsKeeper.Subspace(lockingtypes.ModuleName)
app.paramsKeeper.Subspace(rewardstypes.ModuleName)

// set the BaseApp's parameter store
baseApp.SetParamStore(
Expand Down Expand Up @@ -550,18 +567,6 @@ func New(
&app.tokenmintKeeper,
)

app.rewardskeeper = *rewardskeeper.NewKeeper(
app.cdc,
app.keys[rewardstypes.StoreKey],
app.keys[rewardstypes.MemStoreKey],
app.GetSubspace(rewardstypes.ModuleName),
&app.lockerKeeper,
&app.collectorKeeper,
&app.vaultKeeper,
&app.assetKeeper,
app.bankKeeper,
)

app.collectorKeeper = *collectorkeeper.NewKeeper(
app.cdc,
app.keys[collectortypes.StoreKey],
Expand Down Expand Up @@ -594,11 +599,41 @@ func New(
&app.collectorKeeper,
)

app.liquidityKeeper = liquiditykeeper.NewKeeper(
app.cdc,
app.keys[liquiditytypes.StoreKey],
app.GetSubspace(liquiditytypes.ModuleName),
app.accountKeeper,
app.bankKeeper,
&app.rewardskeeper,
)

app.lockingKeeper = lockingkeeper.NewKeeper(
app.cdc,
app.keys[lockingtypes.StoreKey],
app.GetSubspace(lockingtypes.ModuleName),
app.accountKeeper,
app.bankKeeper,
)

app.rewardskeeper = *rewardskeeper.NewKeeper(
app.cdc,
app.keys[rewardstypes.StoreKey],
app.keys[rewardstypes.MemStoreKey],
app.GetSubspace(rewardstypes.ModuleName),
&app.lockerKeeper,
&app.collectorKeeper,
&app.vaultKeeper,
&app.assetKeeper,
app.bankKeeper,
app.liquidityKeeper,
)

wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOptions)
supportedFeatures := "iterator,staking,stargate,comdex"

wasmOpts = append(cwasm.RegisterCustomPlugins(&app.lockerKeeper, &app.tokenmintKeeper, &app.assetKeeper), wasmOpts...)
wasmOpts = append(cwasm.RegisterCustomPlugins(&app.lockerKeeper, &app.tokenmintKeeper, &app.assetKeeper, &app.rewardskeeper, &app.collectorKeeper), wasmOpts...)

app.wasmKeeper = wasmkeeper.NewKeeper(
app.cdc,
Expand Down Expand Up @@ -698,11 +733,13 @@ func New(
liquidation.NewAppModule(app.cdc, app.liquidationKeeper, app.accountKeeper, app.bankKeeper),
locker.NewAppModule(app.cdc, app.lockerKeeper, app.accountKeeper, app.bankKeeper),
collector.NewAppModule(app.cdc, app.collectorKeeper, app.accountKeeper, app.bankKeeper),
rewards.NewAppModule(app.cdc, app.rewardskeeper, app.accountKeeper, app.bankKeeper),
lend.NewAppModule(app.cdc, app.lendKeeper, app.accountKeeper, app.bankKeeper),
wasm.NewAppModule(app.cdc, &app.wasmKeeper, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
auction.NewAppModule(app.cdc, app.auctionKeeper, app.accountKeeper, app.bankKeeper),
tokenmint.NewAppModule(app.cdc, app.tokenmintKeeper, app.accountKeeper, app.bankKeeper),
liquidity.NewAppModule(app.cdc, app.liquidityKeeper, app.accountKeeper, app.bankKeeper),
locking.NewAppModule(app.cdc, app.lockingKeeper, app.accountKeeper, app.bankKeeper),
rewards.NewAppModule(app.cdc, app.rewardskeeper, app.accountKeeper, app.bankKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -712,18 +749,22 @@ func New(
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
bandoraclemoduletypes.ModuleName, markettypes.ModuleName, rewardstypes.ModuleName, lockertypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, authtypes.ModuleName, capabilitytypes.ModuleName,
authz.ModuleName, transferModule.Name(), assettypes.ModuleName, collectortypes.ModuleName, vaulttypes.ModuleName, liquidationtypes.ModuleName, auctiontypes.ModuleName, tokenminttypes.ModuleName,
lendtypes.ModuleName, vesting.AppModuleBasic{}.Name(), paramstypes.ModuleName, wasmtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName,
bandoraclemoduletypes.ModuleName, markettypes.ModuleName, lockertypes.ModuleName,
crisistypes.ModuleName, genutiltypes.ModuleName, authtypes.ModuleName, capabilitytypes.ModuleName,
authz.ModuleName, transferModule.Name(), assettypes.ModuleName, collectortypes.ModuleName, vaulttypes.ModuleName,
liquidationtypes.ModuleName, auctiontypes.ModuleName, tokenminttypes.ModuleName, lendtypes.ModuleName,
vesting.AppModuleBasic{}.Name(), paramstypes.ModuleName, wasmtypes.ModuleName, banktypes.ModuleName,
govtypes.ModuleName, liquiditytypes.ModuleName, lockingtypes.ModuleName, rewardstypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName,
minttypes.ModuleName, bandoraclemoduletypes.ModuleName, markettypes.ModuleName, rewardstypes.ModuleName, lockertypes.ModuleName,
minttypes.ModuleName, bandoraclemoduletypes.ModuleName, markettypes.ModuleName, lockertypes.ModuleName,
distrtypes.ModuleName, genutiltypes.ModuleName, vesting.AppModuleBasic{}.Name(), evidencetypes.ModuleName, ibchost.ModuleName,
vaulttypes.ModuleName, liquidationtypes.ModuleName, auctiontypes.ModuleName, tokenminttypes.ModuleName, lendtypes.ModuleName, wasmtypes.ModuleName, authtypes.ModuleName, slashingtypes.ModuleName, authz.ModuleName,
paramstypes.ModuleName, capabilitytypes.ModuleName, upgradetypes.ModuleName, transferModule.Name(),
assettypes.ModuleName, collectortypes.ModuleName, banktypes.ModuleName,
liquiditytypes.ModuleName, lockingtypes.ModuleName, rewardstypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -755,13 +796,15 @@ func New(
markettypes.ModuleName,
liquidationtypes.ModuleName,
auctiontypes.ModuleName,
rewardstypes.ModuleName,
lockertypes.StoreKey,
wasmtypes.ModuleName,
authz.ModuleName,
vesting.AppModuleBasic{}.Name(),
upgradetypes.ModuleName,
paramstypes.ModuleName,
liquiditytypes.ModuleName,
lockingtypes.ModuleName,
rewardstypes.ModuleName,
)

app.mm.RegisterInvariants(&app.crisisKeeper)
Expand Down Expand Up @@ -950,9 +993,11 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {
lendtypes.ModuleAcc3: {authtypes.Minter, authtypes.Burner},
liquidationtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
auctiontypes.ModuleName: {authtypes.Minter, authtypes.Burner},
rewardstypes.ModuleName: {authtypes.Minter, authtypes.Burner},
lockertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasm.ModuleName: {authtypes.Burner},
liquiditytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
lockingtypes.ModuleName: nil,
rewardstypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}
}
func (app *App) registerUpgradeHandlers() {
Expand Down
79 changes: 77 additions & 2 deletions app/wasm/bindings/msg.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,85 @@
package bindings

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

type ComdexMessages struct {
WhiteListAssetLocker WhiteListAssetLocker `json:"white_list_asset_locker,omitempty"`
MsgWhiteListAssetLocker *MsgWhiteListAssetLocker `json:"msg_white_list_asset_locker,omitempty"`
MsgWhitelistAppIdVaultInterest *MsgWhitelistAppIdVaultInterest `json:"msg_whitelist_app_id_vault_interest,omitempty"`
MsgWhitelistAppIdLockerRewards *MsgWhitelistAppIdLockerRewards `json:"msg_whitelist_app_id_locker_rewards,omitempty"`
MsgAddExtendedPairsVault *MsgAddExtendedPairsVault `json:"msg_add_extended_pairs_vault,omitempty"`
MsgSetCollectorLookupTable *MsgSetCollectorLookupTable `json:"msg_set_collector_lookup_table,omitempty"`
MsgSetAuctionMappingForApp *MsgSetAuctionMappingForApp `json:"msg_set_auction_mapping_for_app,omitempty"`
MsgUpdateLsrInPairsVault *MsgUpdateLsrInPairsVault `json:"msg_update_lsr_in_pairs_vault,omitempty"`
MsgUpdateLsrInCollectorLookupTable *MsgUpdateLsrInCollectorLookupTable `json:"msg_update_lsr_in_collector_lookup_table,omitempty"`
}

type WhiteListAssetLocker struct {
type MsgWhiteListAssetLocker struct {
AppMappingId uint64 `json:"app_mapping_id"`
AssetId uint64 `json:"asset_id"`
}

type MsgWhitelistAppIdVaultInterest struct {
AppMappingId uint64 `json:"app_mapping_id"`
}

type MsgWhitelistAppIdLockerRewards struct {
AppMappingId uint64 `json:"app_mapping_id"`
AssetId []uint64 `json:"asset_id"`
}

type MsgAddExtendedPairsVault struct {
AppMappingId uint64 `json:"app_mapping_id"`
PairId uint64 `json:"pair_id"`
LiquidationRatio sdk.Dec `json:"liquidation_ratio"`
StabilityFee sdk.Dec `json:"stability_fee"`
ClosingFee sdk.Dec `json:"closing_fee"`
LiquidationPenalty sdk.Dec `json:"liquidation_penalty"`
DrawDownFee sdk.Dec `json:"draw_down_fee"`
IsVaultActive bool `json:"is_vault_active"`
DebtCeiling uint64 `json:"debt_ceiling"`
DebtFloor uint64 `json:"debt_floor"`
IsPsmPair bool `json:"is_psm_pair"`
MinCr sdk.Dec `json:"min_cr"`
PairName string `json:"pair_name"`
AssetOutOraclePrice bool `json:"asset_out_oracle_price"`
AssetOutPrice uint64 `json:"asset_out_price"`
}

type MsgSetCollectorLookupTable struct {
AppMappingId uint64 `json:"app_mapping_id"`
CollectorAssetId uint64 `json:"collector_asset_id"`
SecondaryAssetId uint64 `json:"secondary_asset_id"`
SurplusThreshold uint64 `json:"surplus_threshold"`
DebtThreshold uint64 `json:"debt_threshold"`
LockerSavingRate sdk.Dec `json:"locker_saving_rate"`
LotSize uint64 `json:"lot_size"`
BidFactor sdk.Dec `json:"bid_factor"`
}

type MsgSetAuctionMappingForApp struct {
AppMappingId uint64 `json:"app_mapping_id"`
AssetId []uint64 `json:"asset_id"`
IsSurplusAuction []bool `json:"is_surplus_auction"`
IsDebtAuction []bool `json:"is_debt_auction"`
}

type MsgUpdateLsrInPairsVault struct {
AppMappingId uint64 `json:"app_mapping_id"`
ExtPairId uint64 `json:"ext_pair_id"`
LiquidationRatio sdk.Dec `json:"liquidation_ratio"`
StabilityFee sdk.Dec `json:"stability_fee"`
ClosingFee sdk.Dec `json:"closing_fee"`
LiquidationPenalty sdk.Dec `json:"liquidation_penalty"`
DrawDownFee sdk.Dec `json:"draw_down_fee"`
MinCr sdk.Dec `json:"min_cr"`
DebtCeiling uint64 `json:"debt_ceiling"`
DebtFloor uint64 `json:"debt_floor"`
}

type MsgUpdateLsrInCollectorLookupTable struct {
AppMappingId uint64 `json:"app_mapping_id"`
AssetId uint64 `json:"asset_id"`
LSR sdk.Dec `json:"lsr"`
}
Loading

0 comments on commit 0031eeb

Please sign in to comment.