Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"fmt:check": "forge fmt --check",
"solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix",
"solhint:check": "solhint --config ./.solhint.json 'src/**/*.sol'",
"lint": "npm run fmt && npm run solhint",
"lint": "npm run solhint && npm run fmt",
"lint:check": "npm run fmt:check && npm run solhint:check"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/ChainlinkPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ contract ChainlinkPriceOracle is IPriceOracle {
* @param token The ERC20 token to retrieve the USD price for
* @return price The price of the token in USD
*/
function getPriceUSD(address token) external view returns (uint256) {
function getPriceUSD(IERC20 token) external view returns (uint256) {
(, int256 price,,,) = chainlinkPriceOracle.latestRoundData();
// get rid of warnings
uint256 tmp = uint256(uint160(token));
uint256 tmp = uint256(uint160(address(token)));
uint256 price2 = uint256(price);
return tmp + price2;
}
Expand Down
77 changes: 77 additions & 0 deletions src/interfaces/IERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: MIT
Copy link
Contributor

@Flip-Liquid Flip-Liquid Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm making some edits to the price oracle contract in a separate PR. since I'm already editing the other contract, if you back out these IERC20 changes, I can integrate them in the other PR. jsut don't want to have to deal with the conflict.


pragma solidity >=0.8.0;

/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);

/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);

/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);

/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);

/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);

/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);

/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);

/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
7 changes: 5 additions & 2 deletions src/interfaces/IPriceOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.8.13;

import "solmate/tokens/ERC20.sol";
import "./IERC20.sol";

/**
* @notice This is an interface for contracts providing the price of a token, in
Expand All @@ -11,12 +12,14 @@ import "solmate/tokens/ERC20.sol";
* by being wrapped in a contract implementing this interface.
*/
interface IPriceOracle {
error PriceNotAvailable();

/**
* @notice
* @notice Reverts PriceNotAvailable if the USD price cannot be derived
* @param token The ERC20 token to retrieve the USD price for
* @return price The price of the token in USD
*/
function getPriceUSD(address token) external view returns (uint256 price);
function getPriceUSD(IERC20 token) external view returns (uint256 price);

/**
* @notice Returns the scaling factor for the price
Expand Down
14 changes: 1 addition & 13 deletions src/interfaces/IVolatilityOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ pragma solidity 0.8.13;
* by being wrapped in a contract implementing this interface.
*/
interface IVolatilityOracle {
enum UniswapV3FeeTier {
PCT_POINT_01,
PCT_POINT_05,
PCT_POINT_3,
PCT_1
}

/**
* @notice Retrieves the historical volatility of a ERC20 token.
* @param token The ERC20 token for which to retrieve historical volatility.
Expand All @@ -27,14 +20,9 @@ interface IVolatilityOracle {
* @notice Retrieves the implied volatility of a ERC20 token.
* @param tokenA The ERC20 token for which to retrieve historical volatility.
* @param tokenB The ERC20 token for which to retrieve historical volatility.
* @param tier The Uniswap fee tier for the desired pool on which to derive a
* volatility measurement.
* @return impliedVolatility The implied volatility of the token, scaled by 1e18
*/
function getImpliedVolatility(address tokenA, address tokenB, UniswapV3FeeTier tier)
external
view
returns (uint256 impliedVolatility);
function getImpliedVolatility(address tokenA, address tokenB) external view returns (uint256 impliedVolatility);

/**
* @notice Returns the scaling factor for the volatility
Expand Down