Skip to content

Commit

Permalink
Add missing events
Browse files Browse the repository at this point in the history
  • Loading branch information
mattverse committed Jul 10, 2024
1 parent a85ff17 commit 1becaea
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions x/concentrated-liquidity/lp.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId
types.TypeEvtAddToPosition,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, owner.String()),
sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(positionId, 10)),
sdk.NewAttribute(types.AttributeKeyPositionId, strconv.FormatUint(positionId, 10)),
sdk.NewAttribute(types.AttributeKeyNewPositionId, strconv.FormatUint(newPositionData.ID, 10)),
sdk.NewAttribute(types.AttributeAmount0, newPositionData.Amount0.String()),
Expand Down
2 changes: 2 additions & 0 deletions x/lockup/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ func createBeginUnlockEvent(lock *types.PeriodLock) sdk.Event {
types.TypeEvtBeginUnlock,
sdk.NewAttribute(types.AttributePeriodLockID, osmoutils.Uint64ToString(lock.ID)),
sdk.NewAttribute(types.AttributePeriodLockOwner, lock.Owner),
sdk.NewAttribute(types.AttributePeriodLockDenom, lock.Coins[0].Denom),
sdk.NewAttribute(types.AttributePeriodLockAmount, lock.Coins[0].Amount.String()),
sdk.NewAttribute(types.AttributePeriodLockDuration, lock.Duration.String()),
sdk.NewAttribute(types.AttributePeriodLockUnlockTime, lock.EndTime.String()),
)
Expand Down
1 change: 1 addition & 0 deletions x/lockup/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
AttributePeriodLockID = "period_lock_id"
AttributePeriodLockOwner = "owner"
AttributePeriodLockAmount = "amount"
AttributePeriodLockDenom = "denom"
AttributePeriodLockDuration = "duration"
AttributePeriodLockUnlockTime = "unlock_time"
AttributeUnlockedCoins = "unlocked_coins"
Expand Down
1 change: 1 addition & 0 deletions x/superfluid/keeper/concentrated_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (k Keeper) addToConcentratedLiquiditySuperfluidPosition(ctx sdk.Context, se
sdk.NewEvent(
types.TypeEvtAddToConcentratedLiquiditySuperfluidPosition,
sdk.NewAttribute(sdk.AttributeKeySender, sender.String()),
sdk.NewAttribute(types.AttributeKeyPoolId, strconv.FormatUint(position.PoolId, 10)),
sdk.NewAttribute(types.AttributePositionId, strconv.FormatUint(positionId, 10)),
sdk.NewAttribute(types.AttributeNewPositionId, strconv.FormatUint(positionData.ID, 10)),
sdk.NewAttribute(types.AttributeAmount0, positionData.Amount0.String()),
Expand Down
16 changes: 10 additions & 6 deletions x/superfluid/keeper/internal/events/emit.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,22 @@ func newRemoveSuperfluidAssetEvent(denom string) sdk.Event {
)
}

func EmitSuperfluidDelegateEvent(ctx sdk.Context, lockId uint64, valAddress string) {
func EmitSuperfluidDelegateEvent(ctx sdk.Context, lockId uint64, valAddress string, lockCoins sdk.Coins) {
if ctx.EventManager() == nil {
return
}

ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidDelegateEvent(lockId, valAddress),
newSuperfluidDelegateEvent(lockId, valAddress, lockCoins),
})
}

func newSuperfluidDelegateEvent(lockId uint64, valAddress string) sdk.Event {
func newSuperfluidDelegateEvent(lockId uint64, valAddress string, lockCoins sdk.Coins) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidDelegate,
sdk.NewAttribute(types.AttributeLockId, osmoutils.Uint64ToString(lockId)),
sdk.NewAttribute(types.AttributeLockAmount, lockCoins[0].Amount.String()),
sdk.NewAttribute(types.AttributeLockDenom, lockCoins[0].Denom),
sdk.NewAttribute(types.AttributeValidator, valAddress),
)
}
Expand Down Expand Up @@ -99,20 +101,22 @@ func newSuperfluidIncreaseDelegationEvent(lockId uint64, amount sdk.Coins) sdk.E
)
}

func EmitSuperfluidUndelegateEvent(ctx sdk.Context, lockId uint64) {
func EmitSuperfluidUndelegateEvent(ctx sdk.Context, lockId uint64, lockCoins sdk.Coins) {
if ctx.EventManager() == nil {
return
}

ctx.EventManager().EmitEvents(sdk.Events{
newSuperfluidUndelegateEvent(lockId),
newSuperfluidUndelegateEvent(lockId, lockCoins),
})
}

func newSuperfluidUndelegateEvent(lockId uint64) sdk.Event {
func newSuperfluidUndelegateEvent(lockId uint64, lockCoins sdk.Coins) sdk.Event {
return sdk.NewEvent(
types.TypeEvtSuperfluidUndelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", lockId)),
sdk.NewAttribute(types.AttributeLockAmount, lockCoins[0].Amount.String()),
sdk.NewAttribute(types.AttributeLockDenom, lockCoins[0].Denom),
)
}

Expand Down
6 changes: 5 additions & 1 deletion x/superfluid/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ func (server msgServer) SuperfluidDelegate(goCtx context.Context, msg *types.Msg

err := server.keeper.SuperfluidDelegate(ctx, msg.Sender, msg.LockId, msg.ValAddr)
if err == nil {
events.EmitSuperfluidDelegateEvent(ctx, msg.LockId, msg.ValAddr)
lock, err := server.keeper.lk.GetLockByID(ctx, msg.LockId)
if err != nil {
return &types.MsgSuperfluidDelegateResponse{}, err
}
events.EmitSuperfluidDelegateEvent(ctx, msg.LockId, msg.ValAddr, lock.Coins)
}
return &types.MsgSuperfluidDelegateResponse{}, err
}
Expand Down
2 changes: 2 additions & 0 deletions x/superfluid/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const (
AttributeDenom = "denom"
AttributeSuperfluidAssetType = "superfluid_asset_type"
AttributeLockId = "lock_id"
AttributeLockAmount = "lock_amount"
AttributeLockDenom = "lock_denom"
AttributeValidator = "validator"
AttributeAmount = "amount"
)

0 comments on commit 1becaea

Please sign in to comment.