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

Revert CRA kick if a liquidation awaits settlement #977

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/base/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,13 @@ abstract contract Pool is Clone, ReentrancyGuard, Multicall, IPool {
* @dev update `reserveAuction.latestBurnEventEpoch` and burn event `timestamp` state
* @dev === Reverts on ===
* @dev 2 weeks not passed `ReserveAuctionTooSoon()`
* @dev unsettled liquidation `AuctionNotCleared()`
* @dev === Emit events ===
* @dev - `KickReserveAuction`
*/
function kickReserveAuction() external override nonReentrant {
_revertIfAuctionClearable(auctions, loans);

// start a new claimable reserve auction, passing in relevant parameters such as the current pool size, debt, balance, and inflator value
KickerActions.kickReserveAuction(
auctions,
Expand Down
41 changes: 41 additions & 0 deletions tests/forge/unit/ERC20Pool/ERC20PoolReserveAuction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,45 @@ contract ERC20PoolReserveAuctionNoFundsTest is ERC20HelperContract {
assertEq(_availableQuoteToken(), initialAvailableAmount - claimableTokens);
}

function testReserveAuctionUnsettledLiquidation() external {
// add reserves to the pool
changePrank(_actor2);
_quote.transfer(address(_pool), 1_000 * 1e18);
_assertReserveAuction({
reserves: 1_000 * 1e18,
claimableReserves : 1_000 * 1e18,
claimableReservesRemaining: 0,
auctionPrice: 0,
timeRemaining: 0
});
skip(2 hours);

// create an unsettled liquidation
_addInitialLiquidity({
from: _actor2,
amount: 12_000 * 1e18,
index: _i100_33
});
_drawDebt({
from: _actor3,
borrower: _actor3,
amountToBorrow: 8_000 * 1e18,
limitIndex: _i100_33,
collateralToPledge: 100 * 1e18,
newLup: _p100_33
});
_lenderKick({
from: _actor2,
index: _i100_33,
borrower: _actor3,
debt: 8_007.692307692307696000 * 1e18,
collateral: 100 * 1e18,
bond: 121.559490945280037502 * 1e18
});
skip(73 hours);

// confirm reserve auction may not be kicked
_assertReserveAuctionUnsettledLiquidation();
}

}
5 changes: 5 additions & 0 deletions tests/forge/utils/DSTestPlus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,11 @@ abstract contract DSTestPlus is Test, IPoolEvents {
_pool.kickReserveAuction();
}

function _assertReserveAuctionUnsettledLiquidation() internal {
vm.expectRevert(IPoolErrors.AuctionNotCleared.selector);
_pool.kickReserveAuction();
}

/**********************/
/*** Revert asserts ***/
/**********************/
Expand Down
Loading