Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Protocol admin test #42

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions contracts/test/DevTesting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ contract DevTesting is BaseTest {
}
}

function testModePoolBorrowers() public debuggingOnly fork(MODE_MAINNET) {
emit log_named_array("borrowers", pool.getAllBorrowers());
}

function testModeLiquidationShortfall() public debuggingOnly fork(MODE_MAINNET) {
(uint256 err, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(
0xa75F9C8246f7269279bE4c969e7Bc6Eb619cC204
);

emit log_named_uint("err", err);
emit log_named_uint("collateralValue", collateralValue);
emit log_named_uint("liquidity", liquidity);
emit log_named_uint("shortfall", shortfall);
}

function testModeHealthFactor() public debuggingOnly fork(MODE_MAINNET) {
address rahul = 0x5A9e792143bf2708b4765C144451dCa54f559a19;

Expand Down
92 changes: 92 additions & 0 deletions contracts/test/ProtocolAdminTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import { BaseTest } from "./config/BaseTest.t.sol";
import { SafeOwnableUpgradeable } from "../ionic/SafeOwnableUpgradeable.sol";
import { MasterPriceOracle } from "../oracles/MasterPriceOracle.sol";
import { PoolDirectory } from "../PoolDirectory.sol";
import { IonicComptroller } from "../compound/ComptrollerInterface.sol";

import "@openzeppelin/contracts/access/Ownable.sol";

contract ProtocolAdminTest is BaseTest {
address public expectedAdmin;

function afterForkSetUp() internal virtual override {}

function _checkIfAdmin(address addr, string memory contractName) internal {
emit log("");
emit log(contractName);
assertEq(addr, expectedAdmin, "not the same admin address");
}

function _checkSafeOwnableAdmin(string memory contractName) internal {
SafeOwnableUpgradeable ownable = SafeOwnableUpgradeable(ap.getAddress(contractName));
if (address(ownable) != address(0)) {
_checkIfAdmin(ownable.owner(), contractName);
}
}

function _checkOwnableAdmin(string memory contractName) internal {
Ownable ownable = Ownable(ap.getAddress(contractName));
if (address(ownable) != address(0)) {
_checkIfAdmin(ownable.owner(), contractName);
}
}

function testModeProtocolAdmin() public fork(MODE_MAINNET) {
expectedAdmin = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2; // gnosis safe multisig contract
_testProtocolAdmin();
}

function _testProtocolAdmin() internal {
//expectedAdmin = ap.owner();
// safe ownable
_checkSafeOwnableAdmin("FeeDistributor");
_checkSafeOwnableAdmin("PoolDirectory");
_checkSafeOwnableAdmin("OptimizedVaultsRegistry");
_checkSafeOwnableAdmin("AnkrCertificateTokenPriceOracle");
_checkSafeOwnableAdmin("BalancerLpLinearPoolPriceOracle");
_checkSafeOwnableAdmin("BalancerLpStablePoolPriceOracle");
_checkSafeOwnableAdmin("BalancerLpTokenPriceOracle");
_checkSafeOwnableAdmin("BalancerLpTokenPriceOracleNTokens");
_checkSafeOwnableAdmin("BalancerRateProviderOracle");
_checkSafeOwnableAdmin("BNBxPriceOracle");
_checkSafeOwnableAdmin("CurveLpTokenPriceOracleNoRegistry");
_checkSafeOwnableAdmin("CurveV2LpTokenPriceOracleNoRegistry");
_checkSafeOwnableAdmin("CurveV2PriceOracle");
_checkSafeOwnableAdmin("ERC4626Oracle");
_checkSafeOwnableAdmin("GammaPoolUniswapV3PriceOracle");
_checkSafeOwnableAdmin("GammaPoolAlgebraPriceOracle");
_checkSafeOwnableAdmin("PythPriceOracle");
_checkSafeOwnableAdmin("SimplePriceOracle");
_checkSafeOwnableAdmin("SolidlyPriceOracle");
_checkSafeOwnableAdmin("StkBNBPriceOracle");
_checkSafeOwnableAdmin("WSTEthPriceOracle");
_checkSafeOwnableAdmin("NativeUSDPriceOracle");

// ownable 2 step
_checkSafeOwnableAdmin("LiquidatorsRegistry");
_checkSafeOwnableAdmin("LeveredPositionFactory");
_checkSafeOwnableAdmin("OptimizedAPRVault");

_checkOwnableAdmin("DefaultProxyAdmin");
_checkOwnableAdmin("DiaPriceOracle");
_checkOwnableAdmin("PoolDirectory");

assertEq(MasterPriceOracle(ap.getAddress("MasterPriceOracle")).admin(), expectedAdmin, "mpo admin incorrect");

// check all the pool admins and the flywheels owners
PoolDirectory poolDir = PoolDirectory(ap.getAddress("PoolDirectory"));
PoolDirectory.Pool[] memory pools = poolDir.getAllPools();
for (uint256 i = 0; i < pools.length; i++) {
IonicComptroller pool = IonicComptroller(pools[i].comptroller);
assertEq(pool.admin(), expectedAdmin, "pool admin does not match");

address[] memory flywheels = pool.getRewardsDistributors();
for (uint256 j = 0; j < flywheels.length; j++) {
assertEq(Ownable(flywheels[j]).owner(), expectedAdmin, "flywheel owner not the admin");
}
}
}
}
Loading