Skip to content

Commit

Permalink
Sweep balances in axelarcork EndBlocker
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Jan 29, 2024
1 parent bab9a48 commit 9d6159c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions x/axelarcork/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/ethereum/go-ethereum/common"

distributionTypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/peggyjv/sommelier/v7/x/axelarcork/types"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -54,4 +55,17 @@ func (k Keeper) EndBlocker(ctx sdk.Context) {

return false
})

// Sweep all axelarcork of the sender module account balances to the community pool. Because this account is
// the sender for transfers created by RelayCork calls, funds will not be returned to the caller if the IBC
// transfer fails or gas is refunded.
moduleAcct := k.accountKeeper.GetModuleAddress(types.ModuleName)
balances := k.bankKeeper.GetAllBalances(ctx, moduleAcct)
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, distributionTypes.ModuleName, balances); err != nil {
panic(err)
}

feePool := k.distributionKeeper.GetFeePool(ctx)
feePool.CommunityPool = feePool.CommunityPool.Add(sdk.NewDecCoinsFromCoins(balances...)...)
k.distributionKeeper.SetFeePool(ctx, feePool)
}

0 comments on commit 9d6159c

Please sign in to comment.