-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Gearbox-protocol/new-interfaces
- Loading branch information
Showing
2 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.10; | ||
|
||
interface ITimelock { | ||
event NewAdmin(address indexed newAdmin); | ||
event NewPendingAdmin(address indexed newPendingAdmin); | ||
event NewDelay(uint256 indexed newDelay); | ||
event CancelTransaction( | ||
bytes32 indexed txHash, | ||
address indexed target, | ||
uint256 value, | ||
string signature, | ||
bytes data, | ||
uint256 eta | ||
); | ||
event ExecuteTransaction( | ||
bytes32 indexed txHash, | ||
address indexed target, | ||
uint256 value, | ||
string signature, | ||
bytes data, | ||
uint256 eta | ||
); | ||
event QueueTransaction( | ||
bytes32 indexed txHash, | ||
address indexed target, | ||
uint256 value, | ||
string signature, | ||
bytes data, | ||
uint256 eta | ||
); | ||
|
||
function admin() external view returns (address); | ||
|
||
function pendingAdmin() external view returns (address); | ||
|
||
function delay() external view returns (uint256); | ||
|
||
function queuedTransactions(bytes32 txHash) external view returns (bool); | ||
|
||
function setDelay(uint256 delay_) external; | ||
|
||
function acceptAdmin() external; | ||
|
||
function setPendingAdmin(address pendingAdmin_) external; | ||
|
||
function queueTransaction( | ||
address target, | ||
uint256 value, | ||
string memory signature, | ||
bytes memory data, | ||
uint256 eta | ||
) external returns (bytes32); | ||
|
||
function cancelTransaction( | ||
address target, | ||
uint256 value, | ||
string memory signature, | ||
bytes memory data, | ||
uint256 eta | ||
) external; | ||
|
||
function executeTransaction( | ||
address target, | ||
uint256 value, | ||
string memory signature, | ||
bytes memory data, | ||
uint256 eta | ||
) external payable returns (bytes memory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Gearbox Protocol. Generalized leverage for DeFi protocols | ||
// (c) Gearbox Holdings, 2022 | ||
pragma solidity ^0.8.10; | ||
import { IVersion } from "./IVersion.sol"; | ||
|
||
interface IPriceOracleV2Events { | ||
/// @dev Emits when a new price feed is added | ||
event NewPriceFeed(address indexed token, address indexed priceFeed); | ||
} | ||
|
||
interface IPriceOracleV2Exceptions { | ||
/// @dev Thrown if a price feed returns 0 | ||
error ZeroPriceException(); | ||
|
||
/// @dev Thrown if the last recorded result was not updated in the last round | ||
error ChainPriceStaleException(); | ||
|
||
/// @dev Thrown on attempting to get a result for a token that does not have a price feed | ||
error PriceOracleNotExistsException(); | ||
} | ||
|
||
/// @title Price oracle interface | ||
interface IPriceOracleV2 is | ||
IPriceOracleV2Events, | ||
IPriceOracleV2Exceptions, | ||
IVersion | ||
{ | ||
/// @dev Converts a quantity of an asset to USD (decimals = 8). | ||
/// @param amount Amount to convert | ||
/// @param token Address of the token to be converted | ||
function convertToUSD(uint256 amount, address token) | ||
external | ||
view | ||
returns (uint256); | ||
|
||
/// @dev Converts a quantity of USD (decimals = 8) to an equivalent amount of an asset | ||
/// @param amount Amount to convert | ||
/// @param token Address of the token converted to | ||
function convertFromUSD(uint256 amount, address token) | ||
external | ||
view | ||
returns (uint256); | ||
|
||
/// @dev Converts one asset into another | ||
/// | ||
/// @param amount Amount to convert | ||
/// @param tokenFrom Address of the token to convert from | ||
/// @param tokenTo Address of the token to convert to | ||
function convert( | ||
uint256 amount, | ||
address tokenFrom, | ||
address tokenTo | ||
) external view returns (uint256); | ||
|
||
/// @dev Returns collateral values for two tokens, required for a fast check | ||
/// @param amountFrom Amount of the outbound token | ||
/// @param tokenFrom Address of the outbound token | ||
/// @param amountTo Amount of the inbound token | ||
/// @param tokenTo Address of the inbound token | ||
/// @return collateralFrom Value of the outbound token amount in USD | ||
/// @return collateralTo Value of the inbound token amount in USD | ||
function fastCheck( | ||
uint256 amountFrom, | ||
address tokenFrom, | ||
uint256 amountTo, | ||
address tokenTo | ||
) external view returns (uint256 collateralFrom, uint256 collateralTo); | ||
|
||
/// @dev Returns token's price in USD (8 decimals) | ||
/// @param token The token to compute the price for | ||
function getPrice(address token) external view returns (uint256); | ||
|
||
/// @dev Returns the price feed address for the passed token | ||
/// @param token Token to get the price feed for | ||
function priceFeeds(address token) | ||
external | ||
view | ||
returns (address priceFeed); | ||
|
||
/// @dev Returns the price feed for the passed token, | ||
/// with additional parameters | ||
/// @param token Token to get the price feed for | ||
function priceFeedsWithFlags(address token) | ||
external | ||
view | ||
returns ( | ||
address priceFeed, | ||
bool skipCheck, | ||
uint256 decimals | ||
); | ||
} | ||
|
||
interface IPriceOracleV2Ext is IPriceOracleV2 { | ||
/// @dev Sets a price feed if it doesn't exist, or updates an existing one | ||
/// @param token Address of the token to set the price feed for | ||
/// @param priceFeed Address of a USD price feed adhering to Chainlink's interface | ||
function addPriceFeed(address token, address priceFeed) external; | ||
} |