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

invariant_reserves failure when take / bucketTake #1050

Merged
merged 10 commits into from
Jan 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler {
kickerReward += afterTakeVars.kickerBond - beforeTakeVars.kickerBond;
}

(uint256 inflator, ) = _pool.inflatorInfo();
ith-harvey marked this conversation as resolved.
Show resolved Hide resolved
reservesErrorMargin = Math.max(reservesErrorMargin, inflator/5e17);

// **RE7**: Reserves increase with the quote token paid by taker.
increaseInReserves += totalBalanceAfterTake - totalBalanceBeforeTake;

// **RE9**: Reserves unchanged by takes and bucket takes below TP(at the time of kick)
if (auctionInfo.auctionPrice < auctionInfo.debtToCollateral) {
if (auctionInfo.auctionPrice < Maths.min(auctionInfo.debtToCollateral, auctionInfo.neutralPrice)) {
increaseInReserves = 0;
decreaseInReserves = 0;
}
Expand Down Expand Up @@ -293,6 +296,8 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler {
if (auctionInfo.auctionPrice != 0 && auctionInfo.auctionPrice < 100) {
reservesErrorMargin = (beforeTakeVars.deposit - afterTakeVars.deposit) / auctionInfo.auctionPrice;
}
(uint256 inflator, ) = _pool.inflatorInfo();
ith-harvey marked this conversation as resolved.
Show resolved Hide resolved
reservesErrorMargin = Math.max(reservesErrorMargin, inflator/5e17);

// In case of bucket take, collateral is taken at bucket price.
uint256 takePrice = _priceAt(bucketIndex_);
Expand Down
Loading
Loading