Skip to content

Commit

Permalink
Properly log error (#5862)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8275750)
  • Loading branch information
NotJeremyLiu authored and mergify[bot] committed Jul 28, 2023
1 parent 5660821 commit 010ad66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions x/protorev/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (k Keeper) StoreSwap(ctx sdk.Context, poolId uint64, tokenIn, tokenOut stri
}

if err := k.AddSwapsToSwapsToBackrun(ctx, []types.Trade{swapToBackrun}); err != nil {
ctx.Logger().Error("Protorev error adding swap to backrun from storeSwap", err) // Does not return since logging is last thing in the function
ctx.Logger().Error("Protorev error adding swap to backrun from storeSwap: " + err.Error()) // Does not return since logging is last thing in the function
}
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func (k Keeper) StoreJoinExitPoolSwaps(ctx sdk.Context, sender sdk.AccAddress, p
func (k Keeper) AfterPoolCreatedWithCoins(ctx sdk.Context, poolId uint64) {
baseDenoms, err := k.GetAllBaseDenoms(ctx)
if err != nil {
ctx.Logger().Error("Protorev error getting base denoms in AfterCFMMPoolCreated hook", err)
ctx.Logger().Error("Protorev error getting base denoms in AfterCFMMPoolCreated hook: " + err.Error())
return
}

Expand All @@ -166,13 +166,13 @@ func (k Keeper) AfterPoolCreatedWithCoins(ctx sdk.Context, poolId uint64) {

pool, err := k.poolmanagerKeeper.GetPool(ctx, poolId)
if err != nil {
ctx.Logger().Error("Protorev error getting pool in AfterCFMMPoolCreated hook", err)
ctx.Logger().Error("Protorev error getting pool in AfterCFMMPoolCreated hook: " + err.Error())
return
}

denoms, err := k.poolmanagerKeeper.RouteGetPoolDenoms(ctx, poolId)
if err != nil {
ctx.Logger().Error("Protorev error getting pool liquidity in afterPoolCreated", err)
ctx.Logger().Error("Protorev error getting pool liquidity in afterPoolCreated: " + err.Error())
return
}

Expand Down Expand Up @@ -204,14 +204,14 @@ func (k Keeper) CompareAndStorePool(ctx sdk.Context, poolId uint64, baseDenom, o
// Get comparable liquidity for the new pool
newPoolLiquidity, err := k.GetComparablePoolLiquidity(ctx, poolId)
if err != nil {
ctx.Logger().Error("Protorev error getting newPoolLiquidity in compareAndStorePool", err)
ctx.Logger().Error("Protorev error getting newPoolLiquidity in compareAndStorePool: " + err.Error())
return
}

// Get comparable liquidity for the stored pool
storedPoolLiquidity, err := k.GetComparablePoolLiquidity(ctx, storedPoolId)
if err != nil {
ctx.Logger().Error("Protorev error getting storedPoolLiquidity in compareAndStorePool", err)
ctx.Logger().Error("Protorev error getting storedPoolLiquidity in compareAndStorePool: " + err.Error())
return
}

Expand Down
2 changes: 1 addition & 1 deletion x/protorev/keeper/posthandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (protoRevDec ProtoRevDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
write()
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
} else {
ctx.Logger().Error("ProtoRevTrade failed with error", err)
ctx.Logger().Error("ProtoRevTrade failed with error: " + err.Error())
}

// Delete swaps to backrun for next transaction without consuming gas
Expand Down
2 changes: 1 addition & 1 deletion x/protorev/keeper/rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (k Keeper) ExecuteTrade(ctx sdk.Context, route poolmanagertypes.SwapAmountI

// Send the developer fee to the developer address
if err := k.SendDeveloperFee(ctx, sdk.NewCoin(inputCoin.Denom, profit)); err != nil {
ctx.Logger().Error("failed to send developer fee", "error", err)
ctx.Logger().Error("failed to send developer fee: " + err.Error())
}

// Create and emit the backrun event and add it to the context
Expand Down

0 comments on commit 010ad66

Please sign in to comment.