Sanctra DocsEscrow
Docs/Escrow

Escrow

SanctraEscrow holds the USDG bounty for each Sanctum. It is a single contract with no owner, no admin, no proxy and no fee. Its three important parameters (the token, the Warden signer and the bounty cap) are fixed in the constructor. Money moves in exactly two ways: to the Breaker with a Warden-signed BREACHED verdict, or back to the Owner after the deadline plus a 24-hour grace period. Both calls are open to anyone.

Deployment

The escrow address, its deploy block and the bounty cap are published at 0 (escrow, escrowDeployBlock, maxBountyUsdg) and on Verify once deployed. Source: contracts/src/SanctraEscrow.sol, Solidity 0.8.24. The source is verified on the Robinhood Chain explorer at deployment.

ImmutableMeaning
usdgThe bounty token (USDG, 6 decimals)
wardenThe only verdict signer the contract accepts
maxBountyLargest amount one Sanctum can lock, in token units

Lifecycle

          lock()                     release()  (signed BREACHED, checkedAt <= deadline)
 None  ───────────▶  Locked  ───────────────────────────────────────────▶  Released → Breaker
                       │
                       │  refund()  (block.timestamp > deadline + 24 h)
                       └────────────────────────────────────────────────▶  Refunded → Owner

Each taskId can be used once. Released and Refunded are final.

Functions

lock(taskId, breaker, amount, deadline, termsHash)

Called by the Owner after approving USDG. Records the agreement, then pulls amount from the caller.

  • Reverts TaskExists if the id was used, ZeroBreaker for a zero breaker, BadAmount if amount is 0 or above maxBounty, DeadlinePassed if deadline is not in the future.
  • Measures its own balance before and after the transfer and reverts AmountMismatch if it did not receive exactly amount. Fee-on-transfer behaviour can never leave a Sanctum underfunded.
  • Emits Locked(taskId, owner, breaker, amount, deadline, termsHash).

release(taskId, exploitHash, checkedAt, sig)

Callable by anyone. Pays the locked amount to the Breaker recorded at lock time.

  • Requires status Locked (NotLocked otherwise) and checkedAt <= deadline (CheckedAfterDeadline).
  • Rebuilds the EIP-712 digest from the stored termsHash and breaker, outcome BREACHED, and the supplied exploitHash and checkedAt, then requires the signature to recover to warden (BadSignature).
  • Still valid after the deadline, as long as nobody has refunded yet.
  • Emits Released(taskId, breaker, amount, exploitHash, checkedAt).

refund(taskId)

Callable by anyone. Returns the locked amount to the Owner.

  • Requires status Locked and block.timestamp > deadline + GRACE_PERIOD (GraceNotOver otherwise).
  • Emits Refunded(taskId, owner, amount).

Views

FunctionReturns
agreement(taskId){owner, amount, breaker, deadline, status, termsHash}; status 0 None, 1 Locked, 2 Released, 3 Refunded
verdictDigest(taskId, termsHash, breaker, exploitHash, checkedAt)The digest the Warden must sign for a BREACHED verdict
domainSeparator()EIP-712 domain separator (recomputed if the chain id changes)
GRACE_PERIOD24 hours
OUTCOME_BREACHED1 (HELD is 2 and never pays)
VERDICT_TYPEHASHkeccak256 of the Verdict type string below

Verdict signature

Domain:

{ "name": "Sanctra Warden", "version": "1", "chainId": 4663, "verifyingContract": "<escrow address>" }

Type:

Verdict(bytes32 taskId,bytes32 termsHash,address breaker,uint8 outcome,bytes32 exploitHash,uint64 checkedAt)

The contract accepts only 65-byte signatures with low s (at most half the curve order) and v of 27 or 28, which rules out malleated copies.

Events

event Locked(bytes32 indexed taskId, address indexed owner, address indexed breaker, uint96 amount, uint64 deadline, bytes32 termsHash);
event Released(bytes32 indexed taskId, address indexed breaker, uint96 amount, bytes32 exploitHash, uint64 checkedAt);
event Refunded(bytes32 indexed taskId, address indexed owner, uint96 amount);

Errors

ZeroAddress, ZeroMaxBounty (constructor) · TaskExists, ZeroBreaker, BadAmount, DeadlinePassed, AmountMismatch (lock) · NotLocked, CheckedAfterDeadline, BadSignature (release) · NotLocked, GraceNotOver (refund) · TransferFailed (token call failed, returned false, or the token address has no code).

Fees and gas

There is no fee anywhere in the contract: the full locked amount goes to exactly one of the two parties. Gas is paid in ETH on Robinhood Chain by whoever sends the transaction; SANCTRA's relayer sends release() for BREACHED verdicts.