mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
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:
parent
0efe7f2281
commit
adbd70f71c
@ -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) [#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) [#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) [#1752] Set `x/distribution` CommunityTax to zero on inflation disable upgrade
|
||||||
|
- (community) [#1755] Keep funds in `x/community` in `CommunityPoolLendWithdrawProposal` handler
|
||||||
|
|
||||||
## [v0.24.0]
|
## [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
|
- [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run
|
||||||
large-scale simulations remotely using aws-batch
|
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
|
[#1752]: https://github.com/Kava-Labs/kava/pull/1752
|
||||||
[#1751]: https://github.com/Kava-Labs/kava/pull/1751
|
[#1751]: https://github.com/Kava-Labs/kava/pull/1751
|
||||||
[#1745]: https://github.com/Kava-Labs/kava/pull/1745
|
[#1745]: https://github.com/Kava-Labs/kava/pull/1745
|
||||||
|
@ -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.
|
// HandleCommunityPoolLendWithdrawProposal is a handler for executing a passed community pool lend withdraw proposal.
|
||||||
func HandleCommunityPoolLendWithdrawProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolLendWithdrawProposal) error {
|
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
|
// withdraw funds from x/hard to this module account
|
||||||
err := k.hardKeeper.Withdraw(ctx, k.moduleAddress, p.Amount)
|
return 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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleCommunityCDPRepayDebtProposal is a handler for executing a passed community pool cdp repay debt proposal.
|
// HandleCommunityCDPRepayDebtProposal is a handler for executing a passed community pool cdp repay debt proposal.
|
||||||
|
@ -120,10 +120,13 @@ func (suite *proposalTestSuite) FundCommunityPool(coins sdk.Coins) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *proposalTestSuite) GetCommunityPoolBalance() sdk.Coins {
|
func (suite *proposalTestSuite) GetCommunityPoolBalance() sdk.Coins {
|
||||||
balance, change := suite.App.GetDistrKeeper().GetFeePoolCommunityCoins(suite.Ctx).TruncateDecimal()
|
ak := suite.App.GetAccountKeeper()
|
||||||
// expect no decimal dust
|
bk := suite.App.GetBankKeeper()
|
||||||
suite.True(sdk.NewDecCoins().IsEqual(change), "expected no decimal dust in community pool")
|
|
||||||
return balance
|
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) {
|
func (suite *proposalTestSuite) CheckCommunityPoolBalance(expected sdk.Coins) {
|
||||||
|
Loading…
Reference in New Issue
Block a user