From 7d8cab3aab21bee91f52f287a38bf8012cfb1c64 Mon Sep 17 00:00:00 2001 From: dheerajkd30 Date: Tue, 21 Jun 2022 16:24:31 +0530 Subject: [PATCH] refactor and modify asset module --- app/wasm/message_plugin.go | 9 ++- app/wasm/queries.go | 54 +++++++-------- app/wasm/query_plugin.go | 102 ++++++++++++++-------------- x/asset/client/cli/flags.go | 10 +-- x/asset/client/cli/query.go | 16 ++--- x/asset/client/cli/tx.go | 10 +-- x/asset/keeper/app_mapping.go | 39 +++++------ x/asset/keeper/asset.go | 4 +- x/asset/keeper/gov.go | 1 - x/asset/keeper/pair.go | 7 +- x/asset/keeper/pairs_vault.go | 119 ++++++++++++--------------------- x/asset/keeper/query_server.go | 6 +- x/asset/keeper/whitelist.go | 6 +- x/asset/types/errors.go | 3 - x/asset/types/gov.go | 2 - x/asset/types/lend.go | 2 - x/asset/types/params.go | 1 - 17 files changed, 167 insertions(+), 224 deletions(-) diff --git a/app/wasm/message_plugin.go b/app/wasm/message_plugin.go index fc2cdd6c5..b5d8c3fde 100644 --- a/app/wasm/message_plugin.go +++ b/app/wasm/message_plugin.go @@ -190,8 +190,8 @@ func (m *CustomMessenger) AddExtendedPairsVault(ctx sdk.Context, contractAddr sd } func MsgAddExtendedPairsVault(assetKeeper assetkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, - a *bindings.MsgAddExtendedPairsVault) error { - err := assetKeeper.WasmAddExtendedPairsVaultRecords(ctx, a.AppMappingId, a.PairId, a.LiquidationRatio, a.StabilityFee, a.ClosingFee, a.LiquidationPenalty, a.DrawDownFee, a.IsVaultActive, a.DebtCeiling, a.DebtFloor, a.IsPsmPair, a.MinCr, a.PairName, a.AssetOutOraclePrice, a.AssetOutPrice, a.MinUsdValueLeft) + pairVaultBinding *bindings.MsgAddExtendedPairsVault) error { + err := assetKeeper.WasmAddExtendedPairsVaultRecords(ctx, pairVaultBinding) if err != nil { return err } @@ -241,9 +241,8 @@ func (m *CustomMessenger) UpdateLsrInPairsVault(ctx sdk.Context, contractAddr sd } func MsgUpdateLsrInPairsVault(assetKeeper assetkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress, - a *bindings.MsgUpdateLsrInPairsVault) error { - err := assetKeeper.WasmUpdateLsrInPairsVault(ctx, a.AppMappingId, a.ExtPairId, a.LiquidationRatio, a.StabilityFee, a.ClosingFee, - a.LiquidationPenalty, a.DrawDownFee, a.MinCr, a.DebtCeiling, a.DebtFloor, a.MinUsdValueLeft) + updateLsrPairVault *bindings.MsgUpdateLsrInPairsVault) error { + err := assetKeeper.WasmUpdateLsrInPairsVault(ctx, updateLsrPairVault) if err != nil { return err } diff --git a/app/wasm/queries.go b/app/wasm/queries.go index c6102fed1..34ec89ab7 100644 --- a/app/wasm/queries.go +++ b/app/wasm/queries.go @@ -39,22 +39,22 @@ func NewQueryPlugin( } } -func (qp QueryPlugin) GetAppInfo(ctx sdk.Context, appMappingId uint64) (int64, int64, uint64, error) { - MinGovDeposit, GovTimeInSeconds, AssetId, err := qp.assetKeeper.GetAppWasmQuery(ctx, appMappingId) +func (qp QueryPlugin) GetAppInfo(ctx sdk.Context, appMappingID uint64) (int64, int64, uint64, error) { + MinGovDeposit, GovTimeInSeconds, AssetID, err := qp.assetKeeper.GetAppWasmQuery(ctx, appMappingID) if err != nil { - return MinGovDeposit, GovTimeInSeconds, AssetId, nil + return MinGovDeposit, GovTimeInSeconds, AssetID, nil } - return MinGovDeposit, GovTimeInSeconds, AssetId, nil + return MinGovDeposit, GovTimeInSeconds, AssetID, nil } -func (qp QueryPlugin) GetAssetInfo(ctx sdk.Context, Id uint64) (string, error) { - assetDenom := qp.assetKeeper.GetAssetDenom(ctx, Id) +func (qp QueryPlugin) GetAssetInfo(ctx sdk.Context, ID uint64) (string, error) { + assetDenom := qp.assetKeeper.GetAssetDenom(ctx, ID) return assetDenom, nil } -func (qp QueryPlugin) GetTokenMint(ctx sdk.Context, appMappingId, assetId uint64) (int64, error) { - tokenData, err := qp.tokenMintKeeper.GetAssetDataInTokenMintByAppSupply(ctx, appMappingId, assetId) - if err != true { +func (qp QueryPlugin) GetTokenMint(ctx sdk.Context, appMappingID, assetID uint64) (int64, error) { + tokenData, found := qp.tokenMintKeeper.GetAssetDataInTokenMintByAppSupply(ctx, appMappingID, assetID) + if !found { return tokenData, nil } return tokenData, nil @@ -75,43 +75,43 @@ func (qp QueryPlugin) GetWhitelistAppIdLockerRewardsCheck(ctx sdk.Context, appMa return found, err } -func (qp QueryPlugin) GetExternalLockerRewardsCheck(ctx sdk.Context, appMappingId, assetId uint64) (found bool, err string) { - found, err = qp.rewardsKeeper.GetExternalLockerRewardsCheck(ctx, appMappingId, assetId) +func (qp QueryPlugin) GetExternalLockerRewardsCheck(ctx sdk.Context, appMappingID, assetID uint64) (found bool, err string) { + found, err = qp.rewardsKeeper.GetExternalLockerRewardsCheck(ctx, appMappingID, assetID) return found, err } -func (qp QueryPlugin) GetExternalVaultRewardsCheck(ctx sdk.Context, appMappingId, assetId uint64) (found bool, err string) { - found, err = qp.rewardsKeeper.GetExternalVaultRewardsCheck(ctx, appMappingId, assetId) +func (qp QueryPlugin) GetExternalVaultRewardsCheck(ctx sdk.Context, appMappingID, assetID uint64) (found bool, err string) { + found, err = qp.rewardsKeeper.GetExternalVaultRewardsCheck(ctx, appMappingID, assetID) return found, err } -func (qp QueryPlugin) CollectorLookupTableQueryCheck(ctx sdk.Context, AppMappingId, CollectorAssetId, SecondaryAssetId uint64) (found bool, err string) { - found, err = qp.collectorKeeper.WasmSetCollectorLookupTableQuery(ctx, AppMappingId, CollectorAssetId, SecondaryAssetId) +func (qp QueryPlugin) CollectorLookupTableQueryCheck(ctx sdk.Context, appMappingID, collectorAssetID, secondaryAssetID uint64) (found bool, err string) { + found, err = qp.collectorKeeper.WasmSetCollectorLookupTableQuery(ctx, appMappingID, collectorAssetID, secondaryAssetID) return found, err } -func (qp QueryPlugin) ExtendedPairsVaultRecordsQueryCheck(ctx sdk.Context, AppMappingId, PairId uint64, StabilityFee, ClosingFee, DrawDownFee sdk.Dec, DebtCeiling, DebtFloor uint64, PairName string) (found bool, err string) { - found, err = qp.assetKeeper.WasmAddExtendedPairsVaultRecordsQuery(ctx, AppMappingId, PairId, StabilityFee, ClosingFee, DrawDownFee, DebtCeiling, DebtFloor, PairName) +func (qp QueryPlugin) ExtendedPairsVaultRecordsQueryCheck(ctx sdk.Context, appMappingID, pairID uint64, StabilityFee, ClosingFee, DrawDownFee sdk.Dec, DebtCeiling, DebtFloor uint64, PairName string) (found bool, err string) { + found, err = qp.assetKeeper.WasmAddExtendedPairsVaultRecordsQuery(ctx, appMappingID, pairID, StabilityFee, ClosingFee, DrawDownFee, DebtCeiling, DebtFloor, PairName) return found, err } -func (qp QueryPlugin) AuctionMappingForAppQueryCheck(ctx sdk.Context, AppMappingId uint64) (found bool, err string) { - found, err = qp.collectorKeeper.WasmSetAuctionMappingForAppQuery(ctx, AppMappingId) +func (qp QueryPlugin) AuctionMappingForAppQueryCheck(ctx sdk.Context, appMappingID uint64) (found bool, err string) { + found, err = qp.collectorKeeper.WasmSetAuctionMappingForAppQuery(ctx, appMappingID) return found, err } -func (qp QueryPlugin) WhiteListedAssetQueryCheck(ctx sdk.Context, AppMappingId, AssetId uint64) (found bool, err string) { - found, err = qp.lockerKeeper.WasmAddWhiteListedAssetQuery(ctx, AppMappingId, AssetId) +func (qp QueryPlugin) WhiteListedAssetQueryCheck(ctx sdk.Context, appMappingID, assetID uint64) (found bool, err string) { + found, err = qp.lockerKeeper.WasmAddWhiteListedAssetQuery(ctx, appMappingID, assetID) return found, err } -func (qp QueryPlugin) UpdateLsrInPairsVaultQueryCheck(ctx sdk.Context, AppMappingId, ExtPairId uint64) (found bool, err string) { - found, err = qp.assetKeeper.WasmUpdateLsrInPairsVaultQuery(ctx, AppMappingId, ExtPairId) +func (qp QueryPlugin) UpdateLsrInPairsVaultQueryCheck(ctx sdk.Context, appMappingID, extPairID uint64) (found bool, err string) { + found, err = qp.assetKeeper.WasmUpdateLsrInPairsVaultQuery(ctx, appMappingID, extPairID) return found, err } -func (qp QueryPlugin) UpdateLsrInCollectorLookupTableQueryCheck(ctx sdk.Context, AppMappingId, AssetId uint64) (found bool, err string) { - found, err = qp.collectorKeeper.WasmUpdateLsrInCollectorLookupTableQuery(ctx, AppMappingId, AssetId) +func (qp QueryPlugin) UpdateLsrInCollectorLookupTableQueryCheck(ctx sdk.Context, appMappingID, AssetId uint64) (found bool, err string) { + found, err = qp.collectorKeeper.WasmUpdateLsrInCollectorLookupTableQuery(ctx, appMappingID, AssetId) return found, err } @@ -120,8 +120,8 @@ func (qp QueryPlugin) WasmRemoveWhitelistAppIdVaultInterestQueryCheck(ctx sdk.Co return found, err } -func (qp QueryPlugin) WasmRemoveWhitelistAssetLockerQueryCheck(ctx sdk.Context, AppMappingId, AssetId uint64) (found bool, err string) { - found, err = qp.rewardsKeeper.WasmRemoveWhitelistAssetLockerQuery(ctx, AppMappingId, AssetId) +func (qp QueryPlugin) WasmRemoveWhitelistAssetLockerQueryCheck(ctx sdk.Context, appMappingID, AssetId uint64) (found bool, err string) { + found, err = qp.rewardsKeeper.WasmRemoveWhitelistAssetLockerQuery(ctx, appMappingID, AssetId) return found, err } diff --git a/app/wasm/query_plugin.go b/app/wasm/query_plugin.go index 5a7690ba7..4ad876a46 100644 --- a/app/wasm/query_plugin.go +++ b/app/wasm/query_plugin.go @@ -15,12 +15,12 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. return nil, sdkerrors.Wrap(err, "app query") } if comdexQuery.AppData != nil { - App_Id := comdexQuery.AppData.App_Id - MinGovDeposit, GovTimeInSeconds, AssetId, _ := queryPlugin.GetAppInfo(ctx, App_Id) + appID := comdexQuery.AppData.App_Id + MinGovDeposit, GovTimeInSeconds, assetID, _ := queryPlugin.GetAppInfo(ctx, appID) res := bindings.AppDataResponse{ MinGovDeposit: MinGovDeposit, GovTimeInSeconds: GovTimeInSeconds, - AssetId: AssetId, + AssetId: assetID, } bz, err := json.Marshal(res) if err != nil { @@ -28,8 +28,8 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.AssetData != nil { - asset_Id := comdexQuery.AssetData.Asset_Id - denom, _ := queryPlugin.GetAssetInfo(ctx, asset_Id) + assetID := comdexQuery.AssetData.Asset_Id + denom, _ := queryPlugin.GetAssetInfo(ctx, assetID) res := bindings.AssetDataResponse{ Denom: denom, } @@ -39,9 +39,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.MintedToken != nil { - App_Id := comdexQuery.MintedToken.App_Id - Asset_Id := comdexQuery.MintedToken.Asset_Id - MintedToken, _ := queryPlugin.GetTokenMint(ctx, App_Id, Asset_Id) + appID := comdexQuery.MintedToken.App_Id + assetID := comdexQuery.MintedToken.Asset_Id + MintedToken, _ := queryPlugin.GetTokenMint(ctx, appID, assetID) res := bindings.MintedTokenResponse{ MintedTokens: MintedToken, } @@ -65,10 +65,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.RemoveWhiteListAssetLocker != nil { - App_Id := comdexQuery.RemoveWhiteListAssetLocker.App_Id - Asset_Id := comdexQuery.RemoveWhiteListAssetLocker.Asset_Id + appID := comdexQuery.RemoveWhiteListAssetLocker.App_Id + assetID := comdexQuery.RemoveWhiteListAssetLocker.Asset_Id - found, errormsg := queryPlugin.GetRemoveWhitelistAppIdLockerRewardsCheck(ctx, App_Id, Asset_Id) + found, errormsg := queryPlugin.GetRemoveWhitelistAppIdLockerRewardsCheck(ctx, appID, assetID) res := bindings.RemoveWhiteListAssetResponse{ Found: found, Err: errormsg, @@ -79,10 +79,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.WhitelistAppIdLockerRewards != nil { - App_Id := comdexQuery.WhitelistAppIdLockerRewards.App_Id - Asset_Id := comdexQuery.WhitelistAppIdLockerRewards.Asset_Id + appID := comdexQuery.WhitelistAppIdLockerRewards.App_Id + assetID := comdexQuery.WhitelistAppIdLockerRewards.Asset_Id - found, errormsg := queryPlugin.GetWhitelistAppIdLockerRewardsCheck(ctx, App_Id, Asset_Id) + found, errormsg := queryPlugin.GetWhitelistAppIdLockerRewardsCheck(ctx, appID, assetID) res := bindings.WhitelistAppIdLockerRewardsResponse{ Found: found, Err: errormsg, @@ -93,9 +93,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.WhitelistAppIdVaultInterest != nil { - App_Id := comdexQuery.WhitelistAppIdVaultInterest.App_Id + appID := comdexQuery.WhitelistAppIdVaultInterest.App_Id - found, errormsg := queryPlugin.GetWhitelistAppIdVaultInterestCheck(ctx, App_Id) + found, errormsg := queryPlugin.GetWhitelistAppIdVaultInterestCheck(ctx, appID) res := bindings.WhitelistAppIdLockerRewardsResponse{ Found: found, Err: errormsg, @@ -106,10 +106,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.ExternalLockerRewards != nil { - App_Id := comdexQuery.ExternalLockerRewards.App_Id - Asset_Id := comdexQuery.ExternalLockerRewards.Asset_Id + appID := comdexQuery.ExternalLockerRewards.App_Id + assetID := comdexQuery.ExternalLockerRewards.Asset_Id - found, errormsg := queryPlugin.GetExternalLockerRewardsCheck(ctx, App_Id, Asset_Id) + found, errormsg := queryPlugin.GetExternalLockerRewardsCheck(ctx, appID, assetID) res := bindings.WhitelistAppIdLockerRewardsResponse{ Found: found, Err: errormsg, @@ -120,10 +120,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.ExternalVaultRewards != nil { - App_Id := comdexQuery.ExternalVaultRewards.App_Id - Asset_Id := comdexQuery.ExternalVaultRewards.Asset_Id + appID := comdexQuery.ExternalVaultRewards.App_Id + assetID := comdexQuery.ExternalVaultRewards.Asset_Id - found, errormsg := queryPlugin.GetExternalVaultRewardsCheck(ctx, App_Id, Asset_Id) + found, errormsg := queryPlugin.GetExternalVaultRewardsCheck(ctx, appID, assetID) res := bindings.ExternalVaultRewardsResponse{ Found: found, Err: errormsg, @@ -134,10 +134,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.CollectorLookupTableQuery != nil { - AppMappingId := comdexQuery.CollectorLookupTableQuery.AppMappingId - CollectorAssetId := comdexQuery.CollectorLookupTableQuery.CollectorAssetId - SecondaryAssetId := comdexQuery.CollectorLookupTableQuery.SecondaryAssetId - found, errormsg := queryPlugin.CollectorLookupTableQueryCheck(ctx, AppMappingId, CollectorAssetId, SecondaryAssetId) + appMappingID := comdexQuery.CollectorLookupTableQuery.AppMappingId + collectorAssetID := comdexQuery.CollectorLookupTableQuery.CollectorAssetId + secondaryAssetID := comdexQuery.CollectorLookupTableQuery.SecondaryAssetId + found, errormsg := queryPlugin.CollectorLookupTableQueryCheck(ctx, appMappingID, collectorAssetID, secondaryAssetID) res := bindings.CollectorLookupTableQueryResponse{ Found: found, Err: errormsg, @@ -148,8 +148,8 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.ExtendedPairsVaultRecordsQuery != nil { - AppMappingId := comdexQuery.ExtendedPairsVaultRecordsQuery.AppMappingId - PairId := comdexQuery.ExtendedPairsVaultRecordsQuery.PairId + appMappingID := comdexQuery.ExtendedPairsVaultRecordsQuery.AppMappingId + pairID := comdexQuery.ExtendedPairsVaultRecordsQuery.PairId StabilityFee := comdexQuery.ExtendedPairsVaultRecordsQuery.StabilityFee ClosingFee := comdexQuery.ExtendedPairsVaultRecordsQuery.ClosingFee DrawDownFee := comdexQuery.ExtendedPairsVaultRecordsQuery.DrawDownFee @@ -157,10 +157,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. DebtFloor := comdexQuery.ExtendedPairsVaultRecordsQuery.DebtFloor PairName := comdexQuery.ExtendedPairsVaultRecordsQuery.PairName - found, errormsg := queryPlugin.ExtendedPairsVaultRecordsQueryCheck(ctx, AppMappingId, PairId, StabilityFee, ClosingFee, DrawDownFee, DebtCeiling, DebtFloor, PairName) + found, errorMsg := queryPlugin.ExtendedPairsVaultRecordsQueryCheck(ctx, appMappingID, pairID, StabilityFee, ClosingFee, DrawDownFee, DebtCeiling, DebtFloor, PairName) res := bindings.ExtendedPairsVaultRecordsQueryResponse{ Found: found, - Err: errormsg, + Err: errorMsg, } bz, err := json.Marshal(res) if err != nil { @@ -168,8 +168,8 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.AuctionMappingForAppQuery != nil { - AppMappingId := comdexQuery.AuctionMappingForAppQuery.AppMappingId - found, errormsg := queryPlugin.AuctionMappingForAppQueryCheck(ctx, AppMappingId) + appMappingID := comdexQuery.AuctionMappingForAppQuery.AppMappingId + found, errormsg := queryPlugin.AuctionMappingForAppQueryCheck(ctx, appMappingID) res := bindings.AuctionMappingForAppQueryResponse{ Found: found, Err: errormsg, @@ -180,9 +180,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.WhiteListedAssetQuery != nil { - AppMappingId := comdexQuery.WhiteListedAssetQuery.AppMappingId - AssetId := comdexQuery.WhiteListedAssetQuery.AssetId - found, errormsg := queryPlugin.WhiteListedAssetQueryCheck(ctx, AppMappingId, AssetId) + appMappingID := comdexQuery.WhiteListedAssetQuery.AppMappingId + assetID := comdexQuery.WhiteListedAssetQuery.AssetId + found, errormsg := queryPlugin.WhiteListedAssetQueryCheck(ctx, appMappingID, assetID) res := bindings.WhiteListedAssetQueryResponse{ Found: found, Err: errormsg, @@ -193,9 +193,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.UpdateLsrInPairsVaultQuery != nil { - AppMappingId := comdexQuery.UpdateLsrInPairsVaultQuery.AppMappingId - ExtPairId := comdexQuery.UpdateLsrInPairsVaultQuery.ExtPairId - found, errormsg := queryPlugin.UpdateLsrInPairsVaultQueryCheck(ctx, AppMappingId, ExtPairId) + appMappingID := comdexQuery.UpdateLsrInPairsVaultQuery.AppMappingId + extPairID := comdexQuery.UpdateLsrInPairsVaultQuery.ExtPairId + found, errormsg := queryPlugin.UpdateLsrInPairsVaultQueryCheck(ctx, appMappingID, extPairID) res := bindings.UpdateLsrInPairsVaultQueryResponse{ Found: found, Err: errormsg, @@ -206,9 +206,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.UpdateLsrInCollectorLookupTableQuery != nil { - AppMappingId := comdexQuery.UpdateLsrInCollectorLookupTableQuery.AppMappingId - AssetId := comdexQuery.UpdateLsrInCollectorLookupTableQuery.AssetId - found, errormsg := queryPlugin.UpdateLsrInCollectorLookupTableQueryCheck(ctx, AppMappingId, AssetId) + appMappingID := comdexQuery.UpdateLsrInCollectorLookupTableQuery.AppMappingId + assetID := comdexQuery.UpdateLsrInCollectorLookupTableQuery.AssetId + found, errormsg := queryPlugin.UpdateLsrInCollectorLookupTableQueryCheck(ctx, appMappingID, assetID) res := bindings.UpdateLsrInCollectorLookupTableQueryResponse{ Found: found, Err: errormsg, @@ -219,8 +219,8 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.RemoveWhitelistAppIdVaultInterestQuery != nil { - AppMappingId := comdexQuery.RemoveWhitelistAppIdVaultInterestQuery.AppMappingId - found, errormsg := queryPlugin.WasmRemoveWhitelistAppIdVaultInterestQueryCheck(ctx, AppMappingId) + appMappingID := comdexQuery.RemoveWhitelistAppIdVaultInterestQuery.AppMappingId + found, errormsg := queryPlugin.WasmRemoveWhitelistAppIdVaultInterestQueryCheck(ctx, appMappingID) res := bindings.RemoveWhitelistAppIdVaultInterestQueryResponse{ Found: found, Err: errormsg, @@ -231,10 +231,10 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.RemoveWhitelistAssetLockerQuery != nil { - AppMappingId := comdexQuery.RemoveWhitelistAssetLockerQuery.AppMappingId - AssetId := comdexQuery.RemoveWhitelistAssetLockerQuery.AssetId + appMappingID := comdexQuery.RemoveWhitelistAssetLockerQuery.AppMappingId + assetID := comdexQuery.RemoveWhitelistAssetLockerQuery.AssetId - found, errormsg := queryPlugin.WasmRemoveWhitelistAssetLockerQueryCheck(ctx, AppMappingId, AssetId) + found, errormsg := queryPlugin.WasmRemoveWhitelistAssetLockerQueryCheck(ctx, appMappingID, assetID) res := bindings.RemoveWhitelistAssetLockerQueryResponse{ Found: found, Err: errormsg, @@ -245,9 +245,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.WhitelistAppIdLiquidationQuery != nil { - AppMappingId := comdexQuery.WhitelistAppIdLiquidationQuery.AppMappingId + AppMappingID := comdexQuery.WhitelistAppIdLiquidationQuery.AppMappingId - found, errormsg := queryPlugin.WasmWhitelistAppIdLiquidationQueryCheck(ctx, AppMappingId) + found, errormsg := queryPlugin.WasmWhitelistAppIdLiquidationQueryCheck(ctx, AppMappingID) res := bindings.WhitelistAppIdLiquidationQueryResponse{ Found: found, Err: errormsg, @@ -258,9 +258,9 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } else if comdexQuery.RemoveWhitelistAppIdLiquidationQuery != nil { - AppMappingId := comdexQuery.RemoveWhitelistAppIdLiquidationQuery.AppMappingId + AppMappingID := comdexQuery.RemoveWhitelistAppIdLiquidationQuery.AppMappingId - found, errormsg := queryPlugin.WasmRemoveWhitelistAppIdLiquidationQueryCheck(ctx, AppMappingId) + found, errormsg := queryPlugin.WasmRemoveWhitelistAppIdLiquidationQueryCheck(ctx, AppMappingID) res := bindings.RemoveWhitelistAppIdLiquidationQueryResponse{ Found: found, Err: errormsg, @@ -271,8 +271,6 @@ func CustomQuerier(queryPlugin *QueryPlugin) func(ctx sdk.Context, request json. } return bz, nil } - return nil, wasmvmtypes.UnsupportedRequest{Kind: "unknown App Data query variant"} } - } diff --git a/x/asset/client/cli/flags.go b/x/asset/client/cli/flags.go index ccd0d5511..972361b6b 100644 --- a/x/asset/client/cli/flags.go +++ b/x/asset/client/cli/flags.go @@ -105,8 +105,8 @@ func FlagSetCreateWhiteListedPairsMapping() *flag.FlagSet { } type createExtPairVaultInputs struct { - AppMappingId string `json:"app_mapping_id"` - PairId string `json:"pair_id"` + AppMappingID string `json:"app_mapping_id"` + PairID string `json:"pair_id"` LiquidationRatio string `json:"liquidation_ratio"` StabilityFee string `json:"stability_fee"` ClosingFee string `json:"closing_fee"` @@ -127,8 +127,8 @@ type createExtPairVaultInputs struct { } type createAddAssetMappingInputs struct { - AppId string `json:"app_id"` - AssetId string `json:"asset_id"` + AppID string `json:"app_id"` + AssetID string `json:"asset_id"` GenesisSupply string `json:"genesis_supply"` IsGovToken string `json:"is_gov_token"` Recipient string `json:"recipient"` @@ -138,7 +138,7 @@ type createAddAssetMappingInputs struct { } type createAddWhiteListedPairsInputs struct { - PairId string `json:"pair_id"` + PairID string `json:"pair_id"` ModuleAccount string `json:"module-account"` BaseBorrowRateAsset1 string `json:"base_borrow_rate_asset_1"` BaseBorrowRateAsset2 string `json:"base_borrow_rate_asset_2"` diff --git a/x/asset/client/cli/query.go b/x/asset/client/cli/query.go index 0a04012ee..f6e9fc877 100644 --- a/x/asset/client/cli/query.go +++ b/x/asset/client/cli/query.go @@ -335,7 +335,7 @@ func queryProductToExtendedPair() *cobra.Command { return err } - productId, err := strconv.ParseUint(args[0], 10, 64) + productID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } @@ -345,7 +345,7 @@ func queryProductToExtendedPair() *cobra.Command { res, err := queryClient.QueryProductToExtendedPair( context.Background(), &types.QueryProductToExtendedPairRequest{ - ProductId: productId, + ProductId: productID, }, ) if err != nil { @@ -373,7 +373,7 @@ func queryExtendedPairPsmPairWise() *cobra.Command { return err } - productId, err := strconv.ParseUint(args[0], 10, 64) + productID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } @@ -383,7 +383,7 @@ func queryExtendedPairPsmPairWise() *cobra.Command { res, err := queryClient.QueryExtendedPairPsmPairWise( context.Background(), &types.QueryExtendedPairPsmPairWiseRequest{ - ProductId: productId, + ProductId: productID, }, ) if err != nil { @@ -411,7 +411,7 @@ func queryTokenGov() *cobra.Command { return err } - appId, err := strconv.ParseUint(args[0], 10, 64) + appID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } @@ -421,7 +421,7 @@ func queryTokenGov() *cobra.Command { res, err := queryClient.QueryTokenGov( context.Background(), &types.QueryTokenGovRequest{ - AppId: appId, + AppId: appID, }, ) if err != nil { @@ -449,7 +449,7 @@ func queryExtendedPairDataPsmPairWise() *cobra.Command { return err } - appId, err := strconv.ParseUint(args[0], 10, 64) + appID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } @@ -459,7 +459,7 @@ func queryExtendedPairDataPsmPairWise() *cobra.Command { res, err := queryClient.QueryExtendedPairDataPsmPairWise( context.Background(), &types.QueryExtendedPairDataPsmPairWiseRequest{ - AppId: appId, + AppId: appID, }, ) if err != nil { diff --git a/x/asset/client/cli/tx.go b/x/asset/client/cli/tx.go index 57afa2330..d66ff46bb 100644 --- a/x/asset/client/cli/tx.go +++ b/x/asset/client/cli/tx.go @@ -798,12 +798,12 @@ func NewCreateExtendedPairVaultMsg(clientCtx client.Context, txf tx.Factory, fs return txf, nil, fmt.Errorf("failed to parse extPairVault: %w", err) } - appMappingId, err := strconv.ParseUint(extPairVault.AppMappingId, 10, 64) + appMappingId, err := strconv.ParseUint(extPairVault.AppMappingID, 10, 64) if err != nil { return txf, nil, err } - pairId, err := ParseUint64SliceFromString(extPairVault.PairId, ",") + pairId, err := ParseUint64SliceFromString(extPairVault.PairID, ",") if err != nil { return txf, nil, err } @@ -972,12 +972,12 @@ func NewCreateAssetMappingMsg(clientCtx client.Context, txf tx.Factory, fs *flag return txf, nil, fmt.Errorf("failed to parse assetMapping: %w", err) } - appId, err := strconv.ParseUint(assetMapping.AppId, 10, 64) + appId, err := strconv.ParseUint(assetMapping.AppID, 10, 64) if err != nil { return txf, nil, err } - assetId, err := ParseUint64SliceFromString(assetMapping.AssetId, ",") + assetId, err := ParseUint64SliceFromString(assetMapping.AssetID, ",") if err != nil { return txf, nil, err } @@ -1052,7 +1052,7 @@ func NewCreateWhiteListedPairsMsg(clientCtx client.Context, txf tx.Factory, fs * return txf, nil, fmt.Errorf("failed to parse whiteListedPairs: %w", err) } - pairId, err := ParseUint64SliceFromString(whiteListedPairs.PairId, ",") + pairId, err := ParseUint64SliceFromString(whiteListedPairs.PairID, ",") if err != nil { return txf, nil, err } diff --git a/x/asset/keeper/app_mapping.go b/x/asset/keeper/app_mapping.go index fbb85471d..ad53369b9 100644 --- a/x/asset/keeper/app_mapping.go +++ b/x/asset/keeper/app_mapping.go @@ -65,15 +65,15 @@ func (k *Keeper) GetApp(ctx sdk.Context, id uint64) (app types.AppMapping, found func (k *Keeper) GetAppWasmQuery(ctx sdk.Context, id uint64) (int64, int64, uint64, error) { appData, _ := k.GetApp(ctx, id) minGovDeposit := appData.MinGovDeposit.Int64() - var assetId uint64 + var assetID uint64 gen := appData.GenesisToken govTimeInSeconds := int64(appData.GovTimeInSeconds) for _, v := range gen { - if v.IsgovToken == true { - assetId = v.AssetId + if v.IsgovToken { + assetID = v.AssetId } } - return minGovDeposit, govTimeInSeconds, assetId, nil + return minGovDeposit, govTimeInSeconds, assetID, nil } func (k *Keeper) GetApps(ctx sdk.Context) (apps []types.AppMapping, found bool) { @@ -85,7 +85,7 @@ func (k *Keeper) GetApps(ctx sdk.Context) (apps []types.AppMapping, found bool) defer func(iter sdk.Iterator) { err := iter.Close() if err != nil { - + return } }(iter) @@ -101,23 +101,22 @@ func (k *Keeper) GetApps(ctx sdk.Context) (apps []types.AppMapping, found bool) return apps, true } -func (k *Keeper) GetMintGenesisTokenData(ctx sdk.Context, appId, assetId uint64) (mintData types.MintGenesisToken, found bool) { - appsData, _ := k.GetApp(ctx, appId) +func (k *Keeper) GetMintGenesisTokenData(ctx sdk.Context, appID, assetID uint64) (mintData types.MintGenesisToken, found bool) { + appsData, _ := k.GetApp(ctx, appID) for _, data := range appsData.GenesisToken { - if data.AssetId == assetId { + if data.AssetId == assetID { return data, true } } return mintData, false - } -func (k *Keeper) CheckIfAssetIsAddedToAppMapping(ctx sdk.Context, assetId uint64) bool { +func (k *Keeper) CheckIfAssetIsAddedToAppMapping(ctx sdk.Context, assetID uint64) bool { apps, _ := k.GetApps(ctx) for _, data := range apps { for _, inData := range data.GenesisToken { - if inData.AssetId == assetId { + if inData.AssetId == assetID { return false } } @@ -170,13 +169,13 @@ func (k *Keeper) HasAppForName(ctx sdk.Context, Name string) bool { return store.Has(key) } -func (k *Keeper) SetGenesisTokenForApp(ctx sdk.Context, appId uint64, assetId uint64) { +func (k *Keeper) SetGenesisTokenForApp(ctx sdk.Context, appID uint64, assetID uint64) { var ( store = k.Store(ctx) - key = types.GenesisForApp(appId) + key = types.GenesisForApp(appID) value = k.cdc.MustMarshal( &protobuftypes.UInt64Value{ - Value: assetId, + Value: assetID, }, ) ) @@ -184,10 +183,10 @@ func (k *Keeper) SetGenesisTokenForApp(ctx sdk.Context, appId uint64, assetId ui store.Set(key, value) } -func (k *Keeper) GetGenesisTokenForApp(ctx sdk.Context, appId uint64) uint64 { +func (k *Keeper) GetGenesisTokenForApp(ctx sdk.Context, appID uint64) uint64 { var ( store = k.Store(ctx) - key = types.GenesisForApp(appId) + key = types.GenesisForApp(appID) value = store.Get(key) ) @@ -226,7 +225,6 @@ func (k *Keeper) AddAppMappingRecords(ctx sdk.Context, records ...types.AppMappi k.SetApp(ctx, app) k.SetAppForShortName(ctx, app.ShortName, app.Id) k.SetAppForName(ctx, app.Name, app.Id) - } return nil @@ -234,7 +232,6 @@ func (k *Keeper) AddAppMappingRecords(ctx sdk.Context, records ...types.AppMappi func (k *Keeper) AddAssetMappingRecords(ctx sdk.Context, records ...types.AppMapping) error { for _, msg := range records { - appdata, found := k.GetApp(ctx, msg.Id) if !found { return types.AppIdsDoesntExist @@ -242,7 +239,6 @@ func (k *Keeper) AddAssetMappingRecords(ctx sdk.Context, records ...types.AppMap // var mintGenesis []types.MintGenesisToken for _, data := range msg.GenesisToken { - assetData, found := k.GetAsset(ctx, data.AssetId) if !found { return types.ErrorAssetDoesNotExist @@ -263,9 +259,7 @@ func (k *Keeper) AddAssetMappingRecords(ctx sdk.Context, records ...types.AppMap k.SetGenesisTokenForApp(ctx, msg.Id, data.AssetId) } appdata.GenesisToken = append(appdata.GenesisToken, data) - } - var ( app = types.AppMapping{ Id: msg.Id, @@ -276,10 +270,7 @@ func (k *Keeper) AddAssetMappingRecords(ctx sdk.Context, records ...types.AppMap GenesisToken: appdata.GenesisToken, } ) - k.SetApp(ctx, app) - } - return nil } diff --git a/x/asset/keeper/asset.go b/x/asset/keeper/asset.go index e988f6061..eff6f1d6f 100644 --- a/x/asset/keeper/asset.go +++ b/x/asset/keeper/asset.go @@ -86,7 +86,7 @@ func (k *Keeper) GetAssets(ctx sdk.Context) (assets []types.Asset) { defer func(iter sdk.Iterator) { err := iter.Close() if err != nil { - + return } }(iter) @@ -177,7 +177,6 @@ func (k *Keeper) AddAssetRecords(ctx sdk.Context, records ...types.Asset) error k.SetAssetID(ctx, asset.Id) k.SetAsset(ctx, asset) k.SetAssetForDenom(ctx, asset.Denom, asset.Id) - } return nil @@ -208,7 +207,6 @@ func (k *Keeper) UpdateAssetRecords(ctx sdk.Context, msg types.Asset) error { k.SetAsset(ctx, asset) return nil - } func (k *Keeper) AddPairsRecords(ctx sdk.Context, records ...types.Pair) error { diff --git a/x/asset/keeper/gov.go b/x/asset/keeper/gov.go index fd2016c94..62b78d3d0 100644 --- a/x/asset/keeper/gov.go +++ b/x/asset/keeper/gov.go @@ -23,7 +23,6 @@ func (k Keeper) HandleAddWhitelistedAssetRecords(ctx sdk.Context, p *types.AddWh func (k Keeper) HandleUpdateWhitelistedAssetRecords(ctx sdk.Context, p *types.UpdateWhitelistedAssetProposal) error { return k.UpdateWhitelistedAssetRecords(ctx, p.Asset) - } func (k Keeper) HandleAddWhitelistedPairsRecords(ctx sdk.Context, p *types.AddWhitelistedPairsProposal) error { diff --git a/x/asset/keeper/pair.go b/x/asset/keeper/pair.go index ec8d5f102..d645c9386 100644 --- a/x/asset/keeper/pair.go +++ b/x/asset/keeper/pair.go @@ -69,7 +69,12 @@ func (k *Keeper) GetPairs(ctx sdk.Context) (pairs []types.Pair) { iter = sdk.KVStorePrefixIterator(store, types.PairKeyPrefix) ) - defer iter.Close() + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) for ; iter.Valid(); iter.Next() { var pair types.Pair diff --git a/x/asset/keeper/pairs_vault.go b/x/asset/keeper/pairs_vault.go index 08dfd12df..4eb9318de 100644 --- a/x/asset/keeper/pairs_vault.go +++ b/x/asset/keeper/pairs_vault.go @@ -1,6 +1,7 @@ package keeper import ( + "github.com/comdex-official/comdex/app/wasm/bindings" sdk "github.com/cosmos/cosmos-sdk/types" protobuftypes "github.com/gogo/protobuf/types" @@ -72,7 +73,7 @@ func (k *Keeper) GetPairsVaults(ctx sdk.Context) (apps []types.ExtendedPairVault defer func(iter sdk.Iterator) { err := iter.Close() if err != nil { - + return } }(iter) @@ -88,34 +89,8 @@ func (k *Keeper) GetPairsVaults(ctx sdk.Context) (apps []types.ExtendedPairVault return apps, true } -// func (k *Keeper) SetPairsVaultForPairId(ctx sdk.Context, pairId uint64, id uint64) { -// var ( -// store = k.Store(ctx) -// key = types.PairsForPairIdKey(pairId) -// value = k.cdc.MustMarshal( -// &protobuftypes.UInt64Value{ -// Value: id, -// }, -// ) -// ) - -// store.Set(key, value) -// } - -// // checks if extended pair exists for a given asset pair ID -// func (k *Keeper) HasPairsVaultForPairId(ctx sdk.Context, PairId uint64) bool { -// var ( -// store = k.Store(ctx) -// key = types.PairsForPairIdKey(PairId) -// ) - -// return store.Has(key) -// } - func (k *Keeper) AddExtendedPairsVaultRecords(ctx sdk.Context, records ...types.ExtendedPairVault) error { - for _, msg := range records { - _, found := k.GetApp(ctx, msg.AppMappingId) if !found { return types.ErrorUnknownAppType @@ -174,16 +149,15 @@ func (k *Keeper) AddExtendedPairsVaultRecords(ctx sdk.Context, records ...types. return nil } -func (k *Keeper) WasmAddExtendedPairsVaultRecords(ctx sdk.Context, AppMappingId, PairId uint64, LiquidationRatio, StabilityFee, ClosingFee, LiquidationPenalty, DrawDownFee sdk.Dec, IsVaultActive bool, debtCeiling, debtFloor uint64, IsPsmPair bool, MinCr sdk.Dec, PairName string, AssetOutOraclePrice bool, AssetOutPrice, MinUsdValueLeft uint64) error { - - DebtCeiling := sdk.NewInt(int64(debtCeiling)) - DebtFloor := sdk.NewInt(int64(debtFloor)) +func (k *Keeper) WasmAddExtendedPairsVaultRecords(ctx sdk.Context, pairVaultBinding *bindings.MsgAddExtendedPairsVault) error { + DebtCeiling := sdk.NewInt(int64(pairVaultBinding.DebtCeiling)) + DebtFloor := sdk.NewInt(int64(pairVaultBinding.DebtFloor)) - _, found := k.GetApp(ctx, AppMappingId) + _, found := k.GetApp(ctx, pairVaultBinding.AppMappingId) if !found { return types.ErrorUnknownAppType } - _, pairExists := k.GetPair(ctx, PairId) + _, pairExists := k.GetPair(ctx, pairVaultBinding.PairId) if !pairExists { return types.ErrorPairDoesNotExist } @@ -194,7 +168,7 @@ func (k *Keeper) WasmAddExtendedPairsVaultRecords(ctx sdk.Context, AppMappingId, if len(extendedPairVault) > 0 { for _, data := range extendedPairVault { - if (data.PairName == PairName) && (data.AppMappingId == AppMappingId) { + if (data.PairName == pairVaultBinding.PairName) && (data.AppMappingId == pairVaultBinding.AppMappingId) { return types.ErrorPairNameForID } } @@ -202,33 +176,33 @@ func (k *Keeper) WasmAddExtendedPairsVaultRecords(ctx sdk.Context, AppMappingId, if DebtFloor.GTE(DebtCeiling) { return types.ErrorDebtFloorIsGreaterThanDebtCeiling } - if !(StabilityFee.GTE(sdk.ZeroDec()) && StabilityFee.LT(sdk.OneDec())) { + if !(pairVaultBinding.StabilityFee.GTE(sdk.ZeroDec()) && pairVaultBinding.StabilityFee.LT(sdk.OneDec())) { return types.ErrorFeeShouldNotBeGTOne } - if !(ClosingFee.GTE(sdk.ZeroDec()) && ClosingFee.LT(sdk.OneDec())) { + if !(pairVaultBinding.ClosingFee.GTE(sdk.ZeroDec()) && pairVaultBinding.ClosingFee.LT(sdk.OneDec())) { return types.ErrorFeeShouldNotBeGTOne } - if !(DrawDownFee.GTE(sdk.ZeroDec()) && DrawDownFee.LT(sdk.OneDec())) { + if !(pairVaultBinding.DrawDownFee.GTE(sdk.ZeroDec()) && pairVaultBinding.DrawDownFee.LT(sdk.OneDec())) { return types.ErrorFeeShouldNotBeGTOne } var app = types.ExtendedPairVault{ Id: id + 1, - AppMappingId: AppMappingId, - PairId: PairId, - LiquidationRatio: LiquidationRatio, - StabilityFee: StabilityFee, - ClosingFee: ClosingFee, - LiquidationPenalty: LiquidationPenalty, - DrawDownFee: DrawDownFee, - IsVaultActive: IsVaultActive, + AppMappingId: pairVaultBinding.AppMappingId, + PairId: pairVaultBinding.PairId, + LiquidationRatio: pairVaultBinding.LiquidationRatio, + StabilityFee: pairVaultBinding.StabilityFee, + ClosingFee: pairVaultBinding.ClosingFee, + LiquidationPenalty: pairVaultBinding.LiquidationPenalty, + DrawDownFee: pairVaultBinding.DrawDownFee, + IsVaultActive: pairVaultBinding.IsVaultActive, DebtCeiling: DebtCeiling, DebtFloor: DebtFloor, - IsPsmPair: IsPsmPair, - MinCr: MinCr, - PairName: PairName, - AssetOutOraclePrice: AssetOutOraclePrice, - AssetOutPrice: AssetOutPrice, - MinUsdValueLeft: MinUsdValueLeft, + IsPsmPair: pairVaultBinding.IsPsmPair, + MinCr: pairVaultBinding.MinCr, + PairName: pairVaultBinding.PairName, + AssetOutOraclePrice: pairVaultBinding.AssetOutOraclePrice, + AssetOutPrice: pairVaultBinding.AssetOutPrice, + MinUsdValueLeft: pairVaultBinding.MinUsdValueLeft, } k.SetPairsVaultID(ctx, app.Id) @@ -237,16 +211,15 @@ func (k *Keeper) WasmAddExtendedPairsVaultRecords(ctx sdk.Context, AppMappingId, return nil } -func (k *Keeper) WasmAddExtendedPairsVaultRecordsQuery(ctx sdk.Context, AppMappingId, PairId uint64, StabilityFee, ClosingFee, DrawDownFee sdk.Dec, debtCeiling, debtFloor uint64, PairName string) (bool, string) { - +func (k *Keeper) WasmAddExtendedPairsVaultRecordsQuery(ctx sdk.Context, appMappingID, pairID uint64, StabilityFee, ClosingFee, DrawDownFee sdk.Dec, debtCeiling, debtFloor uint64, PairName string) (bool, string) { DebtCeiling := sdk.NewInt(int64(debtCeiling)) DebtFloor := sdk.NewInt(int64(debtFloor)) - _, found := k.GetApp(ctx, AppMappingId) + _, found := k.GetApp(ctx, appMappingID) if !found { return false, types.ErrorUnknownAppType.Error() } - _, pairExists := k.GetPair(ctx, PairId) + _, pairExists := k.GetPair(ctx, pairID) if !pairExists { return false, types.ErrorPairDoesNotExist.Error() } @@ -254,7 +227,7 @@ func (k *Keeper) WasmAddExtendedPairsVaultRecordsQuery(ctx sdk.Context, AppMappi if len(extendedPairVault) > 0 { for _, data := range extendedPairVault { - if (data.PairName == PairName) && (data.AppMappingId == AppMappingId) { + if (data.PairName == PairName) && (data.AppMappingId == appMappingID) { return false, types.ErrorPairNameForID.Error() } } @@ -275,9 +248,7 @@ func (k *Keeper) WasmAddExtendedPairsVaultRecordsQuery(ctx sdk.Context, AppMappi return true, "" } -func (k *Keeper) WasmUpdateLsrInPairsVault(ctx sdk.Context, appId, exPairId uint64, liqRatio, stabFee, closeFee, penalty, - drawDownFee, minCr sdk.Dec, debtCeiling, debtFloor, minUsdValueLeft uint64) error { - +func (k *Keeper) WasmUpdateLsrInPairsVault(ctx sdk.Context, updateLsrPairVault *bindings.MsgUpdateLsrInPairsVault) error { var ExtPairVaultData types.ExtendedPairVault pairVaults, found := k.GetPairsVaults(ctx) if !found { @@ -285,25 +256,25 @@ func (k *Keeper) WasmUpdateLsrInPairsVault(ctx sdk.Context, appId, exPairId uint } var count = 0 for _, data := range pairVaults { - if data.AppMappingId == appId && data.Id == exPairId { + if data.AppMappingId == updateLsrPairVault.AppMappingId && data.Id == updateLsrPairVault.ExtPairId { count++ ExtPairVaultData.Id = data.Id ExtPairVaultData.PairId = data.PairId ExtPairVaultData.AppMappingId = data.AppMappingId - ExtPairVaultData.LiquidationRatio = liqRatio - ExtPairVaultData.StabilityFee = stabFee - ExtPairVaultData.ClosingFee = closeFee - ExtPairVaultData.LiquidationPenalty = penalty - ExtPairVaultData.DrawDownFee = drawDownFee + ExtPairVaultData.LiquidationRatio = updateLsrPairVault.LiquidationRatio + ExtPairVaultData.StabilityFee = updateLsrPairVault.StabilityFee + ExtPairVaultData.ClosingFee = updateLsrPairVault.ClosingFee + ExtPairVaultData.LiquidationPenalty = updateLsrPairVault.LiquidationPenalty + ExtPairVaultData.DrawDownFee = updateLsrPairVault.DrawDownFee ExtPairVaultData.IsVaultActive = data.IsVaultActive - ExtPairVaultData.DebtCeiling = sdk.NewInt(int64(debtCeiling)) - ExtPairVaultData.DebtFloor = sdk.NewInt(int64(debtFloor)) + ExtPairVaultData.DebtCeiling = sdk.NewInt(int64(updateLsrPairVault.DebtCeiling)) + ExtPairVaultData.DebtFloor = sdk.NewInt(int64(updateLsrPairVault.DebtFloor)) ExtPairVaultData.IsPsmPair = data.IsPsmPair - ExtPairVaultData.MinCr = minCr + ExtPairVaultData.MinCr = updateLsrPairVault.MinCr ExtPairVaultData.PairName = data.PairName ExtPairVaultData.AssetOutOraclePrice = data.AssetOutOraclePrice ExtPairVaultData.AssetOutPrice = data.AssetOutPrice - ExtPairVaultData.MinUsdValueLeft = minUsdValueLeft + ExtPairVaultData.MinUsdValueLeft = updateLsrPairVault.MinUsdValueLeft } } if count == 0 { @@ -311,24 +282,18 @@ func (k *Keeper) WasmUpdateLsrInPairsVault(ctx sdk.Context, appId, exPairId uint } k.SetPairsVault(ctx, ExtPairVaultData) - // var ( - // store = k.Store(ctx) - // key = types.PairsKey(app_id) - // value = k.cdc.MustMarshal(&ExtPairVaultData) - // ) - // store.Set(key, value) return nil } -func (k *Keeper) WasmUpdateLsrInPairsVaultQuery(ctx sdk.Context, appId, exPairId uint64) (bool, string) { +func (k *Keeper) WasmUpdateLsrInPairsVaultQuery(ctx sdk.Context, appID, exPairID uint64) (bool, string) { pairVaults, found := k.GetPairsVaults(ctx) if !found { return false, types.ErrorPairDoesNotExist.Error() } var count = 0 for _, data := range pairVaults { - if data.AppMappingId == appId && data.Id == exPairId { + if data.AppMappingId == appID && data.Id == exPairID { count++ } } diff --git a/x/asset/keeper/query_server.go b/x/asset/keeper/query_server.go index 189cc86c9..bbe3f17b8 100644 --- a/x/asset/keeper/query_server.go +++ b/x/asset/keeper/query_server.go @@ -282,7 +282,7 @@ func (q *queryServer) QueryExtendedPairPsmPairWise(c context.Context, req *types func (q *queryServer) QueryTokenGov(c context.Context, req *types.QueryTokenGovRequest) (*types.QueryTokenGovResponse, error) { var ( ctx = sdk.UnwrapSDKContext(c) - assetId uint64 + assetID uint64 ) appData, found := q.GetApp(ctx, req.AppId) if !found { @@ -290,12 +290,12 @@ func (q *queryServer) QueryTokenGov(c context.Context, req *types.QueryTokenGovR } for _, data := range appData.GenesisToken { if data.IsgovToken { - assetId = data.AssetId + assetID = data.AssetId } } return &types.QueryTokenGovResponse{ - GovAssetId: assetId, + GovAssetId: assetID, }, nil } diff --git a/x/asset/keeper/whitelist.go b/x/asset/keeper/whitelist.go index ccc181e93..714515ed5 100644 --- a/x/asset/keeper/whitelist.go +++ b/x/asset/keeper/whitelist.go @@ -150,7 +150,6 @@ func (k *Keeper) AddWhitelistedAssetRecords(ctx sdk.Context, records ...types.Ex k.SetWhitelistAssetID(ctx, asset.Id) k.SetWhitelistAsset(ctx, asset) - } return nil @@ -168,10 +167,8 @@ func (k *Keeper) UpdateWhitelistedAssetRecords(ctx sdk.Context, msg types.Extend if !msg.LiquidationThreshold.IsZero() { asset.LiquidationThreshold = msg.LiquidationThreshold } - if msg.IsBridgedAsset || !msg.IsBridgedAsset { - asset.IsBridgedAsset = msg.IsBridgedAsset - } + asset.IsBridgedAsset = msg.IsBridgedAsset k.SetWhitelistAsset(ctx, asset) return nil @@ -208,7 +205,6 @@ func (k *Keeper) AddWhitelistedPairsRecords(ctx sdk.Context, records ...types.Ex } func (k *Keeper) UpdateWhitelistedPairRecords(ctx sdk.Context, msg types.ExtendedPairLend) error { - pair, found := k.GetWhitelistPair(ctx, msg.Id) if !found { return types.ErrorPairDoesNotExist diff --git a/x/asset/types/errors.go b/x/asset/types/errors.go index 300ae5b65..ec4f97944 100644 --- a/x/asset/types/errors.go +++ b/x/asset/types/errors.go @@ -22,16 +22,13 @@ var ( ErrorDuplicateAsset = errors.Register(ModuleName, 202, "duplicate asset") ErrorPairDoesNotExist = errors.Register(ModuleName, 203, "pair does not exist") ErrorDuplicatePair = errors.Register(ModuleName, 204, "duplicate pair") - ErrorUnauthorized = errors.Register(ModuleName, 205, "unauthorized") ErrorDuplicateApp = errors.Register(ModuleName, 206, "duplicate app") ErrorPairNameForID = errors.Register(ModuleName, 207, "already has pair name for id in this app") - ErrorExtendedPairDoesNotExist = errors.Register(ModuleName, 208, "extended pair does not exist") AppIdsDoesntExist = errors.Register(ModuleName, 209, "app ids does not exist") ErrorAssetAlreadyExistingApp = errors.Register(ModuleName, 210, "asset already exist in App") ErrorAssetIsOffChain = errors.Register(ModuleName, 211, "asset has been marked off chain") ErrorDebtFloorIsGreaterThanDebtCeiling = errors.Register(ModuleName, 212, "Debt Floor Is Greater Than Debt Ceiling") ErrorGenesisTokenExistForApp = errors.Register(ModuleName, 213, "Genesis Token already Exist For App") - ErrorGenesisCantBeZero = errors.Register(ModuleName, 214, "genesis Cant Be Zero ") ErrorFeeShouldNotBeGTOne = errors.Register(ModuleName, 215, "Fee Should Not Be Greater than One and less than zero") ErrorExtendedPairDoesNotExistForTheApp = errors.Register(ModuleName, 216, "extended pair does not exist for the app") ) diff --git a/x/asset/types/gov.go b/x/asset/types/gov.go index b889b8b3f..de3086542 100644 --- a/x/asset/types/gov.go +++ b/x/asset/types/gov.go @@ -47,7 +47,6 @@ func init() { govtypes.RegisterProposalType(ProposalAddExtendedPairsVault) govtypes.RegisterProposalTypeCodec(&AddExtendedPairsVaultProposal{}, "comdex/AddExtendedPairsVaultProposal") - } var ( @@ -121,7 +120,6 @@ func (p *UpdateAssetProposal) ProposalRoute() string { return RouterKey } func (p *UpdateAssetProposal) ProposalType() string { return ProposalUpdateAsset } func (p *UpdateAssetProposal) ValidateBasic() error { - err := govtypes.ValidateAbstract(p) if err != nil { return err diff --git a/x/asset/types/lend.go b/x/asset/types/lend.go index 180507af1..9133c0485 100644 --- a/x/asset/types/lend.go +++ b/x/asset/types/lend.go @@ -1,11 +1,9 @@ package types func (m *ExtendedAsset) Validate() error { - return nil } func (m *ExtendedPairLend) Validate() error { - return nil } diff --git a/x/asset/types/params.go b/x/asset/types/params.go index 7a9ebfb7b..e34355a7b 100644 --- a/x/asset/types/params.go +++ b/x/asset/types/params.go @@ -25,6 +25,5 @@ func (m *Params) ParamSetPairs() paramstypes.ParamSetPairs { } func (m *Params) Validate() error { - return nil }