diff --git a/app/app.go b/app/app.go index 2e409f132..e607fb048 100644 --- a/app/app.go +++ b/app/app.go @@ -121,6 +121,7 @@ import ( "github.com/comdex-official/comdex/x/esm" esmkeeper "github.com/comdex-official/comdex/x/esm/keeper" esmtypes "github.com/comdex-official/comdex/x/esm/types" + rewardsclient "github.com/comdex-official/comdex/x/rewards/client" "github.com/comdex-official/comdex/x/lend" lendclient "github.com/comdex-official/comdex/x/lend/client" @@ -210,6 +211,7 @@ func GetGovProposalHandlers() []govclient.ProposalHandler { } proposalHandlers = append(proposalHandlers, wasmclient.ProposalHandlers...) proposalHandlers = append(proposalHandlers, assetclient.AddAssetsHandler...) + proposalHandlers = append(proposalHandlers, rewardsclient.AddRewardsHandler...) proposalHandlers = append(proposalHandlers, liquidityclient.LiquidityProposalHandler...) return proposalHandlers } @@ -764,6 +766,7 @@ func New( AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(assettypes.RouterKey, asset.NewUpdateAssetProposalHandler(app.AssetKeeper)). + AddRoute(rewardstypes.RouterKey, rewards.NewAddRewardsProposalHandler(app.Rewardskeeper)). AddRoute(lendtypes.RouterKey, lend.NewLendHandler(app.LendKeeper)). AddRoute(bandoraclemoduletypes.RouterKey, bandoraclemodule.NewFetchPriceHandler(app.BandoracleKeeper)). AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IbcKeeper.ClientKeeper)). diff --git a/app/upgrades/testnet/v1_0_0/constants.go b/app/upgrades/testnet/v1_0_0/constants.go index 378c78c37..2907ae07c 100644 --- a/app/upgrades/testnet/v1_0_0/constants.go +++ b/app/upgrades/testnet/v1_0_0/constants.go @@ -1,4 +1,4 @@ -package v1_0_0 +package v1_0_0 //nolint:revive,stylecheck const ( UpgradeName = "v1.0.0" diff --git a/app/upgrades/testnet/v1_0_0/upgrades.go b/app/upgrades/testnet/v1_0_0/upgrades.go index 9e6cc5969..ce9202cb9 100644 --- a/app/upgrades/testnet/v1_0_0/upgrades.go +++ b/app/upgrades/testnet/v1_0_0/upgrades.go @@ -1,4 +1,4 @@ -package v1_0_0 +package v1_0_0 //nolint:revive,stylecheck import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/app/upgrades/testnet/v2_0_0/constants.go b/app/upgrades/testnet/v2_0_0/constants.go index 68a5ffba6..06e0660f2 100644 --- a/app/upgrades/testnet/v2_0_0/constants.go +++ b/app/upgrades/testnet/v2_0_0/constants.go @@ -1,4 +1,4 @@ -package v2_0_0 +package v2_0_0 //nolint:revive,stylecheck const ( UpgradeName = "v2.0.0" diff --git a/app/upgrades/testnet/v2_0_0/upgrades.go b/app/upgrades/testnet/v2_0_0/upgrades.go index 262ebe71a..fe956408b 100644 --- a/app/upgrades/testnet/v2_0_0/upgrades.go +++ b/app/upgrades/testnet/v2_0_0/upgrades.go @@ -1,4 +1,4 @@ -package v2_0_0 +package v2_0_0 //nolint:revive,stylecheck import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/app/upgrades/testnet/v3_0_0/contstants.go b/app/upgrades/testnet/v3_0_0/contstants.go index 4ecac278d..31c8866b2 100644 --- a/app/upgrades/testnet/v3_0_0/contstants.go +++ b/app/upgrades/testnet/v3_0_0/contstants.go @@ -1,4 +1,4 @@ -package v3_0_0 +package v3_0_0 //nolint:revive,stylecheck const ( UpgradeName = "v3.0.0" diff --git a/app/upgrades/testnet/v3_0_0/upgrades.go b/app/upgrades/testnet/v3_0_0/upgrades.go index ac746f35d..64eadea0c 100644 --- a/app/upgrades/testnet/v3_0_0/upgrades.go +++ b/app/upgrades/testnet/v3_0_0/upgrades.go @@ -1,4 +1,4 @@ -package v3_0_0 +package v3_0_0 //nolint:revive,stylecheck import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/app/upgrades/testnet/v4_0_0/constants.go b/app/upgrades/testnet/v4_0_0/constants.go index 53005be04..b125ba5e3 100644 --- a/app/upgrades/testnet/v4_0_0/constants.go +++ b/app/upgrades/testnet/v4_0_0/constants.go @@ -1,4 +1,4 @@ -package v4_0_0 +package v4_0_0 //nolint:revive,stylecheck const ( UpgradeName = "v4.0.0" diff --git a/app/upgrades/testnet/v4_0_0/upgrades.go b/app/upgrades/testnet/v4_0_0/upgrades.go index 60f04a20c..f8f1d8a06 100644 --- a/app/upgrades/testnet/v4_0_0/upgrades.go +++ b/app/upgrades/testnet/v4_0_0/upgrades.go @@ -1,4 +1,4 @@ -package v4_0_0 +package v4_0_0 //nolint:revive,stylecheck import ( auctionkeeper "github.com/comdex-official/comdex/x/auction/keeper" diff --git a/cmd/comdex/genaccounts.go b/cmd/comdex/genaccounts.go index 33544d279..1fea27ae6 100644 --- a/cmd/comdex/genaccounts.go +++ b/cmd/comdex/genaccounts.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" @@ -40,7 +39,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) depCdc := clientCtx.Codec - cdc := depCdc.(codec.ProtoCodecMarshaler) + cdc := depCdc serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config diff --git a/cmd/comdex/testnet.go b/cmd/comdex/testnet.go index 29f383087..09e0f17e2 100644 --- a/cmd/comdex/testnet.go +++ b/cmd/comdex/testnet.go @@ -16,6 +16,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -37,6 +38,7 @@ var ( flagOutputDir = "output-dir" flagNodeDaemonHome = "node-daemon-home" flagStartingIPAddress = "starting-ip-address" + emptyMnemonic = "" ) func testnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { @@ -170,7 +172,7 @@ func InitTestnet( return err } - addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, true, algo) + addr, secret, err := testutil.GenerateSaveCoinKey(kb, nodeDirName, emptyMnemonic, true, algo) if err != nil { _ = os.RemoveAll(outputDir) return err diff --git a/docs/docs.go b/docs/docs.go index e54964f8c..dd6b82f78 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -43,7 +43,7 @@ func (s *s) ReadDoc() string { }, "escape": func(v interface{}) string { // escape tabs - str := strings.Replace(v.(string), "\t", "\\t", -1) + str := strings.Replace(v.(string), "\t", "\\t", -1) //nolint:forcetypeassert // replace " with \", and if that results in \\", replace that with \\\" str = strings.Replace(str, "\"", "\\\"", -1) return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1) diff --git a/go.mod b/go.mod index a37ab9fec..18fa18ec1 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.13.0 github.com/spf13/cast v1.5.0 - github.com/spf13/cobra v1.5.0 + github.com/spf13/cobra v1.6.0 github.com/stretchr/testify v1.8.0 github.com/swaggo/swag v1.8.6 github.com/tendermint/tendermint v0.34.21 @@ -151,7 +151,7 @@ require ( github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/improbable-eng/grpc-web v0.14.1 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jgautheron/goconst v1.5.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect diff --git a/go.sum b/go.sum index 9dd1f4e9f..598d0c4d5 100644 --- a/go.sum +++ b/go.sum @@ -638,8 +638,9 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1: github.com/improbable-eng/grpc-web v0.14.0/go.mod h1:6hRR09jOEG81ADP5wCQju1z71g6OL4eEvELdran/3cs= github.com/improbable-eng/grpc-web v0.14.1 h1:NrN4PY71A6tAz2sKDvC5JCauENWp0ykG8Oq1H3cpFvw= github.com/improbable-eng/grpc-web v0.14.1/go.mod h1:zEjGHa8DAlkoOXmswrNvhUGEYQA9UI7DhrGeHR1DMGU= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= +github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= @@ -1059,8 +1060,8 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= -github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= -github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= +github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= diff --git a/proto/comdex/rewards/v1beta1/gov.proto b/proto/comdex/rewards/v1beta1/gov.proto new file mode 100644 index 000000000..2a43b3ab8 --- /dev/null +++ b/proto/comdex/rewards/v1beta1/gov.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package comdex.rewards.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "comdex/rewards/v1beta1/rewards.proto"; + + +option go_package = "github.com/comdex-official/comdex/x/rewards/types"; +option (gogoproto.equal_all) = false; +option (gogoproto.goproto_getters_all) = false; + +message AddLendExternalRewardsProposal { + string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; + string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + Lend_external_rewards lend_external_rewards = 3 [(gogoproto.nullable) = false]; +} diff --git a/proto/comdex/rewards/v1beta1/query.proto b/proto/comdex/rewards/v1beta1/query.proto index 947fe0c1e..fedb32f8f 100644 --- a/proto/comdex/rewards/v1beta1/query.proto +++ b/proto/comdex/rewards/v1beta1/query.proto @@ -48,6 +48,9 @@ service Query { rpc QueryWhitelistedAppIdsVault(QueryWhitelistedAppIdsVaultRequest) returns (QueryWhitelistedAppIdsVaultResponse) { option (google.api.http).get = "/comdex/rewards/v1beta1/whitelisted_appids_Vault"; } + rpc QueryExternalRewardLends(QueryExternalRewardLendsRequest) returns (QueryExternalRewardLendsResponse) { + option (google.api.http).get = "/comdex/rewards/v1beta1/lend_external_rewards"; + } } @@ -173,6 +176,19 @@ message QueryWhitelistedAppIdsVaultResponse { repeated uint64 whitelistedAppIdsVault = 1 [(gogoproto.moretags) = "yaml:\"whitelistedAppIdsVault\""]; + cosmos.base.query.v1beta1.PageResponse pagination = 2 + [(gogoproto.moretags) = "yaml:\"pagination\""]; +} + +message QueryExternalRewardLendsRequest{ + cosmos.base.query.v1beta1.PageRequest pagination = 1 + [(gogoproto.moretags) = "yaml:\"pagination\""]; +} + +message QueryExternalRewardLendsResponse { + repeated Lend_external_rewards lend_external_rewards = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"vault_external_rewards\""]; + cosmos.base.query.v1beta1.PageResponse pagination = 2 [(gogoproto.moretags) = "yaml:\"pagination\""]; } \ No newline at end of file diff --git a/proto/comdex/rewards/v1beta1/rewards.proto b/proto/comdex/rewards/v1beta1/rewards.proto index 3e2b1565e..fe78caa9a 100644 --- a/proto/comdex/rewards/v1beta1/rewards.proto +++ b/proto/comdex/rewards/v1beta1/rewards.proto @@ -162,7 +162,7 @@ message Lend_external_rewards{ uint64 app_mapping_id = 2 [ (gogoproto.moretags) = "yaml:\"app_mapping_id\"" ]; - repeated Rewards_asset_pool_data rewards_asset_pool_data = 3 [ + Rewards_asset_pool_data rewards_asset_pool_data = 3 [ (gogoproto.moretags) = "yaml:\"rewards_asset_pool_data\"" ]; cosmos.base.v1beta1.Coin total_rewards = 4 [ diff --git a/x/asset/genesis.go b/x/asset/genesis.go index e2e0b2a4c..f5ec355c3 100644 --- a/x/asset/genesis.go +++ b/x/asset/genesis.go @@ -9,10 +9,10 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { var ( - assetID uint64 = 0 - pairID uint64 = 0 - appID uint64 = 0 - extendedPairID uint64 = 0 + assetID uint64 + pairID uint64 + appID uint64 + extendedPairID uint64 ) k.SetParams(ctx, state.Params) diff --git a/x/auction/expected/keeper.go b/x/auction/expected/keeper.go index 9cd125e94..db201498e 100644 --- a/x/auction/expected/keeper.go +++ b/x/auction/expected/keeper.go @@ -94,7 +94,6 @@ type LendKeeper interface { VerifyCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error CalculateCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) - DeleteBorrow(ctx sdk.Context, id uint64) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found bool) GetAddAuctionParamsData(ctx sdk.Context, appID uint64) (auctionParams lendtypes.AuctionParams, found bool) ModuleBalance(ctx sdk.Context, moduleName string, denom string) sdk.Int diff --git a/x/auction/keeper/alias.go b/x/auction/keeper/alias.go index 59208d369..9c0466de0 100644 --- a/x/auction/keeper/alias.go +++ b/x/auction/keeper/alias.go @@ -229,10 +229,6 @@ func (k Keeper) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, f return k.lend.GetLend(ctx, id) } -func (k Keeper) DeleteBorrow(ctx sdk.Context, id uint64) { - k.lend.DeleteBorrow(ctx, id) -} - func (k Keeper) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found bool) { return k.lend.GetPool(ctx, id) } diff --git a/x/auction/keeper/dutch_lend.go b/x/auction/keeper/dutch_lend.go index 37189c813..c259ba9e7 100644 --- a/x/auction/keeper/dutch_lend.go +++ b/x/auction/keeper/dutch_lend.go @@ -278,6 +278,9 @@ func (k Keeper) PlaceLendDutchAuctionBid(ctx sdk.Context, appID, auctionMappingI if auction.InflowTokenCurrentAmount.IsGTE(auction.InflowTokenTargetAmount) { total := auction.OutflowTokenCurrentAmount err = k.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, sdk.AccAddress(lockedVault.Owner), sdk.NewCoins(total)) + if err != nil { + return err + } err = k.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, bidder, sdk.NewCoins(totalAmountToBidder)) if err != nil { return err diff --git a/x/bandoracle/keeper/oracle.go b/x/bandoracle/keeper/oracle.go index ec0968e34..6d459f7ca 100644 --- a/x/bandoracle/keeper/oracle.go +++ b/x/bandoracle/keeper/oracle.go @@ -10,7 +10,6 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" - gogotypes "github.com/gogo/protobuf/types" protobuftypes "github.com/gogo/protobuf/types" "github.com/comdex-official/comdex/x/bandoracle/types" @@ -37,7 +36,7 @@ func (k Keeper) GetFetchPriceResult(ctx sdk.Context, id types.OracleRequestID) ( // GetLastFetchPriceID return the id from the last FetchPrice request. func (k Keeper) GetLastFetchPriceID(ctx sdk.Context) int64 { bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.LastFetchPriceIDKey)) - intV := gogotypes.Int64Value{} + intV := protobuftypes.Int64Value{} k.cdc.MustUnmarshalLengthPrefixed(bz, &intV) return intV.GetValue() } @@ -46,7 +45,7 @@ func (k Keeper) GetLastFetchPriceID(ctx sdk.Context) int64 { func (k Keeper) SetLastFetchPriceID(ctx sdk.Context, id types.OracleRequestID) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyPrefix(types.LastFetchPriceIDKey), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.Int64Value{Value: int64(id)})) + k.cdc.MustMarshalLengthPrefixed(&protobuftypes.Int64Value{Value: int64(id)})) } func (k Keeper) FetchPrice(ctx sdk.Context, msg types.MsgFetchPriceData) (*types.MsgFetchPriceDataResponse, error) { @@ -143,7 +142,7 @@ func (k Keeper) GetFetchPriceMsg(ctx sdk.Context) types.MsgFetchPriceData { func (k Keeper) GetLastBlockHeight(ctx sdk.Context) int64 { bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.LastBlockHeightKey)) - intV := gogotypes.Int64Value{} + intV := protobuftypes.Int64Value{} k.cdc.MustUnmarshalLengthPrefixed(bz, &intV) return intV.GetValue() } @@ -151,7 +150,7 @@ func (k Keeper) GetLastBlockHeight(ctx sdk.Context) int64 { func (k Keeper) SetLastBlockHeight(ctx sdk.Context, height int64) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyPrefix(types.LastBlockHeightKey), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.Int64Value{Value: height})) + k.cdc.MustMarshalLengthPrefixed(&protobuftypes.Int64Value{Value: height})) } func (k Keeper) AddFetchPriceRecords(ctx sdk.Context, price types.MsgFetchPriceData) error { @@ -170,12 +169,12 @@ func (k Keeper) OraclePriceValidationByRequestID(ctx sdk.Context, req int64) boo func (k Keeper) SetOracleValidationResult(ctx sdk.Context, res bool) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyPrefix(types.OracleValidationResultKey), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.BoolValue{Value: res})) + k.cdc.MustMarshalLengthPrefixed(&protobuftypes.BoolValue{Value: res})) } func (k Keeper) GetOracleValidationResult(ctx sdk.Context) bool { bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.OracleValidationResultKey)) - boolV := gogotypes.BoolValue{} + boolV := protobuftypes.BoolValue{} k.cdc.MustUnmarshalLengthPrefixed(bz, &boolV) return boolV.GetValue() } @@ -183,12 +182,12 @@ func (k Keeper) GetOracleValidationResult(ctx sdk.Context) bool { func (k Keeper) SetTempFetchPriceID(ctx sdk.Context, id int64) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyPrefix(types.TempFetchPriceIDKey), - k.cdc.MustMarshalLengthPrefixed(&gogotypes.Int64Value{Value: id})) + k.cdc.MustMarshalLengthPrefixed(&protobuftypes.Int64Value{Value: id})) } func (k Keeper) GetTempFetchPriceID(ctx sdk.Context) int64 { bz := ctx.KVStore(k.storeKey).Get(types.KeyPrefix(types.TempFetchPriceIDKey)) - intV := gogotypes.Int64Value{} + intV := protobuftypes.Int64Value{} k.cdc.MustUnmarshalLengthPrefixed(bz, &intV) return intV.GetValue() } diff --git a/x/collector/expected/keeper.go b/x/collector/expected/keeper.go index 7f6794ce1..f171ac5b7 100644 --- a/x/collector/expected/keeper.go +++ b/x/collector/expected/keeper.go @@ -41,7 +41,7 @@ type LockerKeeper interface { } type RewardsKeeper interface { - GetReward(ctx sdk.Context, appId, assetID uint64) (rewards rewardstypes.InternalRewards, found bool) + GetReward(ctx sdk.Context, appID, assetID uint64) (rewards rewardstypes.InternalRewards, found bool) CalculationOfRewards(ctx sdk.Context, amount sdk.Int, lsr sdk.Dec, bTime int64) (sdk.Dec, error) SetLockerRewardTracker(ctx sdk.Context, rewards rewardstypes.LockerRewardsTracker) GetLockerRewardTracker(ctx sdk.Context, id, appID uint64) (rewards rewardstypes.LockerRewardsTracker, found bool) diff --git a/x/lend/keeper/borrow.go b/x/lend/keeper/borrow.go index b9a778677..c93e706dc 100644 --- a/x/lend/keeper/borrow.go +++ b/x/lend/keeper/borrow.go @@ -123,10 +123,10 @@ func (k Keeper) SetBorrowInterestTracker(ctx sdk.Context, interest types.BorrowI store.Set(key, value) } -func (k Keeper) GetBorrowInterestTracker(ctx sdk.Context, id uint64) (interest types.BorrowInterestTracker, found bool) { +func (k Keeper) GetBorrowInterestTracker(ctx sdk.Context, ID uint64) (interest types.BorrowInterestTracker, found bool) { var ( store = k.Store(ctx) - key = types.BorrowInterestTrackerKey(id) + key = types.BorrowInterestTrackerKey(ID) value = store.Get(key) ) @@ -137,3 +137,12 @@ func (k Keeper) GetBorrowInterestTracker(ctx sdk.Context, id uint64) (interest t k.cdc.MustUnmarshal(value, &interest) return interest, true } + +func (k Keeper) DeleteBorrowInterestTracker(ctx sdk.Context, ID uint64) { + var ( + store = k.Store(ctx) + key = types.BorrowInterestTrackerKey(ID) + ) + + store.Delete(key) +} diff --git a/x/lend/keeper/funds.go b/x/lend/keeper/funds.go index 0c4f352e3..783f881de 100644 --- a/x/lend/keeper/funds.go +++ b/x/lend/keeper/funds.go @@ -32,6 +32,7 @@ func (k Keeper) UpdateReserveBalances(ctx sdk.Context, assetID uint64, moduleNam return err } } + k.SetReserveBuybackAssetData(ctx, reserve) return nil } diff --git a/x/lend/keeper/grpc_query.go b/x/lend/keeper/grpc_query.go index 3fea63bd3..02ea06d87 100644 --- a/x/lend/keeper/grpc_query.go +++ b/x/lend/keeper/grpc_query.go @@ -97,8 +97,8 @@ func (q QueryServer) QueryAllLendByOwner(c context.Context, req *types.QueryAllL for _, data := range mappingData { lendIds = append(lendIds, data.LendId) } - for _, lendId := range lendIds { - lend, _ := q.GetLend(ctx, lendId) + for _, lendID := range lendIds { + lend, _ := q.GetLend(ctx, lendID) lends = append(lends, lend) } if len(lendIds) == 0 { @@ -131,8 +131,8 @@ func (q QueryServer) QueryAllLendByOwnerAndPool(c context.Context, req *types.Qu lendIds = append(lendIds, data.LendId) } } - for _, lendId := range lendIds { - lend, _ := q.GetLend(ctx, lendId) + for _, lendID := range lendIds { + lend, _ := q.GetLend(ctx, lendID) lends = append(lends, lend) } if len(lendIds) == 0 { @@ -165,8 +165,8 @@ func (q QueryServer) QueryAllBorrowByOwnerAndPool(c context.Context, req *types. borrowIds = append(borrowIds, data.BorrowId...) } } - for _, borrowId := range borrowIds { - borrow, _ := q.GetBorrow(ctx, borrowId) + for _, borrowID := range borrowIds { + borrow, _ := q.GetBorrow(ctx, borrowID) borrows = append(borrows, borrow) } if len(borrowIds) == 0 { @@ -409,8 +409,8 @@ func (q QueryServer) QueryAllBorrowByOwner(c context.Context, req *types.QueryAl for _, data := range mappingData { borrowIds = append(borrowIds, data.BorrowId...) } - for _, borrowId := range borrowIds { - borrow, _ := q.GetBorrow(ctx, borrowId) + for _, borrowID := range borrowIds { + borrow, _ := q.GetBorrow(ctx, borrowID) borrows = append(borrows, borrow) } if len(borrowIds) == 0 { diff --git a/x/lend/keeper/iter.go b/x/lend/keeper/iter.go index fb973cbdc..4444f0a82 100644 --- a/x/lend/keeper/iter.go +++ b/x/lend/keeper/iter.go @@ -11,6 +11,11 @@ import ( // To calculate pending rewards from last interaction func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { + // to calculate lend rewards on the amount lent + // check if the interest accumulated is sufficient for that assetID and poolID + // send the cTokens to the lenders address if less than interest accumulated + // if the user is claiming for the first time then a new lendRewardsTracker is created for that user + lend, _ := k.GetLend(ctx, ID) lendAPR, _ := k.GetLendAPRByAssetIDAndPoolID(ctx, lend.PoolID, lend.AssetID) @@ -23,24 +28,33 @@ func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { RewardsAccumulated: sdk.ZeroDec(), } } + + // Adding interest to existing rewards accumulated lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Add(interestPerBlock) - newInterestPerBlock := sdk.ZeroInt() + + // initializing new variable newInterestPerBlock + newInterestPerInteraction := sdk.ZeroInt() + + // checking if the rewards accumulated is greater than equal to 1 if lendRewardsTracker.RewardsAccumulated.GTE(sdk.OneDec()) { - newInterestPerBlock = lendRewardsTracker.RewardsAccumulated.TruncateInt() - newRewardDec := sdk.NewDec(newInterestPerBlock.Int64()) - lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Sub(newRewardDec) + newInterestPerInteraction = lendRewardsTracker.RewardsAccumulated.TruncateInt() + newRewardDec := sdk.NewDec(newInterestPerInteraction.Int64()) + lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Sub(newRewardDec) // not losing decimal precision } - k.SetLendRewardTracker(ctx, lendRewardsTracker) + k.SetLendRewardTracker(ctx, lendRewardsTracker) // setting the remaing decimal part + + // checking if sufficient cTokens are there to give out as rewards to user poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, lend.PoolID, lend.AssetID) - if newInterestPerBlock.GT(poolAssetLBMappingData.TotalInterestAccumulated) { + if newInterestPerInteraction.GT(poolAssetLBMappingData.TotalInterestAccumulated) { return sdk.Dec{}, types.ErrorInsufficientCTokensForRewards } - if newInterestPerBlock.GT(sdk.ZeroInt()) { - lend.AvailableToBorrow = lend.AvailableToBorrow.Add(newInterestPerBlock) + if newInterestPerInteraction.GT(sdk.ZeroInt()) { + // updating user's balance + lend.AvailableToBorrow = lend.AvailableToBorrow.Add(newInterestPerInteraction) pool, _ := k.GetPool(ctx, lend.PoolID) asset, _ := k.GetAsset(ctx, lend.AssetID) - Amount := sdk.NewCoin(asset.Denom, newInterestPerBlock) + Amount := sdk.NewCoin(asset.Denom, newInterestPerInteraction) assetRatesStat, _ := k.GetAssetRatesParams(ctx, lend.AssetID) cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) @@ -51,7 +65,10 @@ func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { if err != nil { return sdk.Dec{}, err } - + // subtracting newInterestPerInteraction from global lend and interest accumulated + poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Sub(newInterestPerInteraction) + poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Sub(newInterestPerInteraction) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) k.SetLend(ctx, lend) } @@ -59,6 +76,9 @@ func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { } func (k Keeper) IterateBorrow(ctx sdk.Context, ID uint64) (sdk.Dec, sdk.Dec, error) { + // to calculate borrow interest on existing borrow positions + // also calculate the amount going to reserve pool for that borrow position + borrow, _ := k.GetBorrow(ctx, ID) pair, _ := k.GetLendPair(ctx, borrow.PairID) reserveRates, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) @@ -66,13 +86,13 @@ func (k Keeper) IterateBorrow(ctx sdk.Context, ID uint64) (sdk.Dec, sdk.Dec, err return sdk.ZeroDec(), sdk.ZeroDec(), err } currBorrowAPR, _ := k.GetBorrowAPRByAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut, borrow.IsStableBorrow) - interestPerBlock, indexGlobalCurrent, reservePoolAmountPerBlock, reserveGlobalIndex, err := k.CalculateBorrowInterest(ctx, borrow.AmountOut.Amount.String(), currBorrowAPR, reserveRates, borrow) + interestPerInteraction, indexGlobalCurrent, reservePoolAmountPerInteraction, reserveGlobalIndex, err := k.CalculateBorrowInterest(ctx, borrow.AmountOut.Amount.String(), currBorrowAPR, reserveRates, borrow) if err != nil { return sdk.ZeroDec(), sdk.ZeroDec(), err } if !borrow.IsStableBorrow { - borrow.InterestAccumulated = borrow.InterestAccumulated.Add(interestPerBlock) + borrow.InterestAccumulated = borrow.InterestAccumulated.Add(interestPerInteraction) } else { stableInterestPerBlock, err := k.CalculateStableInterest(ctx, borrow.AmountOut.Amount.String(), borrow) if err != nil { @@ -81,6 +101,7 @@ func (k Keeper) IterateBorrow(ctx sdk.Context, ID uint64) (sdk.Dec, sdk.Dec, err borrow.InterestAccumulated = borrow.InterestAccumulated.Add(stableInterestPerBlock) } + // if reserve pool records are not found for the borrowId then a new reservePoolRecords is generated for that borrow ID (on first interaction) reservePoolRecords, found := k.GetBorrowInterestTracker(ctx, borrow.ID) if !found { reservePoolRecords = types.BorrowInterestTracker{ @@ -88,8 +109,8 @@ func (k Keeper) IterateBorrow(ctx sdk.Context, ID uint64) (sdk.Dec, sdk.Dec, err ReservePoolInterest: sdk.ZeroDec(), } } - if reservePoolAmountPerBlock.GT(sdk.ZeroDec()) { - reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Add(reservePoolAmountPerBlock) + if reservePoolAmountPerInteraction.GT(sdk.ZeroDec()) { + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Add(reservePoolAmountPerInteraction) } k.SetBorrowInterestTracker(ctx, reservePoolRecords) k.SetBorrow(ctx, borrow) diff --git a/x/lend/keeper/keeper.go b/x/lend/keeper/keeper.go index 9de57f46d..ba40e0379 100644 --- a/x/lend/keeper/keeper.go +++ b/x/lend/keeper/keeper.go @@ -81,6 +81,7 @@ func uint64InAssetData(a uint64, list []*types.AssetDataPoolMapping) bool { } func (k Keeper) CheckSupplyCap(ctx sdk.Context, assetID, poolID uint64, amt sdk.Int) (bool, error) { + // this fn checks if while depositing the supply cap of a specific lend asset doesn't exceed specified value var supplyCap uint64 assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) @@ -100,12 +101,16 @@ func (k Keeper) CheckSupplyCap(ctx sdk.Context, assetID, poolID uint64, amt sdk. } if currentSupply.Uint64() <= supplyCap { return true, nil - } else { - return false, nil } + return false, nil } func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Amount sdk.Coin, PoolID, AppID uint64) error { + // this fn IBC Assets fom the user + // sends the asset to pool's module-acc + // mints cAsset representative of the lent aasset + // creates a lend Position and updates global lend + killSwitchParams, _ := k.GetKillSwitchData(ctx, AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled @@ -196,10 +201,11 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am LastInteractionTime: ctx.BlockTime(), CPoolName: pool.CPoolName, } - k.UpdateLendStats(ctx, AssetID, PoolID, Amount.Amount, true) + k.UpdateLendStats(ctx, AssetID, PoolID, Amount.Amount, true) // update global lend data in poolAssetLBMappingData k.SetUserLendIDCounter(ctx, lendPos.ID) k.SetLend(ctx, lendPos) + // making UserAssetLendBorrowMapping for user var mappingData types.UserAssetLendBorrowMapping mappingData.Owner = lendPos.Owner mappingData.LendId = lendPos.ID @@ -207,6 +213,7 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am mappingData.BorrowId = nil k.SetUserLendBorrowMapping(ctx, mappingData) + // Adding Lend ID mapping to poolAssetLBMappingData poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, PoolID, AssetID) poolAssetLBMappingData.LendIds = append(poolAssetLBMappingData.LendIds, lendPos.ID) k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) @@ -214,6 +221,11 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am } func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withdrawal sdk.Coin) error { + // this fn is used to withdraw IBC assets from previously lent asset + //we take the cTokens from the user's account and burn them. + // equal amount of IBC Asset is sent back to the user. + // global lend data and user's lend position are updated after successful transaction + lenderAddr, err := sdk.AccAddressFromBech32(addr) if err != nil { return err @@ -277,6 +289,12 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd if err != nil { return err } + + // here 2 conditions exists + // a. if the amount to withdraw is less than equal the AmountIn of lend position then Available to borrow are subtracted by withdraw amt + // b. if the user has some lend rewards added to his position and the withdrawal amount is greater tha amountIn then in this case the amountIn is made 0 + // as no further lend rewards will be available for this user. + if withdrawal.Amount.LT(lendPos.AmountIn.Amount) { if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { return err @@ -849,107 +867,103 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string borrowPos.LastInteractionTime = ctx.BlockTime() poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) - if payment.Amount.LTE(borrowPos.InterestAccumulated.TruncateInt()) { + reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) + amtToReservePool := reservePoolRecords.ReservePoolInterest + + if payment.Amount.LTE(amtToReservePool.TruncateInt()) { + // subtract payment amount from reservePoolRecords for that borrow ID and set reservePoolRecords + // subtract payment amount from borrow-> interest accumulated and set borrow + // send the payment amount to the reserve pool & update stats + // sending repayment to moduleAcc from borrower if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { return err } + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(sdk.NewDecFromInt(payment.Amount)) borrowPos.InterestAccumulated = borrowPos.InterestAccumulated.Sub(sdk.NewDecFromInt(payment.Amount)) + err = k.UpdateReserveBalances(ctx, pair.AssetOut, pool.ModuleName, payment, true) // this functions sends the amount to reserve pool from the cPool + if err != nil { + return err + } - reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) - amtToReservePool := reservePoolRecords.ReservePoolInterest + } else if payment.Amount.GT(amtToReservePool.TruncateInt()) && payment.Amount.LTE(borrowPos.InterestAccumulated.TruncateInt()) { + // from reservePoolRecords amount send tokens to reserve pool + // send remaining payment back to cPool and mint additional tokens for that amount + // update global lend and interest accumulated for remaining amount + // subtract payment amount from borrow-> interest accumulated and set borrow + // make reservePoolRecords 0 - if amtToReservePool.TruncateInt().LTE(payment.Amount) { - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { - return types.ErrReserveRatesNotFound - } - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { - amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) - if err != nil { - return err - } - } - amtBackToPool := payment.Amount.Sub(amtToReservePool.TruncateInt()) - if amtBackToPool.GT(sdk.ZeroInt()) { - err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, amtBackToPool)) - if err != nil { - return err - } - poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(amtBackToPool) - poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(amtBackToPool) - k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) - } + // sending repayment to moduleAcc from borrower + if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { + return err + } - reservePoolRecords.ReservePoolInterest = sdk.ZeroDec() - k.SetBorrowInterestTracker(ctx, reservePoolRecords) - } else { - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { - return types.ErrReserveRatesNotFound - } - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { - amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) - if err != nil { - return err - } + err = k.UpdateReserveBalances(ctx, pair.AssetOut, pool.ModuleName, sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()), true) // this functions sends the amount to reserve pool from the cPool + if err != nil { + return err + } + + // calculation for tokens to be minted and updated in global lend and interest accumulated parameter + cTokensAmount := payment.Amount.Sub(amtToReservePool.TruncateInt()) + if cTokensAmount.LT(sdk.ZeroInt()) { + return types.ErrReserveRatesNotFound + } + if cTokensAmount.GT(sdk.ZeroInt()) { + err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, cTokensAmount)) + if err != nil { + return err } - reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(payment.Amount.ToDec()) - k.SetBorrowInterestTracker(ctx, reservePoolRecords) + poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(cTokensAmount) + poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(cTokensAmount) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) } - } else { + + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(sdk.NewDecFromInt(amtToReservePool.TruncateInt())) // the decimal precision is maintained + borrowPos.InterestAccumulated = borrowPos.InterestAccumulated.Sub(sdk.NewDecFromInt(payment.Amount)) + + } else { // if payment amt greater than borrowPos.InterestAccumulated + // from reservePoolRecords amount send tokens to reserve pool + // mint (interest Accumulated - reservePoolRecords) amount cTokens and send to pool + // update global lend and interest accumulated by the above amount + // send (payment amount - reservePoolRecords amount ) back to the pool + // subtract (payment -interest accumulated) from amount out and set borrow + // update borrow Stats + // make reservePoolRecords 0 + // make interest accumulated 0 + + // sending repayment to moduleAcc from borrower if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { return err } - borrowPos.AmountOut.Amount = borrowPos.AmountOut.Amount.Sub(payment.Amount).Add(borrowPos.InterestAccumulated.TruncateInt()) - - reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) - amtToReservePool := reservePoolRecords.ReservePoolInterest - - if amtToReservePool.TruncateInt().LTE(payment.Amount) { - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { - return types.ErrReserveRatesNotFound - } - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { - amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) - if err != nil { - return err - } - } - amtBackToPool := payment.Amount.Sub(amtToReservePool.TruncateInt()) - if amtBackToPool.GT(sdk.ZeroInt()) { - err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, amtBackToPool)) - if err != nil { - return err - } - poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(amtBackToPool) - poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(amtBackToPool) - k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) - } + err = k.UpdateReserveBalances(ctx, pair.AssetOut, pool.ModuleName, sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()), true) // this functions sends the amount to reserve pool from the cPool + if err != nil { + return err + } - reservePoolRecords.ReservePoolInterest = sdk.ZeroDec() - k.SetBorrowInterestTracker(ctx, reservePoolRecords) - } else { - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { - return types.ErrReserveRatesNotFound - } - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { - amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) - if err != nil { - return err - } + // calculation for tokens to be minted and updated in global lend and interest accumulated parameter + cTokensAmount := borrowPos.InterestAccumulated.TruncateInt().Sub(reservePoolRecords.ReservePoolInterest.TruncateInt()) + if cTokensAmount.LT(sdk.ZeroInt()) { + return types.ErrReserveRatesNotFound + } + if cTokensAmount.GT(sdk.ZeroInt()) { + err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, cTokensAmount)) + if err != nil { + return err } - reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(payment.Amount.ToDec()) - k.SetBorrowInterestTracker(ctx, reservePoolRecords) + poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(cTokensAmount) + poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(cTokensAmount) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) } - k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, payment.Amount.Sub(borrowPos.InterestAccumulated.TruncateInt()), false) - borrowPos.InterestAccumulated = sdk.ZeroDec() + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(sdk.NewDecFromInt(amtToReservePool.TruncateInt())) // the decimal precision is maintained + amtToSubFromBorrowPos := payment.Amount.Sub(borrowPos.InterestAccumulated.TruncateInt()) + borrowPos.AmountOut.Amount = borrowPos.AmountOut.Amount.Sub(amtToSubFromBorrowPos) + borrowPos.InterestAccumulated = borrowPos.InterestAccumulated.Sub(sdk.NewDecFromInt(borrowPos.InterestAccumulated.TruncateInt())) + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, amtToSubFromBorrowPos, false) } k.SetBorrow(ctx, borrowPos) + k.SetBorrowInterestTracker(ctx, reservePoolRecords) return nil } @@ -1225,6 +1239,14 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 lenderAddr, _ := sdk.AccAddressFromBech32(lendPos.Owner) poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) + // take final Amt from the user (AmountOut + interest Accumulated) and send to cPool + // return cToken Back to user + // send amt from reservePoolRecords to reserve pool + // mint cTokens from the (InterestAccumulated - Amnt To reserve pool) amt + // update global lend and interest accumulated from poolAssetLBMappingData + // delete borrow + // delete reservePoolRecords for that borrow ID + amt := sdk.NewCoins(sdk.NewCoin(assetOut.Denom, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()))) if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, amt); err != nil { return err @@ -1235,12 +1257,12 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) amtToReservePool := reservePoolRecords.ReservePoolInterest - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { + if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { return types.ErrReserveRatesNotFound } if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { amount := sdk.NewCoin(assetOut.Denom, amtToReservePool.TruncateInt()) - err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) + err = k.UpdateReserveBalances(ctx, pair.AssetOut, pool.ModuleName, amount, true) if err != nil { return err } @@ -1269,6 +1291,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 k.DeleteIDFromAssetStatsMapping(ctx, pair.AssetOutPoolID, pair.AssetOut, borrowID, false) k.DeleteBorrowIDFromUserMapping(ctx, lendPos.Owner, lendPos.ID, borrowID) k.DeleteBorrow(ctx, borrowID) + k.DeleteBorrowInterestTracker(ctx, borrowID) return nil } @@ -1418,14 +1441,6 @@ func (k Keeper) FundModAcc(ctx sdk.Context, moduleName string, assetID uint64, l return nil } -func (k Keeper) SetReserveBalances(ctx sdk.Context, moduleName string, assetID uint64, payment sdk.Coin) error { - err := k.UpdateReserveBalances(ctx, assetID, moduleName, payment, true) - if err != nil { - return err - } - return nil -} - func (k Keeper) Store(ctx sdk.Context) sdk.KVStore { return ctx.KVStore(k.storeKey) } diff --git a/x/lend/keeper/lend.go b/x/lend/keeper/lend.go index 8983dbf15..77ab12dcb 100644 --- a/x/lend/keeper/lend.go +++ b/x/lend/keeper/lend.go @@ -367,9 +367,9 @@ func (k Keeper) DeleteLendForAddressByAsset(ctx sdk.Context, address string, len store.Delete(key) } -func (k Keeper) DeleteIDFromAssetStatsMapping(ctx sdk.Context, poolID, assetID, id uint64, typeOfId bool) { +func (k Keeper) DeleteIDFromAssetStatsMapping(ctx sdk.Context, poolID, assetID, id uint64, typeOfID bool) { poolLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) - if typeOfId { + if typeOfID { lengthOfIDs := len(poolLBMappingData.LendIds) dataIndex := sort.Search(lengthOfIDs, func(i int) bool { return poolLBMappingData.LendIds[i] >= id }) diff --git a/x/lend/keeper/maths.go b/x/lend/keeper/maths.go index 0cb2cb524..e85e6ad97 100644 --- a/x/lend/keeper/maths.go +++ b/x/lend/keeper/maths.go @@ -135,17 +135,18 @@ func (k Keeper) UpdateAPR(ctx sdk.Context, poolID, assetID uint64) (PoolAssetLBD stableBorrowAPR, _ := k.GetBorrowAPRByAssetID(ctx, poolID, assetID, true) currentUtilisationRatio, _ := k.GetUtilisationRatioByPoolIDAndAssetID(ctx, poolID, assetID) PoolAssetLBData = types.PoolAssetLBMapping{ - PoolID: poolAssetLBData.PoolID, - AssetID: poolAssetLBData.AssetID, - LendIds: poolAssetLBData.LendIds, - BorrowIds: poolAssetLBData.BorrowIds, - TotalBorrowed: poolAssetLBData.TotalBorrowed, - TotalStableBorrowed: poolAssetLBData.TotalStableBorrowed, - TotalLend: poolAssetLBData.TotalLend, - LendApr: lendAPR, - BorrowApr: borrowAPR, - StableBorrowApr: stableBorrowAPR, - UtilisationRatio: currentUtilisationRatio, + PoolID: poolAssetLBData.PoolID, + AssetID: poolAssetLBData.AssetID, + LendIds: poolAssetLBData.LendIds, + BorrowIds: poolAssetLBData.BorrowIds, + TotalBorrowed: poolAssetLBData.TotalBorrowed, + TotalStableBorrowed: poolAssetLBData.TotalStableBorrowed, + TotalLend: poolAssetLBData.TotalLend, + TotalInterestAccumulated: poolAssetLBData.TotalInterestAccumulated, + LendApr: lendAPR, + BorrowApr: borrowAPR, + StableBorrowApr: stableBorrowAPR, + UtilisationRatio: currentUtilisationRatio, } return PoolAssetLBData, true } diff --git a/x/lend/keeper/pair.go b/x/lend/keeper/pair.go index 5f4a0594f..6b2ed3494 100644 --- a/x/lend/keeper/pair.go +++ b/x/lend/keeper/pair.go @@ -88,6 +88,13 @@ func (k Keeper) AddPoolRecords(ctx sdk.Context, pool types.Pool) error { assetStats.TotalInterestAccumulated = sdk.ZeroInt() k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) k.UpdateAPR(ctx, newPool.PoolID, v.AssetID) + reserveBuybackStats, found := k.GetReserveBuybackAssetData(ctx, v.AssetID) + if !found { + reserveBuybackStats.AssetID = v.AssetID + reserveBuybackStats.ReserveAmount = sdk.ZeroInt() + reserveBuybackStats.BuybackAmount = sdk.ZeroInt() + k.SetReserveBuybackAssetData(ctx, reserveBuybackStats) + } } k.SetPool(ctx, newPool) diff --git a/x/liquidation/expected/keeper.go b/x/liquidation/expected/keeper.go index 720c5424e..923144b26 100644 --- a/x/liquidation/expected/keeper.go +++ b/x/liquidation/expected/keeper.go @@ -68,8 +68,6 @@ type LendKeeper interface { VerifyCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error CalculateCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) - DeleteBorrow(ctx sdk.Context, id uint64) - CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found bool) diff --git a/x/liquidation/keeper/alias.go b/x/liquidation/keeper/alias.go index e10353365..400042778 100644 --- a/x/liquidation/keeper/alias.go +++ b/x/liquidation/keeper/alias.go @@ -125,10 +125,6 @@ func (k Keeper) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, f return k.lend.GetLend(ctx, id) } -func (k Keeper) DeleteBorrow(ctx sdk.Context, id uint64) { - k.lend.DeleteBorrow(ctx, id) -} - func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) { k.lend.CreteNewBorrow(ctx, liqBorrow) } @@ -137,14 +133,6 @@ func (k Keeper) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found return k.lend.GetPool(ctx, id) } -//func (k Keeper) GetBorrowStats(ctx sdk.Context) (borrowStats lendtypes.DepositStats, found bool) { -// return k.lend.GetBorrowStats(ctx) -//} -// -//func (k Keeper) SetBorrowStats(ctx sdk.Context, borrowStats lendtypes.DepositStats) { -// k.lend.SetBorrowStats(ctx, borrowStats) -//} - func (k Keeper) GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (AssetStats lendtypes.PoolAssetLBMapping, found bool) { return k.lend.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) } diff --git a/x/liquidity/client/testutil/helpers.go b/x/liquidity/client/testutil/helpers.go index 482f7962d..7308f1908 100644 --- a/x/liquidity/client/testutil/helpers.go +++ b/x/liquidity/client/testutil/helpers.go @@ -41,7 +41,7 @@ func MsgCreate( return clitestutil.ExecTestCLICmd(clientCtx, cli.Create(), args) } -func (s *LiquidityIntegrationTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { +func (s *LiquidityIntegrationTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { //nolint:unused s.T().Helper() err := s.app.BankKeeper.MintCoins(s.ctx, types.ModuleName, amt) s.Require().NoError(err) diff --git a/x/liquidity/keeper/params.go b/x/liquidity/keeper/params.go index 3b342b7be..cb0563445 100644 --- a/x/liquidity/keeper/params.go +++ b/x/liquidity/keeper/params.go @@ -84,7 +84,7 @@ func (k Keeper) UpdateGenericParams(ctx sdk.Context, appID uint64, keys, values if err != nil { return err } - validationErr := parseValidateFunctionMap[k][1].(func(interface{}) error)(parsedValueInterface) + validationErr := parseValidateFunctionMap[k][1].(func(interface{}) error)(parsedValueInterface) //nolint:forcetypeassert //this is just for validation of error if validationErr != nil { return validationErr } diff --git a/x/liquidity/keeper/swap.go b/x/liquidity/keeper/swap.go index 1de6c449d..6a84abc01 100644 --- a/x/liquidity/keeper/swap.go +++ b/x/liquidity/keeper/swap.go @@ -407,7 +407,7 @@ func (k Keeper) ExecuteMatching(ctx sdk.Context, pair types.Pair) error { return err } - if skip { //nolint TODO: update this when there are more than one pools + if skip { return nil } @@ -487,7 +487,6 @@ func (k Keeper) ApplyMatchResult(ctx sdk.Context, pair types.Pair, orders []amm. } else { o.SetStatus(types.OrderStatusPartiallyMatched) k.SetOrder(ctx, pair.AppId, o) - // nolint // TODO: emit an event? } bulkOp.QueueSendCoins(pair.GetEscrowAddress(), order.Orderer, sdk.NewCoins(order.ReceivedDemandCoin)) diff --git a/x/market/module.go b/x/market/module.go index 6eee30d6c..da93246bb 100644 --- a/x/market/module.go +++ b/x/market/module.go @@ -81,7 +81,7 @@ func (a AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - cdc codec.JSONCodec + cdc codec.JSONCodec //nolint:unused keeper keeper.Keeper } diff --git a/x/rewards/client/cli/flags.go b/x/rewards/client/cli/flags.go index d666cf7cb..dbc189a59 100644 --- a/x/rewards/client/cli/flags.go +++ b/x/rewards/client/cli/flags.go @@ -11,10 +11,11 @@ import ( const ( FlagStartTime = "start-time" - FlagPoolID = "pool-id" - FlagAppID = "app-id" - FlagIsMasterPool = "is-master-pool" - FlagChildPoolIds = "child-pool-ids" + FlagPoolID = "pool-id" + FlagAppID = "app-id" + FlagIsMasterPool = "is-master-pool" + FlagChildPoolIds = "child-pool-ids" + FlagAddLendExternalRewardsFile = "add-lend-external-rewards" ) // FlagSetCreateGauge returns flags for creating gauge. @@ -47,3 +48,23 @@ func ParseUint64SliceFromString(s string, separator string) ([]uint64, error) { } return parsedInts, nil } + +func FlagAddExternalLendRewardsMapping() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + fs.String(FlagAddLendExternalRewardsFile, "", "add lend-external-rewards json file path") + return fs +} + +type createAddLendExternalRewardsInputs struct { + AppID string `json:"app_id"` + CPoolID string `json:"c_pool_id"` + AssetID string `json:"asset_id"` + TotalRewards string `json:"total_rewards"` + RewardAssetID string `json:"reward_asset_id"` + Duration string `json:"duration"` + MinLockupTime string `json:"min_lockup_time"` + Title string + Description string + Deposit string +} diff --git a/x/rewards/client/cli/parse.go b/x/rewards/client/cli/parse.go new file mode 100644 index 000000000..8252ff31b --- /dev/null +++ b/x/rewards/client/cli/parse.go @@ -0,0 +1,53 @@ +package cli + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/spf13/pflag" + "os" +) + +type ( + XCreateAddExternalLendRewardsMappingInputs createAddLendExternalRewardsInputs +) + +type XCreateAddExternalLendRewardsMappingInputsExceptions struct { + XCreateAddExternalLendRewardsMappingInputs + Other *string // Other won't raise an error +} + +func (release *createAddLendExternalRewardsInputs) UnmarshalJSON(data []byte) error { + var createAddLendExternalRewardsMappingInputsE XCreateAddExternalLendRewardsMappingInputsExceptions + dec := json.NewDecoder(bytes.NewReader(data)) + dec.DisallowUnknownFields() // Force + + if err := dec.Decode(&createAddLendExternalRewardsMappingInputsE); err != nil { + return err + } + + *release = createAddLendExternalRewardsInputs(createAddLendExternalRewardsMappingInputsE.XCreateAddExternalLendRewardsMappingInputs) + return nil +} + +func parseAddExternalLendRewardsMappingFlags(fs *pflag.FlagSet) (*createAddLendExternalRewardsInputs, error) { + assetMapping := &createAddLendExternalRewardsInputs{} + addAssetMappingFile, _ := fs.GetString(FlagAddLendExternalRewardsFile) + + if addAssetMappingFile == "" { + return nil, fmt.Errorf("must pass in add External rewards lend mapping json using the --%s flag", FlagAddLendExternalRewardsFile) + } + + contents, err := os.ReadFile(addAssetMappingFile) + if err != nil { + return nil, err + } + + // make exception if unknown field exists + err = assetMapping.UnmarshalJSON(contents) + if err != nil { + return nil, err + } + + return assetMapping, nil +} diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go index 007695526..ed1651595 100644 --- a/x/rewards/client/cli/query.go +++ b/x/rewards/client/cli/query.go @@ -39,6 +39,7 @@ func GetQueryCmd() *cobra.Command { queryExternalRewardsLockers(), queryExternalRewardVaults(), queryWhitelistedAppIdsVault(), + queryExternalRewardLends(), ) return cmd @@ -469,3 +470,40 @@ func queryWhitelistedAppIdsVault() *cobra.Command { return cmd } + +func queryExternalRewardLends() *cobra.Command { + cmd := &cobra.Command{ + Use: "lend_external_rewards", + Short: "Query external-rewards of Lend", + RunE: func(cmd *cobra.Command, args []string) error { + ctx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pagination, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(ctx) + + res, err := queryClient.QueryExternalRewardLends( + context.Background(), + &types.QueryExternalRewardLendsRequest{ + Pagination: pagination, + }, + ) + if err != nil { + return err + } + + return ctx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "lend_external_rewards") + + return cmd +} diff --git a/x/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go index e3bf14970..895357763 100644 --- a/x/rewards/client/cli/tx.go +++ b/x/rewards/client/cli/tx.go @@ -3,6 +3,8 @@ package cli import ( "errors" "fmt" + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "strconv" "strings" "time" @@ -12,6 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" + flag "github.com/spf13/pflag" "github.com/cosmos/cosmos-sdk/client" @@ -278,3 +281,109 @@ func NewBuildLiquidityGaugeExtraData(cmd *cobra.Command) (types.MsgCreateGauge_L } return liquidityGaugeExtraData, nil } + +func SubmitAddLendExternalRewardsProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-lend-external-rewards [flags]", + Args: cobra.ExactArgs(0), + Short: "Submit External Lend Rewards", + Long: `Must provide path to a add lend external rewards in JSON file (--add-lend-rewards) +Sample json content +{ + "title" :"Add lend external rewards ", + "description" :"This proposal it to add lend external rewards for commodo app", + "deposit" :"1000000000ucmdx" +}`, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + txf, msg, err := NewAddLendExternalRewards(clientCtx, txf, cmd.Flags()) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().AddFlagSet(FlagAddExternalLendRewardsMapping()) + cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") + + return cmd +} + +func NewAddLendExternalRewards(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + externalRewardsLendMapping, err := parseAddExternalLendRewardsMappingFlags(fs) + if err != nil { + return txf, nil, fmt.Errorf("failed to parse lend external rewards: %w", err) + } + + from := clientCtx.GetFromAddress() + appID, err := strconv.ParseUint(externalRewardsLendMapping.AppID, 10, 64) + if err != nil { + return txf, nil, err + } + cPoolID, err := strconv.ParseUint(externalRewardsLendMapping.AppID, 10, 64) + if err != nil { + return txf, nil, err + } + assetID, err := ParseUint64SliceFromString(externalRewardsLendMapping.AssetID, ",") + if err != nil { + return txf, nil, err + } + + rewardsAssetPoolData := types.RewardsAssetPoolData{ + CPoolId: cPoolID, + AssetId: assetID, + } + totatRewards, err := sdk.ParseCoinNormalized(externalRewardsLendMapping.TotalRewards) + if err != nil { + return txf, nil, err + } + + rewardAssetID, err := strconv.ParseUint(externalRewardsLendMapping.RewardAssetID, 10, 64) + if err != nil { + return txf, nil, err + } + duration, err := strconv.ParseInt(externalRewardsLendMapping.Duration, 10, 64) + if err != nil { + return txf, nil, err + } + minLockup, err := strconv.ParseInt(externalRewardsLendMapping.MinLockupTime, 10, 64) + if err != nil { + return txf, nil, err + } + + externalRewardsLend := types.LendExternalRewards{ + AppMappingId: appID, + RewardsAssetPoolData: &rewardsAssetPoolData, + TotalRewards: totatRewards, + RewardAssetId: rewardAssetID, + DurationDays: duration, + Depositor: from.String(), + MinLockupTimeSeconds: minLockup, + } + + deposit, err := sdk.ParseCoinsNormalized(externalRewardsLendMapping.Deposit) + if err != nil { + return txf, nil, err + } + + content := types.NewAddExternalLendRewardsProposal(externalRewardsLendMapping.Title, externalRewardsLendMapping.Description, externalRewardsLend) + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return txf, nil, err + } + + if err = msg.ValidateBasic(); err != nil { + return txf, nil, err + } + + return txf, msg, nil +} diff --git a/x/rewards/client/proposal_handler.go b/x/rewards/client/proposal_handler.go new file mode 100644 index 000000000..8ef694ab9 --- /dev/null +++ b/x/rewards/client/proposal_handler.go @@ -0,0 +1,11 @@ +package client + +import ( + "github.com/comdex-official/comdex/x/rewards/client/cli" + "github.com/comdex-official/comdex/x/rewards/client/rest" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" +) + +var AddRewardsHandler = []govclient.ProposalHandler{ + govclient.NewProposalHandler(cli.SubmitAddLendExternalRewardsProposal, rest.AddLendExternalRewardsProposalRESTHandler), +} diff --git a/x/rewards/client/rest/tx.go b/x/rewards/client/rest/tx.go new file mode 100644 index 000000000..90cb5b98e --- /dev/null +++ b/x/rewards/client/rest/tx.go @@ -0,0 +1,28 @@ +package rest + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/rest" + govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" + "net/http" +) + +type ( + LendExternalRewards struct{} +) + +func AddLendExternalRewardsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { + return govrest.ProposalRESTHandler{ + SubRoute: "add-lend-external-rewards", + Handler: NewAddLendExternalRewardsRESTHandler(clientCtx), + } +} +func NewAddLendExternalRewardsRESTHandler(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req LendExternalRewards + + if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { + return + } + } +} diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index ac9f0d26a..dca3efe88 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -8,7 +8,7 @@ import ( ) func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { - var gaugeID uint64 = 0 + var gaugeID uint64 k.SetParams(ctx, state.Params) diff --git a/x/rewards/handler.go b/x/rewards/handler.go index 9158ad2c7..54ec30da4 100644 --- a/x/rewards/handler.go +++ b/x/rewards/handler.go @@ -2,6 +2,7 @@ package rewards import ( "fmt" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -35,3 +36,19 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } } } + +func NewAddRewardsProposalHandler(k keeper.Keeper) govtypes.Handler { + return func(ctx sdk.Context, content govtypes.Content) error { + switch c := content.(type) { + case *types.AddLendExternalRewardsProposal: + return handleAddLendRewardsProposal(ctx, k, c) + + default: + return sdkerrors.Wrapf(types.ErrorUnknownProposalType, "%T", c) + } + } +} + +func handleAddLendRewardsProposal(ctx sdk.Context, k keeper.Keeper, p *types.AddLendExternalRewardsProposal) error { + return k.HandleProposalAddLendRewards(ctx, p) +} diff --git a/x/rewards/keeper/distribution.go b/x/rewards/keeper/distribution.go index 01f2b2b96..47c4ea047 100644 --- a/x/rewards/keeper/distribution.go +++ b/x/rewards/keeper/distribution.go @@ -16,7 +16,7 @@ func (k Keeper) GetRewardDistributionData( gaugeType := gauge.Kind var rewardDistributionData []types.RewardDistributionDataCollector - var err error = nil + var err error switch gaugeExtraData := gaugeType.(type) { case *types.Gauge_LiquidityMetaData: diff --git a/x/rewards/keeper/gauge.go b/x/rewards/keeper/gauge.go index cae3a2c35..82177ace5 100644 --- a/x/rewards/keeper/gauge.go +++ b/x/rewards/keeper/gauge.go @@ -24,7 +24,7 @@ func (k Keeper) ValidateMsgCreateGauge(ctx sdk.Context, msg *types.MsgCreateGaug return types.ErrInvalidGaugeTypeID } - if msg.TriggerDuration <= 0 { + if msg.TriggerDuration < types.MinimumEpochDuration { return types.ErrInvalidDuration } diff --git a/x/rewards/keeper/gov.go b/x/rewards/keeper/gov.go new file mode 100644 index 000000000..18060d21e --- /dev/null +++ b/x/rewards/keeper/gov.go @@ -0,0 +1,10 @@ +package keeper + +import ( + "github.com/comdex-official/comdex/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) HandleProposalAddLendRewards(ctx sdk.Context, p *types.AddLendExternalRewardsProposal) error { + return k.AddLendExternalRewards(ctx, p.LendExternalRewards) +} diff --git a/x/rewards/keeper/grpc_query.go b/x/rewards/keeper/grpc_query.go index f4eb505bc..921b73c28 100644 --- a/x/rewards/keeper/grpc_query.go +++ b/x/rewards/keeper/grpc_query.go @@ -249,3 +249,17 @@ func (k Keeper) QueryWhitelistedAppIdsVault(c context.Context, req *types.QueryW WhitelistedAppIdsVault: items, }, nil } + +func (k Keeper) QueryExternalRewardLends(c context.Context, req *types.QueryExternalRewardLendsRequest) (*types.QueryExternalRewardLendsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "request cannot be empty") + } + + ctx := sdk.UnwrapSDKContext(c) + + items := k.GetExternalRewardLends(ctx) + + return &types.QueryExternalRewardLendsResponse{ + LendExternalRewards: items, + }, nil +} diff --git a/x/rewards/keeper/iter.go b/x/rewards/keeper/iter.go index 5b0672085..66bf9ad71 100644 --- a/x/rewards/keeper/iter.go +++ b/x/rewards/keeper/iter.go @@ -135,7 +135,6 @@ func (k Keeper) DistributeExtRewardVault(ctx sdk.Context) error { // calculate new locker rewards func (k Keeper) CalculationOfRewards( ctx sdk.Context, - // nolint amount sdk.Int, lsr sdk.Dec, bTime int64, ) (sdk.Dec, error) { currentTime := ctx.BlockTime().Unix() @@ -183,47 +182,45 @@ func (k Keeper) DistributeExtRewardLend(ctx sdk.Context) error { if epoch.Count < uint64(extRewards[i].DurationDays) { // we will only consider the borrows of the pool and assetID defined totalBorrowedAmt := sdk.ZeroInt() - for _, rewardsAssetPoolData := range v.RewardsAssetPoolData { - for _, assetID := range rewardsAssetPoolData.AssetId { - borrowByPoolIDAssetID, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, rewardsAssetPoolData.CPoolId, assetID) - price, err := k.CalcAssetPrice(ctx, assetID, borrowByPoolIDAssetID.TotalBorrowed.Add(borrowByPoolIDAssetID.TotalStableBorrowed)) - if err != nil { - return err - } - totalBorrowedAmt = totalBorrowedAmt.Add(price) + rewardsAssetPoolData := extRewards[i].RewardsAssetPoolData + for _, assetID := range rewardsAssetPoolData.AssetId { + borrowByPoolIDAssetID, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, rewardsAssetPoolData.CPoolId, assetID) + price, err := k.CalcAssetPrice(ctx, assetID, borrowByPoolIDAssetID.TotalBorrowed.Add(borrowByPoolIDAssetID.TotalStableBorrowed)) + if err != nil { + return err } + totalBorrowedAmt = totalBorrowedAmt.Add(price) } + totalRewardAmt, _ := k.CalcAssetPrice(ctx, v.RewardAssetId, v.TotalRewards.Amount) totalAPR := sdk.NewDecFromInt(totalRewardAmt).Quo(sdk.NewDecFromInt(totalBorrowedAmt)) var inverseRatesSum sdk.Dec - for _, rewardsAssetPoolData := range v.RewardsAssetPoolData { - for _, assetID := range rewardsAssetPoolData.AssetId { - inverseRate := k.InversingRates(ctx, assetID, rewardsAssetPoolData.CPoolId, totalRewardAmt) - inverseRatesSum = inverseRatesSum.Add(inverseRate) - } + + for _, assetID := range rewardsAssetPoolData.AssetId { + inverseRate := k.InversingRates(ctx, assetID, rewardsAssetPoolData.CPoolId, totalRewardAmt) + inverseRatesSum = inverseRatesSum.Add(inverseRate) } - for _, rewardsAssetPoolData := range v.RewardsAssetPoolData { - for _, assetID := range rewardsAssetPoolData.AssetId { - borrowIDs, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, rewardsAssetPoolData.CPoolId, assetID) - for _, borrowID := range borrowIDs.BorrowIds { - borrow, _ := k.GetBorrow(ctx, borrowID) - lend, _ := k.GetLend(ctx, borrow.LendingID) - inverseRate := k.InversingRates(ctx, assetID, rewardsAssetPoolData.CPoolId, totalRewardAmt) - numerator := totalAPR.Mul(inverseRate) - finalAPR := numerator.Quo(inverseRatesSum) - finalDailyRewardsNumerator := sdk.NewDecFromInt(borrow.AmountOut.Amount).Mul(finalAPR) - daysInYear, _ := sdk.NewDecFromStr(types.DaysInYear) - finalDailyRewardsPerUser := finalDailyRewardsNumerator.Quo(daysInYear) - user, _ := sdk.AccAddressFromBech32(lend.Owner) - if finalDailyRewardsPerUser.TruncateInt().GT(sdk.ZeroInt()) { - err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, user, sdk.NewCoin(v.TotalRewards.Denom, finalDailyRewardsPerUser.TruncateInt())) - if err != nil { - continue - } + for _, assetID := range rewardsAssetPoolData.AssetId { + borrowIDs, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, rewardsAssetPoolData.CPoolId, assetID) + for _, borrowID := range borrowIDs.BorrowIds { + borrow, _ := k.GetBorrow(ctx, borrowID) + lend, _ := k.GetLend(ctx, borrow.LendingID) + inverseRate := k.InversingRates(ctx, assetID, rewardsAssetPoolData.CPoolId, totalRewardAmt) + numerator := totalAPR.Mul(inverseRate) + finalAPR := numerator.Quo(inverseRatesSum) + finalDailyRewardsNumerator := sdk.NewDecFromInt(borrow.AmountOut.Amount).Mul(finalAPR) + daysInYear, _ := sdk.NewDecFromStr(types.DaysInYear) + finalDailyRewardsPerUser := finalDailyRewardsNumerator.Quo(daysInYear) + user, _ := sdk.AccAddressFromBech32(lend.Owner) + if finalDailyRewardsPerUser.TruncateInt().GT(sdk.ZeroInt()) { + err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, user, sdk.NewCoin(v.TotalRewards.Denom, finalDailyRewardsPerUser.TruncateInt())) + if err != nil { + continue } } } + } epoch.Count = epoch.Count + types.UInt64One epoch.StartingTime = timeNow + types.SecondsPerDay diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index bd89cdd03..8bd109054 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -120,7 +120,6 @@ func (k Keeper) ActExternalRewardsLockers( assetID uint64, totalRewards sdk.Coin, durationDays int64, - // nolint depositor sdk.AccAddress, minLockupTimeSeconds int64, ) error { @@ -176,7 +175,6 @@ func (k Keeper) ActExternalRewardsVaults( appMappingID uint64, extendedPairID uint64, durationDays, minLockupTimeSeconds int64, totalRewards sdk.Coin, - // nolint depositor sdk.AccAddress, ) error { id := k.GetExternalRewardsVaultID(ctx) @@ -283,3 +281,41 @@ func (k Keeper) WasmRemoveWhitelistAppIDVaultInterestQuery(ctx sdk.Context, appM } return true, "" } + +func (k Keeper) AddLendExternalRewards(ctx sdk.Context, msg types.LendExternalRewards) error { + id := k.GetExternalRewardsLendID(ctx) + endTime := ctx.BlockTime().Add(time.Second * time.Duration(msg.DurationDays*types.SecondsPerDay)) + epochID := k.GetEpochTimeID(ctx) + + epoch := types.EpochTime{ + Id: epochID + 1, + AppMappingId: msg.AppMappingId, + StartingTime: ctx.BlockTime().Unix() + 84600, + } + msg = types.LendExternalRewards{ + Id: id + 1, + AppMappingId: msg.AppMappingId, + RewardsAssetPoolData: msg.RewardsAssetPoolData, + TotalRewards: msg.TotalRewards, + RewardAssetId: msg.RewardAssetId, + DurationDays: msg.DurationDays, + IsActive: true, + AvailableRewards: msg.TotalRewards, + Depositor: msg.Depositor, + StartTimestamp: ctx.BlockTime(), + EndTimestamp: endTime, + MinLockupTimeSeconds: msg.MinLockupTimeSeconds, + EpochId: epoch.Id, + } + depositor, _ := sdk.AccAddressFromBech32(msg.Depositor) + + if err := k.bank.SendCoinsFromAccountToModule(ctx, depositor, types.ModuleName, sdk.NewCoins(msg.TotalRewards)); err != nil { + return err + } + + k.SetEpochTimeID(ctx, msg.EpochId) + k.SetExternalRewardLend(ctx, msg) + k.SetExternalRewardsLendID(ctx, msg.Id) + k.SetEpochTime(ctx, epoch) + return nil +} diff --git a/x/rewards/keeper/rewards.go b/x/rewards/keeper/rewards.go index 2341456f4..6bdd507fc 100644 --- a/x/rewards/keeper/rewards.go +++ b/x/rewards/keeper/rewards.go @@ -23,10 +23,10 @@ func (k Keeper) SetReward(ctx sdk.Context, rewards types.InternalRewards) { store.Set(key, value) } -func (k Keeper) GetReward(ctx sdk.Context, appId, assetID uint64) (rewards types.InternalRewards, found bool) { +func (k Keeper) GetReward(ctx sdk.Context, appID, assetID uint64) (rewards types.InternalRewards, found bool) { var ( store = k.Store(ctx) - key = types.RewardsKey(appId, assetID) + key = types.RewardsKey(appID, assetID) value = store.Get(key) ) @@ -46,10 +46,10 @@ func (k Keeper) DeleteReward(ctx sdk.Context, appID, assetID uint64) { store.Delete(key) } -func (k Keeper) GetRewardByApp(ctx sdk.Context, appId uint64) (rewards []types.InternalRewards, found bool) { +func (k Keeper) GetRewardByApp(ctx sdk.Context, appID uint64) (rewards []types.InternalRewards, found bool) { var ( store = k.Store(ctx) - key = types.RewardsKeyByApp(appId) + key = types.RewardsKeyByApp(appID) iter = sdk.KVStorePrefixIterator(store, key) ) @@ -347,37 +347,6 @@ func (k Keeper) SetExternalRewardVault(ctx sdk.Context, VaultExternalRewards typ store.Set(key, value) } -func (k Keeper) GetExternalRewardLends(ctx sdk.Context) (LendExternalRewards []types.LendExternalRewards) { - var ( - store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.ExternalRewardsLendKeyPrefix) - ) - - defer func(iter sdk.Iterator) { - err := iter.Close() - if err != nil { - return - } - }(iter) - - for ; iter.Valid(); iter.Next() { - var LendExternalReward types.LendExternalRewards - k.cdc.MustUnmarshal(iter.Value(), &LendExternalReward) - LendExternalRewards = append(LendExternalRewards, LendExternalReward) - } - - return LendExternalRewards -} - -func (k Keeper) SetExternalRewardLend(ctx sdk.Context, LendExternalRewards types.LendExternalRewards) { - var ( - store = k.Store(ctx) - key = types.ExternalRewardsLendMappingKey(LendExternalRewards.Id) - value = k.cdc.MustMarshal(&LendExternalRewards) - ) - store.Set(key, value) -} - // Wasm query checks func (k Keeper) GetRemoveWhitelistAppIDLockerRewardsCheck(ctx sdk.Context, appMappingID uint64, assetIDs uint64) (found bool, err string) { @@ -578,92 +547,91 @@ func (k Keeper) CalculateLockerRewards(ctx sdk.Context, appID, assetID, lockerID if !found { return collectortypes.ErrorAssetDoesNotExist } - rewards := sdk.ZeroDec() + var rewards sdk.Dec var err error collectorBTime := collectorLookup.BlockTime.Unix() if collectorLookup.LockerSavingRate.IsZero() { return nil + } + + if blockHeight == 0 { + // take bh from lsr + rewards, err = k.CalculationOfRewards(ctx, NetBalance, collectorLookup.LockerSavingRate, collectorBTime) + if err != nil { + return nil + } } else { - if blockHeight == 0 { - // take bh from lsr - rewards, err = k.CalculationOfRewards(ctx, NetBalance, collectorLookup.LockerSavingRate, collectorBTime) - if err != nil { - return nil - } - } else { - rewards, err = k.CalculationOfRewards(ctx, NetBalance, collectorLookup.LockerSavingRate, lockerBlockTime) - if err != nil { - return nil - } + rewards, err = k.CalculationOfRewards(ctx, NetBalance, collectorLookup.LockerSavingRate, lockerBlockTime) + if err != nil { + return nil } - lockerData, _ := k.GetLocker(ctx, lockerID) - lockerRewardsTracker, found := k.GetLockerRewardTracker(ctx, lockerData.LockerId, appID) + } + lockerData, _ := k.GetLocker(ctx, lockerID) + lockerRewardsTracker, found := k.GetLockerRewardTracker(ctx, lockerData.LockerId, appID) + if !found { + lockerRewardsTracker = types.LockerRewardsTracker{ + LockerId: lockerData.LockerId, + AppMappingId: appID, + RewardsAccumulated: rewards, + } + } else { + lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Add(rewards) + } + + if lockerRewardsTracker.RewardsAccumulated.GTE(sdk.OneDec()) { + // send rewards + newReward := lockerRewardsTracker.RewardsAccumulated.TruncateInt() + newRewardDec := sdk.NewDec(newReward.Int64()) + lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Sub(newRewardDec) + k.SetLockerRewardTracker(ctx, lockerRewardsTracker) + netFeeCollectedData, found := k.GetNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId) if !found { - lockerRewardsTracker = types.LockerRewardsTracker{ - LockerId: lockerData.LockerId, - AppMappingId: appID, - RewardsAccumulated: rewards, - } - } else { - lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Add(rewards) + return nil + } + err = k.DecreaseNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId, newReward, netFeeCollectedData) + if err != nil { + return nil } + assetData, _ := k.GetAsset(ctx, assetID) - if lockerRewardsTracker.RewardsAccumulated.GTE(sdk.OneDec()) { - // send rewards - newReward := sdk.ZeroInt() - newReward = lockerRewardsTracker.RewardsAccumulated.TruncateInt() - newRewardDec := sdk.NewDec(newReward.Int64()) - lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Sub(newRewardDec) - k.SetLockerRewardTracker(ctx, lockerRewardsTracker) - netFeeCollectedData, found := k.GetNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId) - if !found { + if newReward.GT(sdk.ZeroInt()) { + err = k.SendCoinFromModuleToModule(ctx, collectortypes.ModuleName, lockertypes.ModuleName, sdk.NewCoins(sdk.NewCoin(assetData.Denom, newReward))) + if err != nil { return nil } - err = k.DecreaseNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId, newReward, netFeeCollectedData) + } + lockerRewardsMapping, found := k.GetLockerTotalRewardsByAssetAppWise(ctx, appID, lockerData.AssetDepositId) + if !found { + var lockerReward lockertypes.LockerTotalRewardsByAssetAppWise + lockerReward.AppId = appID + lockerReward.AssetId = lockerData.AssetDepositId + lockerReward.TotalRewards = newReward + err = k.SetLockerTotalRewardsByAssetAppWise(ctx, lockerReward) if err != nil { return nil } - assetData, _ := k.GetAsset(ctx, assetID) - - if newReward.GT(sdk.ZeroInt()) { - err = k.SendCoinFromModuleToModule(ctx, collectortypes.ModuleName, lockertypes.ModuleName, sdk.NewCoins(sdk.NewCoin(assetData.Denom, newReward))) - if err != nil { - return nil - } - } - lockerRewardsMapping, found := k.GetLockerTotalRewardsByAssetAppWise(ctx, appID, lockerData.AssetDepositId) - if !found { - var lockerReward lockertypes.LockerTotalRewardsByAssetAppWise - lockerReward.AppId = appID - lockerReward.AssetId = lockerData.AssetDepositId - lockerReward.TotalRewards = newReward - err = k.SetLockerTotalRewardsByAssetAppWise(ctx, lockerReward) - if err != nil { - return nil - } - } else { - lockerRewardsMapping.TotalRewards = lockerRewardsMapping.TotalRewards.Add(newReward) - err = k.SetLockerTotalRewardsByAssetAppWise(ctx, lockerRewardsMapping) - if err != nil { - return nil - } - } - // updating user rewards data - lockerData.BlockTime = ctx.BlockTime() - lockerData.BlockHeight = ctx.BlockHeight() - - lockerData.NetBalance = lockerData.NetBalance.Add(newReward) - lockerData.ReturnsAccumulated = lockerData.ReturnsAccumulated.Add(newReward) - k.SetLocker(ctx, lockerData) - lockers.DepositedAmount = lockers.DepositedAmount.Add(newReward) - k.SetLockerLookupTable(ctx, lockers) } else { - // set tracker rewards - k.SetLockerRewardTracker(ctx, lockerRewardsTracker) - lockerData.BlockTime = ctx.BlockTime() - lockerData.BlockHeight = ctx.BlockHeight() - k.SetLocker(ctx, lockerData) + lockerRewardsMapping.TotalRewards = lockerRewardsMapping.TotalRewards.Add(newReward) + err = k.SetLockerTotalRewardsByAssetAppWise(ctx, lockerRewardsMapping) + if err != nil { + return nil + } } + // updating user rewards data + lockerData.BlockTime = ctx.BlockTime() + lockerData.BlockHeight = ctx.BlockHeight() + + lockerData.NetBalance = lockerData.NetBalance.Add(newReward) + lockerData.ReturnsAccumulated = lockerData.ReturnsAccumulated.Add(newReward) + k.SetLocker(ctx, lockerData) + lockers.DepositedAmount = lockers.DepositedAmount.Add(newReward) + k.SetLockerLookupTable(ctx, lockers) + } else { + // set tracker rewards + k.SetLockerRewardTracker(ctx, lockerRewardsTracker) + lockerData.BlockTime = ctx.BlockTime() + lockerData.BlockHeight = ctx.BlockHeight() + k.SetLocker(ctx, lockerData) } return nil @@ -679,57 +647,126 @@ func (k Keeper) CalculateVaultInterest(ctx sdk.Context, appID, extendedPairID, v return assettypes.ErrorPairDoesNotExist } - interest := sdk.ZeroDec() - var err error extPairVaultBTime := ExtPairVaultData.BlockTime.Unix() if ExtPairVaultData.StabilityFee.IsZero() || ExtPairVaultData.IsStableMintVault { return nil - } else { - if blockHeight == 0 { - // take bh from ext pair - interest, err = k.CalculationOfRewards(ctx, totalDebt, ExtPairVaultData.StabilityFee, extPairVaultBTime) - if err != nil { - return nil - } - } else { - interest, err = k.CalculationOfRewards(ctx, totalDebt, ExtPairVaultData.StabilityFee, vaultBlockTime) - if err != nil { - return nil - } - } - vaultData, _ := k.GetVault(ctx, vaultID) - vaultInterestTracker, found := k.GetVaultInterestTracker(ctx, vaultData.Id, appID) - if !found { - vaultInterestTracker = types.VaultInterestTracker{ - VaultId: vaultData.Id, - AppMappingId: appID, - InterestAccumulated: interest, - } - } else { - vaultInterestTracker.InterestAccumulated = vaultInterestTracker.InterestAccumulated.Add(interest) + } + + blockTime := vaultBlockTime + if blockHeight == 0 { + blockTime = extPairVaultBTime + } + interest, err := k.CalculationOfRewards(ctx, totalDebt, ExtPairVaultData.StabilityFee, blockTime) + if err != nil { + return err + } + + vaultData, _ := k.GetVault(ctx, vaultID) + vaultInterestTracker, found := k.GetVaultInterestTracker(ctx, vaultData.Id, appID) + if !found { + vaultInterestTracker = types.VaultInterestTracker{ + VaultId: vaultData.Id, + AppMappingId: appID, + InterestAccumulated: interest, } + } else { + vaultInterestTracker.InterestAccumulated = vaultInterestTracker.InterestAccumulated.Add(interest) + } - if vaultInterestTracker.InterestAccumulated.GTE(sdk.OneDec()) { - newInterest := sdk.ZeroInt() - newInterest = vaultInterestTracker.InterestAccumulated.TruncateInt() - newInterestDec := sdk.NewDec(newInterest.Int64()) - vaultInterestTracker.InterestAccumulated = vaultInterestTracker.InterestAccumulated.Sub(newInterestDec) + if vaultInterestTracker.InterestAccumulated.GTE(sdk.OneDec()) { + newInterest := vaultInterestTracker.InterestAccumulated.TruncateInt() + newInterestDec := sdk.NewDec(newInterest.Int64()) + vaultInterestTracker.InterestAccumulated = vaultInterestTracker.InterestAccumulated.Sub(newInterestDec) - vaultData.BlockTime = ctx.BlockTime() - vaultData.BlockHeight = ctx.BlockHeight() + vaultData.BlockTime = ctx.BlockTime() + vaultData.BlockHeight = ctx.BlockHeight() - k.SetVaultInterestTracker(ctx, vaultInterestTracker) - intAcc := vaultData.InterestAccumulated - updatedIntAcc := (intAcc).Add(newInterest) - vaultData.InterestAccumulated = updatedIntAcc - k.SetVault(ctx, vaultData) - } else { - k.SetVaultInterestTracker(ctx, vaultInterestTracker) - vaultData.BlockTime = ctx.BlockTime() - vaultData.BlockHeight = ctx.BlockHeight() - k.SetVault(ctx, vaultData) - } + k.SetVaultInterestTracker(ctx, vaultInterestTracker) + intAcc := vaultData.InterestAccumulated + updatedIntAcc := (intAcc).Add(newInterest) + vaultData.InterestAccumulated = updatedIntAcc + k.SetVault(ctx, vaultData) + } else { + k.SetVaultInterestTracker(ctx, vaultInterestTracker) + vaultData.BlockTime = ctx.BlockTime() + vaultData.BlockHeight = ctx.BlockHeight() + k.SetVault(ctx, vaultData) } return nil } + +func (k Keeper) GetExternalRewardLends(ctx sdk.Context) (LendExternalRewards []types.LendExternalRewards) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.ExternalRewardsLendKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var LendExternalReward types.LendExternalRewards + k.cdc.MustUnmarshal(iter.Value(), &LendExternalReward) + LendExternalRewards = append(LendExternalRewards, LendExternalReward) + } + + return LendExternalRewards +} + +func (k Keeper) SetExternalRewardLend(ctx sdk.Context, LendExternalRewards types.LendExternalRewards) { + var ( + store = k.Store(ctx) + key = types.ExternalRewardsLendMappingKey(LendExternalRewards.Id) + value = k.cdc.MustMarshal(&LendExternalRewards) + ) + store.Set(key, value) +} + +func (k Keeper) GetExternalRewardLend(ctx sdk.Context, id uint64) (LendExternalRewards types.LendExternalRewards) { + var ( + store = k.Store(ctx) + key = types.ExternalRewardsLendMappingKey(id) + value = store.Get(key) + ) + if value == nil { + return LendExternalRewards + } + k.cdc.MustUnmarshal(value, &LendExternalRewards) + return LendExternalRewards +} + +func (k Keeper) SetExternalRewardsLendID(ctx sdk.Context, id uint64) { + var ( + store = k.Store(ctx) + key = types.ExtRewardsLendIDKey + value = k.cdc.MustMarshal( + &protobuftypes.UInt64Value{ + Value: id, + }, + ) + ) + + store.Set(key, value) +} + +func (k Keeper) GetExternalRewardsLendID(ctx sdk.Context) uint64 { + var ( + store = k.Store(ctx) + key = types.ExtRewardsLendIDKey + value = store.Get(key) + ) + + if value == nil { + return 0 + } + + var id protobuftypes.UInt64Value + k.cdc.MustUnmarshal(value, &id) + + return id.GetValue() +} diff --git a/x/rewards/module.go b/x/rewards/module.go index f881f28e5..b92242426 100644 --- a/x/rewards/module.go +++ b/x/rewards/module.go @@ -103,7 +103,6 @@ type AppModule struct { } func NewAppModule( - // nolint cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, diff --git a/x/rewards/types/codec.go b/x/rewards/types/codec.go index c8c709247..cc0fa8d08 100644 --- a/x/rewards/types/codec.go +++ b/x/rewards/types/codec.go @@ -6,15 +6,21 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateGauge{}, "comdex/rewards/MsgCreateGauge", nil) cdc.RegisterConcrete(&ActivateExternalRewardsLockers{}, "comdex/rewards/activateExternalRewardsLockers", nil) cdc.RegisterConcrete(&ActivateExternalRewardsVault{}, "comdex/rewards/activateExternalRewardsVault", nil) + cdc.RegisterConcrete(&AddLendExternalRewardsProposal{}, "comdex/rewards/AddLendExternalRewardsProposal", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*govtypes.Content)(nil), + &AddLendExternalRewardsProposal{}, + ) registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgCreateGauge{}, diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index f7565e23a..2fc020150 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -35,4 +35,5 @@ var ( SendCoinsFromAccountToModuleInRewardsIsZero = sdkerrors.Register(ModuleName, 1113, "Coin value in account to module transfer in rewards is zero") ErrInternalRewardsNotFound = sdkerrors.Register(ModuleName, 1114, "Internal rewards not found") ErrStablemintVaultFound = sdkerrors.Register(ModuleName, 1115, "Can't give reward to stablemint vault") + ErrorUnknownProposalType = sdkerrors.Register(ModuleName, 1116, "unknown proposal type") ) diff --git a/x/rewards/types/gauge.go b/x/rewards/types/gauge.go index c53aced3e..ed851ed04 100644 --- a/x/rewards/types/gauge.go +++ b/x/rewards/types/gauge.go @@ -1,7 +1,10 @@ package types +import "time" + const ( LiquidityGaugeTypeID = 1 + MinimumEpochDuration = time.Hour * 12 ) // ValidGaugeTypeIds stores all the gauge types ids diff --git a/x/rewards/types/gov.go b/x/rewards/types/gov.go new file mode 100644 index 000000000..72e59512f --- /dev/null +++ b/x/rewards/types/gov.go @@ -0,0 +1,44 @@ +package types + +import govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + +const ( + ProposalAddLendRewards = "AddLendRewards" +) + +func init() { + govtypes.RegisterProposalType(ProposalAddLendRewards) + govtypes.RegisterProposalTypeCodec(&AddLendExternalRewardsProposal{}, "comdex/AddLendExternalRewardsProposal") +} + +var ( + _ govtypes.Content = &AddLendExternalRewardsProposal{} +) + +func NewAddExternalLendRewardsProposal(title, description string, lendExternalRewards LendExternalRewards) govtypes.Content { + return &AddLendExternalRewardsProposal{ + Title: title, + Description: description, + LendExternalRewards: lendExternalRewards, + } +} + +func (p *AddLendExternalRewardsProposal) GetTitle() string { + return p.Title +} + +func (p *AddLendExternalRewardsProposal) GetDescription() string { + return p.Description +} +func (p *AddLendExternalRewardsProposal) ProposalRoute() string { return RouterKey } + +func (p *AddLendExternalRewardsProposal) ProposalType() string { return ProposalAddLendRewards } + +func (p *AddLendExternalRewardsProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(p) + if err != nil { + return err + } + + return nil +} diff --git a/x/rewards/types/gov.pb.go b/x/rewards/types/gov.pb.go new file mode 100644 index 000000000..d7760bfe7 --- /dev/null +++ b/x/rewards/types/gov.pb.go @@ -0,0 +1,410 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/rewards/v1beta1/gov.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AddLendExternalRewardsProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + LendExternalRewards LendExternalRewards `protobuf:"bytes,3,opt,name=lend_external_rewards,json=lendExternalRewards,proto3" json:"lend_external_rewards"` +} + +func (m *AddLendExternalRewardsProposal) Reset() { *m = AddLendExternalRewardsProposal{} } +func (m *AddLendExternalRewardsProposal) String() string { return proto.CompactTextString(m) } +func (*AddLendExternalRewardsProposal) ProtoMessage() {} +func (*AddLendExternalRewardsProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_67590e1cf8f0fbab, []int{0} +} +func (m *AddLendExternalRewardsProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddLendExternalRewardsProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddLendExternalRewardsProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AddLendExternalRewardsProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddLendExternalRewardsProposal.Merge(m, src) +} +func (m *AddLendExternalRewardsProposal) XXX_Size() int { + return m.Size() +} +func (m *AddLendExternalRewardsProposal) XXX_DiscardUnknown() { + xxx_messageInfo_AddLendExternalRewardsProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_AddLendExternalRewardsProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*AddLendExternalRewardsProposal)(nil), "comdex.rewards.v1beta1.AddLendExternalRewardsProposal") +} + +func init() { proto.RegisterFile("comdex/rewards/v1beta1/gov.proto", fileDescriptor_67590e1cf8f0fbab) } + +var fileDescriptor_67590e1cf8f0fbab = []byte{ + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0xe3, 0xff, 0x07, 0x24, 0x52, 0x06, 0x14, 0xa0, 0xaa, 0x3a, 0xb8, 0x55, 0x84, 0x50, + 0x97, 0xc6, 0x2a, 0x2c, 0x88, 0x8d, 0x4a, 0x6c, 0x1d, 0x50, 0xd8, 0x58, 0x2a, 0x27, 0x76, 0x83, + 0x25, 0x37, 0x37, 0x8a, 0x4d, 0x69, 0xdf, 0x82, 0xc7, 0xe0, 0x51, 0x3a, 0x76, 0x64, 0xaa, 0x20, + 0x19, 0xd9, 0xfa, 0x04, 0xa8, 0xb1, 0x81, 0x4a, 0x94, 0xcd, 0xf6, 0xf9, 0x7c, 0xcf, 0xb9, 0xc7, + 0x6d, 0xc7, 0x30, 0x66, 0x7c, 0x4a, 0x72, 0xfe, 0x44, 0x73, 0xa6, 0xc8, 0xa4, 0x17, 0x71, 0x4d, + 0x7b, 0x24, 0x81, 0x49, 0x90, 0xe5, 0xa0, 0xc1, 0xab, 0x1b, 0x22, 0xb0, 0x44, 0x60, 0x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, 0x41, 0xa5, 0xbd, 0x93, 0x9f, 0x4a, 0xf5, 0x2c, 0xe3, 0x2a, 0xda, + 0xab, 0x9a, 0xbc, 0xf8, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x09, 0x07, 0xa6, 0x48, 0xe1, 0x01, 0x00, + 0x00, +} + +func (m *AddLendExternalRewardsProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AddLendExternalRewardsProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddLendExternalRewardsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.LendExternalRewards.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AddLendExternalRewardsProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = m.LendExternalRewards.Size() + n += 1 + l + sovGov(uint64(l)) + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AddLendExternalRewardsProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AddLendExternalRewardsProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddLendExternalRewardsProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LendExternalRewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LendExternalRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rewards/types/keys.go b/x/rewards/types/keys.go index d64039599..809d5eb63 100644 --- a/x/rewards/types/keys.go +++ b/x/rewards/types/keys.go @@ -37,6 +37,7 @@ var ( EpochTimeIDKey = []byte{0x17} EpochForLockerKeyPrefix = []byte{0x20} ExternalRewardsLendKeyPrefix = []byte{0x27} + ExtRewardsLendIDKey = []byte{0x28} // EpochInfoByDurationKeyPrefix defines the prefix to store EpochInfo by duration. EpochInfoByDurationKeyPrefix = []byte{0x21} diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index 50fc1a6f5..d9c9f0d82 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -1044,6 +1044,102 @@ func (m *QueryWhitelistedAppIdsVaultResponse) GetPagination() *query.PageRespons return nil } +type QueryExternalRewardLendsRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` +} + +func (m *QueryExternalRewardLendsRequest) Reset() { *m = QueryExternalRewardLendsRequest{} } +func (m *QueryExternalRewardLendsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryExternalRewardLendsRequest) ProtoMessage() {} +func (*QueryExternalRewardLendsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e41ca79380357ae5, []int{22} +} +func (m *QueryExternalRewardLendsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryExternalRewardLendsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryExternalRewardLendsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryExternalRewardLendsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryExternalRewardLendsRequest.Merge(m, src) +} +func (m *QueryExternalRewardLendsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryExternalRewardLendsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryExternalRewardLendsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryExternalRewardLendsRequest proto.InternalMessageInfo + +func (m *QueryExternalRewardLendsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryExternalRewardLendsResponse struct { + LendExternalRewards []LendExternalRewards `protobuf:"bytes,1,rep,name=lend_external_rewards,json=lendExternalRewards,proto3" json:"lend_external_rewards" yaml:"vault_external_rewards"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` +} + +func (m *QueryExternalRewardLendsResponse) Reset() { *m = QueryExternalRewardLendsResponse{} } +func (m *QueryExternalRewardLendsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryExternalRewardLendsResponse) ProtoMessage() {} +func (*QueryExternalRewardLendsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e41ca79380357ae5, []int{23} +} +func (m *QueryExternalRewardLendsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryExternalRewardLendsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryExternalRewardLendsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryExternalRewardLendsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryExternalRewardLendsResponse.Merge(m, src) +} +func (m *QueryExternalRewardLendsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryExternalRewardLendsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryExternalRewardLendsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryExternalRewardLendsResponse proto.InternalMessageInfo + +func (m *QueryExternalRewardLendsResponse) GetLendExternalRewards() []LendExternalRewards { + if m != nil { + return m.LendExternalRewards + } + return nil +} + +func (m *QueryExternalRewardLendsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "comdex.rewards.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "comdex.rewards.v1beta1.QueryParamsResponse") @@ -1067,6 +1163,8 @@ func init() { proto.RegisterType((*QueryExternalRewardVaultsResponse)(nil), "comdex.rewards.v1beta1.QueryExternalRewardVaultsResponse") proto.RegisterType((*QueryWhitelistedAppIdsVaultRequest)(nil), "comdex.rewards.v1beta1.QueryWhitelistedAppIdsVaultRequest") proto.RegisterType((*QueryWhitelistedAppIdsVaultResponse)(nil), "comdex.rewards.v1beta1.QueryWhitelistedAppIdsVaultResponse") + proto.RegisterType((*QueryExternalRewardLendsRequest)(nil), "comdex.rewards.v1beta1.QueryExternalRewardLendsRequest") + proto.RegisterType((*QueryExternalRewardLendsResponse)(nil), "comdex.rewards.v1beta1.QueryExternalRewardLendsResponse") } func init() { @@ -1074,81 +1172,86 @@ func init() { } var fileDescriptor_e41ca79380357ae5 = []byte{ - // 1184 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x5d, 0x6f, 0xdb, 0x54, - 0x18, 0xee, 0x09, 0x6d, 0x86, 0x4e, 0x47, 0x07, 0x87, 0x34, 0x74, 0xde, 0x96, 0xb4, 0xa7, 0x5b, - 0x57, 0x5a, 0x66, 0x37, 0x61, 0x62, 0xdd, 0xc6, 0x4d, 0xa3, 0x21, 0x14, 0x51, 0xa4, 0xe1, 0x49, - 0x9b, 0x98, 0x04, 0x91, 0x1b, 0xbb, 0xa9, 0x85, 0x6b, 0xbb, 0xb1, 0xd3, 0x35, 0x54, 0xbb, 0x00, - 0xae, 0x10, 0x17, 0x7c, 0xec, 0x62, 0xd7, 0x88, 0x6b, 0x7e, 0x06, 0xa8, 0x57, 0x50, 0xc1, 0x0d, - 0x57, 0xd5, 0xd4, 0xf2, 0x0b, 0xf6, 0x0b, 0x90, 0xcf, 0x79, 0xdd, 0xc4, 0xa9, 0x8f, 0x9d, 0x8c, - 0x35, 0x77, 0xed, 0xf1, 0xfb, 0xf1, 0x3c, 0xcf, 0xfb, 0xda, 0x7e, 0x62, 0x4c, 0xeb, 0xce, 0xa6, - 0x6e, 0xec, 0x28, 0x4d, 0xe3, 0x91, 0xd6, 0xd4, 0x3d, 0x65, 0xbb, 0xb4, 0x66, 0xf8, 0x5a, 0x49, - 0xd9, 0x6a, 0x19, 0xcd, 0xb6, 0xec, 0x36, 0x1d, 0xdf, 0x21, 0x79, 0x1e, 0x23, 0x43, 0x8c, 0x0c, - 0x31, 0x52, 0xae, 0xe1, 0x34, 0x1c, 0x16, 0xa2, 0x04, 0x7f, 0xf1, 0x68, 0xe9, 0x62, 0xc3, 0x71, - 0x1a, 0x96, 0xa1, 0x68, 0xae, 0xa9, 0x68, 0xb6, 0xed, 0xf8, 0x9a, 0x6f, 0x3a, 0xb6, 0x07, 0x57, - 0x17, 0xea, 0x8e, 0xb7, 0xe9, 0x78, 0xca, 0x9a, 0xe6, 0x19, 0xbc, 0xc9, 0x71, 0x4b, 0x57, 0x6b, - 0x98, 0x36, 0x0b, 0x86, 0xd8, 0x59, 0x01, 0x36, 0x57, 0x6b, 0x6a, 0x9b, 0x61, 0xc1, 0xcb, 0x82, - 0xa0, 0x10, 0x2c, 0x8f, 0x12, 0xd1, 0x6c, 0x68, 0xad, 0x86, 0x91, 0xd2, 0xce, 0x70, 0x9d, 0xfa, - 0x06, 0x14, 0xa2, 0x39, 0x4c, 0x3e, 0x09, 0x50, 0xdf, 0x65, 0x18, 0x54, 0x63, 0xab, 0x65, 0x78, - 0x3e, 0xbd, 0x87, 0xdf, 0x8c, 0x9c, 0x7a, 0xae, 0x63, 0x7b, 0x06, 0x79, 0x1f, 0x67, 0x39, 0xd6, - 0x29, 0x34, 0x8d, 0xe6, 0xc7, 0xcb, 0x05, 0x39, 0x5e, 0x49, 0x99, 0xe7, 0x55, 0x46, 0xf7, 0x0e, - 0x8a, 0x23, 0x2a, 0xe4, 0xd0, 0x2f, 0xf1, 0x79, 0x56, 0x74, 0xc5, 0xb2, 0x3e, 0x60, 0x10, 0xaa, - 0xf6, 0xba, 0x03, 0x1d, 0xc9, 0x67, 0x18, 0x77, 0xf4, 0x82, 0xf2, 0x73, 0x32, 0x17, 0x57, 0x0e, - 0xc4, 0x95, 0xf9, 0x04, 0x3b, 0x1d, 0x1a, 0x06, 0xe4, 0x56, 0x26, 0x9f, 0x1f, 0x14, 0xdf, 0x68, - 0x6b, 0x9b, 0xd6, 0x2d, 0xda, 0xa9, 0x41, 0xd5, 0xae, 0x82, 0xf4, 0x0f, 0x84, 0xa5, 0xb8, 0xe6, - 0x40, 0xec, 0x2e, 0xce, 0x72, 0x55, 0xa6, 0xd0, 0xf4, 0x2b, 0xf3, 0xe3, 0xe5, 0x19, 0x11, 0x31, - 0x96, 0x1b, 0xa4, 0x56, 0x26, 0x03, 0x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c3, 0x49, 0xb4, - 0x1e, 0x29, 0xc3, 0x49, 0x36, 0x0c, 0x74, 0x99, 0x11, 0x2a, 0x93, 0x25, 0x11, 0xa1, 0x2e, 0x37, - 0x50, 0xd3, 0x5c, 0xd7, 0xd4, 0xbd, 0x1a, 0xab, 0x50, 0xf9, 0x68, 0xef, 0xb0, 0x80, 0xf6, 0x0f, - 0x0b, 0xe8, 0xd9, 0x61, 0x01, 0xfd, 0x70, 0x54, 0x18, 0xd9, 0x3f, 0x2a, 0x8c, 0xfc, 0x73, 0x54, - 0x18, 0x79, 0x58, 0x6a, 0x98, 0xfe, 0x46, 0x6b, 0x2d, 0x80, 0x05, 0x55, 0xaf, 0x39, 0xeb, 0xeb, - 0x66, 0xdd, 0xd4, 0xac, 0xb0, 0x4b, 0xa7, 0x8f, 0xdf, 0x76, 0x0d, 0x6f, 0x2d, 0xcb, 0xbe, 0xc8, - 0xbd, 0xfb, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x90, 0x8a, 0x5e, 0xce, 0xc3, 0x14, 0x00, 0x00, + // 1261 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x5d, 0x6f, 0xdc, 0x44, + 0x17, 0xce, 0xec, 0xdb, 0x6c, 0x5f, 0x4d, 0x4a, 0x28, 0xd3, 0x24, 0xa4, 0x6e, 0xbb, 0x49, 0x26, + 0x6d, 0x1a, 0x12, 0x62, 0x27, 0x4b, 0xa1, 0x69, 0xcb, 0x4d, 0x56, 0x45, 0x68, 0x45, 0x90, 0x8a, + 0x2b, 0xb5, 0xa2, 0x12, 0xac, 0x9c, 0xf5, 0x64, 0x63, 0xe1, 0xd8, 0xce, 0xda, 0x9b, 0x26, 0x44, + 0x95, 0xf8, 0xb8, 0x01, 0x21, 0xc4, 0x47, 0x2f, 0x7a, 0x8d, 0xf8, 0x2b, 0x80, 0x72, 0x05, 0x11, + 0xdc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a5, 0x2c, 0x76, 0xef, 0x08, 0x4c, 0x5e, 0xe7, 0x4c, 0x34, + 0x32, 0x27, 0x6d, 0xb3, 0xc4, 0x91, 0xe8, 0x9d, 0xdd, 0x83, 0x02, 0xda, 0x3b, 0x28, 0xa0, 0xa7, + 0x07, 0x05, 0xf4, 0xed, 0x61, 0xa1, 0x6f, 0xef, 0xb0, 0xd0, 0xf7, 0xe7, 0x61, 0xa1, 0xef, 0xc1, + 0x42, 0xcd, 0x0a, 0xd6, 0x1a, 0x2b, 0x21, 0x20, 0x08, 0x39, 0xe7, 0xae, 0xae, 0x5a, 0x55, 0xcb, + 0xb0, 0xa3, 0x14, 0xcd, 0x24, 0xc1, 0xb6, 0xc7, 0xfc, 0x95, 0x3c, 0xff, 0xad, 0xf7, 0xb5, 0x7f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xd2, 0x4e, 0xfc, 0x55, 0x1d, 0x17, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1174,6 +1277,7 @@ type QueryClient interface { QueryExternalRewardsLockers(ctx context.Context, in *QueryExternalRewardsLockersRequest, opts ...grpc.CallOption) (*QueryExternalRewardsLockersResponse, error) QueryExternalRewardVaults(ctx context.Context, in *QueryExternalRewardVaultsRequest, opts ...grpc.CallOption) (*QueryExternalRewardVaultsResponse, error) QueryWhitelistedAppIdsVault(ctx context.Context, in *QueryWhitelistedAppIdsVaultRequest, opts ...grpc.CallOption) (*QueryWhitelistedAppIdsVaultResponse, error) + QueryExternalRewardLends(ctx context.Context, in *QueryExternalRewardLendsRequest, opts ...grpc.CallOption) (*QueryExternalRewardLendsResponse, error) } type queryClient struct { @@ -1283,6 +1387,15 @@ func (c *queryClient) QueryWhitelistedAppIdsVault(ctx context.Context, in *Query return out, nil } +func (c *queryClient) QueryExternalRewardLends(ctx context.Context, in *QueryExternalRewardLendsRequest, opts ...grpc.CallOption) (*QueryExternalRewardLendsResponse, error) { + out := new(QueryExternalRewardLendsResponse) + err := c.cc.Invoke(ctx, "/comdex.rewards.v1beta1.Query/QueryExternalRewardLends", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) @@ -1296,6 +1409,7 @@ type QueryServer interface { QueryExternalRewardsLockers(context.Context, *QueryExternalRewardsLockersRequest) (*QueryExternalRewardsLockersResponse, error) QueryExternalRewardVaults(context.Context, *QueryExternalRewardVaultsRequest) (*QueryExternalRewardVaultsResponse, error) QueryWhitelistedAppIdsVault(context.Context, *QueryWhitelistedAppIdsVaultRequest) (*QueryWhitelistedAppIdsVaultResponse, error) + QueryExternalRewardLends(context.Context, *QueryExternalRewardLendsRequest) (*QueryExternalRewardLendsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1335,6 +1449,9 @@ func (*UnimplementedQueryServer) QueryExternalRewardVaults(ctx context.Context, func (*UnimplementedQueryServer) QueryWhitelistedAppIdsVault(ctx context.Context, req *QueryWhitelistedAppIdsVaultRequest) (*QueryWhitelistedAppIdsVaultResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryWhitelistedAppIdsVault not implemented") } +func (*UnimplementedQueryServer) QueryExternalRewardLends(ctx context.Context, req *QueryExternalRewardLendsRequest) (*QueryExternalRewardLendsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryExternalRewardLends not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1538,6 +1655,24 @@ func _Query_QueryWhitelistedAppIdsVault_Handler(srv interface{}, ctx context.Con return interceptor(ctx, in, info, handler) } +func _Query_QueryExternalRewardLends_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryExternalRewardLendsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryExternalRewardLends(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.rewards.v1beta1.Query/QueryExternalRewardLends", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryExternalRewardLends(ctx, req.(*QueryExternalRewardLendsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "comdex.rewards.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -1586,6 +1721,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryWhitelistedAppIdsVault", Handler: _Query_QueryWhitelistedAppIdsVault_Handler, }, + { + MethodName: "QueryExternalRewardLends", + Handler: _Query_QueryExternalRewardLends_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "comdex/rewards/v1beta1/query.proto", @@ -2407,6 +2546,90 @@ func (m *QueryWhitelistedAppIdsVaultResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *QueryExternalRewardLendsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryExternalRewardLendsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryExternalRewardLendsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryExternalRewardLendsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryExternalRewardLendsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryExternalRewardLendsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.LendExternalRewards) > 0 { + for iNdEx := len(m.LendExternalRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LendExternalRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2731,6 +2954,38 @@ func (m *QueryWhitelistedAppIdsVaultResponse) Size() (n int) { return n } +func (m *QueryExternalRewardLendsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryExternalRewardLendsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.LendExternalRewards) > 0 { + for _, e := range m.LendExternalRewards { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4758,6 +5013,212 @@ func (m *QueryWhitelistedAppIdsVaultResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryExternalRewardLendsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryExternalRewardLendsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryExternalRewardLendsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryExternalRewardLendsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryExternalRewardLendsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryExternalRewardLendsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LendExternalRewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LendExternalRewards = append(m.LendExternalRewards, LendExternalRewards{}) + if err := m.LendExternalRewards[len(m.LendExternalRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index 5e217f217..816b735c3 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -483,6 +483,42 @@ func local_request_Query_QueryWhitelistedAppIdsVault_0(ctx context.Context, mars } +var ( + filter_Query_QueryExternalRewardLends_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_QueryExternalRewardLends_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryExternalRewardLendsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryExternalRewardLends_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryExternalRewardLends(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryExternalRewardLends_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryExternalRewardLendsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryExternalRewardLends_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryExternalRewardLends(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -742,6 +778,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryExternalRewardLends_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryExternalRewardLends_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryExternalRewardLends_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1003,6 +1062,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryExternalRewardLends_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryExternalRewardLends_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryExternalRewardLends_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1028,6 +1107,8 @@ var ( pattern_Query_QueryExternalRewardVaults_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "rewards", "v1beta1", "vault_external_rewards"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryWhitelistedAppIdsVault_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "rewards", "v1beta1", "whitelisted_appids_Vault"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryExternalRewardLends_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "rewards", "v1beta1", "lend_external_rewards"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1052,4 +1133,6 @@ var ( forward_Query_QueryExternalRewardVaults_0 = runtime.ForwardResponseMessage forward_Query_QueryWhitelistedAppIdsVault_0 = runtime.ForwardResponseMessage + + forward_Query_QueryExternalRewardLends_0 = runtime.ForwardResponseMessage ) diff --git a/x/rewards/types/rewards.pb.go b/x/rewards/types/rewards.pb.go index adb5277b7..0539616a2 100644 --- a/x/rewards/types/rewards.pb.go +++ b/x/rewards/types/rewards.pb.go @@ -522,7 +522,7 @@ func (m *EpochTime) GetCount() uint64 { type LendExternalRewards struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` AppMappingId uint64 `protobuf:"varint,2,opt,name=app_mapping_id,json=appMappingId,proto3" json:"app_mapping_id,omitempty" yaml:"app_mapping_id"` - RewardsAssetPoolData []*RewardsAssetPoolData `protobuf:"bytes,3,rep,name=rewards_asset_pool_data,json=rewardsAssetPoolData,proto3" json:"rewards_asset_pool_data,omitempty" yaml:"rewards_asset_pool_data"` + RewardsAssetPoolData *RewardsAssetPoolData `protobuf:"bytes,3,opt,name=rewards_asset_pool_data,json=rewardsAssetPoolData,proto3" json:"rewards_asset_pool_data,omitempty" yaml:"rewards_asset_pool_data"` TotalRewards github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,4,opt,name=total_rewards,json=totalRewards,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"total_rewards" yaml:"total_rewards"` RewardAssetId uint64 `protobuf:"varint,5,opt,name=reward_asset_id,json=rewardAssetId,proto3" json:"reward_asset_id,omitempty" yaml:"epoch_id"` DurationDays int64 `protobuf:"varint,6,opt,name=duration_days,json=durationDays,proto3" json:"duration_days,omitempty" yaml:"duration_days"` @@ -582,7 +582,7 @@ func (m *LendExternalRewards) GetAppMappingId() uint64 { return 0 } -func (m *LendExternalRewards) GetRewardsAssetPoolData() []*RewardsAssetPoolData { +func (m *LendExternalRewards) GetRewardsAssetPoolData() *RewardsAssetPoolData { if m != nil { return m.RewardsAssetPoolData } @@ -727,75 +727,75 @@ func init() { } var fileDescriptor_d29f449503627a2b = []byte{ - // 1082 bytes of a gzipped FileDescriptorProto + // 1079 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xda, 0x4d, 0x6c, 0x4f, 0xec, 0x24, 0x6c, 0xdc, 0x64, 0x9b, 0x0a, 0xaf, 0x35, 0x42, - 0xc5, 0x12, 0xea, 0x9a, 0x04, 0x4e, 0x45, 0x08, 0xc5, 0xb8, 0x42, 0x56, 0x53, 0xa9, 0x0c, 0x08, - 0x09, 0x2e, 0xab, 0xf1, 0xee, 0xc4, 0x1d, 0x75, 0x77, 0x67, 0xe5, 0x1d, 0x87, 0x46, 0x08, 0x89, - 0x1b, 0x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84, 0xa5, 0x94, 0xb3, 0x41, 0xbd, 0x24, 0x87, + 0x76, 0xa2, 0x91, 0xdc, 0x05, 0xd1, 0x38, 0xcc, 0xee, 0x83, 0xb5, 0x94, 0xe3, 0x01, 0xf7, 0x72, + 0xad, 0xad, 0x97, 0x65, 0x1b, 0xdb, 0xae, 0x52, 0x63, 0xd7, 0xa8, 0xb1, 0xfb, 0xb9, 0x89, 0x68, + 0x43, 0xdd, 0xc7, 0xa6, 0xca, 0x3c, 0x93, 0x00, 0x3e, 0xf9, 0xcb, 0xb1, 0xd0, 0xaa, 0xb4, 0xe6, + 0x67, 0x6c, 0x0c, 0xaa, 0x24, 0x0e, 0x26, 0xca, 0x80, 0x73, 0xcb, 0x34, 0xa7, 0xc7, 0x65, 0xea, + 0xb8, 0x2a, 0x52, 0x21, 0x71, 0x30, 0x2e, 0xf1, 0x25, 0xd8, 0x8a, 0x68, 0xec, 0x09, 0x71, 0x1c, + 0x26, 0x32, 0xd4, 0x4b, 0x89, 0xcf, 0xe2, 0x20, 0xad, 0xaf, 0xc8, 0x89, 0x80, 0xa3, 0xcc, 0x69, + 0xa8, 0x64, 0x67, 0x04, 0x42, 0x54, 0x8b, 0x68, 0x7c, 0x20, 0x1d, 0x22, 0xf1, 0x67, 0xca, 0x2c, + 0xc8, 0x41, 0x12, 0xe6, 0x3f, 0x14, 0xe4, 0xa8, 0xcc, 0x92, 0xc3, 0x78, 0x20, 0x2a, 0xca, 0x65, + 0x37, 0x80, 0x7f, 0x16, 0x8d, 0xae, 0x5d, 0x3a, 0x8f, 0xef, 0x82, 0x75, 0x51, 0x33, 0x0e, 0x48, + 0xe0, 0x3d, 0xc0, 0x74, 0xe0, 0x75, 0x0d, 0x9f, 0x6f, 0x8e, 0x32, 0x67, 0x4b, 0x5f, 0x79, 0x26, + 0x02, 0xa2, 0x55, 0x63, 0x12, 0x96, 0x2b, 0x7a, 0x5f, 0xd1, 0xfb, 0x8a, 0xde, 0x67, 0xd3, 0xfb, + 0x37,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2a, 0xfa, 0x82, 0xa8, 0x33, 0x5f, 0x29, 0x85, 0xe6, + 0xe2, 0x79, 0x5f, 0x29, 0xed, 0x7b, 0x4f, 0x4f, 0x1a, 0xd6, 0xb3, 0x93, 0x86, 0xf5, 0xf7, 0x49, + 0xc3, 0x7a, 0x72, 0xda, 0x58, 0x78, 0x76, 0xda, 0x58, 0xf8, 0xfd, 0xb4, 0xb1, 0xf0, 0xd5, 0xee, + 0xd4, 0x70, 0x09, 0x95, 0xb9, 0xcd, 0x0e, 0x0f, 0xa9, 0x4f, 0x71, 0xa8, 0xf7, 0xad, 0xf1, 0xbf, + 0x37, 0xe4, 0xac, 0xf5, 0x96, 0xe5, 0x0f, 0xf3, 0xde, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x94, + 0x06, 0xe7, 0x4b, 0xfd, 0x10, 0x00, 0x00, } func (m *InternalRewards) Marshal() (dAtA []byte, err error) { @@ -1265,19 +1265,17 @@ func (m *LendExternalRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x22 - if len(m.RewardsAssetPoolData) > 0 { - for iNdEx := len(m.RewardsAssetPoolData) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.RewardsAssetPoolData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRewards(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + if m.RewardsAssetPoolData != nil { + { + size, err := m.RewardsAssetPoolData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRewards(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a } if m.AppMappingId != 0 { i = encodeVarintRewards(dAtA, i, uint64(m.AppMappingId)) @@ -1313,20 +1311,20 @@ func (m *RewardsAssetPoolData) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.AssetId) > 0 { - dAtA14 := make([]byte, len(m.AssetId)*10) - var j13 int + dAtA15 := make([]byte, len(m.AssetId)*10) + var j14 int for _, num := range m.AssetId { for num >= 1<<7 { - dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) + dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j13++ + j14++ } - dAtA14[j13] = uint8(num) - j13++ + dAtA15[j14] = uint8(num) + j14++ } - i -= j13 - copy(dAtA[i:], dAtA14[:j13]) - i = encodeVarintRewards(dAtA, i, uint64(j13)) + i -= j14 + copy(dAtA[i:], dAtA15[:j14]) + i = encodeVarintRewards(dAtA, i, uint64(j14)) i-- dAtA[i] = 0x12 } @@ -1515,11 +1513,9 @@ func (m *LendExternalRewards) Size() (n int) { if m.AppMappingId != 0 { n += 1 + sovRewards(uint64(m.AppMappingId)) } - if len(m.RewardsAssetPoolData) > 0 { - for _, e := range m.RewardsAssetPoolData { - l = e.Size() - n += 1 + l + sovRewards(uint64(l)) - } + if m.RewardsAssetPoolData != nil { + l = m.RewardsAssetPoolData.Size() + n += 1 + l + sovRewards(uint64(l)) } l = m.TotalRewards.Size() n += 1 + l + sovRewards(uint64(l)) @@ -2826,8 +2822,10 @@ func (m *LendExternalRewards) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RewardsAssetPoolData = append(m.RewardsAssetPoolData, &RewardsAssetPoolData{}) - if err := m.RewardsAssetPoolData[len(m.RewardsAssetPoolData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.RewardsAssetPoolData == nil { + m.RewardsAssetPoolData = &RewardsAssetPoolData{} + } + if err := m.RewardsAssetPoolData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/rewards/types/tx.go b/x/rewards/types/tx.go index 6b955d9df..70e84b9e9 100644 --- a/x/rewards/types/tx.go +++ b/x/rewards/types/tx.go @@ -86,7 +86,6 @@ func NewMsgActivateExternalRewardsLockers( assetID uint64, totalRewards sdk.Coin, durationDays, minLockupTimeSeconds int64, - // nolint from sdk.AccAddress, ) *ActivateExternalRewardsLockers { return &ActivateExternalRewardsLockers{ @@ -144,7 +143,6 @@ func NewMsgActivateExternalVaultLockers( extendedPairID uint64, totalRewards sdk.Coin, durationDays, minLockupTimeSeconds int64, - // nolint from sdk.AccAddress, ) *ActivateExternalRewardsVault { return &ActivateExternalRewardsVault{ diff --git a/x/vault/client/testutil/helpers.go b/x/vault/client/testutil/helpers.go index 87fc54d72..a53741214 100644 --- a/x/vault/client/testutil/helpers.go +++ b/x/vault/client/testutil/helpers.go @@ -57,7 +57,7 @@ func MsgCreate( return resp, err } -func (s *VaultIntegrationTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { +func (s *VaultIntegrationTestSuite) fundAddr(addr sdk.AccAddress, amt sdk.Coins) { //nolint:unused s.T().Helper() err := s.app.BankKeeper.MintCoins(s.ctx, types.ModuleName, amt) s.Require().NoError(err) diff --git a/x/vault/genesis.go b/x/vault/genesis.go index dfdb27a29..b93c31fcb 100644 --- a/x/vault/genesis.go +++ b/x/vault/genesis.go @@ -9,8 +9,8 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { var ( - vaultID uint64 = 0 - stableVaultID uint64 = 0 + vaultID uint64 + stableVaultID uint64 ) for _, item := range state.Vaults { diff --git a/x/vault/keeper/query_server.go b/x/vault/keeper/query_server.go index b632c4c93..994ad83c1 100644 --- a/x/vault/keeper/query_server.go +++ b/x/vault/keeper/query_server.go @@ -148,7 +148,6 @@ func (q QueryServer) QueryVaultInfoOfOwnerByApp(c context.Context, req *types.Qu return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } - // nolint var ( ctx = sdk.UnwrapSDKContext(c) vaultsIds []uint64 @@ -315,7 +314,6 @@ func (q QueryServer) QueryTokenMintedAssetWiseByApp(c context.Context, req *type return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } - // nolint var ( ctx = sdk.UnwrapSDKContext(c) mintedData []types.MintedDataMap @@ -377,8 +375,8 @@ func (q QueryServer) QueryVaultCountByAppAndExtendedPair(c context.Context, req return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } var ( - ctx = sdk.UnwrapSDKContext(c) - count uint64 = 0 + ctx = sdk.UnwrapSDKContext(c) + count uint64 ) _, found := q.GetApp(ctx, req.AppId) if !found { @@ -431,7 +429,6 @@ func (q QueryServer) QueryExtendedPairIDsByApp(c context.Context, req *types.Que return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } - // nolint var ( ctx = sdk.UnwrapSDKContext(c) pairIDs []uint64 @@ -552,7 +549,6 @@ func (q QueryServer) QueryTVLByAppOfAllExtendedPairs(c context.Context, req *typ return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } - // nolint var ( ctx = sdk.UnwrapSDKContext(c) tvlData []types.TvlLockedDataMap diff --git a/x/vault/types/errors.go b/x/vault/types/errors.go index 3cee5abf2..ae32db050 100644 --- a/x/vault/types/errors.go +++ b/x/vault/types/errors.go @@ -14,7 +14,6 @@ var ( var ( - // nolint // ErrorUnauthorized = errors.Register(ModuleName, 203, "unauthorized") // ErrorDuplicateVault = errors.Register(ModuleName, 204, "duplicate vault") diff --git a/x/vault/types/msg.go b/x/vault/types/msg.go index cfbc76ec1..8709aa9c4 100644 --- a/x/vault/types/msg.go +++ b/x/vault/types/msg.go @@ -19,7 +19,6 @@ var ( ) func NewMsgCreateRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, amountIn sdk.Int, amountOut sdk.Int, ) *MsgCreateRequest { @@ -83,7 +82,6 @@ func (m *MsgCreateRequest) GetSigners() []sdk.AccAddress { } func NewMsgDepositRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, userVaultID uint64, amount sdk.Int, ) *MsgDepositRequest { @@ -141,7 +139,6 @@ func (m *MsgDepositRequest) GetSigners() []sdk.AccAddress { } func NewMsgWithdrawRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, userVaultid uint64, amount sdk.Int, ) *MsgWithdrawRequest { @@ -199,7 +196,6 @@ func (m *MsgWithdrawRequest) GetSigners() []sdk.AccAddress { } func NewMsgDrawRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, userVaultid uint64, amount sdk.Int, ) *MsgDrawRequest { @@ -257,7 +253,6 @@ func (m *MsgDrawRequest) GetSigners() []sdk.AccAddress { } func NewMsgRepayRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, userVaultid uint64, amount sdk.Int, ) *MsgRepayRequest { @@ -315,7 +310,6 @@ func (m *MsgRepayRequest) GetSigners() []sdk.AccAddress { } func NewMsgLiquidateRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, userVaultid uint64, ) *MsgCloseRequest { @@ -363,7 +357,6 @@ func (m *MsgCloseRequest) GetSigners() []sdk.AccAddress { } func NewMsgDepositAndDrawRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, userVaultid uint64, amount sdk.Int, ) *MsgDepositAndDrawRequest { @@ -421,7 +414,6 @@ func (m *MsgDepositAndDrawRequest) GetSigners() []sdk.AccAddress { } func NewMsgCreateStableMintRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, amount sdk.Int, ) *MsgCreateStableMintRequest { @@ -475,7 +467,6 @@ func (m *MsgCreateStableMintRequest) GetSigners() []sdk.AccAddress { } func NewMsgDepositStableMintRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, amount sdk.Int, stablemintID uint64, ) *MsgDepositStableMintRequest { @@ -530,7 +521,6 @@ func (m *MsgDepositStableMintRequest) GetSigners() []sdk.AccAddress { } func NewMsgWithdrawStableMintRequest( - // nolint from sdk.AccAddress, appID uint64, extendedPairVaultID uint64, amount sdk.Int, stablemintID uint64, ) *MsgWithdrawStableMintRequest { @@ -585,7 +575,6 @@ func (m *MsgWithdrawStableMintRequest) GetSigners() []sdk.AccAddress { } func NewMsgVaultInterestCalcRequest( - // nolint from sdk.AccAddress, appID uint64, userVaultID uint64, ) *MsgVaultInterestCalcRequest {