Skip to content

Commit

Permalink
removed euler-price-oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
RedVeil committed Jun 12, 2024
1 parent 63cb926 commit dfa74e7
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 37 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/euler-price-oracle"]
path = lib/euler-price-oracle
url = https://github.com/euler-xyz/euler-price-oracle
1 change: 0 additions & 1 deletion lib/euler-price-oracle
Submodule euler-price-oracle deleted from c4074a
82 changes: 64 additions & 18 deletions src/interfaces/external/aave/IAaveV3.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.20;

import {IERC20} from "openzeppelin-contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol";
import {IERC20} from "openzeppelin-contracts/token/ERC20/IERC20.sol";
import {DataTypes} from "./lib.sol";

interface IScaledBalanceToken {
Expand Down Expand Up @@ -45,7 +45,9 @@ interface IAaveIncentives {
* @dev Returns list of reward token addresses for particular aToken.
*
*/
function getRewardsByAsset(address asset) external view returns (address[] memory);
function getRewardsByAsset(
address asset
) external view returns (address[] memory);

/**
* @dev Returns list of reward tokens for all markets.
Expand All @@ -57,21 +59,44 @@ interface IAaveIncentives {
* @dev Claim all rewards for specified assets for user.
*
*/
function claimAllRewardsOnBehalf(address[] memory assets, address user, address to)
function claimAllRewardsOnBehalf(
address[] memory assets,
address user,
address to
)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmount);
}

// Aave lending pool interface
interface ILendingPool {
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;

function withdraw(address asset, uint256 amount, address to) external returns (uint256);

function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) external returns (uint256);
function supply(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;

function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf)
external;
function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);

function repay(
address asset,
uint256 amount,
uint256 rateMode,
address onBehalfOf
) external returns (uint256);

function borrow(
address asset,
uint256 amount,
uint256 interestRateMode,
uint16 referralCode,
address onBehalfOf
) external;

function flashLoan(
address receiverAddress,
Expand All @@ -83,11 +108,16 @@ interface ILendingPool {
uint16 referralCode
) external;

function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external;
function setUserUseReserveAsCollateral(
address asset,
bool useAsCollateral
) external;

function setUserEMode(uint8 category) external;

function getEModeCategoryData(uint8 id) external returns (DataTypes.EModeData memory emodeData);
function getEModeCategoryData(
uint8 id
) external returns (DataTypes.EModeData memory emodeData);

function getUserEMode(address user) external returns (uint256);

Expand All @@ -97,17 +127,27 @@ interface ILendingPool {
* @return The state of the reserve
*
*/
function getReserveData(address asset) external view returns (DataTypes.ReserveData2 memory);
function getReserveData(
address asset
) external view returns (DataTypes.ReserveData2 memory);

function getReserveNormalizedIncome(address asset) external view returns (uint256);
function getReserveNormalizedIncome(
address asset
) external view returns (uint256);
}

// Aave protocol data provider
interface IProtocolDataProvider {
function getReserveTokensAddresses(address asset)
function getReserveTokensAddresses(
address asset
)
external
view
returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress);
returns (
address aTokenAddress,
address stableDebtTokenAddress,
address variableDebtTokenAddress
);
}

interface IFlashLoanReceiver {
Expand All @@ -130,7 +170,10 @@ interface IFlashLoanReceiver {
bytes calldata params
) external returns (bool);

function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider);
function ADDRESSES_PROVIDER()
external
view
returns (IPoolAddressesProvider);

