diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf82f7c..292ef1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - (community) [#1706] Add disable inflation upgrade to begin blocker that updates x/mint and x/kavadist params - (community) [#1729] Consolidate community funds from `x/distribution` and `x/kavadist` to `x/community` - (community) [#1752] Set `x/distribution` CommunityTax to zero on inflation disable upgrade +- (community) [#1755] Keep funds in `x/community` in `CommunityPoolLendWithdrawProposal` handler ## [v0.24.0] @@ -296,6 +297,7 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md). - [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run large-scale simulations remotely using aws-batch +[#1755]: https://github.com/Kava-Labs/kava/pull/1755 [#1752]: https://github.com/Kava-Labs/kava/pull/1752 [#1751]: https://github.com/Kava-Labs/kava/pull/1751 [#1745]: https://github.com/Kava-Labs/kava/pull/1745 diff --git a/x/community/keeper/proposal_handler.go b/x/community/keeper/proposal_handler.go index abd217dd..f6366b5a 100644 --- a/x/community/keeper/proposal_handler.go +++ b/x/community/keeper/proposal_handler.go @@ -19,22 +19,8 @@ func HandleCommunityPoolLendDepositProposal(ctx sdk.Context, k Keeper, p *types. // HandleCommunityPoolLendWithdrawProposal is a handler for executing a passed community pool lend withdraw proposal. func HandleCommunityPoolLendWithdrawProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolLendWithdrawProposal) error { - // hard allows attempting to withdraw more funds than there is a deposit for. - // this means the amount that gets withdrawn will not necessarily match the amount set in the proposal. - // to calculate how much is withdrawn, compare this module's balance before & after withdraw. - balanceBefore := k.bankKeeper.GetAllBalances(ctx, k.moduleAddress) - // withdraw funds from x/hard to this module account - err := k.hardKeeper.Withdraw(ctx, k.moduleAddress, p.Amount) - if err != nil { - return err - } - - balanceAfter := k.bankKeeper.GetAllBalances(ctx, k.moduleAddress) - totalWithdrawn := balanceAfter.Sub(balanceBefore...) - - // send all withdrawn coins back to community pool - return k.distrKeeper.FundCommunityPool(ctx, totalWithdrawn, k.moduleAddress) + return k.hardKeeper.Withdraw(ctx, k.moduleAddress, p.Amount) } // HandleCommunityCDPRepayDebtProposal is a handler for executing a passed community pool cdp repay debt proposal. diff --git a/x/community/keeper/proposal_handler_test.go b/x/community/keeper/proposal_handler_test.go index ebf01e49..b65bb382 100644 --- a/x/community/keeper/proposal_handler_test.go +++ b/x/community/keeper/proposal_handler_test.go @@ -120,10 +120,13 @@ func (suite *proposalTestSuite) FundCommunityPool(coins sdk.Coins) { } func (suite *proposalTestSuite) GetCommunityPoolBalance() sdk.Coins { - balance, change := suite.App.GetDistrKeeper().GetFeePoolCommunityCoins(suite.Ctx).TruncateDecimal() - // expect no decimal dust - suite.True(sdk.NewDecCoins().IsEqual(change), "expected no decimal dust in community pool") - return balance + ak := suite.App.GetAccountKeeper() + bk := suite.App.GetBankKeeper() + + addr := ak.GetModuleAddress(types.ModuleAccountName) + + // Return x/community module account balance, no longer using x/distribution community pool + return bk.GetAllBalances(suite.Ctx, addr) } func (suite *proposalTestSuite) CheckCommunityPoolBalance(expected sdk.Coins) {