In-depth lesson · Smart contracts
Typical fixes
Every point the Smart contracts reports back under this heading, best-backed first, each with the reports it is seen in.
-
Add a non-reentrancy modifier and update state before external calls.
Seen in 18 reports
-
Update state before external calls and apply a reentrancy guard across all entry points including callbacks.
Seen in 11 reports
-
Use a safe transfer helper that checks the return value and reverts on failure.
Seen in 6 reports
-
Require a caller-supplied minimum output, maximum input and deadline on every swap, mint, redeem and liquidity operation.
Seen in 5 reports
-
Enforce a minimum output or slippage bound on every strategy allocation and redemption.
Seen in 5 reports
-
Use a manipulation-resistant price feed with a freshness check and avoid single-block spot prices.
Seen in 5 reports
-
Revert on oracle timeout instead of returning a stale or huge price, and update accumulators in every state changing function.
Seen in 3 reports
-
Restrict initialise functions to the deployer or use an initializer modifier that prevents nested calls.
-
Use safe transfer and safe approve wrappers that handle tokens returning false or no value.
-
Measure the balance before and after a transfer and use the difference rather than the requested amount.
Seen in 1 report
-
Add a reentrancy guard to the recover-ERC20 function.
Seen in 1 report