diff --git a/script/Common.s.sol b/script/Common.s.sol index 01797051..bc81b77b 100644 --- a/script/Common.s.sol +++ b/script/Common.s.sol @@ -66,7 +66,6 @@ abstract contract Common is Contracts, Params, Test { function deployCollateralContracts(bytes32 _cType) public updateParams { // deploy CollateralJoin and CollateralAuctionHouse - address _delegatee = delegatee[_cType]; if (_cType == ARB) { console.log('Using arb ctype, so deploying delegatable cjoin.'); collateralJoin[_cType] = collateralJoinFactory.deployDelegatableCollateralJoin({ diff --git a/src/libraries/OpenDollarV1Arbitrum.sol b/src/libraries/OpenDollarV1Arbitrum.sol index fb00a4c4..863e1313 100644 --- a/src/libraries/OpenDollarV1Arbitrum.sol +++ b/src/libraries/OpenDollarV1Arbitrum.sol @@ -4,54 +4,54 @@ pragma solidity >=0.7.0; import {IERC20Metadata} from '@openzeppelin/token/ERC20/extensions/IERC20Metadata.sol'; // --- Base Contracts --- -import {ISystemCoin} from '@contracts/tokens/SystemCoin.sol'; -import {IProtocolToken} from '@contracts/tokens/ProtocolToken.sol'; -import {ISAFEEngine} from '@contracts/SAFEEngine.sol'; -import {ITaxCollector} from '@contracts/TaxCollector.sol'; -import {IAccountingEngine} from '@contracts/AccountingEngine.sol'; -import {ILiquidationEngine} from '@contracts/LiquidationEngine.sol'; -import {ISurplusAuctionHouse} from '@contracts/SurplusAuctionHouse.sol'; -import {IDebtAuctionHouse} from '@contracts/DebtAuctionHouse.sol'; -import {ICollateralAuctionHouse} from '@contracts/CollateralAuctionHouse.sol'; -import {IStabilityFeeTreasury} from '@contracts/StabilityFeeTreasury.sol'; -import {IPIDController} from '@contracts/PIDController.sol'; -import {IPIDRateSetter} from '@contracts/PIDRateSetter.sol'; +import {ISystemCoin} from '@interfaces/tokens/ISystemCoin.sol'; +import {IProtocolToken} from '@interfaces/tokens/IProtocolToken.sol'; +import {ISAFEEngine} from '@interfaces/ISAFEEngine.sol'; +import {ITaxCollector} from '@interfaces/ITaxCollector.sol'; +import {IAccountingEngine} from '@interfaces/IAccountingEngine.sol'; +import {ILiquidationEngine} from '@interfaces/ILiquidationEngine.sol'; +import {ISurplusAuctionHouse} from '@interfaces/ISurplusAuctionHouse.sol'; +import {IDebtAuctionHouse} from '@interfaces/IDebtAuctionHouse.sol'; +import {ICollateralAuctionHouse} from '@interfaces/ICollateralAuctionHouse.sol'; +import {IStabilityFeeTreasury} from '@interfaces/IStabilityFeeTreasury.sol'; +import {IPIDController} from '@interfaces/IPIDController.sol'; +import {IPIDRateSetter} from '@interfaces/IPIDRateSetter.sol'; // --- Settlement --- -import {IGlobalSettlement} from '@contracts/settlement/GlobalSettlement.sol'; -import {IPostSettlementSurplusAuctionHouse} from '@contracts/settlement/PostSettlementSurplusAuctionHouse.sol'; -import {ISettlementSurplusAuctioneer} from '@contracts/settlement/SettlementSurplusAuctioneer.sol'; +import {IGlobalSettlement} from '@interfaces/settlement/IGlobalSettlement.sol'; +import {IPostSettlementSurplusAuctionHouse} from '@interfaces/settlement/IPostSettlementSurplusAuctionHouse.sol'; +import {ISettlementSurplusAuctioneer} from '@interfaces/settlement/ISettlementSurplusAuctioneer.sol'; // --- Oracles --- -import {IOracleRelayer} from '@contracts/OracleRelayer.sol'; -import {IDelayedOracle} from '@contracts/oracles/DelayedOracle.sol'; +import {IOracleRelayer} from '@interfaces/IOracleRelayer.sol'; +import {IDelayedOracle} from '@interfaces/oracles/IDelayedOracle.sol'; // --- Token adapters --- -import {ICoinJoin} from '@contracts/utils/CoinJoin.sol'; -import {ICollateralJoin} from '@contracts/utils/CollateralJoin.sol'; +import {ICoinJoin} from '@interfaces/utils/ICoinJoin.sol'; +import {ICollateralJoin} from '@interfaces/utils/ICollateralJoin.sol'; // --- Factories --- -import {ICollateralJoinFactory} from '@contracts/factories/CollateralJoinFactory.sol'; -import {ICollateralAuctionHouseFactory} from '@contracts/factories/CollateralAuctionHouseFactory.sol'; -import {IChainlinkRelayerFactory} from '@contracts/factories/ChainlinkRelayerFactory.sol'; -import {IDenominatedOracleFactory} from '@contracts/factories/DenominatedOracleFactory.sol'; -import {IDelayedOracleFactory} from '@contracts/factories/DelayedOracleFactory.sol'; +import {ICollateralJoinFactory} from '@interfaces/factories/ICollateralJoinFactory.sol'; +import {ICollateralAuctionHouseFactory} from '@interfaces/factories/ICollateralAuctionHouseFactory.sol'; +import {IChainlinkRelayerFactory} from '@interfaces/factories/IChainlinkRelayerFactory.sol'; +import {IDenominatedOracleFactory} from '@interfaces/factories/IDenominatedOracleFactory.sol'; +import {IDelayedOracleFactory} from '@interfaces/factories/IDelayedOracleFactory.sol'; // --- Jobs --- -import {IAccountingJob} from '@contracts/jobs/AccountingJob.sol'; -import {ILiquidationJob} from '@contracts/jobs/LiquidationJob.sol'; -import {IOracleJob} from '@contracts/jobs/OracleJob.sol'; +import {IAccountingJob} from '@interfaces/jobs/IAccountingJob.sol'; +import {ILiquidationJob} from '@interfaces/jobs/ILiquidationJob.sol'; +import {IOracleJob} from '@interfaces/jobs/IOracleJob.sol'; // --- Proxy Contracts --- -import {IBasicActions} from '@contracts/proxies/actions/BasicActions.sol'; -import {IDebtBidActions} from '@contracts/proxies/actions/DebtBidActions.sol'; -import {ISurplusBidActions} from '@contracts/proxies/actions/SurplusBidActions.sol'; -import {ICollateralBidActions} from '@contracts/proxies/actions/CollateralBidActions.sol'; +import {IBasicActions} from '@interfaces/proxies/actions/IBasicActions.sol'; +import {IDebtBidActions} from '@interfaces/proxies/actions/IDebtBidActions.sol'; +import {ISurplusBidActions} from '@interfaces/proxies/actions/ISurplusBidActions.sol'; +import {ICollateralBidActions} from '@interfaces/proxies/actions/ICollateralBidActions.sol'; import {PostSettlementSurplusBidActions} from '@contracts/proxies/actions/PostSettlementSurplusBidActions.sol'; -import {IGlobalSettlementActions} from '@contracts/proxies/actions/GlobalSettlementActions.sol'; -import {IRewardedActions} from '@contracts/proxies/actions/RewardedActions.sol'; -import {IODSafeManager} from '@contracts/proxies/ODSafeManager.sol'; -import {IVault721} from '@contracts/proxies/Vault721.sol'; +import {IGlobalSettlementActions} from '@interfaces/proxies/actions/IGlobalSettlementActions.sol'; +import {IRewardedActions} from '@interfaces/proxies/actions/IRewardedActions.sol'; +import {IODSafeManager} from '@interfaces/proxies/IODSafeManager.sol'; +import {IVault721} from '@interfaces/proxies/IVault721.sol'; import {NFTRenderer} from '@contracts/proxies/NFTRenderer.sol'; // --- Governance Contracts --- diff --git a/test/e2e/Deploy.t.sol b/test/e2e/Deploy.t.sol index 62c3c897..d80a01c3 100644 --- a/test/e2e/Deploy.t.sol +++ b/test/e2e/Deploy.t.sol @@ -20,7 +20,7 @@ import {IProtocolToken} from '@contracts/tokens/ProtocolToken.sol'; abstract contract CommonDeploymentTest is ODTest, Deploy { // SAFEEngine - function test_SAFEEngine_Auth() public { + function test_SAFEEngine_Auth() public view { assertEq(safeEngine.authorizedAccounts(address(oracleRelayer)), true); assertEq(safeEngine.authorizedAccounts(address(taxCollector)), true); assertEq(safeEngine.authorizedAccounts(address(debtAuctionHouse)), true); @@ -34,12 +34,12 @@ abstract contract CommonDeploymentTest is ODTest, Deploy { } // OracleRelayer - function test_OracleRelayer_Auth() public { + function test_OracleRelayer_Auth() public view { assertEq(oracleRelayer.authorizedAccounts(address(pidRateSetter)), true); } // AccountingEngine - function test_AccountingEngine_Auth() public { + function test_AccountingEngine_Auth() public view { assertEq(accountingEngine.authorizedAccounts(address(liquidationEngine)), true); } @@ -48,17 +48,17 @@ abstract contract CommonDeploymentTest is ODTest, Deploy { } // SystemCoin - function test_SystemCoin_Auth() public { + function test_SystemCoin_Auth() public view { assertEq(systemCoin.authorizedAccounts(address(coinJoin)), true); } // ProtocolToken - function test_ProtocolToken_Auth() public { + function test_ProtocolToken_Auth() public view { assertEq(protocolToken.authorizedAccounts(address(debtAuctionHouse)), true); } // SurplusAuctionHouse - function test_SurplusAuctionHouse_Auth() public { + function test_SurplusAuctionHouse_Auth() public view { assertEq(surplusAuctionHouse.authorizedAccounts(address(accountingEngine)), true); } @@ -67,7 +67,7 @@ abstract contract CommonDeploymentTest is ODTest, Deploy { } // DebtAuctionHouse - function test_DebtAuctionHouse_Auth() public { + function test_DebtAuctionHouse_Auth() public view { assertEq(debtAuctionHouse.authorizedAccounts(address(accountingEngine)), true); } @@ -76,7 +76,7 @@ abstract contract CommonDeploymentTest is ODTest, Deploy { } // CollateralAuctionHouse - function test_CollateralAuctionHouse_Auth() public { + function test_CollateralAuctionHouse_Auth() public view { for (uint256 _i; _i < collateralTypes.length; _i++) { bytes32 _cType = collateralTypes[_i]; assertEq(collateralAuctionHouse[_cType].authorizedAccounts(address(liquidationEngine)), true); @@ -92,7 +92,7 @@ abstract contract CommonDeploymentTest is ODTest, Deploy { } } - function test_Grant_Auth() public { + function test_Grant_Auth() public view { uint256 _id; assembly { _id := chainid() @@ -112,7 +112,7 @@ abstract contract CommonDeploymentTest is ODTest, Deploy { } } - function _test_Authorizations(address _target, bool _permission) internal { + function _test_Authorizations(address _target, bool _permission) internal view { // base contracts assertEq(safeEngine.authorizedAccounts(_target), _permission); assertEq(oracleRelayer.authorizedAccounts(_target), _permission); diff --git a/test/e2e/E2ESafeManager.t.sol b/test/e2e/E2ESafeManager.t.sol index 670802ae..4196a361 100644 --- a/test/e2e/E2ESafeManager.t.sol +++ b/test/e2e/E2ESafeManager.t.sol @@ -456,14 +456,7 @@ contract E2ESafeManagerTest_TransferCollateral is E2ESafeManagerSetUp { depositCollatAndGenDebt(_cType(), aliceSafeId, _scenario.lockedCollateral, 0, aliceProxy); modifySAFECollateralization(aliceProxy, aliceSafeId, -int256(_scenario.lockedCollateral), 0); vm.stopPrank(); - bytes memory payload = abi.encodeWithSelector( - basicActions.transferCollateralWithCType.selector, - address(safeManager), - _cType(), - aliceSafeId, - bob, - _scenario.lockedCollateral - ); + vm.prank(bob); vm.expectRevert(IODSafeManager.SafeNotAllowed.selector); safeManager.transferCollateral(_cType(), aliceSafeId, bob, _scenario.lockedCollateral); diff --git a/test/e2e/E2ETest.t.sol b/test/e2e/E2ETest.t.sol index 0ce088da..7fd2500e 100644 --- a/test/e2e/E2ETest.t.sol +++ b/test/e2e/E2ETest.t.sol @@ -53,12 +53,7 @@ abstract contract E2ETest is BaseUser, Base_CType, Common, IERC721Receiver { taxCollector.taxSingle(_cType()); } - function onERC721Received( - address operator, - address from, - uint256 tokenId, - bytes calldata data - ) external returns (bytes4) { + function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) { return IERC721Receiver.onERC721Received.selector; } diff --git a/test/lib/ODLib.t.sol b/test/lib/ODLib.t.sol index 696b8df8..26011891 100644 --- a/test/lib/ODLib.t.sol +++ b/test/lib/ODLib.t.sol @@ -20,6 +20,8 @@ contract ODLib is Test { IVault721 public vault721; function setUp() public virtual { + vm.createSelectFork(vm.rpcUrl('mainnet')); + systemCoin = OpenDollarV1Arbitrum.SYSTEM_COIN; protocolToken = OpenDollarV1Arbitrum.PROTOCOL_TOKEN; safeEngine = OpenDollarV1Arbitrum.SAFE_ENGINE; @@ -27,11 +29,20 @@ contract ODLib is Test { vault721 = OpenDollarV1Arbitrum.VAULT721; } - function testODLib() public { + function testODLib() public view { assertTrue(systemCoin == ISystemCoin(0x221A0f68770658C15B525d0F89F5da2baAB5f321)); assertTrue(protocolToken == IProtocolToken(MAINNET_PROTOCOL_TOKEN)); assertTrue(safeEngine == ISAFEEngine(0xEff45E8e2353893BD0558bD5892A42786E9142F1)); assertTrue(safeManager == IODSafeManager(0x8646CBd915eAAD1a4E2Ba5e2b67Acec4957d5f1a)); assertTrue(vault721 == IVault721(0x0005AFE00fF7E7FF83667bFe4F2996720BAf0B36)); } + + function testTotalSupply() public view { + assertEq(systemCoin.totalSupply(), OpenDollarV1Arbitrum.SYSTEM_COIN.totalSupply()); + } + + function testSafeManager() public { + assertTrue(vault721.safeManager() == safeManager); + assertTrue(vault721.safeManager() == OpenDollarV1Arbitrum.VAULT721.safeManager()); + } } diff --git a/test/mocks/SafeSaviourForTest.sol b/test/mocks/SafeSaviourForTest.sol index a06273b1..90569ad0 100644 --- a/test/mocks/SafeSaviourForTest.sol +++ b/test/mocks/SafeSaviourForTest.sol @@ -7,10 +7,10 @@ contract SafeSaviourForForTest is ISAFESaviour { constructor() {} function saveSAFE( - address _liquidator, - bytes32 _cType, - address _safe - ) external returns (bool _ok, uint256 _collateralAdded, uint256 _liquidatorReward) { + address, + bytes32, + address + ) external pure returns (bool _ok, uint256 _collateralAdded, uint256 _liquidatorReward) { _ok = true; _collateralAdded = type(uint256).max; _liquidatorReward = type(uint256).max; diff --git a/test/scopes/DirectUser.t.sol b/test/scopes/DirectUser.t.sol index 077a304e..245e468b 100644 --- a/test/scopes/DirectUser.t.sol +++ b/test/scopes/DirectUser.t.sol @@ -118,7 +118,7 @@ abstract contract DirectUser is BaseUser, Contracts, ScriptBase { abi.encode(uint256(1)) ); safeEngine.modifySAFECollateralization({ - _cType: ICollateralJoin(_collateralJoin).collateralType(), + _cType: _cType, _safe: _user, _collateralSource: _user, _debtDestination: _user, @@ -197,7 +197,7 @@ abstract contract DirectUser is BaseUser, Contracts, ScriptBase { vm.stopPrank(); } - function _settleDebtAuction(address _user, uint256 _auctionId) internal override { + function _settleDebtAuction(address, uint256 _auctionId) internal override { debtAuctionHouse.settleAuction(_auctionId); } @@ -223,7 +223,7 @@ abstract contract DirectUser is BaseUser, Contracts, ScriptBase { vm.stopPrank(); } - function _settlePostSettlementSurplusAuction(address _user, uint256 _auctionId) internal override { + function _settlePostSettlementSurplusAuction(address, uint256 _auctionId) internal override { postSettlementSurplusAuctionHouse.settleAuction(_auctionId); } diff --git a/test/scopes/ProxyUser.t.sol b/test/scopes/ProxyUser.t.sol index 8fa77a1e..26babca5 100644 --- a/test/scopes/ProxyUser.t.sol +++ b/test/scopes/ProxyUser.t.sol @@ -361,7 +361,7 @@ abstract contract ProxyUser is BaseUser, Contracts, ScriptBase { function _redeemCollateral( address _user, bytes32 _cType, - uint256 _coinsAmount + uint256 ) internal override returns (uint256 _collateralAmount) { ODProxy _proxy = _getProxy(_user);