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

Deploying the STONE market - test check #53

Merged
merged 4 commits into from
Mar 26, 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
60 changes: 59 additions & 1 deletion contracts/test/DevTesting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { Unitroller } from "../compound/Unitroller.sol";
import { DiamondExtension } from "../ionic/DiamondExtension.sol";
import { ICErc20 } from "../compound/CTokenInterfaces.sol";
import { ISwapRouter } from "../external/uniswap/ISwapRouter.sol";
import { MasterPriceOracle } from "../oracles/MasterPriceOracle.sol";
import { RedstoneAdapterPriceOracle } from "../oracles/default/RedstoneAdapterPriceOracle.sol";
import { MasterPriceOracle, BasePriceOracle } from "../oracles/MasterPriceOracle.sol";
import { PoolLens } from "../PoolLens.sol";
import { PoolLensSecondary } from "../PoolLensSecondary.sol";
import { JumpRateModel } from "../compound/JumpRateModel.sol";
Expand Down Expand Up @@ -208,6 +209,52 @@ contract DevTesting is BaseTest {
require(errCode == 0, "should be unable to supply");
}

function testNewStoneMarketCapped() public debuggingOnly fork(MODE_MAINNET) {
address MODE_STONE = 0x80137510979822322193FC997d400D5A6C747bf7;
address stoneWhale = 0x76486cbED5216C82d26Ee60113E48E06C189541A;

address redstoneOracleAddress = 0x63A1531a06F0Ac597a0DfA5A516a37073c3E1e0a;
RedstoneAdapterPriceOracle oracle = RedstoneAdapterPriceOracle(redstoneOracleAddress);
MasterPriceOracle mpo = MasterPriceOracle(ap.getAddress("MasterPriceOracle"));

BasePriceOracle[] memory oracles = new BasePriceOracle[](1);
oracles[0] = oracle;
vm.prank(mpo.admin());
mpo.add(asArray(MODE_STONE), oracles);

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

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

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

vm.startPrank(stoneWhale);
ERC20(MODE_STONE).approve(address(stoneMarket), 1e36);
vm.expectRevert("not authorized");
errCode = stoneMarket.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());

Expand Down Expand Up @@ -285,6 +332,17 @@ contract DevTesting is BaseTest {
// }
}

function testModeAccountLiquidity() public debuggingOnly fork(MODE_MAINNET) {
address borrower = 0x0C387030a5D3AcDcde1A8DDaF26df31BbC1CE763;
(uint256 error, uint256 collateralValue, uint256 liquidity, uint256 shortfall) = pool.getAccountLiquidity(borrower);

emit log("");
emit log_named_address("user", borrower);
emit log_named_uint("collateralValue", collateralValue);
if (liquidity > 0) emit log_named_uint("liquidity", liquidity);
if (shortfall > 0) emit log_named_uint("SHORTFALL", shortfall);
}

function testModeUsdcBorrow() public debuggingOnly fork(MODE_MAINNET) {
vm.prank(deployer);
require(usdcMarket.borrow(5e6) == 0, "can't borrow");
Expand Down
3 changes: 1 addition & 2 deletions contracts/test/LeveredPositionTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ contract ModeWethUSDTLeveredPositionTest is LeveredPositionTest {
function afterForkSetUp() internal override {
super.afterForkSetUp();

uint256 depositAmount = 10e18;
uint256 depositAmount = 1e18;

address wethMarket = 0x71ef7EDa2Be775E5A7aa8afD02C45F059833e9d2;
address USDTMarket = 0x94812F2eEa03A49869f95e1b5868C6f3206ee3D3;
Expand All @@ -1016,7 +1016,6 @@ contract ModeWethUSDTLeveredPositionTest is LeveredPositionTest {

vm.prank(comptroller.admin());
comptroller._setMarketBorrowCaps(cTokens, newBorrowCaps);
vm.stopPrank();

_configurePair(wethMarket, USDTMarket);
_fundMarketAndSelf(ICErc20(wethMarket), wethWhale);
Expand Down
Loading