-
Notifications
You must be signed in to change notification settings - Fork 3
Fix Review #1
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
base: contest-scope
Are you sure you want to change the base?
Fix Review #1
Conversation
| uint256 slashShareOfCollateral = | ||
| _slashShare == 1e18 ? totalSlashableCollateral : (totalSlashableCollateral * _slashShare / 1e18) + 1; |
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.
Change related to cap-labs-dev/cap-contracts#194.
Fixes issues: #154 - Liquidator will attempt to slash more collateral than available due to flawed rounding logic
| balances = new uint256[](assetsLength); | ||
| for (uint256 i; i < assetsLength; ++i) { | ||
| address asset = _assets[i]; | ||
| if (asset == address(0)) revert InvalidAsset(); |
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.
Change related to cap-labs-dev/cap-contracts#191.
Fixes issues: #112 - Zero Address Validation Missing in _transferOutAssets() Causes Denial of Service
| /// @dev Asset must be non-zero address | ||
| error InvalidAsset(); | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#191.
Fixes issues: #112 - Zero Address Validation Missing in _transferOutAssets() Causes Denial of Service
| if (realizedInterest > 0) { | ||
| IVault(reserve.vault).borrow(_asset, realizedInterest, $.delegation); | ||
| IDelegation($.delegation).distributeRewards(_agent, _asset); | ||
| } | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#189.
Fixes issues: #150 - Lender DoS if all asset is borrowed or realized
| /// @notice No debt to liquidate | ||
| error NoDebt(); | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#190.
Fixes issues: #49 - Division by zero in liquidation due to race condition
| if (totalDebt == 0) revert NoDebt(); | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#190.
Fixes issues: #49 - Division by zero in liquidation due to race condition
| (,,,,, health) = ViewLogic.agent($, params.agent); | ||
| if (health >= 1e27) _closeLiquidation($, params.agent); | ||
|
|
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.
| uint256 excess = _utilization - slopes.kink; | ||
| utilizationData.multiplier = utilizationData.multiplier | ||
| * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * (_elapsed * $.rate / 1e27)) / 1e27; | ||
| * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * _elapsed * $.rate / 1e27) / 1e27; |
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.
Change related to cap-labs-dev/cap-contracts#187.
Fixes issues: #148 - Utilization rate multiplier will not shift if oracle is consulted frequently
| } else { | ||
| utilizationData.multiplier = utilizationData.multiplier * 1e27 | ||
| / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * (_elapsed * $.rate / 1e27)); | ||
| / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * _elapsed * $.rate / 1e27); |
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.
Change related to cap-labs-dev/cap-contracts#187.
Fixes issues: #148 - Utilization rate multiplier will not shift if oracle is consulted frequently
|
|
||
| _burn(msg.sender, _amountIn); | ||
|
|
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.
| _burn(msg.sender, _amountIn); | ||
|
|
||
| divest(_asset, amountOut + fee); | ||
|
|
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.
|
|
||
| _burn(msg.sender, _amountIn); | ||
|
|
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.
| } | ||
|
|
||
| divestMany(assets(), totalDivestAmounts); | ||
|
|
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.
| if ($.vault[_asset] != address(0)) { | ||
| IERC4626($.vault[_asset]).withdraw(claimableInterest($, _asset), $.interestReceiver, address(this)); | ||
| emit FractionalReserveInterestRealized(_asset); | ||
| } |
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.
Change related to cap-labs-dev/cap-contracts#192.
Fixes issues: #143 - Missing Zero Address Check in claimableInterest and realizeInterest
| if ($.vault[_asset] == address(0)) return 0; | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#192.
Fixes issues: #143 - Missing Zero Address Check in claimableInterest and realizeInterest
| uint256 slashShareOfCollateral = | ||
| _slashShare == 1e18 ? totalSlashableCollateral : (totalSlashableCollateral * _slashShare / 1e18) + 1; |
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.
Change related to cap-labs-dev/cap-contracts#194.
Fixes issues: #154 - Liquidator will attempt to slash more collateral than available due to flawed rounding logic
| balances = new uint256[](assetsLength); | ||
| for (uint256 i; i < assetsLength; ++i) { | ||
| address asset = _assets[i]; | ||
| if (asset == address(0)) revert InvalidAsset(); |
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.
Change related to cap-labs-dev/cap-contracts#191.
Fixes issues: #112 - Zero Address Validation Missing in _transferOutAssets() Causes Denial of Service
| /// @dev Asset must be non-zero address | ||
| error InvalidAsset(); | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#191.
Fixes issues: #112 - Zero Address Validation Missing in _transferOutAssets() Causes Denial of Service
| if (realizedInterest > 0) { | ||
| IVault(reserve.vault).borrow(_asset, realizedInterest, $.delegation); | ||
| IDelegation($.delegation).distributeRewards(_agent, _asset); | ||
| } | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#189.
Fixes issues: #150 - Lender DoS if all asset is borrowed or realized, #180 - Cannot repay or liquidate on paused asset
| /// @notice No debt to liquidate | ||
| error NoDebt(); | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#190.
Fixes issues: #49 - Division by zero in liquidation due to race condition
| if (totalDebt == 0) revert NoDebt(); | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#190.
Fixes issues: #49 - Division by zero in liquidation due to race condition
| (,,,,, health) = ViewLogic.agent($, params.agent); | ||
| if (health >= 1e27) _closeLiquidation($, params.agent); | ||
|
|
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.
| uint256 excess = _utilization - slopes.kink; | ||
| utilizationData.multiplier = utilizationData.multiplier | ||
| * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * (_elapsed * $.rate / 1e27)) / 1e27; | ||
| * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * _elapsed * $.rate / 1e27) / 1e27; |
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.
Change related to cap-labs-dev/cap-contracts#187.
Fixes issues: #148 - Utilization rate multiplier will not shift if oracle is consulted frequently
| } else { | ||
| utilizationData.multiplier = utilizationData.multiplier * 1e27 | ||
| / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * (_elapsed * $.rate / 1e27)); | ||
| / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * _elapsed * $.rate / 1e27); |
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.
Change related to cap-labs-dev/cap-contracts#187.
Fixes issues: #148 - Utilization rate multiplier will not shift if oracle is consulted frequently
|
|
||
| _burn(msg.sender, _amountIn); | ||
|
|
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.
| _burn(msg.sender, _amountIn); | ||
|
|
||
| divest(_asset, amountOut + fee); | ||
|
|
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.
|
|
||
| _burn(msg.sender, _amountIn); | ||
|
|
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.
| } | ||
|
|
||
| divestMany(assets(), totalDivestAmounts); | ||
|
|
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.
| if ($.vault[_asset] != address(0)) { | ||
| IERC4626($.vault[_asset]).withdraw(claimableInterest($, _asset), $.interestReceiver, address(this)); | ||
| emit FractionalReserveInterestRealized(_asset); | ||
| } |
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.
Change related to cap-labs-dev/cap-contracts#192.
Fixes issues: #143 - Missing Zero Address Check in claimableInterest and realizeInterest
| if ($.vault[_asset] == address(0)) return 0; | ||
|
|
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.
Change related to cap-labs-dev/cap-contracts#192.
Fixes issues: #143 - Missing Zero Address Check in claimableInterest and realizeInterest
Fix Review of
Repo:
cap-labs-dev/cap-contractsCommit Hash:
403326df39f6987359bba648b7c09f81bd53da62