Latest 14 from a total of 14 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Revoke Role | 13883385 | 329 days ago | IN | 0 FRAX | 0.00000154 | ||||
| Revoke Role | 13883378 | 329 days ago | IN | 0 FRAX | 0.00000171 | ||||
| Revoke Role | 13883373 | 329 days ago | IN | 0 FRAX | 0.0000017 | ||||
| Revoke Role | 13883368 | 329 days ago | IN | 0 FRAX | 0.0000017 | ||||
| Grant Role | 13883323 | 329 days ago | IN | 0 FRAX | 0.00000177 | ||||
| Grant Role | 13883317 | 329 days ago | IN | 0 FRAX | 0.00000172 | ||||
| Grant Role | 13883312 | 329 days ago | IN | 0 FRAX | 0.00000168 | ||||
| Grant Role | 13883306 | 329 days ago | IN | 0 FRAX | 0.00000151 | ||||
| Allow Collateral | 13881812 | 329 days ago | IN | 0 FRAX | 0.00000206 | ||||
| Allow Collateral | 13881807 | 329 days ago | IN | 0 FRAX | 0.00000209 | ||||
| Allow Collateral | 13881802 | 329 days ago | IN | 0 FRAX | 0.00000196 | ||||
| Allow Collateral | 13881797 | 329 days ago | IN | 0 FRAX | 0.00000204 | ||||
| Allow Collateral | 13881791 | 329 days ago | IN | 0 FRAX | 0.00000204 | ||||
| Grant Role | 13880340 | 329 days ago | IN | 0 FRAX | 0.00000085 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
CollateralHolderVault
Compiler Version
v0.8.24+commit.e11b9ed9
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 "./CollateralVault.sol";
/**
* @title CollateralHolderVault
* @notice Implementation of CollateralVault for only holding tokens
*/
contract CollateralHolderVault is CollateralVault {
using SafeERC20 for IERC20Metadata;
using EnumerableSet for EnumerableSet.AddressSet;
/* Errors */
error CannotWithdrawMoreValueThanDeposited(
uint256 requestedAmount,
uint256 maxAmount
);
error ToCollateralAmountBelowMin(
uint256 toCollateralAmount,
uint256 toMinCollateral
);
constructor(IPriceOracleGetter oracle) CollateralVault(oracle) {}
/**
* @notice Exchanges one type of collateral for another
* @param fromCollateralAmount Amount of collateral to exchange from
* @param fromCollateral Address of the source collateral token
* @param toCollateralAmount Amount of collateral to receive
* @param toCollateral Address of the destination collateral token
* @dev Ensures the exchange maintains equivalent value using oracle prices
*/
function exchangeCollateral(
uint256 fromCollateralAmount,
address fromCollateral,
uint256 toCollateralAmount,
address toCollateral
) public onlyRole(COLLATERAL_STRATEGY_ROLE) {
// We must take in a collateral that is supported
require(
_supportedCollaterals.contains(toCollateral),
"Unsupported collateral"
);
uint256 maxAmount = maxExchangeAmount(
fromCollateralAmount,
fromCollateral,
toCollateral
);
if (toCollateralAmount > maxAmount) {
revert CannotWithdrawMoreValueThanDeposited(
toCollateralAmount,
maxAmount
);
}
IERC20Metadata(fromCollateral).safeTransferFrom(
msg.sender,
address(this),
fromCollateralAmount
);
IERC20Metadata(toCollateral).safeTransfer(
msg.sender,
toCollateralAmount
);
}
/**
* @notice Exchanges collateral for the maximum possible amount of another collateral
* @param fromCollateralAmount Amount of collateral to exchange from
* @param fromCollateral Address of the source collateral token
* @param toCollateral Address of the destination collateral token
* @param toMinCollateral Minimum amount of destination collateral to receive
* @dev Calculates and executes the maximum possible exchange while respecting minimum amount
*/
function exchangeMaxCollateral(
uint256 fromCollateralAmount,
address fromCollateral,
address toCollateral,
uint256 toMinCollateral
) public onlyRole(COLLATERAL_STRATEGY_ROLE) {
uint256 toCollateralAmount = maxExchangeAmount(
fromCollateralAmount,
fromCollateral,
toCollateral
);
if (toCollateralAmount < toMinCollateral) {
revert ToCollateralAmountBelowMin(
toCollateralAmount,
toMinCollateral
);
}
exchangeCollateral(
fromCollateralAmount,
fromCollateral,
toCollateralAmount,
toCollateral
);
}
/**
* @notice Calculates the maximum amount of destination collateral that can be received
* @param fromCollateralAmount Amount of source collateral
* @param fromCollateral Address of the source collateral token
* @param toCollateral Address of the destination collateral token
* @return toCollateralAmount The maximum amount of destination collateral that can be received
* @dev Uses oracle prices and token decimals to maintain equivalent value
*/
function maxExchangeAmount(
uint256 fromCollateralAmount,
address fromCollateral,
address toCollateral
) public view returns (uint256 toCollateralAmount) {
uint256 fromCollateralPrice = oracle.getAssetPrice(fromCollateral);
uint256 toCollateralPrice = oracle.getAssetPrice(toCollateral);
uint8 fromCollateralDecimals = IERC20Metadata(fromCollateral)
.decimals();
uint8 toCollateralDecimals = IERC20Metadata(toCollateral).decimals();
uint256 fromCollateralUsdValue = (fromCollateralPrice *
fromCollateralAmount) / (10 ** fromCollateralDecimals);
toCollateralAmount =
(fromCollateralUsdValue * (10 ** toCollateralDecimals)) /
toCollateralPrice;
return toCollateralAmount;
}
/**
* @notice Calculates the total value of all collateral in the vault
* @return usdValue The total value of all collateral in USD
*/
function totalValue() public view override returns (uint256 usdValue) {
return _totalValueOfSupportedCollaterals();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {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);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
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` to `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.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 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 signaling 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, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
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.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
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 (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// 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.0.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 ERC165 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 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* 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[EIP 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
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @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.
*
* ```solidity
* 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.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
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 is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @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._positions[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 cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 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 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[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._positions[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) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// 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;
/// @solidity memory-safe-assembly
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 in 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;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/access/AccessControl.sol";
import "@openzeppelin/contracts-5/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts-5/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-5/utils/structs/EnumerableSet.sol";
import "contracts/shared/Constants.sol";
import "contracts/lending/core/interfaces/IPriceOracleGetter.sol";
import "contracts/dusd/OracleAware.sol";
/**
* @title CollateralVault
* @notice Abstract contract for any contract that manages collateral assets
\ */
abstract contract CollateralVault is AccessControl, OracleAware {
using SafeERC20 for IERC20Metadata;
using EnumerableSet for EnumerableSet.AddressSet;
/* Core state */
EnumerableSet.AddressSet internal _supportedCollaterals;
/* Events */
event CollateralAllowed(address indexed collateralAsset);
event CollateralDisallowed(address indexed collateralAsset);
/* Roles */
bytes32 public constant COLLATERAL_MANAGER_ROLE =
keccak256("COLLATERAL_MANAGER_ROLE");
bytes32 public constant COLLATERAL_STRATEGY_ROLE =
keccak256("COLLATERAL_STRATEGY_ROLE");
bytes32 public constant COLLATERAL_WITHDRAWER_ROLE =
keccak256("COLLATERAL_WITHDRAWER_ROLE");
/* Errors */
error UnsupportedCollateral(address collateralAsset);
error CollateralAlreadyAllowed(address collateralAsset);
error NoOracleSupport(address collateralAsset);
error FailedToAddCollateral(address collateralAsset);
error CollateralNotSupported(address collateralAsset);
error MustSupportAtLeastOneCollateral();
error FailedToRemoveCollateral(address collateralAsset);
/**
* @notice Initializes the vault with an oracle and sets up initial roles
* @dev Grants all roles to the contract deployer initially
* @param oracle The price oracle to use for collateral valuation
*/
constructor(
IPriceOracleGetter oracle
) OracleAware(oracle, Constants.ORACLE_BASE_CURRENCY_UNIT) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // This is the super admin
grantRole(COLLATERAL_MANAGER_ROLE, msg.sender);
grantRole(COLLATERAL_WITHDRAWER_ROLE, msg.sender);
grantRole(COLLATERAL_STRATEGY_ROLE, msg.sender);
}
/* Deposit */
/**
* @notice Deposit collateral into the vault
* @param collateralAmount The amount of collateral to deposit
* @param collateralAsset The address of the collateral asset
*/
function deposit(uint256 collateralAmount, address collateralAsset) public {
if (!_supportedCollaterals.contains(collateralAsset)) {
revert UnsupportedCollateral(collateralAsset);
}
IERC20Metadata(collateralAsset).safeTransferFrom(
msg.sender,
address(this),
collateralAmount
);
}
/* Withdrawal */
/**
* @notice Withdraws collateral from the vault
* @param collateralAmount The amount of collateral to withdraw
* @param collateralAsset The address of the collateral asset
*/
function withdraw(
uint256 collateralAmount,
address collateralAsset
) public onlyRole(COLLATERAL_WITHDRAWER_ROLE) {
return _withdraw(msg.sender, collateralAmount, collateralAsset);
}
/**
* @notice Withdraws collateral from the vault to a specific address
* @param recipient The address receiving the collateral
* @param collateralAmount The amount of collateral to withdraw
* @param collateralAsset The address of the collateral asset
*/
function withdrawTo(
address recipient,
uint256 collateralAmount,
address collateralAsset
) public onlyRole(COLLATERAL_WITHDRAWER_ROLE) {
return _withdraw(recipient, collateralAmount, collateralAsset);
}
/**
* @notice Internal function to withdraw collateral from the vault
* @param withdrawer The address withdrawing the collateral
* @param collateralAmount The amount of collateral to withdraw
* @param collateralAsset The address of the collateral asset
*/
function _withdraw(
address withdrawer,
uint256 collateralAmount,
address collateralAsset
) internal {
IERC20Metadata(collateralAsset).safeTransfer(
withdrawer,
collateralAmount
);
}
/* Collateral Info */
/**
* @notice Calculates the total value of all assets in the vault
* @return usdValue The total value of all assets in USD
*/
function totalValue() public view virtual returns (uint256 usdValue);
/**
* @notice Calculates the USD value of a given amount of an asset
* @param assetAmount The amount of the asset
* @param asset The address of the asset
* @return usdValue The USD value of the asset
*/
function assetValueFromAmount(
uint256 assetAmount,
address asset
) public view returns (uint256 usdValue) {
uint256 assetPrice = oracle.getAssetPrice(asset);
uint8 assetDecimals = IERC20Metadata(asset).decimals();
return (assetPrice * assetAmount) / (10 ** assetDecimals);
}
/**
* @notice Calculates the amount of an asset that corresponds to a given USD value
* @param usdValue The USD value
* @param asset The address of the asset
* @return assetAmount The amount of the asset
*/
function assetAmountFromValue(
uint256 usdValue,
address asset
) public view returns (uint256 assetAmount) {
uint256 assetPrice = oracle.getAssetPrice(asset);
uint8 assetDecimals = IERC20Metadata(asset).decimals();
return (usdValue * (10 ** assetDecimals)) / assetPrice;
}
/* Collateral management */
/**
* @notice Allows a new collateral asset
* @param collateralAsset The address of the collateral asset
*/
function allowCollateral(
address collateralAsset
) public onlyRole(COLLATERAL_MANAGER_ROLE) {
if (_supportedCollaterals.contains(collateralAsset)) {
revert CollateralAlreadyAllowed(collateralAsset);
}
if (oracle.getAssetPrice(collateralAsset) == 0) {
revert NoOracleSupport(collateralAsset);
}
if (!_supportedCollaterals.add(collateralAsset)) {
revert FailedToAddCollateral(collateralAsset);
}
emit CollateralAllowed(collateralAsset);
}
/**
* @notice Disallows a previously supported collateral asset
* @dev Requires at least one collateral asset to remain supported
* @param collateralAsset The address of the collateral asset to disallow
*/
function disallowCollateral(
address collateralAsset
) public onlyRole(COLLATERAL_MANAGER_ROLE) {
if (!_supportedCollaterals.contains(collateralAsset)) {
revert CollateralNotSupported(collateralAsset);
}
if (_supportedCollaterals.length() <= 1) {
revert MustSupportAtLeastOneCollateral();
}
if (!_supportedCollaterals.remove(collateralAsset)) {
revert FailedToRemoveCollateral(collateralAsset);
}
emit CollateralDisallowed(collateralAsset);
}
/**
* @notice Checks if a given asset is supported as collateral
* @param collateralAsset The address of the collateral asset to check
* @return bool True if the asset is supported, false otherwise
*/
function isCollateralSupported(
address collateralAsset
) public view returns (bool) {
return _supportedCollaterals.contains(collateralAsset);
}
/**
* @notice Returns a list of all supported collateral assets
* @return address[] Array of collateral asset addresses
*/
function listCollateral() public view returns (address[] memory) {
return _supportedCollaterals.values();
}
/**
* @notice Calculates the total USD value of all supported collateral assets in the vault
* @dev Iterates through all supported collaterals and sums their USD values
* @return uint256 The total value in USD
*/
function _totalValueOfSupportedCollaterals()
internal
view
returns (uint256)
{
uint256 totalUsdValue = 0;
for (uint256 i = 0; i < _supportedCollaterals.length(); i++) {
address collateral = _supportedCollaterals.at(i);
uint256 collateralPrice = oracle.getAssetPrice(collateral);
uint8 collateralDecimals = IERC20Metadata(collateral).decimals();
uint256 collateralValue = (collateralPrice *
IERC20Metadata(collateral).balanceOf(address(this))) /
(10 ** collateralDecimals);
totalUsdValue += collateralValue;
}
return totalUsdValue;
}
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-5/access/AccessControl.sol";
import "contracts/lending/core/interfaces/IPriceOracleGetter.sol";
/**
* @title OracleAware
* @notice Abstract contract that provides oracle functionality to other contracts
*/
abstract contract OracleAware is AccessControl {
/* Core state */
IPriceOracleGetter public oracle;
uint256 public baseCurrencyUnit;
/* Events */
event OracleSet(address indexed newOracle);
/* Errors */
error IncorrectBaseCurrencyUnit(uint256 baseCurrencyUnit);
/**
* @notice Initializes the contract with an oracle and base currency unit
* @param initialOracle The initial oracle to use for price feeds
* @param _baseCurrencyUnit The base currency unit for price calculations
* @dev Sets up the initial oracle and base currency unit values
*/
constructor(IPriceOracleGetter initialOracle, uint256 _baseCurrencyUnit) {
oracle = initialOracle;
baseCurrencyUnit = _baseCurrencyUnit;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/**
* @notice Sets the oracle to use for collateral valuation
* @param newOracle The new oracle to use
*/
function setOracle(
IPriceOracleGetter newOracle
) public onlyRole(DEFAULT_ADMIN_ROLE) {
if (newOracle.BASE_CURRENCY_UNIT() != baseCurrencyUnit) {
revert IncorrectBaseCurrencyUnit(baseCurrencyUnit);
}
oracle = newOracle;
emit OracleSet(address(newOracle));
}
/**
* @notice Updates the base currency unit used for price calculations
* @param _newBaseCurrencyUnit The new base currency unit to set
* @dev Only used if the oracle's base currency unit changes
*/
function setBaseCurrencyUnit(
uint256 _newBaseCurrencyUnit
) public onlyRole(DEFAULT_ADMIN_ROLE) {
baseCurrencyUnit = _newBaseCurrencyUnit;
}
}// SPDX-License-Identifier: AGPL-3.0
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
/**
* @title IPriceOracleGetter
* @author Aave
* @notice Interface for the Aave price oracle.
*/
interface IPriceOracleGetter {
/**
* @notice Returns the base currency address
* @dev Address 0x0 is reserved for USD as base currency.
* @return Returns the base currency address.
*/
function BASE_CURRENCY() external view returns (address);
/**
* @notice Returns the base currency unit
* @dev 1 ether for ETH, 1e8 for USD.
* @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);
}// SPDX-License-Identifier: MIT
/* ———————————————————————————————————————————————————————————————————————————————— *
* _____ ______ ______ __ __ __ __ ______ __ __ *
* /\ __-. /\__ _\ /\ == \ /\ \ /\ "-.\ \ /\ \ /\__ _\ /\ \_\ \ *
* \ \ \/\ \ \/_/\ \/ \ \ __< \ \ \ \ \ \-. \ \ \ \ \/_/\ \/ \ \____ \ *
* \ \____- \ \_\ \ \_\ \_\ \ \_\ \ \_\\"\_\ \ \_\ \ \_\ \/\_____\ *
* \/____/ \/_/ \/_/ /_/ \/_/ \/_/ \/_/ \/_/ \/_/ \/_____/ *
* *
* ————————————————————————————————— dtrinity.org ————————————————————————————————— *
* *
* ▲ *
* ▲ ▲ *
* *
* ———————————————————————————————————————————————————————————————————————————————— *
* dTRINITY Protocol: https://github.com/dtrinity *
* ———————————————————————————————————————————————————————————————————————————————— */
pragma solidity ^0.8.0;
library Constants {
// Shared definitions of how we represent percentages and basis points
uint16 public constant ONE_BPS = 100; // 1 basis point with 2 decimals
uint32 public constant ONE_PERCENT_BPS = ONE_BPS * 100;
uint32 public constant ONE_HUNDRED_PERCENT_BPS = ONE_PERCENT_BPS * 100;
uint32 public constant ORACLE_BASE_CURRENCY_UNIT = 1e8;
}{
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"viaIR": true,
"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":"contract IPriceOracleGetter","name":"oracle","type":"address"}],"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":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"requestedAmount","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"}],"name":"CannotWithdrawMoreValueThanDeposited","type":"error"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"CollateralAlreadyAllowed","type":"error"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"CollateralNotSupported","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"FailedToAddCollateral","type":"error"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"FailedToRemoveCollateral","type":"error"},{"inputs":[{"internalType":"uint256","name":"baseCurrencyUnit","type":"uint256"}],"name":"IncorrectBaseCurrencyUnit","type":"error"},{"inputs":[],"name":"MustSupportAtLeastOneCollateral","type":"error"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"NoOracleSupport","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"toCollateralAmount","type":"uint256"},{"internalType":"uint256","name":"toMinCollateral","type":"uint256"}],"name":"ToCollateralAmountBelowMin","type":"error"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"UnsupportedCollateral","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collateralAsset","type":"address"}],"name":"CollateralAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collateralAsset","type":"address"}],"name":"CollateralDisallowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOracle","type":"address"}],"name":"OracleSet","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":"COLLATERAL_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COLLATERAL_STRATEGY_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COLLATERAL_WITHDRAWER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"allowCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"usdValue","type":"uint256"},{"internalType":"address","name":"asset","type":"address"}],"name":"assetAmountFromValue","outputs":[{"internalType":"uint256","name":"assetAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetAmount","type":"uint256"},{"internalType":"address","name":"asset","type":"address"}],"name":"assetValueFromAmount","outputs":[{"internalType":"uint256","name":"usdValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseCurrencyUnit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"disallowCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fromCollateralAmount","type":"uint256"},{"internalType":"address","name":"fromCollateral","type":"address"},{"internalType":"uint256","name":"toCollateralAmount","type":"uint256"},{"internalType":"address","name":"toCollateral","type":"address"}],"name":"exchangeCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fromCollateralAmount","type":"uint256"},{"internalType":"address","name":"fromCollateral","type":"address"},{"internalType":"address","name":"toCollateral","type":"address"},{"internalType":"uint256","name":"toMinCollateral","type":"uint256"}],"name":"exchangeMaxCollateral","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"isCollateralSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listCollateral","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fromCollateralAmount","type":"uint256"},{"internalType":"address","name":"fromCollateral","type":"address"},{"internalType":"address","name":"toCollateral","type":"address"}],"name":"maxExchangeAmount","outputs":[{"internalType":"uint256","name":"toCollateralAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract IPriceOracleGetter","name":"","type":"address"}],"stateMutability":"view","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":"_newBaseCurrencyUnit","type":"uint256"}],"name":"setBaseCurrencyUnit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPriceOracleGetter","name":"newOracle","type":"address"}],"name":"setOracle","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":[],"name":"totalValue","outputs":[{"internalType":"uint256","name":"usdValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"address","name":"collateralAsset","type":"address"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6080346200019c57601f62001bc238819003918201601f1916830192916001600160401b03841183851017620001a157808392604095865283396020928391810103126200019c57516001600160a01b038116908190036200019c57600180546001600160a01b0319169190911790556305f5e1006002556200008233620001b7565b506200008e33620001b7565b50600060008051602062001b62833981519152815280825260018382200154808252838220338352835260ff8483205416156200017f5750620000d13362000237565b5060008051602062001b82833981519152815280825260018382200154808252838220338352835260ff8483205416156200017f57508260ff916200011633620002c8565b5060008051602062001ba283398151915281528084526001828220015493848252828220903383525220541615620001635750620001543362000354565b50516117619081620003e18239f35b604491519063e2517d3f60e01b82523360048301526024820152fd5b60449084519063e2517d3f60e01b82523360048301526024820152fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b031660008181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205490919060ff166200023357818052816020526040822081835260205260408220600160ff19825416179055339160008051602062001b428339815191528180a4600190565b5090565b6001600160a01b031660008181527fb56095460044281636dd3a77e227972b73971c7d766b38feb76e4e7f12e8c602602052604081205490919060008051602062001b628339815191529060ff16620002c357808352826020526040832082845260205260408320600160ff1982541617905560008051602062001b42833981519152339380a4600190565b505090565b6001600160a01b031660008181527fc191fc48a308d795605d8380942284aa535eb60ab59dded9d8c4eff77cf3c872602052604081205490919060008051602062001b828339815191529060ff16620002c357808352826020526040832082845260205260408320600160ff1982541617905560008051602062001b42833981519152339380a4600190565b6001600160a01b031660008181527f94449471841a7f40a7871d590913647b573afdadc8e3b552848558acac45c28a602052604081205490919060008051602062001ba28339815191529060ff16620002c357808352826020526040832082845260205260408320600160ff1982541617905560008051602062001b42833981519152339380a460019056fe6040608081526004908136101561001557600080fd5b600091823560e01c908162f714ce14610e1e57816301ffc9a714610dc8578163132c29b214610d8d5781631ee903b614610cd1578163248a9ca314610ca75781632e718ab714610c6c5781632f2ff15d14610c42578163339b551514610be357816336568abe14610b9d57816345daa27b14610b625781634a0bbabb14610b405781635c23ef6e14610a405781636e553f65146109da5781637adbf973146108e95781637dc0d1d0146108c057816383f10777146107a1578163847b39d71461077057816391d148541461072a578163a217fddf1461070f578163a4e2a31e146105df578163c4e2c1e61461059c578163cf07456f146104dd578163d4c3eea014610318578163d547741f146102d9578163e00cb4a5146101b157508063f3bddde1146101935763fa6bd2ee1461014b57600080fd5b3461018f57602036600319011261018f576020906101866001600160a01b03610172610e72565b166000526004602052604060002054151590565b90519015158152f35b5080fd5b503461018f578160031936011261018f576020906002549051908152f35b919050346102d557806003193601126102d5576101cc610e57565b600154825163b3596f0760e01b81526001600160a01b039283168186018190526020959391929091869184916024918391165afa9182156102955783918691889461029f575b50855163313ce56760e01b815294859182905afa928315610295576102559495969361025c575b5061024f91610249913590610f16565b91610eef565b90610f29565b9051908152f35b6102499193509161028561024f93883d8a1161028e575b61027d8183610e9e565b810190610ed6565b93915091610239565b503d610273565b84513d88823e3d90fd5b9250925081813d83116102ce575b6102b78183610e9e565b810103126102ca57848391519238610212565b8580fd5b503d6102ad565b8280fd5b919050346102d557806003193601126102d557610314913561030f60016102fe610e57565b938387528660205286200154611278565b6113c7565b5080f35b919050346102d557826003193601126102d557600380546001805490959485936001600160a01b03928316928592915b858710610359576020898951908152f35b9091929394959781855282897fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b01541688519063b3596f0760e01b825280868301526020602492818185818d5afa9081156104d35789916104a6575b508b5163313ce56760e01b81529282848a81845afa93841561047957908d86928c96610483575b50516370a0823160e01b8152308b82015291849183919082905afa928315610479578a93610441575b5050610249610418939261024f92610f16565b82018092116104305750978901959493929190610348565b634e487b7160e01b86526011855285fd5b9080929350813d8311610472575b6104598183610e9e565b8101031261046e57519061024961024f610405565b8880fd5b503d61044f565b8d513d8c823e3d90fd5b859291965061049e90833d851161028e5761027d8183610e9e565b9590916103dc565b90508181813d83116104cc575b6104bd8183610e9e565b8101031261046e5751386103b5565b503d6104b3565b8c513d8b823e3d90fd5b8284346105995780600319360112610599579080519182906003549182855260208095018093600384527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90845b8181106105855750505081610541910382610e9e565b83519485948186019282875251809352850193925b82811061056557505050500390f35b83516001600160a01b031685528695509381019392810192600101610556565b82548452928801926001928301920161052b565b80fd5b8334610599576060366003190112610599576105dc6105b9610e72565b6105c1610e88565b906105ca61110c565b602435916001600160a01b0316611377565b80f35b9050346102d55760203660031901126102d5576105fa610e72565b91610603611186565b6001600160a01b039283166000818152600460205260409020549093906106f95760206024916001541683519283809263b3596f0760e01b825288888301525afa9081156106ef5785916106b9575b50156106a4576106618361165d565b1561068f5750507f500f8acd525a3d9f96ab641587f59e34ef9d02f9397fdd46bb7786273bad16078280a280f35b91602492519163cdb5999560e01b8352820152fd5b916024925191631066c96360e31b8352820152fd5b90506020813d6020116106e7575b816106d460209383610e9e565b810103126106e3575138610652565b8480fd5b3d91506106c7565b82513d87823e3d90fd5b5091602492519163098f893f60e21b8352820152fd5b50503461018f578160031936011261018f5751908152602090f35b9050346102d557816003193601126102d5578160209360ff9261074b610e57565b903582528186528282206001600160a01b039091168252855220549151911615158152f35b8284346105995760603660031901126105995750610255602092610792610e57565b61079a610e88565b9135610f49565b8391503461018f57608036600319011261018f578035926107c0610e57565b906107c9610e88565b91606435936107d66111e2565b6107e1848389610f49565b948086106108a357506107f26111e2565b60018060a01b039283851694610815866000526004602052604060002054151590565b156108675761082590848a610f49565b9081871161084b5750505094610844916105dc9596309133911661131c565b3390611377565b516394d08ba760e01b8152918201869052602482015260449150fd5b815162461bcd60e51b81526020818501526016602482015275155b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b6044820152606490fd5b83516330ff745960e11b8152918201869052602482015260449150fd5b50503461018f578160031936011261018f5760015490516001600160a01b039091168152602090f35b9050346102d55760203660031901126102d55780356001600160a01b03811692908390036109d65761091961123e565b8051638c89b64f60e01b8152906020828481875afa9182156109cc578592610998575b50600254809203610983575050600180546001600160a01b03191683179055507f3f32684a32a11dabdbb8c0177de80aa3ae36a004d75210335b49e544e48cd0aa8280a280f35b51639b6812b960e01b81529182015260249150fd5b9091506020813d6020116109c4575b816109b460209383610e9e565b810103126106e35751903861093c565b3d91506109a7565b81513d87823e3d90fd5b8380fd5b83833461018f578060031936011261018f576001600160a01b036109fc610e57565b1690610a15826000526004602052604060002054151590565b15610a2b57506105dc919235903090339061131c565b51632762993f60e11b81529283015250602490fd5b9050346102d557816003193601126102d557610a5a610e57565b9060018060a01b03938460015416845195869463b3596f0760e01b86521690818486015284602460209889935afa938415610b36579086918395610b05575b50855163313ce56760e01b815291908290859082905afa918215610afa57610ad892610255959492610ad19291610add575b50610eef565b9035610f16565b610f29565b610af49150883d8a1161028e5761027d8183610e9e565b38610acb565b8551903d90823e3d90fd5b8281939296503d8311610b2f575b610b1d8183610e9e565b8101031261018f575192859083610a99565b503d610b13565b85513d84823e3d90fd5b83903461018f57602036600319011261018f57610b5b61123e565b3560025580f35b50503461018f578160031936011261018f57602090517f1f29e81ed8f7ae439f042f6b6767d105e87c4eef908508d5d9e550aef35af6448152f35b83833461018f578060031936011261018f57610bb7610e57565b90336001600160a01b03831603610bd457506103149192356113c7565b5163334bd91960e11b81528390fd5b83833461018f57608036600319011261018f57823592610c01610e57565b604435926001600160a01b036064358181169491939290858103610c3e57610c276111e2565b610815866000526004602052604060002054151590565b8780fd5b919050346102d557806003193601126102d5576103149135610c6760016102fe610e57565b61129e565b50503461018f578160031936011261018f57602090517f85e8f2d6819d6b24108062d87ea08f54651bcb8960d98062d3faf96e7873b8b98152f35b9050346102d55760203660031901126102d557816020936001923581528085522001549051908152f35b9050346102d55760203660031901126102d557610cec610e72565b610cf4611186565b6001600160a01b031660008181526004602052604090205490929015610d785760016003541115610d6b57610d2883611489565b15610d565750507fcebbf63022189259f517d89d98c7c527b44c211d25e443dad13aab2479c7e7b38280a280f35b91602492519163644e3dd760e11b8352820152fd5b516305bc742560e11b8152fd5b916024925191632108722b60e01b8352820152fd5b50503461018f578160031936011261018f57602090517f1a52e20da533a06a1f80a73dba6e5d09cb788f108eae685b8ce6644834e67abe8152f35b9050346102d55760203660031901126102d557359063ffffffff60e01b82168092036102d55760209250637965db0b60e01b8214918215610e0d575b50519015158152f35b6301ffc9a760e01b14915038610e04565b919050346102d55736600319011261018f576105dc90610e3c610e57565b90610e4561110c565b359033906001600160a01b0316611377565b602435906001600160a01b0382168203610e6d57565b600080fd5b600435906001600160a01b0382168203610e6d57565b604435906001600160a01b0382168203610e6d57565b90601f8019910116810190811067ffffffffffffffff821117610ec057604052565b634e487b7160e01b600052604160045260246000fd5b90816020910312610e6d575160ff81168103610e6d5790565b60ff16604d8111610f0057600a0a90565b634e487b7160e01b600052601160045260246000fd5b81810292918115918404141715610f0057565b8115610f33570490565b634e487b7160e01b600052601260045260246000fd5b6001546040805163b3596f0760e01b8082526001600160a01b03958616600483018190529596929594939192918716916020918285602481875afa948515611101576000956110cf575b50906024839289519a8b938492835216958660048301525afa9687156110c457600097611095575b50855194818660048163313ce56760e01b948582525afa95861561108a57600096611069575b508190600488518095819382525afa95861561105f57509161102996959391610ad8959360009561102c575b50509161024f6102496102499361102395610f16565b90610f16565b90565b611023949295506102499361105461024f938361024994903d1061028e5761027d8183610e9e565b96939550935061100d565b513d6000823e3d90fd5b8291965061108390823d841161028e5761027d8183610e9e565b9590610fe1565b87513d6000823e3d90fd5b9080975081813d83116110bd575b6110ad8183610e9e565b81010312610e6d57519538610fbb565b503d6110a3565b86513d6000823e3d90fd5b919094508282813d83116110fa575b6110e88183610e9e565b81010312610e6d579051936024610f93565b503d6110de565b88513d6000823e3d90fd5b3360009081527fc191fc48a308d795605d8380942284aa535eb60ab59dded9d8c4eff77cf3c87260205260409020547f1f29e81ed8f7ae439f042f6b6767d105e87c4eef908508d5d9e550aef35af6449060ff16156111685750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081527fb56095460044281636dd3a77e227972b73971c7d766b38feb76e4e7f12e8c60260205260409020547f85e8f2d6819d6b24108062d87ea08f54651bcb8960d98062d3faf96e7873b8b99060ff16156111685750565b3360009081527f94449471841a7f40a7871d590913647b573afdadc8e3b552848558acac45c28a60205260409020547f1a52e20da533a06a1f80a73dba6e5d09cb788f108eae685b8ce6644834e67abe9060ff16156111685750565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff16156111685750565b80600052600060205260406000203360005260205260ff60406000205416156111685750565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054161560001461131757808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648083019390935291815260a081019181831067ffffffffffffffff841117610ec05761137592604052611589565b565b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152608081019167ffffffffffffffff831182841017610ec05761137592604052611589565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054166000146113175780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b6003548110156114735760036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b634e487b7160e01b600052603260045260246000fd5b6000908082526004908160205260408320548015156000146115835760001990808201818111611570576003549083820191821161155d57818103611513575b5050506003548015611500578101906114e18261143c565b909182549160031b1b1916905560035582526020526040812055600190565b634e487b7160e01b855260318452602485fd5b6115486115226115319361143c565b90549060031b1c92839261143c565b819391549060031b91821b91600019901b19161790565b905585528360205260408520553880806114c9565b634e487b7160e01b875260118652602487fd5b634e487b7160e01b865260118552602486fd5b50505090565b60018060a01b031690600080826020829451910182865af13d15611651573d9067ffffffffffffffff821161163d57906115e591604051916115d56020601f19601f8401160184610e9e565b82523d84602084013e5b846116c8565b908151918215159283611615575b5050506115fd5750565b60249060405190635274afe760e01b82526004820152fd5b81929350906020918101031261018f57602001519081159182150361059957503880806115f3565b634e487b7160e01b83526041600452602483fd5b6115e5906060906115df565b6000818152600460205260408120546116c357600354680100000000000000008110156116af57908261169b6115318460016040960160035561143c565b905560035492815260046020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b906116ef57508051156116dd57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580611722575b611700575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b156116f856fea264697066735822122078b5b2a606e69e7a541d57954e0f14c0d72ae3a9be5496d8c7ddbefa29b660a364736f6c634300081800332f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d85e8f2d6819d6b24108062d87ea08f54651bcb8960d98062d3faf96e7873b8b91f29e81ed8f7ae439f042f6b6767d105e87c4eef908508d5d9e550aef35af6441a52e20da533a06a1f80a73dba6e5d09cb788f108eae685b8ce6644834e67abe000000000000000000000000fa7560956807d95dcef22990ddd92e38dbaf5cdd
Deployed Bytecode
0x6040608081526004908136101561001557600080fd5b600091823560e01c908162f714ce14610e1e57816301ffc9a714610dc8578163132c29b214610d8d5781631ee903b614610cd1578163248a9ca314610ca75781632e718ab714610c6c5781632f2ff15d14610c42578163339b551514610be357816336568abe14610b9d57816345daa27b14610b625781634a0bbabb14610b405781635c23ef6e14610a405781636e553f65146109da5781637adbf973146108e95781637dc0d1d0146108c057816383f10777146107a1578163847b39d71461077057816391d148541461072a578163a217fddf1461070f578163a4e2a31e146105df578163c4e2c1e61461059c578163cf07456f146104dd578163d4c3eea014610318578163d547741f146102d9578163e00cb4a5146101b157508063f3bddde1146101935763fa6bd2ee1461014b57600080fd5b3461018f57602036600319011261018f576020906101866001600160a01b03610172610e72565b166000526004602052604060002054151590565b90519015158152f35b5080fd5b503461018f578160031936011261018f576020906002549051908152f35b919050346102d557806003193601126102d5576101cc610e57565b600154825163b3596f0760e01b81526001600160a01b039283168186018190526020959391929091869184916024918391165afa9182156102955783918691889461029f575b50855163313ce56760e01b815294859182905afa928315610295576102559495969361025c575b5061024f91610249913590610f16565b91610eef565b90610f29565b9051908152f35b6102499193509161028561024f93883d8a1161028e575b61027d8183610e9e565b810190610ed6565b93915091610239565b503d610273565b84513d88823e3d90fd5b9250925081813d83116102ce575b6102b78183610e9e565b810103126102ca57848391519238610212565b8580fd5b503d6102ad565b8280fd5b919050346102d557806003193601126102d557610314913561030f60016102fe610e57565b938387528660205286200154611278565b6113c7565b5080f35b919050346102d557826003193601126102d557600380546001805490959485936001600160a01b03928316928592915b858710610359576020898951908152f35b9091929394959781855282897fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b01541688519063b3596f0760e01b825280868301526020602492818185818d5afa9081156104d35789916104a6575b508b5163313ce56760e01b81529282848a81845afa93841561047957908d86928c96610483575b50516370a0823160e01b8152308b82015291849183919082905afa928315610479578a93610441575b5050610249610418939261024f92610f16565b82018092116104305750978901959493929190610348565b634e487b7160e01b86526011855285fd5b9080929350813d8311610472575b6104598183610e9e565b8101031261046e57519061024961024f610405565b8880fd5b503d61044f565b8d513d8c823e3d90fd5b859291965061049e90833d851161028e5761027d8183610e9e565b9590916103dc565b90508181813d83116104cc575b6104bd8183610e9e565b8101031261046e5751386103b5565b503d6104b3565b8c513d8b823e3d90fd5b8284346105995780600319360112610599579080519182906003549182855260208095018093600384527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90845b8181106105855750505081610541910382610e9e565b83519485948186019282875251809352850193925b82811061056557505050500390f35b83516001600160a01b031685528695509381019392810192600101610556565b82548452928801926001928301920161052b565b80fd5b8334610599576060366003190112610599576105dc6105b9610e72565b6105c1610e88565b906105ca61110c565b602435916001600160a01b0316611377565b80f35b9050346102d55760203660031901126102d5576105fa610e72565b91610603611186565b6001600160a01b039283166000818152600460205260409020549093906106f95760206024916001541683519283809263b3596f0760e01b825288888301525afa9081156106ef5785916106b9575b50156106a4576106618361165d565b1561068f5750507f500f8acd525a3d9f96ab641587f59e34ef9d02f9397fdd46bb7786273bad16078280a280f35b91602492519163cdb5999560e01b8352820152fd5b916024925191631066c96360e31b8352820152fd5b90506020813d6020116106e7575b816106d460209383610e9e565b810103126106e3575138610652565b8480fd5b3d91506106c7565b82513d87823e3d90fd5b5091602492519163098f893f60e21b8352820152fd5b50503461018f578160031936011261018f5751908152602090f35b9050346102d557816003193601126102d5578160209360ff9261074b610e57565b903582528186528282206001600160a01b039091168252855220549151911615158152f35b8284346105995760603660031901126105995750610255602092610792610e57565b61079a610e88565b9135610f49565b8391503461018f57608036600319011261018f578035926107c0610e57565b906107c9610e88565b91606435936107d66111e2565b6107e1848389610f49565b948086106108a357506107f26111e2565b60018060a01b039283851694610815866000526004602052604060002054151590565b156108675761082590848a610f49565b9081871161084b5750505094610844916105dc9596309133911661131c565b3390611377565b516394d08ba760e01b8152918201869052602482015260449150fd5b815162461bcd60e51b81526020818501526016602482015275155b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b6044820152606490fd5b83516330ff745960e11b8152918201869052602482015260449150fd5b50503461018f578160031936011261018f5760015490516001600160a01b039091168152602090f35b9050346102d55760203660031901126102d55780356001600160a01b03811692908390036109d65761091961123e565b8051638c89b64f60e01b8152906020828481875afa9182156109cc578592610998575b50600254809203610983575050600180546001600160a01b03191683179055507f3f32684a32a11dabdbb8c0177de80aa3ae36a004d75210335b49e544e48cd0aa8280a280f35b51639b6812b960e01b81529182015260249150fd5b9091506020813d6020116109c4575b816109b460209383610e9e565b810103126106e35751903861093c565b3d91506109a7565b81513d87823e3d90fd5b8380fd5b83833461018f578060031936011261018f576001600160a01b036109fc610e57565b1690610a15826000526004602052604060002054151590565b15610a2b57506105dc919235903090339061131c565b51632762993f60e11b81529283015250602490fd5b9050346102d557816003193601126102d557610a5a610e57565b9060018060a01b03938460015416845195869463b3596f0760e01b86521690818486015284602460209889935afa938415610b36579086918395610b05575b50855163313ce56760e01b815291908290859082905afa918215610afa57610ad892610255959492610ad19291610add575b50610eef565b9035610f16565b610f29565b610af49150883d8a1161028e5761027d8183610e9e565b38610acb565b8551903d90823e3d90fd5b8281939296503d8311610b2f575b610b1d8183610e9e565b8101031261018f575192859083610a99565b503d610b13565b85513d84823e3d90fd5b83903461018f57602036600319011261018f57610b5b61123e565b3560025580f35b50503461018f578160031936011261018f57602090517f1f29e81ed8f7ae439f042f6b6767d105e87c4eef908508d5d9e550aef35af6448152f35b83833461018f578060031936011261018f57610bb7610e57565b90336001600160a01b03831603610bd457506103149192356113c7565b5163334bd91960e11b81528390fd5b83833461018f57608036600319011261018f57823592610c01610e57565b604435926001600160a01b036064358181169491939290858103610c3e57610c276111e2565b610815866000526004602052604060002054151590565b8780fd5b919050346102d557806003193601126102d5576103149135610c6760016102fe610e57565b61129e565b50503461018f578160031936011261018f57602090517f85e8f2d6819d6b24108062d87ea08f54651bcb8960d98062d3faf96e7873b8b98152f35b9050346102d55760203660031901126102d557816020936001923581528085522001549051908152f35b9050346102d55760203660031901126102d557610cec610e72565b610cf4611186565b6001600160a01b031660008181526004602052604090205490929015610d785760016003541115610d6b57610d2883611489565b15610d565750507fcebbf63022189259f517d89d98c7c527b44c211d25e443dad13aab2479c7e7b38280a280f35b91602492519163644e3dd760e11b8352820152fd5b516305bc742560e11b8152fd5b916024925191632108722b60e01b8352820152fd5b50503461018f578160031936011261018f57602090517f1a52e20da533a06a1f80a73dba6e5d09cb788f108eae685b8ce6644834e67abe8152f35b9050346102d55760203660031901126102d557359063ffffffff60e01b82168092036102d55760209250637965db0b60e01b8214918215610e0d575b50519015158152f35b6301ffc9a760e01b14915038610e04565b919050346102d55736600319011261018f576105dc90610e3c610e57565b90610e4561110c565b359033906001600160a01b0316611377565b602435906001600160a01b0382168203610e6d57565b600080fd5b600435906001600160a01b0382168203610e6d57565b604435906001600160a01b0382168203610e6d57565b90601f8019910116810190811067ffffffffffffffff821117610ec057604052565b634e487b7160e01b600052604160045260246000fd5b90816020910312610e6d575160ff81168103610e6d5790565b60ff16604d8111610f0057600a0a90565b634e487b7160e01b600052601160045260246000fd5b81810292918115918404141715610f0057565b8115610f33570490565b634e487b7160e01b600052601260045260246000fd5b6001546040805163b3596f0760e01b8082526001600160a01b03958616600483018190529596929594939192918716916020918285602481875afa948515611101576000956110cf575b50906024839289519a8b938492835216958660048301525afa9687156110c457600097611095575b50855194818660048163313ce56760e01b948582525afa95861561108a57600096611069575b508190600488518095819382525afa95861561105f57509161102996959391610ad8959360009561102c575b50509161024f6102496102499361102395610f16565b90610f16565b90565b611023949295506102499361105461024f938361024994903d1061028e5761027d8183610e9e565b96939550935061100d565b513d6000823e3d90fd5b8291965061108390823d841161028e5761027d8183610e9e565b9590610fe1565b87513d6000823e3d90fd5b9080975081813d83116110bd575b6110ad8183610e9e565b81010312610e6d57519538610fbb565b503d6110a3565b86513d6000823e3d90fd5b919094508282813d83116110fa575b6110e88183610e9e565b81010312610e6d579051936024610f93565b503d6110de565b88513d6000823e3d90fd5b3360009081527fc191fc48a308d795605d8380942284aa535eb60ab59dded9d8c4eff77cf3c87260205260409020547f1f29e81ed8f7ae439f042f6b6767d105e87c4eef908508d5d9e550aef35af6449060ff16156111685750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b3360009081527fb56095460044281636dd3a77e227972b73971c7d766b38feb76e4e7f12e8c60260205260409020547f85e8f2d6819d6b24108062d87ea08f54651bcb8960d98062d3faf96e7873b8b99060ff16156111685750565b3360009081527f94449471841a7f40a7871d590913647b573afdadc8e3b552848558acac45c28a60205260409020547f1a52e20da533a06a1f80a73dba6e5d09cb788f108eae685b8ce6644834e67abe9060ff16156111685750565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff16156111685750565b80600052600060205260406000203360005260205260ff60406000205416156111685750565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054161560001461131757808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648083019390935291815260a081019181831067ffffffffffffffff841117610ec05761137592604052611589565b565b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152608081019167ffffffffffffffff831182841017610ec05761137592604052611589565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054166000146113175780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b6003548110156114735760036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b634e487b7160e01b600052603260045260246000fd5b6000908082526004908160205260408320548015156000146115835760001990808201818111611570576003549083820191821161155d57818103611513575b5050506003548015611500578101906114e18261143c565b909182549160031b1b1916905560035582526020526040812055600190565b634e487b7160e01b855260318452602485fd5b6115486115226115319361143c565b90549060031b1c92839261143c565b819391549060031b91821b91600019901b19161790565b905585528360205260408520553880806114c9565b634e487b7160e01b875260118652602487fd5b634e487b7160e01b865260118552602486fd5b50505090565b60018060a01b031690600080826020829451910182865af13d15611651573d9067ffffffffffffffff821161163d57906115e591604051916115d56020601f19601f8401160184610e9e565b82523d84602084013e5b846116c8565b908151918215159283611615575b5050506115fd5750565b60249060405190635274afe760e01b82526004820152fd5b81929350906020918101031261018f57602001519081159182150361059957503880806115f3565b634e487b7160e01b83526041600452602483fd5b6115e5906060906115df565b6000818152600460205260408120546116c357600354680100000000000000008110156116af57908261169b6115318460016040960160035561143c565b905560035492815260046020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b906116ef57508051156116dd57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580611722575b611700575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b156116f856fea264697066735822122078b5b2a606e69e7a541d57954e0f14c0d72ae3a9be5496d8c7ddbefa29b660a364736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000fa7560956807d95dcef22990ddd92e38dbaf5cdd
-----Decoded View---------------
Arg [0] : oracle (address): 0xFA7560956807d95DCeF22990DdD92e38DbAf5cDd
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000fa7560956807d95dcef22990ddd92e38dbaf5cdd
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
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.