Skip to content

Commit 2d98820

Browse files
add missing functions in interfaces (#219)
* add missing functions in interfaces * fix interface treasury
1 parent 2fb38de commit 2d98820

4 files changed

Lines changed: 36 additions & 12 deletions

File tree

contracts/interfaces/ITreasury.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ interface ITreasury {
3939
/// @dev This function removes the minting right to the old flash loan module and grants
4040
/// it to the new module
4141
function setFlashLoanModule(address _flashLoanModule) external;
42+
43+
/// @notice Gets the vault manager list
44+
function vaultManagerList(uint256 i) external returns (address);
4245
}

contracts/interfaces/IVaultManager.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ interface IVaultManagerFunctions {
196196

197197
/// @notice Minimum amount of debt a vault can have, expressed in `BASE_TOKENS` that is to say the base of the agTokens
198198
function dust() external view returns (uint256);
199+
200+
/// @notice Pauses external permissionless functions of the contract
201+
function togglePause() external;
199202
}
200203

201204
/// @title IVaultManagerStorage

contracts/mock/MockTreasury.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ contract MockTreasury is ITreasury {
1313
address public vaultManager1;
1414
address public vaultManager2;
1515
address public flashLoanModule;
16+
address[] public vaultManagerList;
1617

1718
constructor(
1819
IAgToken _stablecoin,

contracts/vaultManager/VaultManager.sol

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
8484
if (_oracle.treasury() != _treasury) revert InvalidTreasury();
8585
treasury = _treasury;
8686
collateral = _collateral;
87-
_collatBase = 10 ** (IERC20Metadata(address(collateral)).decimals());
87+
_collatBase = 10**(IERC20Metadata(address(collateral)).decimals());
8888
stablecoin = IAgToken(_treasury.stablecoin());
8989
oracle = _oracle;
9090
string memory _name = string.concat("Angle Protocol ", _symbol, " Vault");
@@ -343,7 +343,7 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
343343

344344
uint256 stablecoinAmountLessFeePaid = (stablecoinAmount *
345345
(BASE_PARAMS - repayFee_) *
346-
(BASE_PARAMS - _borrowFee)) / (BASE_PARAMS ** 2);
346+
(BASE_PARAMS - _borrowFee)) / (BASE_PARAMS**2);
347347
surplus += stablecoinAmount - stablecoinAmountLessFeePaid;
348348
_repayDebt(vaultID, stablecoinAmountLessFeePaid, 0);
349349
}
@@ -365,10 +365,11 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
365365
/// @param liquidator Address of the liquidator which will be performing the liquidation
366366
/// @return liqOpp Description of the opportunity of liquidation
367367
/// @dev This function will revert if it's called on a vault that does not exist
368-
function checkLiquidation(
369-
uint256 vaultID,
370-
address liquidator
371-
) external view returns (LiquidationOpportunity memory liqOpp) {
368+
function checkLiquidation(uint256 vaultID, address liquidator)
369+
external
370+
view
371+
returns (LiquidationOpportunity memory liqOpp)
372+
{
372373
liqOpp = _checkLiquidation(
373374
vaultData[vaultID],
374375
liquidator,
@@ -391,7 +392,15 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
391392
Vault memory vault,
392393
uint256 oracleValue,
393394
uint256 newInterestAccumulator
394-
) internal view returns (uint256 healthFactor, uint256 currentDebt, uint256 collateralAmountInStable) {
395+
)
396+
internal
397+
view
398+
returns (
399+
uint256 healthFactor,
400+
uint256 currentDebt,
401+
uint256 collateralAmountInStable
402+
)
403+
{
395404
currentDebt = (vault.normalizedDebt * newInterestAccumulator) / BASE_INTEREST;
396405
collateralAmountInStable = (vault.collateralAmount * oracleValue) / _collatBase;
397406
if (currentDebt == 0) healthFactor = type(uint256).max;
@@ -798,7 +807,7 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
798807
// Checking if we're in a situation where the health factor is an increasing or a decreasing function of the
799808
// amount repaid. In the first case, the health factor is an increasing function which means that the liquidator
800809
// can bring the vault to the target health ratio
801-
if (healthFactor * liquidationDiscount * surcharge >= collateralFactor * BASE_PARAMS ** 2) {
810+
if (healthFactor * liquidationDiscount * surcharge >= collateralFactor * BASE_PARAMS**2) {
802811
// This is the max amount to repay that will bring the person to the target health factor
803812
// Denom is always positive when a vault gets liquidated in this case and when the health factor
804813
// is an increasing function of the amount of stablecoins repaid
@@ -807,7 +816,7 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
807816
((targetHealthFactor * currentDebt - collateralAmountInStable * collateralFactor) *
808817
BASE_PARAMS *
809818
liquidationDiscount) /
810-
(surcharge * targetHealthFactor * liquidationDiscount - (BASE_PARAMS ** 2) * collateralFactor);
819+
(surcharge * targetHealthFactor * liquidationDiscount - (BASE_PARAMS**2) * collateralFactor);
811820
// Need to check for the dust as liquidating should not leave a dusty amount in the vault
812821
uint256 dustParameter = dustLiquidation;
813822
if (currentDebt * BASE_PARAMS <= maxAmountToRepay * surcharge + dustParameter * BASE_PARAMS) {
@@ -911,7 +920,7 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
911920
emit LiquidationBoostParametersUpdated(_veBoostProxy, xBoost, yBoost);
912921
}
913922

914-
/// @notice Pauses external permissionless functions of the contract
923+
/// @inheritdoc IVaultManagerFunctions
915924
function togglePause() external virtual onlyGovernorOrGuardian {
916925
paused = !paused;
917926
}
@@ -945,7 +954,11 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
945954
/// @param _dustLiquidation New `dustLiquidation` value
946955
/// @param dustCollateral_ New minimum collateral allowed in a vault after a liquidation
947956
/// @dev dustCollateral_ is in stable value
948-
function setDusts(uint256 _dust, uint256 _dustLiquidation, uint256 dustCollateral_) external onlyGovernor {
957+
function setDusts(
958+
uint256 _dust,
959+
uint256 _dustLiquidation,
960+
uint256 dustCollateral_
961+
) external onlyGovernor {
949962
if (_dust > _dustLiquidation) revert InvalidParameterValue();
950963
dust = _dust;
951964
dustLiquidation = _dustLiquidation;
@@ -973,7 +986,11 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
973986
/// @param amount Collateral amount balance of the owner of vaultID increase/decrease
974987
/// @param add Whether the balance should be increased/decreased
975988
/// @param vaultID Vault which sees its collateral amount changed
976-
function _checkpointCollateral(uint256 vaultID, uint256 amount, bool add) internal virtual {}
989+
function _checkpointCollateral(
990+
uint256 vaultID,
991+
uint256 amount,
992+
bool add
993+
) internal virtual {}
977994

978995
/// @notice Get `paused` in storage only if needed
979996
function _paused() internal view virtual returns (bool) {

0 commit comments

Comments
 (0)