aave-protocol-v2/specs/UserConfiguration.spec

67 lines
2.3 KiB
RPMSpec
Raw Normal View History

2020-10-14 21:59:12 +00:00
methods {
2020-12-03 15:20:11 +00:00
setBorrowing(uint256, bool) envfree
setUsingAsCollateral(uint256, bool) envfree
isUsingAsCollateralOrBorrowing(uint256) returns bool envfree
isBorrowing(uint256) returns bool envfree
isUsingAsCollateral(uint256) returns bool envfree
isBorrowingAny() returns bool envfree
isEmpty() returns bool envfree
2020-10-14 21:59:12 +00:00
}
2020-12-03 15:20:11 +00:00
invariant empty(uint256 reserveIndex)
isEmpty() => !isBorrowingAny() && !isUsingAsCollateralOrBorrowing(reserveIndex)
2020-10-14 21:59:12 +00:00
2020-12-03 15:20:11 +00:00
invariant notEmpty(uint256 reserveIndex)
(isBorrowingAny() || isUsingAsCollateral(reserveIndex)) => !isEmpty()
2020-10-14 21:59:12 +00:00
2020-12-03 15:20:11 +00:00
invariant borrowing(uint256 reserveIndex )
isBorrowing(reserveIndex) => isBorrowingAny()
2020-10-14 21:59:12 +00:00
2020-12-03 15:20:11 +00:00
invariant collateralOrBorrowing(uint256 reserveIndex )
(isUsingAsCollateral(reserveIndex) || isBorrowing(reserveIndex)) <=> isUsingAsCollateralOrBorrowing(reserveIndex)
2020-10-14 21:59:12 +00:00
2020-12-03 15:20:11 +00:00
rule setBorrowing(uint256 reserveIndex, bool borrowing)
2020-10-14 21:59:12 +00:00
{
require reserveIndex < 128;
2020-12-03 15:20:11 +00:00
setBorrowing(reserveIndex, borrowing);
assert isBorrowing(reserveIndex) == borrowing, "unexpected result";
2020-10-14 21:59:12 +00:00
}
2020-12-03 15:20:11 +00:00
rule setBorrowingNoChangeToOther(uint256 reserveIndex, uint256 reserveIndexOther, bool borrowing)
2020-10-14 21:59:12 +00:00
{
require reserveIndexOther != reserveIndex;
require reserveIndexOther < 128 && reserveIndex < 128;
2020-12-03 15:20:11 +00:00
bool otherReserveBorrowing = isBorrowing(reserveIndexOther);
bool otherReserveCollateral = isUsingAsCollateral(reserveIndexOther);
2020-10-14 21:59:12 +00:00
2020-12-03 15:20:11 +00:00
setBorrowing(reserveIndex, borrowing);
assert otherReserveBorrowing == isBorrowing(reserveIndexOther) &&
otherReserveCollateral == isUsingAsCollateral(reserveIndexOther), "changed to other reserve";
2020-10-14 21:59:12 +00:00
}
2020-12-03 15:20:11 +00:00
rule setUsingAsCollateral(uint256 reserveIndex, bool usingAsCollateral)
2020-10-14 21:59:12 +00:00
{
require reserveIndex < 128;
2020-12-03 15:20:11 +00:00
setUsingAsCollateral(reserveIndex, usingAsCollateral);
assert isUsingAsCollateral(reserveIndex) == usingAsCollateral, "unexpected result";
2020-10-14 21:59:12 +00:00
}
2020-12-03 15:20:11 +00:00
rule setUsingAsCollateralNoChangeToOther(uint256 reserveIndex, uint256 reserveIndexOther, bool usingAsCollateral)
2020-10-14 21:59:12 +00:00
{
require reserveIndexOther != reserveIndex;
require reserveIndexOther < 128 && reserveIndex < 128;
2020-12-03 15:20:11 +00:00
bool otherReserveBorrowing = isBorrowing(reserveIndexOther);
bool otherReserveCollateral = isUsingAsCollateral(reserveIndexOther);
2020-10-14 21:59:12 +00:00
2020-12-03 15:20:11 +00:00
setUsingAsCollateral(reserveIndex, usingAsCollateral);
assert otherReserveBorrowing == isBorrowing(reserveIndexOther) &&
otherReserveCollateral == isUsingAsCollateral(reserveIndexOther), "changed to other reserve";
2020-10-14 21:59:12 +00:00
}