Architecture
Package lifecycle
Five onchain states and the money that moves at each transition.
States
Open ──(last required accept + funding; auto or clientConfirm)──▶ Confirmed
Open ──(deadline missed / final expiry)──▶ Expired
Confirmed ──(releaseBalances, or review window passed)──▶ Released
Confirmed ──(cancelAfterConfirm, before event date)──▶ CancelledMoney by transition
| Transition | Credited |
|---|---|
| Confirm | Each accepted slot's deposit to its supplier; agency fee to the agency; unaccepted optional slots back to the client |
| Release | Each booked slot's balance to its supplier |
| Cancel after confirm | Unreleased balances back to the client |
| Expire | Earned hold fees to suppliers who accepted; the remainder to the client |
| Change that lowers the total | The excess back to the client immediately |
Invariant
Every unit funded is either still held for a package, credited to someone, or already claimed. Foundry invariant tests check that the contract's USDG balance always covers what it owes.