Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Multichain Info
No addresses found
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
PriceProvidersRepository
Compiler Version
v0.8.13+commit.abaa5c0e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./interfaces/IPriceProvidersRepository.sol"; import "./interfaces/ISiloRepository.sol"; import "./utils/Manageable.sol"; import "./utils/TwoStepOwnable.sol"; import "./lib/TokenHelper.sol"; import "./lib/Ping.sol"; /// @title PriceProvidersRepository /// @notice A repository of price providers. It manages price providers as well as maps assets to their price /// provider. It acts as a entry point for Silo for token prices. /// @custom:security-contact [email protected] contract PriceProvidersRepository is IPriceProvidersRepository, Manageable, TwoStepOwnable { using EnumerableSet for EnumerableSet.AddressSet; /// @dev we require quote token to have 18 decimals uint256 public constant QUOTE_TOKEN_DECIMALS = 18; /// @dev Constant used for prices' decimal points, 1e18 is treated as 1 uint256 private constant _ONE = 1e18; /// @notice SiloRepository contract address address public immutable siloRepository; /// @notice Token in which prices are quoted. It's most likely WETH, however it could vary from deployment /// to deployment. For example 1 SILO costs X amount of quoteToken. address public immutable override quoteToken; /// @notice Maps asset address to its price provider /// @dev Each asset must have a price provider contract assigned, otherwise it's not supported mapping(address => IPriceProvider) public override priceProviders; /// @notice Array of all price providers EnumerableSet.AddressSet private _allProviders; error AssetNotSupported(); error InvalidPriceProvider(); error InvalidPriceProviderQuoteToken(); error InvalidRepository(); error OnlyRepository(); error PriceProviderAlreadyExists(); error PriceProviderDoesNotExist(); error PriceProviderNotRegistered(); error QuoteTokenNotSupported(); modifier onlyRepository() { if (msg.sender != siloRepository) revert OnlyRepository(); _; } /// @param _quoteToken address of quote token /// @param _siloRepository address of SiloRepository constructor(address _quoteToken, address _siloRepository) Manageable(msg.sender) { if (TokenHelper.assertAndGetDecimals(_quoteToken) != QUOTE_TOKEN_DECIMALS) { revert QuoteTokenNotSupported(); } if (!Ping.pong(ISiloRepository(_siloRepository).siloRepositoryPing)) { revert InvalidRepository(); } siloRepository = _siloRepository; quoteToken = _quoteToken; } /// @inheritdoc IPriceProvidersRepository function addPriceProvider(IPriceProvider _provider) external override onlyOwner { if (!Ping.pong(_provider.priceProviderPing)) revert InvalidPriceProvider(); if (_provider.quoteToken() != quoteToken) revert InvalidPriceProviderQuoteToken(); if (!_allProviders.add(address(_provider))) revert PriceProviderAlreadyExists(); emit NewPriceProvider(_provider); } /// @inheritdoc IPriceProvidersRepository function removePriceProvider(IPriceProvider _provider) external virtual override onlyOwner { if (!_allProviders.remove(address(_provider))) revert PriceProviderDoesNotExist(); emit PriceProviderRemoved(_provider); } /// @inheritdoc IPriceProvidersRepository function setPriceProviderForAsset(address _asset, IPriceProvider _provider) external virtual override onlyManager { if (!_allProviders.contains(address(_provider))) { revert PriceProviderNotRegistered(); } if (!_provider.assetSupported(_asset)) revert AssetNotSupported(); emit PriceProviderForAsset(_asset, _provider); priceProviders[_asset] = _provider; } /// @inheritdoc IPriceProvidersRepository function isPriceProvider(IPriceProvider _provider) external view override returns (bool) { return _allProviders.contains(address(_provider)); } /// @inheritdoc IPriceProvidersRepository function providersCount() external view override returns (uint256) { return _allProviders.length(); } /// @inheritdoc IPriceProvidersRepository function providerList() external view override returns (address[] memory) { return _allProviders.values(); } /// @inheritdoc IPriceProvidersRepository function providersReadyForAsset(address _asset) external view override returns (bool) { // quote token is supported by default because getPrice() returns _ONE as its price by default if (_asset == quoteToken) return true; IPriceProvider priceProvider = priceProviders[_asset]; if (address(priceProvider) == address(0)) return false; return priceProvider.assetSupported(_asset); } /// @inheritdoc IPriceProvidersRepository function priceProvidersRepositoryPing() external pure override returns (bytes4) { return this.priceProvidersRepositoryPing.selector; } /// @inheritdoc IPriceProvidersRepository function manager() public view override(Manageable, IPriceProvidersRepository) returns (address) { return Manageable.manager(); } /// @inheritdoc TwoStepOwnable function owner() public view override(Manageable, TwoStepOwnable) returns (address) { return TwoStepOwnable.owner(); } /// @inheritdoc IPriceProvidersRepository function getPrice(address _asset) public view override virtual returns (uint256) { if (_asset == quoteToken) return _ONE; if (address(priceProviders[_asset]) == address(0)) revert AssetNotSupported(); return priceProviders[_asset].getPrice(_asset); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; interface IInterestRateModel { /* solhint-disable */ struct Config { // uopt ∈ (0, 1) – optimal utilization; int256 uopt; // ucrit ∈ (uopt, 1) – threshold of large utilization; int256 ucrit; // ulow ∈ (0, uopt) – threshold of low utilization int256 ulow; // ki > 0 – integrator gain int256 ki; // kcrit > 0 – proportional gain for large utilization int256 kcrit; // klow ≥ 0 – proportional gain for low utilization int256 klow; // klin ≥ 0 – coefficient of the lower linear bound int256 klin; // beta ≥ 0 - a scaling factor int256 beta; // ri ≥ 0 – initial value of the integrator int256 ri; // Tcrit ≥ 0 - the time during which the utilization exceeds the critical value int256 Tcrit; } /* solhint-enable */ /// @dev Set dedicated config for given asset in a Silo. Config is per asset per Silo so different assets /// in different Silo can have different configs. /// It will try to call `_silo.accrueInterest(_asset)` before updating config, but it is not guaranteed, /// that this call will be successful, if it fail config will be set anyway. /// @param _silo Silo address for which config should be set /// @param _asset asset address for which config should be set function setConfig(address _silo, address _asset, Config calldata _config) external; /// @dev get compound interest rate and update model storage /// @param _asset address of an asset in Silo for which interest rate should be calculated /// @param _blockTimestamp current block timestamp /// @return rcomp compounded interest rate from last update until now (1e18 == 100%) function getCompoundInterestRateAndUpdate( address _asset, uint256 _blockTimestamp ) external returns (uint256 rcomp); /// @dev Get config for given asset in a Silo. If dedicated config is not set, default one will be returned. /// @param _silo Silo address for which config should be set /// @param _asset asset address for which config should be set /// @return Config struct for asset in Silo function getConfig(address _silo, address _asset) external view returns (Config memory); /// @dev get compound interest rate /// @param _silo address of Silo /// @param _asset address of an asset in Silo for which interest rate should be calculated /// @param _blockTimestamp current block timestamp /// @return rcomp compounded interest rate from last update until now (1e18 == 100%) function getCompoundInterestRate( address _silo, address _asset, uint256 _blockTimestamp ) external view returns (uint256 rcomp); /// @dev get current annual interest rate /// @param _silo address of Silo /// @param _asset address of an asset in Silo for which interest rate should be calculated /// @param _blockTimestamp current block timestamp /// @return rcur current annual interest rate (1e18 == 100%) function getCurrentInterestRate( address _silo, address _asset, uint256 _blockTimestamp ) external view returns (uint256 rcur); /// @notice get the flag to detect rcomp restriction (zero current interest) due to overflow /// overflow boolean flag to detect rcomp restriction function overflowDetected( address _silo, address _asset, uint256 _blockTimestamp ) external view returns (bool overflow); /// @dev pure function that calculates current annual interest rate /// @param _c configuration object, InterestRateModel.Config /// @param _totalBorrowAmount current total borrows for asset /// @param _totalDeposits current total deposits for asset /// @param _interestRateTimestamp timestamp of last interest rate update /// @param _blockTimestamp current block timestamp /// @return rcur current annual interest rate (1e18 == 100%) function calculateCurrentInterestRate( Config memory _c, uint256 _totalDeposits, uint256 _totalBorrowAmount, uint256 _interestRateTimestamp, uint256 _blockTimestamp ) external pure returns (uint256 rcur); /// @dev pure function that calculates interest rate based on raw input data /// @param _c configuration object, InterestRateModel.Config /// @param _totalBorrowAmount current total borrows for asset /// @param _totalDeposits current total deposits for asset /// @param _interestRateTimestamp timestamp of last interest rate update /// @param _blockTimestamp current block timestamp /// @return rcomp compounded interest rate from last update until now (1e18 == 100%) /// @return ri current integral part of the rate /// @return Tcrit time during which the utilization exceeds the critical value /// @return overflow boolean flag to detect rcomp restriction function calculateCompoundInterestRateWithOverflowDetection( Config memory _c, uint256 _totalDeposits, uint256 _totalBorrowAmount, uint256 _interestRateTimestamp, uint256 _blockTimestamp ) external pure returns ( uint256 rcomp, int256 ri, int256 Tcrit, // solhint-disable-line var-name-mixedcase bool overflow ); /// @dev pure function that calculates interest rate based on raw input data /// @param _c configuration object, InterestRateModel.Config /// @param _totalBorrowAmount current total borrows for asset /// @param _totalDeposits current total deposits for asset /// @param _interestRateTimestamp timestamp of last interest rate update /// @param _blockTimestamp current block timestamp /// @return rcomp compounded interest rate from last update until now (1e18 == 100%) /// @return ri current integral part of the rate /// @return Tcrit time during which the utilization exceeds the critical value function calculateCompoundInterestRate( Config memory _c, uint256 _totalDeposits, uint256 _totalBorrowAmount, uint256 _interestRateTimestamp, uint256 _blockTimestamp ) external pure returns ( uint256 rcomp, int256 ri, int256 Tcrit // solhint-disable-line var-name-mixedcase ); /// @dev returns decimal points used by model function DP() external pure returns (uint256); // solhint-disable-line func-name-mixedcase /// @dev just a helper method to see if address is a InterestRateModel /// @return always true function interestRateModelPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; /// @title Common interface for Silo Incentive Contract interface INotificationReceiver { /// @dev Informs the contract about token transfer /// @param _token address of the token that was transferred /// @param _from sender /// @param _to receiver /// @param _amount amount that was transferred function onAfterTransfer(address _token, address _from, address _to, uint256 _amount) external; /// @dev Sanity check function /// @return always true function notificationReceiverPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.7.6 <0.9.0; /// @title Common interface for Silo Price Providers interface IPriceProvider { /// @notice Returns "Time-Weighted Average Price" for an asset. Calculates TWAP price for quote/asset. /// It unifies all tokens decimal to 18, examples: /// - if asses == quote it returns 1e18 /// - if asset is USDC and quote is ETH and ETH costs ~$3300 then it returns ~0.0003e18 WETH per 1 USDC /// @param _asset address of an asset for which to read price /// @return price of asses with 18 decimals, throws when pool is not ready yet to provide price function getPrice(address _asset) external view returns (uint256 price); /// @dev Informs if PriceProvider is setup for asset. It does not means PriceProvider can provide price right away. /// Some providers implementations need time to "build" buffer for TWAP price, /// so price may not be available yet but this method will return true. /// @param _asset asset in question /// @return TRUE if asset has been setup, otherwise false function assetSupported(address _asset) external view returns (bool); /// @notice Gets token address in which prices are quoted /// @return quoteToken address function quoteToken() external view returns (address); /// @notice Helper method that allows easily detects, if contract is PriceProvider /// @dev this can save us from simple human errors, in case we use invalid address /// but this should NOT be treated as security check /// @return always true function priceProviderPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.7.6 <0.9.0; import "./IPriceProvider.sol"; interface IPriceProvidersRepository { /// @notice Emitted when price provider is added /// @param newPriceProvider new price provider address event NewPriceProvider(IPriceProvider indexed newPriceProvider); /// @notice Emitted when price provider is removed /// @param priceProvider removed price provider address event PriceProviderRemoved(IPriceProvider indexed priceProvider); /// @notice Emitted when asset is assigned to price provider /// @param asset assigned asset address /// @param priceProvider price provider address event PriceProviderForAsset(address indexed asset, IPriceProvider indexed priceProvider); /// @notice Register new price provider /// @param _priceProvider address of price provider function addPriceProvider(IPriceProvider _priceProvider) external; /// @notice Unregister price provider /// @param _priceProvider address of price provider to be removed function removePriceProvider(IPriceProvider _priceProvider) external; /// @notice Sets price provider for asset /// @dev Request for asset price is forwarded to the price provider assigned to that asset /// @param _asset address of an asset for which price provider will be used /// @param _priceProvider address of price provider function setPriceProviderForAsset(address _asset, IPriceProvider _priceProvider) external; /// @notice Returns "Time-Weighted Average Price" for an asset /// @param _asset address of an asset for which to read price /// @return price TWAP price of a token with 18 decimals function getPrice(address _asset) external view returns (uint256 price); /// @notice Gets price provider assigned to an asset /// @param _asset address of an asset for which to get price provider /// @return priceProvider address of price provider function priceProviders(address _asset) external view returns (IPriceProvider priceProvider); /// @notice Gets token address in which prices are quoted /// @return quoteToken address function quoteToken() external view returns (address); /// @notice Gets manager role address /// @return manager role address function manager() external view returns (address); /// @notice Checks if providers are available for an asset /// @param _asset asset address to check /// @return returns TRUE if price feed is ready, otherwise false function providersReadyForAsset(address _asset) external view returns (bool); /// @notice Returns true if address is a registered price provider /// @param _provider address of price provider to be removed /// @return true if address is a registered price provider, otherwise false function isPriceProvider(IPriceProvider _provider) external view returns (bool); /// @notice Gets number of price providers registered /// @return number of price providers registered function providersCount() external view returns (uint256); /// @notice Gets an array of price providers /// @return array of price providers function providerList() external view returns (address[] memory); /// @notice Sanity check function /// @return returns always TRUE function priceProvidersRepositoryPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "./INotificationReceiver.sol"; interface IShareToken is IERC20Metadata { /// @notice Emitted every time receiver is notified about token transfer /// @param notificationReceiver receiver address /// @param success false if TX reverted on `notificationReceiver` side, otherwise true event NotificationSent( INotificationReceiver indexed notificationReceiver, bool success ); /// @notice Mint method for Silo to create debt position /// @param _account wallet for which to mint token /// @param _amount amount of token to be minted function mint(address _account, uint256 _amount) external; /// @notice Burn method for Silo to close debt position /// @param _account wallet for which to burn token /// @param _amount amount of token to be burned function burn(address _account, uint256 _amount) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; interface ISiloFactory { /// @notice Emitted when Silo is deployed /// @param silo address of deployed Silo /// @param asset address of asset for which Silo was deployed /// @param version version of silo implementation event NewSiloCreated(address indexed silo, address indexed asset, uint128 version); /// @notice Must be called by repository on constructor /// @param _siloRepository the SiloRepository to set function initRepository(address _siloRepository) external; /// @notice Deploys Silo /// @param _siloAsset unique asset for which Silo is deployed /// @param _version version of silo implementation /// @param _data (optional) data that may be needed during silo creation /// @return silo deployed Silo address function createSilo(address _siloAsset, uint128 _version, bytes memory _data) external returns (address silo); /// @dev just a helper method to see if address is a factory function siloFactoryPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; import "./ISiloFactory.sol"; import "./ITokensFactory.sol"; import "./IPriceProvidersRepository.sol"; import "./INotificationReceiver.sol"; import "./IInterestRateModel.sol"; interface ISiloRepository { /// @dev protocol fees in precision points (Solvency._PRECISION_DECIMALS), we do allow for fee == 0 struct Fees { /// @dev One time protocol fee for opening a borrow position in precision points (Solvency._PRECISION_DECIMALS) uint64 entryFee; /// @dev Protocol revenue share in interest paid in precision points (Solvency._PRECISION_DECIMALS) uint64 protocolShareFee; /// @dev Protocol share in liquidation profit in precision points (Solvency._PRECISION_DECIMALS). /// It's calculated from total collateral amount to be transferred to liquidator. uint64 protocolLiquidationFee; } struct SiloVersion { /// @dev Default version of Silo. If set to 0, it means it is not set. By default it is set to 1 uint128 byDefault; /// @dev Latest added version of Silo. If set to 0, it means it is not set. By default it is set to 1 uint128 latest; } /// @dev AssetConfig struct represents configurable parameters for each Silo struct AssetConfig { /// @dev Loan-to-Value ratio represents the maximum borrowing power of a specific collateral. /// For example, if the collateral asset has an LTV of 75%, the user can borrow up to 0.75 worth /// of quote token in the principal currency for every quote token worth of collateral. /// value uses 18 decimals eg. 100% == 1e18 /// max valid value is 1e18 so it needs storage of 60 bits uint64 maxLoanToValue; /// @dev Liquidation Threshold represents the threshold at which a borrow position will be considered /// undercollateralized and subject to liquidation for each collateral. For example, /// if a collateral has a liquidation threshold of 80%, it means that the loan will be /// liquidated when the borrowAmount value is worth 80% of the collateral value. /// value uses 18 decimals eg. 100% == 1e18 uint64 liquidationThreshold; /// @dev interest rate model address IInterestRateModel interestRateModel; } event NewDefaultMaximumLTV(uint64 defaultMaximumLTV); event NewDefaultLiquidationThreshold(uint64 defaultLiquidationThreshold); /// @notice Emitted on new Silo creation /// @param silo deployed Silo address /// @param asset unique asset for deployed Silo /// @param siloVersion version of deployed Silo event NewSilo(address indexed silo, address indexed asset, uint128 siloVersion); /// @notice Emitted when new Silo (or existing one) becomes a bridge pool (pool with only bridge tokens). /// @param pool address of the bridge pool, It can be zero address when bridge asset is removed and pool no longer /// is treated as bridge pool event BridgePool(address indexed pool); /// @notice Emitted on new bridge asset /// @param newBridgeAsset address of added bridge asset event BridgeAssetAdded(address indexed newBridgeAsset); /// @notice Emitted on removed bridge asset /// @param bridgeAssetRemoved address of removed bridge asset event BridgeAssetRemoved(address indexed bridgeAssetRemoved); /// @notice Emitted when default interest rate model is changed /// @param newModel address of new interest rate model event InterestRateModel(IInterestRateModel indexed newModel); /// @notice Emitted on price provider repository address update /// @param newProvider address of new oracle repository event PriceProvidersRepositoryUpdate( IPriceProvidersRepository indexed newProvider ); /// @notice Emitted on token factory address update /// @param newTokensFactory address of new token factory event TokensFactoryUpdate(address indexed newTokensFactory); /// @notice Emitted on router address update /// @param newRouter address of new router event RouterUpdate(address indexed newRouter); /// @notice Emitted on INotificationReceiver address update /// @param newIncentiveContract address of new INotificationReceiver event NotificationReceiverUpdate(INotificationReceiver indexed newIncentiveContract); /// @notice Emitted when new Silo version is registered /// @param factory factory address that deploys registered Silo version /// @param siloLatestVersion Silo version of registered Silo /// @param siloDefaultVersion current default Silo version event RegisterSiloVersion(address indexed factory, uint128 siloLatestVersion, uint128 siloDefaultVersion); /// @notice Emitted when Silo version is unregistered /// @param factory factory address that deploys unregistered Silo version /// @param siloVersion version that was unregistered event UnregisterSiloVersion(address indexed factory, uint128 siloVersion); /// @notice Emitted when default Silo version is updated /// @param newDefaultVersion new default version event SiloDefaultVersion(uint128 newDefaultVersion); /// @notice Emitted when default fee is updated /// @param newEntryFee new entry fee /// @param newProtocolShareFee new protocol share fee /// @param newProtocolLiquidationFee new protocol liquidation fee event FeeUpdate( uint64 newEntryFee, uint64 newProtocolShareFee, uint64 newProtocolLiquidationFee ); /// @notice Emitted when asset config is updated for a silo /// @param silo silo for which asset config is being set /// @param asset asset for which asset config is being set /// @param assetConfig new asset config event AssetConfigUpdate(address indexed silo, address indexed asset, AssetConfig assetConfig); /// @notice Emitted when silo (silo factory) version is set for asset /// @param asset asset for which asset config is being set /// @param version Silo version event VersionForAsset(address indexed asset, uint128 version); /// @param _siloAsset silo asset /// @return version of Silo that is assigned for provided asset, if not assigned it returns zero (default) function getVersionForAsset(address _siloAsset) external returns (uint128); /// @notice setter for `getVersionForAsset` mapping /// @param _siloAsset silo asset /// @param _version version of Silo that will be assigned for `_siloAsset`, zero (default) is acceptable function setVersionForAsset(address _siloAsset, uint128 _version) external; /// @notice use this method only when off-chain verification is OFF /// @dev Silo does NOT support rebase and deflationary tokens /// @param _siloAsset silo asset /// @param _siloData (optional) data that may be needed during silo creation /// @return createdSilo address of created silo function newSilo(address _siloAsset, bytes memory _siloData) external returns (address createdSilo); /// @notice use this method to deploy new version of Silo for an asset that already has Silo deployed. /// Only owner (DAO) can replace. /// @dev Silo does NOT support rebase and deflationary tokens /// @param _siloAsset silo asset /// @param _siloVersion version of silo implementation. Use 0 for default version which is fine /// for 99% of cases. /// @param _siloData (optional) data that may be needed during silo creation /// @return createdSilo address of created silo function replaceSilo( address _siloAsset, uint128 _siloVersion, bytes memory _siloData ) external returns (address createdSilo); /// @notice Set factory contract for debt and collateral tokens for each Silo asset /// @dev Callable only by owner /// @param _tokensFactory address of TokensFactory contract that deploys debt and collateral tokens function setTokensFactory(address _tokensFactory) external; /// @notice Set default fees /// @dev Callable only by owner /// @param _fees: /// - _entryFee one time protocol fee for opening a borrow position in precision points /// (Solvency._PRECISION_DECIMALS) /// - _protocolShareFee protocol revenue share in interest paid in precision points /// (Solvency._PRECISION_DECIMALS) /// - _protocolLiquidationFee protocol share in liquidation profit in precision points /// (Solvency._PRECISION_DECIMALS). It's calculated from total collateral amount to be transferred /// to liquidator. function setFees(Fees calldata _fees) external; /// @notice Set configuration for given asset in given Silo /// @dev Callable only by owner /// @param _silo Silo address for which config applies /// @param _asset asset address for which config applies /// @param _assetConfig: /// - _maxLoanToValue maximum Loan-to-Value, for details see `Repository.AssetConfig.maxLoanToValue` /// - _liquidationThreshold liquidation threshold, for details see `Repository.AssetConfig.maxLoanToValue` /// - _interestRateModel interest rate model address, for details see `Repository.AssetConfig.interestRateModel` function setAssetConfig( address _silo, address _asset, AssetConfig calldata _assetConfig ) external; /// @notice Set default interest rate model /// @dev Callable only by owner /// @param _defaultInterestRateModel default interest rate model function setDefaultInterestRateModel(IInterestRateModel _defaultInterestRateModel) external; /// @notice Set default maximum LTV /// @dev Callable only by owner /// @param _defaultMaxLTV default maximum LTV in precision points (Solvency._PRECISION_DECIMALS) function setDefaultMaximumLTV(uint64 _defaultMaxLTV) external; /// @notice Set default liquidation threshold /// @dev Callable only by owner /// @param _defaultLiquidationThreshold default liquidation threshold in precision points /// (Solvency._PRECISION_DECIMALS) function setDefaultLiquidationThreshold(uint64 _defaultLiquidationThreshold) external; /// @notice Set price provider repository /// @dev Callable only by owner /// @param _repository price provider repository address function setPriceProvidersRepository(IPriceProvidersRepository _repository) external; /// @notice Set router contract /// @dev Callable only by owner /// @param _router router address function setRouter(address _router) external; /// @notice Set NotificationReceiver contract /// @dev Callable only by owner /// @param _silo silo address for which to set `_notificationReceiver` /// @param _notificationReceiver NotificationReceiver address function setNotificationReceiver(address _silo, INotificationReceiver _notificationReceiver) external; /// @notice Adds new bridge asset /// @dev New bridge asset must be unique. Duplicates in bridge assets are not allowed. It's possible to add /// bridge asset that has been removed in the past. Note that all Silos must be synced manually. Callable /// only by owner. /// @param _newBridgeAsset bridge asset address function addBridgeAsset(address _newBridgeAsset) external; /// @notice Removes bridge asset /// @dev Note that all Silos must be synced manually. Callable only by owner. /// @param _bridgeAssetToRemove bridge asset address to be removed function removeBridgeAsset(address _bridgeAssetToRemove) external; /// @notice Registers new Silo version /// @dev User can choose which Silo version he wants to deploy. It's possible to have multiple versions of Silo. /// Callable only by owner. /// @param _factory factory contract that deploys new version of Silo /// @param _isDefault true if this version should be used as default function registerSiloVersion(ISiloFactory _factory, bool _isDefault) external; /// @notice Unregisters Silo version /// @dev Callable only by owner. /// @param _siloVersion Silo version to be unregistered function unregisterSiloVersion(uint128 _siloVersion) external; /// @notice Sets default Silo version /// @dev Callable only by owner. /// @param _defaultVersion Silo version to be set as default function setDefaultSiloVersion(uint128 _defaultVersion) external; /// @notice Check if contract address is a Silo deployment /// @param _silo address of expected Silo /// @return true if address is Silo deployment, otherwise false function isSilo(address _silo) external view returns (bool); /// @notice Get Silo address of asset /// @param _asset address of asset /// @return address of corresponding Silo deployment function getSilo(address _asset) external view returns (address); /// @notice Get Silo Factory for given version /// @param _siloVersion version of Silo implementation /// @return ISiloFactory contract that deploys Silos of given version function siloFactory(uint256 _siloVersion) external view returns (ISiloFactory); /// @notice Get debt and collateral Token Factory /// @return ITokensFactory contract that deploys debt and collateral tokens function tokensFactory() external view returns (ITokensFactory); /// @notice Get Router contract /// @return address of router contract function router() external view returns (address); /// @notice Get current bridge assets /// @dev Keep in mind that not all Silos may be synced with current bridge assets so it's possible that some /// assets in that list are not part of given Silo. /// @return address array of bridge assets function getBridgeAssets() external view returns (address[] memory); /// @notice Get removed bridge assets /// @dev Keep in mind that not all Silos may be synced with bridge assets so it's possible that some /// assets in that list are still part of given Silo. /// @return address array of bridge assets function getRemovedBridgeAssets() external view returns (address[] memory); /// @notice Get maximum LTV for asset in given Silo /// @dev If dedicated config is not set, method returns default config /// @param _silo address of Silo /// @param _asset address of an asset /// @return maximum LTV in precision points (Solvency._PRECISION_DECIMALS) function getMaximumLTV(address _silo, address _asset) external view returns (uint256); /// @notice Get Interest Rate Model address for asset in given Silo /// @dev If dedicated config is not set, method returns default config /// @param _silo address of Silo /// @param _asset address of an asset /// @return address of interest rate model function getInterestRateModel(address _silo, address _asset) external view returns (IInterestRateModel); /// @notice Get liquidation threshold for asset in given Silo /// @dev If dedicated config is not set, method returns default config /// @param _silo address of Silo /// @param _asset address of an asset /// @return liquidation threshold in precision points (Solvency._PRECISION_DECIMALS) function getLiquidationThreshold(address _silo, address _asset) external view returns (uint256); /// @notice Get incentive contract address. Incentive contracts are responsible for distributing rewards /// to debt and/or collateral token holders of given Silo /// @param _silo address of Silo /// @return incentive contract address function getNotificationReceiver(address _silo) external view returns (INotificationReceiver); /// @notice Get owner role address of Repository /// @return owner role address function owner() external view returns (address); /// @notice get PriceProvidersRepository contract that manages price providers implementations /// @return IPriceProvidersRepository address function priceProvidersRepository() external view returns (IPriceProvidersRepository); /// @dev Get protocol fee for opening a borrow position /// @return fee in precision points (Solvency._PRECISION_DECIMALS == 100%) function entryFee() external view returns (uint256); /// @dev Get protocol share fee /// @return protocol share fee in precision points (Solvency._PRECISION_DECIMALS == 100%) function protocolShareFee() external view returns (uint256); /// @dev Get protocol liquidation fee /// @return protocol liquidation fee in precision points (Solvency._PRECISION_DECIMALS == 100%) function protocolLiquidationFee() external view returns (uint256); /// @dev Checks all conditions for new silo creation and throws when not possible to create /// @param _asset address of asset for which you want to create silo /// @param _assetIsABridge bool TRUE when `_asset` is bridge asset, FALSE when it is not function ensureCanCreateSiloFor(address _asset, bool _assetIsABridge) external view; function siloRepositoryPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; import "./IShareToken.sol"; interface ITokensFactory { /// @notice Emitted when collateral token is deployed /// @param token address of deployed collateral token event NewShareCollateralTokenCreated(address indexed token); /// @notice Emitted when collateral token is deployed /// @param token address of deployed debt token event NewShareDebtTokenCreated(address indexed token); ///@notice Must be called by repository on constructor /// @param _siloRepository the SiloRepository to set function initRepository(address _siloRepository) external; /// @notice Deploys collateral token /// @param _name name of the token /// @param _symbol symbol of the token /// @param _asset underlying asset for which token is deployed /// @return address of deployed collateral share token function createShareCollateralToken( string memory _name, string memory _symbol, address _asset ) external returns (IShareToken); /// @notice Deploys debt token /// @param _name name of the token /// @param _symbol symbol of the token /// @param _asset underlying asset for which token is deployed /// @return address of deployed debt share token function createShareDebtToken( string memory _name, string memory _symbol, address _asset ) external returns (IShareToken); /// @dev just a helper method to see if address is a factory /// @return always true function tokensFactoryPing() external pure returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.7.6 <0.9.0; library Ping { function pong(function() external pure returns(bytes4) pingFunction) internal pure returns (bool) { return pingFunction.address != address(0) && pingFunction.selector == pingFunction(); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; library TokenHelper { uint256 private constant _BYTES32_SIZE = 32; error TokenIsNotAContract(); function assertAndGetDecimals(address _token) internal view returns (uint256) { (bool hasMetadata, bytes memory data) = _tokenMetadataCall(_token, abi.encodeCall(IERC20Metadata.decimals,())); // decimals() is optional in the ERC20 standard, so if metadata is not accessible // we assume there are no decimals and use 0. if (!hasMetadata) { return 0; } return abi.decode(data, (uint8)); } /// @dev Returns the symbol for the provided ERC20 token. /// An empty string is returned if the call to the token didn't succeed. /// @param _token address of the token to get the symbol for /// @return assetSymbol the token symbol function symbol(address _token) internal view returns (string memory assetSymbol) { (bool hasMetadata, bytes memory data) = _tokenMetadataCall(_token, abi.encodeCall(IERC20Metadata.symbol,())); if (!hasMetadata || data.length == 0) { return "?"; } else if (data.length == _BYTES32_SIZE) { return string(removeZeros(data)); } else { return abi.decode(data, (string)); } } /// @dev Removes bytes with value equal to 0 from the provided byte array. /// @param _data byte array from which to remove zeroes /// @return result byte array with zeroes removed function removeZeros(bytes memory _data) internal pure returns (bytes memory result) { uint256 n = _data.length; unchecked { for (uint256 i; i < n; i++) { if (_data[i] == 0) continue; result = abi.encodePacked(result, _data[i]); } } } /// @dev Performs a staticcall to the token to get its metadata (symbol, decimals, name) function _tokenMetadataCall(address _token, bytes memory _data) private view returns(bool, bytes memory) { // We need to do this before the call, otherwise the call will succeed even for EOAs if (!Address.isContract(_token)) revert TokenIsNotAContract(); (bool success, bytes memory result) = _token.staticcall(_data); // If the call reverted we assume the token doesn't follow the metadata extension if (!success) { return (false, ""); } return (true, result); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.13; /// @title Manageable /// @notice Implements simple manager role that can be changed by a manger or external owner role /// @dev This contract is designed to work with Ownable from openzeppelin /// @custom:security-contact [email protected] abstract contract Manageable { /// @notice wallet address of manager role address private _managerRole; /// @notice Emitted when manager is changed /// @param manager new manager address event ManagerChanged(address manager); error ManagerIsZero(); error OnlyManager(); error OnlyOwnerOrManager(); error ManagerDidNotChange(); modifier onlyManager() { if (_managerRole != msg.sender) revert OnlyManager(); _; } /// @param _manager new manager address constructor(address _manager) { if (_manager == address(0)) revert ManagerIsZero(); _managerRole = _manager; } /// @notice Change manager address /// @dev Callable by manager or external owner role /// @param _manager new manager address function changeManager(address _manager) external { if (msg.sender != owner() && msg.sender != _managerRole) { revert OnlyOwnerOrManager(); } if (_manager == address(0)) revert ManagerIsZero(); if (_manager == _managerRole) revert ManagerDidNotChange(); _managerRole = _manager; emit ManagerChanged(_manager); } function manager() public view virtual returns (address) { return _managerRole; } /// @notice Gets external owner role /// @return owner address function owner() public view virtual returns (address); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.7.6 <0.9.0; /// @title TwoStepOwnable /// @notice Contract that implements the same functionality as popular Ownable contract from openzeppelin library. /// The only difference is that it adds a possibility to transfer ownership in two steps. Single step ownership /// transfer is still supported. /// @dev Two step ownership transfer is meant to be used by humans to avoid human error. Single step ownership /// transfer is meant to be used by smart contracts to avoid over-complicated two step integration. For that reason, /// both ways are supported. abstract contract TwoStepOwnable { /// @dev current owner address private _owner; /// @dev candidate to an owner address private _pendingOwner; /// @notice Emitted when ownership is transferred on `transferOwnership` and `acceptOwnership` /// @param newOwner new owner event OwnershipTransferred(address indexed newOwner); /// @notice Emitted when ownership transfer is proposed, aka pending owner is set /// @param newPendingOwner new proposed/pending owner event OwnershipPending(address indexed newPendingOwner); /** * error OnlyOwner(); * error OnlyPendingOwner(); * error OwnerIsZero(); */ /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { if (owner() != msg.sender) revert("OnlyOwner"); _; } /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(msg.sender); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) revert("OwnerIsZero"); _setOwner(newOwner); } /** * @dev Transfers pending ownership of the contract to a new account (`newPendingOwner`) and clears any existing * pending ownership. * Can only be called by the current owner. */ function transferPendingOwnership(address newPendingOwner) public virtual onlyOwner { _setPendingOwner(newPendingOwner); } /** * @dev Clears the pending ownership. * Can only be called by the current owner. */ function removePendingOwnership() public virtual onlyOwner { _setPendingOwner(address(0)); } /** * @dev Transfers ownership of the contract to a pending owner * Can only be called by the pending owner. */ function acceptOwnership() public virtual { if (msg.sender != pendingOwner()) revert("OnlyPendingOwner"); _setOwner(pendingOwner()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Sets the new owner and emits the corresponding event. */ function _setOwner(address newOwner) private { if (_owner == newOwner) revert("OwnerDidNotChange"); _owner = newOwner; emit OwnershipTransferred(newOwner); if (_pendingOwner != address(0)) { _setPendingOwner(address(0)); } } /** * @dev Sets the new pending owner and emits the corresponding event. */ function _setPendingOwner(address newPendingOwner) private { if (_pendingOwner == newPendingOwner) revert("PendingOwnerDidNotChange"); _pendingOwner = newPendingOwner; emit OwnershipPending(newPendingOwner); } }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_quoteToken","type":"address"},{"internalType":"address","name":"_siloRepository","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AssetNotSupported","type":"error"},{"inputs":[],"name":"InvalidPriceProvider","type":"error"},{"inputs":[],"name":"InvalidPriceProviderQuoteToken","type":"error"},{"inputs":[],"name":"InvalidRepository","type":"error"},{"inputs":[],"name":"ManagerDidNotChange","type":"error"},{"inputs":[],"name":"ManagerIsZero","type":"error"},{"inputs":[],"name":"OnlyManager","type":"error"},{"inputs":[],"name":"OnlyOwnerOrManager","type":"error"},{"inputs":[],"name":"OnlyRepository","type":"error"},{"inputs":[],"name":"PriceProviderAlreadyExists","type":"error"},{"inputs":[],"name":"PriceProviderDoesNotExist","type":"error"},{"inputs":[],"name":"PriceProviderNotRegistered","type":"error"},{"inputs":[],"name":"QuoteTokenNotSupported","type":"error"},{"inputs":[],"name":"TokenIsNotAContract","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"manager","type":"address"}],"name":"ManagerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPriceProvider","name":"newPriceProvider","type":"address"}],"name":"NewPriceProvider","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newPendingOwner","type":"address"}],"name":"OwnershipPending","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"contract IPriceProvider","name":"priceProvider","type":"address"}],"name":"PriceProviderForAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IPriceProvider","name":"priceProvider","type":"address"}],"name":"PriceProviderRemoved","type":"event"},{"inputs":[],"name":"QUOTE_TOKEN_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPriceProvider","name":"_provider","type":"address"}],"name":"addPriceProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"name":"changeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IPriceProvider","name":"_provider","type":"address"}],"name":"isPriceProvider","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"priceProviders","outputs":[{"internalType":"contract IPriceProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceProvidersRepositoryPing","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"providerList","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"providersCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"providersReadyForAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quoteToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removePendingOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPriceProvider","name":"_provider","type":"address"}],"name":"removePriceProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"contract IPriceProvider","name":"_provider","type":"address"}],"name":"setPriceProviderForAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"siloRepository","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingOwner","type":"address"}],"name":"transferPendingOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60c06040523480156200001157600080fd5b50604051620017db380380620017db83398101604081905262000034916200046b565b33806200005457604051639c774ebf60e01b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556200007f3362000110565b60126200009783620001cf60201b62000b251760201c565b14620000b65760405163a14401e960e01b815260040160405180910390fd5b620000da816001600160a01b031663e99ed41d6200024660201b62000b921760201c565b620000f857604051639f45596360e01b815260040160405180910390fd5b6001600160a01b039081166080521660a05262000532565b6001546001600160a01b03808316911603620001675760405162461bcd60e51b81526020600482015260116024820152704f776e65724469644e6f744368616e676560781b60448201526064015b60405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040517f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc68616390600090a26002546001600160a01b031615620001cc57620001cc6000620002d0565b50565b6040805160048152602481019091526020810180516001600160e01b0390811663313ce56760e01b179091526000918291829162000211918691906200037916565b915091508162000225575060009392505050565b808060200190518101906200023b9190620004a3565b60ff16949350505050565b60006001600160a01b03831615801590620002c9575082826040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200028e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002b49190620004c8565b60e083901b6001600160e01b03199081169116145b9392505050565b6002546001600160a01b038083169116036200032f5760405162461bcd60e51b815260206004820152601860248201527f50656e64696e674f776e65724469644e6f744368616e6765000000000000000060448201526064016200015e565b600280546001600160a01b0319166001600160a01b0383169081179091556040517fd6aad444c90d39fb0eee1c6e357a7fad83d63f719ac5f880445a2beb0ff3ab5890600090a250565b6000606062000393846200044860201b62000c171760201c565b620003b1576040516373d39f9d60e01b815260040160405180910390fd5b600080856001600160a01b031685604051620003ce9190620004f4565b600060405180830381855afa9150503d80600081146200040b576040519150601f19603f3d011682016040523d82523d6000602084013e62000410565b606091505b509150915081620004395760006040518060200160405280600081525093509350505062000441565b600193509150505b9250929050565b3b151590565b80516001600160a01b03811681146200046657600080fd5b919050565b600080604083850312156200047f57600080fd5b6200048a836200044e565b91506200049a602084016200044e565b90509250929050565b600060208284031215620004b657600080fd5b815160ff81168114620002c957600080fd5b600060208284031215620004db57600080fd5b81516001600160e01b031981168114620002c957600080fd5b6000825160005b81811015620005175760208186018101518583015201620004fb565b8181111562000527576000828501525b509190910192915050565b60805160a05161126e6200056d60003960008181610161015281816103900152818161056d01526106b3015260006102aa015261126e6000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c806379ba5097116100b8578063bde127181161007c578063bde12718146102a5578063c834439f146102cc578063d0659d75146102e1578063e30c3978146102e9578063eec3e6a7146102fa578063f2fde38b1461030f57600080fd5b806379ba50971461025c5780638da5cb5b1461026457806393b6809c1461026c57806397e8a2d81461027f578063a3fbbaae1461029257600080fd5b806341976e091161010a57806341976e09146101dc57806344552b5d146101ef578063481c6a75146101f757806350ebbcc1146102085780635d54e3951461022b578063715018a61461025457600080fd5b80631b01d69e14610147578063217a4b701461015c5780633278c694146101a0578063329afacd146101b357806339b216a3146101c9575b600080fd5b61015a610155366004611041565b610322565b005b6101837f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61015a6101ae366004611041565b6104a0565b6101bb601281565b604051908152602001610197565b61015a6101d7366004611041565b6104db565b6101bb6101ea366004611041565b610569565b61015a61066f565b6000546001600160a01b0316610183565b61021b610216366004611041565b6106af565b6040519015158152602001610197565b610183610239366004611041565b6003602052600090815260409020546001600160a01b031681565b61015a61078c565b61015a6107c5565b61018361082c565b61015a61027a36600461105e565b610840565b61021b61028d366004611041565b610988565b61015a6102a0366004611041565b610995565b6101837f000000000000000000000000000000000000000000000000000000000000000081565b6102d4610a91565b6040516101979190611097565b6101bb610a9d565b6002546001600160a01b0316610183565b60405163eec3e6a760e01b8152602001610197565b61015a61031d366004611041565b610aa9565b3361032b61082c565b6001600160a01b03161461035a5760405162461bcd60e51b8152600401610351906110e4565b60405180910390fd5b610371816001600160a01b03166357e0c50f610b92565b61038e57604051634cd31fbb60e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031663217a4b706040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041a9190611107565b6001600160a01b03161461044157604051630c2d3f5360e11b815260040160405180910390fd5b61044c600482610c1d565b610469576040516370a96ce960e01b815260040160405180910390fd5b6040516001600160a01b038216907f4705d8451928f44517faa1bdfbbca0e2b931ae93313f022b3b989537b0daa6f590600090a250565b336104a961082c565b6001600160a01b0316146104cf5760405162461bcd60e51b8152600401610351906110e4565b6104d881610c32565b50565b336104e461082c565b6001600160a01b03161461050a5760405162461bcd60e51b8152600401610351906110e4565b610515600482610cd9565b61053257604051631605dd1760e01b815260040160405180910390fd5b6040516001600160a01b038216907fbecb08a245e5ee64b9cf97ff511fa99537ede3f8387ee3df7f951ef1dabd19bd90600090a250565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316036105b35750670de0b6b3a7640000919050565b6001600160a01b03828116600090815260036020526040902054166105eb5760405163981a2a2b60e01b815260040160405180910390fd5b6001600160a01b03828116600081815260036020526040908190205490516341976e0960e01b81526004810192909252909116906341976e0990602401602060405180830381865afa158015610645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106699190611124565b92915050565b3361067861082c565b6001600160a01b03161461069e5760405162461bcd60e51b8152600401610351906110e4565b6106a86000610c32565b565b905090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316036106f257506001919050565b6001600160a01b03808316600090815260036020526040902054168061071b5750600092915050565b60405163598fd92b60e11b81526001600160a01b03848116600483015282169063b31fb25690602401602060405180830381865afa158015610761573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610785919061113d565b9392505050565b3361079561082c565b6001600160a01b0316146107bb5760405162461bcd60e51b8152600401610351906110e4565b6106a86000610cee565b6002546001600160a01b031633146108125760405162461bcd60e51b815260206004820152601060248201526f27b7363ca832b73234b733a7bbb732b960811b6044820152606401610351565b6106a86108276002546001600160a01b031690565b610cee565b60006106aa6001546001600160a01b031690565b6000546001600160a01b0316331461086b5760405163605919ad60e11b815260040160405180910390fd5b610876600482610da1565b610893576040516350c14f3960e01b815260040160405180910390fd5b60405163598fd92b60e11b81526001600160a01b03838116600483015282169063b31fb25690602401602060405180830381865afa1580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd919061113d565b61091a5760405163981a2a2b60e01b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03167f26eb74ff7dd83e64daf822c2515feb1b0a46015000c9f339e23df0988237615160405160405180910390a36001600160a01b03918216600090815260036020526040902080546001600160a01b03191691909216179055565b6000610669600483610da1565b61099d61082c565b6001600160a01b0316336001600160a01b0316141580156109c957506000546001600160a01b03163314155b156109e75760405163b647320d60e01b815260040160405180910390fd5b6001600160a01b038116610a0e57604051639c774ebf60e01b815260040160405180910390fd5b6000546001600160a01b0390811690821603610a3d57604051632ebe652b60e21b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0383169081179091556040519081527f198db6e425fb8aafd1823c6ca50be2d51e5764571a5ae0f0f21c6812e45def0b9060200160405180910390a150565b60606106aa6004610dc3565b60006106aa6004610dd0565b33610ab261082c565b6001600160a01b031614610ad85760405162461bcd60e51b8152600401610351906110e4565b6001600160a01b038116610b1c5760405162461bcd60e51b815260206004820152600b60248201526a4f776e657249735a65726f60a81b6044820152606401610351565b6104d881610cee565b6040805160048152602481019091526020810180516001600160e01b031663313ce56760e01b17905260009081908190610b60908590610dda565b9150915081610b73575060009392505050565b80806020019051810190610b87919061115f565b60ff16949350505050565b60006001600160a01b03831615801590610785575082826040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfc9190611182565b60e083901b6001600160e01b03199081169116149392505050565b3b151590565b6000610785836001600160a01b038416610e8e565b6002546001600160a01b03808316911603610c8f5760405162461bcd60e51b815260206004820152601860248201527f50656e64696e674f776e65724469644e6f744368616e676500000000000000006044820152606401610351565b600280546001600160a01b0319166001600160a01b0383169081179091556040517fd6aad444c90d39fb0eee1c6e357a7fad83d63f719ac5f880445a2beb0ff3ab5890600090a250565b6000610785836001600160a01b038416610edd565b6001546001600160a01b03808316911603610d3f5760405162461bcd60e51b81526020600482015260116024820152704f776e65724469644e6f744368616e676560781b6044820152606401610351565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc68616390600090a26002546001600160a01b0316156104d8576104d86000610c32565b6001600160a01b03811660009081526001830160205260408120541515610785565b6060600061078583610fd0565b6000610669825490565b60006060833b610dfd576040516373d39f9d60e01b815260040160405180910390fd5b600080856001600160a01b031685604051610e1891906111ac565b600060405180830381855afa9150503d8060008114610e53576040519150601f19603f3d011682016040523d82523d6000602084013e610e58565b606091505b509150915081610e7f57600060405180602001604052806000815250935093505050610e87565b600193509150505b9250929050565b6000818152600183016020526040812054610ed557508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610669565b506000610669565b60008181526001830160205260408120548015610fc6576000610f016001836111e7565b8554909150600090610f15906001906111e7565b9050818114610f7a576000866000018281548110610f3557610f3561120c565b9060005260206000200154905080876000018481548110610f5857610f5861120c565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080610f8b57610f8b611222565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610669565b6000915050610669565b60608160000180548060200260200160405190810160405280929190818152602001828054801561102057602002820191906000526020600020905b81548152602001906001019080831161100c575b50505050509050919050565b6001600160a01b03811681146104d857600080fd5b60006020828403121561105357600080fd5b81356107858161102c565b6000806040838503121561107157600080fd5b823561107c8161102c565b9150602083013561108c8161102c565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156110d85783516001600160a01b0316835292840192918401916001016110b3565b50909695505050505050565b60208082526009908201526827b7363ca7bbb732b960b91b604082015260600190565b60006020828403121561111957600080fd5b81516107858161102c565b60006020828403121561113657600080fd5b5051919050565b60006020828403121561114f57600080fd5b8151801515811461078557600080fd5b60006020828403121561117157600080fd5b815160ff8116811461078557600080fd5b60006020828403121561119457600080fd5b81516001600160e01b03198116811461078557600080fd5b6000825160005b818110156111cd57602081860181015185830152016111b3565b818111156111dc576000828501525b509190910192915050565b60008282101561120757634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fdfea264697066735822122034f0afb282988b256dcfa1a84ba5b9e2bbf1a363259d390426cd282b12cfed5164736f6c634300080d0033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000d998c35b7900b344bbbe6555cc11576942cf309d
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101425760003560e01c806379ba5097116100b8578063bde127181161007c578063bde12718146102a5578063c834439f146102cc578063d0659d75146102e1578063e30c3978146102e9578063eec3e6a7146102fa578063f2fde38b1461030f57600080fd5b806379ba50971461025c5780638da5cb5b1461026457806393b6809c1461026c57806397e8a2d81461027f578063a3fbbaae1461029257600080fd5b806341976e091161010a57806341976e09146101dc57806344552b5d146101ef578063481c6a75146101f757806350ebbcc1146102085780635d54e3951461022b578063715018a61461025457600080fd5b80631b01d69e14610147578063217a4b701461015c5780633278c694146101a0578063329afacd146101b357806339b216a3146101c9575b600080fd5b61015a610155366004611041565b610322565b005b6101837f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b0390911681526020015b60405180910390f35b61015a6101ae366004611041565b6104a0565b6101bb601281565b604051908152602001610197565b61015a6101d7366004611041565b6104db565b6101bb6101ea366004611041565b610569565b61015a61066f565b6000546001600160a01b0316610183565b61021b610216366004611041565b6106af565b6040519015158152602001610197565b610183610239366004611041565b6003602052600090815260409020546001600160a01b031681565b61015a61078c565b61015a6107c5565b61018361082c565b61015a61027a36600461105e565b610840565b61021b61028d366004611041565b610988565b61015a6102a0366004611041565b610995565b6101837f000000000000000000000000d998c35b7900b344bbbe6555cc11576942cf309d81565b6102d4610a91565b6040516101979190611097565b6101bb610a9d565b6002546001600160a01b0316610183565b60405163eec3e6a760e01b8152602001610197565b61015a61031d366004611041565b610aa9565b3361032b61082c565b6001600160a01b03161461035a5760405162461bcd60e51b8152600401610351906110e4565b60405180910390fd5b610371816001600160a01b03166357e0c50f610b92565b61038e57604051634cd31fbb60e01b815260040160405180910390fd5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b031663217a4b706040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041a9190611107565b6001600160a01b03161461044157604051630c2d3f5360e11b815260040160405180910390fd5b61044c600482610c1d565b610469576040516370a96ce960e01b815260040160405180910390fd5b6040516001600160a01b038216907f4705d8451928f44517faa1bdfbbca0e2b931ae93313f022b3b989537b0daa6f590600090a250565b336104a961082c565b6001600160a01b0316146104cf5760405162461bcd60e51b8152600401610351906110e4565b6104d881610c32565b50565b336104e461082c565b6001600160a01b03161461050a5760405162461bcd60e51b8152600401610351906110e4565b610515600482610cd9565b61053257604051631605dd1760e01b815260040160405180910390fd5b6040516001600160a01b038216907fbecb08a245e5ee64b9cf97ff511fa99537ede3f8387ee3df7f951ef1dabd19bd90600090a250565b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b0316036105b35750670de0b6b3a7640000919050565b6001600160a01b03828116600090815260036020526040902054166105eb5760405163981a2a2b60e01b815260040160405180910390fd5b6001600160a01b03828116600081815260036020526040908190205490516341976e0960e01b81526004810192909252909116906341976e0990602401602060405180830381865afa158015610645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106699190611124565b92915050565b3361067861082c565b6001600160a01b03161461069e5760405162461bcd60e51b8152600401610351906110e4565b6106a86000610c32565b565b905090565b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b0316036106f257506001919050565b6001600160a01b03808316600090815260036020526040902054168061071b5750600092915050565b60405163598fd92b60e11b81526001600160a01b03848116600483015282169063b31fb25690602401602060405180830381865afa158015610761573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610785919061113d565b9392505050565b3361079561082c565b6001600160a01b0316146107bb5760405162461bcd60e51b8152600401610351906110e4565b6106a86000610cee565b6002546001600160a01b031633146108125760405162461bcd60e51b815260206004820152601060248201526f27b7363ca832b73234b733a7bbb732b960811b6044820152606401610351565b6106a86108276002546001600160a01b031690565b610cee565b60006106aa6001546001600160a01b031690565b6000546001600160a01b0316331461086b5760405163605919ad60e11b815260040160405180910390fd5b610876600482610da1565b610893576040516350c14f3960e01b815260040160405180910390fd5b60405163598fd92b60e11b81526001600160a01b03838116600483015282169063b31fb25690602401602060405180830381865afa1580156108d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fd919061113d565b61091a5760405163981a2a2b60e01b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03167f26eb74ff7dd83e64daf822c2515feb1b0a46015000c9f339e23df0988237615160405160405180910390a36001600160a01b03918216600090815260036020526040902080546001600160a01b03191691909216179055565b6000610669600483610da1565b61099d61082c565b6001600160a01b0316336001600160a01b0316141580156109c957506000546001600160a01b03163314155b156109e75760405163b647320d60e01b815260040160405180910390fd5b6001600160a01b038116610a0e57604051639c774ebf60e01b815260040160405180910390fd5b6000546001600160a01b0390811690821603610a3d57604051632ebe652b60e21b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0383169081179091556040519081527f198db6e425fb8aafd1823c6ca50be2d51e5764571a5ae0f0f21c6812e45def0b9060200160405180910390a150565b60606106aa6004610dc3565b60006106aa6004610dd0565b33610ab261082c565b6001600160a01b031614610ad85760405162461bcd60e51b8152600401610351906110e4565b6001600160a01b038116610b1c5760405162461bcd60e51b815260206004820152600b60248201526a4f776e657249735a65726f60a81b6044820152606401610351565b6104d881610cee565b6040805160048152602481019091526020810180516001600160e01b031663313ce56760e01b17905260009081908190610b60908590610dda565b9150915081610b73575060009392505050565b80806020019051810190610b87919061115f565b60ff16949350505050565b60006001600160a01b03831615801590610785575082826040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfc9190611182565b60e083901b6001600160e01b03199081169116149392505050565b3b151590565b6000610785836001600160a01b038416610e8e565b6002546001600160a01b03808316911603610c8f5760405162461bcd60e51b815260206004820152601860248201527f50656e64696e674f776e65724469644e6f744368616e676500000000000000006044820152606401610351565b600280546001600160a01b0319166001600160a01b0383169081179091556040517fd6aad444c90d39fb0eee1c6e357a7fad83d63f719ac5f880445a2beb0ff3ab5890600090a250565b6000610785836001600160a01b038416610edd565b6001546001600160a01b03808316911603610d3f5760405162461bcd60e51b81526020600482015260116024820152704f776e65724469644e6f744368616e676560781b6044820152606401610351565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f04dba622d284ed0014ee4b9a6a68386be1a4c08a4913ae272de89199cc68616390600090a26002546001600160a01b0316156104d8576104d86000610c32565b6001600160a01b03811660009081526001830160205260408120541515610785565b6060600061078583610fd0565b6000610669825490565b60006060833b610dfd576040516373d39f9d60e01b815260040160405180910390fd5b600080856001600160a01b031685604051610e1891906111ac565b600060405180830381855afa9150503d8060008114610e53576040519150601f19603f3d011682016040523d82523d6000602084013e610e58565b606091505b509150915081610e7f57600060405180602001604052806000815250935093505050610e87565b600193509150505b9250929050565b6000818152600183016020526040812054610ed557508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610669565b506000610669565b60008181526001830160205260408120548015610fc6576000610f016001836111e7565b8554909150600090610f15906001906111e7565b9050818114610f7a576000866000018281548110610f3557610f3561120c565b9060005260206000200154905080876000018481548110610f5857610f5861120c565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080610f8b57610f8b611222565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610669565b6000915050610669565b60608160000180548060200260200160405190810160405280929190818152602001828054801561102057602002820191906000526020600020905b81548152602001906001019080831161100c575b50505050509050919050565b6001600160a01b03811681146104d857600080fd5b60006020828403121561105357600080fd5b81356107858161102c565b6000806040838503121561107157600080fd5b823561107c8161102c565b9150602083013561108c8161102c565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156110d85783516001600160a01b0316835292840192918401916001016110b3565b50909695505050505050565b60208082526009908201526827b7363ca7bbb732b960b91b604082015260600190565b60006020828403121561111957600080fd5b81516107858161102c565b60006020828403121561113657600080fd5b5051919050565b60006020828403121561114f57600080fd5b8151801515811461078557600080fd5b60006020828403121561117157600080fd5b815160ff8116811461078557600080fd5b60006020828403121561119457600080fd5b81516001600160e01b03198116811461078557600080fd5b6000825160005b818110156111cd57602081860181015185830152016111b3565b818111156111dc576000828501525b509190910192915050565b60008282101561120757634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fdfea264697066735822122034f0afb282988b256dcfa1a84ba5b9e2bbf1a363259d390426cd282b12cfed5164736f6c634300080d0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000d998c35b7900b344bbbe6555cc11576942cf309d
-----Decoded View---------------
Arg [0] : _quoteToken (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _siloRepository (address): 0xd998C35B7900b344bbBe6555cc11576942Cf309d
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 000000000000000000000000d998c35b7900b344bbbe6555cc11576942cf309d
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.