Skip to content

Commit

Permalink
linter and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
daopunk committed Jul 12, 2024
1 parent a8b5dce commit 4404cb2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 70 deletions.
34 changes: 17 additions & 17 deletions src/contracts/ODSaviour.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,33 @@ contract ODSaviour is Authorizable, Modifiable, ModifiablePerCollateral, IODSavi
}

function cType(bytes32 _cType) public view returns (address _tokenAddress) {
return address(_saviourTokenAddresses[_cType]);
_tokenAddress = address(_saviourTokenAddresses[_cType]);
}

function saviourIsReady(bytes32 _cType) public view returns (bool) {
return (IERC20(_saviourTokenAddresses[_cType]).allowance(saviourTreasury, address(this)) != 0)
function saviourIsReady(bytes32 _cType) public view returns (bool _ready) {
_ready = (IERC20(_saviourTokenAddresses[_cType]).allowance(saviourTreasury, address(this)) != 0)
&& (ILiquidationEngine(liquidationEngine).safeSaviours(address(this)) != 0);
}

function vaultData(uint256 vaultId) public view returns (VaultData memory vData) {
vData.id = vaultId;
IODSafeManager.SAFEData memory safeData = safeManager.safeData(vaultId);
vData.isAllowed = safeManager.safeCan(safeData.owner, vaultId, safeData.nonce, address(this));
function vaultData(uint256 _vaultId) public view returns (VaultData memory _vData) {
_vData.id = _vaultId;
IODSafeManager.SAFEData memory _safeData = safeManager.safeData(_vaultId);
_vData.isAllowed = safeManager.safeCan(_safeData.owner, _vaultId, _safeData.nonce, address(this));

vData.isChosenSaviour = ILiquidationEngine(liquidationEngine).chosenSAFESaviour(
safeData.collateralType, safeData.safeHandler
_vData.isChosenSaviour = ILiquidationEngine(liquidationEngine).chosenSAFESaviour(
_safeData.collateralType, _safeData.safeHandler
) == address(this);
vData.isEnabled = isVaultEnabled(vaultId);
vData.vaultCtypeTokenAddress = cType(safeData.collateralType);
if (vData.vaultCtypeTokenAddress == address(0)) revert UninitializedCollateral(safeData.collateralType);
_vData.isEnabled = isVaultEnabled(_vaultId);
_vData.vaultCtypeTokenAddress = cType(_safeData.collateralType);
if (_vData.vaultCtypeTokenAddress == address(0)) revert UninitializedCollateral(_safeData.collateralType);

vData.saviourAllowance = IERC20(vData.vaultCtypeTokenAddress).allowance(saviourTreasury, address(this));
_vData.saviourAllowance = IERC20(_vData.vaultCtypeTokenAddress).allowance(saviourTreasury, address(this));

vData.treasuryBalance = IERC20(vData.vaultCtypeTokenAddress).balanceOf(saviourTreasury);
_vData.treasuryBalance = IERC20(_vData.vaultCtypeTokenAddress).balanceOf(saviourTreasury);
}

function saveSAFE(
address _liquidator,
address,
bytes32 _cType,
address _safe
) external returns (bool _ok, uint256 _collateralAdded, uint256 _liquidatorReward) {
Expand Down Expand Up @@ -162,12 +162,12 @@ contract ODSaviour is Authorizable, Modifiable, ModifiablePerCollateral, IODSavi

function _modifyParameters(bytes32 _param, bytes memory _data) internal virtual override {
if (_param == 'setVaultStatus') {
(uint256 _vaultId, bool enabled) = abi.decode(_data, (uint256, bool));
(uint256 _vaultId, bool _enabled) = abi.decode(_data, (uint256, bool));
bytes32 _collateralType = safeManager.safeData(_vaultId).collateralType;
if (address(_saviourTokenAddresses[_collateralType]) == address(0)) {
revert UninitializedCollateral(_collateralType);
}
_enabledVaults[_vaultId] = enabled;
_enabledVaults[_vaultId] = _enabled;
} else if (_param == 'liquidatorReward') {
uint256 _liquidatorReward = abi.decode(_data, (uint256));
liquidatorReward = _liquidatorReward;
Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/IODSaviour.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity 0.8.20;

import {ISAFESaviour} from './ISAFESaviour.sol';
import {IERC20} from '@openzeppelin/token/ERC20/ERC20.sol';

interface IODSaviour is ISAFESaviour {
event VaultStatusSet(uint256 _vaultId, bool _enabled);
Expand Down Expand Up @@ -45,7 +44,7 @@ interface IODSaviour is ISAFESaviour {
}

function isVaultEnabled(uint256 _vaultId) external view returns (bool _enabled);
function vaultData(uint256 vaultId) external view returns (VaultData memory vData);
function vaultData(uint256 _vaultId) external view returns (VaultData memory _vData);
function saviourIsReady(bytes32 _cType) external view returns (bool);

Check warning on line 48 in src/interfaces/IODSaviour.sol

View workflow job for this annotation

GitHub Actions / Run Linters (18.x)

Return value 'bool' in function 'saviourIsReady' must be named
function cType(bytes32 _cType) external view returns (address _tokenAddress);
function saveSAFE(
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/E2ELiquidationFee.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ contract E2ELiquidationFeeSetup is SharedSetup {
}

contract E2ELiquidationFeeTestSetup is E2ELiquidationFeeSetup {
function test_cTypes() public {
function test_cTypes() public view {

Check warning on line 88 in test/e2e/E2ELiquidationFee.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (18.x)

Function name must be in mixedCase
bytes32[] memory _cTypes = collateralJoinFactory.collateralTypesList(); // bytes32 collateralTypes in the protocol
bytes32[] memory _cList = collateralAuctionHouseFactory.collateralList(); // bytes32 collateralTypes for collateral auction
uint256 _l = _cTypes.length;
Expand Down Expand Up @@ -196,7 +196,6 @@ contract E2ELiquidationFeeTest is E2ELiquidationFeeSetup {
assertEq(safeEngine.tokenCollateral(SOC, aliceNFV.safeHandler), 0);

uint256 _externalCollateralBalanceBob = collateral[SOC].balanceOf(bob);
uint256 _externalCollateralBalanceAlice = collateral[SOC].balanceOf(alice);

// bob double's bid from first test
_buyCollateral(SOC, auctionId, 0, MINT * 2, bobProxy);
Expand Down
26 changes: 2 additions & 24 deletions test/mock-contracts/OracleRelayerForTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity 0.8.20;

import {IDelayedOracle} from '@opendollar/interfaces/oracles/IDelayedOracle.sol';
import {IBaseOracle} from '@opendollar/interfaces/oracles/IBaseOracle.sol';

contract OracleRelayerForTest {
struct OracleRelayerParams {
Expand All @@ -23,36 +22,15 @@ contract OracleRelayerForTest {

constructor() {}

function cParams(bytes32 _cType) external returns (OracleRelayerCollateralParams memory) {
function cParams() external view returns (OracleRelayerCollateralParams memory) {
return OracleRelayerCollateralParams({
oracle: IDelayedOracle(address(this)),
safetyCRatio: 1e27,
liquidationCRatio: 1e27
});
}

function read() external returns (uint256) {
function read() external pure returns (uint256) {
return 1 ether;
}
}

// contract OracleRelayerForInternalCallsTest is OracleRelayerForTest {
// event UpdateRedemptionPriceCalled();
// event GetRedemptionPriceCalled();

// constructor(
// address _safeEngine,
// IBaseOracle _systemCoinOracle,
// OracleRelayerParams memory _oracleRelayerParams
// ) OracleRelayerForTest(_safeEngine, _systemCoinOracle, _oracleRelayerParams) {}

// function _updateRedemptionPrice() internal override returns (uint256 _redemptionPrice) {
// emit UpdateRedemptionPriceCalled();
// return super._updateRedemptionPrice();
// }

// function _getRedemptionPrice() internal override returns (uint256 _redemptionPrice) {
// emit GetRedemptionPriceCalled();
// return super._getRedemptionPrice();
// }
// }
35 changes: 10 additions & 25 deletions test/unit/ODSaviour.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ contract UnitODSaviourVaultData is ODSaviourSetUp {
vm.expectRevert(
abi.encodeWithSelector(IODSaviour.UninitializedCollateral.selector, bytes32(abi.encodePacked('TKN')))
);
IODSaviour.VaultData memory saftey = saviour.vaultData(newVaultId);
saviour.vaultData(newVaultId);
}
}

Expand All @@ -181,7 +181,7 @@ contract UnitOdSaviourSaviourIsReady is ODSaviourSetUp {
assertTrue(saviour.saviourIsReady(ARB));
}

function test_SaviourIsReady_False_NoAllowance() public {
function test_SaviourIsReady_False_NoAllowance() public view {
assertFalse(saviour.saviourIsReady(ARB));
}

Expand All @@ -198,11 +198,11 @@ contract UnitOdSaviourSaviourIsReady is ODSaviourSetUp {
}

contract UnitODSaviourDeployment is ODSaviourSetUp {
function test_Set_LiquidationEngine() public {
function test_Set_LiquidationEngine() public view {
assertEq(address(saviour.liquidationEngine()), address(liquidationEngine));
}

function test_Set_Vault721() public {
function test_Set_Vault721() public view {
assertEq(address(saviour.vault721()), address(vault721));
}

Expand All @@ -212,7 +212,7 @@ contract UnitODSaviourDeployment is ODSaviourSetUp {
saviour = new ODSaviour(saviourInit);
}

function test_Set_OracleRelayer() public {
function test_Set_OracleRelayer() public view {
assertEq(address(saviour.oracleRelayer()), address(oracleRelayer));
}

Expand All @@ -222,15 +222,15 @@ contract UnitODSaviourDeployment is ODSaviourSetUp {
saviour = new ODSaviour(saviourInit);
}

function test_Set_SafeManager() public {
function test_Set_SafeManager() public view {
assertEq(address(saviour.safeManager()), address(safeManager));
}

function test_Set_SafeEngine() public {
function test_Set_SafeEngine() public view {
assertEq(address(saviour.safeEngine()), address(safeEngine));
}

function test_Set_CollateralJoinFactory() public {
function test_Set_CollateralJoinFactory() public view {
assertEq(address(saviour.collateralJoinFactory()), address(collateralJoinFactory));
}

Expand All @@ -240,11 +240,11 @@ contract UnitODSaviourDeployment is ODSaviourSetUp {
saviour = new ODSaviour(saviourInit);
}

function test_Set_LiquidatorReward() public {
function test_Set_LiquidatorReward() public view {
assertEq(saviour.liquidatorReward(), 0);
}

function test_Set_SaviourTokens() public {
function test_Set_SaviourTokens() public view {
assertEq(saviour.cType(ARB), address(collateralToken));
}
}
Expand Down Expand Up @@ -376,7 +376,6 @@ contract UnitODSaviourSaveSafe is ODSaviourSetUp {
safeManager.modifySAFECollateralization(
vaultId, int256(liquidation.safeCollateral), int256(liquidation.safeDebt), false
);
uint256 safeStartingCollateralBalance = safeEngine.safes(ARB, safeHandler).lockedCollateral;
vm.stopPrank();
vm.prank(saviourTreasury);
collateralToken.approve(address(saviour), type(uint256).max);
Expand All @@ -393,18 +392,6 @@ contract UnitODSaviourSaveSafe is ODSaviourSetUp {
})
)
);
// struct SAFEEngineCollateralData {
// // Total amount of debt issued by the collateral type
// uint256 /* WAD */ debtAmount;
// // Total amount of collateral locked in SAFEs using the collateral type
// uint256 /* WAD */ lockedAmount;
// // Accumulated rate of the collateral type
// uint256 /* RAY */ accumulatedRate;
// // Floor price at which a SAFE is allowed to generate debt
// uint256 /* RAY */ safetyPrice;
// // Price at which a SAFE gets liquidated
// uint256 /* RAY */ liquidationPrice;
// }

vm.expectEmit();
emit Liquidate(
Expand Down Expand Up @@ -440,8 +427,6 @@ contract UnitODSaviourSaveSafe is ODSaviourSetUp {

uint256 safeStartingDebtBalance = safeEngine.safes(ARB, safeHandler).generatedDebt;

// _notSafeBool = _safeCollateral * _liquidationPrice < _safeDebt * _accumulatedRate;

vm.prank(saviourTreasury);
collateralToken.approve(address(saviour), type(uint256).max);
vm.mockCall(
Expand Down

0 comments on commit 4404cb2

Please sign in to comment.