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

Oeth L2 base plugin - Adjustments. #1227

Open
wants to merge 8 commits into
base: oeth-plugin
Choose a base branch
from
Open
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
113 changes: 5 additions & 108 deletions contracts/plugins/assets/origin/OETHCollateralL2Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,105 +3,9 @@ pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/math/Math.sol";
import "../../../libraries/Fixed.sol";
import "../AppreciatingFiatCollateral.sol";
import "../ERC4626FiatCollateral.sol";
import "../OracleLib.sol";

interface IWSuperOETHb {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
event GovernorshipTransferred(address indexed previousGovernor, address indexed newGovernor);
event PendingGovernorshipTransfer(
address indexed previousGovernor,
address indexed newGovernor
);
event Transfer(address indexed from, address indexed to, uint256 value);
event Withdraw(
address indexed caller,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);

function allowance(address owner, address spender) external view returns (uint256);

function approve(address spender, uint256 amount) external returns (bool);

function asset() external view returns (address);

function balanceOf(address account) external view returns (uint256);

function claimGovernance() external;

function convertToAssets(uint256 shares) external view returns (uint256 assets);

function convertToShares(uint256 assets) external view returns (uint256 shares);

function decimals() external view returns (uint8);

function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);

function deposit(uint256 assets, address receiver) external returns (uint256);

function governor() external view returns (address);

function increaseAllowance(address spender, uint256 addedValue) external returns (bool);

function initialize() external;

function isGovernor() external view returns (bool);

function maxDeposit(address) external view returns (uint256);

function maxMint(address) external view returns (uint256);

function maxRedeem(address owner) external view returns (uint256);

function maxWithdraw(address owner) external view returns (uint256);

function mint(uint256 shares, address receiver) external returns (uint256);

function name() external view returns (string memory);

function previewDeposit(uint256 assets) external view returns (uint256);

function previewMint(uint256 shares) external view returns (uint256);

function previewRedeem(uint256 shares) external view returns (uint256);

function previewWithdraw(uint256 assets) external view returns (uint256);

function redeem(
uint256 shares,
address receiver,
address owner
) external returns (uint256);

function symbol() external view returns (string memory);

function totalAssets() external view returns (uint256);

function totalSupply() external view returns (uint256);

function transfer(address recipient, uint256 amount) external returns (bool);

function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);

function transferGovernance(address _newGovernor) external;

function transferToken(address asset_, uint256 amount_) external;

function withdraw(
uint256 assets,
address receiver,
address owner
) external returns (uint256);
}

interface IMorphoChainlinkOracleV2 {
function price() external view returns (uint256);
}
Expand All @@ -114,7 +18,7 @@ interface IMorphoChainlinkOracleV2 {
* tar = ETH
* UoA = USD
*/
contract OETHCollateralL2Base is AppreciatingFiatCollateral {
contract OETHCollateralL2Base is ERC4626FiatCollateral {
using OracleLib for AggregatorV3Interface;
using FixLib for uint192;

Expand All @@ -125,14 +29,13 @@ contract OETHCollateralL2Base is AppreciatingFiatCollateral {

/// @param config.chainlinkFeed - ignored
/// @param config.oracleTimeout - ignored
/// @param config.oracleError {1} Should be the oracle error for UoA/tok
constructor(
CollateralConfig memory config,
uint192 revenueHiding,
IMorphoChainlinkOracleV2 _targetPerTokChainlinkFeed,
AggregatorV3Interface _uoaPerTargetChainlinkFeed,
uint48 _uoaPerTargetChainlinkTimeout
) AppreciatingFiatCollateral(config, revenueHiding) {
) ERC4626FiatCollateral(config, revenueHiding) {
require(config.defaultThreshold != 0, "defaultThreshold zero");

require(address(_targetPerTokChainlinkFeed) != address(0), "targetPerTokFeed missing");
Expand Down Expand Up @@ -162,7 +65,7 @@ contract OETHCollateralL2Base is AppreciatingFiatCollateral {
{
// {tar/tok}
// {ETH/wsuperOETHb}
uint192 targetPerTok = _safeWrap(targetPerTokChainlinkFeed.price()) / 1e18;
uint192 targetPerTok = _safeWrap(targetPerTokChainlinkFeed.price() / FIX_ONE);

// {UoA/tar}
// {USD/ETH}
Expand All @@ -179,12 +82,6 @@ contract OETHCollateralL2Base is AppreciatingFiatCollateral {

// {tar/ref} = {tar/tok} / {ref/tok} Get current market peg
// ETH/superOETHb = ETH/wsuperOETHb / superOETHb/wsuperOETHb
pegPrice = targetPerTok.div(underlyingRefPerTok());
}

/// @return {ref/tok} Quantity of whole reference units per whole collateral tokens
/// {superOETHb/wsuperOETHb}
function underlyingRefPerTok() public view override returns (uint192) {
return _safeWrap(IWSuperOETHb(address(erc20)).convertToAssets(FIX_ONE));
pegPrice = FIX_ONE;
}
}
5 changes: 1 addition & 4 deletions test/plugins/individual-collateral/origin/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export const BASE_FEEDS_TIMEOUT = {
wsuperOETHb_ETH: bn(86400),
ETH_USD: bn(1200),
}
export const BASE_ORACLE_ERROR = combinedError(
fp('0.0015'),
combinedError(fp('0.005'), fp('0.005'))
)
export const BASE_ORACLE_ERROR = combinedError(fp('0.005'), fp('0.015'))

// Data
export const PRICE_TIMEOUT = bn('604800') // 1 week
Expand Down