Coming up with an invariant
Can't think of any tests? Maybe one of these will spark some inspiration!
Ante Tests are single-failure tests of on-chain protocol invariants. Invariants should reflect fundamental guarantees that a protocol should satisfy.
Take care when defining your project's invariants.
Only define invariants you believe will never fail.
It's the guarantee you are making and potentially staking ETH on.
Here is an non-exhaustive list of invariants you might decide to write an Ante Test for (in no particular order):
  • "Rug" test – check that contract-controlled assets are not drained
  • Plunge protection test – check that contract assets do not drop below some threshold
  • Peg test – check to see that two pegged assets stay pegged in price
    • Note: in order to avoid flash loan manipulation of the Ante Test, this should be implemented against time-weighted average prices (TWAP) rather than spot prices
  • Solvency test – Collateral asset value exceeds liabilities by some factor
  • Bonding curve test – check that the bonding curve calculation (e.g. x*y=k) holds for an automated market maker (AMM) protocol
  • APY guarantee test – check that actual rewards issued by a contract over a given time period exceeds the APY rate advertised by the protocol
  • DAO implementation test – check that a proposal passed by a DAO was actually implemented
    • Checking outcomes can be tricky given the complexity and heterogeneity of outcomes. Defining a narrow test can help manage some of the complexity
    • Alternatively, this can be made generalized by having the DAO vote again on their satisfaction with the implementation outcome and having the Ante Test check the vote result
  • Access test – check that funds can be withdrawn from contract in an expected manner
  • Market cap test – check that the total value of contract assets exceeds some threshold
  • Volume test – check that at least X unique wallets/transactions/etc. use a given protocol over a given time period
These are just some of the many possible Ante Tests that could be written. Happy writing!
Have an idea for a test? We'd love to hear about it! Message us on Twitter/Discord or drop us a line at [email protected]!
Copy link