-
Notifications
You must be signed in to change notification settings - Fork 44
/
events.go
43 lines (38 loc) · 1.77 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package keeper
import (
"fmt"
"strconv"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/perpetual/types"
)
func (k Keeper) EmitFundPayment(ctx sdk.Context, mtp *types.MTP, takeAmount math.Int, takeAsset string, paymentType string) {
ctx.EventManager().EmitEvent(sdk.NewEvent(paymentType,
sdk.NewAttribute("id", strconv.FormatInt(int64(mtp.Id), 10)),
sdk.NewAttribute("payment_amount", takeAmount.String()),
sdk.NewAttribute("payment_asset", takeAsset),
))
}
func (k Keeper) EmitForceClose(ctx sdk.Context, mtp *types.MTP, repayAmount math.Int, closer string) {
ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventForceClose,
sdk.NewAttribute("id", strconv.FormatInt(int64(mtp.Id), 10)),
sdk.NewAttribute("position", mtp.Position.String()),
sdk.NewAttribute("address", mtp.Address),
sdk.NewAttribute("collaterals", mtp.Collateral.String()),
sdk.NewAttribute("custodies", mtp.Custody.String()),
sdk.NewAttribute("repay_amount", repayAmount.String()),
sdk.NewAttribute("leverage", fmt.Sprintf("%s", mtp.Leverage)),
sdk.NewAttribute("liabilities", mtp.Liabilities.String()),
sdk.NewAttribute("borrow_interest_paid_collaterals", mtp.BorrowInterestPaidCollateral.String()),
sdk.NewAttribute("borrow_interest_paid_custodies", mtp.BorrowInterestPaidCustody.String()),
sdk.NewAttribute("health", mtp.MtpHealth.String()),
sdk.NewAttribute("closer", closer),
))
}
func (k Keeper) EmitFundingFeePayment(ctx sdk.Context, mtp *types.MTP, takeAmount math.Int, takeAsset string, paymentType string) {
ctx.EventManager().EmitEvent(sdk.NewEvent(paymentType,
sdk.NewAttribute("id", strconv.FormatInt(int64(mtp.Id), 10)),
sdk.NewAttribute("payment_amount", takeAmount.String()),
sdk.NewAttribute("payment_asset", takeAsset),
))
}