Skip to content

Commit

Permalink
Merge pull request #492 from comdex-official/feature/dev
Browse files Browse the repository at this point in the history
Feature/dev
  • Loading branch information
dheerajkd30 authored Oct 8, 2022
2 parents 6f92e9a + 1f0c15f commit 7361489
Show file tree
Hide file tree
Showing 94 changed files with 10,567 additions and 13,020 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ jobs:
labeler:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].0
- uses: actions/[email protected].2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
11 changes: 8 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ func GetGovProposalHandlers() []govclient.ProposalHandler {
bandoraclemoduleclient.AddFetchPriceHandler,
lendclient.AddLendPairsHandler,
lendclient.AddPoolHandler,
lendclient.UpdateLendPairsHandler,
lendclient.AddAssetToPairHandler,
lendclient.AddAssetRatesStatsHandler,
lendclient.AddAssetRatesParamsHandler,
lendclient.AddAuctionParamsHandler,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
Expand Down Expand Up @@ -553,6 +554,7 @@ func New(
&app.MarketKeeper,
&app.Rewardskeeper,
&app.VaultKeeper,
&app.BandoracleKeeper,
)

app.LendKeeper = lendkeeper.NewKeeper(
Expand Down Expand Up @@ -723,6 +725,7 @@ func New(
app.LiquidityKeeper,
&app.MarketKeeper,
&app.EsmKeeper,
&app.LendKeeper,
)

wasmDir := filepath.Join(homePath, "wasm")
Expand Down Expand Up @@ -1141,8 +1144,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {

func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
tv4_0_0.UpgradeNameV4_3_0,
tv4_0_0.CreateUpgradeHandlerV430(a.mm, a.configurator, a.AssetKeeper),
tv4_0_0.UpgradeNameV4_4_0,
tv4_0_0.CreateUpgradeHandlerV440(a.mm, a.configurator, a.LendKeeper, a.LiquidationKeeper, a.AuctionKeeper),
)

// When a planned update height is reached, the old binary will panic
Expand Down Expand Up @@ -1218,6 +1221,8 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades *
storeUpgrades = &storetypes.StoreUpgrades{}
case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_3_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}
case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_4_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height):
storeUpgrades = &storetypes.StoreUpgrades{}
}
return storeUpgrades
}
14 changes: 14 additions & 0 deletions app/upgrades/testnet/v4_0_0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ const (
}
}'`
)

const (
UpgradeNameV4_4_0 = "v4.4.0.beta"
UpgradeHeightV4_4_0 = "" // replace this height
UpgradeInfoV4_4_0 = `'{
"binaries": {
"darwin/arm64":"",
"darwin/x86_64":"",
"linux/arm64":"",
"linux/x86_64":"",
"windows/x86_64":""
}
}'`
)
39 changes: 39 additions & 0 deletions app/upgrades/testnet/v4_0_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package v4_0_0

import (
auctionkeeper "github.com/comdex-official/comdex/x/auction/keeper"
lendkeeper "github.com/comdex-official/comdex/x/lend/keeper"
liquidationkeeper "github.com/comdex-official/comdex/x/liquidation/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand Down Expand Up @@ -122,3 +125,39 @@ func CreateUpgradeHandlerV430(
return newVM, err
}
}

func UpdateDutchLendAuctions(
ctx sdk.Context,
liquidationkeeper liquidationkeeper.Keeper,
auctionkeeper auctionkeeper.Keeper,
) {
lockedVaults := liquidationkeeper.GetLockedVaults(ctx)
for _, v := range lockedVaults {
if v.Kind != nil {
err := auctionkeeper.LendDutchActivator(ctx, v)
if err != nil {
return
}
}
}
}

