Update x/community lend withdraw proposal to keep funds in x/community (#1755)

* Update x/community lend withdraw proposal to keep funds in x/community

* Update changelog
This commit is contained in:
drklee3 2023-10-25 09:17:11 -07:00 committed by GitHub
parent 0efe7f2281
commit adbd70f71c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 19 deletions

View File

@ -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

View File

@ -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.

View File

@ -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) {