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

Mode: new market test #47

Merged
merged 9 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions contracts/compound/Comptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ contract Comptroller is ComptrollerBase, ComptrollerInterface, ComptrollerErrorR
uint256 err = _supportMarket(cToken);

IFeeDistributor(ionicAdmin).authoritiesRegistry().reconfigureAuthority(address(this));
//supplyCaps[address(cToken)] = 1;

// Set collateral factor
return err == uint256(Error.NO_ERROR) ? _setCollateralFactor(cToken, collateralFactorMantissa) : err;
Expand Down
74 changes: 72 additions & 2 deletions contracts/test/DevTesting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ contract DevTesting is BaseTest {
PoolLens lens = PoolLens(0x431C87E08e2636733a945D742d25Ba77577ED480);

address deployer = 0x1155b614971f16758C92c4890eD338C9e3ede6b7;
address multisig = 0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2;

ICErc20 wethMarket;
ICErc20 usdcMarket;
ICErc20 usdtMarket;
Expand Down Expand Up @@ -150,13 +152,45 @@ contract DevTesting is BaseTest {
}

function testAssetAsCollateralCap() public debuggingOnly fork(MODE_MAINNET) {
pool.getAssetAsCollateralValueCap(wethMarket, usdcMarket, false, deployer);
address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;
address ezEthWhale = 0xd3B02d999C681BD8B75F340FA7e078cE9097bF23;

vm.startPrank(multisig);
uint256 errCode = pool._deployMarket(
1, //delegateType
abi.encode(
MODE_EZETH,
address(pool),
ap.getAddress("FeeDistributor"),
0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode
"Renzo Restaked ETH",
"ezETH",
0.10e18,
0.10e18
),
"",
0.70e18
);
vm.stopPrank();
require(errCode == 0, "error deploying market");

ICErc20[] memory markets = pool.getAllMarkets();
ICErc20 ezEthMarket = markets[markets.length - 1];

// uint256 cap = pool.getAssetAsCollateralValueCap(ezEthMarket, usdcMarket, false, deployer);
uint256 cap = pool.supplyCaps(address(ezEthMarket));
require(cap == 0, "non-zero cap");

vm.startPrank(ezEthWhale);
ERC20(MODE_EZETH).approve(address(ezEthMarket), 1e36);
errCode = ezEthMarket.mint(1e18);
require(errCode == 0, "should be unable to supply");
}

function testRegisterSFS() public debuggingOnly fork(MODE_MAINNET) {
emit log_named_address("pool admin", pool.admin());

vm.startPrank(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2);
vm.startPrank(multisig);
pool.registerInSFS();

ICErc20[] memory markets = pool.getAllMarkets();
Expand All @@ -171,6 +205,42 @@ contract DevTesting is BaseTest {
require(usdcMarket.borrow(5e6) == 0, "can't borrow");
}

function testModeDeployMarket() public debuggingOnly fork(MODE_MAINNET) {
address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;
address weEthWhale = 0x6e55a90772B92f17f87Be04F9562f3faafd0cc38;

vm.startPrank(pool.admin());
uint256 errCode = pool._deployMarket(
1, //delegateType
abi.encode(
MODE_WEETH,
address(pool),
ap.getAddress("FeeDistributor"),
0x21a455cEd9C79BC523D4E340c2B97521F4217817, // irm - jump rate model on mode
"Ionic Wrapped eETH",
"ionweETH",
0.10e18,
0.10e18
),
"",
0.70e18
);
vm.stopPrank();
require(errCode == 0, "error deploying market");

ICErc20[] memory markets = pool.getAllMarkets();
ICErc20 weEthMarket = markets[markets.length - 1];

// uint256 cap = pool.getAssetAsCollateralValueCap(weEthMarket, usdcMarket, false, deployer);
uint256 cap = pool.supplyCaps(address(weEthMarket));
require(cap == 0, "non-zero cap");

vm.startPrank(weEthWhale);
ERC20(MODE_WEETH).approve(address(weEthMarket), 1e36);
errCode = weEthMarket.mint(0.01e18);
require(errCode == 0, "should be unable to supply");
}

function _functionCall(
address target,
bytes memory data,
Expand Down
9 changes: 9 additions & 0 deletions contracts/test/oracles/RedstoneAdapterOracleTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,36 @@ pragma solidity >=0.8.0;

import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import { MasterPriceOracle } from "../../oracles/MasterPriceOracle.sol";
import { RedstoneAdapterPriceOracle } from "../../oracles/default/RedstoneAdapterPriceOracle.sol";

import { BaseTest } from "../config/BaseTest.t.sol";

contract RedstoneAdapterOracleTest is BaseTest {
MasterPriceOracle public mpo;
RedstoneAdapterPriceOracle public oracle;
address public redstoneOracleAddress;
address MODE_USDC = 0xd988097fb8612cc24eeC14542bC03424c656005f;
address MODE_EZETH = 0x2416092f143378750bb29b79eD961ab195CcEea5;
address MODE_WBTC = 0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF;
address MODE_WEETH = 0x028227c4dd1e5419d11Bb6fa6e661920c519D4F5;

function afterForkSetUp() internal override {
if (block.chainid == MODE_MAINNET) {
redstoneOracleAddress = 0x7C1DAAE7BB0688C9bfE3A918A4224041c7177256;
}

oracle = new RedstoneAdapterPriceOracle(redstoneOracleAddress);
mpo = MasterPriceOracle(ap.getAddress("MasterPriceOracle"));
}

function testPrintPricesMode() public fork(MODE_MAINNET) {
emit log_named_uint("ezETH price (18 dec)", oracle.price(MODE_EZETH));
emit log_named_uint("WBTC price (8 dec)", oracle.price(MODE_WBTC));
emit log_named_uint("weETH price (18 dec)", oracle.price(MODE_WEETH));
}

function testPrintMpoPricesMode() public fork(MODE_MAINNET) {
emit log_named_uint("weETH price (18 dec)", mpo.price(MODE_WEETH));
}
}
Loading