// CreateUpgradeHandler creates an SDK upgrade handler for v4_4_0
func CreateUpgradeHandlerV440(
mm *module.Manager,
configurator module.Configurator,
lendkeeper lendkeeper.Keeper,
liquidationkeeper liquidationkeeper.Keeper,
auctionkeeper auctionkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// This change is only for testnet upgrade

UpdateDutchLendAuctions(ctx, liquidationkeeper, auctionkeeper)
newVM, err := mm.RunMigrations(ctx, configurator, fromVM)
if err != nil {
return newVM, err
}
return newVM, err
}
}
1 change: 1 addition & 0 deletions app/wasm/bindings/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type MsgUpdatePairsVault struct {
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"`
MinCr sdk.Dec `json:"min_cr"`
DebtCeiling uint64 `json:"debt_ceiling"`
DebtFloor uint64 `json:"debt_floor"`
Expand Down
4 changes: 2 additions & 2 deletions proto/comdex/asset/v1beta1/app.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ message AppData {
(gogoproto.moretags) = "yaml:\"min_gov_deposit\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false];
double gov_time_in_seconds = 5 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""];
uint64 gov_time_in_seconds = 5 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""];
repeated MintGenesisToken genesis_token = 6 [(gogoproto.moretags) = "yaml:\"genesis_token\"",
(gogoproto.nullable) = false];
}
Expand All @@ -30,7 +30,7 @@ message MintGenesisToken {

message AppAndGovTime {
uint64 app_id = 1 [(gogoproto.moretags) = "yaml:\"app_id\""];
double gov_time_in_seconds = 2 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""];
uint64 gov_time_in_seconds = 2 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""];
string min_gov_deposit = 3 [
(gogoproto.moretags) = "yaml:\"min_gov_deposit\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
Expand Down
4 changes: 0 additions & 4 deletions proto/comdex/bandoracle/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import "comdex/bandoracle/v1beta1/fetch_price.proto";

option go_package = "github.com/comdex-official/comdex/x/bandoracle/types";

service Msg {
rpc FetchPriceData(MsgFetchPriceData) returns (MsgFetchPriceDataResponse);
}

message MsgFetchPriceData {
string creator = 1;
uint64 oracle_script_id = 2 [
Expand Down
78 changes: 39 additions & 39 deletions proto/comdex/lend/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,44 @@ import "comdex/lend/v1beta1/params.proto";
option go_package = "github.com/comdex-official/comdex/x/lend/types";

message GenesisState {
repeated BorrowAsset borrowAsset = 1
[ (gogoproto.moretags) = "yaml:\"borrowAsset\"", (gogoproto.nullable) = false ];
repeated UserBorrowIdMapping userBorrowIdMapping = 2
[ (gogoproto.moretags) = "yaml:\"userBorrowIdMapping\"", (gogoproto.nullable) = false ];
repeated BorrowIdByOwnerAndPoolMapping borrowIdByOwnerAndPoolMapping = 3
[ (gogoproto.moretags) = "yaml:\"borrowIdByOwnerAndPoolMapping\"", (gogoproto.nullable) = false ];
BorrowMapping borrowMapping = 4
[ (gogoproto.moretags) = "yaml:\"borrowMapping\"", (gogoproto.nullable) = false ];
repeated LendAsset lendAsset = 5
[ (gogoproto.moretags) = "yaml:\"lendAsset\"", (gogoproto.nullable) = false ];
repeated Pool pool = 6
[ (gogoproto.moretags) = "yaml:\"pool\"", (gogoproto.nullable) = false ];
repeated AssetToPairMapping assetToPairMapping = 7
[ (gogoproto.moretags) = "yaml:\"assetToPairMapping\"", (gogoproto.nullable) = false ];
repeated UserLendIdMapping userLendIdMapping = 8
[ (gogoproto.moretags) = "yaml:\"userLendIdMapping\"", (gogoproto.nullable) = false ];
repeated LendIdByOwnerAndPoolMapping lendIdByOwnerAndPoolMapping = 9
[ (gogoproto.moretags) = "yaml:\"lendIdByOwnerAndPoolMapping\"", (gogoproto.nullable) = false ];
repeated LendIdToBorrowIdMapping lendIdToBorrowIdMapping = 10
[ (gogoproto.moretags) = "yaml:\"lendIdToBorrowIdMapping\"", (gogoproto.nullable) = false ];
repeated AssetStats assetStats = 11
[ (gogoproto.moretags) = "yaml:\"assetStats\"", (gogoproto.nullable) = false ];
LendMapping lendMapping = 12
[ (gogoproto.moretags) = "yaml:\"lendMapping\"", (gogoproto.nullable) = false ];
DepositStats userDepositStats = 13
[ (gogoproto.moretags) = "yaml:\"userDepositStats\"", (gogoproto.nullable) = false ];
DepositStats reserveDepositStats = 14
[ (gogoproto.moretags) = "yaml:\"reserveDepositStats\"", (gogoproto.nullable) = false ];
DepositStats buyBackDepositStats = 15
[ (gogoproto.moretags) = "yaml:\"buyBackDepositStats\"", (gogoproto.nullable) = false ];
DepositStats borrowDepositStats = 16
[ (gogoproto.moretags) = "yaml:\"borrowDepositStats\"", (gogoproto.nullable) = false ];
repeated Extended_Pair extended_Pair = 17
[ (gogoproto.moretags) = "yaml:\"extended_Pair\"", (gogoproto.nullable) = false ];
repeated AssetRatesStats assetRatesStats = 18
[ (gogoproto.moretags) = "yaml:\"assetRatesStats\"", (gogoproto.nullable) = false ];
repeated AuctionParams auctionParams = 19
[ (gogoproto.moretags) = "yaml:\"auctionParams\"", (gogoproto.nullable) = false ];
Params params = 20 [(gogoproto.nullable) = false];
// repeated BorrowAsset borrowAsset = 1
// [ (gogoproto.moretags) = "yaml:\"borrowAsset\"", (gogoproto.nullable) = false ];
// repeated UserBorrowIdMapping userBorrowIdMapping = 2
// [ (gogoproto.moretags) = "yaml:\"userBorrowIdMapping\"", (gogoproto.nullable) = false ];
// repeated BorrowIdByOwnerAndPoolMapping borrowIdByOwnerAndPoolMapping = 3
// [ (gogoproto.moretags) = "yaml:\"borrowIdByOwnerAndPoolMapping\"", (gogoproto.nullable) = false ];
// BorrowMapping borrowMapping = 4
// [ (gogoproto.moretags) = "yaml:\"borrowMapping\"", (gogoproto.nullable) = false ];
// repeated LendAsset lendAsset = 5
// [ (gogoproto.moretags) = "yaml:\"lendAsset\"", (gogoproto.nullable) = false ];
// repeated Pool pool = 6
// [ (gogoproto.moretags) = "yaml:\"pool\"", (gogoproto.nullable) = false ];
// repeated AssetToPairMapping assetToPairMapping = 7
// [ (gogoproto.moretags) = "yaml:\"assetToPairMapping\"", (gogoproto.nullable) = false ];
// repeated UserLendIdMapping userLendIdMapping = 8
// [ (gogoproto.moretags) = "yaml:\"userLendIdMapping\"", (gogoproto.nullable) = false ];
// repeated LendIdByOwnerAndPoolMapping lendIdByOwnerAndPoolMapping = 9
// [ (gogoproto.moretags) = "yaml:\"lendIdByOwnerAndPoolMapping\"", (gogoproto.nullable) = false ];
// repeated LendIdToBorrowIdMapping lendIdToBorrowIdMapping = 10
// [ (gogoproto.moretags) = "yaml:\"lendIdToBorrowIdMapping\"", (gogoproto.nullable) = false ];
// repeated AssetStats assetStats = 11
// [ (gogoproto.moretags) = "yaml:\"assetStats\"", (gogoproto.nullable) = false ];
// LendMapping lendMapping = 12
// [ (gogoproto.moretags) = "yaml:\"lendMapping\"", (gogoproto.nullable) = false ];
// DepositStats userDepositStats = 13
// [ (gogoproto.moretags) = "yaml:\"userDepositStats\"", (gogoproto.nullable) = false ];
// DepositStats reserveDepositStats = 14
// [ (gogoproto.moretags) = "yaml:\"reserveDepositStats\"", (gogoproto.nullable) = false ];
// DepositStats buyBackDepositStats = 15
// [ (gogoproto.moretags) = "yaml:\"buyBackDepositStats\"", (gogoproto.nullable) = false ];
// DepositStats borrowDepositStats = 16
// [ (gogoproto.moretags) = "yaml:\"borrowDepositStats\"", (gogoproto.nullable) = false ];
// repeated Extended_Pair extended_Pair = 17
// [ (gogoproto.moretags) = "yaml:\"extended_Pair\"", (gogoproto.nullable) = false ];
// repeated AssetRatesStats assetRatesStats = 18
// [ (gogoproto.moretags) = "yaml:\"assetRatesStats\"", (gogoproto.nullable) = false ];
// repeated AuctionParams auctionParams = 19
// [ (gogoproto.moretags) = "yaml:\"auctionParams\"", (gogoproto.nullable) = false ];
// Params params = 20 [(gogoproto.nullable) = false];

}
9 changes: 7 additions & 2 deletions proto/comdex/lend/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ message AddPoolsProposal {
string description = 2 [(gogoproto.moretags) = "yaml:\"description\""];
Pool Pool = 3 [(gogoproto.nullable) = false];
}
message UpdateLendPairsProposal {
string title = 1 [(gogoproto.moretags) = "yaml:\"title\""];
string description = 2 [(gogoproto.moretags) = "yaml:\"description\""];
Extended_Pair pairs = 3 [(gogoproto.nullable) = false];
}

message AddAssetToPairProposal {
string title = 1 [(gogoproto.moretags) = "yaml:\"title\""];
string description = 2 [(gogoproto.moretags) = "yaml:\"description\""];
AssetToPairMapping AssetToPairMapping = 3 [(gogoproto.nullable) = false];
}

message AddAssetRatesStats {
message AddAssetRatesParams {
string title = 1 [(gogoproto.moretags) = "yaml:\"title\""];
string description = 2 [(gogoproto.moretags) = "yaml:\"description\""];
AssetRatesStats AssetRatesStats = 3 [(gogoproto.nullable) = false];
AssetRatesParams AssetRatesParams = 3 [(gogoproto.nullable) = false];
}

message AddAuctionParamsProposal {
Expand Down
Loading

0 comments on commit 7361489

Please sign in to comment.