good morning!!!!

Skip to content
Snippets Groups Projects
Commit 52937d11 authored by Jake Barber's avatar Jake Barber
Browse files

deploying

parent 2d7c0c34
Branches
Tags
No related merge requests found
Pipeline #29346 failed
...@@ -14,25 +14,21 @@ import "../../_external/openzeppelin/Initializable.sol"; ...@@ -14,25 +14,21 @@ import "../../_external/openzeppelin/Initializable.sol";
import "../../_external/openzeppelin/SafeERC20Upgradeable.sol"; import "../../_external/openzeppelin/SafeERC20Upgradeable.sol";
import "../../_external/openzeppelin/ReentrancyGuardUpgradeable.sol"; import "../../_external/openzeppelin/ReentrancyGuardUpgradeable.sol";
interface IERC4626 { interface IERC4626 {
// mints exactly shares vault shares to receiver by depositing assets of underlying tokens.
function mint(uint256 shares, address receiver) external returns (uint256 assets);
// deposits assets of underlying tokens into the vault and grants ownership of shares to receiver // deposits assets of underlying tokens into the vault and grants ownership of shares to receiver
function deposit(uint256 assets, address receiver) external returns (uint256 shares); function deposit(uint256 assets, address receiver) external returns (uint256 shares);
// redeems a specific number of shares from owner and sends assets of underlying token from the vault to receiver // redeems a specific number of shares from owner and sends assets of underlying token to receiver
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
// burns shares from owner and send exactly assets token from the vault to receiver
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
} }
/// @title CappedERC4626 /// @title CappedERC4626
/// @notice Wraps rebasing ERC4626 before being sent to the vault /// @notice Read more about ERC-4626 - https://eips.ethereum.org/EIPS/eip-4626
/// @dev _underlying should be the wrapped shares, whcih appreciate in price /// @notice Wraps rebasing ERC4626 before being sending the wrapped asset to the IP vault
/// @notice Deposits can be either the base or the wrapped asset
/// @notice Withdrawals are ALWAYS the base asset (rebasing)
/// @dev _underlying should be the wrapped shares, whcih appreciates in price
/// @dev _baseUnderlying should be the base asset, which appreciates in balance
/// @dev logic is otherwise the same as CappedGovToken /// @dev logic is otherwise the same as CappedGovToken
/// @dev extends ierc20 upgradable /// @dev extends ierc20 upgradable
contract CappedERC4626 is Initializable, OwnableUpgradeable, ERC20Upgradeable, ReentrancyGuardUpgradeable { contract CappedERC4626 is Initializable, OwnableUpgradeable, ERC20Upgradeable, ReentrancyGuardUpgradeable {
...@@ -99,13 +95,16 @@ contract CappedERC4626 is Initializable, OwnableUpgradeable, ERC20Upgradeable, R ...@@ -99,13 +95,16 @@ contract CappedERC4626 is Initializable, OwnableUpgradeable, ERC20Upgradeable, R
/// @param vaultId recipient vault of tokens /// @param vaultId recipient vault of tokens
/// @param depositBase is true if depositing the rebasing base asset /// @param depositBase is true if depositing the rebasing base asset
function deposit(uint256 amount, uint96 vaultId, bool depositBase) public nonReentrant { function deposit(uint256 amount, uint96 vaultId, bool depositBase) public nonReentrant {
//todo non reentrant
require(amount > 0, "Cannot deposit 0"); require(amount > 0, "Cannot deposit 0");
VotingVault votingVault = VotingVault(_votingVaultController.votingVaultAddress(vaultId)); VotingVault votingVault = VotingVault(_votingVaultController.votingVaultAddress(vaultId));
require(address(votingVault) != address(0x0), "invalid voting vault"); require(address(votingVault) != address(0x0), "invalid voting vault");
IVault vault = IVault(_vaultController.vaultAddress(vaultId)); IVault vault = IVault(_vaultController.vaultAddress(vaultId));
require(address(vault) != address(0x0), "invalid vault"); require(address(vault) != address(0x0), "invalid vault");
//if deposit base (base rebasing token)
//then we wrap and get new amount
//else we are depositing the wrapped token (appreciates in price rather than balance)
//so we just transfer normally
if (depositBase) { if (depositBase) {
amount = depositAndWrap(amount, address(votingVault)); amount = depositAndWrap(amount, address(votingVault));
} else { } else {
...@@ -135,7 +134,7 @@ contract CappedERC4626 is Initializable, OwnableUpgradeable, ERC20Upgradeable, R ...@@ -135,7 +134,7 @@ contract CappedERC4626 is Initializable, OwnableUpgradeable, ERC20Upgradeable, R
require(voting_vault_address != address(0x0), "no voting vault"); require(voting_vault_address != address(0x0), "no voting vault");
// burn the collateral tokens from the sender, which is the vault that holds the collateral tokens // burn the collateral tokens from the sender, which is the vault that holds the collateral tokens
ERC20Upgradeable._burn(_msgSender(), amount); ERC20Upgradeable._burn(_msgSender(), amount);
// move the underlying tokens from voting vault to the target // move the underlying tokens from voting vault to the this contract so we can then unwrap
_votingVaultController.retrieveUnderlying(amount, voting_vault_address, address(this)); _votingVaultController.retrieveUnderlying(amount, voting_vault_address, address(this));
return unwrap(amount, recipient); return unwrap(amount, recipient);
} }
......
...@@ -3,9 +3,6 @@ pragma solidity 0.8.9; ...@@ -3,9 +3,6 @@ pragma solidity 0.8.9;
import "../IOracleRelay.sol"; import "../IOracleRelay.sol";
//testing
import "hardhat/console.sol";
/***************************************** /*****************************************
* This gets USD price on Optimism based on the exchange rate * This gets USD price on Optimism based on the exchange rate
* found on the RocketOvmPriceOracle @ 0x1a8F81c256aee9C640e14bB0453ce247ea0DFE6F * found on the RocketOvmPriceOracle @ 0x1a8F81c256aee9C640e14bB0453ce247ea0DFE6F
...@@ -36,7 +33,6 @@ contract wOETH_ORACLE is IOracleRelay { ...@@ -36,7 +33,6 @@ contract wOETH_ORACLE is IOracleRelay {
function currentValue() external view override returns (uint256) { function currentValue() external view override returns (uint256) {
uint256 curvePrice = getCurvePrice(); uint256 curvePrice = getCurvePrice();
uint256 ethPrice = _ethOracle.currentValue(); uint256 ethPrice = _ethOracle.currentValue();
compare(ethPrice, curvePrice);
//apply wOETH conversion //apply wOETH conversion
uint256 priceInOeth = _priceFeed.previewDeposit(AMOUNT); uint256 priceInOeth = _priceFeed.previewDeposit(AMOUNT);
...@@ -44,18 +40,7 @@ contract wOETH_ORACLE is IOracleRelay { ...@@ -44,18 +40,7 @@ contract wOETH_ORACLE is IOracleRelay {
return ((curvePrice * 1e18) / priceInOeth); return ((curvePrice * 1e18) / priceInOeth);
} }
///@notice this confirms @param curvePrice is within 1% of @param ethPrices ///@notice price_oracle() returns a manipulation resistant EMA price
function compare(uint256 ethPrice, uint256 curvePrice) internal pure {
uint256 buffer = (curvePrice) / 100;
uint256 upperBounds = curvePrice + buffer;
uint256 lowerBounds = curvePrice - buffer;
require(ethPrice > lowerBounds, "Eth price too low");
require(ethPrice < upperBounds, "Eth price too high");
}
function getCurvePrice() internal view returns (uint256 cPrice) { function getCurvePrice() internal view returns (uint256 cPrice) {
uint256 ethPrice = _ethOracle.currentValue(); uint256 ethPrice = _ethOracle.currentValue();
uint256 priceInEth = _curvePool.price_oracle(); uint256 priceInEth = _curvePool.price_oracle();
......
...@@ -21,14 +21,10 @@ const { ethers } = require("hardhat"); ...@@ -21,14 +21,10 @@ const { ethers } = require("hardhat");
/*****************************CHANGE THESE/*****************************/ /*****************************CHANGE THESE/*****************************/
const ASSET_ADDRESS = a.woethAddress const ASSET_ADDRESS = a.woethAddress
//const CHAINLINK_DATA_FEED = "0x2c1d072e956affc0d435cb7ac38ef18d24d9127c" const CURVE_POOL = "0x94B17476A93b3262d87B9a326965D1E91f9c13E7"
//const UNIV3_POOL = "0xa6Cc3C2531FdaA6Ae1A3CA84c2855806728693e8" const CAP = BN("575e18")
const CAP = BN("375000e18")
/***********************************************************************/ /***********************************************************************/
//const existingImplementation = "0x9F86bf2C380d3C63177e6104320Fd3D1DcAE88DA"
let CappedWOETH: CappedGovToken let CappedWOETH: CappedGovToken
let AnchorView: IOracleRelay let AnchorView: IOracleRelay
...@@ -40,7 +36,7 @@ const deployCapTOKENs = async (deployer: SignerWithAddress) => { ...@@ -40,7 +36,7 @@ const deployCapTOKENs = async (deployer: SignerWithAddress) => {
undefined, undefined,
"CappedWOETH", "CappedWOETH",
"cwOETH", "cwOETH",
a.woethAddress, ASSET_ADDRESS,
a.oethAddress, a.oethAddress,
d.VaultController, d.VaultController,
d.VotingVaultController d.VotingVaultController
...@@ -53,8 +49,8 @@ const deployOracles = async (deployer: SignerWithAddress) => { ...@@ -53,8 +49,8 @@ const deployOracles = async (deployer: SignerWithAddress) => {
AnchorView = await DeployContract( AnchorView = await DeployContract(
new WOETH_ORACLE__factory(deployer), new WOETH_ORACLE__factory(deployer),
deployer, deployer,
"0x94B17476A93b3262d87B9a326965D1E91f9c13E7",//curve pool CURVE_POOL,
a.woethAddress, ASSET_ADDRESS,
d.EthOracle d.EthOracle
) )
await AnchorView.deployed() await AnchorView.deployed()
...@@ -67,14 +63,14 @@ const deploy = async (deployer: SignerWithAddress) => { ...@@ -67,14 +63,14 @@ const deploy = async (deployer: SignerWithAddress) => {
await deployCapTOKENs(deployer) await deployCapTOKENs(deployer)
console.log("All Cap TOKENs deployed") console.log("All contracts deployed")
await deployOracles(deployer) await deployOracles(deployer)
console.log("All oracles have been deployed successfully") console.log("All oracles have been deployed")
//await CappedWOETH.setCap(CAP) await CappedWOETH.setCap(CAP)
//console.log("Set TOKEN cap to: ", await toNumber(CAP)) console.log("Set cap to: ", await toNumber(CAP))
}; };
...@@ -89,8 +85,9 @@ async function main() { ...@@ -89,8 +85,9 @@ async function main() {
console.log("DEPLOYING TO MAINNET") console.log("DEPLOYING TO MAINNET")
} }
console.log("Getting accounts")
const accounts = await ethers.getSigners(); const accounts = await ethers.getSigners();
console.log("Got accounts")
const deployer = accounts[0]; const deployer = accounts[0];
console.log("Deployer: ", deployer.address) console.log("Deployer: ", deployer.address)
......
...@@ -11,6 +11,7 @@ export interface Addresser { ...@@ -11,6 +11,7 @@ export interface Addresser {
compVotingAddress: string compVotingAddress: string
} }
//mainnet addresses that are external to IP //mainnet addresses that are external to IP
export class MainnetAddresses { export class MainnetAddresses {
readonly wethAddress: string = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" readonly wethAddress: string = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment