diff --git a/ts/client/src/accounts/healthCache.ts b/ts/client/src/accounts/healthCache.ts index 041723fd8..766d4b9f6 100644 --- a/ts/client/src/accounts/healthCache.ts +++ b/ts/client/src/accounts/healthCache.ts @@ -204,6 +204,15 @@ export class HealthCache { return ZERO_I80F48; } + if ( + sourceBank.initLiabWeight + .sub(targetBank.initAssetWeight) + .abs() + .lte(ZERO_I80F48) + ) { + return ZERO_I80F48; + } + // The health_ratio is a nonlinear based on swap amount. // For large swap amounts the slope is guaranteed to be negative, but small amounts // can have positive slope (e.g. using source deposits to pay back target borrows).