function POOL() external view returns (ILendingPool);
}
Expand Down Expand Up @@ -173,7 +216,10 @@ interface IPoolAddressesProvider {
* @param id The id
* @param newImplementationAddress The address of the new implementation
*/
function setAddressAsProxy(bytes32 id, address newImplementationAddress) external;
function setAddressAsProxy(
bytes32 id,
address newImplementationAddress
) external;

/**
* @notice Sets an address for an id replacing the address saved in the addresses map.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.23;

import {FixedPointMathLib} from "@solady/utils/FixedPointMathLib.sol";
import {Errors} from "src/lib/Errors.sol";
import {Errors} from "./Errors.sol";

type Scale is uint256;

Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/oracles/adapter/AaveV3Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pragma solidity ^0.8.23;

import {BaseAdapter, Errors, IPriceOracle} from "euler-price-oracle/adapter/BaseAdapter.sol";
import {BaseAdapter, Errors, IPriceOracle} from "./BaseAdapter.sol";
import {IAToken} from "src/interfaces/external/aave/IAaveV3.sol";

/// @title AaveV3 Oracle
Expand Down
26 changes: 20 additions & 6 deletions src/peripheral/oracles/adapter/BaseAdapter.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.23;
pragma solidity 0.8.25;

import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {IERC20} from "openzeppelin-contracts/token/ERC20/IERC20.sol";
import {IPriceOracle} from "src/interfaces/IPriceOracle.sol";
import {Errors} from "src/lib/Errors.sol";

Expand All @@ -11,13 +11,21 @@ import {Errors} from "src/lib/Errors.sol";
/// @notice Abstract adapter with virtual bid/ask pricing.
abstract contract BaseAdapter is IPriceOracle {
/// @inheritdoc IPriceOracle
function getQuote(uint256 inAmount, address base, address quote) external view returns (uint256) {
function getQuote(
uint256 inAmount,
address base,
address quote
) external view returns (uint256) {
return _getQuote(inAmount, base, quote);
}

/// @inheritdoc IPriceOracle
/// @dev Does not support true bid/ask pricing.
function getQuotes(uint256 inAmount, address base, address quote) external view returns (uint256, uint256) {
function getQuotes(
uint256 inAmount,
address base,
address quote
) external view returns (uint256, uint256) {
uint256 outAmount = _getQuote(inAmount, base, quote);
return (outAmount, outAmount);
}
Expand All @@ -30,11 +38,17 @@ abstract contract BaseAdapter is IPriceOracle {
/// - a contract that does not implement `decimals()`.
/// @return The decimals of the asset.
function _getDecimals(address asset) internal view returns (uint8) {
(bool success, bytes memory data) = asset.staticcall(abi.encodeCall(IERC20.decimals, ()));
(bool success, bytes memory data) = asset.staticcall(
abi.encodeCall(IERC20.decimals, ())
);
return success && data.length == 32 ? abi.decode(data, (uint8)) : 18;
}

/// @notice Return the quote for the given price query.
/// @dev Must be overridden in the inheriting contract.
function _getQuote(uint256, address, address) internal view virtual returns (uint256);
function _getQuote(
uint256,
address,
address
) internal view virtual returns (uint256);
}
7 changes: 3 additions & 4 deletions src/peripheral/oracles/adapter/CrossOracle.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.23;
pragma solidity ^0.8.25;

import {Errors, BaseAdapter} from "euler-price-oracle/adapter/BaseAdapter.sol";
import {IPriceOracle} from "euler-price-oracle/interfaces/IPriceOracle.sol";
import {ScaleUtils} from "euler-price-oracle/lib/ScaleUtils.sol";
import {Errors, BaseAdapter, IPriceOracle} from "./BaseAdapter.sol";
import {ScaleUtils} from "src/lib/ScaleUtils.sol";

struct OracleStep {
address base;
Expand Down
4 changes: 2 additions & 2 deletions src/peripheral/oracles/adapter/PendleLpOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

pragma solidity ^0.8.23;

import {BaseAdapter, Errors, IPriceOracle} from "euler-price-oracle/adapter/BaseAdapter.sol";
import {ScaleUtils, Scale} from "euler-price-oracle/lib/ScaleUtils.sol";
import {BaseAdapter, Errors, IPriceOracle} from "./BaseAdapter.sol";
import {ScaleUtils, Scale} from "src/lib/ScaleUtils.sol";

interface IPendleMarket {
function readTokens()
Expand Down
2 changes: 1 addition & 1 deletion src/peripheral/oracles/adapter/UniswapV3Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.23;
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {IUniswapV3Factory} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import {OracleLibrary} from "@uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol";
import {BaseAdapter, Errors, IPriceOracle} from "euler-price-oracle/adapter/BaseAdapter.sol";
import {BaseAdapter, Errors, IPriceOracle} from "./BaseAdapter.sol";

/// @title UniswapV3Oracle
/// @custom:security-contact [email protected]
Expand Down

0 comments on commit dfa74e7

Please sign in to comment.