Liquidation test plan alignment with TidalProtocol (Phases 1 & 2) #56
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.
This PR aligns Tidal SC root tests and harness with the new Liquidation Mechanism implemented in
onflow/TidalProtocol(Phases 1 & 2: core repay‑for‑seize and DEX liquidation), as proposed and merged in the upstream protocol PR:Why:
What changed (high‑level):
safeReset()in tests to avoid emulator rollback panics during multi‑step liquidationsgetPositionHealthhelper using UInt128 HF (cadence/scripts/tidal-protocol/position_health.cdc) to match protocol’s e24 fixed‑point healthensurePoolFactoryAndCreatePool()so pool creation never fails due to missing factory in signerMockDexSwapperto rootflow.json; deploy in testsset_dex_liquidation_configand configure oracle deviation bpsMockStrategyto conform toDeFiActionsinterfaces and use providedUniqueIdentifierh >= 1.05e24 - tol(allow equal or higher); this mirrors upstream behavior where rounding may yield slightly above targetFiles of note:
flow.json: addMockDexSwapperentrycadence/scripts/tidal-protocol/position_health.cdc: returnUInt128HF to match protocolcadence/contracts/mocks/MockStrategy.cdc: interface conformance +UniqueIdentifierhandlingcadence/tests/test_helpers.cdc:safeReset,getPositionHealth,ensurePoolFactoryAndCreatePool, deployMockDexSwappercadence/tests/liquidation_rebalance_to_target_test.cdc: rebalance path to HF≈1.3e24cadence/tests/liquidation_via_dex_yield_zero_test.cdc: DEX liquidation path, allowlist, protocol MOET liquidity, HF≥1.05e24cadence/tests/liquidation_integration_test.cdc: end‑to‑end repay‑for‑seize flow; correct protocol signer address per root aliasesHow this maps to TidalProtocol#41:
liquidate_repay_for_seizeand validates post‑HF≈1.05e24Results:
liquidation_integration_test.cdc(repay‑for‑seize)liquidation_rebalance_to_target_test.cdc(rebalance to 1.3)liquidation_via_dex_yield_zero_test.cdc(DEX liquidation to ~1.05)Notes:
HF ≥ targetfor DEX liquidation is intentional and consistent with upstream rounding and guardrails.