diff --git a/src/PoolInfoUtils.sol b/src/PoolInfoUtils.sol index a2595afec..7013f88a7 100644 --- a/src/PoolInfoUtils.sol +++ b/src/PoolInfoUtils.sol @@ -35,6 +35,16 @@ import { PoolCommons } from './libraries/external/PoolCommons.sol'; */ contract PoolInfoUtils { + /** + * @notice Struct contianing local variables used in `auctionStatus` to get around stack size limitations. + * @param lup The price value of the current `Lowest Utilized Price` (`LUP`) bucket, in `WAD` units. + * @param poolDebt Current amount of debt owed by borrowers in pool. (`WAD`). + */ + struct AuctionStatusLocalVars { + uint256 lup; + uint256 poolDebt; + } + /** * @notice Exposes status of a liquidation auction. * @param ajnaPool_ Address of `Ajna` pool. @@ -45,6 +55,9 @@ contract PoolInfoUtils { * @return isCollateralized_ `True` if loan is collateralized. * @return price_ Current price of the auction. (`WAD`) * @return neutralPrice_ Price at which bond holder is neither rewarded nor penalized. (`WAD`) + * @return referencePrice_ Price used to determine auction start price. (`WAD`) + * @return thresholdPrice_ Threshold Price when liquidation was started. (`WAD`) + * @return bondFactor_ The factor used for calculating bond size. (`WAD`) */ function auctionStatus(address ajnaPool_, address borrower_) external @@ -55,23 +68,63 @@ contract PoolInfoUtils { uint256 debtToCover_, bool isCollateralized_, uint256 price_, - uint256 neutralPrice_ + uint256 neutralPrice_, + uint256 referencePrice_, + uint256 thresholdPrice_, + uint256 bondFactor_ ) { - IPool pool = IPool(ajnaPool_); - uint256 referencePrice; - ( , , , kickTime_, referencePrice, neutralPrice_, , , ) = pool.auctionInfo(borrower_); + AuctionStatusLocalVars memory vars; + ( , + bondFactor_, + , + kickTime_, + referencePrice_, + neutralPrice_, + thresholdPrice_, , , ) = IPool(ajnaPool_).auctionInfo(borrower_); + if (kickTime_ != 0) { (debtToCover_, collateral_, ) = this.borrowerInfo(ajnaPool_, borrower_); - - (uint256 poolDebt,,,) = pool.debtInfo(); - uint256 lup_ = _priceAt(pool.depositIndex(poolDebt)); - isCollateralized_ = _isCollateralized(debtToCover_, collateral_, lup_, pool.poolType()); - price_ = _auctionPrice(referencePrice, kickTime_); + (vars.poolDebt,,,) = IPool(ajnaPool_).debtInfo(); + vars.lup = _priceAt(IPool(ajnaPool_).depositIndex(vars.poolDebt)); + isCollateralized_ = _isCollateralized(debtToCover_, collateral_, vars.lup, IPool(ajnaPool_).poolType()); + + price_ = _auctionPrice(referencePrice_, kickTime_); } } + /** + * @notice Returns details of an auction for a given borrower address. + * @dev Calls and returns all values from pool.auctionInfo(). + * @param ajnaPool_ Address of `Ajna` pool. + * @param borrower_ Address of the borrower that is liquidated. + * @return kicker_ Address of the kicker that is kicking the auction. + * @return bondFactor_ The factor used for calculating bond size. + * @return bondSize_ The bond amount in quote token terms. + * @return kickTime_ Time the liquidation was initiated. + * @return referencePrice_ Price used to determine auction start price. + * @return neutralPrice_ `Neutral Price` of auction. + * @return thresholdPrice_ Threshold Price when liquidation was started. + * @return head_ Address of the head auction. + * @return next_ Address of the next auction in queue. + * @return prev_ Address of the prev auction in queue. + */ + function auctionInfo(address ajnaPool_, address borrower_) external view returns ( + address kicker_, + uint256 bondFactor_, + uint256 bondSize_, + uint256 kickTime_, + uint256 referencePrice_, + uint256 neutralPrice_, + uint256 thresholdPrice_, + address head_, + address next_, + address prev_ + ) { + return IPool(ajnaPool_).auctionInfo(borrower_); + } + /** * @notice Retrieves info of a given borrower in a given `Ajna` pool. * @param ajnaPool_ Address of `Ajna` pool. diff --git a/src/base/Pool.sol b/src/base/Pool.sol index ab4386066..e18dcbcef 100644 --- a/src/base/Pool.sol +++ b/src/base/Pool.sol @@ -746,6 +746,7 @@ abstract contract Pool is Clone, ReentrancyGuard, Multicall, IPool { uint256 kickTime_, uint256 referencePrice_, uint256 neutralPrice_, + uint256 thresholdPrice_, address head_, address next_, address prev_ @@ -758,6 +759,7 @@ abstract contract Pool is Clone, ReentrancyGuard, Multicall, IPool { liquidation.kickTime, liquidation.referencePrice, liquidation.neutralPrice, + liquidation.thresholdPrice, auctions.head, liquidation.next, liquidation.prev diff --git a/src/interfaces/pool/commons/IPoolState.sol b/src/interfaces/pool/commons/IPoolState.sol index 8dce78ccd..2b30991ac 100644 --- a/src/interfaces/pool/commons/IPoolState.sol +++ b/src/interfaces/pool/commons/IPoolState.sol @@ -16,6 +16,7 @@ interface IPoolState { * @return kickTime_ Time the liquidation was initiated. * @return referencePrice_ Price used to determine auction start price. * @return neutralPrice_ `Neutral Price` of auction. + * @return thresholdPrice_ Threshold Price when liquidation was started. * @return head_ Address of the head auction. * @return next_ Address of the next auction in queue. * @return prev_ Address of the prev auction in queue. @@ -30,6 +31,7 @@ interface IPoolState { uint256 kickTime_, uint256 referencePrice_, uint256 neutralPrice_, + uint256 thresholdPrice_, address head_, address next_, address prev_ diff --git a/tests/brownie/test_invariants.py b/tests/brownie/test_invariants.py index 41f4fdadd..2c77b31f9 100644 --- a/tests/brownie/test_invariants.py +++ b/tests/brownie/test_invariants.py @@ -166,7 +166,7 @@ def pool_buckets(self): def pool_debt_in_auction(self): auctioned_borrowers_debt = 0 for borrower in self.borrowers: - (_, _, _, kick_time, _, _, _, _, _, _) = self.pool.auctionInfo(borrower) + (_, _, _, kick_time, _, _, _, _, _, _, _) = self.pool.auctionInfo(borrower) if kick_time != 0: (borrower_debt, _, _) = self.pool.borrowerInfo(borrower) auctioned_borrowers_debt += borrower_debt @@ -185,7 +185,7 @@ def pool_auction_bonds(self): auction_bonds_locked = 0 for borrower in self.borrowers: - (_, _, bond_size, _, _, _, _, _, _, _) = self.pool.auctionInfo(borrower) + (_, _, bond_size, _, _, _, _, _, _, _, _) = self.pool.auctionInfo(borrower) auction_bonds_locked += bond_size # Invariant 8: sum of bonds across all auctions = sum of locked balances across all kickers = total bond escrowed accumulator @@ -202,7 +202,7 @@ def pool_loans_and_auctions(self): if borrower_debt != 0: borrowers_with_debt += 1 - (_, _, _, kick_time, _, _, _, _, _, _) = self.pool.auctionInfo(borrower) + (_, _, _, kick_time, _, _, _, _, _, _, _) = self.pool.auctionInfo(borrower) if kick_time != 0: number_of_auctions += 1 @@ -565,7 +565,7 @@ def rule_repay_debt(self, st_borrow_amount, st_borrower, st_sleep): def rule_kick_auction(self, st_borrow_amount, st_lender, st_borrower, st_kicker, st_sleep): # do not kick if already active - (_, _, _, kick_time, _, _, _, _, _, _) = self.pool.auctionInfo(borrowers[st_borrower]) + (_, _, _, kick_time, _, _, _, _, _, _, _) = self.pool.auctionInfo(borrowers[st_borrower]) if kick_time != 0: return @@ -605,7 +605,7 @@ def rule_take_auction(self, st_borrow_amount, st_take_amount, st_lender, st_borr success = True # kick if auction not kicked already - (_, _, _, kick_time, _, _, _, _, _, _) = self.pool.auctionInfo(borrowers[st_borrower]) + (_, _, _, kick_time, _, _, _, _, _, _, _) = self.pool.auctionInfo(borrowers[st_borrower]) if kick_time == 0: self.rule_kick_auction(st_borrow_amount, st_lender, st_borrower, st_kicker, st_sleep) diff --git a/tests/forge/invariants/ERC20Pool/handlers/BasicERC20PoolHandler.sol b/tests/forge/invariants/ERC20Pool/handlers/BasicERC20PoolHandler.sol index 8f5bac357..51c90a089 100644 --- a/tests/forge/invariants/ERC20Pool/handlers/BasicERC20PoolHandler.sol +++ b/tests/forge/invariants/ERC20Pool/handlers/BasicERC20PoolHandler.sol @@ -74,7 +74,7 @@ contract BasicERC20PoolHandler is UnboundedBasicERC20PoolHandler, BasicPoolHandl numberOfCalls['BBasicHandler.pledgeCollateral']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -92,7 +92,7 @@ contract BasicERC20PoolHandler is UnboundedBasicERC20PoolHandler, BasicPoolHandl numberOfCalls['BBasicHandler.pullCollateral']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -110,7 +110,7 @@ contract BasicERC20PoolHandler is UnboundedBasicERC20PoolHandler, BasicPoolHandl numberOfCalls['BBasicHandler.drawDebt']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -128,7 +128,7 @@ contract BasicERC20PoolHandler is UnboundedBasicERC20PoolHandler, BasicPoolHandl numberOfCalls['BBasicHandler.repayDebt']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -176,7 +176,7 @@ contract BasicERC20PoolHandler is UnboundedBasicERC20PoolHandler, BasicPoolHandl boundedAmount_ = constrictToRange(amountToBorrow_, MIN_DEBT_AMOUNT, MAX_DEBT_AMOUNT); // borrower cannot make any action when in auction - (uint256 kickTime, uint256 collateral,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime, uint256 collateral,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return boundedAmount_; // Pre Condition diff --git a/tests/forge/invariants/ERC20Pool/handlers/PanicExitERC20PoolHandler.sol b/tests/forge/invariants/ERC20Pool/handlers/PanicExitERC20PoolHandler.sol index 9903290a0..a6932f66d 100644 --- a/tests/forge/invariants/ERC20Pool/handlers/PanicExitERC20PoolHandler.sol +++ b/tests/forge/invariants/ERC20Pool/handlers/PanicExitERC20PoolHandler.sol @@ -60,7 +60,7 @@ contract PanicExitERC20PoolHandler is UnboundedLiquidationPoolHandler, Unbounded _actor = _borrowers[borrowerIndex_]; changePrank(_actor); - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(_actor); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(_actor); if (block.timestamp > kickTime + 72 hours) { numberOfCalls['BPanicExitPoolHandler.settleDebt']++; _settleAuction(_actor, numberOfBuckets); @@ -164,7 +164,7 @@ contract PanicExitERC20PoolHandler is UnboundedLiquidationPoolHandler, Unbounded function settleHeadAuction( uint256 skippedTime_ ) external useTimestamps skipTime(skippedTime_) writeLogs { - (, , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); + (, , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); if (headAuction != address(0)) { _settleAuction(headAuction, 10); _resetSettledAuction(headAuction, 0); @@ -218,7 +218,7 @@ contract PanicExitERC20PoolHandler is UnboundedLiquidationPoolHandler, Unbounded } function _resetSettledAuction(address borrower_, uint256 borrowerIndex_) internal { - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower_); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower_); if (kickTime == 0) { if (borrowerIndex_ != 0) _activeBorrowers.remove(borrowerIndex_); } diff --git a/tests/forge/invariants/ERC20Pool/handlers/SettleERC20PoolHandler.sol b/tests/forge/invariants/ERC20Pool/handlers/SettleERC20PoolHandler.sol index 65ef26888..5697fc8cd 100644 --- a/tests/forge/invariants/ERC20Pool/handlers/SettleERC20PoolHandler.sol +++ b/tests/forge/invariants/ERC20Pool/handlers/SettleERC20PoolHandler.sol @@ -62,7 +62,7 @@ contract SettleERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBas kickerIndex_ = constrictToRange(kickerIndex_, 0, LENDERS - 1); address kicker = _lenders[kickerIndex_]; - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower); // Kick auction if not already kicked if (kickTime == 0) { @@ -71,7 +71,7 @@ contract SettleERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBas _kickAuction(borrower); } - (,,, kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, kickTime,,,,,,) = _pool.auctionInfo(borrower); if (kickTime == 0) return; @@ -104,7 +104,7 @@ contract SettleERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBas actorIndex_ = constrictToRange(actorIndex_, 0, LENDERS - 1); address payer = _lenders[actorIndex_]; - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower); // Kick auction if not already kicked if (kickTime == 0) { @@ -113,7 +113,7 @@ contract SettleERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBas _kickAuction(borrower); } - (,,, kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, kickTime,,,,,,) = _pool.auctionInfo(borrower); if (kickTime == 0) return; @@ -225,7 +225,7 @@ contract SettleERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBas } } // **CT2**: Keep track of bucketIndex when borrower is removed from auction to check collateral added into that bucket - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower_); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower_); if (kickTime == 0 && collateral % 1e18 != 0 && _pool.poolType() == 1) { buckets.add(7388); lenderDepositTime[borrower_][7388] = block.timestamp; @@ -294,7 +294,7 @@ contract SettleERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBas } function _resetSettledAuction(address borrower_, uint256 borrowerIndex_) internal { - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower_); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower_); if (kickTime == 0) { if (borrowerIndex_ != 0) _activeBorrowers.remove(borrowerIndex_); } diff --git a/tests/forge/invariants/ERC20Pool/handlers/TradingERC20PoolHandler.sol b/tests/forge/invariants/ERC20Pool/handlers/TradingERC20PoolHandler.sol index 32878fffe..0a74f3036 100644 --- a/tests/forge/invariants/ERC20Pool/handlers/TradingERC20PoolHandler.sol +++ b/tests/forge/invariants/ERC20Pool/handlers/TradingERC20PoolHandler.sol @@ -171,7 +171,7 @@ contract TradingERC20PoolHandler is UnboundedLiquidationPoolHandler, UnboundedBa } function _resetSettledAuction(address borrower_, uint256 borrowerIndex_) internal { - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower_); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower_); if (kickTime == 0) { if (borrowerIndex_ != 0) _activeBorrowers.remove(borrowerIndex_); } diff --git a/tests/forge/invariants/ERC721Pool/handlers/BasicERC721PoolHandler.sol b/tests/forge/invariants/ERC721Pool/handlers/BasicERC721PoolHandler.sol index d207cd2d1..74c352e53 100644 --- a/tests/forge/invariants/ERC721Pool/handlers/BasicERC721PoolHandler.sol +++ b/tests/forge/invariants/ERC721Pool/handlers/BasicERC721PoolHandler.sol @@ -88,7 +88,7 @@ contract BasicERC721PoolHandler is UnboundedBasicERC721PoolHandler, BasicPoolHan numberOfCalls['BBasicHandler.pledgeCollateral']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -106,7 +106,7 @@ contract BasicERC721PoolHandler is UnboundedBasicERC721PoolHandler, BasicPoolHan numberOfCalls['BBasicHandler.pullCollateral']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -124,7 +124,7 @@ contract BasicERC721PoolHandler is UnboundedBasicERC721PoolHandler, BasicPoolHan numberOfCalls['BBasicHandler.drawDebt']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -142,7 +142,7 @@ contract BasicERC721PoolHandler is UnboundedBasicERC721PoolHandler, BasicPoolHan numberOfCalls['BBasicHandler.repayDebt']++; // borrower cannot make any action when in auction - (uint256 kickTime,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime,,,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return; // Prepare test phase @@ -209,7 +209,7 @@ contract BasicERC721PoolHandler is UnboundedBasicERC721PoolHandler, BasicPoolHan boundedAmount_ = constrictToRange(amountToBorrow_, MIN_DEBT_AMOUNT, MAX_DEBT_AMOUNT); // borrower cannot make any action when in auction - (uint256 kickTime, uint256 collateral, uint256 debt,,,) = _poolInfo.auctionStatus(address(_pool), _actor); + (uint256 kickTime, uint256 collateral, uint256 debt,,,,,,) = _poolInfo.auctionStatus(address(_pool), _actor); if (kickTime != 0) return boundedAmount_; // Pre Condition diff --git a/tests/forge/invariants/ERC721Pool/handlers/PanicExitERC721PoolHandler.sol b/tests/forge/invariants/ERC721Pool/handlers/PanicExitERC721PoolHandler.sol index 2051776b7..8d16ad0cb 100644 --- a/tests/forge/invariants/ERC721Pool/handlers/PanicExitERC721PoolHandler.sol +++ b/tests/forge/invariants/ERC721Pool/handlers/PanicExitERC721PoolHandler.sol @@ -58,7 +58,7 @@ contract PanicExitERC721PoolHandler is UnboundedLiquidationPoolHandler, Unbounde _actor = _borrowers[borrowerIndex_]; changePrank(_actor); - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(_actor); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(_actor); if (block.timestamp > kickTime + 72 hours) { numberOfCalls['BPanicExitPoolHandler.settleDebt']++; _settleAuction(_actor, numberOfBuckets); @@ -162,7 +162,7 @@ contract PanicExitERC721PoolHandler is UnboundedLiquidationPoolHandler, Unbounde function settleHeadAuction( uint256 skippedTime_ ) external useTimestamps skipTime(skippedTime_) writeLogs { - (, , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); + (, , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); if (headAuction != address(0)) { _settleAuction(headAuction, 10); _resetSettledAuction(headAuction, 0); @@ -216,7 +216,7 @@ contract PanicExitERC721PoolHandler is UnboundedLiquidationPoolHandler, Unbounde } function _resetSettledAuction(address borrower_, uint256 borrowerIndex_) internal { - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower_); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower_); if (kickTime == 0) { if (borrowerIndex_ != 0) _activeBorrowers.remove(borrowerIndex_); } diff --git a/tests/forge/invariants/ERC721Pool/handlers/unbounded/BaseERC721PoolHandler.sol b/tests/forge/invariants/ERC721Pool/handlers/unbounded/BaseERC721PoolHandler.sol index 09dd59ffd..70b249508 100644 --- a/tests/forge/invariants/ERC721Pool/handlers/unbounded/BaseERC721PoolHandler.sol +++ b/tests/forge/invariants/ERC721Pool/handlers/unbounded/BaseERC721PoolHandler.sol @@ -100,6 +100,7 @@ abstract contract BaseERC721PoolHandler is BaseHandler { uint256 kickTimeBefore, uint256 borrowerCollateralBefore, , , uint256 auctionPrice, + , , , ) = _poolInfo.auctionStatus(address(_erc721Pool), borrower_); try _erc721Pool.repayDebt(borrower_, amount_, 0, borrower_, 7388) { diff --git a/tests/forge/invariants/ERC721Pool/handlers/unbounded/UnboundedBasicERC721PoolHandler.sol b/tests/forge/invariants/ERC721Pool/handlers/unbounded/UnboundedBasicERC721PoolHandler.sol index a8dc16d13..80649c99f 100644 --- a/tests/forge/invariants/ERC721Pool/handlers/unbounded/UnboundedBasicERC721PoolHandler.sol +++ b/tests/forge/invariants/ERC721Pool/handlers/unbounded/UnboundedBasicERC721PoolHandler.sol @@ -113,7 +113,7 @@ abstract contract UnboundedBasicERC721PoolHandler is UnboundedBasicPoolHandler, numberOfCalls['UBBasicHandler.pledgeCollateral']++; (, uint256 borrowerCollateralBefore, ) = _pool.borrowerInfo(_actor); - (uint256 kickTimeBefore, , , , uint256 auctionPrice, ) =_poolInfo.auctionStatus(address(_erc721Pool), _actor); + (uint256 kickTimeBefore, , , , uint256 auctionPrice, , , , ) =_poolInfo.auctionStatus(address(_erc721Pool), _actor); // **R1**: Exchange rates are unchanged by pledging collateral for (uint256 bucketIndex = LENDER_MIN_BUCKET_INDEX; bucketIndex <= LENDER_MAX_BUCKET_INDEX; bucketIndex++) { @@ -186,7 +186,7 @@ abstract contract UnboundedBasicERC721PoolHandler is UnboundedBasicPoolHandler, (uint256 interestRate, ) = _erc721Pool.interestRateInfo(); (, uint256 borrowerCollateralBefore, ) = _pool.borrowerInfo(_actor); - (uint256 kickTimeBefore, , , , uint256 auctionPrice, ) =_poolInfo.auctionStatus(address(_erc721Pool), _actor); + (uint256 kickTimeBefore, , , , uint256 auctionPrice, , , , ) =_poolInfo.auctionStatus(address(_erc721Pool), _actor); try _erc721Pool.drawDebt(_actor, amount_, 7388, tokenIds) { // amount is rounded by pool to token scale @@ -215,7 +215,7 @@ abstract contract UnboundedBasicERC721PoolHandler is UnboundedBasicPoolHandler, numberOfCalls['UBBasicHandler.repayDebt']++; (uint256 borrowerDebt, uint256 borrowerCollateralBefore, ) = _poolInfo.borrowerInfo(address(_pool), _actor); - (uint256 kickTimeBefore, , , , uint256 auctionPrice, ) =_poolInfo.auctionStatus(address(_erc721Pool), _actor); + (uint256 kickTimeBefore, , , , uint256 auctionPrice, , , , ) =_poolInfo.auctionStatus(address(_erc721Pool), _actor); // ensure actor always has amount of quote to repay _ensureQuoteAmount(_actor, borrowerDebt + 10 * 1e18); diff --git a/tests/forge/invariants/PositionsAndRewards/handlers/BucketBankruptcyERC20PoolRewardsHandler.sol b/tests/forge/invariants/PositionsAndRewards/handlers/BucketBankruptcyERC20PoolRewardsHandler.sol index b1ab9eda6..318b67807 100644 --- a/tests/forge/invariants/PositionsAndRewards/handlers/BucketBankruptcyERC20PoolRewardsHandler.sol +++ b/tests/forge/invariants/PositionsAndRewards/handlers/BucketBankruptcyERC20PoolRewardsHandler.sol @@ -154,7 +154,7 @@ contract BucketBankruptcyERC20PoolRewardsHandler is UnboundedBasicERC20PoolHandl ) external useTimestamps useRandomActor(takerIndex_) skipTime(skippedTime_) writeLogs { address borrower = _borrowers[constrictToRange(borrowerIndex_, 0, _borrowers.length - 1)]; - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower); // Kick borrower if not already kicked if (kickTime == 0) { @@ -255,7 +255,7 @@ contract BucketBankruptcyERC20PoolRewardsHandler is UnboundedBasicERC20PoolHandl /*******************************/ function _resetSettledAuction(address borrower_, uint256 borrowerIndex_) internal { - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower_); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower_); if (kickTime == 0) { if (borrowerIndex_ != 0) _activeBorrowers.remove(borrowerIndex_); } diff --git a/tests/forge/invariants/base/BasicInvariants.t.sol b/tests/forge/invariants/base/BasicInvariants.t.sol index ad199a7ea..cacc1baba 100644 --- a/tests/forge/invariants/base/BasicInvariants.t.sol +++ b/tests/forge/invariants/base/BasicInvariants.t.sol @@ -321,7 +321,7 @@ abstract contract BasicInvariants is BaseInvariants { for (uint256 i = 0; i < actorCount; i++) { address borrower = IBaseHandler(_handler).actors(i); - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower); if (kickTime == 0) { (uint256 borrowerT0Debt, uint256 borrowerCollateral, ) = _pool.borrowerInfo(borrower); diff --git a/tests/forge/invariants/base/LiquidationInvariants.t.sol b/tests/forge/invariants/base/LiquidationInvariants.t.sol index 4788bcd48..addeba832 100644 --- a/tests/forge/invariants/base/LiquidationInvariants.t.sol +++ b/tests/forge/invariants/base/LiquidationInvariants.t.sol @@ -30,7 +30,7 @@ abstract contract LiquidationInvariants is BasicInvariants { for (uint256 i = 0; i < actorCount; i++) { address borrower = IBaseHandler(_handler).actors(i); - (, , , uint256 kickTime, , , , ,) = _pool.auctionInfo(borrower); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower); if (kickTime != 0) { (uint256 t0debt, , ) = _pool.borrowerInfo(borrower); @@ -62,7 +62,7 @@ abstract contract LiquidationInvariants is BasicInvariants { uint256 lockedBonds; for (uint256 i = 0; i < actorCount; i++) { address borrower = IBaseHandler(_handler).actors(i); - (, , uint256 bond, , , , , , ) = _pool.auctionInfo(borrower); + (, , uint256 bond, , , , , , , ) = _pool.auctionInfo(borrower); lockedBonds += bond; } require(lockedBonds == kickerLockedBond, "A2: bonds in auctions != than kicker locked bonds"); @@ -94,7 +94,7 @@ abstract contract LiquidationInvariants is BasicInvariants { for (uint256 i = 0; i < actorCount; i++) { address borrower = IBaseHandler(_handler).actors(i); - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower); if (kickTime != 0) borrowersKicked += 1; } @@ -108,7 +108,7 @@ abstract contract LiquidationInvariants is BasicInvariants { for (uint256 i = 0; i < actorCount; i++) { address borrower = IBaseHandler(_handler).actors(i); - (address kicker, , uint256 bondSize, , , , , , ) = _pool.auctionInfo(borrower); + (address kicker, , uint256 bondSize, , , , , , , ) = _pool.auctionInfo(borrower); (, uint256 lockedAmount) = _pool.kickerInfo(kicker); require(lockedAmount >= bondSize, "Auction Invariant A5"); diff --git a/tests/forge/invariants/base/handlers/LiquidationPoolHandler.sol b/tests/forge/invariants/base/handlers/LiquidationPoolHandler.sol index e2446cede..caaebc9e8 100644 --- a/tests/forge/invariants/base/handlers/LiquidationPoolHandler.sol +++ b/tests/forge/invariants/base/handlers/LiquidationPoolHandler.sol @@ -55,13 +55,13 @@ abstract contract LiquidationPoolHandler is UnboundedLiquidationPoolHandler, Bas address borrower; // try to take from head auction if any - (, , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); + (, , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); if (headAuction != address(0)) { (, uint256 auctionedCollateral, ) = _poolInfo.borrowerInfo(address(_pool), headAuction); borrower = headAuction; amount_ = auctionedCollateral / 2; - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower); // skip to make auction takeable if (block.timestamp - kickTime < 1 hours) { vm.warp(block.timestamp + 61 minutes); @@ -91,11 +91,11 @@ abstract contract LiquidationPoolHandler is UnboundedLiquidationPoolHandler, Bas address borrower; // try to take from head auction if any - (, , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); + (, , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); if (headAuction != address(0)) { borrower = headAuction; - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower); // skip to make auction takeable if (block.timestamp - kickTime < 1 hours) { vm.warp(block.timestamp + 61 minutes); @@ -126,7 +126,7 @@ abstract contract LiquidationPoolHandler is UnboundedLiquidationPoolHandler, Bas address borrower; // try to settle head auction if any - (, , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); + (, , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); if (headAuction != address(0)) { borrower = headAuction; } else { @@ -150,7 +150,7 @@ abstract contract LiquidationPoolHandler is UnboundedLiquidationPoolHandler, Bas borrower_ = actors[borrowerIndex_]; amount_ = constrictToRange(amount_, MIN_QUOTE_AMOUNT, MAX_QUOTE_AMOUNT); - ( , , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower_); + ( , , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower_); borrowerKicked_ = kickTime != 0; diff --git a/tests/forge/invariants/base/handlers/unbounded/BaseHandler.sol b/tests/forge/invariants/base/handlers/unbounded/BaseHandler.sol index d4f3fe302..da364d569 100644 --- a/tests/forge/invariants/base/handlers/unbounded/BaseHandler.sol +++ b/tests/forge/invariants/base/handlers/unbounded/BaseHandler.sol @@ -135,9 +135,9 @@ abstract contract BaseHandler is Test { address currentActor = _actor; // clear head auction if more than 72 hours passed - (, , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); + (, , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); if (headAuction != address(0)) { - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(headAuction); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(headAuction); if (block.timestamp - kickTime > 72 hours) { (uint256 auctionedDebt, , ) = _poolInfo.borrowerInfo(address(_pool), headAuction); @@ -446,7 +446,7 @@ abstract contract BaseHandler is Test { uint256 kickTimeBefore_, uint256 auctionPrice_ ) internal { - (uint256 kickTimeAfter, , , , , ) = _poolInfo.auctionStatus(address(_pool), borrower_); + (uint256 kickTimeAfter, , , , , , , , ) = _poolInfo.auctionStatus(address(_pool), borrower_); // **CT2**: Keep track of bucketIndex when borrower is removed from auction to check collateral added into that bucket if (kickTimeBefore_ != 0 && kickTimeAfter == 0 && borrowerCollateralBefore_ % 1e18 != 0) { @@ -491,7 +491,7 @@ abstract contract BaseHandler is Test { ) = _poolInfo.poolLoansInfo(address(_pool)); ( - , , , , , , + , , , , , , , address headAuction, , ) = _pool.auctionInfo(address(0)); @@ -599,11 +599,11 @@ abstract contract BaseHandler is Test { uint256 bondFactor; uint256 bondSize; uint256 neutralPrice; - (,,,,,, nextBorrower,,) = _pool.auctionInfo(address(0)); + (,,,,,,, nextBorrower,,) = _pool.auctionInfo(address(0)); while (nextBorrower != address(0)) { data = string(abi.encodePacked("Borrower ", Strings.toHexString(uint160(nextBorrower), 20), " Auction Details :")); printInNextLine(data); - (, bondFactor, bondSize, kickTime, referencePrice, neutralPrice,, nextBorrower,) = _pool.auctionInfo(nextBorrower); + (, bondFactor, bondSize, kickTime, referencePrice, neutralPrice,,, nextBorrower,) = _pool.auctionInfo(nextBorrower); printLog("Bond Factor = ", bondFactor); printLog("Bond Size = ", bondSize); diff --git a/tests/forge/invariants/base/handlers/unbounded/UnboundedLiquidationPoolHandler.sol b/tests/forge/invariants/base/handlers/unbounded/UnboundedLiquidationPoolHandler.sol index 75a872049..fdbbf300c 100644 --- a/tests/forge/invariants/base/handlers/unbounded/UnboundedLiquidationPoolHandler.sol +++ b/tests/forge/invariants/base/handlers/unbounded/UnboundedLiquidationPoolHandler.sol @@ -129,7 +129,7 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler { ) internal updateLocalStateAndPoolInterest { numberOfCalls['UBLiquidationHandler.takeAuction']++; - (address kicker, , , , , , , , ) = _pool.auctionInfo(borrower_); + (address kicker, , , , , , , , , ) = _pool.auctionInfo(borrower_); ( uint256 borrowerDebtBeforeTake, @@ -138,7 +138,7 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler { uint256 totalBondBeforeTake = _getKickerBond(kicker); uint256 totalBalanceBeforeTake = _quote.balanceOf(address(_pool)) * _pool.quoteTokenScale(); - (uint256 kickTimeBefore, , , , uint256 auctionPrice, ) = _poolInfo.auctionStatus(address(_pool), borrower_); + (uint256 kickTimeBefore, , , , uint256 auctionPrice, , , , ) = _poolInfo.auctionStatus(address(_pool), borrower_); // ensure actor always has the amount to take collateral _ensureQuoteAmount(taker_, 1e45); @@ -198,8 +198,8 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler { ) internal updateLocalStateAndPoolInterest { numberOfCalls['UBLiquidationHandler.bucketTake']++; - (address kicker, , , , , , , , ) = _pool.auctionInfo(borrower_); - ( , , , , uint256 auctionPrice, ) = _poolInfo.auctionStatus(address(_pool), borrower_); + (address kicker, , , , , , , , , ) = _pool.auctionInfo(borrower_); + ( , , , , uint256 auctionPrice, , , , ) = _poolInfo.auctionStatus(address(_pool), borrower_); uint256 auctionBucketIndex = auctionPrice < MIN_PRICE ? 7388 : (auctionPrice > MAX_PRICE ? 0 : _indexOf(auctionPrice)); LocalBucketTakeVars memory beforeBucketTakeVars = getBucketTakeInfo(bucketIndex_, kicker, _actor, auctionBucketIndex, borrower_); @@ -266,7 +266,7 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler { exchangeRateShouldNotChange[bucketIndex_] = true; // **CT2**: Keep track of bucketIndex when borrower is removed from auction to check collateral added into that bucket - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower_); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower_); if (kickTime == 0 && _pool.poolType() == 1) { buckets.add(auctionBucketIndex); if (beforeBucketTakeVars.borrowerLps < afterBucketTakeVars.borrowerLps) { @@ -380,7 +380,7 @@ abstract contract UnboundedLiquidationPoolHandler is BaseHandler { } } // **CT2**: Keep track of bucketIndex when borrower is removed from auction to check collateral added into that bucket - (, , , uint256 kickTime, , , , , ) = _pool.auctionInfo(borrower_); + (, , , uint256 kickTime, , , , , , ) = _pool.auctionInfo(borrower_); if (kickTime == 0 && collateral % 1e18 != 0 && _pool.poolType() == 1) { buckets.add(7388); lenderDepositTime[borrower_][7388] = block.timestamp; diff --git a/tests/forge/unit/ERC20Pool/ERC20DSTestPlus.sol b/tests/forge/unit/ERC20Pool/ERC20DSTestPlus.sol index 72ee70cba..d769f113a 100644 --- a/tests/forge/unit/ERC20Pool/ERC20DSTestPlus.sol +++ b/tests/forge/unit/ERC20Pool/ERC20DSTestPlus.sol @@ -177,13 +177,13 @@ abstract contract ERC20DSTestPlus is DSTestPlus, IERC20PoolEvents { // Settle any auctions and then repay debt for (uint i = 0; i < borrowers.length(); i++) { address borrower = borrowers.at(i); - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower); if (kickTime != 0) { changePrank(borrower); _pool.settle(borrower, bucketsUsed.length() + 1); // Settle again if not settled, this can happen when less reserves calculated with DEPOSIT_BUFFER and borrower is not fully settled - (,,, kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, kickTime,,,,,,) = _pool.auctionInfo(borrower); if (kickTime != 0) { _pool.settle(borrower, bucketsUsed.length() + 1); } diff --git a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsKick.t.sol b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsKick.t.sol index 5163e3171..bf830e164 100644 --- a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsKick.t.sol +++ b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsKick.t.sol @@ -603,7 +603,7 @@ contract ERC20PoolLiquidationKickFuzzyTest is ERC20FuzzyHelperContract { // kick all borrowers for (uint256 i = 0; i < noOfBorrowers; i++) { _pool.kick(_borrowers[i], 7_388); - (uint256 kickTime,,,,,) = _poolUtils.auctionStatus(address(_pool), _borrowers[i]); + (uint256 kickTime,,,,,,,,) = _poolUtils.auctionStatus(address(_pool), _borrowers[i]); // ensure borrower is kicked assertEq(kickTime, block.timestamp); diff --git a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsLenderKick.t.sol b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsLenderKick.t.sol index ee7e375fa..670a31fec 100644 --- a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsLenderKick.t.sol +++ b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsLenderKick.t.sol @@ -689,9 +689,9 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { address head; address next; address prev; - (, , , , , , head, next, prev) = _pool.auctionInfo(address(0)); + (, , , , , , , head, next, prev) = _pool.auctionInfo(address(0)); assertEq(head, _borrower1); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, address(0)); @@ -722,11 +722,11 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { assertEq(borrower, address(0)); assertEq(thresholdPrice, 0); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, _borrower5); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, _borrower1); @@ -757,15 +757,15 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { assertEq(borrower, address(0)); assertEq(thresholdPrice, 0); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, _borrower5); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower1); assertEq(next, _borrower4); assertEq(prev, _borrower1); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, _borrower5); @@ -796,19 +796,19 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { assertEq(borrower, address(0)); assertEq(thresholdPrice, 0); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, _borrower5); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower1); assertEq(next, _borrower4); assertEq(prev, _borrower1); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower1); assertEq(next, _borrower3); assertEq(prev, _borrower5); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, _borrower4); @@ -839,23 +839,23 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { assertEq(borrower, address(0)); assertEq(thresholdPrice, 0); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, _borrower5); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower1); assertEq(next, _borrower4); assertEq(prev, _borrower1); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower1); assertEq(next, _borrower3); assertEq(prev, _borrower5); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, _borrower1); assertEq(next, _borrower2); assertEq(prev, _borrower4); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, _borrower3); @@ -924,23 +924,23 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { }) ); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, _borrower5); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower1); assertEq(next, _borrower4); assertEq(prev, _borrower1); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower1); assertEq(next, _borrower3); assertEq(prev, _borrower5); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, _borrower4); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, address(0)); @@ -987,23 +987,23 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { }) ); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower1); assertEq(next, _borrower5); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower1); assertEq(next, _borrower3); assertEq(prev, _borrower1); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, _borrower5); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); assertEq(head, _borrower1); assertEq(next, address(0)); assertEq(prev, address(0)); @@ -1050,23 +1050,23 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { }) ); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower5); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower5); assertEq(next, _borrower3); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower5); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, _borrower5); assertEq(next, address(0)); assertEq(prev, _borrower5); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); assertEq(head, _borrower5); assertEq(next, address(0)); assertEq(prev, address(0)); @@ -1113,23 +1113,23 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { }) ); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, _borrower3); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, _borrower3); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, _borrower3); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, _borrower3); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); assertEq(head, _borrower3); assertEq(next, address(0)); assertEq(prev, address(0)); @@ -1178,23 +1178,23 @@ contract ERC20PoolLiquidationsLenderKickAuctionTest is ERC20HelperContract { }) ); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower1); assertEq(head, address(0)); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower5); assertEq(head, address(0)); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower4); assertEq(head, address(0)); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower3); assertEq(head, address(0)); assertEq(next, address(0)); assertEq(prev, address(0)); - (, , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); + (, , , , , , , head, next, prev) = _pool.auctionInfo(_borrower2); assertEq(head, address(0)); assertEq(next, address(0)); assertEq(prev, address(0)); diff --git a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsScaled.t.sol b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsScaled.t.sol index 77eab2086..366a8bdf5 100644 --- a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsScaled.t.sol +++ b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsScaled.t.sol @@ -318,6 +318,7 @@ contract ERC20PoolLiquidationsScaledTest is ERC20DSTestPlus { uint256 auctionKickTime, uint256 auctionReferencePrice, uint256 auctionNeutralPrice, + uint256 auctionThresholdPrice, , , ) = _pool.auctionInfo(_borrower); @@ -373,7 +374,7 @@ contract ERC20PoolLiquidationsScaledTest is ERC20DSTestPlus { } // confirm LP were awarded to the kicker - (address kicker, , , uint256 kickTime, uint256 referencePrice, uint256 neutralPrice, , ,) = _pool.auctionInfo(_borrower); + (address kicker, , , uint256 kickTime, uint256 referencePrice, uint256 neutralPrice, uint256 thresholdPrice, , ,) = _pool.auctionInfo(_borrower); uint256 auctionPrice = _auctionPrice(referencePrice, kickTime); if (auctionPrice < neutralPrice) { uint256 kickerLP = _kickerLP(bucketId); @@ -444,7 +445,7 @@ contract ERC20PoolLiquidationsScaledTest is ERC20DSTestPlus { uint256 auctionDebt_, uint256 auctionCollateral_ ){ - (, , , uint256 kickTime, uint256 referencePrice, , , , ) = _pool.auctionInfo(_borrower); + (, , , uint256 kickTime, uint256 referencePrice, , uint256 thresholdPrice, , , ) = _pool.auctionInfo(_borrower); uint256 lastAuctionPrice = _auctionPrice(referencePrice, kickTime); (uint256 lastAuctionDebt, uint256 lastAuctionCollateral, ) = _poolUtils.borrowerInfo(address(_pool), _borrower); if (secondsToSkip != 0) { @@ -470,7 +471,7 @@ contract ERC20PoolLiquidationsScaledTest is ERC20DSTestPlus { } function _kickerLP(uint256 bucketId) internal view returns (uint256) { - (address kicker, , , , , , , , ) = _pool.auctionInfo(_borrower); + (address kicker, , , , , , , , , ) = _pool.auctionInfo(_borrower); (uint256 kickerLP, ) = _pool.lenderInfo(bucketId, kicker); return kickerLP; } diff --git a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsTake.t.sol b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsTake.t.sol index c1232eee9..5ca8ad166 100644 --- a/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsTake.t.sol +++ b/tests/forge/unit/ERC20Pool/ERC20PoolLiquidationsTake.t.sol @@ -2222,7 +2222,7 @@ contract ERC20PoolLiquidationTakeFuzzyTest is ERC20FuzzyHelperContract { // skip some time to make auction takeable skip(skipTimeToTake); - (,,,, uint256 auctionPrice, ) = _poolUtils.auctionStatus(address(_pool), _borrower); + (,,,, uint256 auctionPrice, , , , ) = _poolUtils.auctionStatus(address(_pool), _borrower); uint256 minCollateralTakeAmount = Maths.max(Maths.wdiv(1, auctionPrice), 1); diff --git a/tests/forge/unit/ERC721Pool/ERC721DSTestPlus.sol b/tests/forge/unit/ERC721Pool/ERC721DSTestPlus.sol index 3468cce71..fe3575966 100644 --- a/tests/forge/unit/ERC721Pool/ERC721DSTestPlus.sol +++ b/tests/forge/unit/ERC721Pool/ERC721DSTestPlus.sol @@ -43,7 +43,7 @@ abstract contract ERC721DSTestPlus is DSTestPlus, IERC721PoolEvents { changePrank(borrower); // settle borrower if borrower is kicked - (uint256 kickTime, , , , , ) = _poolUtils.auctionStatus(address(_pool), borrower); + (uint256 kickTime, , , , , , , , ) = _poolUtils.auctionStatus(address(_pool), borrower); if (kickTime != 0) { _pool.settle(borrower, bucketsUsed.length()); } @@ -163,13 +163,13 @@ abstract contract ERC721DSTestPlus is DSTestPlus, IERC721PoolEvents { for (uint i = 0; i < borrowers.length(); i++) { address borrower = borrowers.at(i); - (,,, uint256 kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, uint256 kickTime,,,,,,) = _pool.auctionInfo(borrower); if (kickTime != 0) { changePrank(borrower); _pool.settle(borrower, bucketsUsed.length() + 1); // Settle again if not settled, this can happen when less reserves calculated with DEPOSIT_BUFFER and borrower is not fully settled - (,,, kickTime,,,,,) = _pool.auctionInfo(borrower); + (,,, kickTime,,,,,,) = _pool.auctionInfo(borrower); if (kickTime != 0) { _pool.settle(borrower, bucketsUsed.length() + 1); } diff --git a/tests/forge/utils/DSTestPlus.sol b/tests/forge/utils/DSTestPlus.sol index 35a25d629..44680ff35 100644 --- a/tests/forge/utils/DSTestPlus.sol +++ b/tests/forge/utils/DSTestPlus.sol @@ -461,6 +461,7 @@ abstract contract DSTestPlus is Test, IPoolEvents { vars.auctionKickTime, vars.auctionReferencePrice, vars.auctionNeutralPrice, + vars.borrowerThresholdPrice, , , ) = _pool.auctionInfo(state_.borrower); @@ -468,7 +469,8 @@ abstract contract DSTestPlus is Test, IPoolEvents { (uint256 borrowerDebt, uint256 borrowerCollateral , ) = _poolUtils.borrowerInfo(address(_pool), state_.borrower); (, uint256 lockedBonds) = _pool.kickerInfo(state_.kicker); (vars.auctionTotalBondEscrowed,,,) = _pool.reservesInfo(); - (,, vars.auctionDebtInAuction,) = _pool.debtInfo(); + (,, vars.auctionDebtInAuction,) = _pool.debtInfo(); + // FIXME: replacing this with vars.borrowerThresholdPrice from auctionInfo broke many tests vars.borrowerThresholdPrice = borrowerCollateral > 0 ? borrowerDebt * Maths.WAD / borrowerCollateral : 0; assertEq(vars.auctionKickTime != 0, state_.active); @@ -492,7 +494,9 @@ abstract contract DSTestPlus is Test, IPoolEvents { uint256 debtToCover, bool isCollateralized, uint256 price, - uint256 neutralPrice + uint256 neutralPrice, + , + , ) = _poolUtils.auctionStatus(address(_pool), state_.borrower); assertEq(kickTime, state_.kickTime); assertEq(neutralPrice, state_.neutralPrice);