package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/kava-labs/kava/x/harvest/types" ) // Borrow funds func (k Keeper) Borrow(ctx sdk.Context, borrower sdk.AccAddress, coins sdk.Coins) error { err := k.supplyKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleAccountName, borrower, coins) if err != nil { return err } borrow, found := k.GetBorrow(ctx, borrower) if !found { borrow = types.NewBorrow(borrower, coins) } else { borrow.Amount = borrow.Amount.Add(coins...) } k.SetBorrow(ctx, borrow) ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeHarvestBorrow, sdk.NewAttribute(types.AttributeKeyBorrower, borrow.Borrower.String()), sdk.NewAttribute(types.AttributeKeyBorrowCoins, coins.String()), ), ) return nil }