Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
FxUSD
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity =0.8.20;
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable-v4/access/AccessControlUpgradeable.sol";
import { ERC20PermitUpgradeable } from "@openzeppelin/contracts-upgradeable-v4/token/ERC20/extensions/ERC20PermitUpgradeable.sol";
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol";
import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol";
import { EnumerableSetUpgradeable } from "@openzeppelin/contracts-upgradeable-v4/utils/structs/EnumerableSetUpgradeable.sol";
import { IFxFractionalTokenV2 } from "../../interfaces/f(x)/IFxFractionalTokenV2.sol";
import { IFxMarketV2 } from "../../interfaces/f(x)/IFxMarketV2.sol";
import { IFxTreasuryV2 } from "../../interfaces/f(x)/IFxTreasuryV2.sol";
import { IFxUSD } from "../../interfaces/f(x)/IFxUSD.sol";
import { IFxShareableRebalancePool } from "../../interfaces/f(x)/IFxShareableRebalancePool.sol";
contract FxUSD is AccessControlUpgradeable, ERC20PermitUpgradeable, IFxUSD {
using SafeERC20Upgradeable for IERC20Upgradeable;
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
/*************
* Constants *
*************/
/// @dev The precision used to compute nav.
uint256 private constant PRECISION = 1e18;
/***********
* Structs *
***********/
/// @param fToken The address of Fractional Token.
/// @param treasury The address of treasury contract.
/// @param market The address of market contract.
/// @param mintCap The maximum amount of fToken can be minted.
/// @param managed The amount of fToken managed in this contract.
struct FxMarketStruct {
address fToken;
address treasury;
address market;
uint256 mintCap;
uint256 managed;
}
/*************
* Variables *
*************/
/// @notice Mapping from base token address to metadata.
mapping(address => FxMarketStruct) public markets;
/// @dev The list of supported base tokens.
EnumerableSetUpgradeable.AddressSet private supportedTokens;
/// @dev The list of supported rebalance pools.
EnumerableSetUpgradeable.AddressSet private supportedPools;
/*************
* Modifiers *
*************/
modifier onlySupportedMarket(address _baseToken) {
_checkBaseToken(_baseToken);
_;
}
modifier onlySupportedPool(address _pool) {
if (!supportedPools.contains(_pool)) revert ErrorUnsupportedRebalancePool();
_;
}
modifier onlyMintableMarket(address _baseToken, bool isMint) {
_checkMarketMintable(_baseToken, isMint);
_;
}
/***************
* Constructor *
***************/
function initialize(string memory _name, string memory _symbol) external initializer {
__Context_init();
__ERC165_init();
__AccessControl_init();
__ERC20_init(_name, _symbol);
__ERC20Permit_init(_name);
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
/*************************
* Public View Functions *
*************************/
/// @inheritdoc IFxUSD
function getMarkets() external view override returns (address[] memory _tokens) {
uint256 _numMarkets = supportedTokens.length();
_tokens = new address[](_numMarkets);
for (uint256 i = 0; i < _numMarkets; ++i) {
_tokens[i] = supportedTokens.at(i);
}
}
/// @inheritdoc IFxUSD
function getRebalancePools() external view override returns (address[] memory _pools) {
uint256 _numPools = supportedPools.length();
_pools = new address[](_numPools);
for (uint256 i = 0; i < _numPools; ++i) {
_pools[i] = supportedPools.at(i);
}
}
/// @inheritdoc IFxUSD
function nav() external view override returns (uint256 _nav) {
uint256 _numMarkets = supportedTokens.length();
uint256 _supply = totalSupply();
if (_supply == 0) return PRECISION;
for (uint256 i = 0; i < _numMarkets; i++) {
address _baseToken = supportedTokens.at(i);
address _fToken = markets[_baseToken].fToken;
uint256 _fnav = IFxFractionalTokenV2(_fToken).nav();
_nav += _fnav * markets[_baseToken].managed;
}
_nav /= _supply;
}
/// @inheritdoc IFxUSD
function isUnderCollateral() public view override returns (bool) {
uint256 _numMarkets = supportedTokens.length();
for (uint256 i = 0; i < _numMarkets; i++) {
address _baseToken = supportedTokens.at(i);
address _treasury = markets[_baseToken].treasury;
if (IFxTreasuryV2(_treasury).isUnderCollateral()) return true;
}
return false;
}
/****************************
* Public Mutated Functions *
****************************/
/// @inheritdoc IFxUSD
function wrap(
address _baseToken,
uint256 _amount,
address _receiver
) external override onlySupportedMarket(_baseToken) onlyMintableMarket(_baseToken, false) {
if (isUnderCollateral()) revert ErrorUnderCollateral();
address _fToken = markets[_baseToken].fToken;
IERC20Upgradeable(_fToken).safeTransferFrom(_msgSender(), address(this), _amount);
_mintShares(_baseToken, _receiver, _amount);
emit Wrap(_baseToken, _msgSender(), _receiver, _amount);
}
/// @inheritdoc IFxUSD
function wrapFrom(
address _pool,
uint256 _amount,
address _receiver
) external override onlySupportedPool(_pool) {
if (isUnderCollateral()) revert ErrorUnderCollateral();
address _baseToken = IFxShareableRebalancePool(_pool).baseToken();
_checkBaseToken(_baseToken);
_checkMarketMintable(_baseToken, false);
IFxShareableRebalancePool(_pool).withdrawFrom(_msgSender(), _amount, address(this));
_mintShares(_baseToken, _receiver, _amount);
emit Wrap(_baseToken, _msgSender(), _receiver, _amount);
}
/// @inheritdoc IFxUSD
function mint(
address _baseToken,
uint256 _amountIn,
address _receiver,
uint256 _minOut
)
external
override
onlySupportedMarket(_baseToken)
onlyMintableMarket(_baseToken, true)
returns (uint256 _amountOut)
{
if (isUnderCollateral()) revert ErrorUnderCollateral();
address _fToken = markets[_baseToken].fToken;
_amountOut = _mintFToken(_baseToken, _fToken, _amountIn, _minOut);
_mintShares(_baseToken, _receiver, _amountOut);
emit Wrap(_baseToken, _msgSender(), _receiver, _amountOut);
}
/// @inheritdoc IFxUSD
function earn(
address _pool,
uint256 _amount,
address _receiver
) external override onlySupportedPool(_pool) {
if (isUnderCollateral()) revert ErrorUnderCollateral();
address _baseToken = IFxShareableRebalancePool(_pool).baseToken();
_checkBaseToken(_baseToken);
_burnShares(_baseToken, _msgSender(), _amount);
emit Unwrap(_baseToken, _msgSender(), _receiver, _amount);
_deposit(markets[_baseToken].fToken, _pool, _receiver, _amount);
}
/// @inheritdoc IFxUSD
function mintAndEarn(
address _pool,
uint256 _amountIn,
address _receiver,
uint256 _minOut
) external override onlySupportedPool(_pool) returns (uint256 _amountOut) {
if (isUnderCollateral()) revert ErrorUnderCollateral();
address _baseToken = IFxShareableRebalancePool(_pool).baseToken();
_checkBaseToken(_baseToken);
_checkMarketMintable(_baseToken, true);
address _fToken = markets[_baseToken].fToken;
_amountOut = _mintFToken(_baseToken, _fToken, _amountIn, _minOut);
_deposit(_fToken, _pool, _receiver, _amountOut);
}
/// @inheritdoc IFxUSD
function redeem(
address _baseToken,
uint256 _amountIn,
address _receiver,
uint256 _minOut
) external override onlySupportedMarket(_baseToken) returns (uint256 _amountOut, uint256 _bonusOut) {
if (isUnderCollateral()) revert ErrorUnderCollateral();
address _market = markets[_baseToken].market;
address _fToken = markets[_baseToken].fToken;
uint256 _balance = IERC20Upgradeable(_fToken).balanceOf(address(this));
(_amountOut, _bonusOut) = IFxMarketV2(_market).redeemFToken(_amountIn, _receiver, _minOut);
// the real amount of fToken redeemed
_amountIn = _balance - IERC20Upgradeable(_fToken).balanceOf(address(this));
_burnShares(_baseToken, _msgSender(), _amountIn);
emit Unwrap(_baseToken, _msgSender(), _receiver, _amountIn);
}
/// @inheritdoc IFxUSD
function redeemFrom(
address _pool,
uint256 _amountIn,
address _receiver,
uint256 _minOut
) external override onlySupportedPool(_pool) returns (uint256 _amountOut, uint256 _bonusOut) {
address _baseToken = IFxShareableRebalancePool(_pool).baseToken();
address _market = markets[_baseToken].market;
address _fToken = markets[_baseToken].fToken;
// calculate the actual amount of fToken withdrawn from rebalance pool.
_amountOut = IERC20Upgradeable(_fToken).balanceOf(address(this));
IFxShareableRebalancePool(_pool).withdrawFrom(_msgSender(), _amountIn, address(this));
_amountOut = IERC20Upgradeable(_fToken).balanceOf(address(this)) - _amountOut;
// redeem fToken as base token
// assume all fToken will be redeem for simplicity
(_amountOut, _bonusOut) = IFxMarketV2(_market).redeemFToken(_amountOut, _receiver, _minOut);
}
/// @inheritdoc IFxUSD
function autoRedeem(
uint256 _amountIn,
address _receiver,
uint256[] memory _minOuts
)
external
override
returns (
address[] memory _baseTokens,
uint256[] memory _amountOuts,
uint256[] memory _bonusOuts
)
{
uint256 _numMarkets = supportedTokens.length();
if (_minOuts.length != _numMarkets) revert ErrorLengthMismatch();
_baseTokens = new address[](_numMarkets);
_amountOuts = new uint256[](_numMarkets);
_bonusOuts = new uint256[](_numMarkets);
uint256[] memory _supplies = new uint256[](_numMarkets);
bool _isUnderCollateral = false;
for (uint256 i = 0; i < _numMarkets; i++) {
_baseTokens[i] = supportedTokens.at(i);
_supplies[i] = markets[_baseTokens[i]].managed;
address _treasury = markets[_baseTokens[i]].treasury;
if (IFxTreasuryV2(_treasury).isUnderCollateral()) _isUnderCollateral = true;
}
uint256 _supply = totalSupply();
_burn(_msgSender(), _amountIn);
if (_isUnderCollateral) {
// redeem proportionally
for (uint256 i = 0; i < _numMarkets; i++) {
_amountOuts[i] = (_supplies[i] * _amountIn) / _supply;
}
} else {
// redeem by sorted fToken amounts
while (_amountIn > 0) {
unchecked {
uint256 maxSupply = _supplies[0];
uint256 maxIndex = 0;
for (uint256 i = 1; i < _numMarkets; i++) {
if (_supplies[i] > maxSupply) {
maxSupply = _supplies[i];
maxIndex = i;
}
}
if (_amountIn > maxSupply) _amountOuts[maxIndex] = maxSupply;
else _amountOuts[maxIndex] = _amountIn;
_supplies[maxIndex] -= _amountOuts[maxIndex];
_amountIn -= _amountOuts[maxIndex];
}
}
}
for (uint256 i = 0; i < _numMarkets; i++) {
if (_amountOuts[i] == 0) continue;
emit Unwrap(_baseTokens[i], _msgSender(), _receiver, _amountOuts[i]);
markets[_baseTokens[i]].managed -= _amountOuts[i];
address _market = markets[_baseTokens[i]].market;
(_amountOuts[i], _bonusOuts[i]) = IFxMarketV2(_market).redeemFToken(_amountOuts[i], _receiver, _minOuts[i]);
}
}
/************************
* Restricted Functions *
************************/
/// @notice Update the mint capacity of the base token.
/// @param _baseToken The address of base token of the market.
/// @param _newCap The value of current mint capacity.
function updateMintCap(address _baseToken, uint256 _newCap) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (!supportedTokens.contains(_baseToken)) revert ErrorUnsupportedMarket();
uint256 _oldCap = markets[_baseToken].mintCap;
markets[_baseToken].mintCap = _newCap;
emit UpdateMintCap(_baseToken, _oldCap, _newCap);
}
/// @notice Add a new market to fxUSD.
/// @param _market The address of market contract.
/// @param _mintCap The mint capacity of the market.
function addMarket(address _market, uint256 _mintCap) external onlyRole(DEFAULT_ADMIN_ROLE) {
address _baseToken = IFxMarketV2(_market).baseToken();
address _treasury = IFxMarketV2(_market).treasury();
address _fToken = IFxMarketV2(_market).fToken();
if (supportedTokens.contains(_baseToken)) revert ErrorMarketAlreadySupported();
supportedTokens.add(_baseToken);
markets[_baseToken] = FxMarketStruct(_fToken, _treasury, _market, _mintCap, 0);
IERC20Upgradeable(_baseToken).safeApprove(_market, type(uint256).max);
emit AddMarket(_baseToken, _mintCap);
}
/// @notice Add new supported rebalance pools to fxUSD.
/// @param _pools The list of rebalance pools.
function addRebalancePools(address[] memory _pools) external onlyRole(DEFAULT_ADMIN_ROLE) {
for (uint256 i = 0; i < _pools.length; ++i) {
address _baseToken = IFxShareableRebalancePool(_pools[i]).baseToken();
_checkBaseToken(_baseToken);
if (supportedPools.add(_pools[i])) {
emit AddRebalancePool(_baseToken, _pools[i]);
}
}
}
/// @notice Add new supported rebalance pools to fxUSD.
/// @param _pools The list of rebalance pools.
function removeRebalancePools(address[] memory _pools) external onlyRole(DEFAULT_ADMIN_ROLE) {
for (uint256 i = 0; i < _pools.length; ++i) {
address _baseToken = IFxShareableRebalancePool(_pools[i]).baseToken();
if (supportedPools.remove(_pools[i])) {
emit RemoveRebalancePool(_baseToken, _pools[i]);
}
}
}
/**********************
* Internal Functions *
**********************/
/// @dev Internal function to check base token.
/// @param _baseToken The address of the base token.
function _checkBaseToken(address _baseToken) private view {
if (!supportedTokens.contains(_baseToken)) revert ErrorUnsupportedMarket();
}
/// @dev Internal function to check market.
/// @param _baseToken The address of the base token.
/// @param _checkCollateralRatio Whether to check collateral ratio.
function _checkMarketMintable(address _baseToken, bool _checkCollateralRatio) private view {
address _treasury = markets[_baseToken].treasury;
if (_checkCollateralRatio) {
uint256 _collateralRatio = IFxTreasuryV2(_treasury).collateralRatio();
uint256 _stabilityRatio = IFxMarketV2(markets[_baseToken].market).stabilityRatio();
// not allow to mint when collateral ratio <= stability ratio
if (_collateralRatio <= _stabilityRatio) revert ErrorMarketInStabilityMode();
}
// not allow to mint when price is invalid
if (!IFxTreasuryV2(_treasury).isBaseTokenPriceValid()) revert ErrorMarketWithInvalidPrice();
}
/// @dev Internal function to mint fToken.
/// @param _baseToken The address of the base token.
/// @param _fToken The address of the corresponding fToken.
/// @param _amountIn The amount of base token to use.
/// @param _minOut The minimum amount of fxUSD should receive.
/// @return _amountOut The amount of fxUSD received by the receiver.
function _mintFToken(
address _baseToken,
address _fToken,
uint256 _amountIn,
uint256 _minOut
) private returns (uint256 _amountOut) {
address _market = markets[_baseToken].market;
uint256 _mintCap = markets[_baseToken].mintCap;
IERC20Upgradeable(_baseToken).safeTransferFrom(_msgSender(), address(this), _amountIn);
uint256 _balance = IERC20Upgradeable(_baseToken).balanceOf(address(this));
// @note approved in `addMarket`.
_amountOut = IFxMarketV2(_market).mintFToken(_amountIn, address(this), _minOut);
if (IERC20Upgradeable(_fToken).totalSupply() > _mintCap) revert ErrorExceedMintCap();
// refund exceeding base token
uint256 _baseTokenUsed = _balance - IERC20Upgradeable(_baseToken).balanceOf(address(this));
if (_baseTokenUsed < _amountIn) {
unchecked {
IERC20Upgradeable(_baseToken).safeTransfer(_msgSender(), _amountIn - _baseTokenUsed);
}
}
}
/// @dev Internal function to mint fxUSD.
/// @param _baseToken The address of the base token.
/// @param _receiver The address of fxUSD recipient.
/// @param _amount The amount of fxUSD to mint.
function _mintShares(
address _baseToken,
address _receiver,
uint256 _amount
) private {
unchecked {
markets[_baseToken].managed += _amount;
}
_mint(_receiver, _amount);
}
/// @dev Internal function to burn fxUSD.
/// @param _baseToken The address of the base token.
/// @param _owner The address of fxUSD owner.
/// @param _amount The amount of fxUSD to burn.
function _burnShares(
address _baseToken,
address _owner,
uint256 _amount
) private {
uint256 _managed = markets[_baseToken].managed;
if (_amount > _managed) revert ErrorInsufficientLiquidity();
unchecked {
markets[_baseToken].managed -= _amount;
}
_burn(_owner, _amount);
}
/// @dev Internal function to deposit fToken to rebalance pool.
/// @param _fToken the address of fToken.
/// @param _pool The address of rebalance pool.
/// @param _receiver The address of rebalance pool share recipient.
/// @param _amount The amount of fToken to deposit.
function _deposit(
address _fToken,
address _pool,
address _receiver,
uint256 _amount
) internal {
IERC20Upgradeable(_fToken).safeApprove(_pool, 0);
IERC20Upgradeable(_fToken).safeApprove(_pool, _amount);
IFxShareableRebalancePool(_pool).deposit(_amount, _receiver);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(account),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @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 override 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 override 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 override 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 `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @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 Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @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.
*
* _Available since v3.1._
*/
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 `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.0;
interface IERC5267Upgradeable {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Permit.sol)
pragma solidity ^0.8.0;
import "./IERC20PermitUpgradeable.sol";
import "../ERC20Upgradeable.sol";
import "../../../utils/cryptography/ECDSAUpgradeable.sol";
import "../../../utils/cryptography/EIP712Upgradeable.sol";
import "../../../utils/CountersUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* @dev Implementation 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.
*
* _Available since v3.4._
*
* @custom:storage-size 51
*/
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {
using CountersUpgradeable for CountersUpgradeable.Counter;
mapping(address => CountersUpgradeable.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
function __ERC20Permit_init(string memory name) internal onlyInitializing {
__EIP712_init_unchained(name, "1");
}
function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSAUpgradeable.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
CountersUpgradeable.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @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 v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @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.
*/
interface IERC20PermitUpgradeable {
/**
* @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].
*/
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 v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
using AddressUpgradeable for address;
/**
* @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(IERC20Upgradeable token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, 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(IERC20Upgradeable token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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(IERC20Upgradeable token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @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(IERC20Upgradeable token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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(IERC20Upgradeable 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, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @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(IERC20Upgradeable 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))) && AddressUpgradeable.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @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 ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library CountersUpgradeable {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../StringsUpgradeable.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSAUpgradeable {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.8;
import "./ECDSAUpgradeable.sol";
import "../../interfaces/IERC5267Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*
* _Available since v3.4._
*
* @custom:storage-size 52
*/
abstract contract EIP712Upgradeable is Initializable, IERC5267Upgradeable {
bytes32 private constant _TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/// @custom:oz-renamed-from _HASHED_NAME
bytes32 private _hashedName;
/// @custom:oz-renamed-from _HASHED_VERSION
bytes32 private _hashedVersion;
string private _name;
string private _version;
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
_name = name;
_version = version;
// Reset prior values in storage if upgrading
_hashedName = 0;
_hashedVersion = 0;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator();
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {EIP-5267}.
*
* _Available since v4.9._
*/
function eip712Domain()
public
view
virtual
override
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
// If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
// and the EIP712 domain is not reliable, as it will be missing name and version.
require(_hashedName == 0 && _hashedVersion == 0, "EIP712: Uninitialized");
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Name() internal virtual view returns (string memory) {
return _name;
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Version() internal virtual view returns (string memory) {
return _version;
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
*/
function _EIP712NameHash() internal view returns (bytes32) {
string memory name = _EIP712Name();
if (bytes(name).length > 0) {
return keccak256(bytes(name));
} else {
// If the name is empty, the contract may have been upgraded without initializing the new storage.
// We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
bytes32 hashedName = _hashedName;
if (hashedName != 0) {
return hashedName;
} else {
return keccak256("");
}
}
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
*/
function _EIP712VersionHash() internal view returns (bytes32) {
string memory version = _EIP712Version();
if (bytes(version).length > 0) {
return keccak256(bytes(version));
} else {
// If the version is empty, the contract may have been upgraded without initializing the new storage.
// We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
bytes32 hashedVersion = _hashedVersion;
if (hashedVersion != 0) {
return hashedVersion;
} else {
return keccak256("");
}
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[48] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @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 IERC165Upgradeable {
/**
* @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 v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMathUpgradeable {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```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 EnumerableSetUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
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
pragma solidity ^0.8.0;
interface IFxBoostableRebalancePool {
/**********
* Events *
**********/
/// @notice Emitted when user deposit asset into this contract.
/// @param owner The address of asset owner.
/// @param reciever The address of receiver of the asset in this contract.
/// @param amount The amount of asset deposited.
event Deposit(address indexed owner, address indexed reciever, uint256 amount);
/// @notice Emitted when the amount of deposited asset changed due to liquidation or deposit or unlock.
/// @param owner The address of asset owner.
/// @param newDeposit The new amount of deposited asset.
/// @param loss The amount of asset used by liquidation.
event UserDepositChange(address indexed owner, uint256 newDeposit, uint256 loss);
/// @notice Emitted when user withdraw asset.
/// @param owner The address of asset owner.
/// @param reciever The address of receiver of the asset.
/// @param amount The amount of token to withdraw.
event Withdraw(address indexed owner, address indexed reciever, uint256 amount);
/// @notice Emitted when liquidation happens.
/// @param liquidated The amount of asset liquidated.
/// @param baseGained The amount of base token gained.
event Liquidate(uint256 liquidated, uint256 baseGained);
/// @notice Emitted when the address of reward wrapper is updated.
/// @param oldWrapper The address of previous reward wrapper.
/// @param newWrapper The address of current reward wrapper.
event UpdateWrapper(address indexed oldWrapper, address indexed newWrapper);
/// @notice Emitted when the liquidatable collateral ratio is updated.
/// @param oldRatio The previous liquidatable collateral ratio.
/// @param newRatio The current liquidatable collateral ratio.
event UpdateLiquidatableCollateralRatio(uint256 oldRatio, uint256 newRatio);
/**********
* Errors *
**********/
/// @dev Thrown then the src token mismatched.
error ErrorWrapperSrcMismatch();
/// @dev Thrown then the dst token mismatched.
error ErrorWrapperDstMismatch();
/// @dev Thrown when the deposited amount is zero.
error DepositZeroAmount();
/// @dev Thrown when the withdrawn amount is zero.
error WithdrawZeroAmount();
/// @dev Thrown the cannot liquidate.
error CannotLiquidate();
/*************************
* Public View Functions *
*************************/
/// @notice Return the address of treasury contract.
function treasury() external view returns (address);
/// @notice Return the address of market contract.
function market() external view returns (address);
/// @notice Return the address of base token.
function baseToken() external view returns (address);
/// @notice Return the address of underlying token of this contract.
function asset() external view returns (address);
/// @notice Return the total amount of asset deposited to this contract.
function totalSupply() external view returns (uint256);
/// @notice Return the amount of deposited asset for some specific user.
/// @param account The address of user to query.
function balanceOf(address account) external view returns (uint256);
/// @notice Return the current boost ratio for some specific user.
/// @param account The address of user to query, multiplied by 1e18.
function getBoostRatio(address account) external view returns (uint256);
/****************************
* Public Mutated Functions *
****************************/
/// @notice Deposit some asset to this contract.
/// @dev Use `amount=uint256(-1)` if you want to deposit all asset held.
/// @param amount The amount of asset to deposit.
/// @param receiver The address of recipient for the deposited asset.
function deposit(uint256 amount, address receiver) external;
/// @notice Withdraw asset from this contract.
function withdraw(uint256 amount, address receiver) external;
/// @notice Liquidate asset for base token.
/// @param maxAmount The maximum amount of asset to liquidate.
/// @param minBaseOut The minimum amount of base token should receive.
/// @return liquidated The amount of asset liquidated.
/// @return baseOut The amount of base token received.
function liquidate(uint256 maxAmount, uint256 minBaseOut) external returns (uint256 liquidated, uint256 baseOut);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFxFractionalTokenV2 {
/**********
* Errors *
**********/
/// @dev Thrown when caller is not treasury contract.
error ErrorCallerIsNotTreasury();
/*************************
* Public View Functions *
*************************/
/// @notice Return the net asset value for the token, multipled by 1e18.
function nav() external view returns (uint256);
/****************************
* Public Mutated Functions *
****************************/
/// @notice Mint some token to someone.
/// @param to The address of recipient.
/// @param amount The amount of token to mint.
function mint(address to, uint256 amount) external;
/// @notice Burn some token from someone.
/// @param from The address of owner to burn.
/// @param amount The amount of token to burn.
function burn(address from, uint256 amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFxMarketV2 {
/**********
* Events *
**********/
/// @notice Emitted when fToken is minted.
/// @param owner The address of base token owner.
/// @param recipient The address of receiver for fToken or xToken.
/// @param baseTokenIn The amount of base token deposited.
/// @param fTokenOut The amount of fToken minted.
/// @param mintFee The amount of mint fee charged.
event MintFToken(
address indexed owner,
address indexed recipient,
uint256 baseTokenIn,
uint256 fTokenOut,
uint256 mintFee
);
/// @notice Emitted when xToken is minted.
/// @param owner The address of base token owner.
/// @param recipient The address of receiver for fToken or xToken.
/// @param baseTokenIn The amount of base token deposited.
/// @param xTokenOut The amount of xToken minted.
/// @param bonus The amount of base token as bonus.
/// @param mintFee The amount of mint fee charged.
event MintXToken(
address indexed owner,
address indexed recipient,
uint256 baseTokenIn,
uint256 xTokenOut,
uint256 bonus,
uint256 mintFee
);
/// @notice Emitted when someone redeem base token with fToken or xToken.
/// @param owner The address of fToken and xToken owner.
/// @param recipient The address of receiver for base token.
/// @param fTokenBurned The amount of fToken burned.
/// @param baseTokenOut The amount of base token redeemed.
/// @param bonus The amount of base token as bonus.
/// @param redeemFee The amount of redeem fee charged.
event RedeemFToken(
address indexed owner,
address indexed recipient,
uint256 fTokenBurned,
uint256 baseTokenOut,
uint256 bonus,
uint256 redeemFee
);
/// @notice Emitted when someone redeem base token with fToken or xToken.
/// @param owner The address of fToken and xToken owner.
/// @param recipient The address of receiver for base token.
/// @param xTokenBurned The amount of xToken burned.
/// @param baseTokenOut The amount of base token redeemed.
/// @param redeemFee The amount of redeem fee charged.
event RedeemXToken(
address indexed owner,
address indexed recipient,
uint256 xTokenBurned,
uint256 baseTokenOut,
uint256 redeemFee
);
/// @notice Emitted when the fee ratio for minting fToken is updated.
/// @param defaultFeeRatio The new default fee ratio, multipled by 1e18.
/// @param extraFeeRatio The new extra fee ratio, multipled by 1e18.
event UpdateMintFeeRatioFToken(uint256 defaultFeeRatio, int256 extraFeeRatio);
/// @notice Emitted when the fee ratio for minting xToken is updated.
/// @param defaultFeeRatio The new default fee ratio, multipled by 1e18.
/// @param extraFeeRatio The new extra fee ratio, multipled by 1e18.
event UpdateMintFeeRatioXToken(uint256 defaultFeeRatio, int256 extraFeeRatio);
/// @notice Emitted when the fee ratio for redeeming fToken is updated.
/// @param defaultFeeRatio The new default fee ratio, multipled by 1e18.
/// @param extraFeeRatio The new extra fee ratio, multipled by 1e18.
event UpdateRedeemFeeRatioFToken(uint256 defaultFeeRatio, int256 extraFeeRatio);
/// @notice Emitted when the fee ratio for redeeming xToken is updated.
/// @param defaultFeeRatio The new default fee ratio, multipled by 1e18.
/// @param extraFeeRatio The new extra fee ratio, multipled by 1e18.
event UpdateRedeemFeeRatioXToken(uint256 defaultFeeRatio, int256 extraFeeRatio);
/// @notice Emitted when the stability ratio is updated.
/// @param oldRatio The previous collateral ratio to enter stability mode, multiplied by 1e18.
/// @param newRatio The current collateral ratio to enter stability mode, multiplied by 1e18.
event UpdateStabilityRatio(uint256 oldRatio, uint256 newRatio);
/// @notice Emitted when the platform contract is updated.
/// @param oldPlatform The address of previous platform contract.
/// @param newPlatform The address of current platform contract.
event UpdatePlatform(address indexed oldPlatform, address indexed newPlatform);
/// @notice Emitted when the reserve pool contract is updated.
/// @param oldReservePool The address of previous reserve pool contract.
/// @param newReservePool The address of current reserve pool contract.
event UpdateReservePool(address indexed oldReservePool, address indexed newReservePool);
/// @notice Emitted when the RebalancePoolRegistry contract is updated.
/// @param oldRegistry The address of previous RebalancePoolRegistry contract.
/// @param newRegistry The address of current RebalancePoolRegistry contract.
event UpdateRebalancePoolRegistry(address indexed oldRegistry, address indexed newRegistry);
/// @notice Pause or unpause mint.
/// @param oldStatus The previous status for mint.
/// @param newStatus The current status for mint.
event UpdateMintStatus(bool oldStatus, bool newStatus);
/// @notice Pause or unpause redeem.
/// @param oldStatus The previous status for redeem.
/// @param newStatus The current status for redeem.
event UpdateRedeemStatus(bool oldStatus, bool newStatus);
/// @notice Pause or unpause fToken mint in stability mode.
/// @param oldStatus The previous status for mint.
/// @param newStatus The current status for mint.
event UpdateFTokenMintStatusInStabilityMode(bool oldStatus, bool newStatus);
/// @notice Pause or unpause xToken redeem in stability mode.
/// @param oldStatus The previous status for redeem.
/// @param newStatus The current status for redeem.
event UpdateXTokenRedeemStatusInStabilityMode(bool oldStatus, bool newStatus);
/**********
* Errors *
**********/
/// @dev Thrown when the caller if not fUSD contract.
error ErrorCallerNotFUSD();
/// @dev Thrown when token mint is paused.
error ErrorMintPaused();
/// @dev Thrown when fToken mint is paused in stability mode.
error ErrorFTokenMintPausedInStabilityMode();
/// @dev Thrown when mint with zero amount base token.
error ErrorMintZeroAmount();
/// @dev Thrown when the amount of fToken is not enough.
error ErrorInsufficientFTokenOutput();
/// @dev Thrown when the amount of xToken is not enough.
error ErrorInsufficientXTokenOutput();
/// @dev Thrown when token redeem is paused.
error ErrorRedeemPaused();
/// @dev Thrown when xToken redeem is paused in stability mode.
error ErrorXTokenRedeemPausedInStabilityMode();
/// @dev Thrown when redeem with zero amount fToken or xToken.
error ErrorRedeemZeroAmount();
/// @dev Thrown when the amount of base token is not enough.
error ErrorInsufficientBaseOutput();
/// @dev Thrown when the stability ratio is too large.
error ErrorStabilityRatioTooLarge();
/// @dev Thrown when the default fee is too large.
error ErrorDefaultFeeTooLarge();
/// @dev Thrown when the delta fee is too small.
error ErrorDeltaFeeTooSmall();
/// @dev Thrown when the sum of default fee and delta fee is too large.
error ErrorTotalFeeTooLarge();
/// @dev Thrown when the given address is zero.
error ErrorZeroAddress();
/*************************
* Public View Functions *
*************************/
/// @notice The address of Treasury contract.
function treasury() external view returns (address);
/// @notice Return the address of base token.
function baseToken() external view returns (address);
/// @notice Return the address fractional base token.
function fToken() external view returns (address);
/// @notice Return the address leveraged base token.
function xToken() external view returns (address);
/// @notice Return the address of fxUSD token.
function fxUSD() external view returns (address);
/// @notice Return the collateral ratio to enter stability mode, multiplied by 1e18.
function stabilityRatio() external view returns (uint256);
/****************************
* Public Mutated Functions *
****************************/
/// @notice Mint some fToken with some base token.
/// @param baseIn The amount of wrapped value of base token supplied, use `uint256(-1)` to supply all base token.
/// @param recipient The address of receiver for fToken.
/// @param minFTokenMinted The minimum amount of fToken should be received.
/// @return fTokenMinted The amount of fToken should be received.
function mintFToken(
uint256 baseIn,
address recipient,
uint256 minFTokenMinted
) external returns (uint256 fTokenMinted);
/// @notice Mint some xToken with some base token.
/// @param baseIn The amount of wrapped value of base token supplied, use `uint256(-1)` to supply all base token.
/// @param recipient The address of receiver for xToken.
/// @param minXTokenMinted The minimum amount of xToken should be received.
/// @return xTokenMinted The amount of xToken should be received.
/// @return bonus The amount of wrapped value of base token as bonus.
function mintXToken(
uint256 baseIn,
address recipient,
uint256 minXTokenMinted
) external returns (uint256 xTokenMinted, uint256 bonus);
/// @notice Redeem base token with fToken.
/// @param fTokenIn the amount of fToken to redeem, use `uint256(-1)` to redeem all fToken.
/// @param recipient The address of receiver for base token.
/// @param minBaseOut The minimum amount of wrapped value of base token should be received.
/// @return baseOut The amount of wrapped value of base token should be received.
/// @return bonus The amount of wrapped value of base token as bonus.
function redeemFToken(
uint256 fTokenIn,
address recipient,
uint256 minBaseOut
) external returns (uint256 baseOut, uint256 bonus);
/// @notice Redeem base token with xToken.
/// @param xTokenIn the amount of xToken to redeem, use `uint256(-1)` to redeem all xToken.
/// @param recipient The address of receiver for base token.
/// @param minBaseOut The minimum amount of wrapped value of base token should be received.
/// @return baseOut The amount of wrapped value of base token should be received.
function redeemXToken(
uint256 xTokenIn,
address recipient,
uint256 minBaseOut
) external returns (uint256 baseOut);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IFxBoostableRebalancePool } from "./IFxBoostableRebalancePool.sol";
interface IFxShareableRebalancePool is IFxBoostableRebalancePool {
/**********
* Events *
**********/
/// @notice Emitted when one user share votes to another user.
/// @param owner The address of votes owner.
/// @param staker The address of staker to share votes.
event ShareVote(address indexed owner, address indexed staker);
/// @notice Emitted when the owner cancel sharing to some staker.
/// @param owner The address of votes owner.
/// @param staker The address of staker to cancel votes share.
event CancelShareVote(address indexed owner, address indexed staker);
/// @notice Emitted when staker accept the vote sharing.
/// @param staker The address of the staker.
/// @param oldOwner The address of the previous vote sharing owner.
/// @param newOwner The address of the current vote sharing owner.
event AcceptSharedVote(address indexed staker, address indexed oldOwner, address indexed newOwner);
/**********
* Errors *
**********/
/// @dev Thrown when caller shares votes to self.
error ErrorSelfSharingIsNotAllowed();
/// @dev Thrown when a staker with shared votes try to share its votes to others.
error ErrorCascadedSharingIsNotAllowed();
/// @dev Thrown when staker try to accept non-allowed vote sharing.
error ErrorVoteShareNotAllowed();
/// @dev Thrown when staker try to reject a non-existed vote sharing.
error ErrorNoAcceptedSharedVote();
/// @dev Thrown when the staker has ability to share ve balance.
error ErrorVoteOwnerCannotStake();
/// @dev Thrown when staker try to accept twice.
error ErrorRepeatAcceptSharedVote();
/*************************
* Public View Functions *
*************************/
/// @notice Return the owner of votes of some staker.
/// @param account The address of user to query.
function getStakerVoteOwner(address account) external view returns (address);
/****************************
* Public Mutated Functions *
****************************/
/// @notice Withdraw asset from this contract on behalf of someone
function withdrawFrom(
address owner,
uint256 amount,
address receiver
) external;
/// @notice Owner changes the vote sharing state for some user.
/// @param staker The address of user to change.
function toggleVoteSharing(address staker) external;
/// @notice Staker accepts the vote sharing.
/// @param newOwner The address of the owner of the votes.
function acceptSharedVote(address newOwner) external;
/// @notice Staker reject the current vote sharing.
function rejectSharedVote() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFxTreasuryV2 {
/**********
* Events *
**********/
/// @notice Emitted when the platform contract is updated.
/// @param oldPlatform The address of previous platform contract.
/// @param newPlatform The address of current platform contract.
event UpdatePlatform(address indexed oldPlatform, address indexed newPlatform);
/// @notice Emitted when the RebalancePoolSplitter contract is updated.
/// @param oldRebalancePoolSplitter The address of previous RebalancePoolSplitter contract.
/// @param newRebalancePoolSplitter The address of current RebalancePoolSplitter.
event UpdateRebalancePoolSplitter(address indexed oldRebalancePoolSplitter, address indexed newRebalancePoolSplitter);
/// @notice Emitted when the price oracle contract is updated.
/// @param oldPriceOracle The address of previous price oracle.
/// @param newPriceOracle The address of current price oracle.
event UpdatePriceOracle(address indexed oldPriceOracle, address indexed newPriceOracle);
/// @notice Emitted when the strategy contract is updated.
/// @param oldStrategy The address of previous strategy.
/// @param newStrategy The address of current strategy.
event UpdateStrategy(address indexed oldStrategy, address indexed newStrategy);
/// @notice Emitted when the base token cap is updated.
/// @param oldBaseTokenCap The value of previous base token cap.
/// @param newBaseTokenCap The value of current base token cap.
event UpdateBaseTokenCap(uint256 oldBaseTokenCap, uint256 newBaseTokenCap);
/// @notice Emitted when the EMA sample interval is updated.
/// @param oldSampleInterval The value of previous EMA sample interval.
/// @param newSampleInterval The value of current EMA sample interval.
event UpdateEMASampleInterval(uint256 oldSampleInterval, uint256 newSampleInterval);
/// @notice Emitted when the reference price is updated.
/// @param oldPrice The value of previous reference price.
/// @param newPrice The value of current reference price.
event Settle(uint256 oldPrice, uint256 newPrice);
/// @notice Emitted when the ratio for rebalance pool is updated.
/// @param oldRatio The value of the previous ratio, multipled by 1e9.
/// @param newRatio The value of the current ratio, multipled by 1e9.
event UpdateRebalancePoolRatio(uint256 oldRatio, uint256 newRatio);
/// @notice Emitted when the ratio for harvester is updated.
/// @param oldRatio The value of the previous ratio, multipled by 1e9.
/// @param newRatio The value of the current ratio, multipled by 1e9.
event UpdateHarvesterRatio(uint256 oldRatio, uint256 newRatio);
/// @notice Emitted when someone harvest pending stETH rewards.
/// @param caller The address of caller.
/// @param totalRewards The amount of total harvested rewards.
/// @param rebalancePoolRewards The amount of harvested rewards distributed to stability pool.
/// @param harvestBounty The amount of harvested rewards distributed to caller as harvest bounty.
event Harvest(address indexed caller, uint256 totalRewards, uint256 rebalancePoolRewards, uint256 harvestBounty);
/**********
* Errors *
**********/
/// @dev Thrown when the collateral ratio is smaller than 100%.
error ErrorCollateralRatioTooSmall();
/// @dev Thrown when mint exceed total capacity.
error ErrorExceedTotalCap();
/// @dev Thrown when the oracle price is invalid.
error ErrorInvalidOraclePrice();
/// @dev Thrown when the twap price is invalid.
error ErrorInvalidTwapPrice();
/// @dev Thrown when initialize protocol twice.
error ErrorProtocolInitialized();
/// @dev Thrown when the initial amount of base token is not enough.
error ErrorInsufficientInitialBaseToken();
/// @dev Thrown when current is under collateral.
error ErrorUnderCollateral();
/// @dev Thrown when the sample internal for EMA is too small.
error ErrorEMASampleIntervalTooSmall();
/// @dev Thrown when the expense ratio exceeds `MAX_REBALANCE_POOL_RATIO`.
error ErrorRebalancePoolRatioTooLarge();
/// @dev Thrown when the harvester ratio exceeds `MAX_HARVESTER_RATIO`.
error ErrorHarvesterRatioTooLarge();
/// @dev Thrown when the given address is zero.
error ErrorZeroAddress();
/*********
* Enums *
*********/
enum Action {
None,
MintFToken,
MintXToken,
RedeemFToken,
RedeemXToken
}
/*************************
* Public View Functions *
*************************/
/// @notice Return the address of base token.
function baseToken() external view returns (address);
/// @notice Return the address fractional base token.
function fToken() external view returns (address);
/// @notice Return the address leveraged base token.
function xToken() external view returns (address);
/// @notice The reference base token price.
function referenceBaseTokenPrice() external view returns (uint256);
/// @notice The current base token price.
function currentBaseTokenPrice() external view returns (uint256);
/// @notice Return whether the price is valid.
function isBaseTokenPriceValid() external view returns (bool);
/// @notice Return the total amount of underlying value of base token deposited.
function totalBaseToken() external view returns (uint256);
/// @notice Return the address of strategy contract.
function strategy() external view returns (address);
/// @notice Return the total amount of base token managed by strategy.
function strategyUnderlying() external view returns (uint256);
/// @notice Return the current collateral ratio of fToken, multipled by 1e18.
function collateralRatio() external view returns (uint256);
/// @notice Return whether the system is under collateral.
function isUnderCollateral() external view returns (bool);
/// @notice Compute the amount of base token needed to reach the new collateral ratio.
/// @param newCollateralRatio The target collateral ratio, multipled by 1e18.
/// @return maxBaseIn The amount of underlying value of base token needed.
/// @return maxFTokenMintable The amount of fToken can be minted.
function maxMintableFToken(uint256 newCollateralRatio)
external
view
returns (uint256 maxBaseIn, uint256 maxFTokenMintable);
/// @notice Compute the amount of base token needed to reach the new collateral ratio.
/// @param newCollateralRatio The target collateral ratio, multipled by 1e18.
/// @return maxBaseIn The amount of underlying value of base token needed.
/// @return maxXTokenMintable The amount of xToken can be minted.
function maxMintableXToken(uint256 newCollateralRatio)
external
view
returns (uint256 maxBaseIn, uint256 maxXTokenMintable);
/// @notice Compute the amount of fToken needed to reach the new collateral ratio.
/// @param newCollateralRatio The target collateral ratio, multipled by 1e18.
/// @return maxBaseOut The amount of underlying value of base token redeemed.
/// @return maxFTokenRedeemable The amount of fToken needed.
function maxRedeemableFToken(uint256 newCollateralRatio)
external
view
returns (uint256 maxBaseOut, uint256 maxFTokenRedeemable);
/// @notice Compute the amount of xToken needed to reach the new collateral ratio.
/// @param newCollateralRatio The target collateral ratio, multipled by 1e18.
/// @return maxBaseOut The amount of underlying value of base token redeemed.
/// @return maxXTokenRedeemable The amount of xToken needed.
function maxRedeemableXToken(uint256 newCollateralRatio)
external
view
returns (uint256 maxBaseOut, uint256 maxXTokenRedeemable);
/// @notice Return the exponential moving average of the leverage ratio.
function leverageRatio() external view returns (uint256);
/// @notice Convert underlying token amount to wrapped token amount.
/// @param amount The underlying token amount.
function getWrapppedValue(uint256 amount) external view returns (uint256);
/// @notice Convert wrapped token amount to underlying token amount.
/// @param amount The wrapped token amount.
function getUnderlyingValue(uint256 amount) external view returns (uint256);
/// @notice Return the fee ratio distributed to rebalance pool, multipled by 1e9.
function getRebalancePoolRatio() external view returns (uint256);
/// @notice Return the fee ratio distributed to harvester, multipled by 1e9.
function getHarvesterRatio() external view returns (uint256);
/****************************
* Public Mutated Functions *
****************************/
/// @notice Initialize the protocol.
/// @param baseIn The amount of underlying value of the base token used to initialize.
function initializeProtocol(uint256 baseIn) external returns (uint256 fTokenOut, uint256 xTokenOut);
/// @notice Mint fToken with some base token.
/// @param baseIn The amount of underlying value of base token deposited.
/// @param recipient The address of receiver.
/// @return fTokenOut The amount of fToken minted.
function mintFToken(uint256 baseIn, address recipient) external returns (uint256 fTokenOut);
/// @notice Mint xToken with some base token.
/// @param baseIn The amount of underlying value of base token deposited.
/// @param recipient The address of receiver.
/// @return xTokenOut The amount of xToken minted.
function mintXToken(uint256 baseIn, address recipient) external returns (uint256 xTokenOut);
/// @notice Redeem fToken and xToken to base tokne.
/// @param fTokenIn The amount of fToken to redeem.
/// @param xTokenIn The amount of xToken to redeem.
/// @param owner The owner of the fToken or xToken.
/// @param baseOut The amount of underlying value of base token redeemed.
function redeem(
uint256 fTokenIn,
uint256 xTokenIn,
address owner
) external returns (uint256 baseOut);
/// @notice Settle the nav of base token, fToken and xToken.
function settle() external;
/// @notice Transfer some base token to strategy contract.
/// @param amount The amount of token to transfer.
function transferToStrategy(uint256 amount) external;
/// @notice Notify base token profit from strategy contract.
/// @param amount The amount of base token.
function notifyStrategyProfit(uint256 amount) external;
/// @notice Harvest pending rewards to stability pool.
function harvest() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFxUSD {
/**********
* Events *
**********/
/// @notice Emitted when a new market is added.
/// @param baseToken The address of base token of the market.
/// @param mintCap The mint capacity of the market.
event AddMarket(address indexed baseToken, uint256 mintCap);
/// @notice Emitted when the mint capacity is updated.
/// @param baseToken The address of base token of the market.
/// @param oldCap The value of previous mint capacity.
/// @param newCap The value of current mint capacity.
event UpdateMintCap(address indexed baseToken, uint256 oldCap, uint256 newCap);
/// @notice Emitted when a new rebalance pool is added.
/// @param baseToken The address of base token of the market.
/// @param pool The address of the rebalance pool.
event AddRebalancePool(address indexed baseToken, address indexed pool);
/// @notice Emitted when a new rebalance pool is removed.
/// @param baseToken The address of base token of the market.
/// @param pool The address of the rebalance pool.
event RemoveRebalancePool(address indexed baseToken, address indexed pool);
/// @notice Emitted when someone wrap fToken as fxUSD.
/// @param baseToken The address of base token of the market.
/// @param owner The address of fToken owner.
/// @param receiver The address of fxUSD recipient.
/// @param amount The amount of fxUSD minted.
event Wrap(address indexed baseToken, address indexed owner, address indexed receiver, uint256 amount);
/// @notice Emitted when someone unwrap fxUSD as fToken.
/// @param baseToken The address of base token of the market.
/// @param owner The address of fxUSD owner.
/// @param receiver The address of base token recipient.
/// @param amount The amount of fxUSD burned.
event Unwrap(address indexed baseToken, address indexed owner, address indexed receiver, uint256 amount);
/**********
* Errors *
**********/
/// @dev Thrown when someone tries to interact with unsupported market.
error ErrorUnsupportedMarket();
/// @dev Thrown when someone tries to interact with unsupported rebalance pool.
error ErrorUnsupportedRebalancePool();
/// @dev Thrown when someone tries to interact with market in stability mode.
error ErrorMarketInStabilityMode();
/// @dev Thrown when someone tries to interact with market has invalid price.
error ErrorMarketWithInvalidPrice();
/// @dev Thrown when someone tries to add a supported market.
error ErrorMarketAlreadySupported();
/// @dev Thrown when the total supply of fToken exceed mint capacity.
error ErrorExceedMintCap();
/// @dev Thrown when the amount of fToken is not enough for redeem.
error ErrorInsufficientLiquidity();
/// @dev Thrown when current is under collateral.
error ErrorUnderCollateral();
/// @dev Thrown when the length of two arrays is mismatch.
error ErrorLengthMismatch();
/*************************
* Public View Functions *
*************************/
/// @notice Return the list of supported markets.
function getMarkets() external view returns (address[] memory);
/// @notice Return the list of supported rebalance pools.
function getRebalancePools() external view returns (address[] memory);
/// @notice Return the nav of fxUSD.
function nav() external view returns (uint256);
/// @notice Return whether the system is under collateral.
function isUnderCollateral() external view returns (bool);
/****************************
* Public Mutated Functions *
****************************/
/// @notice Wrap fToken to fxUSD.
/// @param baseToken The address of corresponding base token.
/// @param amount The amount of fToken to wrap.
/// @param receiver The address of fxUSD recipient.
function wrap(
address baseToken,
uint256 amount,
address receiver
) external;
/// @notice Wrap fToken from rebalance pool to fxUSD.
/// @param pool The address of rebalance pool.
/// @param amount The amount of fToken to wrap.
/// @param receiver The address of fxUSD recipient.
function wrapFrom(
address pool,
uint256 amount,
address receiver
) external;
/// @notice Mint fxUSD with base token.
/// @param baseToken The address of the base token.
/// @param amountIn The amount of base token to use.
/// @param receiver The address of fxUSD recipient.
/// @param minOut The minimum amount of fxUSD should receive.
/// @return amountOut The amount of fxUSD received by the receiver.
function mint(
address baseToken,
uint256 amountIn,
address receiver,
uint256 minOut
) external returns (uint256 amountOut);
/// @notice Deposit fxUSD to rebalance pool.
/// @param pool The address of rebalance pool.
/// @param amount The amount of fxUSD to use.
/// @param receiver The address of rebalance pool share recipient.
function earn(
address pool,
uint256 amount,
address receiver
) external;
/// @notice Mint fxUSD with base token and deposit to rebalance pool.
/// @param pool The address of rebalance pool.
/// @param amountIn The amount of base token to use.
/// @param receiver The address of rebalance pool recipient.
/// @param minOut The minimum amount of rebalance pool shares should receive.
/// @return amountOut The amount of rebalance pool shares received by the receiver.
function mintAndEarn(
address pool,
uint256 amountIn,
address receiver,
uint256 minOut
) external returns (uint256 amountOut);
/// @notice Redeem fxUSD to base token.
/// @param baseToken The address of the base token.
/// @param amountIn The amount of fxUSD to redeem.
/// @param receiver The address of base token recipient.
/// @param minOut The minimum amount of base token should receive.
/// @return amountOut The amount of base token received by the receiver.
/// @return bonusOut The amount of bonus base token received by the receiver.
function redeem(
address baseToken,
uint256 amountIn,
address receiver,
uint256 minOut
) external returns (uint256 amountOut, uint256 bonusOut);
/// @notice Redeem fToken from rebalance pool to base token.
/// @param amountIn The amount of fxUSD to redeem.
/// @param receiver The address of base token recipient.
/// @param minOut The minimum amount of base token should receive.
/// @return amountOut The amount of base token received by the receiver.
/// @return bonusOut The amount of bonus base token received by the receiver.
function redeemFrom(
address pool,
uint256 amountIn,
address receiver,
uint256 minOut
) external returns (uint256 amountOut, uint256 bonusOut);
/// @notice Redeem fxUSD to base token optimally.
/// @param amountIn The amount of fxUSD to redeem.
/// @param receiver The address of base token recipient.
/// @param minOuts The list of minimum amount of base token should receive.
/// @return baseTokens The list of base token received by the receiver.
/// @return amountOuts The list of amount of base token received by the receiver.
/// @return bonusOuts The list of amount of bonus base token received by the receiver.
function autoRedeem(
uint256 amountIn,
address receiver,
uint256[] memory minOuts
)
external
returns (
address[] memory baseTokens,
uint256[] memory amountOuts,
uint256[] memory bonusOuts
);
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "shanghai",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"ErrorExceedMintCap","type":"error"},{"inputs":[],"name":"ErrorInsufficientLiquidity","type":"error"},{"inputs":[],"name":"ErrorLengthMismatch","type":"error"},{"inputs":[],"name":"ErrorMarketAlreadySupported","type":"error"},{"inputs":[],"name":"ErrorMarketInStabilityMode","type":"error"},{"inputs":[],"name":"ErrorMarketWithInvalidPrice","type":"error"},{"inputs":[],"name":"ErrorUnderCollateral","type":"error"},{"inputs":[],"name":"ErrorUnsupportedMarket","type":"error"},{"inputs":[],"name":"ErrorUnsupportedRebalancePool","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintCap","type":"uint256"}],"name":"AddMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"AddRebalancePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"RemoveRebalancePool","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCap","type":"uint256"}],"name":"UpdateMintCap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Wrap","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"uint256","name":"_mintCap","type":"uint256"}],"name":"addMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"name":"addRebalancePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256[]","name":"_minOuts","type":"uint256[]"}],"name":"autoRedeem","outputs":[{"internalType":"address[]","name":"_baseTokens","type":"address[]"},{"internalType":"uint256[]","name":"_amountOuts","type":"uint256[]"},{"internalType":"uint256[]","name":"_bonusOuts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"earn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarkets","outputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRebalancePools","outputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isUnderCollateral","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"markets","outputs":[{"internalType":"address","name":"fToken","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"mintCap","type":"uint256"},{"internalType":"uint256","name":"managed","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"mintAndEarn","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nav","outputs":[{"internalType":"uint256","name":"_nav","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"},{"internalType":"uint256","name":"_bonusOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"redeemFrom","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"},{"internalType":"uint256","name":"_bonusOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"name":"removeRebalancePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","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":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_newCap","type":"uint256"}],"name":"updateMintCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"wrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"wrapFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234801561000f575f80fd5b506147068061001d5f395ff3fe608060405234801561000f575f80fd5b506004361061023f575f3560e01c80635c15155e11610135578063a5f879ca116100b4578063d505accf11610079578063d505accf1461057b578063d547741f1461058e578063dd62ed3e146105a1578063ec2c9016146105b4578063f3f094a1146105bc575f80fd5b8063a5f879ca14610530578063a9059cbb14610543578063b8452aa914610556578063c1590cd71461056b578063cdc6c7cc14610573575f80fd5b80638e8f294b116100fa5780638e8f294b1461047757806391d14854146104fb57806395d89b411461050e578063a217fddf14610516578063a457c2d71461051d575f80fd5b80635c15155e146103e6578063685dc7d3146103f957806370a08231146104215780637ecebe001461044957806384b0196e1461045c575f80fd5b80633644e515116101c15780633c173a4f116101865780633c173a4f14610387578063468a0efd1461039a57806346c55f80146103ad57806347b2795c146103c05780634cd88b76146103d3575f80fd5b80633644e5151461033357806336568abe1461033b578063395093511461034e5780633a4639e1146103615780633bb03e2d14610374575f80fd5b80631a3dde45116102075780631a3dde45146102c757806323b872dd146102dc578063248a9ca3146102ef5780632f2ff15d14610311578063313ce56714610324575f80fd5b806301ffc9a71461024357806306fdde031461026b578063095ea7b31461028057806316c403351461029357806318160ddd146102b5575b5f80fd5b610256610251366004613d54565b6105cf565b60405190151581526020015b60405180910390f35b610273610605565b6040516102629190613dc8565b61025661028e366004613dee565b610695565b6102a66102a1366004613e7e565b6106ac565b60405161026293929190613f9b565b6099545b604051908152602001610262565b6102da6102d5366004613fdd565b610db3565b005b6102566102ea366004614066565b610ef0565b6102b96102fd3660046140a4565b5f9081526065602052604090206001015490565b6102da61031f3660046140bb565b610f13565b60405160128152602001610262565b6102b9610f37565b6102da6103493660046140bb565b610f45565b61025661035c366004613dee565b610fc8565b6102da61036f3660046140e9565b610fe9565b6102b9610382366004614128565b611189565b6102b9610395366004614128565b611291565b6102da6103a83660046140e9565b611366565b6102da6103bb366004613dee565b6114b2565b6102da6103ce366004613fdd565b611548565b6102da6103e13660046141d8565b611677565b6102da6103f43660046140e9565b6117b0565b61040c610407366004614128565b61187e565b60408051928352602083019190915201610262565b6102b961042f366004614237565b6001600160a01b03165f9081526097602052604090205490565b6102b9610457366004614237565b611b02565b610464611b1f565b6040516102629796959493929190614252565b6104c2610485366004614237565b6101306020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b039384169492841693909116919085565b604080516001600160a01b039687168152948616602086015292909416918301919091526060820152608081019190915260a001610262565b6102566105093660046140bb565b611bb8565b610273611be2565b6102b95f81565b61025661052b366004613dee565b611bf1565b6102da61053e366004613dee565b611c6b565b610256610551366004613dee565b611ec2565b61055e611ecf565b60405161026291906142c1565b6102b9611f78565b61025661209e565b6102da6105893660046142d3565b612171565b6102da61059c3660046140bb565b6122d2565b6102b96105af366004614344565b6122f6565b61055e612320565b61040c6105ca366004614128565b6123c4565b5f6001600160e01b03198216637965db0b60e01b14806105ff57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060609a805461061490614370565b80601f016020809104026020016040519081016040528092919081815260200182805461064090614370565b801561068b5780601f106106625761010080835404028352916020019161068b565b820191905f5260205f20905b81548152906001019060200180831161066e57829003601f168201915b5050505050905090565b5f336106a28185856125dd565b5060019392505050565b60608060605f6106bd610131612700565b9050808551146106e057604051637326389560e01b815260040160405180910390fd5b806001600160401b038111156106f8576106f8613e18565b604051908082528060200260200182016040528015610721578160200160208202803683370190505b509350806001600160401b0381111561073c5761073c613e18565b604051908082528060200260200182016040528015610765578160200160208202803683370190505b509250806001600160401b0381111561078057610780613e18565b6040519080825280602002602001820160405280156107a9578160200160208202803683370190505b5091505f816001600160401b038111156107c5576107c5613e18565b6040519080825280602002602001820160405280156107ee578160200160208202803683370190505b5090505f805b8381101561096c5761080861013182612709565b87828151811061081a5761081a6143a2565b60200260200101906001600160a01b031690816001600160a01b0316815250506101305f888381518110610850576108506143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015483828151811061088d5761088d6143a2565b6020026020010181815250505f6101305f8984815181106108b0576108b06143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206001015f9054906101000a90046001600160a01b03169050806001600160a01b031663cdc6c7cc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561092b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061094f91906143b6565b1561095957600192505b5080610964816143e9565b9150506107f4565b505f61097760995490565b9050610983338b61271b565b81156109f8575f5b848110156109f257818b8583815181106109a7576109a76143a2565b60200260200101516109b99190614401565b6109c39190614418565b8782815181106109d5576109d56143a2565b6020908102919091010152806109ea816143e9565b91505061098b565b50610b23565b8915610b23575f835f81518110610a1157610a116143a2565b602002602001015190505f80600190505b86811015610a735782868281518110610a3d57610a3d6143a2565b60200260200101511115610a6b57858181518110610a5d57610a5d6143a2565b602002602001015192508091505b600101610a22565b50818c1115610aa05781888281518110610a8f57610a8f6143a2565b602002602001018181525050610ac0565b8b888281518110610ab357610ab36143a2565b6020026020010181815250505b878181518110610ad257610ad26143a2565b6020026020010151858281518110610aec57610aec6143a2565b602002602001018181510391508181525050878181518110610b1057610b106143a2565b60200260200101518c039b5050506109f8565b5f5b84811015610da557868181518110610b3f57610b3f6143a2565b60200260200101515f0315610d93576001600160a01b038a16336001600160a01b0316898381518110610b7457610b746143a2565b60200260200101516001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8a8581518110610bb857610bb86143a2565b6020026020010151604051610bcf91815260200190565b60405180910390a4868181518110610be957610be96143a2565b60200260200101516101305f8a8481518110610c0757610c076143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015f828254610c3f9190614437565b925050819055505f6101305f8a8481518110610c5d57610c5d6143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206002015f9054906101000a90046001600160a01b03169050806001600160a01b031663d0ce98fa898481518110610cbd57610cbd6143a2565b60200260200101518d8d8681518110610cd857610cd86143a2565b60200260200101516040518463ffffffff1660e01b8152600401610d18939291909283526001600160a01b03919091166020830152604082015260600190565b60408051808303815f875af1158015610d33573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d57919061444a565b898481518110610d6957610d696143a2565b60200260200101898581518110610d8257610d826143a2565b602090810291909101019190915252505b80610d9d816143e9565b915050610b25565b505050505093509350939050565b5f610dbd8161284d565b5f5b8251811015610eeb575f838281518110610ddb57610ddb6143a2565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e1e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e42919061446c565b9050610e4d8161285a565b610e7b848381518110610e6257610e626143a2565b602002602001015161013361288390919063ffffffff16565b15610eda57838281518110610e9257610e926143a2565b60200260200101516001600160a01b0316816001600160a01b03167fab3eb4272572b64f7ef5518a913a482ba7dae0fd1b51b7557e7429d8000dabe360405160405180910390a35b50610ee4816143e9565b9050610dbf565b505050565b5f33610efd858285612897565b610f0885858561290f565b506001949350505050565b5f82815260656020526040902060010154610f2d8161284d565b610eeb8383612ab8565b5f610f40612b3d565b905090565b6001600160a01b0381163314610fba5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610fc48282612b46565b5050565b5f336106a2818585610fda83836122f6565b610fe49190614487565b6125dd565b82610ff661013382612bac565b61101357604051630a5af2b960e41b815260040160405180910390fd5b61101b61209e565b1561103957604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611076573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061109a919061446c565b90506110a58161285a565b6110af815f612bcd565b6001600160a01b03851663e162402f336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018790523060448201526064015f604051808303815f87803b15801561110a575f80fd5b505af115801561111c573d5f803e3d5ffd5b5050505061112b818486612d74565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78760405161117a91815260200190565b60405180910390a45050505050565b5f8461119761013382612bac565b6111b457604051630a5af2b960e41b815260040160405180910390fd5b6111bc61209e565b156111da57604051635cbe463960e01b815260040160405180910390fd5b5f866001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611217573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061123b919061446c565b90506112468161285a565b611251816001612bcd565b6001600160a01b038082165f90815261013060205260409020541661127882828988612d9f565b935061128681898887612fd3565b505050949350505050565b5f8461129c8161285a565b8560016112a98282612bcd565b6112b161209e565b156112cf57604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038089165f9081526101306020526040902054166112f689828a89612d9f565b9450611303898887612d74565b6001600160a01b038716336001600160a01b03168a6001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78860405161135291815260200190565b60405180910390a450505050949350505050565b8261137361013382612bac565b61139057604051630a5af2b960e41b815260040160405180910390fd5b61139861209e565b156113b657604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113f3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611417919061446c565b90506114228161285a565b61142d81338661305e565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8760405161147c91815260200190565b60405180910390a46001600160a01b038082165f90815261013060205260409020546114ab9116868587612fd3565b5050505050565b5f6114bc8161284d565b6114c861013184612bac565b6114e5576040516338453dd760e01b815260040160405180910390fd5b6001600160a01b0383165f8181526101306020908152604091829020600301805490869055825181815291820186905292917f8b7ffd801f5f56da3dab6179fa82d8dcfa0aef7edfa3d5a5c895b1c2ed4c2982910160405180910390a250505050565b5f6115528161284d565b5f5b8251811015610eeb575f838281518110611570576115706143a2565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115b3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115d7919061446c565b90506116078483815181106115ee576115ee6143a2565b60200260200101516101336130c790919063ffffffff16565b156116665783828151811061161e5761161e6143a2565b60200260200101516001600160a01b0316816001600160a01b03167f37ef9fb84c18a8c84c537c46b4201d2c1f95d1c059a56ea05cf00c518b21689260405160405180910390a35b50611670816143e9565b9050611554565b5f54610100900460ff161580801561169557505f54600160ff909116105b806116ae5750303b1580156116ae57505f5460ff166001145b6117115760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610fb1565b5f805460ff191660011790558015611732575f805461ff0019166101001790555b61173a6130db565b6117426130db565b61174a6130db565b6117548383613103565b61175d83613133565b6117675f33612ab8565b8015610eeb575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b826117ba8161285a565b835f6117c68282612bcd565b6117ce61209e565b156117ec57604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038681165f9081526101306020526040902054166118138133308961317c565b61181e878688612d74565b6001600160a01b038516336001600160a01b0316886001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78960405161186d91815260200190565b60405180910390a450505050505050565b5f808561188d61013382612bac565b6118aa57604051630a5af2b960e41b815260040160405180910390fd5b5f876001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118e7573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061190b919061446c565b6001600160a01b038181165f9081526101306020526040908190206002810154905491516370a0823160e01b815230600482015293945082169291169081906370a0823190602401602060405180830381865afa15801561196e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611992919061449a565b95506001600160a01b038a1663e162402f336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018c90523060448201526064015f604051808303815f87803b1580156119ef575f80fd5b505af1158015611a01573d5f803e3d5ffd5b50506040516370a0823160e01b81523060048201528892506001600160a01b03841691506370a0823190602401602060405180830381865afa158015611a49573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a6d919061449a565b611a779190614437565b6040516368674c7d60e11b8152600481018290526001600160a01b038a81166024830152604482018a90529197509083169063d0ce98fa9060640160408051808303815f875af1158015611acd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611af1919061444a565b909b909a5098505050505050505050565b6001600160a01b0381165f90815260fd60205260408120546105ff565b5f6060805f805f606060c9545f801b148015611b3b575060ca54155b611b7f5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606401610fb1565b611b876131e7565b611b8f6131f6565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f9182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060609b805461061490614370565b5f3381611bfe82866122f6565b905083811015611c5e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610fb1565b610f0882868684036125dd565b5f611c758161284d565b5f836001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cb2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cd6919061446c565b90505f846001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d15573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d39919061446c565b90505f856001600160a01b031663a8694e576040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d78573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d9c919061446c565b9050611daa61013184612bac565b15611dc857604051639d80f21f60e01b815260040160405180910390fd5b611dd461013184612883565b506040805160a0810182526001600160a01b03808416825284811660208084019182528a8316848601908152606085018b81525f608087018181528b8716808352610130909552979020955186549086166001600160a01b031991821617875593516001870180549187169186169190911790559051600286018054919095169316929092179092555160038301559151600490910155611e7790875f19613205565b826001600160a01b03167f7db2b525ddc969d78e5db660ace79ab264aff9c141437a4b78a87f2aeb39ee8d86604051611eb291815260200190565b60405180910390a2505050505050565b5f336106a281858561290f565b60605f611edd610133612700565b9050806001600160401b03811115611ef757611ef7613e18565b604051908082528060200260200182016040528015611f20578160200160208202803683370190505b5091505f5b81811015611f7357611f3961013382612709565b838281518110611f4b57611f4b6143a2565b6001600160a01b0390921660209283029190910190910152611f6c816143e9565b9050611f25565b505090565b5f80611f85610131612700565b90505f611f9160995490565b9050805f03611faa57670de0b6b3a76400009250505090565b5f5b8281101561208c575f611fc161013183612709565b6001600160a01b038082165f9081526101306020908152604080832054815163c1590cd760e01b81529151959650909316939192849263c1590cd7926004808401939192918290030181865afa15801561201d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612041919061449a565b6001600160a01b0384165f908152610130602052604090206004015490915061206a9082614401565b6120749088614487565b96505050508080612084906143e9565b915050611fac565b506120978184614418565b9250505090565b5f806120ab610131612700565b90505f5b81811015612169575f6120c461013183612709565b6001600160a01b038082165f9081526101306020908152604091829020600101548251633371b1f360e21b8152925194955090921692839263cdc6c7cc92600480820193918290030181865afa158015612120573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061214491906143b6565b1561215457600194505050505090565b50508080612161906143e9565b9150506120af565b505f91505090565b834211156121c15760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610fb1565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886121ef8c613318565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f6122498261333f565b90505f6122588287878761336b565b9050896001600160a01b0316816001600160a01b0316146122bb5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610fb1565b6122c68a8a8a6125dd565b50505050505050505050565b5f828152606560205260409020600101546122ec8161284d565b610eeb8383612b46565b6001600160a01b039182165f90815260986020908152604080832093909416825291909152205490565b60605f61232e610131612700565b9050806001600160401b0381111561234857612348613e18565b604051908082528060200260200182016040528015612371578160200160208202803683370190505b5091505f5b81811015611f735761238a61013182612709565b83828151811061239c5761239c6143a2565b6001600160a01b03909216602092830291909101909101526123bd816143e9565b9050612376565b5f80856123d08161285a565b6123d861209e565b156123f657604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038781165f90815261013060205260408082206002810154905491516370a0823160e01b81523060048201529084169391909116919082906370a0823190602401602060405180830381865afa158015612459573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061247d919061449a565b6040516368674c7d60e11b8152600481018b90526001600160a01b038a81166024830152604482018a90529192509084169063d0ce98fa9060640160408051808303815f875af11580156124d3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906124f7919061444a565b6040516370a0823160e01b815230600482015291975095506001600160a01b038316906370a0823190602401602060405180830381865afa15801561253e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612562919061449a565b61256c9082614437565b98506125798a338b61305e565b6001600160a01b038816336001600160a01b03168b6001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8c6040516125c891815260200190565b60405180910390a45050505094509492505050565b6001600160a01b03831661263f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610fb1565b6001600160a01b0382166126a05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610fb1565b6001600160a01b038381165f8181526098602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6105ff825490565b5f6127148383613393565b9392505050565b6001600160a01b03821661277b5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610fb1565b6001600160a01b0382165f90815260976020526040902054818110156127ee5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610fb1565b6001600160a01b0383165f8181526097602090815260408083208686039055609980548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b61285781336133b9565b50565b61286661013182612bac565b612857576040516338453dd760e01b815260040160405180910390fd5b5f612714836001600160a01b038416613412565b5f6128a284846122f6565b90505f19811461290957818110156128fc5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610fb1565b61290984848484036125dd565b50505050565b6001600160a01b0383166129735760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610fb1565b6001600160a01b0382166129d55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610fb1565b6001600160a01b0383165f9081526097602052604090205481811015612a4c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610fb1565b6001600160a01b038085165f8181526097602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612aab9086815260200190565b60405180910390a3612909565b612ac28282611bb8565b610fc4575f8281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612af93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f610f4061345e565b612b508282611bb8565b15610fc4575f8281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381165f9081526001830160205260408120541515612714565b6001600160a01b038083165f9081526101306020526040902060010154168115612cf7575f816001600160a01b031663b4eae1cb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c52919061449a565b6001600160a01b038086165f90815261013060209081526040808320600201548151630cf0b5b360e41b815291519596509294929093169263cf0b5b3092600480830193928290030181865afa158015612cae573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612cd2919061449a565b9050808211612cf4576040516319168f7960e21b815260040160405180910390fd5b50505b806001600160a01b0316639e3ad8716040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d33573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d5791906143b6565b610eeb57604051631d05894b60e31b815260040160405180910390fd5b6001600160a01b0383165f90815261013060205260409020600401805482019055610eeb82826134d1565b6001600160a01b038481165f81815261013060205260408120600281015460039091015491931691612dd39033308861317c565b6040516370a0823160e01b81523060048201525f906001600160a01b038916906370a0823190602401602060405180830381865afa158015612e17573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e3b919061449a565b6040516364c9b4c360e01b815260048101889052306024820152604481018790529091506001600160a01b038416906364c9b4c3906064016020604051808303815f875af1158015612e8f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612eb3919061449a565b935081876001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ef2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f16919061449a565b1115612f3557604051630788a88760e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038a16906370a0823190602401602060405180830381865afa158015612f79573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f9d919061449a565b612fa79083614437565b905086811015612fc757612fc76001600160a01b038a1633838a03613590565b50505050949350505050565b612fe76001600160a01b038516845f613205565b612ffb6001600160a01b0385168483613205565b604051636e553f6560e01b8152600481018290526001600160a01b038381166024830152841690636e553f65906044015f604051808303815f87803b158015613042575f80fd5b505af1158015613054573d5f803e3d5ffd5b5050505050505050565b6001600160a01b0383165f90815261013060205260409020600401548082111561309b5760405163b268a92160e01b815260040160405180910390fd5b6001600160a01b0384165f9081526101306020526040902060040180548390039055612909838361271b565b5f612714836001600160a01b0384166135c0565b5f54610100900460ff166131015760405162461bcd60e51b8152600401610fb1906144b1565b565b5f54610100900460ff166131295760405162461bcd60e51b8152600401610fb1906144b1565b610fc482826136a3565b5f54610100900460ff166131595760405162461bcd60e51b8152600401610fb1906144b1565b61285781604051806040016040528060018152602001603160f81b8152506136e2565b6040516001600160a01b03808516602483015283166044820152606481018290526129099085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261372f565b606060cb805461061490614370565b606060cc805461061490614370565b80158061327d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015613257573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061327b919061449a565b155b6132e85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610fb1565b6040516001600160a01b038316602482015260448101829052610eeb90849063095ea7b360e01b906064016131b0565b6001600160a01b0381165f90815260fd602052604090208054600181018255905b50919050565b5f6105ff61334b612b3d565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f61337a87878787613802565b91509150613387816138bf565b5090505b949350505050565b5f825f0182815481106133a8576133a86143a2565b905f5260205f200154905092915050565b6133c38282611bb8565b610fc4576133d081613a08565b6133db836020613a1a565b6040516020016133ec9291906144fc565b60408051601f198184030181529082905262461bcd60e51b8252610fb191600401613dc8565b5f81815260018301602052604081205461345757508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556105ff565b505f6105ff565b5f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f613488613baf565b613490613c07565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b0382166135275760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610fb1565b8060995f8282546135389190614487565b90915550506001600160a01b0382165f818152609760209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6040516001600160a01b038316602482015260448101829052610eeb90849063a9059cbb60e01b906064016131b0565b5f818152600183016020526040812054801561369a575f6135e2600183614437565b85549091505f906135f590600190614437565b9050818114613654575f865f018281548110613613576136136143a2565b905f5260205f200154905080875f018481548110613633576136336143a2565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061366557613665614570565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506105ff565b5f9150506105ff565b5f54610100900460ff166136c95760405162461bcd60e51b8152600401610fb1906144b1565b609a6136d583826145d1565b50609b610eeb82826145d1565b5f54610100900460ff166137085760405162461bcd60e51b8152600401610fb1906144b1565b60cb61371483826145d1565b5060cc61372182826145d1565b50505f60c981905560ca5550565b5f613783826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c379092919063ffffffff16565b905080515f14806137a35750808060200190518101906137a391906143b6565b610eeb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610fb1565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561383757505f905060036138b6565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613888573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b0381166138b0575f600192509250506138b6565b91505f90505b94509492505050565b5f8160048111156138d2576138d261468c565b036138da5750565b60018160048111156138ee576138ee61468c565b0361393b5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610fb1565b600281600481111561394f5761394f61468c565b0361399c5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610fb1565b60038160048111156139b0576139b061468c565b036128575760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610fb1565b60606105ff6001600160a01b03831660145b60605f613a28836002614401565b613a33906002614487565b6001600160401b03811115613a4a57613a4a613e18565b6040519080825280601f01601f191660200182016040528015613a74576020820181803683370190505b509050600360fc1b815f81518110613a8e57613a8e6143a2565b60200101906001600160f81b03191690815f1a905350600f60fb1b81600181518110613abc57613abc6143a2565b60200101906001600160f81b03191690815f1a9053505f613ade846002614401565b613ae9906001614487565b90505b6001811115613b60576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613b1d57613b1d6143a2565b1a60f81b828281518110613b3357613b336143a2565b60200101906001600160f81b03191690815f1a90535060049490941c93613b59816146a0565b9050613aec565b5083156127145760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610fb1565b5f80613bb96131e7565b805190915015613bd0578051602090910120919050565b60c9548015613bdf5792915050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709250505090565b5f80613c116131f6565b805190915015613c28578051602090910120919050565b60ca548015613bdf5792915050565b606061338b84845f85855f80866001600160a01b03168587604051613c5c91906146b5565b5f6040518083038185875af1925050503d805f8114613c96576040519150601f19603f3d011682016040523d82523d5f602084013e613c9b565b606091505b5091509150613cac87838387613cb7565b979650505050505050565b60608315613d255782515f03613d1e576001600160a01b0385163b613d1e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fb1565b508161338b565b61338b8383815115613d3a5781518083602001fd5b8060405162461bcd60e51b8152600401610fb19190613dc8565b5f60208284031215613d64575f80fd5b81356001600160e01b031981168114612714575f80fd5b5f5b83811015613d95578181015183820152602001613d7d565b50505f910152565b5f8151808452613db4816020860160208601613d7b565b601f01601f19169290920160200192915050565b602081525f6127146020830184613d9d565b6001600160a01b0381168114612857575f80fd5b5f8060408385031215613dff575f80fd5b8235613e0a81613dda565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715613e5457613e54613e18565b604052919050565b5f6001600160401b03821115613e7457613e74613e18565b5060051b60200190565b5f805f60608486031215613e90575f80fd5b83359250602080850135613ea381613dda565b925060408501356001600160401b03811115613ebd575f80fd5b8501601f81018713613ecd575f80fd5b8035613ee0613edb82613e5c565b613e2c565b81815260059190911b82018301908381019089831115613efe575f80fd5b928401925b82841015613f1c57833582529284019290840190613f03565b80955050505050509250925092565b5f8151808452602080850194508084015f5b83811015613f625781516001600160a01b031687529582019590820190600101613f3d565b509495945050505050565b5f8151808452602080850194508084015f5b83811015613f6257815187529582019590820190600101613f7f565b606081525f613fad6060830186613f2b565b8281036020840152613fbf8186613f6d565b90508281036040840152613fd38185613f6d565b9695505050505050565b5f6020808385031215613fee575f80fd5b82356001600160401b03811115614003575f80fd5b8301601f81018513614013575f80fd5b8035614021613edb82613e5c565b81815260059190911b8201830190838101908783111561403f575f80fd5b928401925b82841015613cac57833561405781613dda565b82529284019290840190614044565b5f805f60608486031215614078575f80fd5b833561408381613dda565b9250602084013561409381613dda565b929592945050506040919091013590565b5f602082840312156140b4575f80fd5b5035919050565b5f80604083850312156140cc575f80fd5b8235915060208301356140de81613dda565b809150509250929050565b5f805f606084860312156140fb575f80fd5b833561410681613dda565b925060208401359150604084013561411d81613dda565b809150509250925092565b5f805f806080858703121561413b575f80fd5b843561414681613dda565b935060208501359250604085013561415d81613dda565b9396929550929360600135925050565b5f82601f83011261417c575f80fd5b81356001600160401b0381111561419557614195613e18565b6141a8601f8201601f1916602001613e2c565b8181528460208386010111156141bc575f80fd5b816020850160208301375f918101602001919091529392505050565b5f80604083850312156141e9575f80fd5b82356001600160401b03808211156141ff575f80fd5b61420b8683870161416d565b93506020850135915080821115614220575f80fd5b5061422d8582860161416d565b9150509250929050565b5f60208284031215614247575f80fd5b813561271481613dda565b60ff60f81b8816815260e060208201525f61427060e0830189613d9d565b82810360408401526142828189613d9d565b606084018890526001600160a01b038716608085015260a0840186905283810360c085015290506142b38185613f6d565b9a9950505050505050505050565b602081525f6127146020830184613f2b565b5f805f805f805f60e0888a0312156142e9575f80fd5b87356142f481613dda565b9650602088013561430481613dda565b95506040880135945060608801359350608088013560ff81168114614327575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215614355575f80fd5b823561436081613dda565b915060208301356140de81613dda565b600181811c9082168061438457607f821691505b60208210810361333957634e487b7160e01b5f52602260045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156143c6575f80fd5b81518015158114612714575f80fd5b634e487b7160e01b5f52601160045260245ffd5b5f600182016143fa576143fa6143d5565b5060010190565b80820281158282048414176105ff576105ff6143d5565b5f8261443257634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156105ff576105ff6143d5565b5f806040838503121561445b575f80fd5b505080516020909101519092909150565b5f6020828403121561447c575f80fd5b815161271481613dda565b808201808211156105ff576105ff6143d5565b5f602082840312156144aa575f80fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351614533816017850160208801613d7b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614564816028840160208801613d7b565b01602801949350505050565b634e487b7160e01b5f52603160045260245ffd5b601f821115610eeb575f81815260208120601f850160051c810160208610156145aa5750805b601f850160051c820191505b818110156145c9578281556001016145b6565b505050505050565b81516001600160401b038111156145ea576145ea613e18565b6145fe816145f88454614370565b84614584565b602080601f831160018114614631575f841561461a5750858301515b5f19600386901b1c1916600185901b1785556145c9565b5f85815260208120601f198616915b8281101561465f57888601518255948401946001909101908401614640565b508582101561467c57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52602160045260245ffd5b5f816146ae576146ae6143d5565b505f190190565b5f82516146c6818460208701613d7b565b919091019291505056fea2646970667358221220d77802c51bd15bb0f78491f0cfc521b857a125cd9fc8aa4a0398d7adff48a64564736f6c63430008140033
Deployed Bytecode
0x608060405234801561000f575f80fd5b506004361061023f575f3560e01c80635c15155e11610135578063a5f879ca116100b4578063d505accf11610079578063d505accf1461057b578063d547741f1461058e578063dd62ed3e146105a1578063ec2c9016146105b4578063f3f094a1146105bc575f80fd5b8063a5f879ca14610530578063a9059cbb14610543578063b8452aa914610556578063c1590cd71461056b578063cdc6c7cc14610573575f80fd5b80638e8f294b116100fa5780638e8f294b1461047757806391d14854146104fb57806395d89b411461050e578063a217fddf14610516578063a457c2d71461051d575f80fd5b80635c15155e146103e6578063685dc7d3146103f957806370a08231146104215780637ecebe001461044957806384b0196e1461045c575f80fd5b80633644e515116101c15780633c173a4f116101865780633c173a4f14610387578063468a0efd1461039a57806346c55f80146103ad57806347b2795c146103c05780634cd88b76146103d3575f80fd5b80633644e5151461033357806336568abe1461033b578063395093511461034e5780633a4639e1146103615780633bb03e2d14610374575f80fd5b80631a3dde45116102075780631a3dde45146102c757806323b872dd146102dc578063248a9ca3146102ef5780632f2ff15d14610311578063313ce56714610324575f80fd5b806301ffc9a71461024357806306fdde031461026b578063095ea7b31461028057806316c403351461029357806318160ddd146102b5575b5f80fd5b610256610251366004613d54565b6105cf565b60405190151581526020015b60405180910390f35b610273610605565b6040516102629190613dc8565b61025661028e366004613dee565b610695565b6102a66102a1366004613e7e565b6106ac565b60405161026293929190613f9b565b6099545b604051908152602001610262565b6102da6102d5366004613fdd565b610db3565b005b6102566102ea366004614066565b610ef0565b6102b96102fd3660046140a4565b5f9081526065602052604090206001015490565b6102da61031f3660046140bb565b610f13565b60405160128152602001610262565b6102b9610f37565b6102da6103493660046140bb565b610f45565b61025661035c366004613dee565b610fc8565b6102da61036f3660046140e9565b610fe9565b6102b9610382366004614128565b611189565b6102b9610395366004614128565b611291565b6102da6103a83660046140e9565b611366565b6102da6103bb366004613dee565b6114b2565b6102da6103ce366004613fdd565b611548565b6102da6103e13660046141d8565b611677565b6102da6103f43660046140e9565b6117b0565b61040c610407366004614128565b61187e565b60408051928352602083019190915201610262565b6102b961042f366004614237565b6001600160a01b03165f9081526097602052604090205490565b6102b9610457366004614237565b611b02565b610464611b1f565b6040516102629796959493929190614252565b6104c2610485366004614237565b6101306020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b039384169492841693909116919085565b604080516001600160a01b039687168152948616602086015292909416918301919091526060820152608081019190915260a001610262565b6102566105093660046140bb565b611bb8565b610273611be2565b6102b95f81565b61025661052b366004613dee565b611bf1565b6102da61053e366004613dee565b611c6b565b610256610551366004613dee565b611ec2565b61055e611ecf565b60405161026291906142c1565b6102b9611f78565b61025661209e565b6102da6105893660046142d3565b612171565b6102da61059c3660046140bb565b6122d2565b6102b96105af366004614344565b6122f6565b61055e612320565b61040c6105ca366004614128565b6123c4565b5f6001600160e01b03198216637965db0b60e01b14806105ff57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060609a805461061490614370565b80601f016020809104026020016040519081016040528092919081815260200182805461064090614370565b801561068b5780601f106106625761010080835404028352916020019161068b565b820191905f5260205f20905b81548152906001019060200180831161066e57829003601f168201915b5050505050905090565b5f336106a28185856125dd565b5060019392505050565b60608060605f6106bd610131612700565b9050808551146106e057604051637326389560e01b815260040160405180910390fd5b806001600160401b038111156106f8576106f8613e18565b604051908082528060200260200182016040528015610721578160200160208202803683370190505b509350806001600160401b0381111561073c5761073c613e18565b604051908082528060200260200182016040528015610765578160200160208202803683370190505b509250806001600160401b0381111561078057610780613e18565b6040519080825280602002602001820160405280156107a9578160200160208202803683370190505b5091505f816001600160401b038111156107c5576107c5613e18565b6040519080825280602002602001820160405280156107ee578160200160208202803683370190505b5090505f805b8381101561096c5761080861013182612709565b87828151811061081a5761081a6143a2565b60200260200101906001600160a01b031690816001600160a01b0316815250506101305f888381518110610850576108506143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015483828151811061088d5761088d6143a2565b6020026020010181815250505f6101305f8984815181106108b0576108b06143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206001015f9054906101000a90046001600160a01b03169050806001600160a01b031663cdc6c7cc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561092b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061094f91906143b6565b1561095957600192505b5080610964816143e9565b9150506107f4565b505f61097760995490565b9050610983338b61271b565b81156109f8575f5b848110156109f257818b8583815181106109a7576109a76143a2565b60200260200101516109b99190614401565b6109c39190614418565b8782815181106109d5576109d56143a2565b6020908102919091010152806109ea816143e9565b91505061098b565b50610b23565b8915610b23575f835f81518110610a1157610a116143a2565b602002602001015190505f80600190505b86811015610a735782868281518110610a3d57610a3d6143a2565b60200260200101511115610a6b57858181518110610a5d57610a5d6143a2565b602002602001015192508091505b600101610a22565b50818c1115610aa05781888281518110610a8f57610a8f6143a2565b602002602001018181525050610ac0565b8b888281518110610ab357610ab36143a2565b6020026020010181815250505b878181518110610ad257610ad26143a2565b6020026020010151858281518110610aec57610aec6143a2565b602002602001018181510391508181525050878181518110610b1057610b106143a2565b60200260200101518c039b5050506109f8565b5f5b84811015610da557868181518110610b3f57610b3f6143a2565b60200260200101515f0315610d93576001600160a01b038a16336001600160a01b0316898381518110610b7457610b746143a2565b60200260200101516001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8a8581518110610bb857610bb86143a2565b6020026020010151604051610bcf91815260200190565b60405180910390a4868181518110610be957610be96143a2565b60200260200101516101305f8a8481518110610c0757610c076143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015f828254610c3f9190614437565b925050819055505f6101305f8a8481518110610c5d57610c5d6143a2565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206002015f9054906101000a90046001600160a01b03169050806001600160a01b031663d0ce98fa898481518110610cbd57610cbd6143a2565b60200260200101518d8d8681518110610cd857610cd86143a2565b60200260200101516040518463ffffffff1660e01b8152600401610d18939291909283526001600160a01b03919091166020830152604082015260600190565b60408051808303815f875af1158015610d33573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d57919061444a565b898481518110610d6957610d696143a2565b60200260200101898581518110610d8257610d826143a2565b602090810291909101019190915252505b80610d9d816143e9565b915050610b25565b505050505093509350939050565b5f610dbd8161284d565b5f5b8251811015610eeb575f838281518110610ddb57610ddb6143a2565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e1e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e42919061446c565b9050610e4d8161285a565b610e7b848381518110610e6257610e626143a2565b602002602001015161013361288390919063ffffffff16565b15610eda57838281518110610e9257610e926143a2565b60200260200101516001600160a01b0316816001600160a01b03167fab3eb4272572b64f7ef5518a913a482ba7dae0fd1b51b7557e7429d8000dabe360405160405180910390a35b50610ee4816143e9565b9050610dbf565b505050565b5f33610efd858285612897565b610f0885858561290f565b506001949350505050565b5f82815260656020526040902060010154610f2d8161284d565b610eeb8383612ab8565b5f610f40612b3d565b905090565b6001600160a01b0381163314610fba5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610fc48282612b46565b5050565b5f336106a2818585610fda83836122f6565b610fe49190614487565b6125dd565b82610ff661013382612bac565b61101357604051630a5af2b960e41b815260040160405180910390fd5b61101b61209e565b1561103957604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611076573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061109a919061446c565b90506110a58161285a565b6110af815f612bcd565b6001600160a01b03851663e162402f336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018790523060448201526064015f604051808303815f87803b15801561110a575f80fd5b505af115801561111c573d5f803e3d5ffd5b5050505061112b818486612d74565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78760405161117a91815260200190565b60405180910390a45050505050565b5f8461119761013382612bac565b6111b457604051630a5af2b960e41b815260040160405180910390fd5b6111bc61209e565b156111da57604051635cbe463960e01b815260040160405180910390fd5b5f866001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611217573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061123b919061446c565b90506112468161285a565b611251816001612bcd565b6001600160a01b038082165f90815261013060205260409020541661127882828988612d9f565b935061128681898887612fd3565b505050949350505050565b5f8461129c8161285a565b8560016112a98282612bcd565b6112b161209e565b156112cf57604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038089165f9081526101306020526040902054166112f689828a89612d9f565b9450611303898887612d74565b6001600160a01b038716336001600160a01b03168a6001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78860405161135291815260200190565b60405180910390a450505050949350505050565b8261137361013382612bac565b61139057604051630a5af2b960e41b815260040160405180910390fd5b61139861209e565b156113b657604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113f3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611417919061446c565b90506114228161285a565b61142d81338661305e565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8760405161147c91815260200190565b60405180910390a46001600160a01b038082165f90815261013060205260409020546114ab9116868587612fd3565b5050505050565b5f6114bc8161284d565b6114c861013184612bac565b6114e5576040516338453dd760e01b815260040160405180910390fd5b6001600160a01b0383165f8181526101306020908152604091829020600301805490869055825181815291820186905292917f8b7ffd801f5f56da3dab6179fa82d8dcfa0aef7edfa3d5a5c895b1c2ed4c2982910160405180910390a250505050565b5f6115528161284d565b5f5b8251811015610eeb575f838281518110611570576115706143a2565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115b3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115d7919061446c565b90506116078483815181106115ee576115ee6143a2565b60200260200101516101336130c790919063ffffffff16565b156116665783828151811061161e5761161e6143a2565b60200260200101516001600160a01b0316816001600160a01b03167f37ef9fb84c18a8c84c537c46b4201d2c1f95d1c059a56ea05cf00c518b21689260405160405180910390a35b50611670816143e9565b9050611554565b5f54610100900460ff161580801561169557505f54600160ff909116105b806116ae5750303b1580156116ae57505f5460ff166001145b6117115760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610fb1565b5f805460ff191660011790558015611732575f805461ff0019166101001790555b61173a6130db565b6117426130db565b61174a6130db565b6117548383613103565b61175d83613133565b6117675f33612ab8565b8015610eeb575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b826117ba8161285a565b835f6117c68282612bcd565b6117ce61209e565b156117ec57604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038681165f9081526101306020526040902054166118138133308961317c565b61181e878688612d74565b6001600160a01b038516336001600160a01b0316886001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78960405161186d91815260200190565b60405180910390a450505050505050565b5f808561188d61013382612bac565b6118aa57604051630a5af2b960e41b815260040160405180910390fd5b5f876001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118e7573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061190b919061446c565b6001600160a01b038181165f9081526101306020526040908190206002810154905491516370a0823160e01b815230600482015293945082169291169081906370a0823190602401602060405180830381865afa15801561196e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611992919061449a565b95506001600160a01b038a1663e162402f336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018c90523060448201526064015f604051808303815f87803b1580156119ef575f80fd5b505af1158015611a01573d5f803e3d5ffd5b50506040516370a0823160e01b81523060048201528892506001600160a01b03841691506370a0823190602401602060405180830381865afa158015611a49573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a6d919061449a565b611a779190614437565b6040516368674c7d60e11b8152600481018290526001600160a01b038a81166024830152604482018a90529197509083169063d0ce98fa9060640160408051808303815f875af1158015611acd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611af1919061444a565b909b909a5098505050505050505050565b6001600160a01b0381165f90815260fd60205260408120546105ff565b5f6060805f805f606060c9545f801b148015611b3b575060ca54155b611b7f5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606401610fb1565b611b876131e7565b611b8f6131f6565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f9182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060609b805461061490614370565b5f3381611bfe82866122f6565b905083811015611c5e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610fb1565b610f0882868684036125dd565b5f611c758161284d565b5f836001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cb2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cd6919061446c565b90505f846001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d15573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d39919061446c565b90505f856001600160a01b031663a8694e576040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d78573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d9c919061446c565b9050611daa61013184612bac565b15611dc857604051639d80f21f60e01b815260040160405180910390fd5b611dd461013184612883565b506040805160a0810182526001600160a01b03808416825284811660208084019182528a8316848601908152606085018b81525f608087018181528b8716808352610130909552979020955186549086166001600160a01b031991821617875593516001870180549187169186169190911790559051600286018054919095169316929092179092555160038301559151600490910155611e7790875f19613205565b826001600160a01b03167f7db2b525ddc969d78e5db660ace79ab264aff9c141437a4b78a87f2aeb39ee8d86604051611eb291815260200190565b60405180910390a2505050505050565b5f336106a281858561290f565b60605f611edd610133612700565b9050806001600160401b03811115611ef757611ef7613e18565b604051908082528060200260200182016040528015611f20578160200160208202803683370190505b5091505f5b81811015611f7357611f3961013382612709565b838281518110611f4b57611f4b6143a2565b6001600160a01b0390921660209283029190910190910152611f6c816143e9565b9050611f25565b505090565b5f80611f85610131612700565b90505f611f9160995490565b9050805f03611faa57670de0b6b3a76400009250505090565b5f5b8281101561208c575f611fc161013183612709565b6001600160a01b038082165f9081526101306020908152604080832054815163c1590cd760e01b81529151959650909316939192849263c1590cd7926004808401939192918290030181865afa15801561201d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612041919061449a565b6001600160a01b0384165f908152610130602052604090206004015490915061206a9082614401565b6120749088614487565b96505050508080612084906143e9565b915050611fac565b506120978184614418565b9250505090565b5f806120ab610131612700565b90505f5b81811015612169575f6120c461013183612709565b6001600160a01b038082165f9081526101306020908152604091829020600101548251633371b1f360e21b8152925194955090921692839263cdc6c7cc92600480820193918290030181865afa158015612120573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061214491906143b6565b1561215457600194505050505090565b50508080612161906143e9565b9150506120af565b505f91505090565b834211156121c15760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610fb1565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886121ef8c613318565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f6122498261333f565b90505f6122588287878761336b565b9050896001600160a01b0316816001600160a01b0316146122bb5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610fb1565b6122c68a8a8a6125dd565b50505050505050505050565b5f828152606560205260409020600101546122ec8161284d565b610eeb8383612b46565b6001600160a01b039182165f90815260986020908152604080832093909416825291909152205490565b60605f61232e610131612700565b9050806001600160401b0381111561234857612348613e18565b604051908082528060200260200182016040528015612371578160200160208202803683370190505b5091505f5b81811015611f735761238a61013182612709565b83828151811061239c5761239c6143a2565b6001600160a01b03909216602092830291909101909101526123bd816143e9565b9050612376565b5f80856123d08161285a565b6123d861209e565b156123f657604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038781165f90815261013060205260408082206002810154905491516370a0823160e01b81523060048201529084169391909116919082906370a0823190602401602060405180830381865afa158015612459573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061247d919061449a565b6040516368674c7d60e11b8152600481018b90526001600160a01b038a81166024830152604482018a90529192509084169063d0ce98fa9060640160408051808303815f875af11580156124d3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906124f7919061444a565b6040516370a0823160e01b815230600482015291975095506001600160a01b038316906370a0823190602401602060405180830381865afa15801561253e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612562919061449a565b61256c9082614437565b98506125798a338b61305e565b6001600160a01b038816336001600160a01b03168b6001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8c6040516125c891815260200190565b60405180910390a45050505094509492505050565b6001600160a01b03831661263f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610fb1565b6001600160a01b0382166126a05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610fb1565b6001600160a01b038381165f8181526098602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6105ff825490565b5f6127148383613393565b9392505050565b6001600160a01b03821661277b5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610fb1565b6001600160a01b0382165f90815260976020526040902054818110156127ee5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610fb1565b6001600160a01b0383165f8181526097602090815260408083208686039055609980548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b61285781336133b9565b50565b61286661013182612bac565b612857576040516338453dd760e01b815260040160405180910390fd5b5f612714836001600160a01b038416613412565b5f6128a284846122f6565b90505f19811461290957818110156128fc5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610fb1565b61290984848484036125dd565b50505050565b6001600160a01b0383166129735760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610fb1565b6001600160a01b0382166129d55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610fb1565b6001600160a01b0383165f9081526097602052604090205481811015612a4c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610fb1565b6001600160a01b038085165f8181526097602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612aab9086815260200190565b60405180910390a3612909565b612ac28282611bb8565b610fc4575f8281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612af93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f610f4061345e565b612b508282611bb8565b15610fc4575f8281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381165f9081526001830160205260408120541515612714565b6001600160a01b038083165f9081526101306020526040902060010154168115612cf7575f816001600160a01b031663b4eae1cb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c52919061449a565b6001600160a01b038086165f90815261013060209081526040808320600201548151630cf0b5b360e41b815291519596509294929093169263cf0b5b3092600480830193928290030181865afa158015612cae573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612cd2919061449a565b9050808211612cf4576040516319168f7960e21b815260040160405180910390fd5b50505b806001600160a01b0316639e3ad8716040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d33573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d5791906143b6565b610eeb57604051631d05894b60e31b815260040160405180910390fd5b6001600160a01b0383165f90815261013060205260409020600401805482019055610eeb82826134d1565b6001600160a01b038481165f81815261013060205260408120600281015460039091015491931691612dd39033308861317c565b6040516370a0823160e01b81523060048201525f906001600160a01b038916906370a0823190602401602060405180830381865afa158015612e17573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e3b919061449a565b6040516364c9b4c360e01b815260048101889052306024820152604481018790529091506001600160a01b038416906364c9b4c3906064016020604051808303815f875af1158015612e8f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612eb3919061449a565b935081876001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ef2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f16919061449a565b1115612f3557604051630788a88760e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038a16906370a0823190602401602060405180830381865afa158015612f79573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f9d919061449a565b612fa79083614437565b905086811015612fc757612fc76001600160a01b038a1633838a03613590565b50505050949350505050565b612fe76001600160a01b038516845f613205565b612ffb6001600160a01b0385168483613205565b604051636e553f6560e01b8152600481018290526001600160a01b038381166024830152841690636e553f65906044015f604051808303815f87803b158015613042575f80fd5b505af1158015613054573d5f803e3d5ffd5b5050505050505050565b6001600160a01b0383165f90815261013060205260409020600401548082111561309b5760405163b268a92160e01b815260040160405180910390fd5b6001600160a01b0384165f9081526101306020526040902060040180548390039055612909838361271b565b5f612714836001600160a01b0384166135c0565b5f54610100900460ff166131015760405162461bcd60e51b8152600401610fb1906144b1565b565b5f54610100900460ff166131295760405162461bcd60e51b8152600401610fb1906144b1565b610fc482826136a3565b5f54610100900460ff166131595760405162461bcd60e51b8152600401610fb1906144b1565b61285781604051806040016040528060018152602001603160f81b8152506136e2565b6040516001600160a01b03808516602483015283166044820152606481018290526129099085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261372f565b606060cb805461061490614370565b606060cc805461061490614370565b80158061327d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015613257573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061327b919061449a565b155b6132e85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610fb1565b6040516001600160a01b038316602482015260448101829052610eeb90849063095ea7b360e01b906064016131b0565b6001600160a01b0381165f90815260fd602052604090208054600181018255905b50919050565b5f6105ff61334b612b3d565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f61337a87878787613802565b91509150613387816138bf565b5090505b949350505050565b5f825f0182815481106133a8576133a86143a2565b905f5260205f200154905092915050565b6133c38282611bb8565b610fc4576133d081613a08565b6133db836020613a1a565b6040516020016133ec9291906144fc565b60408051601f198184030181529082905262461bcd60e51b8252610fb191600401613dc8565b5f81815260018301602052604081205461345757508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556105ff565b505f6105ff565b5f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f613488613baf565b613490613c07565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b0382166135275760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610fb1565b8060995f8282546135389190614487565b90915550506001600160a01b0382165f818152609760209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6040516001600160a01b038316602482015260448101829052610eeb90849063a9059cbb60e01b906064016131b0565b5f818152600183016020526040812054801561369a575f6135e2600183614437565b85549091505f906135f590600190614437565b9050818114613654575f865f018281548110613613576136136143a2565b905f5260205f200154905080875f018481548110613633576136336143a2565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061366557613665614570565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506105ff565b5f9150506105ff565b5f54610100900460ff166136c95760405162461bcd60e51b8152600401610fb1906144b1565b609a6136d583826145d1565b50609b610eeb82826145d1565b5f54610100900460ff166137085760405162461bcd60e51b8152600401610fb1906144b1565b60cb61371483826145d1565b5060cc61372182826145d1565b50505f60c981905560ca5550565b5f613783826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c379092919063ffffffff16565b905080515f14806137a35750808060200190518101906137a391906143b6565b610eeb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610fb1565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561383757505f905060036138b6565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613888573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b0381166138b0575f600192509250506138b6565b91505f90505b94509492505050565b5f8160048111156138d2576138d261468c565b036138da5750565b60018160048111156138ee576138ee61468c565b0361393b5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610fb1565b600281600481111561394f5761394f61468c565b0361399c5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610fb1565b60038160048111156139b0576139b061468c565b036128575760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610fb1565b60606105ff6001600160a01b03831660145b60605f613a28836002614401565b613a33906002614487565b6001600160401b03811115613a4a57613a4a613e18565b6040519080825280601f01601f191660200182016040528015613a74576020820181803683370190505b509050600360fc1b815f81518110613a8e57613a8e6143a2565b60200101906001600160f81b03191690815f1a905350600f60fb1b81600181518110613abc57613abc6143a2565b60200101906001600160f81b03191690815f1a9053505f613ade846002614401565b613ae9906001614487565b90505b6001811115613b60576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613b1d57613b1d6143a2565b1a60f81b828281518110613b3357613b336143a2565b60200101906001600160f81b03191690815f1a90535060049490941c93613b59816146a0565b9050613aec565b5083156127145760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610fb1565b5f80613bb96131e7565b805190915015613bd0578051602090910120919050565b60c9548015613bdf5792915050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709250505090565b5f80613c116131f6565b805190915015613c28578051602090910120919050565b60ca548015613bdf5792915050565b606061338b84845f85855f80866001600160a01b03168587604051613c5c91906146b5565b5f6040518083038185875af1925050503d805f8114613c96576040519150601f19603f3d011682016040523d82523d5f602084013e613c9b565b606091505b5091509150613cac87838387613cb7565b979650505050505050565b60608315613d255782515f03613d1e576001600160a01b0385163b613d1e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fb1565b508161338b565b61338b8383815115613d3a5781518083602001fd5b8060405162461bcd60e51b8152600401610fb19190613dc8565b5f60208284031215613d64575f80fd5b81356001600160e01b031981168114612714575f80fd5b5f5b83811015613d95578181015183820152602001613d7d565b50505f910152565b5f8151808452613db4816020860160208601613d7b565b601f01601f19169290920160200192915050565b602081525f6127146020830184613d9d565b6001600160a01b0381168114612857575f80fd5b5f8060408385031215613dff575f80fd5b8235613e0a81613dda565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715613e5457613e54613e18565b604052919050565b5f6001600160401b03821115613e7457613e74613e18565b5060051b60200190565b5f805f60608486031215613e90575f80fd5b83359250602080850135613ea381613dda565b925060408501356001600160401b03811115613ebd575f80fd5b8501601f81018713613ecd575f80fd5b8035613ee0613edb82613e5c565b613e2c565b81815260059190911b82018301908381019089831115613efe575f80fd5b928401925b82841015613f1c57833582529284019290840190613f03565b80955050505050509250925092565b5f8151808452602080850194508084015f5b83811015613f625781516001600160a01b031687529582019590820190600101613f3d565b509495945050505050565b5f8151808452602080850194508084015f5b83811015613f6257815187529582019590820190600101613f7f565b606081525f613fad6060830186613f2b565b8281036020840152613fbf8186613f6d565b90508281036040840152613fd38185613f6d565b9695505050505050565b5f6020808385031215613fee575f80fd5b82356001600160401b03811115614003575f80fd5b8301601f81018513614013575f80fd5b8035614021613edb82613e5c565b81815260059190911b8201830190838101908783111561403f575f80fd5b928401925b82841015613cac57833561405781613dda565b82529284019290840190614044565b5f805f60608486031215614078575f80fd5b833561408381613dda565b9250602084013561409381613dda565b929592945050506040919091013590565b5f602082840312156140b4575f80fd5b5035919050565b5f80604083850312156140cc575f80fd5b8235915060208301356140de81613dda565b809150509250929050565b5f805f606084860312156140fb575f80fd5b833561410681613dda565b925060208401359150604084013561411d81613dda565b809150509250925092565b5f805f806080858703121561413b575f80fd5b843561414681613dda565b935060208501359250604085013561415d81613dda565b9396929550929360600135925050565b5f82601f83011261417c575f80fd5b81356001600160401b0381111561419557614195613e18565b6141a8601f8201601f1916602001613e2c565b8181528460208386010111156141bc575f80fd5b816020850160208301375f918101602001919091529392505050565b5f80604083850312156141e9575f80fd5b82356001600160401b03808211156141ff575f80fd5b61420b8683870161416d565b93506020850135915080821115614220575f80fd5b5061422d8582860161416d565b9150509250929050565b5f60208284031215614247575f80fd5b813561271481613dda565b60ff60f81b8816815260e060208201525f61427060e0830189613d9d565b82810360408401526142828189613d9d565b606084018890526001600160a01b038716608085015260a0840186905283810360c085015290506142b38185613f6d565b9a9950505050505050505050565b602081525f6127146020830184613f2b565b5f805f805f805f60e0888a0312156142e9575f80fd5b87356142f481613dda565b9650602088013561430481613dda565b95506040880135945060608801359350608088013560ff81168114614327575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215614355575f80fd5b823561436081613dda565b915060208301356140de81613dda565b600181811c9082168061438457607f821691505b60208210810361333957634e487b7160e01b5f52602260045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f602082840312156143c6575f80fd5b81518015158114612714575f80fd5b634e487b7160e01b5f52601160045260245ffd5b5f600182016143fa576143fa6143d5565b5060010190565b80820281158282048414176105ff576105ff6143d5565b5f8261443257634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156105ff576105ff6143d5565b5f806040838503121561445b575f80fd5b505080516020909101519092909150565b5f6020828403121561447c575f80fd5b815161271481613dda565b808201808211156105ff576105ff6143d5565b5f602082840312156144aa575f80fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351614533816017850160208801613d7b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614564816028840160208801613d7b565b01602801949350505050565b634e487b7160e01b5f52603160045260245ffd5b601f821115610eeb575f81815260208120601f850160051c810160208610156145aa5750805b601f850160051c820191505b818110156145c9578281556001016145b6565b505050505050565b81516001600160401b038111156145ea576145ea613e18565b6145fe816145f88454614370565b84614584565b602080601f831160018114614631575f841561461a5750858301515b5f19600386901b1c1916600185901b1785556145c9565b5f85815260208120601f198616915b8281101561465f57888601518255948401946001909101908401614640565b508582101561467c57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52602160045260245ffd5b5f816146ae576146ae6143d5565b505f190190565b5f82516146c6818460208701613d7b565b919091019291505056fea2646970667358221220d77802c51bd15bb0f78491f0cfc521b857a125cd9fc8aa4a0398d7adff48a64564736f6c63430008140033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.