2022-12-13 00:38:27 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
2024-05-01 03:17:24 +00:00
|
|
|
"github.com/0glabs/0g-chain/x/community/types"
|
2022-12-13 00:38:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// HandleCommunityPoolLendDepositProposal is a handler for executing a passed community pool lend deposit proposal.
|
|
|
|
func HandleCommunityPoolLendDepositProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolLendDepositProposal) error {
|
2023-01-26 23:27:41 +00:00
|
|
|
// move funds from community pool to x/community so hard position is held by this module.
|
|
|
|
err := k.distrKeeper.DistributeFromFeePool(ctx, p.Amount, k.moduleAddress)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
// deposit funds into hard
|
2022-12-13 00:38:27 +00:00
|
|
|
return k.hardKeeper.Deposit(ctx, k.moduleAddress, p.Amount)
|
|
|
|
}
|
|
|
|
|
|
|
|
// HandleCommunityPoolLendWithdrawProposal is a handler for executing a passed community pool lend withdraw proposal.
|
|
|
|
func HandleCommunityPoolLendWithdrawProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolLendWithdrawProposal) error {
|
2023-01-26 23:27:41 +00:00
|
|
|
// withdraw funds from x/hard to this module account
|
2023-10-25 16:17:11 +00:00
|
|
|
return k.hardKeeper.Withdraw(ctx, k.moduleAddress, p.Amount)
|
2022-12-13 00:38:27 +00:00
|
|
|
}
|
2023-04-20 21:13:16 +00:00
|
|
|
|
|
|
|
// HandleCommunityCDPRepayDebtProposal is a handler for executing a passed community pool cdp repay debt proposal.
|
|
|
|
func HandleCommunityCDPRepayDebtProposal(ctx sdk.Context, k Keeper, p *types.CommunityCDPRepayDebtProposal) error {
|
|
|
|
// make debt repayment
|
|
|
|
return k.cdpKeeper.RepayPrincipal(ctx, k.moduleAddress, p.CollateralType, p.Payment)
|
|
|
|
}
|
2023-04-20 23:08:53 +00:00
|
|
|
|
|
|
|
// HandleCommunityCDPWithdrawCollateralProposal is a handler for executing a
|
|
|
|
// passed community pool cdp withdraw collateral proposal.
|
|
|
|
func HandleCommunityCDPWithdrawCollateralProposal(
|
|
|
|
ctx sdk.Context,
|
|
|
|
k Keeper,
|
|
|
|
p *types.CommunityCDPWithdrawCollateralProposal,
|
|
|
|
) error {
|
|
|
|
// withdraw collateral
|
|
|
|
return k.cdpKeeper.WithdrawCollateral(ctx, k.moduleAddress, k.moduleAddress, p.Collateral, p.CollateralType)
|
|
|
|
}
|