Skip to content

Commit

Permalink
events
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Apr 18, 2024
1 parent 88eba70 commit 272aedb
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 47 deletions.
5 changes: 5 additions & 0 deletions proto/umee/leverage/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ message EventFundOracle {
// Assets sent to oracle module
repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
}

// EventFundAuction is emitted when sending rewards to auction module
message EventFundAuction {
repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
}
13 changes: 8 additions & 5 deletions x/leverage/keeper/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,16 @@ func (k Keeper) fundModules(ctx sdk.Context, toOracle, toAuction sdk.Coins) erro
"to oracle", toOracleCheck,
"to auction", toAuctionCheck,
)
sdkutil.Emit(&ctx, &types.EventFundOracle{Assets: toOracleCheck})

send := k.bankKeeper.SendCoinsFromModuleToModule
if !toOracleCheck.IsZero() {
return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, oracletypes.ModuleName, toOracleCheck)
sdkutil.Emit(&ctx, &types.EventFundOracle{Assets: toOracleCheck})
if err := send(ctx, types.ModuleName, oracletypes.ModuleName, toOracleCheck); err != nil {
return err
}
}
if !toOracleCheck.IsZero() {
return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, auction.ModuleName, toOracleCheck)
if !toAuctionCheck.IsZero() {
sdkutil.Emit(&ctx, &types.EventFundAuction{Assets: toOracleCheck})
return send(ctx, types.ModuleName, auction.ModuleName, toAuctionCheck)
}

return nil
Expand Down
260 changes: 218 additions & 42 deletions x/leverage/types/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 272aedb

Please sign in to comment.