@@ -6,10 +6,13 @@ import (
6
6
"sync"
7
7
"time"
8
8
9
+ seiutils "github.com/sei-protocol/sei-chain/utils"
9
10
"github.com/sei-protocol/sei-chain/utils/logging"
10
11
"github.com/sei-protocol/sei-chain/utils/tracing"
11
12
12
13
sdk "github.com/cosmos/cosmos-sdk/types"
14
+ authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
15
+ bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
13
16
"github.com/sei-protocol/sei-chain/store/whitelist/multi"
14
17
seisync "github.com/sei-protocol/sei-chain/sync"
15
18
"github.com/sei-protocol/sei-chain/utils/datastructures"
@@ -46,6 +49,8 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo
46
49
env := newEnv (ctx , validContractsInfo , keeper )
47
50
cachedCtx , msCached := cacheContext (ctx , env )
48
51
memStateCopy := dexutils .GetMemState (cachedCtx .Context ()).DeepCopy ()
52
+ preRunRents := keeper .GetRentsForContracts (ctx , seiutils .Map (validContractsInfo , func (c types.ContractInfoV2 ) string { return c .ContractAddr }))
53
+
49
54
handleDeposits (spanCtx , cachedCtx , env , keeper , tracer )
50
55
51
56
runner := NewParallelRunner (func (contract types.ContractInfoV2 ) {
@@ -66,6 +71,8 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo
66
71
67
72
// No error is thrown for any contract. This should happen most of the time.
68
73
if env .failedContractAddresses .Size () == 0 {
74
+ postRunRents := keeper .GetRentsForContracts (ctx , seiutils .Map (validContractsInfo , func (c types.ContractInfoV2 ) string { return c .ContractAddr }))
75
+ TransferRentFromDexToCollector (ctx , keeper .BankKeeper , preRunRents , postRunRents )
69
76
msCached .Write ()
70
77
return env .validContractsInfo , ctx , true
71
78
}
@@ -241,3 +248,17 @@ func filterNewValidContracts(ctx sdk.Context, env *environment) []types.Contract
241
248
}
242
249
return newValidContracts
243
250
}
251
+
252
+ func TransferRentFromDexToCollector (ctx sdk.Context , bankKeeper bankkeeper.Keeper , preRents map [string ]uint64 , postRents map [string ]uint64 ) {
253
+ total := uint64 (0 )
254
+ for addr , preRent := range preRents {
255
+ if postRent , ok := postRents [addr ]; ok {
256
+ total += preRent - postRent
257
+ } else {
258
+ total += preRent
259
+ }
260
+ }
261
+ if err := bankKeeper .SendCoinsFromModuleToModule (ctx , types .ModuleName , authtypes .FeeCollectorName , sdk .NewCoins (sdk .NewCoin ("usei" , sdk .NewInt (int64 (total ))))); err != nil {
262
+ ctx .Logger ().Error ("sending coints from dex to fee collector failed due to %s" , err )
263
+ }
264
+ }
0 commit comments