feat: add BabylonSpoke with its own cap-bounded liquidation logic and per-reserve bypass flags - #1343
Closed
avniculae wants to merge 6 commits into
Closed
feat: add BabylonSpoke with its own cap-bounded liquidation logic and per-reserve bypass flags#1343avniculae wants to merge 6 commits into
avniculae wants to merge 6 commits into
Conversation
avniculae
force-pushed
the
feat/babylon-spoke-generic
branch
from
August 24, 2026 14:15
e798dcb to
daf8f4b
Compare
… per-reserve bypass flags
…e Hub like any zero-amount liquidation
…EIP-170 size limit
avniculae
force-pushed
the
feat/babylon-spoke-generic
branch
from
August 26, 2026 10:12
30ffcf9 to
de878e0
Compare
Contributor
Author
|
Superseded by #1345: we're going with the dedicated Babylon liquidation logic scoped to the vaultBTC use case instead of generalizing the canonical LiquidationLogic. Keeping this branch around as a reference for the generic-overrides approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to the
feat/babylon-spokebranch. All Babylon behavior lives in aBabylonSpokesubclass and a dedicatedBabylonLiquidationLogiclibrary; the canonicalLiquidationLogicis byte-identical to main andSpoke's only change isvirtualonliquidationCall(no bytecode change for canonical instances, so gas snapshots stay at main).BabylonLiquidationLogicmirrors the canonical sizing and reuses its building blocks (_validateLiquidationCall,_liquidateCollateral/_liquidateDebt,_calculateCollateralToLiquidate, bonus and target-HF formulas) instead of forking them. Its own param structs carry aLiquidationOverridesinput, and sizing differs from canonical in three ways: the collateral available for seizure ismin(suppliedShares, maxCollateralSharesToRemove)(the cap slots in where the canonical full-collateral bound sits), the dust threshold is a parameter (zero disables dust protection), andbypassTargetHealthFactorsizes the repayment tomin(debtToCover, full reserve debt). When the cap binds below the user's balance, the remaining collateral and debt must respect the dust threshold or the call reverts withMustNotLeaveDust. A zero cap degenerates to a zero-amount liquidation, which the Hub rejects, so there is no bespoke zero check.BabylonSpokedisables the canonical entry (UnsupportedLiquidationCall), exposes the overload withmaxCollateralToRemove(uint256.max= no cap), and stores per-reserveLiquidationBypassflags (restrictedupdateLiquidationBypass; a flag on either reserve of a liquidation applies). The liquidation manager gate comes in a follow-up.BabylonSpokeInstanceexceeds EIP-170 at the standard spoke profile (24,952 bytes at via-ir/750), so it compiles under a new via-ir/200 profile (23,844 bytes, 732 margin). Slimming the contract instead is an option if the lower runs are a concern.Tests: an equivalence test pins Babylon sizing with neutral overrides to the canonical output; deterministic unit tests cover cap/bypass/dust-threshold sizing including the dust-bump-exceeds-cap revert; an integration suite upgrades a spoke proxy to
BabylonSpokeInstancein place. No canonical test or snapshot is modified.Note for reviewers: repeated fuzz runs on this branch surfaced a pre-existing failure in
test_getUserRiskPremium_fuzz_two_users_two_reserves_borrowedthat reproduces on unmodified main (forge test --fuzz-seed 0x640, fails within ~20 runs withHealthFactorBelowThreshold). Unrelated to this change; happy to file it separately.