Skip to content

Instantly share code, notes, and snippets.

@HarryR
Created April 5, 2023 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarryR/83b4adcd99b91276cc7b0e3d68c59a68 to your computer and use it in GitHub Desktop.
Save HarryR/83b4adcd99b91276cc7b0e3d68c59a68 to your computer and use it in GitHub Desktop.
import z3
s = z3.Solver()
bvp = 256
bvs = 2**bvp
balanceOf_signer = z3.BitVec('balanceOf_signer', bvp)
wad = z3.BitVec('wad', bvp)
reward = z3.BitVec('reward', bvp)
contract_balance = z3.Int('contract_balance') # z3.IntVal((10**18) * 4.48)
# Calculate balance of user after performing withdrawal
balanceOf_after = z3.BitVec('balanceOf_after', bvp)
s.add(balanceOf_after == balanceOf_signer - (wad + reward))
# Contract has a reasonable balance, say 500k ROSE
#s.add(contract_balance < z3.IntVal((10**18) * 500000))
# Must be able to perform 2 transfers
s.add(contract_balance >= z3.BV2Int(wad) + z3.BV2Int(reward))
# Contract current balance cannot exceed signer balance
s.add(balanceOf_signer < contract_balance)
#s.add(balanceOf_signer <= z3.BitVecVal((10**18) * 100))
# require(balanceOf[signer] >= wad + reward, "Insufficient Balance");
s.add(balanceOf_signer >= wad + reward)
s.add(balanceOf_after > balanceOf_signer)
s.check()
s.model()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment