Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = "aave-v4"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.13"
dependencies = ["z3-solver>=4.15.7.0"]

[dependency-groups]
dev = ["ruff>=0.15.0"]

[tool.ruff.format]
quote-style = "single"
29 changes: 0 additions & 29 deletions tests/misc/liquidity_growth.py

This file was deleted.

44 changes: 0 additions & 44 deletions tests/misc/share_assets_conversion.py

This file was deleted.

58 changes: 0 additions & 58 deletions tests/misc/supply_share_price_deficit.py

This file was deleted.

87 changes: 0 additions & 87 deletions tests/misc/supply_share_price_fees.py

This file was deleted.

37 changes: 0 additions & 37 deletions tests/misc/supply_share_price_repay.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from z3 import *
from commons import *

s = Optimize()

UINT256_MAX = IntVal(2**256 - 1)
RAY = IntVal(10**27)
SECONDS_PER_YEAR = IntVal(365 * 24 * 60 * 60)
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated

rate = IntVal(2**96 - 1)
lastUpdateTimestamp = IntVal(1)
currentTimestamp = Int("currentTimestamp")
currentTimestamp = Int('currentTimestamp')
elapsed = currentTimestamp - lastUpdateTimestamp

s.add(elapsed >= 0)
Expand All @@ -19,4 +18,4 @@

assert s.check() == sat
m = s.model()
print("currentTimestamp max =", m[currentTimestamp])
print('currentTimestamp max =', m[currentTimestamp])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can create a function in commons called maximize, similar to proveValid, wdyt?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea ty, lmk wdyt of the addition

38 changes: 24 additions & 14 deletions tests/misc/z3/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ def fromRayUp(a):
def toRay(a):
return a * RAY


def min(a, b):
return If(a <= b, a, b)


def percentMulUp(value, percentage):
return (value * percentage + PERCENTAGE_FACTOR - 1) / PERCENTAGE_FACTOR


def percentMulDown(value, percentage):
return (value * percentage) / PERCENTAGE_FACTOR


def toAddedSharesDown(assets, totalAddedAssets, addedShares):
return mulDivDown(
assets, addedShares + VIRTUAL_SHARES, totalAddedAssets + VIRTUAL_ASSETS
Expand Down Expand Up @@ -102,39 +112,39 @@ def toValue(amount, decimals, price):


def proveValid(s, propertyDescription, property, assumptions=[], variables=[]):
propertyDescriptionOutput = f"-- VALID Property: {propertyDescription} --"
print("=" * len(propertyDescriptionOutput))
propertyDescriptionOutput = f'-- VALID Property: {propertyDescription} --'
print('=' * len(propertyDescriptionOutput))
print(propertyDescriptionOutput)

result = s.check(Not(property), *assumptions)
if result == sat:
print("❌ Property is not valid:")
print('❌ Property is not valid:')
print(s.model())
for variable, variableName in variables:
print(f"{variableName}: {s.model().eval(variable)}")
print(f'{variableName}: {s.model().eval(variable)}')
elif result == unsat:
print(f"✅ Property is valid.")
print(f'✅ Property is valid.')
elif result == unknown:
print("❓ Timed out or unknown.")
print('❓ Timed out or unknown.')

print("=" * len(propertyDescriptionOutput))
print('=' * len(propertyDescriptionOutput))


def proveSatisfiable(s, propertyDescription, property, assumptions=[], variables=[]):
propertyDescriptionOutput = f"-- SATISFIABLE Property: {propertyDescription} --"
print("=" * len(propertyDescriptionOutput))
propertyDescriptionOutput = f'-- SATISFIABLE Property: {propertyDescription} --'
print('=' * len(propertyDescriptionOutput))
print(propertyDescriptionOutput)

result = s.check(property, *assumptions)
if result == sat:
print("✅ Property is satisfiable")
print('✅ Property is satisfiable')
m = s.model()
print(m)
for variable, variableName in variables:
print(f"{variableName}: {m.eval(variable)}")
print(f'{variableName}: {m.eval(variable)}')
elif result == unsat:
print("❌ Property is unsatisfiable.")
print('❌ Property is unsatisfiable.')
elif result == unknown:
print("❓ Timed out or unknown.")
print('❓ Timed out or unknown.')

print("=" * len(propertyDescriptionOutput))
print('=' * len(propertyDescriptionOutput))
Loading
Loading