-
Notifications
You must be signed in to change notification settings - Fork 9
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
Sherlock-111: Wrong Inflator used in calculating HTP to determine accrualIndex #916
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -874,8 +874,8 @@ contract ERC721PoolCollateralTest is ERC721HelperContract { | |||
kickMomp: 0.000000099836282890 * 1e18, | |||
totalBondEscrowed: 5.907892673985352325 * 1e18, | |||
auctionPrice: 0.000004621809202112 * 1e18, | |||
debtInAuction: 439.681348088864224563 * 1e18, | |||
thresholdPrice: 385.774399985858744479 * 1e18, | |||
debtInAuction: 467.777790958346588935 * 1e18, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this surprised me at first, but makes sense as less deposit was available in higher priced buckets to swap for collateral
); | ||
} | ||
(, uint256 maxThresholdPrice,) = _pool.loansInfo(); | ||
maxThresholdPrice = Maths.wdiv(maxThresholdPrice, inflator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I don't think we need to wdiv
and then wmul
again to obtain HTP, _pool.loansInfo()
already does this
function loansInfo() external view override returns (address, uint256, uint256) {
return (
Loans.getMax(loans).borrower,
Maths.wmul(Loans.getMax(loans).thresholdPrice, inflatorState.inflator),
Loans.noOfLoans(loans)
);
}
, so I suggest getting rid of (uint256 inflator, ) = _pool.inflatorInfo();
and simplify this to
// get TP of worst loan and poolDebt
(, uint256 htp,) = _pool.loansInfo();
(, uint256 poolDebt, , ) = _pool.debtInfo();
uint256 accrualIndex;
if (htp > MAX_PRICE) accrualIndex = 1; // if HTP is over the highest price bucket then no buckets earn interest
else if (htp < MIN_PRICE) accrualIndex = MAX_FENWICK_INDEX; // if HTP is under the lowest price bucket then all buckets earn interest
else accrualIndex = _poolInfo.priceToIndex(htp);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 64e811a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concern about unused param/variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of change
High level
interestEarningDeposit
calculation.Contract size (same as pre change)
Pre Change
N/A
Post Change
N/A
Gas usage (same as pre change)
Pre Change
N/A
Post Change
N/A