Docs
How a deal works
Lifecycle, states, and who can call what.
Lifecycle
- Lock. The payer calls
createDealon the DealFactory with the payee, asset, amount, mode, deadline and one or more tranches. The factory deploys a new Deal clone and moves the earnest into it in the same transaction. - Accept. The payee calls
accept. If a payee bond is set, it is posted now. Before acceptance the payer maycancelfor a full refund. - Condition. In Metric mode, the Terms are read live. In Handshake mode, the payee calls
markDeliveredand the payer reviews. - Settle. Anyone calls
settle(trancheIndex). The contract releases to the payee, minus the 1 % fee, or refunds the payer, according to the rules below.
Each Deal is its own contract. Its parameters cannot change after creation. The factory holds no funds.
States
| State | Meaning |
|---|---|
| Open | Created, earnest locked, payee has not accepted. The payer may cancel. |
| Active | Accepted by the payee, or a bounty. Terms are live. |
| Delivered | Handshake only. The payee marked the work delivered. The 72 h review window is running. |
| Settled | Finished, and at least one amount was released to the payee. |
| Refunded | Finished, and nothing was released except a possible kill fee. Includes cancelled and rejected deals. |
| Expired | The payee never accepted and the deadline passed. The earnest was returned. |
Bounties have no payee to accept, so they start in Active. See Open bounties.
Who can call what
| Function | Caller | When | Effect |
|---|---|---|---|
accept | Payee | Open, before the deadline | Posts the bond if set. State becomes Active. |
cancel | Payer | Open, named payee only | Full refund. State becomes Refunded. |
markDelivered | Payee | Handshake, Active, before the deadline | State becomes Delivered. Review window starts. |
acceptDelivery | Payer | Delivered | Releases to the payee. State becomes Settled. |
reject | Payer | Delivered, inside 72 h | Kill fee to the payee, rest refunded. State becomes Refunded. |
settle(trancheIndex) | Anyone | See below | Releases or refunds. |
claim(trancheIndex) | Anyone | Bounty, Active, Term true | Pays the caller. |
observe(trancheIndex) | Anyone | Any time | Records an observation for Terms that measure over time. |
What settle does
settle reads the deal at the moment it is called.
- Open, past the deadline. Full refund to the payer. State becomes Expired.
- Metric, Term true. The tranche is released to the payee, minus the fee. This also works after the deadline, as long as nobody has refunded the tranche first.
- Metric, Term false, past the deadline. The tranche is refunded to the payer.
- Metric, Term false, before the deadline. Reverts with
ConditionNotMet. - Handshake, Delivered, 72 h passed. Released to the payee. Silence means release.
- Handshake, Active, past the deadline. Refunded to the payer. The payee bond, if any, goes to the payer.
"Past the deadline" means the block timestamp is strictly greater than the deadline. At the deadline second itself, the deal is still running.
Payees should call settle as soon as their Term is true. Once the deadline has passed, anyone, including the payer, can call settle the moment the Term reads false, and that refund is final.
Final accounting
A Deal finishes when every tranche is closed. If anything was released, the final state is Settled. If nothing was, it is Refunded. A posted payee bond is returned or forfeited at this point. See Payee bond.
History
Every Deal stores its own history on-chain: creation, acceptance, delivery, each release and refund, bond movements. The deal page reads it directly, so no indexer is needed.