docs: fill in contract-scoped project context - #3
Merged
Conversation
Bring the contract-relevant design context into this repo, which now owns the contract ADRs (the architecture repo was temporary exploration): - CONTEXT.md: domain language and architecture map, scoped to the contracts - ADR-0003: trampoline deployment & settlement integration - ADR-0004: penalty schedule & attribution (contract-scoped extract) - ADR-0005: trampoline execution authority & EIP-712 proposal signature - docs/adr/README.md: index plus known open questions - docs/reference/: CoW slashing framework, auction mechanics, solver CIPs - docs/agents/: issue tracker and triage label conventions Fix the broken references in ADR-0001/0002 (CONTEXT.md, economics note, old ADR-0006 numbering) and convert code anchors to GitHub permalinks pinned at cowprotocol/contracts@c6b61ce. The RFP is cited by its forum URL. AGENTS.md points at CONTEXT.md for vocabulary instead of carrying its own glossary, and README lists the Trampoline as a planned contract. Escrow.deposit() gets a TODO for the deploy-at-deposit-time factory hook settled in ADR-0003; the hook lands with the Trampoline factory.
jean-neiverth
approved these changes
Jul 13, 2026
jean-neiverth
pushed a commit
that referenced
this pull request
Jul 13, 2026
Bring the contract-relevant design context into this repo, which now owns the contract ADRs (the architecture repo was temporary exploration): - CONTEXT.md: domain language and architecture map, scoped to the contracts - ADR-0003: trampoline deployment & settlement integration - ADR-0004: penalty schedule & attribution (contract-scoped extract) - ADR-0005: trampoline execution authority & EIP-712 proposal signature - docs/adr/README.md: index plus known open questions - docs/reference/: CoW slashing framework, auction mechanics, solver CIPs - docs/agents/: issue tracker and triage label conventions Fix the broken references in ADR-0001/0002 (CONTEXT.md, economics note, old ADR-0006 numbering) and convert code anchors to GitHub permalinks pinned at cowprotocol/contracts@c6b61ce. The RFP is cited by its forum URL. AGENTS.md points at CONTEXT.md for vocabulary instead of carrying its own glossary, and README lists the Trampoline as a planned contract. Escrow.deposit() gets a TODO for the deploy-at-deposit-time factory hook settled in ADR-0003; the hook lands with the Trampoline factory.
jean-neiverth
added a commit
that referenced
this pull request
Jul 13, 2026
* feat: implement escrow contract per ADR-0002 Implement the full BYOSEscrow contract with owner/operator role separation, cooldown-based all-or-nothing withdrawals, freeze/unfreeze for Track B investigations, debit authority for Track A/B penalties, and permissionless debit sweeping to owner. * refactor: rename BYOSEscrow to Escrow per ADR-0002 The ADR defines the contract as simply "Escrow". Aligns contract name, test file, test directory, and deploy script with the specification. * fix: import ordering in deploy script for forge fmt * fix: exclude block-timestamp lint rule in foundry config The block-timestamp lint warns about validator manipulation of block.timestamp, but this is irrelevant for day-scale cooldowns. Foundry 1.7.1 runs the linter during build and deny=warnings makes this a hard error in CI. * test: add withdrawal lifecycle state cleanup and post-withdrawal debit tests Extend test_full_withdrawal_lifecycle with a second deposit/withdraw cycle to verify no leftover deposits or totalDebited in contract state. Add test_debit_after_withdrawal_reverts to confirm operator cannot debit a sub-solver after their balance has been fully withdrawn. * feat: two-step ownership transfer with acceptOwnership Replace direct ownership transfer with a two-step process: owner calls transferOwnership to set a pendingOwner, then pendingOwner calls acceptOwnership to finalize. Prevents irrecoverable loss from typos. A second transferOwnership call overrides any pending transfer. * refactor: rename solver to subSolver in tests Aligns test variable names with the domain terminology used in the contract and ADR. * refactor: extract _balance() helper for safe deposits-minus-debits Consolidates the repeated deposits[s] - totalDebited[s] subtraction into a single internal function with an explicit underflow guard. Reverts with InsufficientBalance instead of a raw panic if the invariant is ever violated. * docs: add natspec and inline comments to Escrow contract * refactor: replace deposits/totalDebited with single balances mapping Collapses two per-sub-solver mappings into one. Deposits add to the balance, debits subtract from it, withdrawal zeroes it. Eliminates indefinite accumulation of stale accounting state, removes the _balance() helper (no subtraction needed), and saves one SLOAD in debit() and one SSTORE in executeWithdrawal(). * chore: remove BYOSTrampoline from escrow branch BYOSTrampoline belongs in its own branch/PR. Removes the contract, its tests, and the deploy script reference. * docs: bring escrow and trampoline ADRs into this repo Copied from cow-byos-architecture docs/adr/ as the canonical reference for contract design decisions. * docs: update escrow ADR to reflect implementation changes - Single balances mapping instead of deposits/totalDebited - Two-step ownership transfer (transferOwnership + acceptOwnership) - Updated interface, view semantics, and alternatives considered * docs: add README and AGENTS.md README covers project overview, contract table, architecture links, and development instructions. AGENTS.md provides guidelines for AI agents: repo structure, conventions, domain language, and testing patterns. * docs: fill in contract-scoped project context (#3) Bring the contract-relevant design context into this repo, which now owns the contract ADRs (the architecture repo was temporary exploration): - CONTEXT.md: domain language and architecture map, scoped to the contracts - ADR-0003: trampoline deployment & settlement integration - ADR-0004: penalty schedule & attribution (contract-scoped extract) - ADR-0005: trampoline execution authority & EIP-712 proposal signature - docs/adr/README.md: index plus known open questions - docs/reference/: CoW slashing framework, auction mechanics, solver CIPs - docs/agents/: issue tracker and triage label conventions Fix the broken references in ADR-0001/0002 (CONTEXT.md, economics note, old ADR-0006 numbering) and convert code anchors to GitHub permalinks pinned at cowprotocol/contracts@c6b61ce. The RFP is cited by its forum URL. AGENTS.md points at CONTEXT.md for vocabulary instead of carrying its own glossary, and README lists the Trampoline as a planned contract. Escrow.deposit() gets a TODO for the deploy-at-deposit-time factory hook settled in ADR-0003; the hook lands with the Trampoline factory. * fix: revert executeWithdrawal when balance is zero Prevents a no-op withdrawal (e.g. after full debit during cooldown) from silently succeeding. Now reverts with NothingToWithdraw instead. --------- Co-authored-by: Pedro Yves Fracari <55461956+yvesfracari@users.noreply.github.com>
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.


Stacked on #1.
This repo now owns the contract-scoped design context for BYOS (the architecture repo was temporary exploration and is going away), so this PR brings that context in for humans and agents. API, operations, and grant material stays out.
New
c_l, ...), the two-risk-classes table, and the contract design posture.Escrow.deposit()triggers the factory deploy.execute, theProposalDataEIP-712 struct (interactionsHashcloses the fabricated-fault vector), factory-bound domain separator, storage-free nonces.Changed
cowprotocol/contracts@c6b61ce(paths verified at that commit); ADR-0001 notes that ADR-0005 settled its execution-authority and payload-shape forks. The RFP is cited by its forum URL.Escrow.sol: TODO indeposit()for the deploy-at-deposit-time factory hook from ADR-0003 (lands with the Trampoline factory).No behavior changes;
forge buildandforge fmt --checkpass.