Skip to content

Refactor Escrowed REP and Fork Migration Path for Security Pools#312

Open
KillariDev wants to merge 7 commits into
mainfrom
t3code/4f690d1b
Open

Refactor Escrowed REP and Fork Migration Path for Security Pools#312
KillariDev wants to merge 7 commits into
mainfrom
t3code/4f690d1b

Conversation

@KillariDev

Copy link
Copy Markdown
Collaborator

Summary

  • Merges t3code/4f690d1b into main with protocol-level refactors that move fork/migration behavior into the on-chain flow and simplify build orchestration.
  • Removes shared-package freshness/refresh prechecks from root scripts and replaces them with direct artifact freshness checks based on file mtimes in scripts/ensure-contract-artifacts.mts.
  • Drops stale shared dependency script and shared/ts/protocolConfig.ts, updating export surfaces accordingly.
  • Reworks Zoltar and EscalationGame constructor/config constants flow: replaces mutable/constructor-provided fork params with internal constants and updates burn threshold math.
  • Replaces prior SafeERC20 helper usage in core repayment/burn paths with direct token transfer/transferFrom calls and introduces escrow accounting for vault deposits (escrowedRepByVault) inside EscalationGame.
  • Adds fork migration mechanics: preview/validated deposit recording from the security pool, imported forked deposit replay, vault deposit export, residual REP sweep-to-security-pool, and a parent/deposit index helper API.
  • Updates peripheral deployment/migration contracts plus simulator/test harnesses and UI contract bindings/types to align with the new fork migration and workflow data flow.

Testing

  • Not run (not requested in this task).
  • Suggested checks to run before merge:
    • bun run ensure-contract-artifacts
    • bun run tsc
    • bun run test
    • bun run check
    • bun run knip
    • bun run format

- Move per-vault REP lock accounting from SecurityPool into EscalationGame and transfer deposits through preview/record APIs
- Add deposit export/import and residual sweep helpers for fork continuation and unresolved vault state cleanup
- Update forker/liquidation/withdrawal paths to rely on escrowed balances, remove stale lock bookkeeping, and align total-balance checks with full REP custody
- Update EscalationGame constructor/init-code flow to inject REP token explicitly for deterministic deployment
- Replace locked-rep book-keeping with on-game escrowed-rep accounting and add non-transfer claim/export helpers
- Remove SecurityPool escalation lock fields and migrate deposit escrow to ownership-derivative accounting with round-up safety checks
- Update forking paths to support own-fork escalation REP partitioning and deterministic rep-to-ownership migration
- Adjust factory/address derivation and TS UI/test wiring to match new deployment and claim/export interfaces
- Renamed fork accounting from `repAtFork` to `auctionableRepAtFork` and added `getOwnForkRepBuckets` to expose vault/escalation REP partitions for own-fork tracking
- Reworked own-fork escalation migration to consume source/child REP buckets, rename vault migration callback to `claimForkedEscalationDeposits`, and emit separate child-vault vs wallet claim events
- Updated Solidity/TS contract tests, simulator helpers, and UI components/types to use the new APIs and naming so fork/auction workflows and pricing logic remain consistent
- add `getOwnForkMigrationStatus` on `SecurityPoolForker` (and interface) and emit child-pool info in escalation-claim event
- switch fork auction loading to use new migration-status payload for own-fork REP metrics
- move own-fork diagnostics in `ForkAuctionSection` into an `Advanced Diagnostics` accordion
- add/update Solidity and UI tests to cover own-fork migration label/visibility and data plumbing
- Relocate peripheral test Solidity mocks/contracts from `solidity/contracts/peripherals/test` to `solidity/contracts/test/peripherals`
- Fix Solidity import paths for moved files and relocated peripheral dependencies
- Update Solidity TS tests to reference the new `test_peripherals_*` artifact module names
- Introduced `SecurityPoolForkerEscalationForker` and moved escalation-specific fork/deposit migration logic into it
- Unified own-fork bookkeeping into `forkDataByPool` by merging bucket fields into `SecurityPoolForkerForkData`
- Refactored `SecurityPoolForker` truth-auction and finalize paths into smaller helpers, and updated storage layout test coverage for unified fork-session fields
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