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

Feature/dev #419

Merged
merged 20 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ func New(
&app.MarketKeeper,
&app.AuctionKeeper,
&app.EsmKeeper,
&app.Rewardskeeper,
&app.LendKeeper,
)

Expand Down Expand Up @@ -1142,8 +1143,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {

func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
tv4_0_0.UpgradeName,
tv4_0_0.CreateUpgradeHandler(a.mm, a.configurator),
tv4_0_0.UpgradeNameV4_1_0,
tv4_0_0.CreateUpgradeHandlerV410(a.mm, a.configurator, a.Rewardskeeper, a.LiquidityKeeper),
)

// When a planned update height is reached, the old binary will panic
Expand Down Expand Up @@ -1211,6 +1212,8 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades *
Added: []string{vaulttypes.ModuleName, rewardstypes.ModuleName, liquidationtypes.ModuleName,
collectortypes.ModuleName, lockertypes.ModuleName, lendtypes.ModuleName, auctiontypes.ModuleName, esmtypes.ModuleName},
}
case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_1_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 @@ -13,3 +13,17 @@ const (
}
}'`
)

const (
UpgradeNameV4_1_0 = "v4.1.0"
UpgradeHeightV4_1_0 = "" // replace this height
UpgradeInfoV4_1_0 = `'{
"binaries": {
"darwin/arm64":"",
"darwin/x86_64":"",
"linux/arm64":"",
"linux/x86_64":"",
"windows/x86_64":""
}
}'`
)
52 changes: 52 additions & 0 deletions app/upgrades/testnet/v4_0_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package v4_0_0

import (
liquiditykeeper "github.com/comdex-official/comdex/x/liquidity/keeper"
liquiditytypes "github.com/comdex-official/comdex/x/liquidity/types"
rewardskeeper "github.com/comdex-official/comdex/x/rewards/keeper"
rewardstypes "github.com/comdex-official/comdex/x/rewards/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand All @@ -22,3 +26,51 @@ func CreateUpgradeHandler(
return newVM, err
}
}

func CreateSwapFeeGauge(
ctx sdk.Context,
rewardsKeeper rewardskeeper.Keeper,
liquidityKeeper liquiditykeeper.Keeper,
appID, poolID uint64,
) {
params, _ := liquidityKeeper.GetGenericParams(ctx, appID)
pool, _ := liquidityKeeper.GetPool(ctx, appID, poolID)
pair, _ := liquidityKeeper.GetPair(ctx, appID, pool.PairId)
newGauge := rewardstypes.NewMsgCreateGauge(
appID,
pair.GetSwapFeeCollectorAddress(),
ctx.BlockTime(),
rewardstypes.LiquidityGaugeTypeID,
liquiditytypes.DefaultSwapFeeDistributionDuration,
sdk.NewCoin(params.SwapFeeDistrDenom, sdk.NewInt(0)),
1,
)
newGauge.Kind = &rewardstypes.MsgCreateGauge_LiquidityMetaData{
LiquidityMetaData: &rewardstypes.LiquidtyGaugeMetaData{
PoolId: pool.Id,
IsMasterPool: false,
ChildPoolIds: []uint64{},
},
}
_ = rewardsKeeper.CreateNewGauge(ctx, newGauge, true)
}

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

CreateSwapFeeGauge(ctx, rewardskeeper, liquiditykeeper, 1, 1)
newVM, err := mm.RunMigrations(ctx, configurator, fromVM)

if err != nil {
return newVM, err
}
return newVM, err
}
}
19 changes: 19 additions & 0 deletions proto/comdex/auction/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,22 @@ message QueryDutchLendBiddingsResponse {
[(gogoproto.moretags) = "yaml:\"pagination\""];
}

message QueryFilterDutchAuctionsRequest {
uint64 app_id = 1;
string denom = 2;
bool history = 3;
cosmos.base.query.v1beta1.PageRequest pagination = 4
[(gogoproto.moretags) = "yaml:\"pagination\""];
}

message QueryFilterDutchAuctionsResponse {
repeated DutchAuction auctions = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"auctions\""
];
cosmos.base.query.v1beta1.PageResponse pagination = 2
[(gogoproto.moretags) = "yaml:\"pagination\""];
}

service Query {
rpc QuerySurplusAuction(QuerySurplusAuctionRequest) returns (QuerySurplusAuctionResponse) {
Expand Down Expand Up @@ -313,4 +329,7 @@ service Query {
rpc QueryDutchLendBiddings(QueryDutchLendBiddingsRequest) returns (QueryDutchLendBiddingsResponse) {
option (google.api.http).get = "/comdex/auction/v1beta1/dutchlendbiddings/{bidder}/{app_id}/{history}";
}
rpc QueryFilterDutchAuctions(QueryFilterDutchAuctionsRequest) returns (QueryFilterDutchAuctionsResponse) {
option (google.api.http).get = "/comdex/auction/v1beta1/filterdutchauctions/{app_id}/{denom}/{history}";
}
}
2 changes: 0 additions & 2 deletions proto/comdex/collector/v1beta1/collector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";


// this line is used by starport scaffolding # genesis/proto/import

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

message CollectorData {
Expand Down
4 changes: 1 addition & 3 deletions proto/comdex/collector/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ package comdex.collector.v1beta1;
import "gogoproto/gogo.proto";
import "comdex/collector/v1beta1/params.proto";
import "comdex/collector/v1beta1/collector.proto";
// this line is used by starport scaffolding # genesis/proto/import

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

// GenesisState defines the collector module's genesis state.
message GenesisState {
repeated AppAssetIdToFeeCollectedData netFeeCollectedData = 1
[ (gogoproto.moretags) = "yaml:\"netFeeCollectedData\"", (gogoproto.nullable) = false ];
Expand All @@ -21,5 +19,5 @@ message GenesisState {
repeated AppToDenomsMapping appToDenomsMapping = 5
[ (gogoproto.moretags) = "yaml:\"appToDenomsMapping\"", (gogoproto.nullable) = false ];
Params params = 6 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state

}
5 changes: 2 additions & 3 deletions proto/comdex/collector/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
syntax = "proto3";
package comdex.collector.v1beta1;

// this line is used by starport scaffolding # proto/tx/import

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

// Msg defines the Msg service.
service Msg {
// this line is used by starport scaffolding # proto/tx/rpc

}

// this line is used by starport scaffolding # proto/tx/message

45 changes: 0 additions & 45 deletions proto/comdex/esm/v1beta1/esm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,6 @@ message UsersDepositMapping{
];
}

message ESMMarketPrice{
uint64 appId = 1 [(gogoproto.moretags) = "yaml:\"appId\""];
bool isPriceSet = 2;
repeated Market market = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"amount_in\""
];
}

message Market {
uint64 asset_id = 1 [
(gogoproto.customname) = "AssetID",
(gogoproto.moretags) = "yaml:\"asset_id\""
];
uint64 rates = 2;
}

message DataAfterCoolOff {
uint64 appId = 1 [ (gogoproto.moretags) = "yaml:\"appId\"" ];
repeated AssetToAmount collateral_asset = 2 [
Expand Down Expand Up @@ -160,34 +143,6 @@ message AssetToAmount {
];
}

message AssetToAmountValue {
uint64 appId = 1 [ (gogoproto.moretags) = "yaml:\"appId\"" ];

uint64 asset_id = 2 [
(gogoproto.customname) = "AssetID",
(gogoproto.moretags) = "yaml:\"asset_id\""
];
string amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
string asset_value_to_app_value_ratio = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"asset_value_to_app_value_ratio\""
];
}

message AppToAmountValue {
uint64 appId = 1 [ (gogoproto.moretags) = "yaml:\"appId\"" ];
string amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
}

message DebtAssetsRates {
uint64 asset_id = 1 [
(gogoproto.customname) = "AssetID",
Expand Down
6 changes: 0 additions & 6 deletions proto/comdex/esm/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ message GenesisState {
[ (gogoproto.moretags) = "yaml:\"killSwitchParams\"", (gogoproto.nullable) = false ];
repeated UsersDepositMapping usersDepositMapping = 5
[ (gogoproto.moretags) = "yaml:\"usersDepositMapping\"", (gogoproto.nullable) = false ];
repeated ESMMarketPrice eSMMarketPrice = 6
[ (gogoproto.moretags) = "yaml:\"eSMMarketPrice\"", (gogoproto.nullable) = false ];
repeated DataAfterCoolOff dataAfterCoolOff = 7
[ (gogoproto.moretags) = "yaml:\"dataAfterCoolOff\"", (gogoproto.nullable) = false ];
repeated AssetToAmountValue assetToAmountValue = 8
[ (gogoproto.moretags) = "yaml:\"assetToAmountValue\"", (gogoproto.nullable) = false ];
repeated AppToAmountValue appToAmountValue = 9
[ (gogoproto.moretags) = "yaml:\"appToAmountValue\"", (gogoproto.nullable) = false ];
Params params = 10 [(gogoproto.nullable) = false];
}
13 changes: 13 additions & 0 deletions proto/comdex/esm/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ message QueryDataAfterCoolOffResponse {
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"data_after_cool_off\""];
}

message QuerySnapshotPriceRequest {
uint64 app_id = 1;
uint64 asset_id = 2;
}

message QuerySnapshotPriceResponse {
uint64 price = 1;
}

service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/comdex/v1beta1/esm/params";
Expand All @@ -87,4 +96,8 @@ service Query {
rpc QueryDataAfterCoolOff(QueryDataAfterCoolOffRequest) returns (QueryDataAfterCoolOffResponse) {
option (google.api.http).get = "/comdex/esm/v1beta1/data_after_cool_off/{id}";
}

rpc QuerySnapshotPrice(QuerySnapshotPriceRequest) returns (QuerySnapshotPriceResponse) {
option (google.api.http).get = "/comdex/esm/v1beta1/price_snapshot/{app_id}/{asset_id}";
}
}
4 changes: 1 addition & 3 deletions proto/comdex/lend/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ package comdex.lend.v1beta1;
import "gogoproto/gogo.proto";
import "comdex/lend/v1beta1/lend.proto";
import "comdex/lend/v1beta1/params.proto";
// this line is used by starport scaffolding # genesis/proto/import

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

// GenesisState defines the lend module's genesis state.
message GenesisState {
repeated BorrowAsset borrowAsset = 1
[ (gogoproto.moretags) = "yaml:\"borrowAsset\"", (gogoproto.nullable) = false ];
Expand Down Expand Up @@ -49,5 +47,5 @@ message GenesisState {
repeated AuctionParams auctionParams = 19
[ (gogoproto.moretags) = "yaml:\"auctionParams\"", (gogoproto.nullable) = false ];
Params params = 20 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state

}
Loading