ERC20FlashMint.spec 1004 B

123456789101112131415161718192021222324252627282930
  1. import "erc20methods.spec"
  2. methods {
  3. maxFlashLoan(address) returns(uint256) envfree
  4. _burn(address account, uint256 amount) returns(bool) => specBurn(account, amount)
  5. }
  6. ghost mapping(address => uint256) trackedBurnAmount;
  7. // returns is needed to overcome current CVL limitations: "could not type expression "specBurn(account,amount)", message: A summary must return a simple type, but specBurn(account,amount) returns 'void'"
  8. function specBurn(address account, uint256 amount) returns bool {
  9. trackedBurnAmount[account] = amount;
  10. return true;
  11. }
  12. // Check that if flashLoan() call is successful, then proper amount of tokens was burnt(fee + flashLoan amount)
  13. rule letsWatchItBurns(env e) {
  14. address receiver;
  15. address token;
  16. uint256 amount;
  17. bytes data;
  18. uint256 feeBefore = flashFee(e, token, amount);
  19. flashLoan(e, receiver, token, amount, data);
  20. uint256 burned = trackedBurnAmount[receiver];
  21. assert to_mathint(amount + feeBefore) == burned, "cheater";
  22. }