Skip to content

SIG-605: add comprehensive fork e2e tests for SignalsRouter#66

Merged
worjs merged 1 commit into
mainfrom
test/SIG-605-fork-e2e
Apr 12, 2026
Merged

SIG-605: add comprehensive fork e2e tests for SignalsRouter#66
worjs merged 1 commit into
mainfrom
test/SIG-605-fork-e2e

Conversation

@worjs
Copy link
Copy Markdown
Contributor

@worjs worjs commented Apr 12, 2026

Context

SIG-605 added the SignalsRouter for atomic swap-and-bet operations (PR #65). This PR adds comprehensive fork tests that exercise the Router against a live Citrea mainnet fork — real Satsuma swaps, real Core contract state.

Decisions

  • Tests run against prod fork (FORK_ENV=prod) so they validate against actual deployed contracts and pool liquidity, not mock state
  • Each Router entry point gets its own full-flow test: openPositionWithSwap, increasePositionWithSwap, decreasePositionWithSwap, closePositionWithSwap, claimPayoutWithSwap
  • claimPayoutWithSwap test drives the settlement path (warp → markSettlementFailed → finalizeSecondarySettlement → requestSettlementChunks → claim) to cover the payout flow end-to-end
  • _findActiveMarket helper searches backward from nextMarketId for an active, seeded, in-window market — tests skip gracefully if none exists
  • _openRealPosition places the position at center ticks (not edge) so the cost/payout is meaningful rather than near-zero
  • Existing swap-only test renamed to test_satsuma_swap_usdcE_to_ctUSD for clarity and simplified (removed redundant local variables)

Risk Areas

  • claimPayoutWithSwap test manipulates settlement state via ownerSafe — the settlement value calculation (winningTick * 1e6) assumes 8-decimal Redstone feed and tick = price * 100 convention
  • _findActiveMarket iterates up to nextMarketId + 5 — relies on there being an active market during test execution

Sibling PRs

7 fork tests validating Router against real Citrea mainnet state:
- Real Satsuma USDC.e→ctUSD swap + ABI selector verification
- All 5 Router functions (open/increase/decrease/close/claim)
  against real SignalsCore and SignalsPosition
- Claim uses secondary settlement path (no oracle dependency)
Copy link
Copy Markdown

@signals-reviewer signals-reviewer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR adds comprehensive fork tests for SignalsRouter (introduced in PR #65), exercising all 5 router entry points (openPositionWithSwap, increasePositionWithSwap, decreasePositionWithSwap, closePositionWithSwap, claimPayoutWithSwap) against a live Citrea mainnet fork with real Satsuma swap liquidity and real Core contract state. The claimPayoutWithSwap test drives the full secondary settlement path end-to-end. The existing swap test is renamed for clarity and simplified.

Cross-PR Context

Sibling PRs (SIG-605)

  • v1-contract PR#65 (MERGED): SIG-605: add SignalsRouter for atomic swap-and-bet — the production contract this PR tests

No downstream repos affected — this is test-only code with no interface or ABI changes.

Issues

No issues found.

Suggestions

No suggestions.

Verdict

APPROVE: Clean test PR with comprehensive coverage of all router entry points including the settlement claim path. Settlement timing logic (warp sequences, PendingOps phase, claimDelay) is correct. The settlementValue = winningTick * 1e6 calculation correctly maps tick values (price × 100) to 8-decimal Redstone feed format. Helper design (_findActiveMarket backward search, _openRealPosition center-tick alignment) is sound.

@worjs worjs merged commit d564357 into main Apr 12, 2026
15 checks passed
@worjs worjs deleted the test/SIG-605-fork-e2e branch April 12, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant