Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
Contract Name:
RedstoneChainlinkCompositeWrapperWithThresholding
Compiler Version
v0.8.22+commit.4fc1097e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "../interface/chainlink/BaseChainlinkWrapper.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import { IPriceFeed } from "../interface/chainlink/IPriceFeed.sol";
import "./ThresholdingUtils.sol";
/**
* @title RedstoneChainlinkCompositeWrapperWithThresholding
* @dev Implementation of BaseChainlinkWrapper for composite Redstone oracles with thresholding
*/
contract RedstoneChainlinkCompositeWrapperWithThresholding is BaseChainlinkWrapper, ThresholdingUtils {
/* Core state */
struct CompositeFeed {
address feed1;
address feed2;
ThresholdConfig primaryThreshold; // Primary price source threshold config
ThresholdConfig secondaryThreshold; // Secondary price source threshold config
}
mapping(address => CompositeFeed) public compositeFeeds;
/* Events */
event CompositeFeedAdded(
address indexed asset,
address feed1,
address feed2,
uint256 lowerThresholdInBase1,
uint256 fixedPriceInBase1,
uint256 lowerThresholdInBase2,
uint256 fixedPriceInBase2
);
event CompositeFeedRemoved(address indexed asset);
event CompositeFeedUpdated(
address indexed asset,
uint256 lowerThresholdInBase1,
uint256 fixedPriceInBase1,
uint256 lowerThresholdInBase2,
uint256 fixedPriceInBase2
);
constructor(address baseCurrency, uint256 _baseCurrencyUnit) BaseChainlinkWrapper(baseCurrency, _baseCurrencyUnit) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(ORACLE_MANAGER_ROLE, msg.sender);
}
function addCompositeFeed(
address asset,
address feed1,
address feed2,
uint256 lowerThresholdInBase1,
uint256 fixedPriceInBase1,
uint256 lowerThresholdInBase2,
uint256 fixedPriceInBase2
) external onlyRole(ORACLE_MANAGER_ROLE) {
compositeFeeds[asset] = CompositeFeed({
feed1: feed1,
feed2: feed2,
primaryThreshold: ThresholdConfig({ lowerThresholdInBase: lowerThresholdInBase1, fixedPriceInBase: fixedPriceInBase1 }),
secondaryThreshold: ThresholdConfig({ lowerThresholdInBase: lowerThresholdInBase2, fixedPriceInBase: fixedPriceInBase2 })
});
emit CompositeFeedAdded(asset, feed1, feed2, lowerThresholdInBase1, fixedPriceInBase1, lowerThresholdInBase2, fixedPriceInBase2);
}
function removeCompositeFeed(address asset) external onlyRole(ORACLE_MANAGER_ROLE) {
delete compositeFeeds[asset];
emit CompositeFeedRemoved(asset);
}
function updateCompositeFeed(
address asset,
uint256 lowerThresholdInBase1,
uint256 fixedPriceInBase1,
uint256 lowerThresholdInBase2,
uint256 fixedPriceInBase2
) external onlyRole(ORACLE_MANAGER_ROLE) {
CompositeFeed storage feed = compositeFeeds[asset];
if (feed.feed1 == address(0) || feed.feed2 == address(0)) {
revert FeedNotSet(asset);
}
feed.primaryThreshold.lowerThresholdInBase = lowerThresholdInBase1;
feed.primaryThreshold.fixedPriceInBase = fixedPriceInBase1;
feed.secondaryThreshold.lowerThresholdInBase = lowerThresholdInBase2;
feed.secondaryThreshold.fixedPriceInBase = fixedPriceInBase2;
emit CompositeFeedUpdated(asset, lowerThresholdInBase1, fixedPriceInBase1, lowerThresholdInBase2, fixedPriceInBase2);
}
function getPriceInfo(address asset) public view override returns (uint256 price, bool isAlive) {
CompositeFeed memory feed = compositeFeeds[asset];
if (feed.feed1 == address(0) || feed.feed2 == address(0)) {
revert FeedNotSet(asset);
}
(, int256 answer1, , uint256 updatedAt1, ) = IPriceFeed(feed.feed1).latestRoundData();
(, int256 answer2, , uint256 updatedAt2, ) = IPriceFeed(feed.feed2).latestRoundData();
uint256 chainlinkPrice1 = answer1 > 0 ? uint256(answer1) : 0;
uint256 chainlinkPrice2 = answer2 > 0 ? uint256(answer2) : 0;
// Convert both prices to BASE_CURRENCY_UNIT first
uint256 priceInBase1 = _convertToBaseCurrencyUnit(chainlinkPrice1);
uint256 priceInBase2 = _convertToBaseCurrencyUnit(chainlinkPrice2);
// Apply thresholding to prices in BASE_CURRENCY_UNIT if specified
if (feed.primaryThreshold.lowerThresholdInBase > 0) {
priceInBase1 = _applyThreshold(priceInBase1, feed.primaryThreshold);
}
if (feed.secondaryThreshold.lowerThresholdInBase > 0) {
priceInBase2 = _applyThreshold(priceInBase2, feed.secondaryThreshold);
}
price = (priceInBase1 * priceInBase2) / BASE_CURRENCY_UNIT;
isAlive =
price > 0 &&
updatedAt1 + CHAINLINK_HEARTBEAT + heartbeatStaleTimeLimit > block.timestamp &&
updatedAt2 + CHAINLINK_HEARTBEAT + heartbeatStaleTimeLimit > block.timestamp;
}
function getAssetPrice(address asset) external view override returns (uint256) {
(uint256 price, bool isAlive) = getPriceInfo(asset);
if (!isAlive) {
revert PriceIsStale();
}
return price;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {IERC165, ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)
pragma solidity >=0.8.4;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted to signal this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
/**
* @dev Interface for the individual oracle wrappers, to unify interface between different oracle providers
*/
interface IOracleWrapper {
/**
* @notice Returns the base currency address
* @dev Address 0x0 is commonly used for USD, but can be any token address based on the implementation.
* @return Returns the base currency address.
*/
function BASE_CURRENCY() external view returns (address);
/**
* @notice Returns the base currency unit
* @dev Represents the decimal precision of the base currency (e.g., 1e8 for USD, 1e18 for ETH).
* @return Returns the base currency unit.
*/
function BASE_CURRENCY_UNIT() external view returns (uint256);
/**
* @notice Returns the asset price in the base currency
* @param asset The address of the asset
* @return The price of the asset
*/
function getAssetPrice(address asset) external view returns (uint256);
/**
* @notice Returns the price and alive status of an asset
* @param asset The address of the asset
* @return price The price of the asset
* @return isAlive The alive status of the asset
*/
function getPriceInfo(address asset) external view returns (uint256 price, bool isAlive);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "../IOracleWrapper.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
/**
* @title BaseChainlinkWrapper
* @dev Abstract contract that implements the IOracleWrapper interface for Chainlink-style oracles
* Provides common functionality for all Chainlink-compatible oracle wrappers
*/
abstract contract BaseChainlinkWrapper is IOracleWrapper, AccessControl {
/* Core state */
uint256 public constant CHAINLINK_BASE_CURRENCY_UNIT = 10 ** 8; // Chainlink uses 8 decimals
uint256 public constant CHAINLINK_HEARTBEAT = 24 hours;
address private immutable _baseCurrency;
uint256 public immutable BASE_CURRENCY_UNIT;
uint256 public heartbeatStaleTimeLimit = 30 minutes;
/* Roles */
bytes32 public constant ORACLE_MANAGER_ROLE = keccak256("ORACLE_MANAGER_ROLE");
/* Errors */
error PriceIsStale();
error InvalidPrice();
error FeedNotSet(address asset);
/**
* @dev Constructor that sets the base currency and base currency unit
* @param baseCurrency The address of the base currency (zero address for USD)
* @param _baseCurrencyUnit The decimal precision of the base currency (e.g., 1e8 for USD)
*/
constructor(address baseCurrency, uint256 _baseCurrencyUnit) {
_baseCurrency = baseCurrency;
BASE_CURRENCY_UNIT = _baseCurrencyUnit;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(ORACLE_MANAGER_ROLE, msg.sender);
}
/**
* @notice Returns the base currency address
* @return Returns the base currency address
*/
function BASE_CURRENCY() external view override returns (address) {
return _baseCurrency;
}
/**
* @notice Gets the price information for an asset
* @param asset The address of the asset to get the price for
* @return price The price of the asset in base currency units
* @return isAlive Whether the price feed is considered active/valid
*/
function getPriceInfo(address asset) public view virtual override returns (uint256 price, bool isAlive);
/**
* @notice Gets the current price of an asset
* @param asset The address of the asset to get the price for
* @return The current price of the asset
*/
function getAssetPrice(address asset) external view virtual override returns (uint256) {
(uint256 price, bool isAlive) = getPriceInfo(asset);
if (!isAlive) {
revert PriceIsStale();
}
return price;
}
/**
* @dev Converts a price from Chainlink decimals to base currency decimals
* @param price The price in Chainlink decimals
* @return The price in base currency decimals
*/
function _convertToBaseCurrencyUnit(uint256 price) internal view returns (uint256) {
return (price * BASE_CURRENCY_UNIT) / CHAINLINK_BASE_CURRENCY_UNIT;
}
/**
* @notice Sets the heartbeat stale time limit
* @param _newHeartbeatStaleTimeLimit The new heartbeat stale time limit
*/
function setHeartbeatStaleTimeLimit(uint256 _newHeartbeatStaleTimeLimit) external onlyRole(ORACLE_MANAGER_ROLE) {
heartbeatStaleTimeLimit = _newHeartbeatStaleTimeLimit;
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
interface IPriceFeed {
function decimals() external view returns (uint8);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
abstract contract ThresholdingUtils {
/* Types */
struct ThresholdConfig {
/// @notice The minimum price after which thresholding is applied. Not a price cap, but a trigger point.
/// @dev If lowerThresholdInBase == fixedPriceInBase: Acts as an upper threshold
/// @dev If lowerThresholdInBase < fixedPriceInBase: Acts as "price rounding up" (e.g. if USDC > 0.997 then round to 1)
/// @dev If lowerThresholdInBase > fixedPriceInBase: Acts as "price rounding down" (e.g. if USDC > 1.003 then round to 1)
uint256 lowerThresholdInBase;
uint256 fixedPriceInBase;
}
/**
* @notice Apply threshold to a price value
* @param priceInBase The price to check against threshold
* @param thresholdConfig The threshold configuration
* @return The original price or fixed price based on threshold
*/
function _applyThreshold(uint256 priceInBase, ThresholdConfig memory thresholdConfig) internal pure returns (uint256) {
if (priceInBase > thresholdConfig.lowerThresholdInBase) {
return thresholdConfig.fixedPriceInBase;
}
return priceInBase;
}
}{
"evmVersion": "paris",
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"baseCurrency","type":"address"},{"internalType":"uint256","name":"_baseCurrencyUnit","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"FeedNotSet","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"PriceIsStale","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"address","name":"feed1","type":"address"},{"indexed":false,"internalType":"address","name":"feed2","type":"address"},{"indexed":false,"internalType":"uint256","name":"lowerThresholdInBase1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedPriceInBase1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lowerThresholdInBase2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedPriceInBase2","type":"uint256"}],"name":"CompositeFeedAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"}],"name":"CompositeFeedRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"lowerThresholdInBase1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedPriceInBase1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lowerThresholdInBase2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fixedPriceInBase2","type":"uint256"}],"name":"CompositeFeedUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"BASE_CURRENCY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BASE_CURRENCY_UNIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CHAINLINK_BASE_CURRENCY_UNIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CHAINLINK_HEARTBEAT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ORACLE_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"feed1","type":"address"},{"internalType":"address","name":"feed2","type":"address"},{"internalType":"uint256","name":"lowerThresholdInBase1","type":"uint256"},{"internalType":"uint256","name":"fixedPriceInBase1","type":"uint256"},{"internalType":"uint256","name":"lowerThresholdInBase2","type":"uint256"},{"internalType":"uint256","name":"fixedPriceInBase2","type":"uint256"}],"name":"addCompositeFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"compositeFeeds","outputs":[{"internalType":"address","name":"feed1","type":"address"},{"internalType":"address","name":"feed2","type":"address"},{"components":[{"internalType":"uint256","name":"lowerThresholdInBase","type":"uint256"},{"internalType":"uint256","name":"fixedPriceInBase","type":"uint256"}],"internalType":"struct ThresholdingUtils.ThresholdConfig","name":"primaryThreshold","type":"tuple"},{"components":[{"internalType":"uint256","name":"lowerThresholdInBase","type":"uint256"},{"internalType":"uint256","name":"fixedPriceInBase","type":"uint256"}],"internalType":"struct ThresholdingUtils.ThresholdConfig","name":"secondaryThreshold","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getAssetPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getPriceInfo","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"isAlive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"heartbeatStaleTimeLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"removeCompositeFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newHeartbeatStaleTimeLimit","type":"uint256"}],"name":"setHeartbeatStaleTimeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"lowerThresholdInBase1","type":"uint256"},{"internalType":"uint256","name":"fixedPriceInBase1","type":"uint256"},{"internalType":"uint256","name":"lowerThresholdInBase2","type":"uint256"},{"internalType":"uint256","name":"fixedPriceInBase2","type":"uint256"}],"name":"updateCompositeFeed","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60c06040526107086001553480156200001757600080fd5b5060405162001075380380620010758339810160408190526200003a916200015d565b6001600160a01b03821660805260a081905281816200005b600033620000ae565b50620000776000805160206200105583398151915233620000ae565b506200008991506000905033620000ae565b50620000a56000805160206200105583398151915233620000ae565b50505062000199565b6000828152602081815260408083206001600160a01b038516845290915281205460ff1662000153576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556200010a3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600162000157565b5060005b92915050565b600080604083850312156200017157600080fd5b82516001600160a01b03811681146200018957600080fd5b6020939093015192949293505050565b60805160a051610e88620001cd600039600081816101e6015281816107a90152610b3c015260006102c30152610e886000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c806391d14854116100ad578063c5efe27c11610071578063c5efe27c14610290578063d547741f146102a3578063e19f4700146102b6578063eae06eec146102ed578063f99256d5146102f857600080fd5b806391d14854146102435780639a999d4514610256578063a217fddf14610260578063b3596f0714610268578063bfc69e1c1461027b57600080fd5b806336568abe116100f457806336568abe146101bb578063519ffff1146101ce5780638c89b64f146101e15780638edbf436146102085780638f5997151461023057600080fd5b806301ffc9a71461013157806304dea65114610159578063248a9ca31461016e5780632ecac6fc1461019f5780632f2ff15d146101a8575b600080fd5b61014461013f366004610bc6565b610374565b60405190151581526020015b60405180910390f35b61016c610167366004610c13565b6103ab565b005b61019161017c366004610c55565b60009081526020819052604090206001015490565b604051908152602001610150565b61019160015481565b61016c6101b6366004610c6e565b61049e565b61016c6101c9366004610c6e565b6104c9565b61016c6101dc366004610c9a565b610501565b6101917f000000000000000000000000000000000000000000000000000000000000000081565b61021b610216366004610c9a565b610594565b60408051928352901515602083015201610150565b61016c61023e366004610cb5565b61083c565b610144610251366004610c6e565b610983565b6101916201518081565b610191600081565b610191610276366004610c9a565b6109ac565b610191600080516020610e3383398151915281565b61016c61029e366004610c55565b6109e3565b61016c6102b1366004610c6e565b610a01565b6040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152602001610150565b6101916305f5e10081565b610364610306366004610c9a565b6002602081815260009283526040928390208054600182015485518087018752948301548552600383015485850152855180870190965260048301548652600590920154928501929092526001600160a01b03918216939116919084565b6040516101509493929190610d1d565b60006001600160e01b03198216637965db0b60e01b14806103a557506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080516020610e338339815191526103c381610a26565b6001600160a01b038087166000908152600260205260409020805490911615806103f8575060018101546001600160a01b0316155b1561042657604051630dcaf86b60e01b81526001600160a01b03881660048201526024015b60405180910390fd5b600281018690556003810185905560048101849055600581018390556040805187815260208101879052908101859052606081018490526001600160a01b038816907fbdebb389cb3e5b0a7c038b900aeea5b6e265e74efd0de50488c3574a4d7861d59060800160405180910390a250505050505050565b6000828152602081905260409020600101546104b981610a26565b6104c38383610a33565b50505050565b6001600160a01b03811633146104f25760405163334bd91960e11b815260040160405180910390fd5b6104fc8282610ac5565b505050565b600080516020610e3383398151915261051981610a26565b6001600160a01b038216600081815260026020819052604080832080546001600160a01b03199081168255600182018054909116905591820183905560038201839055600482018390556005909101829055517fdabc58d0456c50872fa82879bc9ce7f6a455b4372db632857a62de4abd0996919190a25050565b6001600160a01b03808216600090815260026020818152604080842081516080810183528154871681526001820154871681850152825180840184529482015485526003820154858501528083019490945281518083019092526004810154825260050154918101919091526060820152805191928392161580610623575060208101516001600160a01b0316155b1561064c57604051630dcaf86b60e01b81526001600160a01b038516600482015260240161041d565b60008082600001516001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610691573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b59190610d80565b5093505092505060008084602001516001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610701573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107259190610d80565b50935050925050600080851361073c57600061073e565b845b90506000808413610750576000610752565b835b9050600061075f83610b30565b9050600061076c83610b30565b60408a0151519091501561078b57610788828a60400151610b6b565b91505b606089015151156107a7576107a4818a60600151610b6b565b90505b7f00000000000000000000000000000000000000000000000000000000000000006107d28284610de6565b6107dc9190610dfd565b9a5060008b118015610807575060015442906107fb620151808a610e1f565b6108059190610e1f565b115b801561082c575060015442906108206201518088610e1f565b61082a9190610e1f565b115b9950505050505050505050915091565b600080516020610e3383398151915261085481610a26565b604080516080810182526001600160a01b03808a1682528881166020808401918252845180860186528a81528082018a905284860190815285518087018752898152808301899052606086019081528e85166000818152600280865290899020975188549088166001600160a01b03199182161789559551600189018054919098169616959095179095559051805193860193909355918101516003850155905180516004850155015160059092019190915590517f8af3f37e726b4aaf30de76bd00359c9166bf6b9a01e457c3d4557df631227eed90610971908a908a908a908a908a908a906001600160a01b03968716815294909516602085015260408401929092526060830152608082015260a081019190915260c00190565b60405180910390a25050505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60008060006109ba84610594565b91509150806109dc576040516342bc305b60e11b815260040160405180910390fd5b5092915050565b600080516020610e338339815191526109fb81610a26565b50600155565b600082815260208190526040902060010154610a1c81610a26565b6104c38383610ac5565b610a308133610b89565b50565b6000610a3f8383610983565b610abd576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055610a753390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016103a5565b5060006103a5565b6000610ad18383610983565b15610abd576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016103a5565b60006305f5e100610b617f000000000000000000000000000000000000000000000000000000000000000084610de6565b6103a59190610dfd565b8051600090831115610b82575060208101516103a5565b5090919050565b610b938282610983565b610bc25760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161041d565b5050565b600060208284031215610bd857600080fd5b81356001600160e01b031981168114610bf057600080fd5b9392505050565b80356001600160a01b0381168114610c0e57600080fd5b919050565b600080600080600060a08688031215610c2b57600080fd5b610c3486610bf7565b97602087013597506040870135966060810135965060800135945092505050565b600060208284031215610c6757600080fd5b5035919050565b60008060408385031215610c8157600080fd5b82359150610c9160208401610bf7565b90509250929050565b600060208284031215610cac57600080fd5b610bf082610bf7565b600080600080600080600060e0888a031215610cd057600080fd5b610cd988610bf7565b9650610ce760208901610bf7565b9550610cf560408901610bf7565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b6001600160a01b0385811682528416602082015260c08101610d4c604083018580518252602090810151910152565b82516080830152602083015160a083015295945050505050565b805169ffffffffffffffffffff81168114610c0e57600080fd5b600080600080600060a08688031215610d9857600080fd5b610da186610d66565b9450602086015193506040860151925060608601519150610dc460808701610d66565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176103a5576103a5610dd0565b600082610e1a57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156103a5576103a5610dd056feced6982f480260bdd8ad5cb18ff2854f0306d78d904ad6cc107e8f3a0f526c18a264697066735822122084c36e658fe15e876f87262e2e6ec18c9d165ff26f80029c166a9d546afb123064736f6c63430008160033ced6982f480260bdd8ad5cb18ff2854f0306d78d904ad6cc107e8f3a0f526c1800000000000000000000000055f937def274c6cbd9444f0857639757c5a2a3e90000000000000000000000000000000000000000000000000de0b6b3a7640000
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806391d14854116100ad578063c5efe27c11610071578063c5efe27c14610290578063d547741f146102a3578063e19f4700146102b6578063eae06eec146102ed578063f99256d5146102f857600080fd5b806391d14854146102435780639a999d4514610256578063a217fddf14610260578063b3596f0714610268578063bfc69e1c1461027b57600080fd5b806336568abe116100f457806336568abe146101bb578063519ffff1146101ce5780638c89b64f146101e15780638edbf436146102085780638f5997151461023057600080fd5b806301ffc9a71461013157806304dea65114610159578063248a9ca31461016e5780632ecac6fc1461019f5780632f2ff15d146101a8575b600080fd5b61014461013f366004610bc6565b610374565b60405190151581526020015b60405180910390f35b61016c610167366004610c13565b6103ab565b005b61019161017c366004610c55565b60009081526020819052604090206001015490565b604051908152602001610150565b61019160015481565b61016c6101b6366004610c6e565b61049e565b61016c6101c9366004610c6e565b6104c9565b61016c6101dc366004610c9a565b610501565b6101917f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b61021b610216366004610c9a565b610594565b60408051928352901515602083015201610150565b61016c61023e366004610cb5565b61083c565b610144610251366004610c6e565b610983565b6101916201518081565b610191600081565b610191610276366004610c9a565b6109ac565b610191600080516020610e3383398151915281565b61016c61029e366004610c55565b6109e3565b61016c6102b1366004610c6e565b610a01565b6040516001600160a01b037f00000000000000000000000055f937def274c6cbd9444f0857639757c5a2a3e9168152602001610150565b6101916305f5e10081565b610364610306366004610c9a565b6002602081815260009283526040928390208054600182015485518087018752948301548552600383015485850152855180870190965260048301548652600590920154928501929092526001600160a01b03918216939116919084565b6040516101509493929190610d1d565b60006001600160e01b03198216637965db0b60e01b14806103a557506301ffc9a760e01b6001600160e01b03198316145b92915050565b600080516020610e338339815191526103c381610a26565b6001600160a01b038087166000908152600260205260409020805490911615806103f8575060018101546001600160a01b0316155b1561042657604051630dcaf86b60e01b81526001600160a01b03881660048201526024015b60405180910390fd5b600281018690556003810185905560048101849055600581018390556040805187815260208101879052908101859052606081018490526001600160a01b038816907fbdebb389cb3e5b0a7c038b900aeea5b6e265e74efd0de50488c3574a4d7861d59060800160405180910390a250505050505050565b6000828152602081905260409020600101546104b981610a26565b6104c38383610a33565b50505050565b6001600160a01b03811633146104f25760405163334bd91960e11b815260040160405180910390fd5b6104fc8282610ac5565b505050565b600080516020610e3383398151915261051981610a26565b6001600160a01b038216600081815260026020819052604080832080546001600160a01b03199081168255600182018054909116905591820183905560038201839055600482018390556005909101829055517fdabc58d0456c50872fa82879bc9ce7f6a455b4372db632857a62de4abd0996919190a25050565b6001600160a01b03808216600090815260026020818152604080842081516080810183528154871681526001820154871681850152825180840184529482015485526003820154858501528083019490945281518083019092526004810154825260050154918101919091526060820152805191928392161580610623575060208101516001600160a01b0316155b1561064c57604051630dcaf86b60e01b81526001600160a01b038516600482015260240161041d565b60008082600001516001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610691573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b59190610d80565b5093505092505060008084602001516001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610701573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107259190610d80565b50935050925050600080851361073c57600061073e565b845b90506000808413610750576000610752565b835b9050600061075f83610b30565b9050600061076c83610b30565b60408a0151519091501561078b57610788828a60400151610b6b565b91505b606089015151156107a7576107a4818a60600151610b6b565b90505b7f0000000000000000000000000000000000000000000000000de0b6b3a76400006107d28284610de6565b6107dc9190610dfd565b9a5060008b118015610807575060015442906107fb620151808a610e1f565b6108059190610e1f565b115b801561082c575060015442906108206201518088610e1f565b61082a9190610e1f565b115b9950505050505050505050915091565b600080516020610e3383398151915261085481610a26565b604080516080810182526001600160a01b03808a1682528881166020808401918252845180860186528a81528082018a905284860190815285518087018752898152808301899052606086019081528e85166000818152600280865290899020975188549088166001600160a01b03199182161789559551600189018054919098169616959095179095559051805193860193909355918101516003850155905180516004850155015160059092019190915590517f8af3f37e726b4aaf30de76bd00359c9166bf6b9a01e457c3d4557df631227eed90610971908a908a908a908a908a908a906001600160a01b03968716815294909516602085015260408401929092526060830152608082015260a081019190915260c00190565b60405180910390a25050505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60008060006109ba84610594565b91509150806109dc576040516342bc305b60e11b815260040160405180910390fd5b5092915050565b600080516020610e338339815191526109fb81610a26565b50600155565b600082815260208190526040902060010154610a1c81610a26565b6104c38383610ac5565b610a308133610b89565b50565b6000610a3f8383610983565b610abd576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055610a753390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016103a5565b5060006103a5565b6000610ad18383610983565b15610abd576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016103a5565b60006305f5e100610b617f0000000000000000000000000000000000000000000000000de0b6b3a764000084610de6565b6103a59190610dfd565b8051600090831115610b82575060208101516103a5565b5090919050565b610b938282610983565b610bc25760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161041d565b5050565b600060208284031215610bd857600080fd5b81356001600160e01b031981168114610bf057600080fd5b9392505050565b80356001600160a01b0381168114610c0e57600080fd5b919050565b600080600080600060a08688031215610c2b57600080fd5b610c3486610bf7565b97602087013597506040870135966060810135965060800135945092505050565b600060208284031215610c6757600080fd5b5035919050565b60008060408385031215610c8157600080fd5b82359150610c9160208401610bf7565b90509250929050565b600060208284031215610cac57600080fd5b610bf082610bf7565b600080600080600080600060e0888a031215610cd057600080fd5b610cd988610bf7565b9650610ce760208901610bf7565b9550610cf560408901610bf7565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b6001600160a01b0385811682528416602082015260c08101610d4c604083018580518252602090810151910152565b82516080830152602083015160a083015295945050505050565b805169ffffffffffffffffffff81168114610c0e57600080fd5b600080600080600060a08688031215610d9857600080fd5b610da186610d66565b9450602086015193506040860151925060608601519150610dc460808701610d66565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176103a5576103a5610dd0565b600082610e1a57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156103a5576103a5610dd056feced6982f480260bdd8ad5cb18ff2854f0306d78d904ad6cc107e8f3a0f526c18a264697066735822122084c36e658fe15e876f87262e2e6ec18c9d165ff26f80029c166a9d546afb123064736f6c63430008160033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000055f937def274c6cbd9444f0857639757c5a2a3e90000000000000000000000000000000000000000000000000de0b6b3a7640000
-----Decoded View---------------
Arg [0] : baseCurrency (address): 0x55F937DEF274C6CBd9444f0857639757C5A2a3E9
Arg [1] : _baseCurrencyUnit (uint256): 1000000000000000000
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000055f937def274c6cbd9444f0857639757c5a2a3e9
Arg [1] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.