Contracts overview
The CashScript covenants that enforce intents and liquidity, what each guarantees, and which are routed to today.
All protocol rules live in CashScript covenants (pragma cashscript ^0.12.0) under contracts-bch-swap/contracts. Everything off-chain is replaceable; these are not.
Routed today (V2)
| Contract | Role | Spend paths | Reference |
|---|---|---|---|
LimitOrderSwapV2 |
Fixed-price intent | fill(), cancel(), cancelEarly() |
Reference |
DutchAuctionSwapV2 |
Decaying-price intent (and TWAP slices) | fill(), cancel() |
Reference |
StrategyCovenantV2 |
Fixed-rate Mesh pool | fill(), dock() |
Reference |
Shared design rules
- Bind to your own index. Every V2 covenant checks
tx.outputs[this.activeInputIndex], never a fixed position. - Derive, don't trust. Amounts come from comparing inputs and outputs, not from arguments.
- Full funding or nothing. An intent can only be filled if its UTXO holds the whole sell amount.
- Refund everything. Exit paths return every sat and token the UTXO holds, so over- and under-funding are always recoverable.
- Chain time only. Times are compared against
tx.locktime/tx.time(MTP).
Not routed
| Contract | Status |
|---|---|
LimitOrderSwap, DutchAuctionSwap, StrategyCovenant (V1) |
Superseded. The server drops V1 pools on boot and rejects them at registration |
LimitOrderSwapWithFee, DutchAuctionSwapWithFee |
V1 fee variants; fees are now surplus outputs |
OracleStrategyCovenant, MultiPairRecyclingCovenant, DutchDecayStrategyCovenant, MeshStrategyWithSurplusCapture |
Research designs for advanced strategies |
Verification
cd contracts-bch-swap && npm run test:security:v2 # 39/39 on the VM
The suite replays the V1 drain patterns against V2 and checks index binding, funding edge cases, Dutch windows and multi-covenant composition.