Skip to content

Commit

Permalink
make megavault withdrawal logging more succinct (#2607)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 authored Nov 25, 2024
1 parent 8f0899e commit 4eaca4a
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions protocol/x/vault/keeper/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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
}
Expand All @@ -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",
Expand All @@ -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
}
Expand All @@ -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",
Expand All @@ -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
}
Expand Down

0 comments on commit 4eaca4a

Please sign in to comment.