Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding liquidate fix #653

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
2 changes: 2 additions & 0 deletions certora/confs/AccrueInterest.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
],
"verify": "MorphoHarness:certora/specs/AccrueInterest.spec",
"prover_args": [
"-depth 3",
"-smt_hashingScheme plaininjectivity",
"-mediumTimeout 30"
],
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Accrue Interest"
}
1 change: 1 addition & 0 deletions certora/confs/AssetsAccounting.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"verify": "MorphoHarness:certora/specs/AssetsAccounting.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Assets Accounting"
}
1 change: 1 addition & 0 deletions certora/confs/ConsistentState.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"verify": "MorphoHarness:certora/specs/ConsistentState.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Consistent State"
}
1 change: 1 addition & 0 deletions certora/confs/ExactMath.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"-smt_hashingScheme plaininjectivity",
"-mediumTimeout 30"
],
"server": "production",
"msg": "Morpho Blue Exact Math"
}
1 change: 1 addition & 0 deletions certora/confs/Health.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"prover_args": [
"-smt_hashingScheme plaininjectivity"
],
"server": "production",
"msg": "Morpho Blue Health"
}
1 change: 1 addition & 0 deletions certora/confs/LibSummary.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"verify": "MorphoHarness:certora/specs/LibSummary.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Lib Summary"
}
1 change: 1 addition & 0 deletions certora/confs/Liveness.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"verify": "MorphoInternalAccess:certora/specs/Liveness.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Liveness"
}
1 change: 1 addition & 0 deletions certora/confs/RatioMath.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"-mediumTimeout 30",
"-timeout 3600"
],
"server": "production",
"msg": "Morpho Blue Ratio Math"
}
1 change: 1 addition & 0 deletions certora/confs/Reentrancy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"prover_args": [
"-enableStorageSplitting false"
],
"server": "production",
"msg": "Morpho Blue Reentrancy"
}
1 change: 1 addition & 0 deletions certora/confs/Reverts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"verify": "MorphoHarness:certora/specs/Reverts.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Reverts"
}
1 change: 1 addition & 0 deletions certora/confs/Transfer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
],
"verify": "TransferHarness:certora/specs/Transfer.spec",
"rule_sanity": "basic",
"server": "production",
"msg": "Morpho Blue Transfer"
}
9 changes: 6 additions & 3 deletions src/Morpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,15 @@ contract Morpho is IMorphoStaticTyping {
if (seizedAssets > 0) {
uint256 seizedAssetsQuoted = seizedAssets.mulDivUp(collateralPrice, ORACLE_PRICE_SCALE);

repaidShares = seizedAssetsQuoted.wDivUp(liquidationIncentiveFactor).toSharesDown(
repaidShares = seizedAssetsQuoted.wDivUp(liquidationIncentiveFactor).toSharesUp(
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
market[id].totalBorrowAssets, market[id].totalBorrowShares
);
} else {
seizedAssets = repaidShares.toAssetsDown(market[id].totalBorrowAssets, market[id].totalBorrowShares)
.wMulDown(liquidationIncentiveFactor).mulDivDown(ORACLE_PRICE_SCALE, collateralPrice);
uint256 repayIncentive = repaidShares.toAssetsDown(
market[id].totalBorrowAssets, market[id].totalBorrowShares
).wMulDown(liquidationIncentiveFactor);

seizedAssets = repayIncentive.mulDivDown(ORACLE_PRICE_SCALE, collateralPrice);
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
}
}
uint256 repaidAssets = repaidShares.toAssetsUp(market[id].totalBorrowAssets, market[id].totalBorrowShares);
Expand Down
Loading