Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base Market Deployments #110

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: codespell-project/actions-codespell@v2.0
with:
check_filenames: true
ignore_words_list: we
ignore_words_list: we,amountIn
skip: ./.git,./lib,./certora

validate-links:
Expand Down
6 changes: 3 additions & 3 deletions deployment-config/00_Default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"initialDefaultAdmin": "0x94544835Cf97c631f101c5f538787fE14E2E04f6",
"protocol": "0x0000000000417626Ef34D62C4DC189b021603f2F",
"ilkAddress": "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110"
}
"protocol": "0xE5a5F3A6C88B894710992e1C2626be0DEB99566E",
"ilkAddress": "0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A"
}
2 changes: 1 addition & 1 deletion deployment-config/02_DeployInterestRateModule.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"adjustedAboveKinkSlope": "0",
"minimumAboveKinkSlope": "64011036758000000000"
},
"yieldOracleAddress": "0x437CC840e234C2127f54CD59B0B18aF59c586760"
"yieldOracleAddress": "0x2CAe5eD3b35654499EE605cD66A9b14a0d053773"
}
15 changes: 7 additions & 8 deletions deployment-config/04_DeployIonPool.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"underlying": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"treasury": "0x0000000000417626Ef34D62C4DC189b021603f2F",
"underlying": "0x4200000000000000000000000000000000000006",
"treasury": "0xE5a5F3A6C88B894710992e1C2626be0DEB99566E",
"decimals": "18",
"name": "Ion ezETH WETH Token",
"symbol": "iezETH-WETH",
"whitelist": "0x7E317f99aA313669AaCDd8dB3927ff3aCB562dAD",
"interestRateModule": "0xCcfD0fDEE103B4b4e45B5D8934540070219A6653",
"ionImpl": "0x77ca0d4b78d8b4f3c71e20f8c8771c4cb7abe201",
"salt": "0x413a3e110b6efc009e045a000000000000000000000000000000000000000000"
"name": "Ion weETH WETH Token",
"symbol": "iweETH-WETH",
"whitelist": "0xf98248f0dA9D51d827A3C42d608acF65c77BD76A",
"interestRateModule": "0x7BC91582b10c3ce83be1918daE5136B59FC55e01",
"salt": "0xa53bcb7572e19b03e4aae7000000000000000000000000000000000000000000"
}
3 changes: 2 additions & 1 deletion deployment-config/05_DeployInitialReserveAndSpotOracles.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"maxChange": "30000000000000000000000000",
"ltv": "930000000000000000000000000",
"maxTimeFromLastUpdate": "87000"
"maxTimeFromLastUpdate": "87000",
"gracePeriod": "3600"
}
6 changes: 3 additions & 3 deletions deployment-config/06_SetupCollateral.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ionPool": "0x00000000008a3A77bd91bC738Ed2Efaa262c3763",
"spotOracle": "0x08fEDD981732c2a0EceCd4c70a41eA3AC454A6FD",
"debtCeiling": "0",
"ionPool": "0x00000000000fA8e0FD26b4554d067CF1856De7F5",
"spotOracle": "0x5D83953248cbF1FF723978FbD3490D9a2385A52d",
"debtCeiling": "000000000000000000000000000000000000000000000000",
"dust": "4000000000000000000000000000000000000000000000"
}
2 changes: 1 addition & 1 deletion deployment-config/07_DeployGemJoin.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ionPool": "0x00000000008a3A77bd91bC738Ed2Efaa262c3763"
"ionPool": "0x00000000000fA8e0FD26b4554d067CF1856De7F5"
}
6 changes: 3 additions & 3 deletions deployment-config/08_DeployHandlers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ionPool": "0x00000000008a3A77bd91bC738Ed2Efaa262c3763",
"gemJoin": "0xe3692b2E55Eb2494cA73610c3b027F53815CCD39",
"whitelist": "0x7E317f99aA313669AaCDd8dB3927ff3aCB562dAD"
"ionPool": "0x00000000000fA8e0FD26b4554d067CF1856De7F5",
"gemJoin": "0xe21ae2d45dEDF8dEE2D854774a904d33b8700E78",
"whitelist": "0xf98248f0dA9D51d827A3C42d608acF65c77BD76A"
}
6 changes: 3 additions & 3 deletions deployment-config/09_DeployLiquidation.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"liquidationThreshold": "960000000000000000000000000",
"maxDiscount": "200000000000000000000000000",
"reserveFactor": "10000000000000000000000000",
"ionPool": "0x00000000008a3A77bd91bC738Ed2Efaa262c3763",
"reserveOracle": "0x3239396B740cD6BBABb42196A03f7B77fA7102C9",
"salt": "0xb54f84bfabde3501ca221f000000000000000000000000000000000000000000"
"ionPool": "0x00000000000fA8e0FD26b4554d067CF1856De7F5",
"reserveOracle": "0x39c66dEAA7BA7576ed1498C5A0601454740e386C",
"salt": "0x7dbc99ede0e74803aa149e000000000000000000000000000000000000000000"
}
12 changes: 6 additions & 6 deletions deployment-config/10_AdminTransfer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"ionPool": "0x00000000008a3A77bd91bC738Ed2Efaa262c3763",
"yieldOracle": "0x437CC840e234C2127f54CD59B0B18aF59c586760",
"whitelist": "0x7E317f99aA313669AaCDd8dB3927ff3aCB562dAD",
"proxyAdmin": "91192b4d46d77d013bdee650ad38452ed1da0175",
"liquidation": "0x0000000000d8858E1A9B373582A691dB992C23CA",
"gemJoin": "0xe3692b2E55Eb2494cA73610c3b027F53815CCD39"
"ionPool": "0x00000000000fA8e0FD26b4554d067CF1856De7F5",
"yieldOracle": "0x2CAe5eD3b35654499EE605cD66A9b14a0d053773",
"whitelist": "0xf98248f0dA9D51d827A3C42d608acF65c77BD76A",
"proxyAdmin": "0xe559662C42FF6460BE7c7f0C67aBA789Fde53861",
"liquidation": "0x00000000009229776762B5e6b865a06afeB4444c",
"gemJoin": "0xe21ae2d45dEDF8dEE2D854774a904d33b8700E78"
}
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ remappings = ["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"forge-safe/=lib/forge-safe/src/"]
fs_permissions = [{ access = "read-write", path = "./"}]
optimizer = true
optimizer_runs = 300
optimizer_runs = 200
no_match_contract = "Echidna"
no_match_path = "script/**/*.sol"
gas_reports = ["IonHandler", "IonRegistry", "TransparentUpgradeableProxy", "IonPool", "WstEthHandler", "EthXHandler", "SwEthHandler", "GemJoin", "InterestRate", "Whitelist", "WeEthHandler"]
Expand Down
4 changes: 2 additions & 2 deletions script/deploy-test/03_DeployWhitelist.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Whitelist } from "../../src/Whitelist.sol";
contract DeployWhitelistTest is DeployTestBase, DeployWhitelistScript {
function checkState(Whitelist whitelist) public {
assert(address(whitelist).code.length > 0);
// assertEq(whitelist.owner(), initialDefaultAdmin, "initial owner");
assertEq(whitelist.owner(), initialDefaultAdmin, "initial owner");
assertEq(whitelist.lendersRoot(), lenderRoot, "lendersRoot");
assertEq(whitelist.borrowersRoot(0), borrowerRoots[0], "borrowersRoot(0)");
assertEq(whitelist.pendingOwner(), protocol, "pendingOwner");
assertEq(whitelist.pendingOwner(), address(0), "pendingOwner should be zero");

vm.startPrank(initialDefaultAdmin);
whitelist.transferOwnership(protocol);
Expand Down
2 changes: 1 addition & 1 deletion script/deploy-test/10_AdminTransfer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract DeployAdminTransferTest is DeployTestBase, AdminTransferScript {
assertLe(addressSchedule, block.timestamp, "address schedule");

// assertEq(yieldOracle.pendingOwner(), protocol, "yield oracle pending owner");
// assertEq(whitelist.pendingOwner(), protocol, "whitelist pending owner");
assertEq(whitelist.pendingOwner(), protocol, "whitelist pending owner");
assertEq(proxyAdmin.pendingOwner(), protocol, "proxy admin pending owner");
assertTrue(ionPool.hasRole(ionPool.GEM_JOIN_ROLE(), address(gemJoin)), "gem join role");
assertTrue(ionPool.hasRole(ionPool.LIQUIDATOR_ROLE(), address(liquidation)), "gem join role");
Expand Down
15 changes: 8 additions & 7 deletions script/deploy/04_DeployIonPool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ contract DeployIonPoolScript is DeployScript {
bytes32 salt = config.readBytes32(".salt");

function createX() public returns (IonPool ionImpl, IonPool ionPool) {
ionImpl = IonPool(config.readAddress(".ionImpl"));
// ionImpl = IonPool(config.readAddress(".ionImpl"));

_validateInterface(IERC20(underlying));
_validateInterface(interestRateModule);
_validateInterface(whitelist);

// ionImpl = IonPool();
_validateInterfaceIonPool(ionImpl);

// if (deployCreate2) {
// ionImpl = new IonPool{ salt: DEFAULT_SALT }();
// } else {
// ionImpl = new IonPool();
// }
if (deployCreate2) {
ionImpl = new IonPool{ salt: DEFAULT_SALT }();
} else {
ionImpl = new IonPool();
}

_validateInterfaceIonPool(ionImpl);

bytes memory initCode = type(TransparentUpgradeableProxy).creationCode;

Expand Down
22 changes: 16 additions & 6 deletions script/deploy/05_DeployInitialReserveAndSpotOracles.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity 0.8.21;

import { DeployScript } from "../Deploy.s.sol";
import { RAY } from "../../src/libraries/math/WadRayMath.sol";
import { EzEthWethReserveOracle } from "./../../src/oracles/reserve/lrt/EzEthWethReserveOracle.sol";
import { EzEthWethSpotOracle } from "./../../src/oracles/spot/lrt/EzEthWethSpotOracle.sol";
import { WeEthWethReserveOracle } from "./../../src/oracles/reserve/lrt/WeEthWethReserveOracle.sol";
import { WeEthWethSpotOracle } from "./../../src/oracles/spot/lrt/WeEthWethSpotOracle.sol";

import { stdJson as StdJson } from "forge-std/StdJson.sol";

Expand All @@ -15,6 +15,7 @@ contract DeployInitialReserveAndSpotOraclesScript is DeployScript {
string config = vm.readFile(configPath);

uint256 maxChange = config.readUint(".maxChange");
uint256 gracePeriod = config.readUint(".gracePeriod");
uint256 ltv = config.readUint(".ltv");

function run() public broadcast returns (address reserveOracle, address spotOracle) {
Expand All @@ -28,13 +29,22 @@ contract DeployInitialReserveAndSpotOraclesScript is DeployScript {
uint256 maxTimeFromLastUpdate = config.readUint(".maxTimeFromLastUpdate");

if (deployCreate2) {
reserveOracle = address(new EzEthWethReserveOracle{ salt: DEFAULT_SALT }(0, new address[](3), 0, maxChange));
reserveOracle = address(
new WeEthWethReserveOracle{ salt: DEFAULT_SALT }(
0, new address[](3), 0, maxChange, maxTimeFromLastUpdate, gracePeriod
)
);
spotOracle = address(
new EzEthWethSpotOracle{ salt: DEFAULT_SALT }(ltv, address(reserveOracle), maxTimeFromLastUpdate)
new WeEthWethSpotOracle{ salt: DEFAULT_SALT }(
ltv, address(reserveOracle), maxTimeFromLastUpdate, gracePeriod
)
);
} else {
reserveOracle = address(new EzEthWethReserveOracle(0, new address[](3), 0, maxChange));
spotOracle = address(new EzEthWethSpotOracle(ltv, address(reserveOracle), maxTimeFromLastUpdate));
reserveOracle = address(
new WeEthWethReserveOracle(0, new address[](3), 0, maxChange, maxTimeFromLastUpdate, gracePeriod)
);
spotOracle =
address(new WeEthWethSpotOracle(ltv, address(reserveOracle), maxTimeFromLastUpdate, gracePeriod));
}
}
}
24 changes: 18 additions & 6 deletions script/deploy/08_DeployHandlers.s.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import { MAINNET_WSTETH_WETH_UNISWAP, EZETH_WETH_BALANCER_POOL_ID } from "../../src/Constants.sol";
import { BASE_WETH, BASE_WEETH_WETH_BALANCER_POOL_ID, BASE_WSTETH_WETH_UNISWAP } from "../../src/Constants.sol";
import { DeployScript } from "../Deploy.s.sol";
import { IonPool } from "../../src/IonPool.sol";
import { GemJoin } from "../../src/join/GemJoin.sol";
import { Whitelist } from "../../src/Whitelist.sol";
import { IonHandlerBase } from "../../src/flash/IonHandlerBase.sol";
import { EzEthWethHandler } from "./../../src/flash/lrt/EzEthWethHandler.sol";
import { WeEthWethHandler } from "./../../src/flash/lrt/WeEthWethHandler.sol";
import { stdJson as StdJson } from "forge-std/StdJson.sol";

// NOTE: Different handlers will have different constructor parameters.
Expand All @@ -28,12 +28,24 @@ contract DeployHandlersScript is DeployScript {
_validateInterfaceIonPool(ionPool);

if (deployCreate2) {
handler = new EzEthWethHandler{ salt: DEFAULT_SALT }(
ILK_INDEX_ZERO, ionPool, gemJoin, whitelist, MAINNET_WSTETH_WETH_UNISWAP, EZETH_WETH_BALANCER_POOL_ID
handler = new WeEthWethHandler{ salt: DEFAULT_SALT }(
ILK_INDEX_ZERO,
ionPool,
gemJoin,
whitelist,
BASE_WSTETH_WETH_UNISWAP,
BASE_WEETH_WETH_BALANCER_POOL_ID,
BASE_WETH
);
} else {
handler = new EzEthWethHandler{ salt: DEFAULT_SALT }(
ILK_INDEX_ZERO, ionPool, gemJoin, whitelist, MAINNET_WSTETH_WETH_UNISWAP, EZETH_WETH_BALANCER_POOL_ID
handler = new WeEthWethHandler{ salt: DEFAULT_SALT }(
ILK_INDEX_ZERO,
ionPool,
gemJoin,
whitelist,
BASE_WSTETH_WETH_UNISWAP,
BASE_WEETH_WETH_BALANCER_POOL_ID,
BASE_WETH
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion script/deploy/10_AdminTransfer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract AdminTransferScript is DeployScript {

ionPool.beginDefaultAdminTransfer(protocol);
// yieldOracle.transferOwnership(protocol);
// whitelist.transferOwnership(protocol);
whitelist.transferOwnership(protocol);
proxyAdmin.transferOwnership(protocol);
}
}
13 changes: 13 additions & 0 deletions src/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import {
IRenzoOracle,
IRestakeManager
} from "./interfaces/ProviderInterfaces.sol";
import { IWETH9 } from "./interfaces/IWETH9.sol";
import { IRedstonePriceFeed } from "./interfaces/IRedstone.sol";
import { IChainlink } from "./interfaces/IChainlink.sol";
import { ICreateX } from "./interfaces/ICreateX.sol";

import { IPMarketV3 } from "pendle-core-v2-public/interfaces/IPMarketV3.sol";

import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import { IERC20 } from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";

uint8 constant REDSTONE_DECIMALS = 8;

Expand All @@ -53,6 +55,8 @@ IEtherFiLiquidityPool constant ETHER_FI_LIQUIDITY_POOL_ADDRESS =
IWeEth constant WEETH_ADDRESS = IWeEth(0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee);
IRedstonePriceFeed constant REDSTONE_WEETH_ETH_PRICE_FEED =
IRedstonePriceFeed(0x8751F736E94F6CD167e8C5B97E245680FbD9CC36);
IChainlink constant BASE_WEETH_ETH_PRICE_CHAINLINK = IChainlink(0xFC1415403EbB0c693f9a7844b92aD2Ff24775C65);
IChainlink constant BASE_WEETH_ETH_EXCHANGE_RATE_CHAINLINK = IChainlink(0x35e9D7001819Ea3B39Da906aE6b06A62cfe2c181);

jpick713 marked this conversation as resolved.
Show resolved Hide resolved
// rsETH
IRedstonePriceFeed constant REDSTONE_RSETH_ETH_PRICE_FEED =
Expand Down Expand Up @@ -97,3 +101,12 @@ IPMarketV3 constant PT_RSWETH_POOL = IPMarketV3(0x1729981345aa5CaCdc19eA9eeffea9

// CreateX
ICreateX constant CREATEX = ICreateX(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed);

// --- BASE ---

// EtherFi
bytes32 constant BASE_WEETH_WETH_BALANCER_POOL_ID = 0xab99a3e856deb448ed99713dfce62f937e2d4d74000000000000000000000118;
IUniswapV3Pool constant BASE_WSTETH_WETH_UNISWAP = IUniswapV3Pool(0x20E068D76f9E90b90604500B84c7e19dCB923e7e);
IChainlink constant BASE_SEQUENCER_UPTIME_FEED = IChainlink(0xBCF85224fc0756B9Fa45aA7892530B47e10b6433);
IERC20 constant BASE_WEETH = IERC20(0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A);
IWETH9 constant BASE_WETH = IWETH9(0x4200000000000000000000000000000000000006);
4 changes: 3 additions & 1 deletion src/flash/BalancerFlashloanDirectMintHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ IVault constant VAULT = IVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);

/**
* @notice This contract allows for easy creation of leverage positions through
* Balancer flashloans and LST mints through the LST provider.
* Balancer flashloans and LST mints through the LST provider. This contract
* should be used when the base asset of the market is `WETH` and when the asset
* required to mint the collateral is also `WETH`.
*
* @dev There are a couple things to consider here from a security perspective. The
* first one is that the flashloan callback must only be callable from the
Expand Down
10 changes: 4 additions & 6 deletions src/flash/IonHandlerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { IWETH9 } from "../interfaces/IWETH9.sol";
import { GemJoin } from "../join/GemJoin.sol";
import { WadRayMath, RAY } from "../libraries/math/WadRayMath.sol";
import { Whitelist } from "../Whitelist.sol";
import { WETH_ADDRESS } from "../Constants.sol";

import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down Expand Up @@ -70,9 +69,8 @@ abstract contract IonHandlerBase {
}

IERC20 public immutable BASE;
// Will keep WETH for compatibility with other strategies. But this should
// be removed eventually to remove dependence on WETH as a base asset.
IWETH9 public immutable WETH;

uint8 public immutable ILK_INDEX;
IonPool public immutable POOL;
GemJoin public immutable JOIN;
Expand All @@ -86,14 +84,14 @@ abstract contract IonHandlerBase {
* @param _gemJoin the `GemJoin` associated with the `ilkIndex` of this
* contract.
* @param _whitelist the `Whitelist` module address.
* @param _weth The WETH address of the chain.
*/
constructor(uint8 _ilkIndex, IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist) {
constructor(uint8 _ilkIndex, IonPool _ionPool, GemJoin _gemJoin, Whitelist _whitelist, IWETH9 _weth) {
POOL = _ionPool;
ILK_INDEX = _ilkIndex;

BASE = IERC20(_ionPool.underlying());

IWETH9 _weth = WETH_ADDRESS;
WETH = _weth;

address ilkAddress = POOL.getIlkAddress(_ilkIndex);
Expand Down Expand Up @@ -262,6 +260,6 @@ abstract contract IonHandlerBase {
* @dev To allow unwrapping of WETH into ETH.
*/
receive() external payable {
if (msg.sender != address(WETH_ADDRESS)) revert CannotSendEthToContract();
if (msg.sender != address(WETH)) revert CannotSendEthToContract();
}
}
6 changes: 4 additions & 2 deletions src/flash/PtHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IonPool } from "../IonPool.sol";
import { GemJoin } from "../join/GemJoin.sol";
import { Whitelist } from "../Whitelist.sol";
import { IonHandlerBase } from "./IonHandlerBase.sol";
import { IWETH9 } from "./../interfaces/IWETH9.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down Expand Up @@ -47,9 +48,10 @@ contract PtHandler is IonHandlerBase, IPMarketSwapCallback {
IonPool pool,
GemJoin join,
Whitelist whitelist,
IPMarketV3 _market
IPMarketV3 _market,
IWETH9 _weth
)
IonHandlerBase(0, pool, join, whitelist)
IonHandlerBase(0, pool, join, whitelist, _weth)
{
if (!pool.hasRole(pool.GEM_JOIN_ROLE(), address(join))) revert InvalidGemJoin(address(join));

Expand Down
Loading
Loading