Smart Contracts
Hook and settlement
Shade is implemented as a Uniswap v4 hook in contracts/src/ShadeHook.sol. Makers sign ShadeTypes.Order off-chain. A solver calls settleMatchedOrders, which checks EIP-712 signatures, consumes nonces, nets complementary flow at the pool mid, and routes leftovers through the PoolManager.
Source
contracts/src/ShadeTypes.sol
contracts/src/ShadeHook.sol
contracts/test/ShadeHook.t.solThe hook address must encode BEFORE_SWAP | AFTER_SWAP. Tests and script/DeployShadeHook.s.sol mine that prefix with HookMiner. Robinhood Chain deployment addresses will replace this once the hook is broadcast.
Settlement interface
function settleMatchedOrders(
Order calldata orderA,
bytes calldata sigA,
Order calldata orderB,
bytes calldata sigB,
PoolKey calldata key,
uint256 executedPrice
) external;
function cancelOrder(uint256 nonce) external;Revert conditions
- Invalid or expired signature.
- Nonce already cancelled or filled.
- Solver price more than 1 bps from the pool mid.
- Orders that are not complementary, or tokens that are not the pool pair.
Events
OrderSettled(bytes32 orderHashA, bytes32 orderHashB, uint256 executedPrice) is emitted on a fill.OrderCancelled(address maker, uint256 nonce) is emitted when a maker invalidates a nonce.