diff --git a/.golangci.yml b/.golangci.yml index ed019d9bf..2d17ee5ab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -39,7 +39,7 @@ linters: #- goconst #- gocritic #- gocyclo - - godot + #- godot - godox #- goerr113 - gofmt @@ -69,7 +69,7 @@ linters: - typecheck - unconvert #- unparam - - unused + #- unused - will be enabled later - varcheck - whitespace #- wsl diff --git a/app/app.go b/app/app.go index e53d6a3cd..68d633c4c 100644 --- a/app/app.go +++ b/app/app.go @@ -1144,8 +1144,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string { func (a *App) registerUpgradeHandlers() { a.UpgradeKeeper.SetUpgradeHandler( - tv4_0_0.UpgradeNameV4_1_0, - tv4_0_0.CreateUpgradeHandlerV410(a.mm, a.configurator, a.Rewardskeeper, a.LiquidityKeeper), + tv4_0_0.UpgradeNameV4_2_0, + tv4_0_0.CreateUpgradeHandlerV420(a.mm, a.configurator), ) // When a planned update height is reached, the old binary will panic @@ -1215,6 +1215,8 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades * } case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_1_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): storeUpgrades = &storetypes.StoreUpgrades{} + case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_2_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): + storeUpgrades = &storetypes.StoreUpgrades{} } return storeUpgrades } diff --git a/app/upgrades/testnet/v4_0_0/constants.go b/app/upgrades/testnet/v4_0_0/constants.go index 131895c4b..9ad47fec7 100644 --- a/app/upgrades/testnet/v4_0_0/constants.go +++ b/app/upgrades/testnet/v4_0_0/constants.go @@ -27,3 +27,17 @@ const ( } }'` ) + +const ( + UpgradeNameV4_2_0 = "v4.2.0" + UpgradeHeightV4_2_0 = "" // replace this height + UpgradeInfoV4_2_0 = `'{ + "binaries": { + "darwin/arm64":"", + "darwin/x86_64":"", + "linux/arm64":"", + "linux/x86_64":"", + "windows/x86_64":"" + } + }'` +) diff --git a/app/upgrades/testnet/v4_0_0/upgrades.go b/app/upgrades/testnet/v4_0_0/upgrades.go index 8987a7bc1..2d7558d23 100644 --- a/app/upgrades/testnet/v4_0_0/upgrades.go +++ b/app/upgrades/testnet/v4_0_0/upgrades.go @@ -55,7 +55,7 @@ func CreateSwapFeeGauge( _ = rewardsKeeper.CreateNewGauge(ctx, newGauge, true) } -// CreateUpgradeHandler creates an SDK upgrade handler for v4_0_1 +// CreateUpgradeHandler creates an SDK upgrade handler for v4_1_0 func CreateUpgradeHandlerV410( mm *module.Manager, configurator module.Configurator, @@ -74,3 +74,20 @@ func CreateUpgradeHandlerV410( return newVM, err } } + +// CreateUpgradeHandler creates an SDK upgrade handler for v4_2_0 +func CreateUpgradeHandlerV420( + mm *module.Manager, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // This change is only for testnet upgrade + + newVM, err := mm.RunMigrations(ctx, configurator, fromVM) + + if err != nil { + return newVM, err + } + return newVM, err + } +} diff --git a/proto/comdex/lend/v1beta1/lend.proto b/proto/comdex/lend/v1beta1/lend.proto index e726fd06c..4206b63c5 100644 --- a/proto/comdex/lend/v1beta1/lend.proto +++ b/proto/comdex/lend/v1beta1/lend.proto @@ -56,7 +56,19 @@ message LendAsset { uint64 app_id = 10 [(gogoproto.customname) = "AppID", (gogoproto.moretags) = "yaml:\"app_id\""]; - string cpool_name = 11 [ + string global_index = 11 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"global_index\"" + ]; + + google.protobuf.Timestamp last_interaction_time = 12 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"last_interaction_time\"" + ]; + + string cpool_name = 13 [ (gogoproto.customname) = "CPoolName", (gogoproto.moretags) = "yaml:\"cpool_name\"" ]; @@ -124,7 +136,24 @@ message BorrowAsset { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; - string cpool_name = 12 [ + string global_index = 12 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"global_index\"" + ]; + string reserve_global_index = 13 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"reserve_global_index\"" + ]; + + google.protobuf.Timestamp last_interaction_time = 14 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"last_interaction_time\"" + ]; + + string cpool_name = 15 [ (gogoproto.customname) = "CPoolName", (gogoproto.moretags) = "yaml:\"cpool_name\"" ]; diff --git a/proto/comdex/lend/v1beta1/tx.proto b/proto/comdex/lend/v1beta1/tx.proto index 0e5df7d7e..e34f8618e 100644 --- a/proto/comdex/lend/v1beta1/tx.proto +++ b/proto/comdex/lend/v1beta1/tx.proto @@ -34,6 +34,10 @@ service Msg { // FundModuleAccounts funds an existing module account rpc FundModuleAccounts(MsgFundModuleAccounts) returns (MsgFundModuleAccountsResponse); + + rpc CalculateBorrowInterest(MsgCalculateBorrowInterest) returns (MsgCalculateBorrowInterestResponse); + + rpc CalculateLendRewards(MsgCalculateLendRewards) returns (MsgCalculateLendRewardsResponse); } message MsgLend { @@ -111,6 +115,16 @@ message MsgFundModuleAccounts { cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; } +message MsgCalculateBorrowInterest { + string borrower = 1; + uint64 borrow_id = 2; +} + +message MsgCalculateLendRewards{ + string lender = 1; + uint64 lend_id = 2; +} + message MsgLendResponse {} message MsgWithdrawResponse {} @@ -131,4 +145,8 @@ message MsgCloseBorrowResponse {} message MsgBorrowAlternateResponse {} -message MsgFundModuleAccountsResponse {} \ No newline at end of file +message MsgFundModuleAccountsResponse {} + +message MsgCalculateBorrowInterestResponse {} + +message MsgCalculateLendRewardsResponse {} \ No newline at end of file diff --git a/x/auction/client/cli/cli.go b/x/auction/client/cli/cli.go index ab0dfcad7..f6f2d1fa8 100644 --- a/x/auction/client/cli/cli.go +++ b/x/auction/client/cli/cli.go @@ -2,8 +2,8 @@ package cli import ( "github.com/cosmos/cosmos-sdk/client" - "strings" "github.com/spf13/cobra" + "strings" ) func GetQueryCmd() *cobra.Command { @@ -56,12 +56,12 @@ func GetTxCmd() *cobra.Command { return cmd } -func ParseStringFromString(s string, seperator string) ([]string, error) { +func ParseStringFromString(s string, separator string) ([]string, error) { var parsedStrings []string - for _, s := range strings.Split(s, seperator) { + for _, s := range strings.Split(s, separator) { s = strings.TrimSpace(s) parsedStrings = append(parsedStrings, s) } return parsedStrings, nil -} \ No newline at end of file +} diff --git a/x/auction/keeper/alias.go b/x/auction/keeper/alias.go index 85dcdb8af..b6c6a5d0c 100644 --- a/x/auction/keeper/alias.go +++ b/x/auction/keeper/alias.go @@ -156,8 +156,8 @@ func (k Keeper) UpdateCollateralLockedAmountLockerMapping(ctx sdk.Context, appMa func (k Keeper) GetAllAuctionMappingForApp(ctx sdk.Context) (collectorAuctionLookupTable []types.AppAssetIdToAuctionLookupTable, found bool) { return k.collector.GetAllAuctionMappingForApp(ctx) } -func (k Keeper) DeleteLockedVault(ctx sdk.Context, appId, id uint64) { - k.liquidation.DeleteLockedVault(ctx, appId, id) +func (k Keeper) DeleteLockedVault(ctx sdk.Context, appID, id uint64) { + k.liquidation.DeleteLockedVault(ctx, appID, id) } func (k Keeper) DeleteUserVaultExtendedPairMapping(ctx sdk.Context, address string, appID uint64, pairVaultID uint64) { diff --git a/x/auction/keeper/surplus_test.go b/x/auction/keeper/surplus_test.go index de8381e87..c836104d0 100644 --- a/x/auction/keeper/surplus_test.go +++ b/x/auction/keeper/surplus_test.go @@ -71,10 +71,10 @@ func (s *KeeperTestSuite) TestSurplusActivator() { surplusAuction, err := k.GetSurplusAuction(*ctx, appId, auctionMappingId, auctionId) s.Require().NoError(err) - collectorLookUp, found := collectorKeeper.GetCollectorLookupTable(*ctx, 1,2) + collectorLookUp, found := collectorKeeper.GetCollectorLookupTable(*ctx, 1, 2) s.Require().True(found) - netFees, found := k.GetNetFeeCollectedData(*ctx, uint64(1),2) + netFees, found := k.GetNetFeeCollectedData(*ctx, uint64(1), 2) s.Require().True(found) s.Require().Equal(surplusAuction.AppId, appId) diff --git a/x/collector/keeper/alias.go b/x/collector/keeper/alias.go index af1abd113..373378177 100644 --- a/x/collector/keeper/alias.go +++ b/x/collector/keeper/alias.go @@ -55,8 +55,8 @@ func (k Keeper) GetLockerLookupTable(ctx sdk.Context, appID, assetID uint64) (lo return k.locker.GetLockerLookupTable(ctx, appID, assetID) } -func (k Keeper) GetReward(ctx sdk.Context, appId, assetID uint64) (rewards rewardstypes.InternalRewards, found bool) { - return k.rewards.GetReward(ctx, appId, assetID) +func (k Keeper) GetReward(ctx sdk.Context, appID, assetID uint64) (rewards rewardstypes.InternalRewards, found bool) { + return k.rewards.GetReward(ctx, appID, assetID) } func (k Keeper) GetLocker(ctx sdk.Context, lockerID uint64) (locker lockertypes.Locker, found bool) { diff --git a/x/esm/keeper/keeper.go b/x/esm/keeper/keeper.go index 213c234af..404473016 100644 --- a/x/esm/keeper/keeper.go +++ b/x/esm/keeper/keeper.go @@ -211,7 +211,7 @@ func (k Keeper) CalculateCollateral(ctx sdk.Context, appID uint64, amount sdk.Co if err2 != nil { return err2 } - data.Amount = data.Amount.Sub((sdk.Int(tokenQuant))) + data.Amount = data.Amount.Sub(tokenQuant) esmDataAfterCoolOff.CollateralAsset = append(esmDataAfterCoolOff.CollateralAsset[:i], esmDataAfterCoolOff.CollateralAsset[i+1:]...) esmDataAfterCoolOff.CollateralAsset = append(esmDataAfterCoolOff.CollateralAsset[:i+1], esmDataAfterCoolOff.CollateralAsset[i:]...) esmDataAfterCoolOff.CollateralAsset[i] = data diff --git a/x/lend/abci.go b/x/lend/abci.go index afed62cb8..f24e33a57 100644 --- a/x/lend/abci.go +++ b/x/lend/abci.go @@ -14,22 +14,11 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) { defer telemetry.ModuleMeasureSince(types.ModuleName, ctx.BlockTime(), telemetry.MetricKeyBeginBlocker) _ = utils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error { - err := k.IterateLends(ctx) - if err != nil { - ctx.Logger().Error("error in Iterate Lends") - } - err = k.IterateBorrows(ctx) - if err != nil { - ctx.Logger().Error("error in Iterate Borrows") - } - err = k.ReBalanceStableRates(ctx) + + err := k.ReBalanceStableRates(ctx) if err != nil { ctx.Logger().Error("error in ReBalance Stable Rates") } - err = k.SetLastInterestTime(ctx, ctx.BlockTime().Unix()) - if err != nil { - ctx.Logger().Error("error in SetLastInterestTime") - } return nil }) } diff --git a/x/lend/client/cli/tx.go b/x/lend/client/cli/tx.go index 32458ae4b..1ca155acd 100644 --- a/x/lend/client/cli/tx.go +++ b/x/lend/client/cli/tx.go @@ -27,16 +27,18 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand( txLend(), - txWithdraw(), //withdraw collateral partially or fully + txWithdraw(), txDeposit(), txCloseLend(), txBorrowAsset(), txDrawAsset(), - txRepayAsset(), //including functionality of both repaying and closing position + txRepayAsset(), txDepositBorrowAsset(), txCloseBorrowAsset(), txBorrowAssetAlternate(), txFundModuleAccounts(), + txCalculateBorrowInterest(), + txCalculateLendRewards(), ) return cmd @@ -917,3 +919,55 @@ func NewAddAuctionParams(clientCtx client.Context, txf tx.Factory, fs *flag.Flag return txf, msg, nil } + +func txCalculateBorrowInterest() *cobra.Command { + cmd := &cobra.Command{ + Use: "calculate-borrow-interest [borrow-id] ", + Short: " calculate borrow interest for a borrow position", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + ctx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + borrowID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + msg := types.NewMsgCalculateBorrowInterest(ctx.GetFromAddress().String(), borrowID) + + return tx.GenerateOrBroadcastTxCLI(ctx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func txCalculateLendRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "calculate-lend-rewards [lend-id] ", + Short: " calculate lend rewards for a lend position", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + ctx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + borrowID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + msg := types.NewMsgCalculateLendRewards(ctx.GetFromAddress().String(), borrowID) + + return tx.GenerateOrBroadcastTxCLI(ctx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/lend/genesis.go b/x/lend/genesis.go index 69b5a2053..77ecfe423 100644 --- a/x/lend/genesis.go +++ b/x/lend/genesis.go @@ -84,7 +84,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { lends, _ := k.GetLends(ctx) userDeposit, _ := k.GetUserDepositStats(ctx) reserveDeposit, _ := k.GetReserveDepositStats(ctx) - buyBackDeposir, _ := k.GetBuyBackDepositStats(ctx) + buyBackDeposit, _ := k.GetBuyBackDepositStats(ctx) borrowDeposit, _ := k.GetBorrowStats(ctx) return types.NewGenesisState( k.GetAllBorrow(ctx), @@ -101,7 +101,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { lends, userDeposit, reserveDeposit, - buyBackDeposir, + buyBackDeposit, borrowDeposit, k.GetLendPairs(ctx), k.GetAllAssetRatesStats(ctx), diff --git a/x/lend/handler.go b/x/lend/handler.go index 11ee1a548..cf167d487 100644 --- a/x/lend/handler.go +++ b/x/lend/handler.go @@ -63,6 +63,14 @@ func NewHandler(k keeper.Keeper) sdk.Handler { res, err := server.FundModuleAccounts(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgCalculateBorrowInterest: + res, err := server.CalculateBorrowInterest(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + + case *types.MsgCalculateLendRewards: + res, err := server.CalculateLendRewards(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/lend/keeper/iter.go b/x/lend/keeper/iter.go index 40e5d081c..ff467abdd 100644 --- a/x/lend/keeper/iter.go +++ b/x/lend/keeper/iter.go @@ -7,122 +7,112 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -func (k Keeper) IterateLends(ctx sdk.Context) error { - lends, _ := k.GetLends(ctx) - for _, v := range lends.LendIDs { - lend, _ := k.GetLend(ctx, v) - lendAPR, err := k.GetLendAPRByAssetIDAndPoolID(ctx, lend.PoolID, lend.AssetID) - if err != nil { - continue - } - interestPerBlock, err := k.CalculateRewards(ctx, lend.AmountIn.Amount.String(), lendAPR) - if err != nil { - continue - } - lendRewardsTracker, found := k.GetLendRewardTracker(ctx, lend.ID) - if !found { - lendRewardsTracker = types.LendRewardsTracker{ - LendingId: lend.ID, - RewardsAccumulated: sdk.ZeroDec(), - } - } - lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Add(interestPerBlock) - newInterestPerBlock := sdk.ZeroInt() - if lendRewardsTracker.RewardsAccumulated.GTE(sdk.OneDec()) { - newInterestPerBlock = lendRewardsTracker.RewardsAccumulated.TruncateInt() - newRewardDec := sdk.NewDec(newInterestPerBlock.Int64()) - lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Sub(newRewardDec) - } - k.SetLendRewardTracker(ctx, lendRewardsTracker) - if newInterestPerBlock.GT(sdk.ZeroInt()) { - lend.UpdatedAmountIn = lend.UpdatedAmountIn.Add(newInterestPerBlock) - lend.AvailableToBorrow = lend.AvailableToBorrow.Add(newInterestPerBlock) - lend.Reward_Accumulated = lend.Reward_Accumulated.Add(newInterestPerBlock) - - pool, _ := k.GetPool(ctx, lend.PoolID) - asset, _ := k.GetAsset(ctx, lend.AssetID) - Amount := sdk.NewCoin(asset.Denom, newInterestPerBlock) - assetRatesStat, found := k.GetAssetRatesStats(ctx, lend.AssetID) - if !found { - continue - } - cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) - cToken := sdk.NewCoin(cAsset.Denom, Amount.Amount) - if err != nil { - continue - } - addr, _ := sdk.AccAddressFromBech32(lend.Owner) - err = k.SendCoinFromModuleToAccount(ctx, pool.ModuleName, addr, cToken) - if err != nil { - continue - } - k.SetLend(ctx, lend) +func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { + lend, _ := k.GetLend(ctx, ID) + lendAPR, _ := k.GetLendAPRByAssetIDAndPoolID(ctx, lend.PoolID, lend.AssetID) + + interestPerBlock, indexGlobalCurrent, _ := k.CalculateLendReward(ctx, lend.AmountIn.Amount.String(), lendAPR, lend) + + lendRewardsTracker, found := k.GetLendRewardTracker(ctx, lend.ID) + if !found { + lendRewardsTracker = types.LendRewardsTracker{ + LendingId: lend.ID, + RewardsAccumulated: sdk.ZeroDec(), } } - return nil -} + lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Add(interestPerBlock) + newInterestPerBlock := sdk.ZeroInt() + if lendRewardsTracker.RewardsAccumulated.GTE(sdk.OneDec()) { + newInterestPerBlock = lendRewardsTracker.RewardsAccumulated.TruncateInt() + newRewardDec := sdk.NewDec(newInterestPerBlock.Int64()) + lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Sub(newRewardDec) + } + k.SetLendRewardTracker(ctx, lendRewardsTracker) + if newInterestPerBlock.GT(sdk.ZeroInt()) { + lend.UpdatedAmountIn = lend.UpdatedAmountIn.Add(newInterestPerBlock) + lend.AvailableToBorrow = lend.AvailableToBorrow.Add(newInterestPerBlock) + lend.Reward_Accumulated = lend.Reward_Accumulated.Add(newInterestPerBlock) -func (k Keeper) IterateBorrows(ctx sdk.Context) error { - borrows, _ := k.GetBorrows(ctx) - for _, v := range borrows.BorrowIDs { - borrow, _ := k.GetBorrow(ctx, v) - pair, _ := k.GetLendPair(ctx, borrow.PairID) + pool, _ := k.GetPool(ctx, lend.PoolID) + asset, _ := k.GetAsset(ctx, lend.AssetID) + Amount := sdk.NewCoin(asset.Denom, newInterestPerBlock) + assetRatesStat, _ := k.GetAssetRatesStats(ctx, lend.AssetID) - borrowAPR, _ := k.GetBorrowAPRByAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut, borrow.IsStableBorrow) - interestPerBlock, err := k.CalculateRewards(ctx, borrow.AmountOut.Amount.String(), borrowAPR) - if err != nil { - continue - } - reserveRates, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) - if err != nil { - continue - } - reservePoolAmountPerBlock, err := k.CalculateRewards(ctx, borrow.AmountOut.Amount.String(), reserveRates) + cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) + cToken := sdk.NewCoin(cAsset.Denom, Amount.Amount) + + addr, _ := sdk.AccAddressFromBech32(lend.Owner) + err := k.SendCoinFromModuleToAccount(ctx, pool.ModuleName, addr, cToken) if err != nil { - continue - } - borrowInterestTracker, found := k.GetBorrowInterestTracker(ctx, borrow.ID) - if !found { - borrowInterestTracker = types.BorrowInterestTracker{ - BorrowingId: borrow.ID, - InterestAccumulated: sdk.ZeroDec(), - } - } - borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Add(interestPerBlock) - newInterestPerBlock := sdk.ZeroInt() - if borrowInterestTracker.InterestAccumulated.GTE(sdk.OneDec()) { - newInterestPerBlock = borrowInterestTracker.InterestAccumulated.TruncateInt() - newRewardDec := sdk.NewDec(newInterestPerBlock.Int64()) - borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Sub(newRewardDec) + return sdk.Dec{}, err } - k.SetBorrowInterestTracker(ctx, borrowInterestTracker) - reservePoolRecords, found := k.GetReservePoolRecordsForBorrow(ctx, borrow.ID) - if !found { - reservePoolRecords = types.ReservePoolRecordsForBorrow{ - ID: borrow.ID, - InterestAccumulated: sdk.ZeroDec(), - } + k.SetLend(ctx, lend) + } + + return indexGlobalCurrent, nil +} + +func (k Keeper) IterateBorrow(ctx sdk.Context, ID uint64) (sdk.Dec, sdk.Dec, error) { + borrow, _ := k.GetBorrow(ctx, ID) + pair, _ := k.GetLendPair(ctx, borrow.PairID) + reserveRates, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) + if err != nil { + 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) + if err != nil { + return sdk.ZeroDec(), sdk.ZeroDec(), err + } + borrowInterestTracker, found := k.GetBorrowInterestTracker(ctx, borrow.ID) + if !found { + borrowInterestTracker = types.BorrowInterestTracker{ + BorrowingId: borrow.ID, + InterestAccumulated: sdk.ZeroDec(), } - if reservePoolAmountPerBlock.GT(sdk.ZeroDec()) { - reservePoolRecords.InterestAccumulated = reservePoolRecords.InterestAccumulated.Add(reservePoolAmountPerBlock) + } + if !borrow.IsStableBorrow { + borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Add(interestPerBlock) + } else { + stableInterestPerBlock, err := k.CalculateStableInterest(ctx, borrow.AmountOut.Amount.String(), borrow) + if err != nil { + return sdk.ZeroDec(), sdk.ZeroDec(), err } - k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) - if newInterestPerBlock.GT(sdk.ZeroInt()) { - borrow.UpdatedAmountOut = borrow.UpdatedAmountOut.Add(newInterestPerBlock) - borrow.Interest_Accumulated = borrow.Interest_Accumulated.Add(newInterestPerBlock) + borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Add(stableInterestPerBlock) + } + newInterestPerBlock := sdk.ZeroInt() + if borrowInterestTracker.InterestAccumulated.GTE(sdk.OneDec()) { + newInterestPerBlock = borrowInterestTracker.InterestAccumulated.TruncateInt() + newRewardDec := sdk.NewDec(newInterestPerBlock.Int64()) + borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Sub(newRewardDec) + } + k.SetBorrowInterestTracker(ctx, borrowInterestTracker) - k.SetBorrow(ctx, borrow) + reservePoolRecords, found := k.GetReservePoolRecordsForBorrow(ctx, borrow.ID) + if !found { + reservePoolRecords = types.ReservePoolRecordsForBorrow{ + ID: borrow.ID, + InterestAccumulated: sdk.ZeroDec(), } } - return nil + if reservePoolAmountPerBlock.GT(sdk.ZeroDec()) { + reservePoolRecords.InterestAccumulated = reservePoolRecords.InterestAccumulated.Add(reservePoolAmountPerBlock) + } + k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) + if newInterestPerBlock.GT(sdk.ZeroInt()) { + borrow.UpdatedAmountOut = borrow.UpdatedAmountOut.Add(newInterestPerBlock) + borrow.Interest_Accumulated = borrow.Interest_Accumulated.Add(newInterestPerBlock) + k.SetBorrow(ctx, borrow) + } + return indexGlobalCurrent, reserveGlobalIndex, nil } -func (k Keeper) CalculateRewards(ctx sdk.Context, amount string, rate sdk.Dec) (sdk.Dec, error) { +func (k Keeper) CalculateStableInterest(ctx sdk.Context, amount string, borrow types.BorrowAsset) (sdk.Dec, error) { currentTime := ctx.BlockTime().Unix() - prevInterestTime := k.GetLastInterestTime(ctx) + prevInterestTime := borrow.LastInteractionTime.Unix() if prevInterestTime == int64(types.Uint64Zero) { prevInterestTime = currentTime } @@ -131,12 +121,74 @@ func (k Keeper) CalculateRewards(ctx sdk.Context, amount string, rate sdk.Dec) ( return sdk.ZeroDec(), sdkerrors.Wrap(types.ErrNegativeTimeElapsed, fmt.Sprintf("%d seconds", secondsElapsed)) } yearsElapsed := sdk.NewDec(secondsElapsed).QuoInt64(types.SecondsPerYear) - amtFloat, _ := sdk.NewDecFromStr(amount) - perc := rate - newAmount := amtFloat.Mul(perc).Mul(yearsElapsed) + amt, _ := sdk.NewDecFromStr(amount) + perc := borrow.StableBorrowRate + newAmount := amt.Mul(perc).Mul(yearsElapsed) return newAmount, nil } +func (k Keeper) CalculateLendReward(ctx sdk.Context, amount string, rate sdk.Dec, lend types.LendAsset) (sdk.Dec, sdk.Dec, error) { + currentTime := ctx.BlockTime().Unix() + lastInteraction := lend.LastInteractionTime + globalIndex := lend.GlobalIndex + prevInterestTime := lastInteraction.Unix() + if prevInterestTime == int64(types.Uint64Zero) { + prevInterestTime = currentTime + } + secondsElapsed := currentTime - prevInterestTime + if secondsElapsed < int64(types.Uint64Zero) { + return sdk.ZeroDec(), sdk.ZeroDec(), sdkerrors.Wrap(types.ErrNegativeTimeElapsed, fmt.Sprintf("%d seconds", secondsElapsed)) + } + yearsElapsed := sdk.NewDec(secondsElapsed).QuoInt64(types.SecondsPerYear) + amt, _ := sdk.NewDecFromStr(amount) + + effectiveRate := rate.Mul(yearsElapsed) + factor1 := sdk.OneDec().Add(effectiveRate) + indexGlobalCurrent := globalIndex.Mul(factor1) + factor2 := indexGlobalCurrent.Quo(globalIndex) + liabilityCurrent := amt.Mul(factor2) + + newAmount := liabilityCurrent.Sub(amt) + return newAmount, indexGlobalCurrent, nil +} + +func (k Keeper) CalculateBorrowInterest(ctx sdk.Context, amount string, rate, reserveRate sdk.Dec, borrow types.BorrowAsset) (sdk.Dec, sdk.Dec, sdk.Dec, sdk.Dec, error) { + currentTime := ctx.BlockTime().Unix() + lastInteraction := borrow.LastInteractionTime + globalIndex := borrow.GlobalIndex + reserveGlobalIndex := borrow.ReserveGlobalIndex + prevInterestTime := lastInteraction.Unix() + if prevInterestTime == int64(types.Uint64Zero) { + prevInterestTime = currentTime + } + secondsElapsed := currentTime - prevInterestTime + if secondsElapsed < int64(types.Uint64Zero) { + return sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdkerrors.Wrap(types.ErrNegativeTimeElapsed, fmt.Sprintf("%d seconds", secondsElapsed)) + } + yearsElapsed := sdk.NewDec(secondsElapsed).QuoInt64(types.SecondsPerYear) + amt, _ := sdk.NewDecFromStr(amount) + + // for calculating interest accrued per interaction + effectiveRate := rate.Mul(yearsElapsed) + factor1 := sdk.OneDec().Add(effectiveRate) + indexGlobalCurrent := globalIndex.Mul(factor1) + factor2 := indexGlobalCurrent.Quo(globalIndex) + liabilityCurrent := amt.Mul(factor2) + + newAmount := liabilityCurrent.Sub(amt) + + // for calculating amount to reserve pool accrued per interaction + reserveEffectiveRate := reserveRate.Mul(yearsElapsed) + reserveFactor1 := sdk.OneDec().Add(reserveEffectiveRate) + reserveIndexGlobalCurrent := reserveGlobalIndex.Mul(reserveFactor1) + reserveFactor2 := reserveIndexGlobalCurrent.Quo(reserveGlobalIndex) + reserveLiabilityCurrent := amt.Mul(reserveFactor2) + + newAmountReservePool := reserveLiabilityCurrent.Sub(amt) + + return newAmount, indexGlobalCurrent, newAmountReservePool, reserveIndexGlobalCurrent, nil +} + func (k Keeper) ReBalanceStableRates(ctx sdk.Context) error { borrows, _ := k.GetBorrows(ctx) diff --git a/x/lend/keeper/keeper.go b/x/lend/keeper/keeper.go index af45a070f..515a81c2e 100644 --- a/x/lend/keeper/keeper.go +++ b/x/lend/keeper/keeper.go @@ -140,18 +140,28 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am lendID := k.GetUserLendIDHistory(ctx) + var globalIndex sdk.Dec + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, AssetID, PoolID) + if assetStats.LendApr.IsZero() { + globalIndex = sdk.OneDec() + } else { + globalIndex = assetStats.LendApr + } + lendPos := types.LendAsset{ - ID: lendID + 1, - AssetID: AssetID, - PoolID: PoolID, - Owner: lenderAddr, - AmountIn: Amount, - LendingTime: ctx.BlockTime(), - UpdatedAmountIn: Amount.Amount, - AvailableToBorrow: Amount.Amount, - Reward_Accumulated: sdk.ZeroInt(), - CPoolName: pool.CPoolName, - AppID: AppID, + ID: lendID + 1, + AssetID: AssetID, + PoolID: PoolID, + Owner: lenderAddr, + AmountIn: Amount, + LendingTime: ctx.BlockTime(), + UpdatedAmountIn: Amount.Amount, + AvailableToBorrow: Amount.Amount, + Reward_Accumulated: sdk.ZeroInt(), + AppID: AppID, + GlobalIndex: globalIndex, + LastInteractionTime: ctx.BlockTime(), + CPoolName: pool.CPoolName, } k.UpdateLendStats(ctx, AssetID, PoolID, Amount.Amount, true) k.SetUserLendIDHistory(ctx, lendPos.ID) @@ -186,6 +196,13 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } + indexGlobalCurrent, err := k.IterateLends(ctx, lendID) + if err != nil { + return err + } + lendPos, _ = k.GetLend(ctx, lendID) + lendPos.GlobalIndex = indexGlobalCurrent + lendPos.LastInteractionTime = ctx.BlockTime() getAsset, _ := k.GetAsset(ctx, lendPos.AssetID) pool, _ := k.GetPool(ctx, lendPos.PoolID) @@ -226,56 +243,55 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd return err } - lendIDToBorrowIDMapping, _ := k.GetLendIDToBorrowIDMapping(ctx, lendID) - if lendIDToBorrowIDMapping.BorrowingID == nil && withdrawal.Amount.LT(lendPos.UpdatedAmountIn) { - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { - return err - } + if withdrawal.Amount.LT(lendPos.UpdatedAmountIn) { + if withdrawal.Amount.GTE(lendPos.AmountIn.Amount) { + if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + return err + } - //burn c/Token - err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) - if err != nil { - return err - } + //burn c/Token + err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) + if err != nil { + return err + } - if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { - return err - } + if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { + return err + } + subtractionFactor := lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) + subtractionAmount := lendPos.AmountIn.Amount.Sub(subtractionFactor) + k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, subtractionAmount, false) + lendPos.Reward_Accumulated = sdk.ZeroInt() + lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(subtractionAmount) + lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) + k.SetLend(ctx, lendPos) - if withdrawal.Amount.LTE(lendPos.AmountIn.Amount) { - k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, withdrawal.Amount, false) } else { - k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, lendPos.AmountIn.Amount, false) - } - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) - lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) - k.SetLend(ctx, lendPos) - - } else if withdrawal.Amount.LT(lendPos.AvailableToBorrow) { - // add CR validation - // lend to borrow mapping - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { - return err - } - //burn c/Token - err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) - if err != nil { - return err - } - - if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { - return err - } + if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + return err + } + //burn c/Token + err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) + if err != nil { + return err + } - if withdrawal.Amount.LTE(lendPos.AmountIn.Amount) { + if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { + return err + } k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, withdrawal.Amount, false) - } else { - k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, lendPos.AmountIn.Amount, false) - } - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) - lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) - k.SetLend(ctx, lendPos) + if withdrawal.Amount.GTE(lendPos.Reward_Accumulated) { + lendPos.Reward_Accumulated = sdk.ZeroInt() + } else { + lendPos.Reward_Accumulated = lendPos.Reward_Accumulated.Sub(withdrawal.Amount) + } + lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(withdrawal.Amount) + lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) + k.SetLend(ctx, lendPos) + } } else { return types.ErrWithdrawAmountLimitExceeds } @@ -297,6 +313,13 @@ func (k Keeper) DepositAsset(ctx sdk.Context, addr string, lendID uint64, deposi if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } + indexGlobalCurrent, err := k.IterateLends(ctx, lendID) + if err != nil { + return err + } + lendPos, _ = k.GetLend(ctx, lendID) + lendPos.GlobalIndex = indexGlobalCurrent + lendPos.LastInteractionTime = ctx.BlockTime() getAsset, _ := k.GetAsset(ctx, lendPos.AssetID) pool, _ := k.GetPool(ctx, lendPos.PoolID) @@ -350,6 +373,13 @@ func (k Keeper) CloseLend(ctx sdk.Context, addr string, lendID uint64) error { if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } + indexGlobalCurrent, err := k.IterateLends(ctx, lendID) + if err != nil { + return err + } + lendPos, _ = k.GetLend(ctx, lendID) + lendPos.GlobalIndex = indexGlobalCurrent + lendPos.LastInteractionTime = ctx.BlockTime() pool, _ := k.GetPool(ctx, lendPos.PoolID) @@ -501,7 +531,12 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, if loan.Amount.GT(availableAmount.Sub(reservedAmount)) { return sdkerrors.Wrap(types.ErrBorrowingPoolInsufficient, loan.String()) } - + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, pair.AssetOut, pair.AssetOutPoolID) + reserveGlobalIndex, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) + if err != nil { + reserveGlobalIndex = sdk.OneDec() + } + globalIndex := assetStats.BorrowApr if !pair.IsInterPool { AmountOut := loan // take c/Tokens from the user @@ -535,6 +570,9 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, BorrowingTime: ctx.BlockTime(), UpdatedAmountOut: AmountOut.Amount, Interest_Accumulated: sdk.ZeroInt(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), CPoolName: AssetOutPool.CPoolName, } k.UpdateBorrowStats(ctx, pair, borrowPos, AmountOut.Amount, true) @@ -645,6 +683,9 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, BorrowingTime: ctx.BlockTime(), UpdatedAmountOut: AmountOut.Amount, Interest_Accumulated: sdk.ZeroInt(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), CPoolName: AssetOutPool.CPoolName, } k.UpdateBorrowStats(ctx, pair, borrowPos, AmountOut.Amount, true) @@ -714,6 +755,9 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, BorrowingTime: ctx.BlockTime(), UpdatedAmountOut: AmountOut.Amount, Interest_Accumulated: sdk.ZeroInt(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), CPoolName: AssetOutPool.CPoolName, } k.UpdateBorrowStats(ctx, pair, borrowPos, AmountOut.Amount, true) @@ -781,9 +825,20 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string if lendPos.Owner != borrowerAddr { return types.ErrLendAccessUnauthorised } + indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) + if err != nil { + return err + } + borrowPos, found = k.GetBorrow(ctx, borrowID) + if !found { + return types.ErrBorrowNotFound + } if borrowPos.AmountOut.Denom != payment.Denom { return types.ErrBadOfferCoinAmount } + borrowPos.GlobalIndex = indexGlobalCurrent + borrowPos.ReserveGlobalIndex = reserveGlobalIndex + borrowPos.LastInteractionTime = ctx.BlockTime() if payment.Amount.LT(borrowPos.UpdatedAmountOut) { if payment.Amount.LTE(borrowPos.Interest_Accumulated) { @@ -836,7 +891,8 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string return err } borrowPos.UpdatedAmountOut = borrowPos.UpdatedAmountOut.Sub(payment.Amount) - amountOut := borrowPos.AmountOut.Amount.Sub(payment.Amount).Add(borrowPos.Interest_Accumulated) + amtOut := borrowPos.AmountOut.Amount.Sub(payment.Amount) + amountOut := amtOut.Add(borrowPos.Interest_Accumulated) borrowPos.AmountOut.Amount = amountOut reservePoolRecords, _ := k.GetReservePoolRecordsForBorrow(ctx, borrowID) @@ -857,10 +913,11 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string return err } } + amtBorrowStats := payment.Amount.Sub(borrowPos.Interest_Accumulated) borrowPos.Interest_Accumulated = sdk.ZeroInt() reservePoolRecords.InterestAccumulated = sdk.ZeroDec() k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) - k.UpdateBorrowStats(ctx, pair, borrowPos, amountOut, false) + k.UpdateBorrowStats(ctx, pair, borrowPos, amtBorrowStats, false) k.SetBorrow(ctx, borrowPos) } @@ -892,6 +949,17 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string if lendPos.Owner != addr { return types.ErrLendAccessUnauthorised } + indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) + if err != nil { + return err + } + borrowPos, found = k.GetBorrow(ctx, borrowID) + if !found { + return types.ErrBorrowNotFound + } + borrowPos.GlobalIndex = indexGlobalCurrent + borrowPos.ReserveGlobalIndex = reserveGlobalIndex + borrowPos.LastInteractionTime = ctx.BlockTime() assetRatesStat, found := k.GetAssetRatesStats(ctx, lendPos.AssetID) if !found { return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) @@ -1026,6 +1094,17 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, if lendPos.Owner != borrowerAddr { return types.ErrLendAccessUnauthorised } + indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) + if err != nil { + return err + } + borrowPos, found = k.GetBorrow(ctx, borrowID) + if !found { + return types.ErrBorrowNotFound + } + borrowPos.GlobalIndex = indexGlobalCurrent + borrowPos.ReserveGlobalIndex = reserveGlobalIndex + borrowPos.LastInteractionTime = ctx.BlockTime() if borrowPos.AmountOut.Denom != amount.Denom { return types.ErrBadOfferCoinAmount } @@ -1041,7 +1120,7 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, if !found { return types.ErrorAssetStatsNotFound } - err := k.VerifyCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut.Add(amount.Amount), assetOut, assetRatesStats.Ltv) + err = k.VerifyCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut.Add(amount.Amount), assetOut, assetRatesStats.Ltv) if err != nil { return err } @@ -1086,14 +1165,24 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } + if lendPos.Owner != borrowerAddr { + return types.ErrLendAccessUnauthorised + } + indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) + if err != nil { + return err + } + borrowPos, found = k.GetBorrow(ctx, borrowID) + if !found { + return types.ErrBorrowNotFound + } + borrowPos.GlobalIndex = indexGlobalCurrent + borrowPos.ReserveGlobalIndex = reserveGlobalIndex + borrowPos.LastInteractionTime = ctx.BlockTime() assetInPool, found := k.GetPool(ctx, lendPos.PoolID) if !found { return types.ErrPoolNotFound } - - if lendPos.Owner != borrowerAddr { - return types.ErrLendAccessUnauthorised - } assetOut, found := k.GetAsset(ctx, pair.AssetOut) if !found { return assettypes.ErrorAssetDoesNotExist @@ -1103,10 +1192,10 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 return types.ErrInsufficientFunds } amt := sdk.NewCoins(sdk.NewCoin(assetOut.Denom, borrowPos.UpdatedAmountOut)) - if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, amt); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, amt); err != nil { return err } - if err := k.bank.SendCoinsFromModuleToAccount(ctx, assetInPool.ModuleName, lenderAddr, sdk.NewCoins(borrowPos.AmountIn)); err != nil { + if err = k.bank.SendCoinsFromModuleToAccount(ctx, assetInPool.ModuleName, lenderAddr, sdk.NewCoins(borrowPos.AmountIn)); err != nil { return err } @@ -1117,18 +1206,18 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 } if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { amount := sdk.NewCoin(assetOut.Denom, amtToReservePool.TruncateInt()) - err := k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) + err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) if err != nil { return err } } if borrowPos.Interest_Accumulated.GT(amtToReservePool.TruncateInt()) { - err := k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, borrowPos.Interest_Accumulated.Sub(amtToReservePool.TruncateInt()))) + err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, borrowPos.Interest_Accumulated.Sub(amtToReservePool.TruncateInt()))) if err != nil { return err } } - err := k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, false) + err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, false) if err != nil { return err } @@ -1223,18 +1312,28 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo lendID := k.GetUserLendIDHistory(ctx) + var globalIndex sdk.Dec + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, AssetID, PoolID) + if assetStats.LendApr.IsZero() { + globalIndex = sdk.OneDec() + } else { + globalIndex = assetStats.LendApr + } + lendPos := types.LendAsset{ - ID: lendID + 1, - AssetID: AssetID, - PoolID: PoolID, - Owner: lenderAddr, - AmountIn: AmountIn, - LendingTime: ctx.BlockTime(), - UpdatedAmountIn: AmountIn.Amount, - AvailableToBorrow: AmountIn.Amount, - Reward_Accumulated: sdk.ZeroInt(), - CPoolName: pool.CPoolName, - AppID: AppID, + ID: lendID + 1, + AssetID: AssetID, + PoolID: PoolID, + Owner: lenderAddr, + AmountIn: AmountIn, + LendingTime: ctx.BlockTime(), + UpdatedAmountIn: AmountIn.Amount, + AvailableToBorrow: AmountIn.Amount, + Reward_Accumulated: sdk.ZeroInt(), + AppID: AppID, + GlobalIndex: globalIndex, + LastInteractionTime: ctx.BlockTime(), + CPoolName: pool.CPoolName, } k.UpdateLendStats(ctx, AssetID, PoolID, AmountIn.Amount, true) k.SetUserLendIDHistory(ctx, lendPos.ID) @@ -1320,11 +1419,18 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke borrowID := k.GetUserBorrowIDHistory(ctx) pair, _ := k.GetLendPair(ctx, liqBorrow.ExtendedPairId) AssetOut, _ := k.GetAsset(ctx, pair.AssetOut) + assetInRatesStats, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) AssetRatesStats, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) cAssetIn, _ := k.GetAsset(ctx, AssetRatesStats.CAssetID) AssetOutPool, _ := k.GetPool(ctx, pair.AssetOutPoolID) lendPos, _ := k.GetLend(ctx, kind.LendingId) - lendPair, _ := k.GetLendPair(ctx, liqBorrow.ExtendedPairId) + AssetInPool, _ := k.GetPool(ctx, lendPos.PoolID) + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, pair.AssetOut, pair.AssetOutPoolID) + reserveGlobalIndex, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) + if err != nil { + reserveGlobalIndex = sdk.OneDec() + } + globalIndex := assetStats.BorrowApr borrowPos := types.BorrowAsset{ ID: borrowID + 1, @@ -1338,10 +1444,64 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke BorrowingTime: ctx.BlockTime(), UpdatedAmountOut: liqBorrow.AmountOut, Interest_Accumulated: sdk.ZeroInt(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), CPoolName: AssetOutPool.CPoolName, } + // Adjusting bridged asset qty after auctions + if kind.BridgedAssetAmount.Amount != sdk.ZeroInt() { + priceAssetIn, _ := k.GetPriceForAsset(ctx, pair.AssetIn) + adjustedBridgedAssetAmt := borrowPos.AmountIn.Amount.ToDec().Mul(assetInRatesStats.Ltv) + amtIn := adjustedBridgedAssetAmt.TruncateInt().Mul(sdk.NewIntFromUint64(priceAssetIn)) + priceFirstBridgedAsset, _ := k.GetPriceForAsset(ctx, AssetInPool.FirstBridgedAssetID) + priceSecondBridgedAsset, _ := k.GetPriceForAsset(ctx, AssetInPool.SecondBridgedAssetID) + firstBridgedAsset, _ := k.GetAsset(ctx, AssetInPool.FirstBridgedAssetID) + + if kind.BridgedAssetAmount.Denom == firstBridgedAsset.Denom { + firstBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceFirstBridgedAsset)) + diff := borrowPos.BridgedAssetAmount.Amount.Sub(firstBridgedAssetQty) + if diff.GT(sdk.ZeroInt()) { + err := k.SendCoinFromModuleToModule(ctx, AssetOutPool.ModuleName, AssetInPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, diff))) + if err != nil { + return + } + borrowPos.BridgedAssetAmount.Amount = firstBridgedAssetQty + } else { + newDiff := firstBridgedAssetQty.Sub(borrowPos.BridgedAssetAmount.Amount) + if newDiff.GT(sdk.ZeroInt()) { + err := k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, newDiff))) + if err != nil { + return + } + borrowPos.BridgedAssetAmount.Amount = firstBridgedAssetQty + } + } + + } else { + secondBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceSecondBridgedAsset)) + diff := borrowPos.BridgedAssetAmount.Amount.Sub(secondBridgedAssetQty) + if diff.GT(sdk.ZeroInt()) { + err := k.SendCoinFromModuleToModule(ctx, AssetOutPool.ModuleName, AssetInPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, diff))) + if err != nil { + return + } + borrowPos.BridgedAssetAmount.Amount = secondBridgedAssetQty + } else { + newDiff := secondBridgedAssetQty.Sub(borrowPos.BridgedAssetAmount.Amount) + if newDiff.GT(sdk.ZeroInt()) { + err := k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, newDiff))) + if err != nil { + return + } + borrowPos.BridgedAssetAmount.Amount = secondBridgedAssetQty + } + } + } + + } OriginalBorrowID := liqBorrow.OriginalVaultId - err := k.UpdateLendIDToBorrowIDMapping(ctx, kind.LendingId, OriginalBorrowID, false) + err = k.UpdateLendIDToBorrowIDMapping(ctx, kind.LendingId, OriginalBorrowID, false) if err != nil { return } @@ -1352,7 +1512,7 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke if err != nil { return } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, lendPair.AssetOutPoolID, true) + err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, pair.AssetOutPoolID, true) if err != nil { return } @@ -1365,3 +1525,59 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke return } } + +func (k Keeper) MsgCalculateBorrowInterest(ctx sdk.Context, borrowerAddr string, borrowID uint64) error { + borrowPos, found := k.GetBorrow(ctx, borrowID) + if !found { + return types.ErrBorrowNotFound + } + + lendPos, found := k.GetLend(ctx, borrowPos.LendingID) + if !found { + return types.ErrLendNotFound + } + killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + if killSwitchParams.BreakerEnable { + return esmtypes.ErrCircuitBreakerEnabled + } + if lendPos.Owner != borrowerAddr { + return types.ErrLendAccessUnauthorised + } + indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) + if err != nil { + return err + } + borrowPos, found = k.GetBorrow(ctx, borrowID) + if !found { + return types.ErrBorrowNotFound + } + borrowPos.GlobalIndex = indexGlobalCurrent + borrowPos.ReserveGlobalIndex = reserveGlobalIndex + borrowPos.LastInteractionTime = ctx.BlockTime() + k.SetBorrow(ctx, borrowPos) + return nil +} + +func (k Keeper) MsgCalculateLendRewards(ctx sdk.Context, addr string, lendID uint64) error { + lendPos, found := k.GetLend(ctx, lendID) + if !found { + return types.ErrLendNotFound + } + + killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + if killSwitchParams.BreakerEnable { + return esmtypes.ErrCircuitBreakerEnabled + } + indexGlobalCurrent, err := k.IterateLends(ctx, lendID) + if err != nil { + return err + } + lendPos, _ = k.GetLend(ctx, lendID) + lendPos.GlobalIndex = indexGlobalCurrent + lendPos.LastInteractionTime = ctx.BlockTime() + if lendPos.Owner != addr { + return types.ErrLendAccessUnauthorised + } + k.SetLend(ctx, lendPos) + return nil +} diff --git a/x/lend/keeper/lend.go b/x/lend/keeper/lend.go index d37d7a59a..e997a6ed8 100644 --- a/x/lend/keeper/lend.go +++ b/x/lend/keeper/lend.go @@ -559,34 +559,6 @@ func (k Keeper) AssetStatsByPoolIDAndAssetID(ctx sdk.Context, assetID, poolID ui return AssetStats, true } -func (k Keeper) SetLastInterestTime(ctx sdk.Context, interestTime int64) error { - store := ctx.KVStore(k.storeKey) - timeKey := types.CreateLastInterestTimeKey() - - bz, err := k.cdc.Marshal(&protobuftypes.Int64Value{Value: interestTime}) - if err != nil { - return err - } - - store.Set(timeKey, bz) - return nil -} - -// GetLastInterestTime gets last time at which interest was accrued. -func (k Keeper) GetLastInterestTime(ctx sdk.Context) int64 { - store := ctx.KVStore(k.storeKey) - timeKey := types.CreateLastInterestTimeKey() - bz := store.Get(timeKey) - - val := protobuftypes.Int64Value{} - - if err := k.cdc.Unmarshal(bz, &val); err != nil { - panic(err) - } - - return val.Value -} - func (k Keeper) UpdateLendIDsMapping( ctx sdk.Context, lendID uint64, diff --git a/x/lend/keeper/maths.go b/x/lend/keeper/maths.go index 6d08f42b8..872a4b9f4 100644 --- a/x/lend/keeper/maths.go +++ b/x/lend/keeper/maths.go @@ -76,17 +76,19 @@ func (k Keeper) GetLendAPRByAssetIDAndPoolID(ctx sdk.Context, poolID, assetID ui return lendAPY, nil } -func (k Keeper) GetAverageBorrowRate(ctx sdk.Context, poolID, assetID uint64) (averageBorrowRate sdk.Dec, err error) { +func (k Keeper) GetAverageBorrowRate(ctx sdk.Context, poolID, assetID uint64) (sdk.Dec, error) { assetStats, _ := k.UpdateAPR(ctx, poolID, assetID) factor1 := assetStats.BorrowApr.Mul(sdk.Dec(assetStats.TotalBorrowed)) factor2 := assetStats.StableBorrowApr.Mul(sdk.Dec(assetStats.TotalStableBorrowed)) numerator := factor1.Add(factor2) denominator := sdk.Dec(assetStats.TotalStableBorrowed).Add(sdk.Dec(assetStats.TotalBorrowed)) - if denominator == sdk.ZeroDec() { - return sdk.Dec{}, types.ErrAverageBorrowRate + + if denominator.GT(sdk.ZeroDec()) { + averageBorrowRate := numerator.Quo(denominator) + return averageBorrowRate, nil + } - averageBorrowRate = numerator.Quo(denominator) - return averageBorrowRate, nil + return sdk.ZeroDec(), types.ErrAverageBorrowRate } func (k Keeper) GetSavingRate(ctx sdk.Context, poolID, assetID uint64) (savingRate sdk.Dec, err error) { @@ -107,14 +109,17 @@ func (k Keeper) GetSavingRate(ctx sdk.Context, poolID, assetID uint64) (savingRa func (k Keeper) GetReserveRate(ctx sdk.Context, poolID, assetID uint64) (reserveRate sdk.Dec, err error) { averageBorrowRate, err := k.GetAverageBorrowRate(ctx, poolID, assetID) if err != nil { - return sdk.Dec{}, err + return sdk.ZeroDec(), err } savingRate, err := k.GetSavingRate(ctx, poolID, assetID) if err != nil { return sdk.Dec{}, err } - reserveRate = averageBorrowRate.Sub(savingRate) - return reserveRate, nil + if averageBorrowRate != sdk.ZeroDec() { + reserveRate = averageBorrowRate.Sub(savingRate) + return reserveRate, nil + } + return sdk.ZeroDec(), nil } func (k Keeper) UpdateAPR(ctx sdk.Context, poolID, assetID uint64) (AssetStats types.AssetStats, found bool) { diff --git a/x/lend/keeper/msg_server.go b/x/lend/keeper/msg_server.go index 84377f920..f40c9a3cd 100644 --- a/x/lend/keeper/msg_server.go +++ b/x/lend/keeper/msg_server.go @@ -161,3 +161,31 @@ func (m msgServer) FundModuleAccounts(goCtx context.Context, accounts *types.Msg return &types.MsgFundModuleAccountsResponse{}, nil } + +func (m msgServer) CalculateBorrowInterest(goCtx context.Context, interest *types.MsgCalculateBorrowInterest) (*types.MsgCalculateBorrowInterestResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + borrowID := interest.BorrowId + + if err := m.keeper.MsgCalculateBorrowInterest(ctx, interest.Borrower, borrowID); err != nil { + return nil, err + } + + ctx.GasMeter().ConsumeGas(types.CalculateBorrowInterestGas, "CalculateBorrowInterestGas") + + return &types.MsgCalculateBorrowInterestResponse{}, nil +} + +func (m msgServer) CalculateLendRewards(goCtx context.Context, rewards *types.MsgCalculateLendRewards) (*types.MsgCalculateLendRewardsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + borrowID := rewards.LendId + + if err := m.keeper.MsgCalculateLendRewards(ctx, rewards.Lender, borrowID); err != nil { + return nil, err + } + + ctx.GasMeter().ConsumeGas(types.CalculateLendRewardGas, "CalculateLendRewardGas") + + return &types.MsgCalculateLendRewardsResponse{}, nil +} diff --git a/x/lend/module.go b/x/lend/module.go index b4c1b21a0..7a99c9302 100644 --- a/x/lend/module.go +++ b/x/lend/module.go @@ -44,12 +44,12 @@ func (AppModuleBasic) Name() string { return types.ModuleName } -func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) -} +//func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { +// types.RegisterCodec(cdc) +//} func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterCodec(cdc) + types.RegisterLegacyAminoCodec(cdc) } // RegisterInterfaces registers the module's interface types. diff --git a/x/lend/types/codec.go b/x/lend/types/codec.go index aef487b71..fcb20bf51 100644 --- a/x/lend/types/codec.go +++ b/x/lend/types/codec.go @@ -3,29 +3,31 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) -func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgLend{}, "comdex/lend/lend", nil) - cdc.RegisterConcrete(&MsgWithdraw{}, "comdex/lend/withdraw", nil) - cdc.RegisterConcrete(&MsgDeposit{}, "comdex/lend/deposit", nil) - cdc.RegisterConcrete(&MsgCloseLend{}, "comdex/lend/close-lend", nil) - cdc.RegisterConcrete(&MsgBorrow{}, "comdex/lend/borrow", nil) - cdc.RegisterConcrete(&MsgDepositBorrow{}, "comdex/lend/deposit-borrow", nil) - cdc.RegisterConcrete(&MsgDraw{}, "comdex/lend/draw", nil) - cdc.RegisterConcrete(&MsgCloseBorrow{}, "comdex/lend/close-borrow", nil) - cdc.RegisterConcrete(&MsgRepay{}, "comdex/lend/repay", nil) - cdc.RegisterConcrete(&MsgBorrowAlternate{}, "comdex/lend/borrow-alternate", nil) - cdc.RegisterConcrete(&MsgFundModuleAccounts{}, "comdex/lend/fund-module", nil) - cdc.RegisterConcrete(&LendPairsProposal{}, "comdex/lend/add-lend-pairs", nil) - cdc.RegisterConcrete(&AddPoolsProposal{}, "comdex/lend/add-lend-pools", nil) - cdc.RegisterConcrete(&AddAssetToPairProposal{}, "comdex/lend/add-asset-to-pair-mapping", nil) - cdc.RegisterConcrete(&AddAssetRatesStats{}, "comdex/lend/add-asset-rates-stats", nil) - cdc.RegisterConcrete(&AddAuctionParamsProposal{}, "comdex/lend/add-auction-params", nil) +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgLend{}, "comdex/lend/MsgLend", nil) + cdc.RegisterConcrete(&MsgWithdraw{}, "comdex/lend/MsgWithdraw", nil) + cdc.RegisterConcrete(&MsgDeposit{}, "comdex/lend/MsgDeposit", nil) + cdc.RegisterConcrete(&MsgCloseLend{}, "comdex/lend/MsgCloseLend", nil) + cdc.RegisterConcrete(&MsgBorrow{}, "comdex/lend/MsgBorrow", nil) + cdc.RegisterConcrete(&MsgDepositBorrow{}, "comdex/lend/MsgDepositBorrow", nil) + cdc.RegisterConcrete(&MsgDraw{}, "comdex/lend/MsgDraw", nil) + cdc.RegisterConcrete(&MsgCloseBorrow{}, "comdex/lend/MsgCloseBorrow", nil) + cdc.RegisterConcrete(&MsgRepay{}, "comdex/lend/MsgRepay", nil) + cdc.RegisterConcrete(&MsgBorrowAlternate{}, "comdex/lend/MsgBorrowAlternate", nil) + cdc.RegisterConcrete(&MsgFundModuleAccounts{}, "comdex/lend/MsgFundModuleAccounts", nil) + cdc.RegisterConcrete(&LendPairsProposal{}, "comdex/lend/LendPairsProposal", nil) + cdc.RegisterConcrete(&AddPoolsProposal{}, "comdex/lend/AddPoolsProposal", nil) + cdc.RegisterConcrete(&AddAssetToPairProposal{}, "comdex/lend/AddAssetToPairProposal", nil) + cdc.RegisterConcrete(&AddAssetRatesStats{}, "comdex/lend/AddAssetRatesStats", nil) + cdc.RegisterConcrete(&AddAuctionParamsProposal{}, "comdex/lend/AddAuctionParamsProposal", nil) + cdc.RegisterConcrete(&MsgCalculateBorrowInterest{}, "comdex/lend/MsgCalculateBorrowInterest", nil) + cdc.RegisterConcrete(&MsgCalculateLendRewards{}, "comdex/lend/MsgCalculateLendRewards", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -50,12 +52,20 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgRepay{}, &MsgBorrowAlternate{}, &MsgFundModuleAccounts{}, + &MsgCalculateBorrowInterest{}, + &MsgCalculateLendRewards{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } var ( - Amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) ) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/lend/types/keys.go b/x/lend/types/keys.go index 076080eb6..b594b6157 100644 --- a/x/lend/types/keys.go +++ b/x/lend/types/keys.go @@ -30,17 +30,19 @@ const ( ) var ( - TypeLendAssetRequest = ModuleName + ":lend" - TypeWithdrawAssetRequest = ModuleName + ":withdraw" - TypeBorrowAssetRequest = ModuleName + ":borrow" - TypeRepayAssetRequest = ModuleName + ":repay" - TypeFundModuleAccountRequest = ModuleName + ":fund-module" - TypeDepositAssetRequest = ModuleName + ":deposit" - TypeCloseLendAssetRequest = ModuleName + ":close-lend" - TypeCloseBorrowAssetRequest = ModuleName + ":close-borrow" - TypeDrawAssetRequest = ModuleName + ":draw" - TypeDepositBorrowdAssetRequest = ModuleName + ":deposit-borrow" - TypeBorrowAlternateAssetRequest = ModuleName + ":borrow-alternate" + TypeLendAssetRequest = ModuleName + ":lend" + TypeWithdrawAssetRequest = ModuleName + ":withdraw" + TypeBorrowAssetRequest = ModuleName + ":borrow" + TypeRepayAssetRequest = ModuleName + ":repay" + TypeFundModuleAccountRequest = ModuleName + ":fund-module" + TypeDepositAssetRequest = ModuleName + ":deposit" + TypeCloseLendAssetRequest = ModuleName + ":close-lend" + TypeCloseBorrowAssetRequest = ModuleName + ":close-borrow" + TypeDrawAssetRequest = ModuleName + ":draw" + TypeDepositBorrowAssetRequest = ModuleName + ":deposit-borrow" + TypeBorrowAlternateAssetRequest = ModuleName + ":borrow-alternate" + TypeCalculateBorrowInterestRequest = ModuleName + ":calculate-borrow-interest" + TypeCalculateLendRewardsRequest = ModuleName + ":calculate-lend-rewards" ) var ( @@ -67,7 +69,6 @@ var ( LendIDToBorrowIDMappingKeyPrefix = []byte{0x28} AssetStatsByPoolIDAndAssetIDKeyPrefix = []byte{0x29} AssetRatesStatsKeyPrefix = []byte{0x30} - KeyPrefixLastTime = []byte{0x31} LendByUserAndPoolPrefix = []byte{0x34} BorrowByUserAndPoolPrefix = []byte{0x35} DepositStatsPrefix = []byte{0x36} @@ -165,12 +166,6 @@ func SetAssetStatsByPoolIDAndAssetID(assetID, pairID uint64) []byte { return append(v, sdk.Uint64ToBigEndian(pairID)...) } -func CreateLastInterestTimeKey() []byte { - var key []byte - key = append(key, KeyPrefixLastTime...) - return key -} - func LendByUserAndPoolKey(owner string, ID uint64) []byte { return append(append(LendByUserAndPoolPrefix, sdk.Uint64ToBigEndian(ID)...), owner...) } diff --git a/x/lend/types/lend.pb.go b/x/lend/types/lend.pb.go index 5422f08e6..f309d3b88 100644 --- a/x/lend/types/lend.pb.go +++ b/x/lend/types/lend.pb.go @@ -30,17 +30,19 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type LendAsset struct { - ID uint64 `protobuf:"varint,1,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` - AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` - PoolID uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - AmountIn github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,5,opt,name=amount_in,json=amountIn,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount_in" yaml:"amount_in"` - LendingTime time.Time `protobuf:"bytes,6,opt,name=lending_time,json=lendingTime,proto3,stdtime" json:"lending_time" yaml:"lending_time"` - UpdatedAmountIn github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=updated_amount_in,json=updatedAmountIn,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"updated_amount_in" yaml:"updated_amount_in"` - AvailableToBorrow github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=available_to_borrow,json=availableToBorrow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"available_to_borrow" yaml:"available_to_borrow"` - Reward_Accumulated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=reward_Accumulated,json=rewardAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"reward_Accumulated" yaml:"reward_accumulated"` - AppID uint64 `protobuf:"varint,10,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` - CPoolName string `protobuf:"bytes,11,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` + ID uint64 `protobuf:"varint,1,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` + AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + PoolID uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` + AmountIn github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,5,opt,name=amount_in,json=amountIn,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount_in" yaml:"amount_in"` + LendingTime time.Time `protobuf:"bytes,6,opt,name=lending_time,json=lendingTime,proto3,stdtime" json:"lending_time" yaml:"lending_time"` + UpdatedAmountIn github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=updated_amount_in,json=updatedAmountIn,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"updated_amount_in" yaml:"updated_amount_in"` + AvailableToBorrow github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=available_to_borrow,json=availableToBorrow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"available_to_borrow" yaml:"available_to_borrow"` + Reward_Accumulated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=reward_Accumulated,json=rewardAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"reward_Accumulated" yaml:"reward_accumulated"` + AppID uint64 `protobuf:"varint,10,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` + GlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=global_index,json=globalIndex,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"global_index" yaml:"global_index"` + LastInteractionTime time.Time `protobuf:"bytes,12,opt,name=last_interaction_time,json=lastInteractionTime,proto3,stdtime" json:"last_interaction_time" yaml:"last_interaction_time"` + CPoolName string `protobuf:"bytes,13,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` } func (m *LendAsset) Reset() { *m = LendAsset{} } @@ -125,6 +127,13 @@ func (m *LendAsset) GetAppID() uint64 { return 0 } +func (m *LendAsset) GetLastInteractionTime() time.Time { + if m != nil { + return m.LastInteractionTime + } + return time.Time{} +} + func (m *LendAsset) GetCPoolName() string { if m != nil { return m.CPoolName @@ -144,7 +153,10 @@ type BorrowAsset struct { StableBorrowRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=stable_borrow_rate,json=stableBorrowRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_borrow_rate" yaml:"stable_borrow_rate"` UpdatedAmountOut github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=updated_amount_out,json=updatedAmountOut,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"updated_amount_out" yaml:"updated_amount_out"` Interest_Accumulated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=interest_Accumulated,json=interestAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"interest_Accumulated" yaml:"interest_accumulated"` - CPoolName string `protobuf:"bytes,12,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` + GlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=global_index,json=globalIndex,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"global_index" yaml:"global_index"` + ReserveGlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=reserve_global_index,json=reserveGlobalIndex,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reserve_global_index" yaml:"reserve_global_index"` + LastInteractionTime time.Time `protobuf:"bytes,14,opt,name=last_interaction_time,json=lastInteractionTime,proto3,stdtime" json:"last_interaction_time" yaml:"last_interaction_time"` + CPoolName string `protobuf:"bytes,15,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` } func (m *BorrowAsset) Reset() { *m = BorrowAsset{} } @@ -236,6 +248,13 @@ func (m *BorrowAsset) GetBorrowingTime() time.Time { return time.Time{} } +func (m *BorrowAsset) GetLastInteractionTime() time.Time { + if m != nil { + return m.LastInteractionTime + } + return time.Time{} +} + func (m *BorrowAsset) GetCPoolName() string { if m != nil { return m.CPoolName @@ -1515,166 +1534,173 @@ func init() { func init() { proto.RegisterFile("comdex/lend/v1beta1/lend.proto", fileDescriptor_b87bb4bef8334ddd) } var fileDescriptor_b87bb4bef8334ddd = []byte{ - // 2536 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, - 0x15, 0xf7, 0xca, 0xfa, 0x20, 0x1f, 0x45, 0x49, 0x1c, 0x52, 0x31, 0x23, 0xc7, 0x5a, 0x67, 0x52, - 0x38, 0xee, 0x21, 0x14, 0xac, 0xa6, 0x40, 0x62, 0xc4, 0x48, 0x48, 0xcb, 0x6a, 0x98, 0xd8, 0x72, - 0x32, 0x76, 0x1a, 0xf4, 0x73, 0x31, 0xe4, 0x8e, 0xe4, 0x85, 0xc9, 0xdd, 0xcd, 0xce, 0xae, 0x1c, - 0xf5, 0xc3, 0x08, 0xda, 0x43, 0x81, 0x9e, 0x72, 0xef, 0xad, 0x87, 0xe6, 0x3f, 0xe8, 0xad, 0x40, - 0x2f, 0x6d, 0x73, 0x68, 0x81, 0x1c, 0x83, 0x1e, 0xd8, 0x82, 0x3e, 0x14, 0xe8, 0x51, 0xc7, 0x9e, - 0x8a, 0xf9, 0xd8, 0x2f, 0x92, 0xb1, 0xbd, 0x92, 0x8b, 0xa0, 0x27, 0x71, 0x66, 0xde, 0xfc, 0xde, - 0x9b, 0x79, 0x1f, 0xf3, 0xde, 0x5b, 0xc1, 0x66, 0xdf, 0x1b, 0xda, 0xec, 0xe3, 0xad, 0x01, 0x73, - 0xed, 0xad, 0xc3, 0x2b, 0x3d, 0x16, 0xd2, 0x2b, 0x72, 0xd0, 0xf2, 0x03, 0x2f, 0xf4, 0x50, 0x5d, - 0xad, 0xb7, 0xe4, 0x94, 0x5e, 0xdf, 0x68, 0x1c, 0x78, 0x07, 0x9e, 0x5c, 0xdf, 0x12, 0xbf, 0x14, - 0xe9, 0x86, 0x79, 0xe0, 0x79, 0x07, 0x03, 0xb6, 0x25, 0x47, 0xbd, 0x68, 0x7f, 0x2b, 0x74, 0x86, - 0x8c, 0x87, 0x74, 0xe8, 0x6b, 0x82, 0xcd, 0xbe, 0xc7, 0x87, 0x1e, 0xdf, 0xea, 0x51, 0xce, 0x12, - 0x5e, 0x7d, 0xcf, 0x71, 0xd5, 0x3a, 0xfe, 0xdd, 0x12, 0x94, 0x6f, 0x32, 0xd7, 0x6e, 0x73, 0xce, - 0x42, 0x74, 0x15, 0x40, 0x30, 0x75, 0xdc, 0x03, 0xcb, 0xb1, 0x9b, 0xc6, 0x45, 0xe3, 0xf2, 0x7c, - 0xe7, 0xfc, 0x78, 0x64, 0xce, 0x75, 0x77, 0x8e, 0x47, 0x66, 0xed, 0x88, 0x0e, 0x07, 0x57, 0x71, - 0x4a, 0x81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0x1e, 0xf0, 0xdc, 0xff, 0xcb, 0xd1, - 0xfe, 0x6a, 0x40, 0x43, 0x3c, 0xe5, 0x96, 0xfa, 0x42, 0xce, 0x93, 0x73, 0xbd, 0x3a, 0xa3, 0xd1, - 0xb3, 0xfe, 0xc4, 0xde, 0xce, 0x43, 0xa8, 0xc7, 0x40, 0xff, 0xf3, 0xf3, 0xe8, 0xff, 0x1d, 0xe0, - 0x99, 0xe3, 0x74, 0xde, 0xfe, 0x7c, 0xbc, 0x69, 0x7c, 0x31, 0xde, 0x34, 0xfe, 0x39, 0xde, 0x34, - 0x3e, 0x7d, 0xb4, 0x79, 0xe6, 0x8b, 0x47, 0x9b, 0x67, 0xbe, 0x7c, 0xb4, 0x79, 0xe6, 0xfb, 0xad, - 0x1c, 0x53, 0x11, 0x6e, 0x5f, 0xf1, 0xf6, 0xf7, 0x9d, 0xbe, 0x43, 0x07, 0x7a, 0xbc, 0xa5, 0xff, - 0x97, 0x47, 0x0a, 0xd0, 0x5b, 0x94, 0xdf, 0x36, 0xbf, 0xf5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xee, 0xf8, 0xd5, 0x35, 0xe7, 0x23, 0x00, 0x00, + // 2646 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5a, 0x4d, 0x6c, 0x1b, 0xc7, + 0x15, 0xf6, 0xca, 0xfa, 0x21, 0x1f, 0x49, 0x49, 0x1c, 0x52, 0x31, 0x23, 0xd9, 0x5a, 0x67, 0x52, + 0x38, 0xea, 0x21, 0x14, 0xac, 0xa6, 0x40, 0x62, 0x24, 0x48, 0x48, 0xcb, 0x4a, 0x98, 0xd8, 0xb2, + 0x33, 0x76, 0x1a, 0xf4, 0x77, 0x31, 0xe4, 0x8e, 0xe4, 0x85, 0x97, 0xbb, 0x9b, 0xdd, 0xa5, 0x6c, + 0xf5, 0xc7, 0x0d, 0xda, 0x43,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a, 0xc2, 0x1d, 0x84, 0x8a, 0xb9, + 0x1e, 0xa3, 0x7d, 0x57, 0x69, 0xaf, 0x66, 0xb4, 0xbb, 0x83, 0x30, 0x97, 0x7a, 0xb5, 0xde, 0x9b, + 0x83, 0x10, 0xfd, 0x56, 0x83, 0x7a, 0xd7, 0xb7, 0xcc, 0x43, 0xce, 0x45, 0xe2, 0xd9, 0x90, 0x63, + 0x82, 0xdf, 0x1e, 0x6b, 0xca, 0xbe, 0x32, 0x65, 0x43, 0x79, 0xc8, 0x14, 0x90, 0x5c, 0x46, 0x21, + 0x85, 0x20, 0xfc, 0x52, 0x72, 0x20, 0x32, 0x61, 0x39, 0xf1, 0x3c, 0x71, 0xc7, 0x0a, 0x4f, 0xbc, + 0x63, 0x2f, 0x28, 0xbb, 0xd6, 0xc6, 0x3d, 0x37, 0xb9, 0x5c, 0x95, 0xb8, 0x53, 0x5c, 0xab, 0x63, + 0x40, 0x19, 0xcf, 0x32, 0x7c, 0x1a, 0xb2, 0x19, 0x98, 0x4e, 0x12, 0x88, 0x62, 0xba, 0x49, 0x44, + 0x4c, 0x56, 0x83, 0x94, 0xbb, 0x12, 0x1a, 0x0a, 0xd5, 0x63, 0x2f, 0x01, 0x77, 0x03, 0x78, 0x3a, + 0x92, 0x9d, 0x44, 0xc4, 0x64, 0x35, 0xf3, 0xb8, 0xf0, 0x93, 0xff, 0x58, 0x83, 0xba, 0xe0, 0x1e, + 0x16, 0x84, 0x19, 0x8a, 0x97, 0xcc, 0x79, 0x23, 0xb7, 0x76, 0xe5, 0x08, 0x31, 0x66, 0x86, 0xe4, + 0x6b, 0x51, 0x77, 0x9a, 0xe6, 0xc7, 0x39, 0xbb, 0xfc, 0xb5, 0x71, 0xf6, 0x2f, 0xa1, 0xee, 0xb3, + 0x80, 0xf9, 0x47, 0xcc, 0xc8, 0x68, 0xac, 0xe4, 0x5e, 0xab, 0xd4, 0xb8, 0x11, 0x3d, 0x67, 0x93, + 0x98, 0x98, 0x20, 0xd5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0xe9, 0x8f, 0x2e, 0x98, 0x28, 0x38, 0x1c, 0x42, 0x79, 0x97, 0x79, 0x6e, 0x60, 0xa9, 0xfc, + 0xc4, 0x84, 0x4a, 0xf6, 0xdc, 0x35, 0x71, 0xee, 0x2f, 0x4c, 0x3d, 0xf7, 0xcc, 0x89, 0x9f, 0x57, + 0x5b, 0x57, 0xcf, 0x6c, 0x5d, 0x74, 0xd4, 0xe5, 0x6e, 0xfa, 0x90, 0xff, 0x3d, 0x0f, 0x95, 0xd6, + 0x40, 0x94, 0x79, 0x6f, 0x51, 0x9f, 0xf6, 0x03, 0xb4, 0x15, 0x7f, 0x34, 0x95, 0x3b, 0x53, 0xfd, + 0xca, 0x6f, 0xa5, 0x3f, 0x86, 0x06, 0x95, 0x53, 0x0d, 0x73, 0xe0, 0x4b, 0x66, 0x93, 0x25, 0xc4, + 0x40, 0xa5, 0x46, 0x2f, 0x9e, 0x0c, 0x75, 0x5d, 0xcd, 0xfd, 0x0a, 0x49, 0x4c, 0x9e, 0x53, 0x43, + 0xbb, 0x6a, 0x44, 0x56, 0x2f, 0x03, 0xbe, 0xd3, 0xdd, 0xc1, 0xc1, 0x01, 0xf3, 0x55, 0xd0, 0x35, + 0x73, 0x18, 0x23, 0x51, 0x30, 0x51, 0x70, 0x3c, 0x96, 0xeb, 0x0d, 0x02, 0x4f, 0x85, 0x5d, 0x33, + 0xc7, 0x72, 0x1c, 0x03, 0x13, 0x01, 0xc5, 0x21, 0x83, 0x90, 0x79, 0x2a, 0xe0, 0x7a, 0x23, 0xb7, + 0x4f, 0x94, 0x22, 0x7e, 0x61, 0x1c, 0x92, 0xff, 0x41, 0xfb, 0x50, 0xf3, 0x7c, 0xab, 0x27, 0x6a, + 0xa2, 0xaa, 0x42, 0x7f, 0xec, 0x31, 0x55, 0xdc, 0xda, 0x4c, 0x1e, 0xb5, 0x29, 0x42, 0x98, 0x54, + 0x45, 0xef, 0x9e, 0xea, 0xbc, 0x73, 0xec, 0x31, 0xd4, 0x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 0xab, 0x7f, 0x0a, + 0x13, 0x06, 0x74, 0x17, 0xc5, 0xf7, 0xb6, 0xef, 0xfc, 0x37, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x6b, + 0xa6, 0xb6, 0x30, 0x26, 0x00, 0x00, } func (m *LendAsset) Marshal() (dAtA []byte, err error) { @@ -1702,8 +1728,26 @@ func (m *LendAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.CPoolName) i = encodeVarintLend(dAtA, i, uint64(len(m.CPoolName))) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x6a + } + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastInteractionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime):]) + if err1 != nil { + return 0, err1 } + i -= n1 + i = encodeVarintLend(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x62 + { + size := m.GlobalIndex.Size() + i -= size + if _, err := m.GlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a if m.AppID != 0 { i = encodeVarintLend(dAtA, i, uint64(m.AppID)) i-- @@ -1739,12 +1783,12 @@ func (m *LendAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x3a - n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LendingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LendingTime):]) - if err1 != nil { - return 0, err1 + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LendingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LendingTime):]) + if err2 != nil { + return 0, err2 } - i -= n1 - i = encodeVarintLend(dAtA, i, uint64(n1)) + i -= n2 + i = encodeVarintLend(dAtA, i, uint64(n2)) i-- dAtA[i] = 0x32 { @@ -1807,8 +1851,36 @@ func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.CPoolName) i = encodeVarintLend(dAtA, i, uint64(len(m.CPoolName))) i-- - dAtA[i] = 0x62 + dAtA[i] = 0x7a + } + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastInteractionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintLend(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x72 + { + size := m.ReserveGlobalIndex.Size() + i -= size + if _, err := m.ReserveGlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + { + size := m.GlobalIndex.Size() + i -= size + if _, err := m.GlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x62 { size := m.Interest_Accumulated.Size() i -= size @@ -1839,12 +1911,12 @@ func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x4a - n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.BorrowingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.BorrowingTime):]) - if err3 != nil { - return 0, err3 + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.BorrowingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.BorrowingTime):]) + if err5 != nil { + return 0, err5 } - i -= n3 - i = encodeVarintLend(dAtA, i, uint64(n3)) + i -= n5 + i = encodeVarintLend(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x42 { @@ -2098,20 +2170,20 @@ func (m *AssetToPairMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.PairID) > 0 { - dAtA8 := make([]byte, len(m.PairID)*10) - var j7 int + dAtA10 := make([]byte, len(m.PairID)*10) + var j9 int for _, num := range m.PairID { for num >= 1<<7 { - dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j7++ + j9++ } - dAtA8[j7] = uint8(num) - j7++ + dAtA10[j9] = uint8(num) + j9++ } - i -= j7 - copy(dAtA[i:], dAtA8[:j7]) - i = encodeVarintLend(dAtA, i, uint64(j7)) + i -= j9 + copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintLend(dAtA, i, uint64(j9)) i-- dAtA[i] = 0x1a } @@ -2149,20 +2221,20 @@ func (m *UserLendIdMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.LendIDs) > 0 { - dAtA10 := make([]byte, len(m.LendIDs)*10) - var j9 int + dAtA12 := make([]byte, len(m.LendIDs)*10) + var j11 int for _, num := range m.LendIDs { for num >= 1<<7 { - dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j9++ + j11++ } - dAtA10[j9] = uint8(num) - j9++ + dAtA12[j11] = uint8(num) + j11++ } - i -= j9 - copy(dAtA[i:], dAtA10[:j9]) - i = encodeVarintLend(dAtA, i, uint64(j9)) + i -= j11 + copy(dAtA[i:], dAtA12[:j11]) + i = encodeVarintLend(dAtA, i, uint64(j11)) i-- dAtA[i] = 0x12 } @@ -2197,20 +2269,20 @@ func (m *LendIdByOwnerAndPoolMapping) MarshalToSizedBuffer(dAtA []byte) (int, er var l int _ = l if len(m.LendIDs) > 0 { - dAtA12 := make([]byte, len(m.LendIDs)*10) - var j11 int + dAtA14 := make([]byte, len(m.LendIDs)*10) + var j13 int for _, num := range m.LendIDs { for num >= 1<<7 { - dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) + dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j11++ + j13++ } - dAtA12[j11] = uint8(num) - j11++ + dAtA14[j13] = uint8(num) + j13++ } - i -= j11 - copy(dAtA[i:], dAtA12[:j11]) - i = encodeVarintLend(dAtA, i, uint64(j11)) + i -= j13 + copy(dAtA[i:], dAtA14[:j13]) + i = encodeVarintLend(dAtA, i, uint64(j13)) i-- dAtA[i] = 0x1a } @@ -2250,20 +2322,20 @@ func (m *BorrowIdByOwnerAndPoolMapping) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l if len(m.BorrowIDs) > 0 { - dAtA14 := make([]byte, len(m.BorrowIDs)*10) - var j13 int + dAtA16 := make([]byte, len(m.BorrowIDs)*10) + var j15 int for _, num := range m.BorrowIDs { for num >= 1<<7 { - dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) + dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j13++ + j15++ } - dAtA14[j13] = uint8(num) - j13++ + dAtA16[j15] = uint8(num) + j15++ } - i -= j13 - copy(dAtA[i:], dAtA14[:j13]) - i = encodeVarintLend(dAtA, i, uint64(j13)) + i -= j15 + copy(dAtA[i:], dAtA16[:j15]) + i = encodeVarintLend(dAtA, i, uint64(j15)) i-- dAtA[i] = 0x1a } @@ -2303,20 +2375,20 @@ func (m *UserBorrowIdMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.BorrowIDs) > 0 { - dAtA16 := make([]byte, len(m.BorrowIDs)*10) - var j15 int + dAtA18 := make([]byte, len(m.BorrowIDs)*10) + var j17 int for _, num := range m.BorrowIDs { for num >= 1<<7 { - dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) + dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j15++ + j17++ } - dAtA16[j15] = uint8(num) - j15++ + dAtA18[j17] = uint8(num) + j17++ } - i -= j15 - copy(dAtA[i:], dAtA16[:j15]) - i = encodeVarintLend(dAtA, i, uint64(j15)) + i -= j17 + copy(dAtA[i:], dAtA18[:j17]) + i = encodeVarintLend(dAtA, i, uint64(j17)) i-- dAtA[i] = 0x12 } @@ -2351,20 +2423,20 @@ func (m *LendIdToBorrowIdMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if len(m.BorrowingID) > 0 { - dAtA18 := make([]byte, len(m.BorrowingID)*10) - var j17 int + dAtA20 := make([]byte, len(m.BorrowingID)*10) + var j19 int for _, num := range m.BorrowingID { for num >= 1<<7 { - dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j17++ + j19++ } - dAtA18[j17] = uint8(num) - j17++ + dAtA20[j19] = uint8(num) + j19++ } - i -= j17 - copy(dAtA[i:], dAtA18[:j17]) - i = encodeVarintLend(dAtA, i, uint64(j17)) + i -= j19 + copy(dAtA[i:], dAtA20[:j19]) + i = encodeVarintLend(dAtA, i, uint64(j19)) i-- dAtA[i] = 0x12 } @@ -2663,20 +2735,20 @@ func (m *LendMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.LendIDs) > 0 { - dAtA20 := make([]byte, len(m.LendIDs)*10) - var j19 int + dAtA22 := make([]byte, len(m.LendIDs)*10) + var j21 int for _, num := range m.LendIDs { for num >= 1<<7 { - dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) + dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j19++ + j21++ } - dAtA20[j19] = uint8(num) - j19++ + dAtA22[j21] = uint8(num) + j21++ } - i -= j19 - copy(dAtA[i:], dAtA20[:j19]) - i = encodeVarintLend(dAtA, i, uint64(j19)) + i -= j21 + copy(dAtA[i:], dAtA22[:j21]) + i = encodeVarintLend(dAtA, i, uint64(j21)) i-- dAtA[i] = 0xa } @@ -2704,20 +2776,20 @@ func (m *BorrowMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.BorrowIDs) > 0 { - dAtA22 := make([]byte, len(m.BorrowIDs)*10) - var j21 int + dAtA24 := make([]byte, len(m.BorrowIDs)*10) + var j23 int for _, num := range m.BorrowIDs { for num >= 1<<7 { - dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) + dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j21++ + j23++ } - dAtA22[j21] = uint8(num) - j21++ + dAtA24[j23] = uint8(num) + j23++ } - i -= j21 - copy(dAtA[i:], dAtA22[:j21]) - i = encodeVarintLend(dAtA, i, uint64(j21)) + i -= j23 + copy(dAtA[i:], dAtA24[:j23]) + i = encodeVarintLend(dAtA, i, uint64(j23)) i-- dAtA[i] = 0xa } @@ -2745,20 +2817,20 @@ func (m *StableBorrowMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.StableBorrowIDs) > 0 { - dAtA24 := make([]byte, len(m.StableBorrowIDs)*10) - var j23 int + dAtA26 := make([]byte, len(m.StableBorrowIDs)*10) + var j25 int for _, num := range m.StableBorrowIDs { for num >= 1<<7 { - dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80) + dAtA26[j25] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j23++ + j25++ } - dAtA24[j23] = uint8(num) - j23++ + dAtA26[j25] = uint8(num) + j25++ } - i -= j23 - copy(dAtA[i:], dAtA24[:j23]) - i = encodeVarintLend(dAtA, i, uint64(j23)) + i -= j25 + copy(dAtA[i:], dAtA26[:j25]) + i = encodeVarintLend(dAtA, i, uint64(j25)) i-- dAtA[i] = 0xa } @@ -3155,6 +3227,10 @@ func (m *LendAsset) Size() (n int) { if m.AppID != 0 { n += 1 + sovLend(uint64(m.AppID)) } + l = m.GlobalIndex.Size() + n += 1 + l + sovLend(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime) + n += 1 + l + sovLend(uint64(l)) l = len(m.CPoolName) if l > 0 { n += 1 + l + sovLend(uint64(l)) @@ -3194,6 +3270,12 @@ func (m *BorrowAsset) Size() (n int) { n += 1 + l + sovLend(uint64(l)) l = m.Interest_Accumulated.Size() n += 1 + l + sovLend(uint64(l)) + l = m.GlobalIndex.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.ReserveGlobalIndex.Size() + n += 1 + l + sovLend(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime) + n += 1 + l + sovLend(uint64(l)) l = len(m.CPoolName) if l > 0 { n += 1 + l + sovLend(uint64(l)) @@ -3972,6 +4054,73 @@ func (m *LendAsset) Unmarshal(dAtA []byte) error { } } case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GlobalIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + 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 ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInteractionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LastInteractionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CPoolName", wireType) } @@ -4365,6 +4514,107 @@ func (m *BorrowAsset) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GlobalIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + 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 ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReserveGlobalIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + 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 ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ReserveGlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInteractionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LastInteractionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CPoolName", wireType) } diff --git a/x/lend/types/params.go b/x/lend/types/params.go index eeb32730b..c202be269 100644 --- a/x/lend/types/params.go +++ b/x/lend/types/params.go @@ -9,20 +9,23 @@ import ( var _ paramtypes.ParamSet = (*Params)(nil) const ( - LendGas = sdk.Gas(32763) - WithdrawGas = sdk.Gas(22763) - DepositGas = sdk.Gas(22763) - CloseLendGas = sdk.Gas(22763) - BorrowAssetGas = sdk.Gas(22763) - DrawAssetGas = sdk.Gas(22763) - RepayAssetGas = sdk.Gas(22763) - DepositBorrowAssetGas = sdk.Gas(22763) - CloseBorrowAssetGas = sdk.Gas(22763) - BorrowAssetAlternateGas = sdk.Gas(22763) + LendGas = sdk.Gas(32763) + WithdrawGas = sdk.Gas(22763) + DepositGas = sdk.Gas(22763) + CloseLendGas = sdk.Gas(22763) + BorrowAssetGas = sdk.Gas(22763) + DrawAssetGas = sdk.Gas(22763) + RepayAssetGas = sdk.Gas(22763) + DepositBorrowAssetGas = sdk.Gas(22763) + CloseBorrowAssetGas = sdk.Gas(22763) + BorrowAssetAlternateGas = sdk.Gas(22763) + CalculateBorrowInterestGas = sdk.Gas(22763) + CalculateLendRewardGas = sdk.Gas(22763) ) const ( AppName = "commodo" + AppID = uint64(3) Uint64Zero = uint64(0) Uint64Two = uint64(2) Perc1 = string("0.2") diff --git a/x/lend/types/tx.go b/x/lend/types/tx.go index e041832e6..e347e5fdc 100644 --- a/x/lend/types/tx.go +++ b/x/lend/types/tx.go @@ -349,7 +349,7 @@ func NewMsgDepositBorrow(borrower string, borrowID uint64, amount sdk.Coin) *Msg } func (msg MsgDepositBorrow) Route() string { return ModuleName } -func (msg MsgDepositBorrow) Type() string { return TypeDepositBorrowdAssetRequest } +func (msg MsgDepositBorrow) Type() string { return TypeDepositBorrowAssetRequest } func (msg *MsgDepositBorrow) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.GetBorrower()) @@ -473,3 +473,75 @@ func (msg *MsgBorrowAlternate) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } + +func NewMsgCalculateBorrowInterest(borrower string, borrowID uint64) *MsgCalculateBorrowInterest { + return &MsgCalculateBorrowInterest{ + Borrower: borrower, + BorrowId: borrowID, + } +} + +func (msg MsgCalculateBorrowInterest) Route() string { return ModuleName } +func (msg MsgCalculateBorrowInterest) Type() string { return TypeCalculateBorrowInterestRequest } + +func (msg *MsgCalculateBorrowInterest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.GetBorrower()) + if err != nil { + return err + } + + if msg.BorrowId <= 0 { + return fmt.Errorf("borrow id should be positive: %d > 0", msg.BorrowId) + } + return nil +} + +func (msg *MsgCalculateBorrowInterest) GetSigners() []sdk.AccAddress { + lender, err := sdk.AccAddressFromBech32(msg.GetBorrower()) + if err != nil { + panic(err) + } + return []sdk.AccAddress{lender} +} + +// GetSignBytes get the bytes for the message signer to sign on. +func (msg *MsgCalculateBorrowInterest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func NewMsgCalculateLendRewards(lender string, lendID uint64) *MsgCalculateLendRewards { + return &MsgCalculateLendRewards{ + Lender: lender, + LendId: lendID, + } +} + +func (msg MsgCalculateLendRewards) Route() string { return ModuleName } +func (msg MsgCalculateLendRewards) Type() string { return TypeCalculateLendRewardsRequest } + +func (msg *MsgCalculateLendRewards) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.GetLender()) + if err != nil { + return err + } + + if msg.LendId <= 0 { + return fmt.Errorf("lend id should be positive: %d > 0", msg.LendId) + } + return nil +} + +func (msg *MsgCalculateLendRewards) GetSigners() []sdk.AccAddress { + lender, err := sdk.AccAddressFromBech32(msg.GetLender()) + if err != nil { + panic(err) + } + return []sdk.AccAddress{lender} +} + +// GetSignBytes get the bytes for the message signer to sign on. +func (msg *MsgCalculateLendRewards) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} diff --git a/x/lend/types/tx.pb.go b/x/lend/types/tx.pb.go index 07c0b01d1..326a5b6ee 100644 --- a/x/lend/types/tx.pb.go +++ b/x/lend/types/tx.pb.go @@ -761,6 +761,110 @@ func (m *MsgFundModuleAccounts) GetAmount() types.Coin { return types.Coin{} } +type MsgCalculateBorrowInterest struct { + Borrower string `protobuf:"bytes,1,opt,name=borrower,proto3" json:"borrower,omitempty"` + BorrowId uint64 `protobuf:"varint,2,opt,name=borrow_id,json=borrowId,proto3" json:"borrow_id,omitempty"` +} + +func (m *MsgCalculateBorrowInterest) Reset() { *m = MsgCalculateBorrowInterest{} } +func (m *MsgCalculateBorrowInterest) String() string { return proto.CompactTextString(m) } +func (*MsgCalculateBorrowInterest) ProtoMessage() {} +func (*MsgCalculateBorrowInterest) Descriptor() ([]byte, []int) { + return fileDescriptor_957d64b59d60594d, []int{11} +} +func (m *MsgCalculateBorrowInterest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCalculateBorrowInterest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCalculateBorrowInterest.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 *MsgCalculateBorrowInterest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCalculateBorrowInterest.Merge(m, src) +} +func (m *MsgCalculateBorrowInterest) XXX_Size() int { + return m.Size() +} +func (m *MsgCalculateBorrowInterest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCalculateBorrowInterest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCalculateBorrowInterest proto.InternalMessageInfo + +func (m *MsgCalculateBorrowInterest) GetBorrower() string { + if m != nil { + return m.Borrower + } + return "" +} + +func (m *MsgCalculateBorrowInterest) GetBorrowId() uint64 { + if m != nil { + return m.BorrowId + } + return 0 +} + +type MsgCalculateLendRewards struct { + Lender string `protobuf:"bytes,1,opt,name=lender,proto3" json:"lender,omitempty"` + LendId uint64 `protobuf:"varint,2,opt,name=lend_id,json=lendId,proto3" json:"lend_id,omitempty"` +} + +func (m *MsgCalculateLendRewards) Reset() { *m = MsgCalculateLendRewards{} } +func (m *MsgCalculateLendRewards) String() string { return proto.CompactTextString(m) } +func (*MsgCalculateLendRewards) ProtoMessage() {} +func (*MsgCalculateLendRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_957d64b59d60594d, []int{12} +} +func (m *MsgCalculateLendRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCalculateLendRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCalculateLendRewards.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 *MsgCalculateLendRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCalculateLendRewards.Merge(m, src) +} +func (m *MsgCalculateLendRewards) XXX_Size() int { + return m.Size() +} +func (m *MsgCalculateLendRewards) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCalculateLendRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCalculateLendRewards proto.InternalMessageInfo + +func (m *MsgCalculateLendRewards) GetLender() string { + if m != nil { + return m.Lender + } + return "" +} + +func (m *MsgCalculateLendRewards) GetLendId() uint64 { + if m != nil { + return m.LendId + } + return 0 +} + type MsgLendResponse struct { } @@ -768,7 +872,7 @@ func (m *MsgLendResponse) Reset() { *m = MsgLendResponse{} } func (m *MsgLendResponse) String() string { return proto.CompactTextString(m) } func (*MsgLendResponse) ProtoMessage() {} func (*MsgLendResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{11} + return fileDescriptor_957d64b59d60594d, []int{13} } func (m *MsgLendResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -804,7 +908,7 @@ func (m *MsgWithdrawResponse) Reset() { *m = MsgWithdrawResponse{} } func (m *MsgWithdrawResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawResponse) ProtoMessage() {} func (*MsgWithdrawResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{12} + return fileDescriptor_957d64b59d60594d, []int{14} } func (m *MsgWithdrawResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -840,7 +944,7 @@ func (m *MsgDepositResponse) Reset() { *m = MsgDepositResponse{} } func (m *MsgDepositResponse) String() string { return proto.CompactTextString(m) } func (*MsgDepositResponse) ProtoMessage() {} func (*MsgDepositResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{13} + return fileDescriptor_957d64b59d60594d, []int{15} } func (m *MsgDepositResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -876,7 +980,7 @@ func (m *MsgCloseLendResponse) Reset() { *m = MsgCloseLendResponse{} } func (m *MsgCloseLendResponse) String() string { return proto.CompactTextString(m) } func (*MsgCloseLendResponse) ProtoMessage() {} func (*MsgCloseLendResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{14} + return fileDescriptor_957d64b59d60594d, []int{16} } func (m *MsgCloseLendResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -912,7 +1016,7 @@ func (m *MsgBorrowResponse) Reset() { *m = MsgBorrowResponse{} } func (m *MsgBorrowResponse) String() string { return proto.CompactTextString(m) } func (*MsgBorrowResponse) ProtoMessage() {} func (*MsgBorrowResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{15} + return fileDescriptor_957d64b59d60594d, []int{17} } func (m *MsgBorrowResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -948,7 +1052,7 @@ func (m *MsgRepayResponse) Reset() { *m = MsgRepayResponse{} } func (m *MsgRepayResponse) String() string { return proto.CompactTextString(m) } func (*MsgRepayResponse) ProtoMessage() {} func (*MsgRepayResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{16} + return fileDescriptor_957d64b59d60594d, []int{18} } func (m *MsgRepayResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -984,7 +1088,7 @@ func (m *MsgDepositBorrowResponse) Reset() { *m = MsgDepositBorrowRespon func (m *MsgDepositBorrowResponse) String() string { return proto.CompactTextString(m) } func (*MsgDepositBorrowResponse) ProtoMessage() {} func (*MsgDepositBorrowResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{17} + return fileDescriptor_957d64b59d60594d, []int{19} } func (m *MsgDepositBorrowResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1020,7 +1124,7 @@ func (m *MsgDrawResponse) Reset() { *m = MsgDrawResponse{} } func (m *MsgDrawResponse) String() string { return proto.CompactTextString(m) } func (*MsgDrawResponse) ProtoMessage() {} func (*MsgDrawResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{18} + return fileDescriptor_957d64b59d60594d, []int{20} } func (m *MsgDrawResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1056,7 +1160,7 @@ func (m *MsgCloseBorrowResponse) Reset() { *m = MsgCloseBorrowResponse{} func (m *MsgCloseBorrowResponse) String() string { return proto.CompactTextString(m) } func (*MsgCloseBorrowResponse) ProtoMessage() {} func (*MsgCloseBorrowResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{19} + return fileDescriptor_957d64b59d60594d, []int{21} } func (m *MsgCloseBorrowResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1092,7 +1196,7 @@ func (m *MsgBorrowAlternateResponse) Reset() { *m = MsgBorrowAlternateRe func (m *MsgBorrowAlternateResponse) String() string { return proto.CompactTextString(m) } func (*MsgBorrowAlternateResponse) ProtoMessage() {} func (*MsgBorrowAlternateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{20} + return fileDescriptor_957d64b59d60594d, []int{22} } func (m *MsgBorrowAlternateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1128,7 +1232,7 @@ func (m *MsgFundModuleAccountsResponse) Reset() { *m = MsgFundModuleAcco func (m *MsgFundModuleAccountsResponse) String() string { return proto.CompactTextString(m) } func (*MsgFundModuleAccountsResponse) ProtoMessage() {} func (*MsgFundModuleAccountsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_957d64b59d60594d, []int{21} + return fileDescriptor_957d64b59d60594d, []int{23} } func (m *MsgFundModuleAccountsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1157,6 +1261,78 @@ func (m *MsgFundModuleAccountsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgFundModuleAccountsResponse proto.InternalMessageInfo +type MsgCalculateBorrowInterestResponse struct { +} + +func (m *MsgCalculateBorrowInterestResponse) Reset() { *m = MsgCalculateBorrowInterestResponse{} } +func (m *MsgCalculateBorrowInterestResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCalculateBorrowInterestResponse) ProtoMessage() {} +func (*MsgCalculateBorrowInterestResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_957d64b59d60594d, []int{24} +} +func (m *MsgCalculateBorrowInterestResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCalculateBorrowInterestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCalculateBorrowInterestResponse.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 *MsgCalculateBorrowInterestResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCalculateBorrowInterestResponse.Merge(m, src) +} +func (m *MsgCalculateBorrowInterestResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCalculateBorrowInterestResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCalculateBorrowInterestResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCalculateBorrowInterestResponse proto.InternalMessageInfo + +type MsgCalculateLendRewardsResponse struct { +} + +func (m *MsgCalculateLendRewardsResponse) Reset() { *m = MsgCalculateLendRewardsResponse{} } +func (m *MsgCalculateLendRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCalculateLendRewardsResponse) ProtoMessage() {} +func (*MsgCalculateLendRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_957d64b59d60594d, []int{25} +} +func (m *MsgCalculateLendRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCalculateLendRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCalculateLendRewardsResponse.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 *MsgCalculateLendRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCalculateLendRewardsResponse.Merge(m, src) +} +func (m *MsgCalculateLendRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCalculateLendRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCalculateLendRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCalculateLendRewardsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgLend)(nil), "comdex.lend.v1beta1.MsgLend") proto.RegisterType((*MsgWithdraw)(nil), "comdex.lend.v1beta1.MsgWithdraw") @@ -1169,6 +1345,8 @@ func init() { proto.RegisterType((*MsgCloseBorrow)(nil), "comdex.lend.v1beta1.MsgCloseBorrow") proto.RegisterType((*MsgBorrowAlternate)(nil), "comdex.lend.v1beta1.MsgBorrowAlternate") proto.RegisterType((*MsgFundModuleAccounts)(nil), "comdex.lend.v1beta1.MsgFundModuleAccounts") + proto.RegisterType((*MsgCalculateBorrowInterest)(nil), "comdex.lend.v1beta1.MsgCalculateBorrowInterest") + proto.RegisterType((*MsgCalculateLendRewards)(nil), "comdex.lend.v1beta1.MsgCalculateLendRewards") proto.RegisterType((*MsgLendResponse)(nil), "comdex.lend.v1beta1.MsgLendResponse") proto.RegisterType((*MsgWithdrawResponse)(nil), "comdex.lend.v1beta1.MsgWithdrawResponse") proto.RegisterType((*MsgDepositResponse)(nil), "comdex.lend.v1beta1.MsgDepositResponse") @@ -1180,67 +1358,74 @@ func init() { proto.RegisterType((*MsgCloseBorrowResponse)(nil), "comdex.lend.v1beta1.MsgCloseBorrowResponse") proto.RegisterType((*MsgBorrowAlternateResponse)(nil), "comdex.lend.v1beta1.MsgBorrowAlternateResponse") proto.RegisterType((*MsgFundModuleAccountsResponse)(nil), "comdex.lend.v1beta1.MsgFundModuleAccountsResponse") + proto.RegisterType((*MsgCalculateBorrowInterestResponse)(nil), "comdex.lend.v1beta1.MsgCalculateBorrowInterestResponse") + proto.RegisterType((*MsgCalculateLendRewardsResponse)(nil), "comdex.lend.v1beta1.MsgCalculateLendRewardsResponse") } func init() { proto.RegisterFile("comdex/lend/v1beta1/tx.proto", fileDescriptor_957d64b59d60594d) } var fileDescriptor_957d64b59d60594d = []byte{ - // 874 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcd, 0x6e, 0xe3, 0x54, - 0x14, 0x8e, 0x9b, 0xc4, 0x49, 0x4e, 0xa1, 0x3f, 0xb7, 0x7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0xad, 0x49, 0x2f, 0x28, 0xcb, 0x93, 0x99, 0xf3, 0x80, - 0xbf, 0xf6, 0x82, 0xea, 0xbf, 0x50, 0x34, 0xa8, 0xdd, 0xc0, 0x9e, 0x79, 0x39, 0xb2, 0x02, 0x9f, - 0x40, 0x29, 0xfa, 0xee, 0xd7, 0x80, 0x83, 0x8f, 0x69, 0xe1, 0xff, 0x12, 0xcc, 0xf5, 0xb9, 0x33, - 0x41, 0x23, 0x3e, 0x4c, 0x1a, 0xff, 0xb0, 0x09, 0x3f, 0x0c, 0xc7, 0xe6, 0xe9, 0x83, 0xd7, 0x61, - 0x26, 0xa6, 0xf1, 0x23, 0x0b, 0x50, 0x7d, 0x39, 0x05, 0x48, 0x10, 0x7a, 0xaf, 0x13, 0x60, 0xdf, - 0x35, 0x03, 0xfc, 0x3e, 0x5b, 0x2b, 0xb1, 0x7c, 0xb2, 0x03, 0xcb, 0x67, 0x80, 0xad, 0xb9, 0x87, - 0xb2, 0x35, 0x31, 0x2e, 0xf9, 0xb1, 0xe3, 0x22, 0x0f, 0x1d, 0x97, 0x41, 0xc2, 0x17, 0x1e, 0x4a, - 0xf8, 0xc4, 0xf6, 0x2c, 0x26, 0xb7, 0xe7, 0x73, 0x09, 0x96, 0x0c, 0x6a, 0xff, 0xd8, 0x73, 0x2d, - 0x83, 0x58, 0xbd, 0x0e, 0xde, 0x6b, 0xb7, 0x43, 0x13, 0x8a, 0x54, 0x80, 0x2e, 0x93, 0xfc, 0x62, - 0x76, 0x31, 0xaf, 0x60, 0x42, 0x82, 0xca, 0x10, 0x57, 0xed, 0x6e, 0x11, 0xfb, 0x75, 0xcf, 0x0e, - 0xd4, 0xbd, 0x4f, 0x95, 0xdc, 0xc3, 0xa8, 0x32, 0x0f, 0xb3, 0xfc, 0x12, 0x35, 0x30, 0xf5, 0x88, - 0x4b, 0x71, 0x75, 0x09, 0x16, 0x12, 0x5b, 0x5f, 0x88, 0x17, 0x19, 0x11, 0xf8, 0x5c, 0x09, 0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0xb9, 0xe0, 0x3f, 0x1b, 0xd9, 0x0d, 0x9e, 0xee, 0xd7, 0x13, 0x28, - 0x89, 0x00, 0x7f, 0xc3, 0xec, 0xdd, 0xad, 0xbf, 0x35, 0xba, 0x3b, 0x42, 0x51, 0xd1, 0x27, 0x54, - 0x14, 0xc1, 0x02, 0x40, 0x43, 0xf6, 0xe4, 0x57, 0x69, 0x6e, 0xee, 0xeb, 0x2a, 0xbb, 0x93, 0xeb, - 0xc6, 0x51, 0xf7, 0x7f, 0xba, 0xba, 0x51, 0xa5, 0xeb, 0x1b, 0x55, 0x7a, 0x73, 0xa3, 0x4a, 0xcf, - 0x6e, 0xd5, 0xcc, 0xf5, 0xad, 0x9a, 0x79, 0x75, 0xab, 0x66, 0xfe, 0xd2, 0x6c, 0x27, 0x38, 0xed, - 0xb5, 0x42, 0x9f, 0x7a, 0xe4, 0x77, 0x9b, 0x9c, 0x9c, 0x38, 0x6d, 0xc7, 0xec, 0xf0, 0xb7, 0xce, - 0x7f, 0x27, 0x04, 0x97, 0x1e, 0xa6, 0x2d, 0x99, 0xfd, 0x63, 0xff, 0xcd, 0xbb, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xec, 0x21, 0x66, 0xbe, 0x43, 0x0c, 0x00, 0x00, + // 960 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xce, 0xc6, 0x8e, 0x7f, 0x4e, 0xa0, 0x3f, 0x93, 0x3f, 0x77, 0x49, 0x37, 0xa9, 0x69, 0xa9, + 0xf9, 0xe9, 0x5a, 0x0d, 0x48, 0xbd, 0x41, 0xa0, 0xa6, 0x11, 0xc2, 0x11, 0x0b, 0xc8, 0x15, 0x20, + 0xb8, 0xb1, 0xc6, 0xde, 0xe9, 0x76, 0xc5, 0x7a, 0x67, 0xb5, 0x33, 0x6e, 0x5a, 0xe0, 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 0x2c, 0x04, 0xd3, 0x61, 0x8e, 0xa1, 0x28, 0xb7, 0x9f, 0x91, 0x5b, 0x42, + 0x6b, 0xe6, 0x56, 0xfe, 0x45, 0xa1, 0x0e, 0xac, 0xe7, 0x97, 0xd9, 0x9b, 0x33, 0xbb, 0xa1, 0xd2, + 0x7d, 0x77, 0x01, 0x90, 0x0e, 0xf0, 0x3d, 0x5c, 0x9e, 0xdc, 0x70, 0xb7, 0x67, 0x77, 0x47, 0x03, + 0xed, 0xe6, 0x82, 0x40, 0x1d, 0x8c, 0x03, 0x9a, 0xb2, 0x13, 0xde, 0x31, 0xb9, 0xf9, 0x3f, 0xd6, + 0x3e, 0x58, 0x1c, 0xab, 0xa3, 0xfe, 0x62, 0xc1, 0x8e, 0x69, 0xcc, 0x1b, 0x7f, 0x82, 0xc1, 0xc0, + 0xbe, 0xb7, 0xa4, 0x81, 0xce, 0xe2, 0x07, 0xd8, 0x9c, 0xba, 0x14, 0xde, 0x9b, 0xeb, 0x30, 0x87, + 0xb6, 0x3f, 0x58, 0x06, 0x3d, 0x8c, 0x7d, 0xf8, 0xe9, 0xf3, 0x53, 0xc7, 0x7a, 0x71, 0xea, 0x58, + 0xff, 0x9c, 0x3a, 0xd6, 0x6f, 0x67, 0xce, 0xca, 0x8b, 0x33, 0x67, 0xe5, 0xaf, 0x33, 0x67, 0xe5, + 0x3b, 0x37, 0x08, 0xf9, 0xe3, 0x41, 0x57, 0x78, 0x6d, 0x66, 0x9e, 0xef, 0xd0, 0x47, 0x8f, 0xc2, + 0x5e, 0x88, 0x23, 0x75, 0x6f, 0xaa, 0x7f, 0x85, 0xfc, 0x59, 0x42, 0x58, 0xb7, 0x24, 0xff, 0xc6, + 0xbd, 0xff, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x33, 0x52, 0x38, 0x31, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1272,6 +1457,8 @@ type MsgClient interface { BorrowAlternate(ctx context.Context, in *MsgBorrowAlternate, opts ...grpc.CallOption) (*MsgBorrowAlternateResponse, error) // FundModuleAccounts funds an existing module account FundModuleAccounts(ctx context.Context, in *MsgFundModuleAccounts, opts ...grpc.CallOption) (*MsgFundModuleAccountsResponse, error) + CalculateBorrowInterest(ctx context.Context, in *MsgCalculateBorrowInterest, opts ...grpc.CallOption) (*MsgCalculateBorrowInterestResponse, error) + CalculateLendRewards(ctx context.Context, in *MsgCalculateLendRewards, opts ...grpc.CallOption) (*MsgCalculateLendRewardsResponse, error) } type msgClient struct { @@ -1381,6 +1568,24 @@ func (c *msgClient) FundModuleAccounts(ctx context.Context, in *MsgFundModuleAcc return out, nil } +func (c *msgClient) CalculateBorrowInterest(ctx context.Context, in *MsgCalculateBorrowInterest, opts ...grpc.CallOption) (*MsgCalculateBorrowInterestResponse, error) { + out := new(MsgCalculateBorrowInterestResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Msg/CalculateBorrowInterest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CalculateLendRewards(ctx context.Context, in *MsgCalculateLendRewards, opts ...grpc.CallOption) (*MsgCalculateLendRewardsResponse, error) { + out := new(MsgCalculateLendRewardsResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Msg/CalculateLendRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // LendAsset defines a method for lending coins to the ModuleAccount. @@ -1400,6 +1605,8 @@ type MsgServer interface { BorrowAlternate(context.Context, *MsgBorrowAlternate) (*MsgBorrowAlternateResponse, error) // FundModuleAccounts funds an existing module account FundModuleAccounts(context.Context, *MsgFundModuleAccounts) (*MsgFundModuleAccountsResponse, error) + CalculateBorrowInterest(context.Context, *MsgCalculateBorrowInterest) (*MsgCalculateBorrowInterestResponse, error) + CalculateLendRewards(context.Context, *MsgCalculateLendRewards) (*MsgCalculateLendRewardsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1439,6 +1646,12 @@ func (*UnimplementedMsgServer) BorrowAlternate(ctx context.Context, req *MsgBorr func (*UnimplementedMsgServer) FundModuleAccounts(ctx context.Context, req *MsgFundModuleAccounts) (*MsgFundModuleAccountsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FundModuleAccounts not implemented") } +func (*UnimplementedMsgServer) CalculateBorrowInterest(ctx context.Context, req *MsgCalculateBorrowInterest) (*MsgCalculateBorrowInterestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CalculateBorrowInterest not implemented") +} +func (*UnimplementedMsgServer) CalculateLendRewards(ctx context.Context, req *MsgCalculateLendRewards) (*MsgCalculateLendRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CalculateLendRewards not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1642,6 +1855,42 @@ func _Msg_FundModuleAccounts_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_CalculateBorrowInterest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCalculateBorrowInterest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CalculateBorrowInterest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.lend.v1beta1.Msg/CalculateBorrowInterest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CalculateBorrowInterest(ctx, req.(*MsgCalculateBorrowInterest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CalculateLendRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCalculateLendRewards) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CalculateLendRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.lend.v1beta1.Msg/CalculateLendRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CalculateLendRewards(ctx, req.(*MsgCalculateLendRewards)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "comdex.lend.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -1690,6 +1939,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "FundModuleAccounts", Handler: _Msg_FundModuleAccounts_Handler, }, + { + MethodName: "CalculateBorrowInterest", + Handler: _Msg_CalculateBorrowInterest_Handler, + }, + { + MethodName: "CalculateLendRewards", + Handler: _Msg_CalculateLendRewards_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "comdex/lend/v1beta1/tx.proto", @@ -2247,6 +2504,76 @@ func (m *MsgFundModuleAccounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgCalculateBorrowInterest) 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 *MsgCalculateBorrowInterest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCalculateBorrowInterest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BorrowId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.BorrowId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Borrower) > 0 { + i -= len(m.Borrower) + copy(dAtA[i:], m.Borrower) + i = encodeVarintTx(dAtA, i, uint64(len(m.Borrower))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCalculateLendRewards) 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 *MsgCalculateLendRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCalculateLendRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LendId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.LendId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Lender) > 0 { + i -= len(m.Lender) + copy(dAtA[i:], m.Lender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Lender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgLendResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2500,16 +2827,62 @@ func (m *MsgFundModuleAccountsResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgCalculateBorrowInterestResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil +} + +func (m *MsgCalculateBorrowInterestResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCalculateBorrowInterestResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCalculateLendRewardsResponse) 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 *MsgCalculateLendRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCalculateLendRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base } func (m *MsgLend) Size() (n int) { if m == nil { @@ -2737,6 +3110,38 @@ func (m *MsgFundModuleAccounts) Size() (n int) { return n } +func (m *MsgCalculateBorrowInterest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Borrower) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.BorrowId != 0 { + n += 1 + sovTx(uint64(m.BorrowId)) + } + return n +} + +func (m *MsgCalculateLendRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Lender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.LendId != 0 { + n += 1 + sovTx(uint64(m.LendId)) + } + return n +} + func (m *MsgLendResponse) Size() (n int) { if m == nil { return 0 @@ -2836,6 +3241,24 @@ func (m *MsgFundModuleAccountsResponse) Size() (n int) { return n } +func (m *MsgCalculateBorrowInterestResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCalculateLendRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4502,6 +4925,208 @@ func (m *MsgFundModuleAccounts) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCalculateBorrowInterest) 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 ErrIntOverflowTx + } + 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: MsgCalculateBorrowInterest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCalculateBorrowInterest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Borrower", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Borrower = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BorrowId", wireType) + } + m.BorrowId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BorrowId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCalculateLendRewards) 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 ErrIntOverflowTx + } + 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: MsgCalculateLendRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCalculateLendRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Lender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Lender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LendId", wireType) + } + m.LendId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LendId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgLendResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -5052,6 +5677,106 @@ func (m *MsgFundModuleAccountsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCalculateBorrowInterestResponse) 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 ErrIntOverflowTx + } + 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: MsgCalculateBorrowInterestResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCalculateBorrowInterestResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCalculateLendRewardsResponse) 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 ErrIntOverflowTx + } + 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: MsgCalculateLendRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCalculateLendRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/lend/types/tx_test.go b/x/lend/types/tx_test.go index 1ab98ba9c..241a45b92 100644 --- a/x/lend/types/tx_test.go +++ b/x/lend/types/tx_test.go @@ -550,7 +550,7 @@ func TestNewMsgDepositBorrow(t *testing.T) { t.Run(tc.name, func(t *testing.T) { require.Equal(t, tc.msg.Route(), types.RouterKey) - require.Equal(t, tc.msg.Type(), types.TypeDepositBorrowdAssetRequest) + require.Equal(t, tc.msg.Type(), types.TypeDepositBorrowAssetRequest) err := tc.msg.ValidateBasic() diff --git a/x/liquidation/keeper/keeper.go b/x/liquidation/keeper/keeper.go index 2caecdb37..c978c10c9 100644 --- a/x/liquidation/keeper/keeper.go +++ b/x/liquidation/keeper/keeper.go @@ -78,7 +78,7 @@ func (k Keeper) Store(ctx sdk.Context) sdk.KVStore { //Wasm tx and query binding functions func (k Keeper) WasmWhitelistAppIDLiquidation(ctx sdk.Context, appID uint64) error { - _, found := k.GetAppIdByAppForLiquidation(ctx, appID) + _, found := k.GetAppIDByAppForLiquidation(ctx, appID) if found { return types.ErrAppIDDoesNotExists } @@ -88,7 +88,7 @@ func (k Keeper) WasmWhitelistAppIDLiquidation(ctx sdk.Context, appID uint64) err } func (k Keeper) WasmWhitelistAppIDLiquidationQuery(ctx sdk.Context, appID uint64) (bool, string) { - _, found := k.GetAppIdByAppForLiquidation(ctx, appID) + _, found := k.GetAppIDByAppForLiquidation(ctx, appID) if found { return false, types.ErrAppIDExists.Error() } @@ -96,17 +96,17 @@ func (k Keeper) WasmWhitelistAppIDLiquidationQuery(ctx sdk.Context, appID uint64 } func (k Keeper) WasmRemoveWhitelistAppIDLiquidation(ctx sdk.Context, appID uint64) error { - _, found := k.GetAppIdByAppForLiquidation(ctx, appID) + _, found := k.GetAppIDByAppForLiquidation(ctx, appID) if !found { return types.ErrAppIDDoesNotExists } - k.DeleteAppId(ctx, appID) + k.DeleteAppID(ctx, appID) return nil } func (k Keeper) WasmRemoveWhitelistAppIDLiquidationQuery(ctx sdk.Context, appID uint64) (bool, string) { - _, found := k.GetAppIdByAppForLiquidation(ctx, appID) + _, found := k.GetAppIDByAppForLiquidation(ctx, appID) if !found { return false, types.ErrAppIDDoesNotExists.Error() } diff --git a/x/liquidation/keeper/liquidate_borrow.go b/x/liquidation/keeper/liquidate_borrow.go index 7da23d6ad..41c82b44a 100644 --- a/x/liquidation/keeper/liquidate_borrow.go +++ b/x/liquidation/keeper/liquidate_borrow.go @@ -8,17 +8,34 @@ import ( ) func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { - borrowIds, found := k.GetBorrows(ctx) + borrows, found := k.GetBorrows(ctx) + params := k.GetParams(ctx) if !found { return nil } - for _, v := range borrowIds.BorrowIDs { - borrowPos, found := k.GetBorrow(ctx, v) + liquidationOffsetHolder, found := k.GetLiquidationOffsetHolder(ctx, lendtypes.AppID, types.VaultLiquidationsOffsetPrefix) + if !found { + liquidationOffsetHolder = types.NewLiquidationOffsetHolder(lendtypes.AppID, 0) + } + borrowIDs := borrows.BorrowIDs + start, end := types.GetSliceStartEndForLiquidations(len(borrowIDs), int(liquidationOffsetHolder.CurrentOffset), int(params.LiquidationBatchSize)) + + if start == end { + liquidationOffsetHolder.CurrentOffset = 0 + start, end = types.GetSliceStartEndForLiquidations(len(borrowIDs), int(liquidationOffsetHolder.CurrentOffset), int(params.LiquidationBatchSize)) + } + newBorrowIDs := borrowIDs[start:end] + for l := range newBorrowIDs { + borrowPos, found := k.GetBorrow(ctx, newBorrowIDs[l]) if !found { continue } lendPair, _ := k.GetLendPair(ctx, borrowPos.PairID) lendPos, _ := k.GetLend(ctx, borrowPos.LendingID) + killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + if killSwitchParams.BreakerEnable { + continue + } pool, _ := k.GetPool(ctx, lendPos.PoolID) assetIn, _ := k.GetAsset(ctx, lendPair.AssetIn) assetOut, _ := k.GetAsset(ctx, lendPair.AssetOut) @@ -36,16 +53,16 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { continue } k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) - k.DeleteBorrow(ctx, v) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, v, false) + k.DeleteBorrow(ctx, borrowIDs[l]) + err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowIDs[l], false) if err != nil { continue } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, v, lendPair.AssetOutPoolID, false) + err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowIDs[l], lendPair.AssetOutPoolID, false) if err != nil { continue } - err = k.UpdateBorrowIdsMapping(ctx, v, false) + err = k.UpdateBorrowIdsMapping(ctx, borrowIDs[l], false) if err != nil { continue } @@ -61,16 +78,16 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { continue } k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) - k.DeleteBorrow(ctx, v) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, v, false) + k.DeleteBorrow(ctx, borrowIDs[l]) + err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowIDs[l], false) if err != nil { continue } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, v, lendPair.AssetOutPoolID, false) + err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowIDs[l], lendPair.AssetOutPoolID, false) if err != nil { continue } - err = k.UpdateBorrowIdsMapping(ctx, v, false) + err = k.UpdateBorrowIdsMapping(ctx, borrowIDs[l], false) if err != nil { continue } @@ -85,16 +102,16 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { continue } k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) - k.DeleteBorrow(ctx, v) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, v, false) + k.DeleteBorrow(ctx, borrowIDs[l]) + err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowIDs[l], false) if err != nil { continue } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, v, lendPair.AssetOutPoolID, false) + err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowIDs[l], lendPair.AssetOutPoolID, false) if err != nil { continue } - err = k.UpdateBorrowIdsMapping(ctx, v, false) + err = k.UpdateBorrowIdsMapping(ctx, borrowIDs[l], false) if err != nil { continue } @@ -108,6 +125,8 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { return nil } } + liquidationOffsetHolder.CurrentOffset = uint64(end) + k.SetLiquidationOffsetHolder(ctx, types.VaultLiquidationsOffsetPrefix, liquidationOffsetHolder) return nil } diff --git a/x/liquidation/keeper/liquidate_vaults.go b/x/liquidation/keeper/liquidate_vaults.go index ca0789713..363063902 100644 --- a/x/liquidation/keeper/liquidate_vaults.go +++ b/x/liquidation/keeper/liquidate_vaults.go @@ -338,7 +338,7 @@ func (k Keeper) SetAppIDForLiquidation(ctx sdk.Context, appID uint64) { store.Set(key, value) } -func (k Keeper) GetAppIdByAppForLiquidation(ctx sdk.Context, appID uint64) (uint64, bool) { +func (k Keeper) GetAppIDByAppForLiquidation(ctx sdk.Context, appID uint64) (uint64, bool) { var ( store = k.Store(ctx) key = types.WhitelistAppKeyByApp(appID) @@ -377,7 +377,7 @@ func (k Keeper) GetAppIdsForLiquidation(ctx sdk.Context) (appIds []uint64) { return appIds } -func (k Keeper) DeleteAppId(ctx sdk.Context, appID uint64) { +func (k Keeper) DeleteAppID(ctx sdk.Context, appID uint64) { var ( store = k.Store(ctx) key = types.WhitelistAppKeyByApp(appID) diff --git a/x/liquidity/keeper/grpc_query.go b/x/liquidity/keeper/grpc_query.go index 2d5847e83..ac79dbf76 100644 --- a/x/liquidity/keeper/grpc_query.go +++ b/x/liquidity/keeper/grpc_query.go @@ -721,7 +721,7 @@ func (k Querier) PoolIncentives(c context.Context, req *types.QueryPoolsIncentiv if len(gauge.GetLiquidityMetaData().ChildPoolIds) == 0 { pools := k.GetAllPools(ctx, req.AppId) for _, pool := range pools { - if pool.Id != gauge.GetLiquidityMetaData().PoolId { + if pool.Id != gauge.GetLiquidityMetaData().PoolId && !pool.Disabled { childPoolIds = append(childPoolIds, pool.Id) } } diff --git a/x/liquidity/keeper/rewards.go b/x/liquidity/keeper/rewards.go index 0ab3e5b1a..baeddd142 100644 --- a/x/liquidity/keeper/rewards.go +++ b/x/liquidity/keeper/rewards.go @@ -177,7 +177,7 @@ func (k Keeper) GetFarmingRewardsData(ctx sdk.Context, appID uint64, coinsToDist if len(liquidityGaugeData.ChildPoolIds) == 0 { pools := k.GetAllPools(ctx, appID) for _, pool := range pools { - if pool.Id != liquidityGaugeData.PoolId { + if pool.Id != liquidityGaugeData.PoolId && !pool.Disabled { childPoolIds = append(childPoolIds, pool.Id) } } diff --git a/x/locker/keeper/locker.go b/x/locker/keeper/locker.go index f519a7edd..67fd9afff 100644 --- a/x/locker/keeper/locker.go +++ b/x/locker/keeper/locker.go @@ -232,11 +232,11 @@ func (k Keeper) GetAllLockerLookupTable(ctx sdk.Context) (lockerLookupTable []ty } // UpdateAmountLockerMapping For updating token locker mapping in lookup table. -func (k Keeper) UpdateAmountLockerMapping(ctx sdk.Context, appId uint64, assetID uint64, amount sdk.Int, changeType bool) { +func (k Keeper) UpdateAmountLockerMapping(ctx sdk.Context, appID uint64, assetID uint64, amount sdk.Int, changeType bool) { //if Change type true = Add to deposits //If change type false = Subtract from the deposits - lookupTableData, exists := k.GetLockerLookupTable(ctx, appId, assetID) + lookupTableData, exists := k.GetLockerLookupTable(ctx, appID, assetID) if exists { if changeType { @@ -536,8 +536,7 @@ func (k Keeper) AddWhiteListedAsset(c context.Context, msg *types.MsgAddWhiteLis lockerLookupData.AppId = appMapping.Id k.SetLockerLookupTable(ctx, lockerLookupData) return &types.MsgAddWhiteListedAssetResponse{}, nil - } else { - // Check if the asset from msg exists or not , - return nil, types.ErrorLockerProductAssetMappingExists } + // Check if the asset from msg exists or not , + return nil, types.ErrorLockerProductAssetMappingExists } diff --git a/x/market/keeper/oracle.go b/x/market/keeper/oracle.go index 083e6fdec..3a79cf6c3 100644 --- a/x/market/keeper/oracle.go +++ b/x/market/keeper/oracle.go @@ -179,5 +179,4 @@ func (k Keeper) GetPriceForAsset(ctx sdk.Context, id uint64) (uint64, bool) { } else { return 1000000, true } - } diff --git a/x/rewards/keeper/gauge.go b/x/rewards/keeper/gauge.go index 0cced9361..1f2a930dc 100644 --- a/x/rewards/keeper/gauge.go +++ b/x/rewards/keeper/gauge.go @@ -91,6 +91,9 @@ func (k Keeper) ValidateMsgCreateGaugeLiquidityMetaData(ctx sdk.Context, appID u childPoolIds := kind.LiquidityMetaData.ChildPoolIds for _, poolID := range childPoolIds { + if poolID == kind.LiquidityMetaData.PoolId { + return sdkerrors.Wrap(types.ErrSamePoolID, fmt.Sprintf("pool id : %d", poolID)) + } _, found := k.liquidityKeeper.GetPool(ctx, appID, poolID) if !found { return sdkerrors.Wrap(types.ErrInvalidPoolID, fmt.Sprintf("invalid child pool id : %d", poolID)) diff --git a/x/rewards/keeper/msg_server.go b/x/rewards/keeper/msg_server.go index 49d208176..48674611c 100644 --- a/x/rewards/keeper/msg_server.go +++ b/x/rewards/keeper/msg_server.go @@ -3,8 +3,8 @@ package keeper import ( "context" - esmtypes "github.com/comdex-official/comdex/x/esm/types" assettypes "github.com/comdex-official/comdex/x/asset/types" + esmtypes "github.com/comdex-official/comdex/x/esm/types" "github.com/comdex-official/comdex/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/rewards/keeper/rewards.go b/x/rewards/keeper/rewards.go index a8663c45a..5f9bc28db 100644 --- a/x/rewards/keeper/rewards.go +++ b/x/rewards/keeper/rewards.go @@ -656,7 +656,7 @@ func (k Keeper) CalculateVaultInterest(ctx sdk.Context, appID, extendedPairID, v interest := sdk.ZeroDec() var err error extPairVaultBTime := ExtPairVaultData.BlockTime.Unix() - if ExtPairVaultData.StabilityFee.IsZero() || ExtPairVaultData.IsStableMintVault{ + if ExtPairVaultData.StabilityFee.IsZero() || ExtPairVaultData.IsStableMintVault { return nil } else { if blockHeight == 0 { diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index 6d921e0a3..f7565e23a 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -17,6 +17,7 @@ var ( ErrNoGaugeForDuration = sdkerrors.Register(ModuleName, 8, "no gauges found for given duration") ErrDepositSmallThanEpoch = sdkerrors.Register(ModuleName, 9, "deposit amount smaller than total epochs/triggers") ErrInvalidCalculatedAMount = sdkerrors.Register(ModuleName, 10, "available distribution coins smaller than calculated distribution amount") + ErrSamePoolID = sdkerrors.Register(ModuleName, 11, "same pool id cannot exists in child pool ids") ErrAssetIDDoesNotExist = sdkerrors.Register(ModuleName, 1101, "Asset Id does not exist in locker for App_Mapping") ErrNegativeTimeElapsed = sdkerrors.Register(ModuleName, 1102, "negative time elapsed since last interest time") diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index 4e3812f8f..0c58055e8 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -1,12 +1,12 @@ package types -func NewGenesisState(internal_rewards []InternalRewards, locker_rewards_tracker []LockerRewardsTracker, vault_interest_tracker []VaultInterestTracker, locker_external_rewards []LockerExternalRewards, vault_external_rewards []VaultExternalRewards, appIDs []uint64, epochInfo []EpochInfo, gauge []Gauge, gaugeDuration []GaugeByTriggerDuration, params Params) *GenesisState { +func NewGenesisState(internalRewards []InternalRewards, lockerRewardsTracker []LockerRewardsTracker, vaultInterestTracker []VaultInterestTracker, lockerExternalRewards []LockerExternalRewards, vaultExternalRewards []VaultExternalRewards, appIDs []uint64, epochInfo []EpochInfo, gauge []Gauge, gaugeDuration []GaugeByTriggerDuration, params Params) *GenesisState { return &GenesisState{ - InternalRewards: internal_rewards, - LockerRewardsTracker: locker_rewards_tracker, - VaultInterestTracker: vault_interest_tracker, - LockerExternalRewards: locker_external_rewards, - VaultExternalRewards: vault_external_rewards, + InternalRewards: internalRewards, + LockerRewardsTracker: lockerRewardsTracker, + VaultInterestTracker: vaultInterestTracker, + LockerExternalRewards: lockerExternalRewards, + VaultExternalRewards: vaultExternalRewards, AppIDs: appIDs, EpochInfo: epochInfo, Gauge: gauge, diff --git a/x/vault/handler_test.go b/x/vault/handler_test.go index c438ffc50..526f1b9e0 100644 --- a/x/vault/handler_test.go +++ b/x/vault/handler_test.go @@ -23,7 +23,7 @@ func TestInvalidMsg(t *testing.T) { app.VaultKeeper = keeper.NewKeeper( app.AppCodec(), app.GetKey(types.StoreKey), app.BankKeeper, &app.AssetKeeper, &app.MarketKeeper, &app.CollectorKeeper, &app.EsmKeeper, - app.TokenmintKeeper, app.Rewardskeeper ) + app.TokenmintKeeper, app.Rewardskeeper) h := vault.NewHandler(app.VaultKeeper) res, err := h(sdk.NewContext(nil, tmproto.Header{}, false, nil), testdata.NewTestMsg()) diff --git a/x/vault/types/msg.go b/x/vault/types/msg.go index c1e7ade48..382f640fa 100644 --- a/x/vault/types/msg.go +++ b/x/vault/types/msg.go @@ -84,12 +84,12 @@ func (m *MsgCreateRequest) GetSigners() []sdk.AccAddress { func NewMsgDepositRequest( // nolint from sdk.AccAddress, - appID uint64, extendedPairVaultID uint64, userVaultid uint64, amount sdk.Int) *MsgDepositRequest { + appID uint64, extendedPairVaultID uint64, userVaultID uint64, amount sdk.Int) *MsgDepositRequest { return &MsgDepositRequest{ From: from.String(), AppId: appID, ExtendedPairVaultId: extendedPairVaultID, - UserVaultId: userVaultid, + UserVaultId: userVaultID, Amount: amount, } } @@ -577,11 +577,11 @@ func (m *MsgWithdrawStableMintRequest) GetSigners() []sdk.AccAddress { func NewMsgVaultInterestCalcRequest( // nolint from sdk.AccAddress, - appID uint64, userVaultId uint64) *MsgVaultInterestCalcRequest { + appID uint64, userVaultID uint64) *MsgVaultInterestCalcRequest { return &MsgVaultInterestCalcRequest{ From: from.String(), AppId: appID, - UserVaultId: userVaultId, + UserVaultId: userVaultID, } }