The example below is the shape of almost every state-changing function we write: checks, then effects, then interactions, with an event at the end. It is simple on purpose: in larger code, an external call made before the state update is how reentrancy bugs get in.
function redeem(uint256 shares, address receiver) external nonReentrant returns (uint256 assets) {
if (shares == 0) revert ZeroShares();
assets = previewRedeem(shares);
if (assets == 0) revert ZeroAssets();
_burn(msg.sender, shares);
totalManaged -= assets;
asset.safeTransfer(receiver, assets);
emit Withdraw(msg.sender, receiver, msg.sender, assets, shares);
}
And this is the kind of property we test with an invariant: whatever sequence of deposits, withdrawals and transfers the fuzzer tries, the vault never owes more than it holds.
function invariant_vaultIsSolvent() public view {
assertGe(asset.balanceOf(address(vault)), vault.totalAssets(), "vault owes more than it holds");
}
function invariant_supplyMatchesBalances() public view {
assertEq(vault.totalSupply(), handler.sumOfBalances(), "share supply drifted");
}
Every contract we deliver comes with a test report (coverage, fuzz runs, invariant runs), the static-analysis results with each finding resolved or explained, deployment scripts and a short operations runbook. When a review pass is in the proposal, its checklist is delivered too.
Before mainnet we check:
- Constructor and initializer arguments match the specification, and every implementation contract has its initializers disabled.
- Every admin, minter, pauser and upgrader role is held by your multisig, and the deployer address holds no role.
- Source code is verified on the block explorer for every deployed address.
- For an upgrade, the storage layout matches the previous version, and the timelock delay is the one in the specification.
- Monitoring alerts are live before the contract accepts funds.
- New contracts that will hold value start with deposit caps, raised as they prove themselves in production.