From ab2486786072fc06281e3b14d2f2fb49aea8fb9f Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Mon, 25 Nov 2024 11:40:55 -0500 Subject: [PATCH] make megavault withdrawal logging more succinct --- protocol/x/vault/keeper/withdraw.go | 41 +++-------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/protocol/x/vault/keeper/withdraw.go b/protocol/x/vault/keeper/withdraw.go index 436effd9d6..5c63a01547 100644 --- a/protocol/x/vault/keeper/withdraw.go +++ b/protocol/x/vault/keeper/withdraw.go @@ -290,7 +290,7 @@ func (k Keeper) RedeemFromMainAndSubVaults( _, perpetual, marketParam, marketPrice, err := k.GetVaultClobPerpAndMarket(ctx, *vaultId) if err != nil { - if simulate { + if !simulate { log.DebugLog( ctx, "Megavault withdrawal: failed to get perpetual and market. Skipping this vault", @@ -299,20 +299,12 @@ func (k Keeper) RedeemFromMainAndSubVaults( "Error", err, ) - } else { - log.ErrorLogWithError( - ctx, - "Megavault withdrawal: error when getting perpetual and market. Skipping this vault", - err, - "Vault ID", - vaultId, - ) } continue } leverage, equity, err := k.GetVaultLeverageAndEquity(ctx, *vaultId, &perpetual, &marketPrice) if err != nil { - if simulate { + if !simulate { log.DebugLog( ctx, "Megavault withdrawal: failed to get vault leverage and equity. Skipping this vault", @@ -321,14 +313,6 @@ func (k Keeper) RedeemFromMainAndSubVaults( "Error", err, ) - } else { - log.ErrorLogWithError( - ctx, - "Megavault withdrawal: error when getting vault leverage and equity. Skipping this vault", - err, - "Vault ID", - vaultId, - ) } continue } @@ -343,7 +327,7 @@ func (k Keeper) RedeemFromMainAndSubVaults( &marketParam, ) if err != nil { - if simulate { + if !simulate { log.DebugLog( ctx, "Megavault withdrawal: failed to get vault withdrawal slippage. Skipping this vault", @@ -352,14 +336,6 @@ func (k Keeper) RedeemFromMainAndSubVaults( "Error", err, ) - } else { - log.ErrorLogWithError( - ctx, - "Megavault withdrawal: error when getting vault withdrawal slippage. Skipping this vault", - err, - "Vault ID", - vaultId, - ) } continue } @@ -371,7 +347,7 @@ func (k Keeper) RedeemFromMainAndSubVaults( quantumsToTransfer := new(big.Int).Quo(redeemedFromSubVault.Num(), redeemedFromSubVault.Denom()) if quantumsToTransfer.Sign() <= 0 || !quantumsToTransfer.IsUint64() { - if simulate { + if !simulate { log.DebugLog( ctx, "Megavault withdrawal: quantums to transfer is invalid. Skipping this vault", @@ -380,15 +356,6 @@ func (k Keeper) RedeemFromMainAndSubVaults( "Quantums", quantumsToTransfer, ) - } else { - log.ErrorLog( - ctx, - "Megavault withdrawal: quantums to transfer is invalid. Skipping this vault", - "Vault ID", - vaultId, - "Quantums", - quantumsToTransfer, - ) } continue }