Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 9 from a total of 9 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Transfer Ownersh... | 18571602 | 444 days ago | IN | 0 ETH | 0.00123593 | ||||
New Curve | 18567221 | 444 days ago | IN | 0 ETH | 0.29446794 | ||||
New Curve | 18567220 | 444 days ago | IN | 0 ETH | 0.26453683 | ||||
New Curve | 18567220 | 444 days ago | IN | 0 ETH | 0.26453817 | ||||
New Curve | 18567220 | 444 days ago | IN | 0 ETH | 0.26449928 | ||||
New Curve | 18567179 | 444 days ago | IN | 0 ETH | 0.24699857 | ||||
New Curve | 18567179 | 444 days ago | IN | 0 ETH | 0.24693621 | ||||
New Curve | 18567179 | 444 days ago | IN | 0 ETH | 0.24691319 | ||||
New Curve | 18567019 | 444 days ago | IN | 0 ETH | 0.28738314 |
Latest 8 internal transactions
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
18567221 | 444 days ago | Contract Creation | 0 ETH | |||
18567220 | 444 days ago | Contract Creation | 0 ETH | |||
18567220 | 444 days ago | Contract Creation | 0 ETH | |||
18567220 | 444 days ago | Contract Creation | 0 ETH | |||
18567179 | 444 days ago | Contract Creation | 0 ETH | |||
18567179 | 444 days ago | Contract Creation | 0 ETH | |||
18567179 | 444 days ago | Contract Creation | 0 ETH | |||
18567019 | 444 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
CurveFactoryV3
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is disstributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "./Curve.sol"; import "./AssimilatorFactory.sol"; import "./assimilators/AssimilatorV3.sol"; import "./interfaces/ICurveFactory.sol"; import "./interfaces/IAssimilatorFactory.sol"; import "./interfaces/IConfig.sol"; contract CurveFactoryV3 is ICurveFactory, Ownable { using Address for address; IAssimilatorFactory public immutable assimilatorFactory; IConfig public config; event NewCurve(address indexed caller, bytes32 indexed id, address indexed curve); mapping(bytes32 => address) public curves; mapping(address => bool) public isDFXCurve; address public immutable wETH; struct CurveIDPair { bytes32 curveId; bytes32 curveIdReversed; } struct CurveInfo { string _name; string _symbol; address _baseCurrency; address _quoteCurrency; uint256 _baseWeight; uint256 _quoteWeight; IOracle _baseOracle; IOracle _quoteOracle; uint256 _alpha; uint256 _beta; uint256 _feeAtHalt; uint256 _epsilon; uint256 _lambda; } constructor(address _assimFactory, address _config, address _weth) { require(_assimFactory.isContract(), "invalid-assimFactory"); assimilatorFactory = IAssimilatorFactory(_assimFactory); require(_config.isContract(), "invalid-config"); config = IConfig(_config); wETH = _weth; } function getProtocolFee() external view virtual override returns (int128) { return config.getProtocolFee(); } function getProtocolTreasury() public view virtual override returns (address) { return config.getProtocolTreasury(); } function getCurve(address _baseCurrency, address _quoteCurrency) external view returns (address payable) { bytes32 curveId = keccak256(abi.encode(_baseCurrency, _quoteCurrency)); return payable(curves[curveId]); } function newCurve(CurveInfo memory _info) public returns (Curve) { require(_info._quoteCurrency != address(0), "quote-currency-zero-address"); require(_info._baseCurrency != _info._quoteCurrency, "quote-base-currencies-same"); require((_info._baseWeight + _info._quoteWeight) == 1e18, "invalid-weights"); uint256 quoteDec = IERC20Metadata(_info._quoteCurrency).decimals(); uint256 baseDec = IERC20Metadata(_info._baseCurrency).decimals(); CurveIDPair memory idPair = generateCurveID(_info._baseCurrency, _info._quoteCurrency); if (curves[idPair.curveId] != address(0) || curves[idPair.curveIdReversed] != address(0)) revert("pair-exists"); AssimilatorV3 _baseAssim; _baseAssim = (assimilatorFactory.getAssimilator(_info._baseCurrency, _info._quoteCurrency)); if (address(_baseAssim) == address(0)) { _baseAssim = assimilatorFactory.newAssimilator(_info._quoteCurrency, _info._baseOracle, _info._baseCurrency, baseDec); } AssimilatorV3 _quoteAssim; _quoteAssim = (assimilatorFactory.getAssimilator(_info._quoteCurrency, _info._baseCurrency)); if (address(_quoteAssim) == address(0)) { _quoteAssim = assimilatorFactory.newAssimilator( _info._baseCurrency, _info._quoteOracle, _info._quoteCurrency, quoteDec ); } address[] memory _assets = new address[](10); uint256[] memory _assetWeights = new uint256[](2); // Base Currency _assets[0] = _info._baseCurrency; _assets[1] = address(_baseAssim); _assets[2] = _info._baseCurrency; _assets[3] = address(_baseAssim); _assets[4] = _info._baseCurrency; // Quote Currency (typically USDC) _assets[5] = _info._quoteCurrency; _assets[6] = address(_quoteAssim); _assets[7] = _info._quoteCurrency; _assets[8] = address(_quoteAssim); _assets[9] = _info._quoteCurrency; // Weights _assetWeights[0] = _info._baseWeight; _assetWeights[1] = _info._quoteWeight; // New curve Curve curve = new Curve( _info._name, _info._symbol, _assets, _assetWeights, address(this), address(config) ); curve.setParams(_info._alpha, _info._beta, _info._feeAtHalt, _info._epsilon, _info._lambda); curves[idPair.curveId] = address(curve); curves[idPair.curveIdReversed] = address(curve); isDFXCurve[address(curve)] = true; emit NewCurve(msg.sender, idPair.curveId, address(curve)); return curve; } function generateCurveID(address _base, address _quote) private pure returns (CurveIDPair memory) { CurveIDPair memory pair; pair.curveId = keccak256(abi.encode(_base, _quote)); pair.curveIdReversed = keccak256(abi.encode(_quote, _base)); return pair; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * 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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return 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 (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IWeth.sol"; import "./interfaces/IAssimilatorFactory.sol"; import "./lib/ABDKMath64x64.sol"; import "./lib/FullMath.sol"; import "./lib/NoDelegateCall.sol"; import "./Orchestrator.sol"; import "./ProportionalLiquidity.sol"; import "./Swaps.sol"; import "./ViewLiquidity.sol"; import "./Storage.sol"; import "./interfaces/ICurveFactory.sol"; import "./interfaces/IAssimilator.sol"; import "./interfaces/ICurve.sol"; import "./interfaces/IConfig.sol"; import "./Structs.sol"; library Curves { using ABDKMath64x64 for int128; event Approval(address indexed _owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function add(uint256 x, uint256 y, string memory errorMessage) private pure returns (uint256 z) { require((z = x + y) >= x, errorMessage); } function sub(uint256 x, uint256 y, string memory errorMessage) private pure returns (uint256 z) { require((z = x - y) <= x, errorMessage); } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(Storage.Curve storage curve, address recipient, uint256 amount) external returns (bool) { _transfer(curve, msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(Storage.Curve storage curve, address spender, uint256 amount) external returns (bool) { _approve(curve, msg.sender, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount` */ function transferFrom(Storage.Curve storage curve, address sender, address recipient, uint256 amount) external returns (bool) { _transfer(curve, sender, recipient, amount); _approve( curve, sender, msg.sender, sub(curve.allowances[sender][msg.sender], amount, "Curve/insufficient-allowance") ); 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(Storage.Curve storage curve, address spender, uint256 addedValue) external returns (bool) { _approve( curve, msg.sender, spender, add(curve.allowances[msg.sender][spender], addedValue, "Curve/approval-overflow") ); 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(Storage.Curve storage curve, address spender, uint256 subtractedValue) external returns (bool) { _approve( curve, msg.sender, spender, sub(curve.allowances[msg.sender][spender], subtractedValue, "Curve/allowance-decrease-underflow") ); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is public function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(Storage.Curve storage curve, address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); curve.balances[sender] = sub(curve.balances[sender], amount, "Curve/insufficient-balance"); curve.balances[recipient] = add(curve.balances[recipient], amount, "Curve/transfer-overflow"); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `_owner`s tokens. * * This is public 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(Storage.Curve storage curve, address _owner, address spender, uint256 amount) private { require(_owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); curve.allowances[_owner][spender] = amount; emit Approval(_owner, spender, amount); } } contract Curve is Storage, NoDelegateCall, ICurve { using SafeMath for uint256; using ABDKMath64x64 for int128; using SafeERC20 for IERC20; address private curveFactory; address private immutable wETH; IConfig private config; event Approval(address indexed _owner, address indexed spender, uint256 value); event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda); event AssetIncluded(address indexed numeraire, address indexed reserve, uint256 weight); event AssimilatorIncluded( address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator ); event PartitionRedeemed(address indexed token, address indexed redeemer, uint256 value); event OwnershipTransfered(address indexed previousOwner, address indexed newOwner); event FrozenSet(bool isFrozen); event EmergencyAlarm(bool isEmergency); event Trade( address indexed trader, address indexed origin, address indexed target, uint256 originAmount, uint256 targetAmount, int128 rawProtocolFee ); event Transfer(address indexed from, address indexed to, uint256 value); modifier onlyOwner() { require(msg.sender == owner || msg.sender == config.getProtocolTreasury(), "Curve/caller-is-not-owner"); _; } modifier nonReentrant() { require(notEntered, "Curve/re-entered"); notEntered = false; _; notEntered = true; } modifier transactable() { require(!frozen, "Curve/frozen-only-allowing-proportional-withdraw"); _; } modifier isEmergency() { require(emergency, "Curve/emergency-only-allowing-emergency-proportional-withdraw"); _; } modifier isNotEmergency() { require(!emergency, "Curve/emergency-only-allowing-emergency-proportional-withdraw"); _; } modifier deadline(uint256 _deadline) { require(block.timestamp < _deadline, "Curve/tx-deadline-passed"); _; } modifier globallyTransactable() { require(!config.getGlobalFrozenState(), "Curve/frozen-globally-only-allowing-proportional-withdraw"); _; } constructor( string memory _name, string memory _symbol, address[] memory _assets, uint256[] memory _assetWeights, address _factory, address _config ) { require(_factory != address(0), "Curve/curve factory zero address!"); owner = msg.sender; name = _name; symbol = _symbol; curveFactory = _factory; config = IConfig(_config); emit OwnershipTransfered(address(0), msg.sender); wETH = ICurveFactory(_factory).wETH(); Orchestrator.initialize(curve, numeraires, reserves, derivatives, _assets, _assetWeights); } /// @notice sets the parameters for the pool /// @param _alpha the value for alpha (halt threshold) must be less than or equal to 1 and greater than 0 /// @param _beta the value for beta must be less than alpha and greater than 0 /// @param _feeAtHalt the maximum value for the fee at the halt point /// @param _epsilon the base fee for the pool /// @param _lambda the value for lambda must be less than or equal to 1 and greater than zero function setParams(uint256 _alpha, uint256 _beta, uint256 _feeAtHalt, uint256 _epsilon, uint256 _lambda) external onlyOwner { Orchestrator.setParams(curve, _alpha, _beta, _feeAtHalt, _epsilon, _lambda); } function setAssimilator(address _baseCurrency, address _baseAssim, address _quoteCurrency, address _quoteAssim) external onlyOwner { Orchestrator.setAssimilator(curve, _baseCurrency, _baseAssim, _quoteCurrency, _quoteAssim); } /// @notice excludes an assimilator from the curve /// @param _derivative the address of the assimilator to exclude function excludeDerivative(address _derivative) external onlyOwner { for (uint256 i = 0; i < numeraires.length; i++) { if (_derivative == numeraires[i]) { revert("Curve/cannot-delete-numeraire"); } if (_derivative == reserves[i]) { revert("Curve/cannot-delete-reserve"); } } delete curve.assimilators[_derivative]; } /// @notice view the current parameters of the curve /// @return alpha_ the current alpha value /// beta_ the current beta value /// delta_ the current delta value /// epsilon_ the current epsilon value /// lambda_ the current lambda value /// omega_ the current omega value function viewCurve() external view returns (uint256 alpha_, uint256 beta_, uint256 delta_, uint256 epsilon_, uint256 lambda_) { return Orchestrator.viewCurve(curve); } function setEmergency(bool _emergency) external onlyOwner { emit EmergencyAlarm(_emergency); emergency = _emergency; } function setFrozen(bool _toFreezeOrNotToFreeze) external onlyOwner { emit FrozenSet(_toFreezeOrNotToFreeze); frozen = _toFreezeOrNotToFreeze; } function transferOwnership(address _newOwner) external onlyOwner { require(_newOwner != address(0), "Curve/new-owner-cannot-be-zero-address"); emit OwnershipTransfered(owner, _newOwner); owner = _newOwner; } /// @notice swap a dynamic origin amount for a fixed target amount /// @param _origin the address of the origin /// @param _target the address of the target /// @param _originAmount the origin amount /// @param _minTargetAmount the minimum target amount /// @param _deadline deadline in block number after which the trade will not execute /// @return targetAmount_ the amount of target that has been swapped for the origin amount function originSwap( address _origin, address _target, uint256 _originAmount, uint256 _minTargetAmount, uint256 _deadline ) external deadline(_deadline) globallyTransactable transactable noDelegateCall isNotEmergency nonReentrant returns (uint256 targetAmount_) { OriginSwapData memory _swapData; _swapData._origin = _origin; _swapData._target = _target; _swapData._originAmount = _originAmount; _swapData._recipient = msg.sender; _swapData._curveFactory = curveFactory; uint256 balanceBefore = IERC20(_target).balanceOf(_swapData._recipient); Swaps.originSwap(curve, _swapData, false); uint256 balanceAfter = IERC20(_target).balanceOf(_swapData._recipient); targetAmount_ = balanceAfter - balanceBefore; require(targetAmount_ >= _minTargetAmount, "Curve/below-min-target-amount"); } function originSwapFromETH(address _target, uint256 _minTargetAmount, uint256 _deadline) external payable deadline(_deadline) globallyTransactable transactable noDelegateCall isNotEmergency nonReentrant returns (uint256 targetAmount_) { // first convert coming ETH to WETH & send wrapped amount to user back IWETH(wETH).deposit{value: msg.value}(); IERC20(wETH).safeTransferFrom(address(this), msg.sender, msg.value); OriginSwapData memory _swapData; _swapData._origin = wETH; _swapData._target = _target; _swapData._originAmount = msg.value; _swapData._recipient = msg.sender; _swapData._curveFactory = curveFactory; targetAmount_ = Swaps.originSwap(curve, _swapData, false); require(targetAmount_ >= _minTargetAmount, "Curve/below-min-target-amount"); } function originSwapToETH(address _origin, uint256 _originAmount, uint256 _minTargetAmount, uint256 _deadline) external deadline(_deadline) globallyTransactable transactable noDelegateCall isNotEmergency nonReentrant returns (uint256 targetAmount_) { OriginSwapData memory _swapData; _swapData._origin = _origin; _swapData._target = wETH; _swapData._originAmount = _originAmount; _swapData._recipient = msg.sender; _swapData._curveFactory = curveFactory; targetAmount_ = Swaps.originSwap(curve, _swapData, true); require(targetAmount_ >= _minTargetAmount, "Curve/below-min-target-amount"); } /// @notice view how much target amount a fixed origin amount will swap for /// @param _origin the address of the origin /// @param _target the address of the target /// @param _originAmount the origin amount /// @return targetAmount_ the target amount that would have been swapped for the origin amount function viewOriginSwap(address _origin, address _target, uint256 _originAmount) external view globallyTransactable transactable returns (uint256 targetAmount_) { targetAmount_ = Swaps.viewOriginSwap(curve, _origin, _target, _originAmount); } /// @notice swap a dynamic origin amount for a fixed target amount /// @param _origin the address of the origin /// @param _target the address of the target /// @param _maxOriginAmount the maximum origin amount /// @param _targetAmount the target amount /// @param _deadline deadline in block number after which the trade will not execute /// @return originAmount_ the amount of origin that has been swapped for the target function targetSwap( address _origin, address _target, uint256 _maxOriginAmount, uint256 _targetAmount, uint256 _deadline ) external deadline(_deadline) globallyTransactable transactable noDelegateCall isNotEmergency nonReentrant returns (uint256 originAmount_) { TargetSwapData memory _swapData; _swapData._origin = _origin; _swapData._target = _target; _swapData._targetAmount = _targetAmount; _swapData._recipient = msg.sender; _swapData._curveFactory = curveFactory; originAmount_ = Swaps.targetSwap(curve, _swapData); require(originAmount_ <= _maxOriginAmount, "Curve/above-max-origin-amount"); } /// @notice view how much of the origin currency the target currency will take /// @param _origin the address of the origin /// @param _target the address of the target /// @param _targetAmount the target amount /// @return originAmount_ the amount of target that has been swapped for the origin function viewTargetSwap(address _origin, address _target, uint256 _targetAmount) external view globallyTransactable transactable returns (uint256 originAmount_) { originAmount_ = Swaps.viewTargetSwap(curve, _origin, _target, _targetAmount); } // deposit erc20 tokens function deposit( uint256 _deposit, uint256 _minQuoteAmount, uint256 _minBaseAmount, uint256 _maxQuoteAmount, uint256 _maxBaseAmount, uint256 _deadline ) external deadline(_deadline) globallyTransactable transactable nonReentrant noDelegateCall isNotEmergency returns (uint256 curvesMinted_, uint256[] memory deposits_) { require(_deposit > 0, "Curve/deposit_below_zero"); (curvesMinted_, deposits_) = viewDeposit(_deposit); DepositData memory _depositData; _depositData.deposits = _deposit; _depositData.minQuote = _minQuoteAmount; _depositData.minBase = _minBaseAmount; _depositData.maxQuote = _maxQuoteAmount; _depositData.maxBase = _maxBaseAmount; _depositData.baseAmt = deposits_[0]; _depositData.quoteAmt = deposits_[1]; _depositData.token0 = reserves[0]; _depositData.token0Bal = IERC20(reserves[0]).balanceOf(address(this)); _depositData.token1Bal = IERC20(reserves[1]).balanceOf(address(this)); (curvesMinted_, deposits_) = ProportionalLiquidity.proportionalDeposit(curve, _depositData); return (curvesMinted_, deposits_); } // deposit in ETH & erc20 pair function depositETH( uint256 _deposit, uint256 _minQuoteAmount, uint256 _minBaseAmount, uint256 _maxQuoteAmount, uint256 _maxBaseAmount, uint256 _deadline ) external payable deadline(_deadline) globallyTransactable transactable nonReentrant noDelegateCall isNotEmergency returns (uint256 curvesMinted_, uint256[] memory deposits_) { require(_deposit > 0, "Curve/deposit_below_zero"); (curvesMinted_, deposits_) = viewDeposit(_deposit); IWETH(wETH).deposit{value: msg.value}(); IERC20(wETH).safeTransferFrom(address(this), msg.sender, msg.value); DepositData memory _depositData; _depositData.deposits = _deposit; _depositData.minQuote = _minQuoteAmount; _depositData.minBase = _minBaseAmount; _depositData.maxQuote = _maxQuoteAmount; _depositData.maxBase = _maxBaseAmount; _depositData.baseAmt = deposits_[0]; _depositData.quoteAmt = deposits_[1]; _depositData.token0 = reserves[0]; _depositData.token0Bal = IERC20(reserves[0]).balanceOf(address(this)); _depositData.token1Bal = IERC20(reserves[1]).balanceOf(address(this)); (curvesMinted_, deposits_) = ProportionalLiquidity.proportionalDeposit(curve, _depositData); uint256 remainder = 0; if (IAssimilator(curve.assets[0].addr).underlyingToken() == wETH) { remainder = msg.value - deposits_[0]; } else if (IAssimilator(curve.assets[1].addr).underlyingToken() == wETH) { remainder = msg.value - deposits_[1]; } else { revert("Curve/Deposit ETH failed"); } // now need to determine which is wETH if (remainder > 0) { IERC20(wETH).safeTransferFrom(msg.sender, address(this), remainder); IWETH(wETH).withdraw(remainder); (bool success,) = msg.sender.call{value: remainder}(""); require(success, "Curve/ETH transfer failed"); } return (curvesMinted_, deposits_); } /// @notice view deposits and curves minted a given deposit would return /// @param _deposit the full amount of stablecoins you want to deposit. Divided evenly according to the /// prevailing proportions of the numeraire assets of the pool /// @return (the amount of curves you receive in return for your deposit, /// the amount deposited for each numeraire) function viewDeposit(uint256 _deposit) public view globallyTransactable transactable returns (uint256, uint256[] memory) { // curvesToMint_, depositsToMake_ uint256 deposit_; uint256[] memory outs_ = new uint256[](2); (deposit_, outs_) = ProportionalLiquidity.viewProportionalDeposit(curve, _deposit); uint256 ratio = (_deposit * 1e36) / deposit_; outs_[0] = (outs_[0] * ratio) / 1e36; outs_[1] = (outs_[1] * ratio) / 1e36; return (_deposit, outs_); } /// @notice Emergency withdraw tokens in the event that the oracle somehow bugs out /// and no one is able to withdraw due to the invariant check /// @param _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the /// numeraire assets of the pool /// @return withdrawals_ the amonts of numeraire assets withdrawn from the pool function emergencyWithdraw(uint256 _curvesToBurn, uint256 _deadline) external isEmergency deadline(_deadline) nonReentrant noDelegateCall returns (uint256[] memory withdrawals_) { return ProportionalLiquidity.proportionalWithdraw(curve, _curvesToBurn, false); } /// @notice withdrawas amount of curve tokens from the the pool equally from the numeraire assets of the pool with no slippage /// @param _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the /// numeraire assets of the pool /// @return withdrawals_ the amonts of numeraire assets withdrawn from the pool function withdraw(uint256 _curvesToBurn, uint256 _deadline) external deadline(_deadline) nonReentrant noDelegateCall isNotEmergency returns (uint256[] memory withdrawals_) { return ProportionalLiquidity.proportionalWithdraw(curve, _curvesToBurn, false); } /// @notice withdrawas amount of curve tokens from the the pool equally from the numeraire assets of the pool with no slippage, WETH is unwrapped to ETH /// @param _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the /// numeraire assets of the pool /// @return withdrawals_ the amonts of numeraire assets withdrawn from the pool function withdrawETH(uint256 _curvesToBurn, uint256 _deadline) external deadline(_deadline) nonReentrant noDelegateCall isNotEmergency returns (uint256[] memory withdrawals_) { return ProportionalLiquidity.proportionalWithdraw(curve, _curvesToBurn, true); } /// @notice views the withdrawal information from the pool /// @param _curvesToBurn the full amount you want to withdraw from the pool which will be withdrawn from evenly amongst the /// numeraire assets of the pool /// @return the amonnts of numeraire assets withdrawn from the pool function viewWithdraw(uint256 _curvesToBurn) external view globallyTransactable transactable returns (uint256[] memory) { return ProportionalLiquidity.viewProportionalWithdraw(curve, _curvesToBurn); } function getWeth() external view override returns (address) { return wETH; } function supportsInterface(bytes4 _interface) public pure returns (bool supports_) { supports_ = this.supportsInterface.selector == _interface // erc165 || bytes4(0x7f5828d0) == _interface // eip173 || bytes4(0x36372b07) == _interface; // erc20 } /// @notice transfers curve tokens /// @param _recipient the address of where to send the curve tokens /// @param _amount the amount of curve tokens to send /// @return success_ the success bool of the call function transfer(address _recipient, uint256 _amount) public nonReentrant noDelegateCall isNotEmergency returns (bool success_) { success_ = Curves.transfer(curve, _recipient, _amount); } /// @notice transfers curve tokens from one address to another address /// @param _sender the account from which the curve tokens will be sent /// @param _recipient the account to which the curve tokens will be sent /// @param _amount the amount of curve tokens to transfer /// @return success_ the success bool of the call function transferFrom(address _sender, address _recipient, uint256 _amount) public nonReentrant noDelegateCall isNotEmergency returns (bool success_) { success_ = Curves.transferFrom(curve, _sender, _recipient, _amount); } /// @notice approves a user to spend curve tokens on their behalf /// @param _spender the account to allow to spend from msg.sender /// @param _amount the amount to specify the spender can spend /// @return success_ the success bool of this call function approve(address _spender, uint256 _amount) public nonReentrant noDelegateCall returns (bool success_) { success_ = Curves.approve(curve, _spender, _amount); } /// @notice view the curve token balance of a given account /// @param _account the account to view the balance of /// @return balance_ the curve token ballance of the given account function balanceOf(address _account) public view returns (uint256 balance_) { balance_ = curve.balances[_account]; } /// @notice views the total curve supply of the pool /// @return totalSupply_ the total supply of curve tokens function totalSupply() public view returns (uint256 totalSupply_) { totalSupply_ = curve.totalSupply; } /// @notice views the total allowance one address has to spend from another address /// @param _owner the address of the owner /// @param _spender the address of the spender /// @return allowance_ the amount the owner has allotted the spender function allowance(address _owner, address _spender) public view returns (uint256 allowance_) { allowance_ = curve.allowances[_owner][_spender]; } /// @notice views the total amount of liquidity in the curve in numeraire value and format - 18 decimals /// @return total_ the total value in the curve /// @return individual_ the individual values in the curve function liquidity() public view returns (uint256 total_, uint256[] memory individual_) { return ViewLiquidity.viewLiquidity(curve); } /// @notice view the assimilator address for a derivative /// @return assimilator_ the assimilator address function assimilator(address _derivative) public view returns (address assimilator_) { assimilator_ = curve.assimilators[_derivative].addr; } receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/Address.sol"; import "./assimilators/AssimilatorV3.sol"; import "./interfaces/IAssimilatorFactory.sol"; import "./interfaces/IOracle.sol"; import "./interfaces/ICurveFactory.sol"; import "./interfaces/IConfig.sol"; contract AssimilatorFactory is IAssimilatorFactory { using Address for address; event NewAssimilator( address indexed caller, bytes32 indexed id, address indexed assimilator, address oracle, address token, address quote ); event AssimilatorRevoked(address indexed caller, bytes32 indexed id, address indexed assimilator); event CurveFactoryUpdated(address indexed caller, address indexed curveFactory); mapping(bytes32 => AssimilatorV3) public assimilators; address public curveFactory; address public config; modifier onlyCurveFactoryOrOwner() { require(msg.sender == curveFactory || msg.sender == owner(), "unauthorized"); _; } modifier onlyOwner() { require(msg.sender == IConfig(config).getProtocolTreasury(), "unauthorized"); _; } constructor(address _config) { require(_config.isContract(), "config-invalid!"); config = _config; } function owner() public view returns (address) { return IConfig(config).getProtocolTreasury(); } function setCurveFactory(address _curveFactory) external onlyOwner { require(_curveFactory != address(0), "curve-factory-invalid!"); curveFactory = _curveFactory; emit CurveFactoryUpdated(msg.sender, curveFactory); } function getAssimilator(address _token, address _quote) external view override returns (AssimilatorV3) { bytes32 assimilatorID = keccak256(abi.encode(_token, _quote)); return assimilators[assimilatorID]; } function newAssimilator(address _quote, IOracle _oracle, address _token, uint256 _tokenDecimals) external override onlyCurveFactoryOrOwner returns (AssimilatorV3) { require(curveFactory != address(0), "curve-factory-not-set"); bytes32 assimilatorID = keccak256(abi.encode(_token, _quote)); if (address(assimilators[assimilatorID]) != address(0)) { revert("assimilator-already-exists"); } AssimilatorV3 assimilator = new AssimilatorV3( ICurveFactory(curveFactory).wETH(), _quote, _oracle, _token, _tokenDecimals, IOracle(_oracle).decimals() ); assimilators[assimilatorID] = assimilator; emit NewAssimilator(msg.sender, assimilatorID, address(assimilator), address(_oracle), _token, _quote); return assimilator; } function revokeAssimilator(address _token, address _quote) external onlyOwner { bytes32 assimilatorID = keccak256(abi.encode(_token, _quote)); address _assimAddress = address(assimilators[assimilatorID]); assimilators[assimilatorID] = AssimilatorV3(address(0)); emit AssimilatorRevoked(msg.sender, assimilatorID, address(_assimAddress)); } }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../lib/ABDKMath64x64.sol"; import "../interfaces/IAssimilator.sol"; import "../interfaces/IOracle.sol"; import "../interfaces/IWeth.sol"; contract AssimilatorV3 is IAssimilator { using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; using SafeMath for uint256; using SafeERC20 for IERC20Metadata; IERC20Metadata public immutable pairToken; IOracle public immutable oracle; IERC20Metadata public immutable token; uint256 public immutable oracleDecimals; uint256 public immutable tokenDecimals; uint256 public immutable pairTokenDecimals; address public immutable wETH; // solhint-disable-next-line constructor( address _wETH, address _pairToken, IOracle _oracle, address _token, uint256 _tokenDecimals, uint256 _oracleDecimals ) { wETH = _wETH; oracle = _oracle; token = IERC20Metadata(_token); oracleDecimals = _oracleDecimals; tokenDecimals = _tokenDecimals; pairToken = IERC20Metadata(_pairToken); pairTokenDecimals = pairToken.decimals(); } function underlyingToken() external view override returns (address) { return address(token); } function getWeth() external view override returns (address) { return wETH; } function getRate() public view override returns (uint256) { (, int256 price,,,) = oracle.latestRoundData(); require(price >= 0, "invalid price oracle"); return uint256(price); } // takes raw eurs amount, transfers it in, calculates corresponding numeraire amount and returns it function intakeRawAndGetBalance(uint256 _amount) external payable override returns (int128 amount_, int128 balance_) { require(_amount > 0, "zero amount!"); uint256 balanceBefore = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 balanceAfter = token.balanceOf(address(this)); uint256 diff = _amount - (balanceAfter - balanceBefore); if (diff > 0) { intakeMoreFromFoT(_amount, diff); } uint256 _balance = token.balanceOf(address(this)); uint256 _rate = getRate(); balance_ = ((_balance * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); amount_ = ((_amount * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); } // takes raw eurs amount, transfers it in, calculates corresponding numeraire amount and returns it function intakeRaw(uint256 _amount) external payable override returns (int128 amount_) { require(_amount > 0, "zero amount!"); uint256 balanceBefore = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), _amount); uint256 balanceAfter = token.balanceOf(address(this)); uint256 diff = _amount - (balanceAfter - balanceBefore); if (diff > 0) { intakeMoreFromFoT(_amount, diff); } uint256 _rate = getRate(); amount_ = ((_amount * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); } // takes a numeraire amount, calculates the raw amount of eurs, tr ansfers it in and returns the corresponding raw amount function intakeNumeraire(int128 _amount) external payable override returns (uint256 amount_) { uint256 _rate = getRate(); // improve precision amount_ = Math.ceilDiv(_amount.mulu(10 ** (tokenDecimals + oracleDecimals + 18)), _rate * 1e18); require(amount_ > 0, "zero amount!"); uint256 balanceBefore = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), amount_); uint256 balanceAfter = token.balanceOf(address(this)); uint256 diff = amount_ - (balanceAfter - balanceBefore); if (diff > 0) intakeMoreFromFoT(amount_, diff); } // takes a numeraire amount, calculates the raw amount of eurs, transfers it in and returns the corresponding raw amount function intakeNumeraireLPRatio( uint256 _minBaseAmount, uint256 _maxBaseAmount, uint256 _baseAmount, uint256 _minpairTokenAmount, uint256 _maxpairTokenAmount, uint256 _quoteAmount, address token0 ) external payable override returns (uint256 amount_) { if (token0 == address(token)) { amount_ = _baseAmount; } else { amount_ = _quoteAmount; } require(amount_ > 0, "zero amount!"); if (token0 == address(token)) { require(amount_ > _minBaseAmount && amount_ <= _maxBaseAmount, "Assimilator/LP Ratio imbalanced!"); } else { require(amount_ > _minpairTokenAmount && amount_ <= _maxpairTokenAmount, "Assimilator/LP Ratio imbalanced!"); } uint256 balanceBefore = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), amount_); uint256 balanceAfter = token.balanceOf(address(this)); uint256 diff = amount_ - (balanceAfter - balanceBefore); if (diff > 0) intakeMoreFromFoT(amount_, diff); } function intakeMoreFromFoT(uint256 amount_, uint256 diff) internal { require(amount_ > 0, "zero amount!"); // handle FoT token uint256 feePercentage = diff.mul(1e5).div(amount_).add(1); uint256 additionalIntakeAmt = (diff * 1e5) / (1e5 - feePercentage); token.safeTransferFrom(msg.sender, address(this), additionalIntakeAmt); } // takes a raw amount of eurs and transfers it out, returns numeraire value of the raw amount function outputRawAndGetBalance(address _dst, uint256 _amount) external override returns (int128 amount_, int128 balance_) { require(_amount > 0, "zero amount!"); uint256 _rate = getRate(); token.safeTransfer(_dst, _amount); uint256 _balance = token.balanceOf(address(this)); amount_ = ((_amount * _rate)).divu(10 ** (tokenDecimals + oracleDecimals)); balance_ = ((_balance * _rate)).divu(10 ** (tokenDecimals + oracleDecimals)); } // takes a raw amount of eurs and transfers it out, returns numeraire value of the raw amount function outputRaw(address _dst, uint256 _amount) external override returns (int128 amount_) { require(_amount > 0, "zero amount!"); uint256 _rate = getRate(); token.safeTransfer(_dst, _amount); amount_ = ((_amount * _rate)).divu(10 ** (tokenDecimals + oracleDecimals)); } // takes a numeraire value of eurs, figures out the raw amount, transfers raw amount out, and returns raw amount function outputNumeraire(address _dst, int128 _amount, bool _toETH) external payable override returns (uint256 amount_) { uint256 _rate = getRate(); amount_ = Math.ceilDiv(_amount.mulu(10 ** (tokenDecimals + oracleDecimals + 18)), _rate * 1e18); require(amount_ > 0, "zero amount!"); if (_toETH) { IWETH(wETH).withdraw(amount_); (bool success,) = payable(_dst).call{value: amount_}(""); require(success, "Assimilator/Transfer ETH Failed"); } else { token.safeTransfer(_dst, amount_); } } // takes a numeraire amount and returns the raw amount function viewRawAmount(int128 _amount) external view override returns (uint256 amount_) { uint256 _rate = getRate(); // improve precision amount_ = Math.ceilDiv(_amount.mulu(10 ** (tokenDecimals + oracleDecimals + 18)), _rate * 1e18); } function viewRawAmountLPRatio(uint256 _baseWeight, uint256 _pairTokenWeight, address _addr, int128 _amount) external view override returns (uint256 amount_) { uint256 _tokenBal = token.balanceOf(_addr); if (_tokenBal <= 0) return 0; _tokenBal = _tokenBal.mul(10 ** (18 + pairTokenDecimals)).div(_baseWeight); uint256 _pairTokenBal = pairToken.balanceOf(_addr).mul(10 ** (18 + tokenDecimals)).div(_pairTokenWeight); // Rate is in pair token decimals uint256 _rate = _pairTokenBal.mul(1e6).div(_tokenBal); amount_ = Math.ceilDiv(_amount.mulu(10 ** tokenDecimals * 1e6 * 1e18), _rate * 1e18); } // takes a raw amount and returns the numeraire amount function viewNumeraireAmount(uint256 _amount) external view override returns (int128 amount_) { uint256 _rate = getRate(); amount_ = ((_amount * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); } // views the numeraire value of the current balance of the reserve, in this case eurs function viewNumeraireBalance(address _addr) external view override returns (int128 balance_) { uint256 _rate = getRate(); uint256 _balance = token.balanceOf(_addr); if (_balance <= 0) return ABDKMath64x64.fromUInt(0); balance_ = ((_balance * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); } // views the numeraire value of the current balance of the reserve, in this case eurs function viewNumeraireAmountAndBalance(address _addr, uint256 _amount) external view override returns (int128 amount_, int128 balance_) { uint256 _rate = getRate(); amount_ = ((_amount * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); uint256 _balance = token.balanceOf(_addr); balance_ = ((_balance * _rate) / 10 ** oracleDecimals).divu(10 ** tokenDecimals); } // views the numeraire value of the current balance of the reserve, in this case eurs // instead of calculating with chainlink's "rate" it'll be determined by the existing // token ratio. This is in here to prevent LPs from losing out on future oracle price updates function viewNumeraireBalanceLPRatio(uint256 _baseWeight, uint256 _pairTokenWeight, address _addr) external view override returns (int128 balance_) { uint256 _tokenBal = token.balanceOf(_addr); if (_tokenBal <= 0) return ABDKMath64x64.fromUInt(0); uint256 _pairTokenBal = pairToken.balanceOf(_addr).mul(1e18).div(_pairTokenWeight); // Rate is in 1e6 uint256 _rate = _pairTokenBal.mul(1e18).div(_tokenBal.mul(1e18).div(_baseWeight)); balance_ = ((_tokenBal * _rate) / 10 ** pairTokenDecimals).divu(1e18); } function transferFee(int128 _amount, address _treasury) external payable override { uint256 _rate = getRate(); if (_amount < 0) _amount = -(_amount); uint256 amount = _amount.mulu(10 ** (tokenDecimals + oracleDecimals + 18)) / (_rate * 1e18); token.safeTransfer(_treasury, amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "./IAssimilatorFactory.sol"; interface ICurveFactory { function getProtocolFee() external view returns (int128); function getProtocolTreasury() external view returns (address); function assimilatorFactory() external view returns (IAssimilatorFactory); function wETH() external view returns (address); function isDFXCurve(address) external view returns (bool); }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "../assimilators/AssimilatorV3.sol"; import "../interfaces/IOracle.sol"; interface IAssimilatorFactory { function getAssimilator(address _token, address _quote) external view returns (AssimilatorV3); function newAssimilator(address _quote, IOracle _oracle, address _token, uint256 _tokenDecimals) external returns (AssimilatorV3); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface IConfig { function getGlobalFrozenState() external view returns (bool); function getProtocolFee() external view returns (int128); function getProtocolTreasury() external view returns (address); function setGlobalFrozen(bool) external; function updateProtocolTreasury(address) external; function updateProtocolFee(int128) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface IWETH { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); function withdraw(uint256) external; }
// SPDX-License-Identifier: BSD-4-Clause /* * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity ^0.8.13; /** * Smart contract library of mathematical functions operating with signed * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is * basically a simple fraction whose numerator is signed 128-bit integer and * denominator is 2^64. As long as denominator is always the same, there is no * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are * represented by int128 type holding only the numerator. */ library ABDKMath64x64 { /* * Minimum value signed 64.64-bit fixed point number may have. */ int128 private constant MIN_64x64 = -0x80000000000000000000000000000000; /* * Maximum value signed 64.64-bit fixed point number may have. */ int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; /** * Convert signed 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromInt(int256 x) internal pure returns (int128) { unchecked { require(x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF); return int128(x << 64); } } /** * Convert signed 64.64 fixed point number into signed 64-bit integer number * rounding down. * * @param x signed 64.64-bit fixed point number * @return signed 64-bit integer number */ function toInt(int128 x) internal pure returns (int64) { unchecked { return int64(x >> 64); } } /** * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point * number. Revert on overflow. * * @param x unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function fromUInt(uint256 x) internal pure returns (int128) { unchecked { require(x <= 0x7FFFFFFFFFFFFFFF); return int128(int256(x << 64)); } } /** * Convert signed 64.64 fixed point number into unsigned 64-bit integer * number rounding down. Revert on underflow. * * @param x signed 64.64-bit fixed point number * @return unsigned 64-bit integer number */ function toUInt(int128 x) internal pure returns (uint64) { unchecked { require(x >= 0); return uint64(uint128(x >> 64)); } } /** * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point * number rounding down. Revert on overflow. * * @param x signed 128.128-bin fixed point number * @return signed 64.64-bit fixed point number */ function from128x128(int256 x) internal pure returns (int128) { unchecked { int256 result = x >> 64; require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Convert signed 64.64 fixed point number into signed 128.128 fixed point * number. * * @param x signed 64.64-bit fixed point number * @return signed 128.128 fixed point number */ function to128x128(int128 x) internal pure returns (int256) { unchecked { return int256(x) << 64; } } /** * Calculate x + y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function add(int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) + y; require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Calculate x - y. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sub(int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) - y; require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Calculate x * y rounding down. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function mul(int128 x, int128 y) internal pure returns (int128) { unchecked { int256 result = int256(x) * y >> 64; require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point * number and y is signed 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y signed 256-bit integer number * @return signed 256-bit integer number */ function muli(int128 x, int256 y) internal pure returns (int256) { unchecked { if (x == MIN_64x64) { require( y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF && y <= 0x1000000000000000000000000000000000000000000000000 ); return -y << 63; } else { bool negativeResult = false; if (x < 0) { x = -x; negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint256 absoluteResult = mulu(x, uint256(y)); if (negativeResult) { require(absoluteResult <= 0x8000000000000000000000000000000000000000000000000000000000000000); return -int256(absoluteResult); // We rely on overflow behavior here } else { require(absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int256(absoluteResult); } } } } /** * Calculate x * y rounding down, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64 fixed point number * @param y unsigned 256-bit integer number * @return unsigned 256-bit integer number */ function mulu(int128 x, uint256 y) internal pure returns (uint256) { unchecked { if (y == 0) return 0; require(x >= 0); uint256 lo = (uint256(int256(x)) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64; uint256 hi = uint256(int256(x)) * (y >> 128); require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); hi <<= 64; require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo); return hi + lo; } } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function div(int128 x, int128 y) internal pure returns (int128) { unchecked { require(y != 0); int256 result = (int256(x) << 64) / y; require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Calculate x / y rounding towards zero, where x and y are signed 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x signed 256-bit integer number * @param y signed 256-bit integer number * @return signed 64.64-bit fixed point number */ function divi(int256 x, int256 y) internal pure returns (int128) { unchecked { require(y != 0); bool negativeResult = false; if (x < 0) { x = -x; // We rely on overflow behavior here negativeResult = true; } if (y < 0) { y = -y; // We rely on overflow behavior here negativeResult = !negativeResult; } uint128 absoluteResult = divuu(uint256(x), uint256(y)); if (negativeResult) { require(absoluteResult <= 0x80000000000000000000000000000000); return -int128(absoluteResult); // We rely on overflow behavior here } else { require(absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return int128(absoluteResult); // We rely on overflow behavior here } } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return signed 64.64-bit fixed point number */ function divu(uint256 x, uint256 y) internal pure returns (int128) { unchecked { require(y != 0); uint128 result = divuu(x, y); require(result <= uint128(MAX_64x64)); return int128(result); } } /** * Calculate -x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function neg(int128 x) internal pure returns (int128) { unchecked { require(x != MIN_64x64); return -x; } } /** * Calculate |x|. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function abs(int128 x) internal pure returns (int128) { unchecked { require(x != MIN_64x64); return x < 0 ? -x : x; } } /** * Calculate 1 / x rounding towards zero. Revert on overflow or when x is * zero. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function inv(int128 x) internal pure returns (int128) { unchecked { require(x != 0); int256 result = int256(0x100000000000000000000000000000000) / x; require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function avg(int128 x, int128 y) internal pure returns (int128) { unchecked { return int128((int256(x) + int256(y)) >> 1); } } /** * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down. * Revert on overflow or in case x * y is negative. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function gavg(int128 x, int128 y) internal pure returns (int128) { unchecked { int256 m = int256(x) * int256(y); require(m >= 0); require(m < 0x4000000000000000000000000000000000000000000000000000000000000000); return int128(sqrtu(uint256(m))); } } /** * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number * and y is unsigned 256-bit integer number. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @param y uint256 value * @return signed 64.64-bit fixed point number */ function pow(int128 x, uint256 y) internal pure returns (int128) { unchecked { bool negative = x < 0 && y & 1 == 1; uint256 absX = uint128(x < 0 ? -x : x); uint256 absResult; absResult = 0x100000000000000000000000000000000; if (absX <= 0x10000000000000000) { absX <<= 63; while (y != 0) { if (y & 0x1 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x2 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x4 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; if (y & 0x8 != 0) { absResult = absResult * absX >> 127; } absX = absX * absX >> 127; y >>= 4; } absResult >>= 64; } else { uint256 absXShift = 63; if (absX < 0x1000000000000000000000000) { absX <<= 32; absXShift -= 32; } if (absX < 0x10000000000000000000000000000) { absX <<= 16; absXShift -= 16; } if (absX < 0x1000000000000000000000000000000) { absX <<= 8; absXShift -= 8; } if (absX < 0x10000000000000000000000000000000) { absX <<= 4; absXShift -= 4; } if (absX < 0x40000000000000000000000000000000) { absX <<= 2; absXShift -= 2; } if (absX < 0x80000000000000000000000000000000) { absX <<= 1; absXShift -= 1; } uint256 resultShift = 0; while (y != 0) { require(absXShift < 64); if (y & 0x1 != 0) { absResult = absResult * absX >> 127; resultShift += absXShift; if (absResult > 0x100000000000000000000000000000000) { absResult >>= 1; resultShift += 1; } } absX = absX * absX >> 127; absXShift <<= 1; if (absX >= 0x100000000000000000000000000000000) { absX >>= 1; absXShift += 1; } y >>= 1; } require(resultShift < 64); absResult >>= 64 - resultShift; } int256 result = negative ? -int256(absResult) : int256(absResult); require(result >= MIN_64x64 && result <= MAX_64x64); return int128(result); } } /** * Calculate sqrt (x) rounding down. Revert if x < 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function sqrt(int128 x) internal pure returns (int128) { unchecked { require(x >= 0); return int128(sqrtu(uint256(int256(x)) << 64)); } } /** * Calculate binary logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function log_2(int128 x) internal pure returns (int128) { unchecked { require(x > 0); int256 msb = 0; int256 xc = x; if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; } if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore int256 result = msb - 64 << 64; uint256 ux = uint256(int256(x)) << uint256(127 - msb); for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) { ux *= ux; uint256 b = ux >> 255; ux >>= 127 + b; result += bit * int256(b); } return int128(result); } } /** * Calculate natural logarithm of x. Revert if x <= 0. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function ln(int128 x) internal pure returns (int128) { unchecked { require(x > 0); return int128(int256(uint256(int256(log_2(x))) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128)); } } /** * Calculate binary exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp_2(int128 x) internal pure returns (int128) { unchecked { require(x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) { result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128; } if (x & 0x4000000000000000 > 0) { result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128; } if (x & 0x2000000000000000 > 0) { result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128; } if (x & 0x1000000000000000 > 0) { result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128; } if (x & 0x800000000000000 > 0) { result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128; } if (x & 0x400000000000000 > 0) { result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128; } if (x & 0x200000000000000 > 0) { result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128; } if (x & 0x100000000000000 > 0) { result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128; } if (x & 0x80000000000000 > 0) { result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128; } if (x & 0x40000000000000 > 0) { result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128; } if (x & 0x20000000000000 > 0) { result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128; } if (x & 0x10000000000000 > 0) { result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128; } if (x & 0x8000000000000 > 0) { result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128; } if (x & 0x4000000000000 > 0) { result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128; } if (x & 0x2000000000000 > 0) { result = result * 0x1000162E525EE054754457D5995292026 >> 128; } if (x & 0x1000000000000 > 0) { result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128; } if (x & 0x800000000000 > 0) { result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128; } if (x & 0x400000000000 > 0) { result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128; } if (x & 0x200000000000 > 0) { result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128; } if (x & 0x100000000000 > 0) { result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128; } if (x & 0x80000000000 > 0) { result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128; } if (x & 0x40000000000 > 0) { result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128; } if (x & 0x20000000000 > 0) { result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128; } if (x & 0x10000000000 > 0) { result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128; } if (x & 0x8000000000 > 0) { result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128; } if (x & 0x4000000000 > 0) { result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128; } if (x & 0x2000000000 > 0) { result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128; } if (x & 0x1000000000 > 0) { result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128; } if (x & 0x800000000 > 0) { result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128; } if (x & 0x400000000 > 0) { result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128; } if (x & 0x200000000 > 0) { result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128; } if (x & 0x100000000 > 0) { result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128; } if (x & 0x80000000 > 0) { result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128; } if (x & 0x40000000 > 0) { result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128; } if (x & 0x20000000 > 0) { result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128; } if (x & 0x10000000 > 0) { result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128; } if (x & 0x8000000 > 0) { result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128; } if (x & 0x4000000 > 0) { result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128; } if (x & 0x2000000 > 0) { result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128; } if (x & 0x1000000 > 0) { result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128; } if (x & 0x800000 > 0) { result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128; } if (x & 0x400000 > 0) { result = result * 0x100000000002C5C85FDF477B662B26945 >> 128; } if (x & 0x200000 > 0) { result = result * 0x10000000000162E42FEFA3AE53369388C >> 128; } if (x & 0x100000 > 0) { result = result * 0x100000000000B17217F7D1D351A389D40 >> 128; } if (x & 0x80000 > 0) { result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128; } if (x & 0x40000 > 0) { result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128; } if (x & 0x20000 > 0) { result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128; } if (x & 0x10000 > 0) { result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128; } if (x & 0x8000 > 0) { result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128; } if (x & 0x4000 > 0) { result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128; } if (x & 0x2000 > 0) { result = result * 0x1000000000000162E42FEFA39F02B772C >> 128; } if (x & 0x1000 > 0) { result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128; } if (x & 0x800 > 0) { result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128; } if (x & 0x400 > 0) { result = result * 0x100000000000002C5C85FDF473DEA871F >> 128; } if (x & 0x200 > 0) { result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128; } if (x & 0x100 > 0) { result = result * 0x100000000000000B17217F7D1CF79E949 >> 128; } if (x & 0x80 > 0) { result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128; } if (x & 0x40 > 0) { result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128; } if (x & 0x20 > 0) { result = result * 0x100000000000000162E42FEFA39EF366F >> 128; } if (x & 0x10 > 0) { result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128; } if (x & 0x8 > 0) { result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128; } if (x & 0x4 > 0) { result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128; } if (x & 0x2 > 0) { result = result * 0x1000000000000000162E42FEFA39EF358 >> 128; } if (x & 0x1 > 0) { result = result * 0x10000000000000000B17217F7D1CF79AB >> 128; } result >>= uint256(int256(63 - (x >> 64))); require(result <= uint256(int256(MAX_64x64))); return int128(int256(result)); } } /** * Calculate natural exponent of x. Revert on overflow. * * @param x signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function exp(int128 x) internal pure returns (int128) { unchecked { require(x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2(int128(int256(x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } } /** * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit * integer numbers. Revert on overflow or when y is zero. * * @param x unsigned 256-bit integer number * @param y unsigned 256-bit integer number * @return unsigned 64.64-bit fixed point number */ function divuu(uint256 x, uint256 y) private pure returns (uint128) { unchecked { require(y != 0); uint256 result; if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) { result = (x << 64) / y; } else { uint256 msb = 192; uint256 xc = x >> 192; if (xc >= 0x100000000) { xc >>= 32; msb += 32; } if (xc >= 0x10000) { xc >>= 16; msb += 16; } if (xc >= 0x100) { xc >>= 8; msb += 8; } if (xc >= 0x10) { xc >>= 4; msb += 4; } if (xc >= 0x4) { xc >>= 2; msb += 2; } if (xc >= 0x2) msb += 1; // No need to shift xc anymore result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1); require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 hi = result * (y >> 128); uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); uint256 xh = x >> 192; uint256 xl = x << 64; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here lo = hi << 128; if (xl < lo) xh -= 1; xl -= lo; // We rely on overflow behavior here assert(xh == hi >> 128); result += xl / y; } require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); return uint128(result); } } /** * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer * number. * * @param x unsigned 256-bit integer number * @return unsigned 128-bit integer number */ function sqrtu(uint256 x) private pure returns (uint128) { unchecked { if (x == 0) { return 0; } else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) r <<= 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint128(r < r1 ? r : r1); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then 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(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (0 - denominator) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } 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 // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use 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. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // 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 precoditions 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 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; /// @title Prevents delegatecall to a contract /// @notice Base contract that provides a modifier for preventing delegatecall to methods in a child contract abstract contract NoDelegateCall { /// @dev The original address of this contract address private immutable original; constructor() { // Immutables are computed in the init code of the contract, and then inlined into the deployed bytecode. // In other words, this variable won't change when it's checked at runtime. original = address(this); } /// @dev Private method is used instead of inlining into modifier because modifiers are copied into each method, /// and the use of immutable means the address bytes are copied in every place the modifier is used. function checkNotDelegateCall() private view { require(address(this) == original); } /// @notice Prevents delegatecall into the modified method modifier noDelegateCall() { checkNotDelegateCall(); _; } }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./lib/ABDKMath64x64.sol"; import "./Storage.sol"; import "./CurveMath.sol"; library Orchestrator { using SafeERC20 for IERC20; using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; int128 private constant ONE_WEI = 0x12; event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda); event AssetIncluded(address indexed numeraire, address indexed reserve, uint256 weight); event AssimilatorIncluded( address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator ); function setParams( Storage.Curve storage curve, uint256 _alpha, uint256 _beta, uint256 _feeAtHalt, uint256 _epsilon, uint256 _lambda ) external { require(0 < _alpha && _alpha < 1e18, "Curve/parameter-invalid-alpha"); require(_beta < _alpha, "Curve/parameter-invalid-beta"); require(_feeAtHalt <= 5e17, "Curve/parameter-invalid-max"); require(_epsilon <= 1e16, "Curve/parameter-invalid-epsilon"); require(_lambda <= 1e18, "Curve/parameter-invalid-lambda"); int128 _omega = getFee(curve); curve.alpha = (_alpha + 1).divu(1e18); curve.beta = (_beta + 1).divu(1e18); curve.delta = (_feeAtHalt).divu(1e18).div(uint256(2).fromUInt().mul(curve.alpha.sub(curve.beta))) + ONE_WEI; curve.epsilon = (_epsilon + 1).divu(1e18); curve.lambda = (_lambda + 1).divu(1e18); int128 _psi = getFee(curve); require(_omega >= _psi, "Curve/parameters-increase-fee"); emit ParametersSet(_alpha, _beta, curve.delta.mulu(1e18), _epsilon, _lambda); } function setAssimilator( Storage.Curve storage curve, address _baseCurrency, address _baseAssim, address _quoteCurrency, address _quoteAssim ) external { require(_baseCurrency != address(0), "Curve/numeraire-cannot-be-zero-address"); require(_baseAssim != address(0), "Curve/numeraire-assimilator-cannot-be-zero-address"); require(_quoteCurrency != address(0), "Curve/reserve-cannot-be-zero-address"); require(_quoteAssim != address(0), "Curve/reserve-assimilator-cannot-be-zero-address"); Storage.Assimilator storage _baseAssimilator = curve.assimilators[_baseCurrency]; _baseAssimilator.addr = _baseAssim; Storage.Assimilator storage _quoteAssimilator = curve.assimilators[_quoteCurrency]; _quoteAssimilator.addr = _quoteAssim; curve.assets[0] = _baseAssimilator; curve.assets[1] = _quoteAssimilator; } function getFee(Storage.Curve storage curve) private view returns (int128 fee_) { int128 _gLiq; // Always pairs int128[] memory _bals = new int128[](2); for (uint256 i = 0; i < _bals.length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(curve.assets[i].addr); _bals[i] = _bal; _gLiq += _bal; } fee_ = CurveMath.calculateFee(_gLiq, _bals, curve.beta, curve.delta, curve.weights); } function initialize( Storage.Curve storage curve, address[] storage numeraires, address[] storage reserves, address[] storage derivatives, address[] calldata _assets, uint256[] calldata _assetWeights ) external { require(_assetWeights.length == 2, "Curve/assetWeights-must-be-length-two"); require(_assets.length % 5 == 0, "Curve/assets-must-be-divisible-by-five"); for (uint256 i = 0; i < _assetWeights.length; i++) { uint256 ix = i * 5; numeraires.push(_assets[ix]); derivatives.push(_assets[ix]); reserves.push(_assets[2 + ix]); if (_assets[ix] != _assets[2 + ix]) { derivatives.push(_assets[2 + ix]); } includeAsset( curve, _assets[ix], // numeraire _assets[1 + ix], // numeraire assimilator _assets[2 + ix], // reserve _assets[3 + ix], // reserve assimilator _assets[4 + ix], // reserve approve to _assetWeights[i] ); } } function includeAsset( Storage.Curve storage curve, address _numeraire, address _numeraireAssim, address _reserve, address _reserveAssim, address _reserveApproveTo, uint256 _weight ) private { require(_numeraire != address(0), "Curve/numeraire-cannot-be-zero-address"); require(_numeraireAssim != address(0), "Curve/numeraire-assimilator-cannot-be-zero-address"); require(_reserve != address(0), "Curve/reserve-cannot-be-zero-address"); require(_reserveAssim != address(0), "Curve/reserve-assimilator-cannot-be-zero-address"); require(_weight < 1e18, "Curve/weight-must-be-less-than-one"); if (_numeraire != _reserve) { IERC20(_numeraire).safeApprove(_reserveApproveTo, type(uint256).max); } Storage.Assimilator storage _numeraireAssimilator = curve.assimilators[_numeraire]; _numeraireAssimilator.addr = _numeraireAssim; _numeraireAssimilator.ix = uint8(curve.assets.length); Storage.Assimilator storage _reserveAssimilator = curve.assimilators[_reserve]; _reserveAssimilator.addr = _reserveAssim; _reserveAssimilator.ix = uint8(curve.assets.length); int128 __weight = _weight.divu(1e18).add(uint256(1).divu(1e18)); curve.weights.push(__weight); curve.assets.push(_numeraireAssimilator); emit AssetIncluded(_numeraire, _reserve, _weight); emit AssimilatorIncluded(_numeraire, _numeraire, _reserve, _numeraireAssim); if (_numeraireAssim != _reserveAssim) { emit AssimilatorIncluded(_reserve, _numeraire, _reserve, _reserveAssim); } } function viewCurve(Storage.Curve storage curve) external view returns (uint256 alpha_, uint256 beta_, uint256 delta_, uint256 epsilon_, uint256 lambda_) { alpha_ = curve.alpha.mulu(1e18); beta_ = curve.beta.mulu(1e18); delta_ = curve.delta.mulu(1e18); epsilon_ = curve.epsilon.mulu(1e18); lambda_ = curve.lambda.mulu(1e18); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./Assimilators.sol"; import "./Storage.sol"; import "./lib/UnsafeMath64x64.sol"; import "./lib/ABDKMath64x64.sol"; import "./CurveMath.sol"; import "./Structs.sol"; import "./interfaces/IAssimilator.sol"; import "./interfaces/ICurve.sol"; library ProportionalLiquidity { using ABDKMath64x64 for uint256; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; using SafeMath for uint256; event Transfer(address indexed from, address indexed to, uint256 value); int128 public constant ONE = 0x10000000000000000; int128 public constant ONE_WEI = 0x12; function proportionalDeposit(Storage.Curve storage curve, DepositData memory depositData) external returns (uint256 curves_, uint256[] memory) { int128 __deposit = depositData.deposits.divu(1e18); uint256 _length = curve.assets.length; uint256[] memory deposits_ = new uint256[](_length); (int128 _oGLiq, int128[] memory _oBals) = getGrossLiquidityAndBalancesForDeposit(curve); // No liquidity, oracle sets the ratio if (_oGLiq == 0) { for (uint256 i = 0; i < _length; i++) { // Variable here to avoid stack-too-deep errors int128 _d = __deposit.mul(curve.weights[i]); deposits_[i] = Assimilators.intakeNumeraire(curve.assets[i].addr, _d.add(ONE_WEI)); } } else { // We already have an existing pool ratio // which must be respected int128 _multiplier = __deposit.div(_oGLiq); uint256 _baseWeight = curve.weights[0].mulu(1e18); uint256 _quoteWeight = curve.weights[1].mulu(1e18); for (uint256 i = 0; i < _length; i++) { IntakeNumLpRatioInfo memory info; info.minBase = depositData.minBase; info.maxBase = depositData.maxBase; info.baseAmt = depositData.baseAmt; info.minQuote = depositData.minQuote; info.quoteAmt = depositData.quoteAmt; info.maxQuote = depositData.maxQuote; info.token0 = depositData.token0; deposits_[i] = Assimilators.intakeNumeraireLPRatio(curve.assets[i].addr, info); } } curves_ = depositData.deposits; require(curves_ > 0, "Proportional Liquidity/can't mint negative amount"); mint(curve, msg.sender, curves_); return (curves_, deposits_); } function viewProportionalDeposit(Storage.Curve storage curve, uint256 _deposit) external view returns (uint256 curves_, uint256[] memory) { int128 __deposit = _deposit.divu(1e18); uint256 _length = curve.assets.length; (int128 _oGLiq, int128[] memory _oBals) = getGrossLiquidityAndBalancesForDeposit(curve); uint256[] memory deposits_ = new uint256[](_length); // No liquidity if (_oGLiq == 0) { for (uint256 i = 0; i < _length; i++) { deposits_[i] = Assimilators.viewRawAmount(curve.assets[i].addr, __deposit.mul(curve.weights[i]).add(ONE_WEI)); } } else { // We already have an existing pool ratio // this must be respected int128 _multiplier = __deposit.div(_oGLiq); uint256 _baseWeight = curve.weights[0].mulu(1e18); uint256 _quoteWeight = curve.weights[1].mulu(1e18); // Deposits into the pool is determined by existing LP ratio for (uint256 i = 0; i < _length; i++) { deposits_[i] = Assimilators.viewRawAmountLPRatio( curve.assets[i].addr, _baseWeight, _quoteWeight, _oBals[i].mul(_multiplier).add(ONE_WEI) ); } } int128 _totalShells = curve.totalSupply.divu(1e18); int128 _newShells = __deposit; if (_totalShells > 0) { _newShells = __deposit.mul(_totalShells); _newShells = _newShells.div(_oGLiq); } curves_ = _newShells.mulu(1e18); return (curves_, deposits_); } function proportionalWithdraw(Storage.Curve storage curve, uint256 _withdrawal, bool _toETH) external returns (uint256[] memory) { uint256 _length = curve.assets.length; (, int128[] memory _oBals) = getGrossLiquidityAndBalances(curve); uint256[] memory withdrawals_ = new uint256[](_length); int128 _totalShells = curve.totalSupply.divu(1e18); int128 __withdrawal = _withdrawal.divu(1e18); int128 _multiplier = __withdrawal.div(_totalShells); for (uint256 i = 0; i < _length; i++) { if ( _toETH && ( IAssimilator(curve.assets[i].addr).underlyingToken() == IAssimilator(curve.assets[i].addr).getWeth() ) ) { withdrawals_[i] = Assimilators.outputNumeraire(curve.assets[i].addr, msg.sender, _oBals[i].mul(_multiplier), true); } else { withdrawals_[i] = Assimilators.outputNumeraire(curve.assets[i].addr, msg.sender, _oBals[i].mul(_multiplier), false); } } burn(curve, msg.sender, _withdrawal); return withdrawals_; } function viewProportionalWithdraw(Storage.Curve storage curve, uint256 _withdrawal) external view returns (uint256[] memory) { uint256 _length = curve.assets.length; (, int128[] memory _oBals) = getGrossLiquidityAndBalances(curve); uint256[] memory withdrawals_ = new uint256[](_length); int128 _multiplier = _withdrawal.divu(1e18).div(curve.totalSupply.divu(1e18)); for (uint256 i = 0; i < _length; i++) { withdrawals_[i] = Assimilators.viewRawAmount(curve.assets[i].addr, _oBals[i].mul(_multiplier)); } return withdrawals_; } function getGrossLiquidityAndBalancesForDeposit(Storage.Curve storage curve) internal view returns (int128 grossLiquidity_, int128[] memory) { uint256 _length = curve.assets.length; int128[] memory balances_ = new int128[](_length); uint256 _baseWeight = curve.weights[0].mulu(1e18); uint256 _quoteWeight = curve.weights[1].mulu(1e18); for (uint256 i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalanceLPRatio(_baseWeight, _quoteWeight, curve.assets[i].addr); balances_[i] = _bal; grossLiquidity_ += _bal; } return (grossLiquidity_, balances_); } function getGrossLiquidityAndBalances(Storage.Curve storage curve) internal view returns (int128 grossLiquidity_, int128[] memory) { uint256 _length = curve.assets.length; int128[] memory balances_ = new int128[](_length); for (uint256 i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(curve.assets[i].addr); balances_[i] = _bal; grossLiquidity_ += _bal; } return (grossLiquidity_, balances_); } function burn(Storage.Curve storage curve, address account, uint256 amount) private { curve.balances[account] = burnSub(curve.balances[account], amount); curve.totalSupply = burnSub(curve.totalSupply, amount); emit Transfer(msg.sender, address(0), amount); } function mint(Storage.Curve storage curve, address account, uint256 amount) private { // uint256 minLock = 1e6; uint256 minLock = 1e15; if (curve.totalSupply == 0) { require(amount > minLock, "Proportional Liquidity/amount too small!"); uint256 toMintAmt = amount - minLock; // mint to lp provider curve.totalSupply = mintAdd(curve.totalSupply, toMintAmt); curve.balances[account] = mintAdd(curve.balances[account], toMintAmt); emit Transfer(address(0), msg.sender, toMintAmt); // mint to 0 address curve.totalSupply = mintAdd(curve.totalSupply, minLock); curve.balances[address(0)] = mintAdd(curve.balances[address(0)], minLock); emit Transfer(address(this), address(0), minLock); } else { curve.totalSupply = mintAdd(curve.totalSupply, amount); curve.balances[account] = mintAdd(curve.balances[account], amount); emit Transfer(address(0), msg.sender, amount); } } function mintAdd(uint256 x, uint256 y) private pure returns (uint256 z) { require((z = x + y) >= x, "Curve/mint-overflow"); } function burnSub(uint256 x, uint256 y) private pure returns (uint256 z) { require((z = x - y) <= x, "Curve/burn-underflow"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./Structs.sol"; import "./Assimilators.sol"; import "./Storage.sol"; import "./CurveMath.sol"; import "./lib/UnsafeMath64x64.sol"; import "./lib/ABDKMath64x64.sol"; library Swaps { using ABDKMath64x64 for int128; using ABDKMath64x64 for int256; using UnsafeMath64x64 for int128; using ABDKMath64x64 for uint256; using SafeMath for uint256; event Trade( address indexed trader, address indexed origin, address indexed target, uint256 originAmount, uint256 targetAmount, int128 rawProtocolFee ); int128 public constant ONE = 0x10000000000000000; function getOriginAndTarget(Storage.Curve storage curve, address _o, address _t) private view returns (Storage.Assimilator memory, Storage.Assimilator memory) { Storage.Assimilator memory o_ = curve.assimilators[_o]; Storage.Assimilator memory t_ = curve.assimilators[_t]; require(o_.addr != address(0), "Curve/origin-not-supported"); require(t_.addr != address(0), "Curve/target-not-supported"); return (o_, t_); } function originSwap(Storage.Curve storage curve, OriginSwapData memory _swapData, bool toETH) external returns (uint256 tAmt_) { (Storage.Assimilator memory _o, Storage.Assimilator memory _t) = getOriginAndTarget(curve, _swapData._origin, _swapData._target); require(_swapData._origin != _swapData._target, "swap/same-origin-target"); if (_o.ix == _t.ix) { return Assimilators.outputNumeraire( _t.addr, _swapData._recipient, Assimilators.intakeRaw(_o.addr, _swapData._originAmount), toETH ); } SwapInfo memory _swapInfo; (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals) = getOriginSwapData(curve, _o.ix, _t.ix, _o.addr, _swapData._originAmount); _swapInfo.totalAmount = _amt; _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix); _swapInfo.curveFactory = ICurveFactory(_swapData._curveFactory); _swapInfo.amountToUser = _amt.us_mul(ONE - curve.epsilon); _swapInfo.totalFee = _swapInfo.amountToUser - _amt; _swapInfo.protocolFeePercentage = _swapInfo.curveFactory.getProtocolFee(); _swapInfo.treasury = _swapInfo.curveFactory.getProtocolTreasury(); _swapInfo.amountToTreasury = _swapInfo.totalFee.muli(_swapInfo.protocolFeePercentage).divi(100000); Assimilators.transferFee(_t.addr, _swapInfo.amountToTreasury, _swapInfo.treasury); tAmt_ = Assimilators.outputNumeraire(_t.addr, _swapData._recipient, _swapInfo.amountToUser, toETH); emit Trade( msg.sender, _swapData._origin, _swapData._target, _swapData._originAmount, tAmt_, _swapInfo.amountToTreasury ); } function viewOriginSwap(Storage.Curve storage curve, address _origin, address _target, uint256 _originAmount) external view returns (uint256 tAmt_) { (Storage.Assimilator memory _o, Storage.Assimilator memory _t) = getOriginAndTarget(curve, _origin, _target); if (_o.ix == _t.ix) { return Assimilators.viewRawAmount(_t.addr, Assimilators.viewNumeraireAmount(_o.addr, _originAmount)); } (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals) = viewOriginSwapData(curve, _o.ix, _t.ix, _originAmount, _o.addr); _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _t.ix); _amt = _amt.us_mul(ONE - curve.epsilon); tAmt_ = Assimilators.viewRawAmount(_t.addr, _amt.abs()); } function targetSwap(Storage.Curve storage curve, TargetSwapData memory _swapData) external returns (uint256 oAmt_) { (Storage.Assimilator memory _o, Storage.Assimilator memory _t) = getOriginAndTarget(curve, _swapData._origin, _swapData._target); require(_swapData._origin != _swapData._target, "swap/same-origin-target"); if (_o.ix == _t.ix) { return Assimilators.intakeNumeraire( _o.addr, Assimilators.outputRaw(_t.addr, _swapData._recipient, _swapData._targetAmount) ); } (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals) = getTargetSwapData(curve, _t.ix, _o.ix, _t.addr, _swapData._recipient, _swapData._targetAmount); _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix); SwapInfo memory _swapInfo; _swapInfo.totalAmount = _amt; _swapInfo.curveFactory = ICurveFactory(_swapData._curveFactory); _swapInfo.amountToUser = _amt.us_mul(ONE + curve.epsilon); _swapInfo.totalFee = _swapInfo.amountToUser - _amt; _swapInfo.protocolFeePercentage = _swapInfo.curveFactory.getProtocolFee(); _swapInfo.treasury = _swapInfo.curveFactory.getProtocolTreasury(); _swapInfo.amountToTreasury = _swapInfo.totalFee.muli(_swapInfo.protocolFeePercentage).divi(100000); Assimilators.transferFee(_o.addr, _swapInfo.amountToTreasury, _swapInfo.treasury); oAmt_ = Assimilators.intakeNumeraire(_o.addr, _swapInfo.amountToUser); emit Trade( msg.sender, _swapData._origin, _swapData._target, oAmt_, _swapData._targetAmount, _swapInfo.amountToTreasury ); } function viewTargetSwap(Storage.Curve storage curve, address _origin, address _target, uint256 _targetAmount) external view returns (uint256 oAmt_) { (Storage.Assimilator memory _o, Storage.Assimilator memory _t) = getOriginAndTarget(curve, _origin, _target); if (_o.ix == _t.ix) { return Assimilators.viewRawAmount(_o.addr, Assimilators.viewNumeraireAmount(_t.addr, _targetAmount)); } (int128 _amt, int128 _oGLiq, int128 _nGLiq, int128[] memory _nBals, int128[] memory _oBals) = viewTargetSwapData(curve, _t.ix, _o.ix, _targetAmount, _t.addr); _amt = CurveMath.calculateTrade(curve, _oGLiq, _nGLiq, _oBals, _nBals, _amt, _o.ix); _amt = _amt.us_mul(ONE + curve.epsilon); oAmt_ = Assimilators.viewRawAmount(_o.addr, _amt); } function getOriginSwapData( Storage.Curve storage curve, uint256 _inputIx, uint256 _outputIx, address _assim, uint256 _amt ) private returns (int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory) { uint256 _length = curve.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); Storage.Assimilator[] memory _reserves = curve.assets; for (uint256 i = 0; i < _length; i++) { if (i != _inputIx) { nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr); } else { int128 _bal; (amt_, _bal) = Assimilators.intakeRawAndGetBalance(_assim, _amt); oBals_[i] = _bal.sub(amt_); nBals_[i] = _bal; } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return (amt_, oGLiq_, nGLiq_, oBals_, nBals_); } function getTargetSwapData( Storage.Curve storage curve, uint256 _inputIx, uint256 _outputIx, address _assim, address _recipient, uint256 _amt ) private returns (int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory) { uint256 _length = curve.assets.length; int128[] memory oBals_ = new int128[](_length); int128[] memory nBals_ = new int128[](_length); Storage.Assimilator[] memory _reserves = curve.assets; for (uint256 i = 0; i < _length; i++) { if (i != _inputIx) { nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(_reserves[i].addr); } else { int128 _bal; (amt_, _bal) = Assimilators.outputRawAndGetBalance(_assim, _recipient, _amt); oBals_[i] = _bal.sub(amt_); nBals_[i] = _bal; } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return (amt_, oGLiq_, nGLiq_, oBals_, nBals_); } function viewOriginSwapData( Storage.Curve storage curve, uint256 _inputIx, uint256 _outputIx, uint256 _amt, address _assim ) private view returns (int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory) { uint256 _length = curve.assets.length; int128[] memory nBals_ = new int128[](_length); int128[] memory oBals_ = new int128[](_length); for (uint256 i = 0; i < _length; i++) { if (i != _inputIx) { nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(curve.assets[i].addr); } else { int128 _bal; (amt_, _bal) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt); oBals_[i] = _bal; nBals_[i] = _bal.add(amt_); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return (amt_, oGLiq_, nGLiq_, nBals_, oBals_); } function viewTargetSwapData( Storage.Curve storage curve, uint256 _inputIx, uint256 _outputIx, uint256 _amt, address _assim ) private view returns (int128 amt_, int128 oGLiq_, int128 nGLiq_, int128[] memory, int128[] memory) { uint256 _length = curve.assets.length; int128[] memory nBals_ = new int128[](_length); int128[] memory oBals_ = new int128[](_length); for (uint256 i = 0; i < _length; i++) { if (i != _inputIx) { nBals_[i] = oBals_[i] = Assimilators.viewNumeraireBalance(curve.assets[i].addr); } else { int128 _bal; (amt_, _bal) = Assimilators.viewNumeraireAmountAndBalance(_assim, _amt); amt_ = amt_.neg(); oBals_[i] = _bal; nBals_[i] = _bal.add(amt_); } oGLiq_ += oBals_[i]; nGLiq_ += nBals_[i]; } nGLiq_ = nGLiq_.sub(amt_); nBals_[_outputIx] = ABDKMath64x64.sub(nBals_[_outputIx], amt_); return (amt_, oGLiq_, nGLiq_, nBals_, oBals_); } }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "./Storage.sol"; import "./Assimilators.sol"; import "./lib/ABDKMath64x64.sol"; library ViewLiquidity { using ABDKMath64x64 for int128; function viewLiquidity(Storage.Curve storage curve) external view returns (uint256 total_, uint256[] memory individual_) { uint256 _length = curve.assets.length; individual_ = new uint256[](_length); for (uint256 i = 0; i < _length; i++) { uint256 _liquidity = Assimilators.viewNumeraireBalance(curve.assets[i].addr).mulu(1e18); total_ += _liquidity; individual_[i] = _liquidity; } return (total_, individual_); } }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "./interfaces/IOracle.sol"; import "./Assimilators.sol"; contract Storage { struct Curve { // Curve parameters int128 alpha; int128 beta; int128 delta; int128 epsilon; int128 lambda; int128[] weights; // Assets and their assimilators Assimilator[] assets; mapping(address => Assimilator) assimilators; // Oracles to determine the price // Note that 0'th index should always be USDC 1e18 // Oracle's pricing should be denominated in Currency/USDC mapping(address => IOracle) oracles; // ERC20 Interface uint256 totalSupply; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowances; } struct Assimilator { address addr; uint8 ix; } // Curve parameters Curve public curve; // Ownable address public owner; string public name; string public symbol; uint8 public constant decimals = 18; address[] public derivatives; address[] public numeraires; address[] public reserves; // Curve operational state bool public frozen = false; bool public emergency = false; bool public notEntered = true; }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; interface IAssimilator { function oracleDecimals() external view returns (uint256); function underlyingToken() external view returns (address); function getWeth() external view returns (address); function tokenDecimals() external view returns (uint256); function getRate() external view returns (uint256); function intakeRaw(uint256 amount) external payable returns (int128); function intakeRawAndGetBalance(uint256 amount) external payable returns (int128, int128); function intakeNumeraire(int128 amount) external payable returns (uint256); function intakeNumeraireLPRatio(uint256, uint256, uint256, uint256, uint256, uint256, address) external payable returns (uint256); function outputRaw(address dst, uint256 amount) external returns (int128); function outputRawAndGetBalance(address dst, uint256 amount) external returns (int128, int128); function outputNumeraire(address dst, int128 amount, bool toETH) external payable returns (uint256); function viewRawAmount(int128) external view returns (uint256); function viewRawAmountLPRatio(uint256, uint256, address, int128) external view returns (uint256); function viewNumeraireAmount(uint256) external view returns (int128); function viewNumeraireBalanceLPRatio(uint256, uint256, address) external view returns (int128); function viewNumeraireBalance(address) external view returns (int128); function viewNumeraireAmountAndBalance(address, uint256) external view returns (int128, int128); function transferFee(int128, address) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface ICurve { function getWeth() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import "./interfaces/ICurveFactory.sol"; import "./interfaces/IOracle.sol"; struct OriginSwapData { address _origin; address _target; uint256 _originAmount; address _recipient; address _curveFactory; } struct TargetSwapData { address _origin; address _target; uint256 _targetAmount; address _recipient; address _curveFactory; } struct SwapInfo { int128 totalAmount; int128 totalFee; int128 amountToUser; int128 amountToTreasury; int128 protocolFeePercentage; address treasury; ICurveFactory curveFactory; } struct DepositData { uint256 deposits; uint256 minQuote; uint256 minBase; uint256 quoteAmt; uint256 maxQuote; uint256 maxBase; uint256 baseAmt; address token0; uint256 token0Bal; uint256 token1Bal; } struct IntakeNumLpRatioInfo { uint256 baseWeight; uint256 minBase; uint256 maxBase; uint256 baseAmt; uint256 quoteWeight; uint256 minQuote; uint256 maxQuote; uint256 quoteAmt; int128 amount; address token0; uint256 token0Bal; uint256 token1Bal; }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; interface IOracle { function acceptOwnership() external; function accessController() external view returns (address); function aggregator() external view returns (address); function confirmAggregator(address _aggregator) external; function decimals() external view returns (uint8); function description() external view returns (string memory); function getAnswer(uint256 _roundId) external view returns (int256); function getRoundData(uint80 _roundId) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); function getTimestamp(uint256 _roundId) external view returns (uint256); function latestAnswer() external view returns (int256); function latestRound() external view returns (uint256); function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); function latestTimestamp() external view returns (uint256); function owner() external view returns (address); function phaseAggregators(uint16) external view returns (address); function phaseId() external view returns (uint16); function proposeAggregator(address _aggregator) external; function proposedAggregator() external view returns (address); function proposedGetRoundData(uint80 _roundId) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); function proposedLatestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); function setController(address _accessController) external; function transferOwnership(address _to) external; function version() external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { 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) { 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 v4.4.1 (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 IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ 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.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.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 ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the 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 {} }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "./Storage.sol"; import "./lib/UnsafeMath64x64.sol"; import "./lib/ABDKMath64x64.sol"; library CurveMath { int128 private constant ONE = 0x10000000000000000; int128 private constant MAX = 0x4000000000000000; // .25 in layman's terms int128 private constant MAX_DIFF = -0x10C6F7A0B5EE; int128 private constant ONE_WEI = 0x12; using ABDKMath64x64 for int128; using UnsafeMath64x64 for int128; using ABDKMath64x64 for uint256; // This is used to prevent stack too deep errors function calculateFee(int128 _gLiq, int128[] memory _bals, Storage.Curve storage curve, int128[] memory _weights) internal view returns (int128 psi_) { int128 _beta = curve.beta; int128 _delta = curve.delta; psi_ = calculateFee(_gLiq, _bals, _beta, _delta, _weights); } function calculateFee(int128 _gLiq, int128[] memory _bals, int128 _beta, int128 _delta, int128[] memory _weights) internal pure returns (int128 psi_) { uint256 _length = _bals.length; for (uint256 i = 0; i < _length; i++) { int128 _ideal = _gLiq.mul(_weights[i]); psi_ += calculateMicroFee(_bals[i], _ideal, _beta, _delta); } } function calculateMicroFee(int128 _bal, int128 _ideal, int128 _beta, int128 _delta) private pure returns (int128 fee_) { if (_bal < _ideal) { int128 _threshold = _ideal.mul(ONE - _beta); if (_bal < _threshold) { int128 _feeMargin = _threshold - _bal; fee_ = _feeMargin.mul(_delta); fee_ = fee_.div(_ideal); if (fee_ > MAX) fee_ = MAX; fee_ = fee_.mul(_feeMargin); } else { fee_ = 0; } } else { int128 _threshold = _ideal.mul(ONE + _beta); if (_bal > _threshold) { int128 _feeMargin = _bal - _threshold; fee_ = _feeMargin.mul(_delta); fee_ = fee_.div(_ideal); if (fee_ > MAX) fee_ = MAX; fee_ = fee_.mul(_feeMargin); } else { fee_ = 0; } } } function calculateTrade( Storage.Curve storage curve, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals, int128 _inputAmt, uint256 _outputIndex ) internal view returns (int128 outputAmt_) { outputAmt_ = -_inputAmt; int128 _lambda = curve.lambda; int128[] memory _weights = curve.weights; int128 _omega = calculateFee(_oGLiq, _oBals, curve, _weights); int128 _psi; for (uint256 i = 0; i < 32; i++) { _psi = calculateFee(_nGLiq, _nBals, curve, _weights); int128 prevAmount; { prevAmount = outputAmt_; outputAmt_ = _omega < _psi ? -(_inputAmt + _omega - _psi) : -(_inputAmt + _lambda.mul(_omega - _psi)); } if (outputAmt_ / 1e13 == prevAmount / 1e13) { _nGLiq = _oGLiq + _inputAmt + outputAmt_; _nBals[_outputIndex] = _oBals[_outputIndex] + outputAmt_; enforceHalts(curve, _oGLiq, _nGLiq, _oBals, _nBals, _weights); enforceSwapInvariant(_oGLiq, _omega, _nGLiq, _psi); return outputAmt_; } else { _nGLiq = _oGLiq + _inputAmt + outputAmt_; _nBals[_outputIndex] = _oBals[_outputIndex].add(outputAmt_); } } revert("Curve/swap-convergence-failed"); } function calculateLiquidityMembrane( Storage.Curve storage curve, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals ) internal view returns (int128 curves_) { enforceHalts(curve, _oGLiq, _nGLiq, _oBals, _nBals, curve.weights); int128 _omega; int128 _psi; { int128 _beta = curve.beta; int128 _delta = curve.delta; int128[] memory _weights = curve.weights; _omega = calculateFee(_oGLiq, _oBals, _beta, _delta, _weights); _psi = calculateFee(_nGLiq, _nBals, _beta, _delta, _weights); } int128 _feeDiff = _psi.sub(_omega); int128 _liqDiff = _nGLiq.sub(_oGLiq); int128 _oUtil = _oGLiq.sub(_omega); int128 _totalShells = curve.totalSupply.divu(1e18); int128 _curveMultiplier; if (_totalShells == 0) { curves_ = _nGLiq.sub(_psi); } else if (_feeDiff >= 0) { _curveMultiplier = _liqDiff.sub(_feeDiff).div(_oUtil); } else { _curveMultiplier = _liqDiff.sub(curve.lambda.mul(_feeDiff)); _curveMultiplier = _curveMultiplier.div(_oUtil); } if (_totalShells != 0) { curves_ = _totalShells.mul(_curveMultiplier); } } function enforceSwapInvariant(int128 _oGLiq, int128 _omega, int128 _nGLiq, int128 _psi) private pure { int128 _nextUtil = _nGLiq - _psi; int128 _prevUtil = _oGLiq - _omega; int128 _diff = _nextUtil - _prevUtil; require(0 < _diff || _diff >= MAX_DIFF, "Curve/swap-invariant-violation"); } function enforceHalts( Storage.Curve storage curve, int128 _oGLiq, int128 _nGLiq, int128[] memory _oBals, int128[] memory _nBals, int128[] memory _weights ) private view { uint256 _length = _nBals.length; int128 _alpha = curve.alpha; for (uint256 i = 0; i < _length; i++) { int128 _nIdeal = _nGLiq.mul(_weights[i]); if (_nBals[i] > _nIdeal) { int128 _upperAlpha = ONE + _alpha; int128 _nHalt = _nIdeal.mul(_upperAlpha); if (_nBals[i] > _nHalt) { int128 _oHalt = _oGLiq.mul(_weights[i]).mul(_upperAlpha); if (_oBals[i] < _oHalt) revert("Curve/upper-halt-1"); if (_nBals[i] - _nHalt > _oBals[i] - _oHalt) { revert("Curve/upper-halt-2"); } } } else { int128 _lowerAlpha = ONE - _alpha; int128 _nHalt = _nIdeal.mul(_lowerAlpha); if (_nBals[i] < _nHalt) { int128 _oHalt = _oGLiq.mul(_weights[i]); _oHalt = _oHalt.mul(_lowerAlpha); if (_oBals[i] > _oHalt) revert("Curve/lower-halt"); if (_nHalt - _nBals[i] > _oHalt - _oBals[i]) { revert("Curve/lower-halt"); } } } } } }
// SPDX-License-Identifier: MIT // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. pragma solidity ^0.8.13; import "@openzeppelin/contracts/utils/Address.sol"; import "./interfaces/IAssimilator.sol"; import "./lib/ABDKMath64x64.sol"; import "./Structs.sol"; library Assimilators { using ABDKMath64x64 for int128; using Address for address; IAssimilator public constant iAsmltr = IAssimilator(address(0)); function delegate(address _callee, bytes memory _data) internal returns (bytes memory) { require(_callee.isContract(), "Assimilators/callee-is-not-a-contract"); // solhint-disable-next-line (bool _success, bytes memory returnData_) = _callee.delegatecall(_data); // solhint-disable-next-line assembly { if eq(_success, 0) { revert(add(returnData_, 0x20), returndatasize()) } } return returnData_; } function getRate(address _assim) internal view returns (uint256 amount_) { amount_ = IAssimilator(_assim).getRate(); } function viewRawAmount(address _assim, int128 _amt) internal view returns (uint256 amount_) { amount_ = IAssimilator(_assim).viewRawAmount(_amt); } function viewRawAmountLPRatio(address _assim, uint256 _baseWeight, uint256 _quoteWeight, int128 _amount) internal view returns (uint256 amount_) { amount_ = IAssimilator(_assim).viewRawAmountLPRatio(_baseWeight, _quoteWeight, address(this), _amount); } function viewNumeraireAmount(address _assim, uint256 _amt) internal view returns (int128 amt_) { amt_ = IAssimilator(_assim).viewNumeraireAmount(_amt); } function viewNumeraireAmountAndBalance(address _assim, uint256 _amt) internal view returns (int128 amt_, int128 bal_) { (amt_, bal_) = IAssimilator(_assim).viewNumeraireAmountAndBalance(address(this), _amt); } function viewNumeraireBalance(address _assim) internal view returns (int128 bal_) { bal_ = IAssimilator(_assim).viewNumeraireBalance(address(this)); } function viewNumeraireBalanceLPRatio(uint256 _baseWeight, uint256 _quoteWeight, address _assim) internal view returns (int128 bal_) { bal_ = IAssimilator(_assim).viewNumeraireBalanceLPRatio(_baseWeight, _quoteWeight, address(this)); } function intakeRaw(address _assim, uint256 _amt) internal returns (int128 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRaw.selector, _amt); amt_ = abi.decode(delegate(_assim, data), (int128)); } function intakeRawAndGetBalance(address _assim, uint256 _amt) internal returns (int128 amt_, int128 bal_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeRawAndGetBalance.selector, _amt); (amt_, bal_) = abi.decode(delegate(_assim, data), (int128, int128)); } function intakeNumeraire(address _assim, int128 _amt) internal returns (uint256 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.intakeNumeraire.selector, _amt); amt_ = abi.decode(delegate(_assim, data), (uint256)); } function intakeNumeraireLPRatio(address _assim, IntakeNumLpRatioInfo memory info) internal returns (uint256 amt_) { bytes memory data = abi.encodeWithSelector( iAsmltr.intakeNumeraireLPRatio.selector, info.minBase, info.maxBase, info.baseAmt, info.minQuote, info.maxQuote, info.quoteAmt, info.token0 ); amt_ = abi.decode(delegate(_assim, data), (uint256)); } function outputRaw(address _assim, address _dst, uint256 _amt) internal returns (int128 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputRaw.selector, _dst, _amt); amt_ = abi.decode(delegate(_assim, data), (int128)); amt_ = amt_.neg(); } function outputRawAndGetBalance(address _assim, address _dst, uint256 _amt) internal returns (int128 amt_, int128 bal_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputRawAndGetBalance.selector, _dst, _amt); (amt_, bal_) = abi.decode(delegate(_assim, data), (int128, int128)); amt_ = amt_.neg(); } function outputNumeraire(address _assim, address _dst, int128 _amt, bool _toETH) internal returns (uint256 amt_) { bytes memory data = abi.encodeWithSelector(iAsmltr.outputNumeraire.selector, _dst, _amt.abs(), _toETH); amt_ = abi.decode(delegate(_assim, data), (uint256)); } function transferFee(address _assim, int128 _amt, address _treasury) internal { bytes memory data = abi.encodeWithSelector(iAsmltr.transferFee.selector, _amt, _treasury); delegate(_assim, data); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; library UnsafeMath64x64 { /** * Calculate x * y rounding down. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function us_mul(int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) * y >> 64; return int128(result); } /** * Calculate x / y rounding towards zero. Revert on overflow or when y is * zero. * * @param x signed 64.64-bit fixed point number * @param y signed 64.64-bit fixed point number * @return signed 64.64-bit fixed point number */ function us_div(int128 x, int128 y) internal pure returns (int128) { int256 result = (int256(x) << 64) / y; return int128(result); } }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "@forge-std/=lib/forge-std/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": { "src/Curve.sol": { "Curves": "0x85e9690c2D4C6cAE31D96f9B5AfE6d111D165157" }, "src/Orchestrator.sol": { "Orchestrator": "0x1190da269FfE6F4567fED0C3c9BbA01F88372254" }, "src/ProportionalLiquidity.sol": { "ProportionalLiquidity": "0x0a7e79B7A4912Ea42F82e25B9c033919b97F6Fb0" }, "src/Swaps.sol": { "Swaps": "0x74982d2fd25cA0e0DeE702e40AfFd93Bae04D3a6" }, "src/ViewLiquidity.sol": { "ViewLiquidity": "0x1134daeAA652E11360631E3CC93e688204D9354b" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_assimFactory","type":"address"},{"internalType":"address","name":"_config","type":"address"},{"internalType":"address","name":"_weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"curve","type":"address"}],"name":"NewCurve","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"assimilatorFactory","outputs":[{"internalType":"contract IAssimilatorFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"contract IConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"curves","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_baseCurrency","type":"address"},{"internalType":"address","name":"_quoteCurrency","type":"address"}],"name":"getCurve","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolFee","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isDFXCurve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_baseCurrency","type":"address"},{"internalType":"address","name":"_quoteCurrency","type":"address"},{"internalType":"uint256","name":"_baseWeight","type":"uint256"},{"internalType":"uint256","name":"_quoteWeight","type":"uint256"},{"internalType":"contract IOracle","name":"_baseOracle","type":"address"},{"internalType":"contract IOracle","name":"_quoteOracle","type":"address"},{"internalType":"uint256","name":"_alpha","type":"uint256"},{"internalType":"uint256","name":"_beta","type":"uint256"},{"internalType":"uint256","name":"_feeAtHalt","type":"uint256"},{"internalType":"uint256","name":"_epsilon","type":"uint256"},{"internalType":"uint256","name":"_lambda","type":"uint256"}],"internalType":"struct CurveFactoryV3.CurveInfo","name":"_info","type":"tuple"}],"name":"newCurve","outputs":[{"internalType":"contract Curve","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c06040523480156200001157600080fd5b5060405162005f2538038062005f25833981016040819052620000349162000180565b6200003f3362000113565b6001600160a01b0383163b6200009c5760405162461bcd60e51b815260206004820152601460248201527f696e76616c69642d617373696d466163746f727900000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b0383811660805282163b620000ec5760405162461bcd60e51b815260206004820152600e60248201526d696e76616c69642d636f6e66696760901b604482015260640162000093565b600180546001600160a01b0319166001600160a01b039384161790551660a05250620001ca565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200017b57600080fd5b919050565b6000806000606084860312156200019657600080fd5b620001a18462000163565b9250620001b16020850162000163565b9150620001c16040850162000163565b90509250925092565b60805160a051615d1a6200020b60003960006101fe01526000818160ce015281816106f8015281816107bd01528181610866015261092a0152615d1a6000f3fe60806040523480156200001157600080fd5b5060043610620000c35760003560e01c80639611f3d9116200007a5780639611f3d91462000182578063a5a41031146200018c578063b483079b14620001aa578063dfcb53cd14620001c1578063f242862114620001f8578063f2fde38b146200022057600080fd5b80630d82a78d14620000c85780634ca98f68146200010d57806366903e801462000124578063715018a6146200015057806379502c55146200015c5780638da5cb5b1462000170575b600080fd5b620000f07f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b620000f06200011e36600462000f5e565b62000237565b620000f06200013536600462000f9c565b6002602052600090815260409020546001600160a01b031681565b6200015a6200029b565b005b600154620000f0906001600160a01b031681565b6000546001600160a01b0316620000f0565b620000f0620002b3565b6200019662000329565b604051600f9190910b815260200162000104565b620000f0620001bb3660046200108e565b6200039a565b620001e7620001d2366004620011c4565b60036020526000908152604090205460ff1681565b604051901515815260200162000104565b620000f07f000000000000000000000000000000000000000000000000000000000000000081565b6200015a62000231366004620011c4565b62000dfd565b6000808383604051602001620002639291906001600160a01b0392831681529116602082015260400190565b60408051601f198184030181529181528151602092830120600090815260029092529020546001600160a01b03169150505b92915050565b620002a562000e7c565b620002b1600062000ed8565b565b60015460408051639611f3d960e01b815290516000926001600160a01b031691639611f3d99160048083019260209291908290030181865afa158015620002fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003249190620011eb565b905090565b6001546040805163a5a4103160e01b815290516000926001600160a01b03169163a5a410319160048083019260209291908290030181865afa15801562000374573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200032491906200120b565b60608101516000906001600160a01b0316620003fd5760405162461bcd60e51b815260206004820152601b60248201527f71756f74652d63757272656e63792d7a65726f2d61646472657373000000000060448201526064015b60405180910390fd5b81606001516001600160a01b031682604001516001600160a01b031603620004685760405162461bcd60e51b815260206004820152601a60248201527f71756f74652d626173652d63757272656e636965732d73616d650000000000006044820152606401620003f4565b8160a0015182608001516200047e919062001230565b670de0b6b3a764000014620004c85760405162461bcd60e51b815260206004820152600f60248201526e696e76616c69642d7765696768747360881b6044820152606401620003f4565b600082606001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200050d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000533919062001252565b60ff169050600083604001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200057d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005a3919062001252565b60ff16905060006200064085604001518660600151604080518082018252600080825260209182018190528251808401845281815280830191825283516001600160a01b039687168185018190529590961686850181905284518088038601815260609788018652805190850120825284518085019190915280850195909552835180860385018152949095019092528251920191909120905290565b80516000908152600260205260409020549091506001600160a01b03161515806200068757506020808201516000908152600290915260409020546001600160a01b031615155b15620006c45760405162461bcd60e51b815260206004820152600b60248201526a706169722d65786973747360a81b6044820152606401620003f4565b60408581015160608701519151634206a40560e11b81526001600160a01b03918216600482015291811660248301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063840d480a90604401602060405180830381865afa15801562000742573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007689190620011eb565b90506001600160a01b0381166200083257606086015160c08701516040808901519051636b7f8b5960e11b81526001600160a01b039384166004820152918316602483015282166044820152606481018590527f00000000000000000000000000000000000000000000000000000000000000009091169063d6ff16b2906084016020604051808303816000875af115801562000809573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200082f9190620011eb565b90505b60608601516040808801519051634206a40560e11b81526001600160a01b03928316600482015290821660248201526000917f0000000000000000000000000000000000000000000000000000000000000000169063840d480a90604401602060405180830381865afa158015620008ae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008d49190620011eb565b90506001600160a01b0381166200099d5760408088015160e089015160608a01519251636b7f8b5960e11b81526001600160a01b03928316600482015290821660248201529181166044830152606482018790527f0000000000000000000000000000000000000000000000000000000000000000169063d6ff16b2906084016020604051808303816000875af115801562000974573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200099a9190620011eb565b90505b60408051600a8082526101608201909252600091602082016101408036833750506040805160028082526060820183529394506000939092509060208301908036833701905050905088604001518260008151811062000a015762000a0162001277565b60200260200101906001600160a01b031690816001600160a01b031681525050838260018151811062000a385762000a3862001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088604001518260028151811062000a735762000a7362001277565b60200260200101906001600160a01b031690816001600160a01b031681525050838260038151811062000aaa5762000aaa62001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088604001518260048151811062000ae55762000ae562001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088606001518260058151811062000b205762000b2062001277565b60200260200101906001600160a01b031690816001600160a01b031681525050828260068151811062000b575762000b5762001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088606001518260078151811062000b925762000b9262001277565b60200260200101906001600160a01b031690816001600160a01b031681525050828260088151811062000bc95762000bc962001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088606001518260098151811062000c045762000c0462001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088608001518160008151811062000c3f5762000c3f62001277565b6020026020010181815250508860a001518160018151811062000c665762000c6662001277565b602002602001018181525050600089600001518a60200151848430600160009054906101000a90046001600160a01b031660405162000ca59062000f28565b62000cb69695949392919062001312565b604051809103906000f08015801562000cd3573d6000803e3d6000fd5b506101008b01516101208c01516101408d01516101608e01516101808f0151604051631b05177160e31b8152600481019590955260248501939093526044840191909152606483015260848201529091506001600160a01b0382169063d828bb889060a401600060405180830381600087803b15801562000d5357600080fd5b505af115801562000d68573d6000803e3d6000fd5b50508751600090815260026020908152604080832080546001600160a01b0388166001600160a01b03199182168117909255838d015185528285208054909116821790558084526003909252808320805460ff191660011790558a519051919450925033917fe7a19de9e8788cc07c144818f2945144acd6234f790b541aa1010371c8b2a73b91a49998505050505050505050565b62000e0762000e7c565b6001600160a01b03811662000e6e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401620003f4565b62000e798162000ed8565b50565b6000546001600160a01b03163314620002b15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003f4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61491d80620013c883390190565b6001600160a01b038116811462000e7957600080fd5b803562000f598162000f36565b919050565b6000806040838503121562000f7257600080fd5b823562000f7f8162000f36565b9150602083013562000f918162000f36565b809150509250929050565b60006020828403121562000faf57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6040516101a0810167ffffffffffffffff8111828210171562000ff35762000ff362000fb6565b60405290565b600082601f8301126200100b57600080fd5b813567ffffffffffffffff8082111562001029576200102962000fb6565b604051601f8301601f19908116603f0116810190828211818310171562001054576200105462000fb6565b816040528381528660208588010111156200106e57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215620010a157600080fd5b813567ffffffffffffffff80821115620010ba57600080fd5b908301906101a08286031215620010d057600080fd5b620010da62000fcc565b823582811115620010ea57600080fd5b620010f88782860162000ff9565b8252506020830135828111156200110e57600080fd5b6200111c8782860162000ff9565b602083015250620011306040840162000f4c565b6040820152620011436060840162000f4c565b60608201526080830135608082015260a083013560a08201526200116a60c0840162000f4c565b60c08201526200117d60e0840162000f4c565b60e082015261010083810135908201526101208084013590820152610140808401359082015261016080840135908201526101809283013592810192909252509392505050565b600060208284031215620011d757600080fd5b8135620011e48162000f36565b9392505050565b600060208284031215620011fe57600080fd5b8151620011e48162000f36565b6000602082840312156200121e57600080fd5b815180600f0b8114620011e457600080fd5b808201808211156200029557634e487b7160e01b600052601160045260246000fd5b6000602082840312156200126557600080fd5b815160ff81168114620011e457600080fd5b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b81811015620012b55760208185018101518683018201520162001297565b506000602082860101526020601f19601f83011685010191505092915050565b600081518084526020808501945080840160005b838110156200130757815187529582019590820190600101620012e9565b509495945050505050565b60c0815260006200132760c08301896200128d565b6020838203818501526200133c828a6200128d565b84810360408601528851808252828a0193509082019060005b818110156200137c5784516001600160a01b03168352938301939183019160010162001355565b50508481036060860152620013928189620012d5565b9350505050620013ad60808301856001600160a01b03169052565b6001600160a01b03831660a083015297965050505050505056fe60c06040526010805462ffffff1916620100001790553480156200002257600080fd5b506040516200491d3803806200491d83398101604081905262000045916200043b565b306080526001600160a01b038216620000ae5760405162461bcd60e51b815260206004820152602160248201527f43757276652f637572766520666163746f7279207a65726f20616464726573736044820152602160f81b606482015260840160405180910390fd5b600a80546001600160a01b03191633179055600b620000ce8782620005a7565b50600c620000dd8682620005a7565b50601080546301000000600160b81b03191663010000006001600160a01b038581169190910291909117909155601180546001600160a01b03191691831691909117905560405133906000907f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee67908290a3816001600160a01b031663f24286216040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200018d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001b3919062000673565b6001600160a01b031660a052604051635931eef160e11b8152731190da269ffe6f4567fed0c3c9bba01f883722549063b263dde2906200020690600090600e90600f90600d908b908b9060040162000698565b60006040518083038186803b1580156200021f57600080fd5b505af415801562000234573d6000803e3d6000fd5b5050505050505050505062000740565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171562000285576200028562000244565b604052919050565b600082601f8301126200029f57600080fd5b81516001600160401b03811115620002bb57620002bb62000244565b6020620002d1601f8301601f191682016200025a565b8281528582848701011115620002e657600080fd5b60005b8381101562000306578581018301518282018401528201620002e9565b506000928101909101919091529392505050565b60006001600160401b0382111562000336576200033662000244565b5060051b60200190565b80516001600160a01b03811681146200035857600080fd5b919050565b600082601f8301126200036f57600080fd5b815160206200038862000382836200031a565b6200025a565b82815260059290921b84018101918181019086841115620003a857600080fd5b8286015b84811015620003ce57620003c08162000340565b8352918301918301620003ac565b509695505050505050565b600082601f830112620003eb57600080fd5b81516020620003fe62000382836200031a565b82815260059290921b840181019181810190868411156200041e57600080fd5b8286015b84811015620003ce578051835291830191830162000422565b60008060008060008060c087890312156200045557600080fd5b86516001600160401b03808211156200046d57600080fd5b6200047b8a838b016200028d565b975060208901519150808211156200049257600080fd5b620004a08a838b016200028d565b96506040890151915080821115620004b757600080fd5b620004c58a838b016200035d565b95506060890151915080821115620004dc57600080fd5b50620004eb89828a01620003d9565b935050620004fc6080880162000340565b91506200050c60a0880162000340565b90509295509295509295565b600181811c908216806200052d57607f821691505b6020821081036200054e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620005a257600081815260208120601f850160051c810160208610156200057d5750805b601f850160051c820191505b818110156200059e5782815560010162000589565b5050505b505050565b81516001600160401b03811115620005c357620005c362000244565b620005db81620005d4845462000518565b8462000554565b602080601f831160018114620006135760008415620005fa5750858301515b600019600386901b1c1916600185901b1785556200059e565b600085815260208120601f198616915b82811015620006445788860151825594840194600190910190840162000623565b5085821015620006635787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156200068657600080fd5b620006918262000340565b9392505050565b600060c082018883526020888185015287604085015286606085015260c0608085015281865180845260e086019150828801935060005b81811015620006f65784516001600160a01b031683529383019391830191600101620006cf565b505084810360a0860152855180825290820192508186019060005b818110156200072f5782518552938301939183019160010162000711565b50929b9a5050505050505050505050565b60805160a051614171620007ac6000396000818161034601528181611352015281816113d0015281816116400152818161172e0152818161185b01528181611899015281816120de0152818161214d0152818161218d0152613103015260006134b301526141716000f3fe60806040526004361061024a5760003560e01c806370a0823111610139578063a8e9d528116100b6578063caa6fea41161007a578063caa6fea41461078e578063d828bb88146107ad578063dd62ed3e146107cd578063de3e2e2414610813578063e5cf8a5c14610833578063f2fde38b1461085357600080fd5b8063a8e9d528146106ee578063a9059cbb1461070e578063c0046e391461072e578063c7cdea371461074e578063c912ff7a1461076e57600080fd5b80638334278d116100fd5780638334278d14610659578063838e6a22146106795780638da5cb5b1461069957806395d89b41146106b9578063a3f5d8cc146106ce57600080fd5b806370a08231146105465780637165485d1461057c57806372b4129a146105f957806379a390a5146106195780637e932d321461063957600080fd5b806323b872dd116101c7578063525d0da71161018b578063525d0da7146104965780635872278a146104b6578063595520c7146104d65780636919ba27146105135780636f2ef95b1461052657600080fd5b806323b872dd146103e3578063313ce567146104035780633cae77f71461042a578063441a3e70146104635780634fe5da711461048357600080fd5b80630b2583c81161020e5780630b2583c814610309578063107c279f1461033757806318160ddd1461037e5780631a686502146103935780631f276b6e146103b657600080fd5b806301ffc9a7146102565780630501d5561461028b578063054f7d9c146102ad57806306fdde03146102c7578063095ea7b3146102e957600080fd5b3661025157005b600080fd5b34801561026257600080fd5b50610276610271366004613801565b610873565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102ab6102a636600461383c565b6108c5565b005b3480156102b957600080fd5b506010546102769060ff1681565b3480156102d357600080fd5b506102dc6109d9565b604051610282919061387d565b3480156102f557600080fd5b506102766103043660046138c5565b610a67565b34801561031557600080fd5b506103296103243660046138f1565b610b49565b604051908152602001610282565b34801561034357600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b039091168152602001610282565b34801561038a57600080fd5b50600754610329565b34801561039f57600080fd5b506103a8610e70565b60405161028292919061397d565b3480156103c257600080fd5b506103d66103d1366004613996565b610ef6565b60405161028291906139b8565b3480156103ef57600080fd5b506102766103fe3660046139cb565b61101d565b34801561040f57600080fd5b50610418601281565b60405160ff9091168152602001610282565b34801561043657600080fd5b50610366610445366004613a0c565b6001600160a01b039081166000908152600560205260409020541690565b34801561046f57600080fd5b506103d661047e366004613996565b61112f565b6103a8610491366004613a29565b6111b5565b3480156104a257600080fd5b506103296104b13660046139cb565b6119b8565b3480156104c257600080fd5b506103a86104d1366004613a29565b611b01565b3480156104e257600080fd5b506104eb611ef3565b604080519586526020860194909452928401919091526060830152608082015260a001610282565b610329610521366004613a6c565b611f87565b34801561053257600080fd5b506103a8610541366004613aa1565b61228b565b34801561055257600080fd5b50610329610561366004613a0c565b6001600160a01b031660009081526008602052604090205490565b34801561058857600080fd5b506000546001546002546007546105bc93600f81810b94600160801b92839004820b9481830b9493909104820b92910b9086565b60408051600f97880b815295870b602087015293860b9385019390935290840b606084015290920b608082015260a081019190915260c001610282565b34801561060557600080fd5b506103296106143660046138f1565b6124de565b34801561062557600080fd5b506102ab610634366004613aba565b61273f565b34801561064557600080fd5b506102ab61065436600461383c565b61288b565b34801561066557600080fd5b50610366610674366004613aa1565b61298f565b34801561068557600080fd5b506103296106943660046139cb565b6129b9565b3480156106a557600080fd5b50600a54610366906001600160a01b031681565b3480156106c557600080fd5b506102dc612abd565b3480156106da57600080fd5b506010546102769062010000900460ff1681565b3480156106fa57600080fd5b50610366610709366004613aa1565b612aca565b34801561071a57600080fd5b506102766107293660046138c5565b612ada565b34801561073a57600080fd5b50610366610749366004613aa1565b612b8f565b34801561075a57600080fd5b506103d6610769366004613996565b612b9f565b34801561077a57600080fd5b506102ab610789366004613a0c565b612c6b565b34801561079a57600080fd5b5060105461027690610100900460ff1681565b3480156107b957600080fd5b506102ab6107c8366004613b16565b612e62565b3480156107d957600080fd5b506103296107e8366004613b51565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b34801561081f57600080fd5b5061032961082e366004613b8a565b612fab565b34801561083f57600080fd5b506103d661084e366004613aa1565b6131fe565b34801561085f57600080fd5b506102ab61086e366004613a0c565b61332b565b60006301ffc9a760e01b6001600160e01b0319831614806108a457506307f5828d60e41b6001600160e01b03198316145b806108bf57506336372b0760e01b6001600160e01b03198316145b92915050565b600a546001600160a01b03163314806109655750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561092c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109509190613bc5565b6001600160a01b0316336001600160a01b0316145b61098a5760405162461bcd60e51b815260040161098190613be2565b60405180910390fd5b60405181151581527fa44450e52bea871e50cfee059fbe027c26ff43fd7534c06b7de61d90b58ab3c19060200160405180910390a1601080549115156101000261ff0019909216919091179055565b600b80546109e690613c19565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1290613c19565b8015610a5f5780601f10610a3457610100808354040283529160200191610a5f565b820191906000526020600020905b815481529060010190602001808311610a4257829003601f168201915b505050505081565b60105460009062010000900460ff16610a925760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055610aa66134a8565b60405163e60ac42960e01b8152600060048201526001600160a01b0384166024820152604481018390527385e9690c2d4c6cae31d96f9b5afe6d111d1651579063e60ac429906064015b602060405180830381865af4158015610b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b319190613c7d565b6010805462ff00001916620100001790559392505050565b600081804210610b6b5760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be29190613c7d565b15610bff5760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615610c225760405162461bcd60e51b815260040161098190613d2e565b610c2a6134a8565b601054610100900460ff1615610c525760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff16610c7a5760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916908190556040805160a0810182526001600160a01b038a8116825289811660208084018290528385018b905233606085018190526301000000909604909216608084015283516370a0823160e01b8152600481019590955292519193600093926370a08231926024808401939192918290030181865afa158015610d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d309190613ddb565b60405163fd17568b60e01b81529091507374982d2fd25ca0e0dee702e40affd93bae04d3a69063fd17568b90610d6f9060009086908290600401613e31565b602060405180830381865af4158015610d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db09190613ddb565b5060608201516040516370a0823160e01b81526001600160a01b0391821660048201526000918a16906370a0823190602401602060405180830381865afa158015610dff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e239190613ddb565b9050610e2f8282613e6b565b945086851015610e515760405162461bcd60e51b815260040161098190613e7e565b50506010805462ff000019166201000017905550909695505050505050565b604051633745793960e11b815260006004820181905290606090731134daeaa652e11360631e3cc93e688204d9354b90636e8af27290602401600060405180830381865af4158015610ec6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610eee9190810190613f5b565b915091509091565b601054606090610100900460ff16610f205760405162461bcd60e51b815260040161098190613d7e565b81804210610f405760405162461bcd60e51b815260040161098190613c9a565b60105462010000900460ff16610f685760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055610f7c6134a8565b60405163eaadf2b560e01b8152600060048201819052602482018690526044820152730a7e79b7a4912ea42f82e25b9c033919b97f6fb09063eaadf2b5906064015b600060405180830381865af4158015610fdb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110039190810190613fa2565b9150506010805462ff000019166201000017905592915050565b60105460009062010000900460ff166110485760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916905561105c6134a8565b601054610100900460ff16156110845760405162461bcd60e51b815260040161098190613d7e565b6040516303a90f6960e31b8152600060048201526001600160a01b03808616602483015284166044820152606481018390527385e9690c2d4c6cae31d96f9b5afe6d111d16515790631d487b4890608401602060405180830381865af41580156110f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111169190613c7d565b6010805462ff0000191662010000179055949350505050565b6060818042106111515760405162461bcd60e51b815260040161098190613c9a565b60105462010000900460ff166111795760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916905561118d6134a8565b601054610100900460ff1615610f7c5760405162461bcd60e51b815260040161098190613d7e565b60006060828042106111d95760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561122c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112509190613c7d565b1561126d5760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156112905760405162461bcd60e51b815260040161098190613d2e565b60105462010000900460ff166112b85760405162461bcd60e51b815260040161098190613c53565b6010805462ff0000191690556112cc6134a8565b601054610100900460ff16156112f45760405162461bcd60e51b815260040161098190613d7e565b6000891161133f5760405162461bcd60e51b815260206004820152601860248201527743757276652f6465706f7369745f62656c6f775f7a65726f60401b6044820152606401610981565b6113488961228b565b80935081945050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156113ab57600080fd5b505af11580156113bf573d6000803e3d6000fd5b506113fc9350506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016915030905033346134df565b6114046137a5565b89815260208101899052604081018890526080810187905260a081018690528251839060009061143657611436613fd7565b60200260200101518160c00181815250508260018151811061145a5761145a613fd7565b6020026020010151816060018181525050600f60008154811061147f5761147f613fd7565b60009182526020822001546001600160a01b031660e0830152600f80549091906114ab576114ab613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156114fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115209190613ddb565b610100820152600f8054600190811061153b5761153b613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561158c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b09190613ddb565b610120820152604051629d2ea960e41b8152730a7e79b7a4912ea42f82e25b9c033919b97f6fb0906309d2ea90906115ef906000908590600401613fed565b600060405180830381865af415801561160c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116349190810190613f5b565b809450819550505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600060040160008154811061167f5761167f613fd7565b6000918252602091829020015460408051632495a59960e01b815290516001600160a01b0390921692632495a599926004808401938290030181865afa1580156116cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f19190613bc5565b6001600160a01b03160361172c578360008151811061171257611712613fd7565b6020026020010151346117259190613e6b565b9050611848565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600060040160018154811061176d5761176d613fd7565b6000918252602091829020015460408051632495a59960e01b815290516001600160a01b0390921692632495a599926004808401938290030181865afa1580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df9190613bc5565b6001600160a01b031603611800578360018151811061171257611712613fd7565b60405162461bcd60e51b815260206004820152601860248201527f43757276652f4465706f73697420455448206661696c656400000000000000006044820152606401610981565b8015611997576118836001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330846134df565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156118e557600080fd5b505af11580156118f9573d6000803e3d6000fd5b50506040516000925033915083908381818185875af1925050503d806000811461193f576040519150601f19603f3d011682016040523d82523d6000602084013e611944565b606091505b50509050806119955760405162461bcd60e51b815260206004820152601960248201527f43757276652f455448207472616e73666572206661696c6564000000000000006044820152606401610981565b505b5050506010805462ff00001916620100001790559097909650945050505050565b601154604080516306a8e1cd60e41b815290516000926001600160a01b031691636a8e1cd09160048083019260209291908290030181865afa158015611a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a269190613c7d565b15611a435760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615611a665760405162461bcd60e51b815260040161098190613d2e565b6040516315be82e960e21b8152600060048201526001600160a01b03808616602483015284166044820152606481018390527374982d2fd25ca0e0dee702e40affd93bae04d3a6906356fa0ba4906084015b602060405180830381865af4158015611ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af99190613ddb565b949350505050565b6000606082804210611b255760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9c9190613c7d565b15611bb95760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615611bdc5760405162461bcd60e51b815260040161098190613d2e565b60105462010000900460ff16611c045760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055611c186134a8565b601054610100900460ff1615611c405760405162461bcd60e51b815260040161098190613d7e565b60008911611c8b5760405162461bcd60e51b815260206004820152601860248201527743757276652f6465706f7369745f62656c6f775f7a65726f60401b6044820152606401610981565b611c948961228b565b9093509150611ca16137a5565b89815260208101899052604081018890526080810187905260a0810186905282518390600090611cd357611cd3613fd7565b60200260200101518160c001818152505082600181518110611cf757611cf7613fd7565b6020026020010151816060018181525050600f600081548110611d1c57611d1c613fd7565b60009182526020822001546001600160a01b031660e0830152600f8054909190611d4857611d48613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dbd9190613ddb565b610100820152600f80546001908110611dd857611dd8613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4d9190613ddb565b610120820152604051629d2ea960e41b8152730a7e79b7a4912ea42f82e25b9c033919b97f6fb0906309d2ea9090611e8c906000908590600401613fed565b600060405180830381865af4158015611ea9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ed19190810190613f5b565b6010805462ff0000191662010000179055909b909a5098505050505050505050565b6000806000806000731190da269ffe6f4567fed0c3c9bba01f8837225463faa50b5d60006040518263ffffffff1660e01b8152600401611f3591815260200190565b60a060405180830381865af4158015611f52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f769190614079565b945094509450945094509091929394565b600081804210611fa95760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120209190613c7d565b1561203d5760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156120605760405162461bcd60e51b815260040161098190613d2e565b6120686134a8565b601054610100900460ff16156120905760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff166120b85760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916905560408051630d0e30db60e41b815290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163d0e30db091349160048082019260009290919082900301818588803b15801561212857600080fd5b505af115801561213c573d6000803e3d6000fd5b506121799350506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016915030905033346134df565b6040805160a0810182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682528781166020830152348284015233606083015260105463010000009004166080820152905163fd17568b60e01b81527374982d2fd25ca0e0dee702e40affd93bae04d3a69063fd17568b9061220e9060009085908290600401613e31565b602060405180830381865af415801561222b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224f9190613ddb565b9250848310156122715760405162461bcd60e51b815260040161098190613e7e565b50506010805462ff00001916620100001790559392505050565b60006060601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123069190613c7d565b156123235760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156123465760405162461bcd60e51b815260040161098190613d2e565b604080516002808252606082018352600092839291906020830190803683370190505060405163822f39d560e01b81526000600482015260248101879052909150730a7e79b7a4912ea42f82e25b9c033919b97f6fb09063822f39d590604401600060405180830381865af41580156123c3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526123eb9190810190613f5b565b909250905060008261240c876ec097ce7bc90715b34b9f10000000006140b9565b61241691906140d0565b90506ec097ce7bc90715b34b9f1000000000818360008151811061243c5761243c613fd7565b602002602001015161244e91906140b9565b61245891906140d0565b8260008151811061246b5761246b613fd7565b6020026020010181815250506ec097ce7bc90715b34b9f1000000000818360018151811061249b5761249b613fd7565b60200260200101516124ad91906140b9565b6124b791906140d0565b826001815181106124ca576124ca613fd7565b602090810291909101015250939492505050565b6000818042106125005760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612553573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125779190613c7d565b156125945760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156125b75760405162461bcd60e51b815260040161098190613d2e565b6125bf6134a8565b601054610100900460ff16156125e75760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff1661260f5760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916908190556040805160a0810182526001600160a01b038a811682528981166020830152818301889052336060830152630100000090930490921660808301525163498e2a2560e11b81527374982d2fd25ca0e0dee702e40affd93bae04d3a69063931c544a906126909060009085906004016140f2565b602060405180830381865af41580156126ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d19190613ddb565b9250858311156127235760405162461bcd60e51b815260206004820152601d60248201527f43757276652f61626f76652d6d61782d6f726967696e2d616d6f756e740000006044820152606401610981565b50506010805462ff000019166201000017905595945050505050565b600a546001600160a01b03163314806127df5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ca9190613bc5565b6001600160a01b0316336001600160a01b0316145b6127fb5760405162461bcd60e51b815260040161098190613be2565b604051632e6ce08560e11b8152600060048201526001600160a01b0380861660248301528085166044830152808416606483015282166084820152731190da269ffe6f4567fed0c3c9bba01f8837225490635cd9c10a9060a40160006040518083038186803b15801561286d57600080fd5b505af4158015612881573d6000803e3d6000fd5b5050505050505050565b600a546001600160a01b031633148061292b5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129169190613bc5565b6001600160a01b0316336001600160a01b0316145b6129475760405162461bcd60e51b815260040161098190613be2565b60405181151581527f7c029deaca9b6c66abb68e5f874a812822f0fcaa52a890f980a7ab1afb5edba69060200160405180910390a16010805460ff1916911515919091179055565b600f818154811061299f57600080fd5b6000918252602090912001546001600160a01b0316905081565b601154604080516306a8e1cd60e41b815290516000926001600160a01b031691636a8e1cd09160048083019260209291908290030181865afa158015612a03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a279190613c7d565b15612a445760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615612a675760405162461bcd60e51b815260040161098190613d2e565b604051637dba2aed60e11b8152600060048201526001600160a01b03808616602483015284166044820152606481018390527374982d2fd25ca0e0dee702e40affd93bae04d3a69063fb7455da90608401611ab8565b600c80546109e690613c19565b600e818154811061299f57600080fd5b60105460009062010000900460ff16612b055760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055612b196134a8565b601054610100900460ff1615612b415760405162461bcd60e51b815260040161098190613d7e565b60405163a4bcd45960e01b8152600060048201526001600160a01b0384166024820152604481018390527385e9690c2d4c6cae31d96f9b5afe6d111d1651579063a4bcd45990606401610af0565b600d818154811061299f57600080fd5b606081804210612bc15760405162461bcd60e51b815260040161098190613c9a565b60105462010000900460ff16612be95760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055612bfd6134a8565b601054610100900460ff1615612c255760405162461bcd60e51b815260040161098190613d7e565b60405163eaadf2b560e01b8152600060048201526024810185905260016044820152730a7e79b7a4912ea42f82e25b9c033919b97f6fb09063eaadf2b590606401610fbe565b600a546001600160a01b0316331480612d0b5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf69190613bc5565b6001600160a01b0316336001600160a01b0316145b612d275760405162461bcd60e51b815260040161098190613be2565b60005b600e54811015612e3a57600e8181548110612d4757612d47613fd7565b6000918252602090912001546001600160a01b0390811690831603612dae5760405162461bcd60e51b815260206004820152601d60248201527f43757276652f63616e6e6f742d64656c6574652d6e756d6572616972650000006044820152606401610981565b600f8181548110612dc157612dc1613fd7565b6000918252602090912001546001600160a01b0390811690831603612e285760405162461bcd60e51b815260206004820152601b60248201527f43757276652f63616e6e6f742d64656c6574652d7265736572766500000000006044820152606401610981565b80612e3281614106565b915050612d2a565b506001600160a01b0316600090815260056020526040902080546001600160a81b0319169055565b600a546001600160a01b0316331480612f025750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ec9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eed9190613bc5565b6001600160a01b0316336001600160a01b0316145b612f1e5760405162461bcd60e51b815260040161098190613be2565b60405163231888b760e01b8152600060048201526024810186905260448101859052606481018490526084810183905260a48101829052731190da269ffe6f4567fed0c3c9bba01f883722549063231888b79060c40160006040518083038186803b158015612f8c57600080fd5b505af4158015612fa0573d6000803e3d6000fd5b505050505050505050565b600081804210612fcd5760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613020573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130449190613c7d565b156130615760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156130845760405162461bcd60e51b815260040161098190613d2e565b61308c6134a8565b601054610100900460ff16156130b45760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff166130dc5760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916908190556040805160a0810182526001600160a01b0389811682527f000000000000000000000000000000000000000000000000000000000000000081166020830152818301899052336060830152630100000090930490921660808301525163fd17568b60e01b81527374982d2fd25ca0e0dee702e40affd93bae04d3a69063fd17568b90613180906000908590600190600401613e31565b602060405180830381865af415801561319d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c19190613ddb565b9250848310156131e35760405162461bcd60e51b815260040161098190613e7e565b50506010805462ff0000191662010000179055949350505050565b601154604080516306a8e1cd60e41b815290516060926001600160a01b031691636a8e1cd09160048083019260209291908290030181865afa158015613248573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326c9190613c7d565b156132895760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156132ac5760405162461bcd60e51b815260040161098190613d2e565b6040516330771ac760e11b81526000600482015260248101839052730a7e79b7a4912ea42f82e25b9c033919b97f6fb0906360ee358e90604401600060405180830381865af4158015613303573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108bf9190810190613fa2565b600a546001600160a01b03163314806133cb5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa158015613392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b69190613bc5565b6001600160a01b0316336001600160a01b0316145b6133e75760405162461bcd60e51b815260040161098190613be2565b6001600160a01b03811661344c5760405162461bcd60e51b815260206004820152602660248201527f43757276652f6e65772d6f776e65722d63616e6e6f742d62652d7a65726f2d6160448201526564647265737360d01b6064820152608401610981565b600a546040516001600160a01b038084169216907f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee6790600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146134dd57600080fd5b565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261353990859061353f565b50505050565b6000613594826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136169092919063ffffffff16565b80519091501561361157808060200190518101906135b29190613c7d565b6136115760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610981565b505050565b6060611af9848460008561362c565b9392505050565b60608247101561368d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610981565b600080866001600160a01b031685876040516136a9919061411f565b60006040518083038185875af1925050503d80600081146136e6576040519150601f19603f3d011682016040523d82523d6000602084013e6136eb565b606091505b50915091506136fc87838387613707565b979650505050505050565b6060831561377657825160000361376f576001600160a01b0385163b61376f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610981565b5081611af9565b611af9838381511561378b5781518083602001fd5b8060405162461bcd60e51b8152600401610981919061387d565b6040518061014001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160008152602001600081525090565b60006020828403121561381357600080fd5b81356001600160e01b03198116811461362557600080fd5b801515811461383957600080fd5b50565b60006020828403121561384e57600080fd5b81356136258161382b565b60005b8381101561387457818101518382015260200161385c565b50506000910152565b602081526000825180602084015261389c816040850160208701613859565b601f01601f19169190910160400192915050565b6001600160a01b038116811461383957600080fd5b600080604083850312156138d857600080fd5b82356138e3816138b0565b946020939093013593505050565b600080600080600060a0868803121561390957600080fd5b8535613914816138b0565b94506020860135613924816138b0565b94979496505050506040830135926060810135926080909101359150565b600081518084526020808501945080840160005b8381101561397257815187529582019590820190600101613956565b509495945050505050565b828152604060208201526000611af96040830184613942565b600080604083850312156139a957600080fd5b50508035926020909101359150565b6020815260006136256020830184613942565b6000806000606084860312156139e057600080fd5b83356139eb816138b0565b925060208401356139fb816138b0565b929592945050506040919091013590565b600060208284031215613a1e57600080fd5b8135613625816138b0565b60008060008060008060c08789031215613a4257600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215613a8157600080fd5b8335613a8c816138b0565b95602085013595506040909401359392505050565b600060208284031215613ab357600080fd5b5035919050565b60008060008060808587031215613ad057600080fd5b8435613adb816138b0565b93506020850135613aeb816138b0565b92506040850135613afb816138b0565b91506060850135613b0b816138b0565b939692955090935050565b600080600080600060a08688031215613b2e57600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b60008060408385031215613b6457600080fd5b8235613b6f816138b0565b91506020830135613b7f816138b0565b809150509250929050565b60008060008060808587031215613ba057600080fd5b8435613bab816138b0565b966020860135965060408601359560600135945092505050565b600060208284031215613bd757600080fd5b8151613625816138b0565b60208082526019908201527f43757276652f63616c6c65722d69732d6e6f742d6f776e657200000000000000604082015260600190565b600181811c90821680613c2d57607f821691505b602082108103613c4d57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526010908201526f10dd5c9d994bdc994b595b9d195c995960821b604082015260600190565b600060208284031215613c8f57600080fd5b81516136258161382b565b60208082526018908201527f43757276652f74782d646561646c696e652d7061737365640000000000000000604082015260600190565b60208082526039908201527f43757276652f66726f7a656e2d676c6f62616c6c792d6f6e6c792d616c6c6f7760408201527f696e672d70726f706f7274696f6e616c2d776974686472617700000000000000606082015260800190565b60208082526030908201527f43757276652f66726f7a656e2d6f6e6c792d616c6c6f77696e672d70726f706f60408201526f7274696f6e616c2d776974686472617760801b606082015260800190565b6020808252603d908201527f43757276652f656d657267656e63792d6f6e6c792d616c6c6f77696e672d656d60408201527f657267656e63792d70726f706f7274696f6e616c2d7769746864726177000000606082015260800190565b600060208284031215613ded57600080fd5b5051919050565b80516001600160a01b0390811683526020808301518216908401526040808301519084015260608083015182169084015260809182015116910152565b83815260e08101613e456020830185613df4565b82151560c0830152949350505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156108bf576108bf613e55565b6020808252601d908201527f43757276652f62656c6f772d6d696e2d7461726765742d616d6f756e74000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b600082601f830112613edc57600080fd5b8151602067ffffffffffffffff80831115613ef957613ef9613eb5565b8260051b604051601f19603f83011681018181108482111715613f1e57613f1e613eb5565b604052938452858101830193838101925087851115613f3c57600080fd5b83870191505b848210156136fc57815183529183019190830190613f42565b60008060408385031215613f6e57600080fd5b82519150602083015167ffffffffffffffff811115613f8c57600080fd5b613f9885828601613ecb565b9150509250929050565b600060208284031215613fb457600080fd5b815167ffffffffffffffff811115613fcb57600080fd5b611af984828501613ecb565b634e487b7160e01b600052603260045260246000fd5b60006101608201905083825282516020830152602083015160408301526040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c083015160e083015260e0830151610100614058818501836001600160a01b03169052565b84015161012084810191909152909301516101409092019190915292915050565b600080600080600060a0868803121561409157600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b80820281158282048414176108bf576108bf613e55565b6000826140ed57634e487b7160e01b600052601260045260246000fd5b500490565b82815260c081016136256020830184613df4565b60006001820161411857614118613e55565b5060010190565b60008251614131818460208701613859565b919091019291505056fea26469706673582212209fe70fae664b7f88f6ddb308707297efdaab6e0c0059376ecafddee9e2c0cb2164736f6c63430008150033a2646970667358221220359105fa2fb1873a9b6e325d8c73e1bb41d2f57b09dd7edd2950b2f931587f3464736f6c63430008150033000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde0000000000000000000000001020e08935e9f8ee963356f4c47d7fe8a024c8a7000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x60806040523480156200001157600080fd5b5060043610620000c35760003560e01c80639611f3d9116200007a5780639611f3d91462000182578063a5a41031146200018c578063b483079b14620001aa578063dfcb53cd14620001c1578063f242862114620001f8578063f2fde38b146200022057600080fd5b80630d82a78d14620000c85780634ca98f68146200010d57806366903e801462000124578063715018a6146200015057806379502c55146200015c5780638da5cb5b1462000170575b600080fd5b620000f07f000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde81565b6040516001600160a01b0390911681526020015b60405180910390f35b620000f06200011e36600462000f5e565b62000237565b620000f06200013536600462000f9c565b6002602052600090815260409020546001600160a01b031681565b6200015a6200029b565b005b600154620000f0906001600160a01b031681565b6000546001600160a01b0316620000f0565b620000f0620002b3565b6200019662000329565b604051600f9190910b815260200162000104565b620000f0620001bb3660046200108e565b6200039a565b620001e7620001d2366004620011c4565b60036020526000908152604090205460ff1681565b604051901515815260200162000104565b620000f07f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6200015a62000231366004620011c4565b62000dfd565b6000808383604051602001620002639291906001600160a01b0392831681529116602082015260400190565b60408051601f198184030181529181528151602092830120600090815260029092529020546001600160a01b03169150505b92915050565b620002a562000e7c565b620002b1600062000ed8565b565b60015460408051639611f3d960e01b815290516000926001600160a01b031691639611f3d99160048083019260209291908290030181865afa158015620002fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003249190620011eb565b905090565b6001546040805163a5a4103160e01b815290516000926001600160a01b03169163a5a410319160048083019260209291908290030181865afa15801562000374573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200032491906200120b565b60608101516000906001600160a01b0316620003fd5760405162461bcd60e51b815260206004820152601b60248201527f71756f74652d63757272656e63792d7a65726f2d61646472657373000000000060448201526064015b60405180910390fd5b81606001516001600160a01b031682604001516001600160a01b031603620004685760405162461bcd60e51b815260206004820152601a60248201527f71756f74652d626173652d63757272656e636965732d73616d650000000000006044820152606401620003f4565b8160a0015182608001516200047e919062001230565b670de0b6b3a764000014620004c85760405162461bcd60e51b815260206004820152600f60248201526e696e76616c69642d7765696768747360881b6044820152606401620003f4565b600082606001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200050d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000533919062001252565b60ff169050600083604001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200057d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005a3919062001252565b60ff16905060006200064085604001518660600151604080518082018252600080825260209182018190528251808401845281815280830191825283516001600160a01b039687168185018190529590961686850181905284518088038601815260609788018652805190850120825284518085019190915280850195909552835180860385018152949095019092528251920191909120905290565b80516000908152600260205260409020549091506001600160a01b03161515806200068757506020808201516000908152600290915260409020546001600160a01b031615155b15620006c45760405162461bcd60e51b815260206004820152600b60248201526a706169722d65786973747360a81b6044820152606401620003f4565b60408581015160608701519151634206a40560e11b81526001600160a01b03918216600482015291811660248301526000917f000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde9091169063840d480a90604401602060405180830381865afa15801562000742573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007689190620011eb565b90506001600160a01b0381166200083257606086015160c08701516040808901519051636b7f8b5960e11b81526001600160a01b039384166004820152918316602483015282166044820152606481018590527f000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde9091169063d6ff16b2906084016020604051808303816000875af115801562000809573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200082f9190620011eb565b90505b60608601516040808801519051634206a40560e11b81526001600160a01b03928316600482015290821660248201526000917f000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde169063840d480a90604401602060405180830381865afa158015620008ae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008d49190620011eb565b90506001600160a01b0381166200099d5760408088015160e089015160608a01519251636b7f8b5960e11b81526001600160a01b03928316600482015290821660248201529181166044830152606482018790527f000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde169063d6ff16b2906084016020604051808303816000875af115801562000974573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200099a9190620011eb565b90505b60408051600a8082526101608201909252600091602082016101408036833750506040805160028082526060820183529394506000939092509060208301908036833701905050905088604001518260008151811062000a015762000a0162001277565b60200260200101906001600160a01b031690816001600160a01b031681525050838260018151811062000a385762000a3862001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088604001518260028151811062000a735762000a7362001277565b60200260200101906001600160a01b031690816001600160a01b031681525050838260038151811062000aaa5762000aaa62001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088604001518260048151811062000ae55762000ae562001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088606001518260058151811062000b205762000b2062001277565b60200260200101906001600160a01b031690816001600160a01b031681525050828260068151811062000b575762000b5762001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088606001518260078151811062000b925762000b9262001277565b60200260200101906001600160a01b031690816001600160a01b031681525050828260088151811062000bc95762000bc962001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088606001518260098151811062000c045762000c0462001277565b60200260200101906001600160a01b031690816001600160a01b03168152505088608001518160008151811062000c3f5762000c3f62001277565b6020026020010181815250508860a001518160018151811062000c665762000c6662001277565b602002602001018181525050600089600001518a60200151848430600160009054906101000a90046001600160a01b031660405162000ca59062000f28565b62000cb69695949392919062001312565b604051809103906000f08015801562000cd3573d6000803e3d6000fd5b506101008b01516101208c01516101408d01516101608e01516101808f0151604051631b05177160e31b8152600481019590955260248501939093526044840191909152606483015260848201529091506001600160a01b0382169063d828bb889060a401600060405180830381600087803b15801562000d5357600080fd5b505af115801562000d68573d6000803e3d6000fd5b50508751600090815260026020908152604080832080546001600160a01b0388166001600160a01b03199182168117909255838d015185528285208054909116821790558084526003909252808320805460ff191660011790558a519051919450925033917fe7a19de9e8788cc07c144818f2945144acd6234f790b541aa1010371c8b2a73b91a49998505050505050505050565b62000e0762000e7c565b6001600160a01b03811662000e6e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401620003f4565b62000e798162000ed8565b50565b6000546001600160a01b03163314620002b15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620003f4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61491d80620013c883390190565b6001600160a01b038116811462000e7957600080fd5b803562000f598162000f36565b919050565b6000806040838503121562000f7257600080fd5b823562000f7f8162000f36565b9150602083013562000f918162000f36565b809150509250929050565b60006020828403121562000faf57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6040516101a0810167ffffffffffffffff8111828210171562000ff35762000ff362000fb6565b60405290565b600082601f8301126200100b57600080fd5b813567ffffffffffffffff8082111562001029576200102962000fb6565b604051601f8301601f19908116603f0116810190828211818310171562001054576200105462000fb6565b816040528381528660208588010111156200106e57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215620010a157600080fd5b813567ffffffffffffffff80821115620010ba57600080fd5b908301906101a08286031215620010d057600080fd5b620010da62000fcc565b823582811115620010ea57600080fd5b620010f88782860162000ff9565b8252506020830135828111156200110e57600080fd5b6200111c8782860162000ff9565b602083015250620011306040840162000f4c565b6040820152620011436060840162000f4c565b60608201526080830135608082015260a083013560a08201526200116a60c0840162000f4c565b60c08201526200117d60e0840162000f4c565b60e082015261010083810135908201526101208084013590820152610140808401359082015261016080840135908201526101809283013592810192909252509392505050565b600060208284031215620011d757600080fd5b8135620011e48162000f36565b9392505050565b600060208284031215620011fe57600080fd5b8151620011e48162000f36565b6000602082840312156200121e57600080fd5b815180600f0b8114620011e457600080fd5b808201808211156200029557634e487b7160e01b600052601160045260246000fd5b6000602082840312156200126557600080fd5b815160ff81168114620011e457600080fd5b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b81811015620012b55760208185018101518683018201520162001297565b506000602082860101526020601f19601f83011685010191505092915050565b600081518084526020808501945080840160005b838110156200130757815187529582019590820190600101620012e9565b509495945050505050565b60c0815260006200132760c08301896200128d565b6020838203818501526200133c828a6200128d565b84810360408601528851808252828a0193509082019060005b818110156200137c5784516001600160a01b03168352938301939183019160010162001355565b50508481036060860152620013928189620012d5565b9350505050620013ad60808301856001600160a01b03169052565b6001600160a01b03831660a083015297965050505050505056fe60c06040526010805462ffffff1916620100001790553480156200002257600080fd5b506040516200491d3803806200491d83398101604081905262000045916200043b565b306080526001600160a01b038216620000ae5760405162461bcd60e51b815260206004820152602160248201527f43757276652f637572766520666163746f7279207a65726f20616464726573736044820152602160f81b606482015260840160405180910390fd5b600a80546001600160a01b03191633179055600b620000ce8782620005a7565b50600c620000dd8682620005a7565b50601080546301000000600160b81b03191663010000006001600160a01b038581169190910291909117909155601180546001600160a01b03191691831691909117905560405133906000907f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee67908290a3816001600160a01b031663f24286216040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200018d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001b3919062000673565b6001600160a01b031660a052604051635931eef160e11b8152731190da269ffe6f4567fed0c3c9bba01f883722549063b263dde2906200020690600090600e90600f90600d908b908b9060040162000698565b60006040518083038186803b1580156200021f57600080fd5b505af415801562000234573d6000803e3d6000fd5b5050505050505050505062000740565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171562000285576200028562000244565b604052919050565b600082601f8301126200029f57600080fd5b81516001600160401b03811115620002bb57620002bb62000244565b6020620002d1601f8301601f191682016200025a565b8281528582848701011115620002e657600080fd5b60005b8381101562000306578581018301518282018401528201620002e9565b506000928101909101919091529392505050565b60006001600160401b0382111562000336576200033662000244565b5060051b60200190565b80516001600160a01b03811681146200035857600080fd5b919050565b600082601f8301126200036f57600080fd5b815160206200038862000382836200031a565b6200025a565b82815260059290921b84018101918181019086841115620003a857600080fd5b8286015b84811015620003ce57620003c08162000340565b8352918301918301620003ac565b509695505050505050565b600082601f830112620003eb57600080fd5b81516020620003fe62000382836200031a565b82815260059290921b840181019181810190868411156200041e57600080fd5b8286015b84811015620003ce578051835291830191830162000422565b60008060008060008060c087890312156200045557600080fd5b86516001600160401b03808211156200046d57600080fd5b6200047b8a838b016200028d565b975060208901519150808211156200049257600080fd5b620004a08a838b016200028d565b96506040890151915080821115620004b757600080fd5b620004c58a838b016200035d565b95506060890151915080821115620004dc57600080fd5b50620004eb89828a01620003d9565b935050620004fc6080880162000340565b91506200050c60a0880162000340565b90509295509295509295565b600181811c908216806200052d57607f821691505b6020821081036200054e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620005a257600081815260208120601f850160051c810160208610156200057d5750805b601f850160051c820191505b818110156200059e5782815560010162000589565b5050505b505050565b81516001600160401b03811115620005c357620005c362000244565b620005db81620005d4845462000518565b8462000554565b602080601f831160018114620006135760008415620005fa5750858301515b600019600386901b1c1916600185901b1785556200059e565b600085815260208120601f198616915b82811015620006445788860151825594840194600190910190840162000623565b5085821015620006635787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156200068657600080fd5b620006918262000340565b9392505050565b600060c082018883526020888185015287604085015286606085015260c0608085015281865180845260e086019150828801935060005b81811015620006f65784516001600160a01b031683529383019391830191600101620006cf565b505084810360a0860152855180825290820192508186019060005b818110156200072f5782518552938301939183019160010162000711565b50929b9a5050505050505050505050565b60805160a051614171620007ac6000396000818161034601528181611352015281816113d0015281816116400152818161172e0152818161185b01528181611899015281816120de0152818161214d0152818161218d0152613103015260006134b301526141716000f3fe60806040526004361061024a5760003560e01c806370a0823111610139578063a8e9d528116100b6578063caa6fea41161007a578063caa6fea41461078e578063d828bb88146107ad578063dd62ed3e146107cd578063de3e2e2414610813578063e5cf8a5c14610833578063f2fde38b1461085357600080fd5b8063a8e9d528146106ee578063a9059cbb1461070e578063c0046e391461072e578063c7cdea371461074e578063c912ff7a1461076e57600080fd5b80638334278d116100fd5780638334278d14610659578063838e6a22146106795780638da5cb5b1461069957806395d89b41146106b9578063a3f5d8cc146106ce57600080fd5b806370a08231146105465780637165485d1461057c57806372b4129a146105f957806379a390a5146106195780637e932d321461063957600080fd5b806323b872dd116101c7578063525d0da71161018b578063525d0da7146104965780635872278a146104b6578063595520c7146104d65780636919ba27146105135780636f2ef95b1461052657600080fd5b806323b872dd146103e3578063313ce567146104035780633cae77f71461042a578063441a3e70146104635780634fe5da711461048357600080fd5b80630b2583c81161020e5780630b2583c814610309578063107c279f1461033757806318160ddd1461037e5780631a686502146103935780631f276b6e146103b657600080fd5b806301ffc9a7146102565780630501d5561461028b578063054f7d9c146102ad57806306fdde03146102c7578063095ea7b3146102e957600080fd5b3661025157005b600080fd5b34801561026257600080fd5b50610276610271366004613801565b610873565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102ab6102a636600461383c565b6108c5565b005b3480156102b957600080fd5b506010546102769060ff1681565b3480156102d357600080fd5b506102dc6109d9565b604051610282919061387d565b3480156102f557600080fd5b506102766103043660046138c5565b610a67565b34801561031557600080fd5b506103296103243660046138f1565b610b49565b604051908152602001610282565b34801561034357600080fd5b507f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b039091168152602001610282565b34801561038a57600080fd5b50600754610329565b34801561039f57600080fd5b506103a8610e70565b60405161028292919061397d565b3480156103c257600080fd5b506103d66103d1366004613996565b610ef6565b60405161028291906139b8565b3480156103ef57600080fd5b506102766103fe3660046139cb565b61101d565b34801561040f57600080fd5b50610418601281565b60405160ff9091168152602001610282565b34801561043657600080fd5b50610366610445366004613a0c565b6001600160a01b039081166000908152600560205260409020541690565b34801561046f57600080fd5b506103d661047e366004613996565b61112f565b6103a8610491366004613a29565b6111b5565b3480156104a257600080fd5b506103296104b13660046139cb565b6119b8565b3480156104c257600080fd5b506103a86104d1366004613a29565b611b01565b3480156104e257600080fd5b506104eb611ef3565b604080519586526020860194909452928401919091526060830152608082015260a001610282565b610329610521366004613a6c565b611f87565b34801561053257600080fd5b506103a8610541366004613aa1565b61228b565b34801561055257600080fd5b50610329610561366004613a0c565b6001600160a01b031660009081526008602052604090205490565b34801561058857600080fd5b506000546001546002546007546105bc93600f81810b94600160801b92839004820b9481830b9493909104820b92910b9086565b60408051600f97880b815295870b602087015293860b9385019390935290840b606084015290920b608082015260a081019190915260c001610282565b34801561060557600080fd5b506103296106143660046138f1565b6124de565b34801561062557600080fd5b506102ab610634366004613aba565b61273f565b34801561064557600080fd5b506102ab61065436600461383c565b61288b565b34801561066557600080fd5b50610366610674366004613aa1565b61298f565b34801561068557600080fd5b506103296106943660046139cb565b6129b9565b3480156106a557600080fd5b50600a54610366906001600160a01b031681565b3480156106c557600080fd5b506102dc612abd565b3480156106da57600080fd5b506010546102769062010000900460ff1681565b3480156106fa57600080fd5b50610366610709366004613aa1565b612aca565b34801561071a57600080fd5b506102766107293660046138c5565b612ada565b34801561073a57600080fd5b50610366610749366004613aa1565b612b8f565b34801561075a57600080fd5b506103d6610769366004613996565b612b9f565b34801561077a57600080fd5b506102ab610789366004613a0c565b612c6b565b34801561079a57600080fd5b5060105461027690610100900460ff1681565b3480156107b957600080fd5b506102ab6107c8366004613b16565b612e62565b3480156107d957600080fd5b506103296107e8366004613b51565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b34801561081f57600080fd5b5061032961082e366004613b8a565b612fab565b34801561083f57600080fd5b506103d661084e366004613aa1565b6131fe565b34801561085f57600080fd5b506102ab61086e366004613a0c565b61332b565b60006301ffc9a760e01b6001600160e01b0319831614806108a457506307f5828d60e41b6001600160e01b03198316145b806108bf57506336372b0760e01b6001600160e01b03198316145b92915050565b600a546001600160a01b03163314806109655750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa15801561092c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109509190613bc5565b6001600160a01b0316336001600160a01b0316145b61098a5760405162461bcd60e51b815260040161098190613be2565b60405180910390fd5b60405181151581527fa44450e52bea871e50cfee059fbe027c26ff43fd7534c06b7de61d90b58ab3c19060200160405180910390a1601080549115156101000261ff0019909216919091179055565b600b80546109e690613c19565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1290613c19565b8015610a5f5780601f10610a3457610100808354040283529160200191610a5f565b820191906000526020600020905b815481529060010190602001808311610a4257829003601f168201915b505050505081565b60105460009062010000900460ff16610a925760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055610aa66134a8565b60405163e60ac42960e01b8152600060048201526001600160a01b0384166024820152604481018390527385e9690c2d4c6cae31d96f9b5afe6d111d1651579063e60ac429906064015b602060405180830381865af4158015610b0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b319190613c7d565b6010805462ff00001916620100001790559392505050565b600081804210610b6b5760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be29190613c7d565b15610bff5760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615610c225760405162461bcd60e51b815260040161098190613d2e565b610c2a6134a8565b601054610100900460ff1615610c525760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff16610c7a5760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916908190556040805160a0810182526001600160a01b038a8116825289811660208084018290528385018b905233606085018190526301000000909604909216608084015283516370a0823160e01b8152600481019590955292519193600093926370a08231926024808401939192918290030181865afa158015610d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d309190613ddb565b60405163fd17568b60e01b81529091507374982d2fd25ca0e0dee702e40affd93bae04d3a69063fd17568b90610d6f9060009086908290600401613e31565b602060405180830381865af4158015610d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db09190613ddb565b5060608201516040516370a0823160e01b81526001600160a01b0391821660048201526000918a16906370a0823190602401602060405180830381865afa158015610dff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e239190613ddb565b9050610e2f8282613e6b565b945086851015610e515760405162461bcd60e51b815260040161098190613e7e565b50506010805462ff000019166201000017905550909695505050505050565b604051633745793960e11b815260006004820181905290606090731134daeaa652e11360631e3cc93e688204d9354b90636e8af27290602401600060405180830381865af4158015610ec6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610eee9190810190613f5b565b915091509091565b601054606090610100900460ff16610f205760405162461bcd60e51b815260040161098190613d7e565b81804210610f405760405162461bcd60e51b815260040161098190613c9a565b60105462010000900460ff16610f685760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055610f7c6134a8565b60405163eaadf2b560e01b8152600060048201819052602482018690526044820152730a7e79b7a4912ea42f82e25b9c033919b97f6fb09063eaadf2b5906064015b600060405180830381865af4158015610fdb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110039190810190613fa2565b9150506010805462ff000019166201000017905592915050565b60105460009062010000900460ff166110485760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916905561105c6134a8565b601054610100900460ff16156110845760405162461bcd60e51b815260040161098190613d7e565b6040516303a90f6960e31b8152600060048201526001600160a01b03808616602483015284166044820152606481018390527385e9690c2d4c6cae31d96f9b5afe6d111d16515790631d487b4890608401602060405180830381865af41580156110f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111169190613c7d565b6010805462ff0000191662010000179055949350505050565b6060818042106111515760405162461bcd60e51b815260040161098190613c9a565b60105462010000900460ff166111795760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916905561118d6134a8565b601054610100900460ff1615610f7c5760405162461bcd60e51b815260040161098190613d7e565b60006060828042106111d95760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561122c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112509190613c7d565b1561126d5760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156112905760405162461bcd60e51b815260040161098190613d2e565b60105462010000900460ff166112b85760405162461bcd60e51b815260040161098190613c53565b6010805462ff0000191690556112cc6134a8565b601054610100900460ff16156112f45760405162461bcd60e51b815260040161098190613d7e565b6000891161133f5760405162461bcd60e51b815260206004820152601860248201527743757276652f6465706f7369745f62656c6f775f7a65726f60401b6044820152606401610981565b6113488961228b565b80935081945050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156113ab57600080fd5b505af11580156113bf573d6000803e3d6000fd5b506113fc9350506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016915030905033346134df565b6114046137a5565b89815260208101899052604081018890526080810187905260a081018690528251839060009061143657611436613fd7565b60200260200101518160c00181815250508260018151811061145a5761145a613fd7565b6020026020010151816060018181525050600f60008154811061147f5761147f613fd7565b60009182526020822001546001600160a01b031660e0830152600f80549091906114ab576114ab613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156114fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115209190613ddb565b610100820152600f8054600190811061153b5761153b613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561158c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b09190613ddb565b610120820152604051629d2ea960e41b8152730a7e79b7a4912ea42f82e25b9c033919b97f6fb0906309d2ea90906115ef906000908590600401613fed565b600060405180830381865af415801561160c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116349190810190613f5b565b809450819550505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600060040160008154811061167f5761167f613fd7565b6000918252602091829020015460408051632495a59960e01b815290516001600160a01b0390921692632495a599926004808401938290030181865afa1580156116cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f19190613bc5565b6001600160a01b03160361172c578360008151811061171257611712613fd7565b6020026020010151346117259190613e6b565b9050611848565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316600060040160018154811061176d5761176d613fd7565b6000918252602091829020015460408051632495a59960e01b815290516001600160a01b0390921692632495a599926004808401938290030181865afa1580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df9190613bc5565b6001600160a01b031603611800578360018151811061171257611712613fd7565b60405162461bcd60e51b815260206004820152601860248201527f43757276652f4465706f73697420455448206661696c656400000000000000006044820152606401610981565b8015611997576118836001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330846134df565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156118e557600080fd5b505af11580156118f9573d6000803e3d6000fd5b50506040516000925033915083908381818185875af1925050503d806000811461193f576040519150601f19603f3d011682016040523d82523d6000602084013e611944565b606091505b50509050806119955760405162461bcd60e51b815260206004820152601960248201527f43757276652f455448207472616e73666572206661696c6564000000000000006044820152606401610981565b505b5050506010805462ff00001916620100001790559097909650945050505050565b601154604080516306a8e1cd60e41b815290516000926001600160a01b031691636a8e1cd09160048083019260209291908290030181865afa158015611a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a269190613c7d565b15611a435760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615611a665760405162461bcd60e51b815260040161098190613d2e565b6040516315be82e960e21b8152600060048201526001600160a01b03808616602483015284166044820152606481018390527374982d2fd25ca0e0dee702e40affd93bae04d3a6906356fa0ba4906084015b602060405180830381865af4158015611ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af99190613ddb565b949350505050565b6000606082804210611b255760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9c9190613c7d565b15611bb95760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615611bdc5760405162461bcd60e51b815260040161098190613d2e565b60105462010000900460ff16611c045760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055611c186134a8565b601054610100900460ff1615611c405760405162461bcd60e51b815260040161098190613d7e565b60008911611c8b5760405162461bcd60e51b815260206004820152601860248201527743757276652f6465706f7369745f62656c6f775f7a65726f60401b6044820152606401610981565b611c948961228b565b9093509150611ca16137a5565b89815260208101899052604081018890526080810187905260a0810186905282518390600090611cd357611cd3613fd7565b60200260200101518160c001818152505082600181518110611cf757611cf7613fd7565b6020026020010151816060018181525050600f600081548110611d1c57611d1c613fd7565b60009182526020822001546001600160a01b031660e0830152600f8054909190611d4857611d48613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dbd9190613ddb565b610100820152600f80546001908110611dd857611dd8613fd7565b6000918252602090912001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4d9190613ddb565b610120820152604051629d2ea960e41b8152730a7e79b7a4912ea42f82e25b9c033919b97f6fb0906309d2ea9090611e8c906000908590600401613fed565b600060405180830381865af4158015611ea9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ed19190810190613f5b565b6010805462ff0000191662010000179055909b909a5098505050505050505050565b6000806000806000731190da269ffe6f4567fed0c3c9bba01f8837225463faa50b5d60006040518263ffffffff1660e01b8152600401611f3591815260200190565b60a060405180830381865af4158015611f52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f769190614079565b945094509450945094509091929394565b600081804210611fa95760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120209190613c7d565b1561203d5760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156120605760405162461bcd60e51b815260040161098190613d2e565b6120686134a8565b601054610100900460ff16156120905760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff166120b85760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916905560408051630d0e30db60e41b815290516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163d0e30db091349160048082019260009290919082900301818588803b15801561212857600080fd5b505af115801561213c573d6000803e3d6000fd5b506121799350506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016915030905033346134df565b6040805160a0810182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682528781166020830152348284015233606083015260105463010000009004166080820152905163fd17568b60e01b81527374982d2fd25ca0e0dee702e40affd93bae04d3a69063fd17568b9061220e9060009085908290600401613e31565b602060405180830381865af415801561222b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224f9190613ddb565b9250848310156122715760405162461bcd60e51b815260040161098190613e7e565b50506010805462ff00001916620100001790559392505050565b60006060601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123069190613c7d565b156123235760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156123465760405162461bcd60e51b815260040161098190613d2e565b604080516002808252606082018352600092839291906020830190803683370190505060405163822f39d560e01b81526000600482015260248101879052909150730a7e79b7a4912ea42f82e25b9c033919b97f6fb09063822f39d590604401600060405180830381865af41580156123c3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526123eb9190810190613f5b565b909250905060008261240c876ec097ce7bc90715b34b9f10000000006140b9565b61241691906140d0565b90506ec097ce7bc90715b34b9f1000000000818360008151811061243c5761243c613fd7565b602002602001015161244e91906140b9565b61245891906140d0565b8260008151811061246b5761246b613fd7565b6020026020010181815250506ec097ce7bc90715b34b9f1000000000818360018151811061249b5761249b613fd7565b60200260200101516124ad91906140b9565b6124b791906140d0565b826001815181106124ca576124ca613fd7565b602090810291909101015250939492505050565b6000818042106125005760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612553573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125779190613c7d565b156125945760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156125b75760405162461bcd60e51b815260040161098190613d2e565b6125bf6134a8565b601054610100900460ff16156125e75760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff1661260f5760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916908190556040805160a0810182526001600160a01b038a811682528981166020830152818301889052336060830152630100000090930490921660808301525163498e2a2560e11b81527374982d2fd25ca0e0dee702e40affd93bae04d3a69063931c544a906126909060009085906004016140f2565b602060405180830381865af41580156126ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126d19190613ddb565b9250858311156127235760405162461bcd60e51b815260206004820152601d60248201527f43757276652f61626f76652d6d61782d6f726967696e2d616d6f756e740000006044820152606401610981565b50506010805462ff000019166201000017905595945050505050565b600a546001600160a01b03163314806127df5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ca9190613bc5565b6001600160a01b0316336001600160a01b0316145b6127fb5760405162461bcd60e51b815260040161098190613be2565b604051632e6ce08560e11b8152600060048201526001600160a01b0380861660248301528085166044830152808416606483015282166084820152731190da269ffe6f4567fed0c3c9bba01f8837225490635cd9c10a9060a40160006040518083038186803b15801561286d57600080fd5b505af4158015612881573d6000803e3d6000fd5b5050505050505050565b600a546001600160a01b031633148061292b5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129169190613bc5565b6001600160a01b0316336001600160a01b0316145b6129475760405162461bcd60e51b815260040161098190613be2565b60405181151581527f7c029deaca9b6c66abb68e5f874a812822f0fcaa52a890f980a7ab1afb5edba69060200160405180910390a16010805460ff1916911515919091179055565b600f818154811061299f57600080fd5b6000918252602090912001546001600160a01b0316905081565b601154604080516306a8e1cd60e41b815290516000926001600160a01b031691636a8e1cd09160048083019260209291908290030181865afa158015612a03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a279190613c7d565b15612a445760405162461bcd60e51b815260040161098190613cd1565b60105460ff1615612a675760405162461bcd60e51b815260040161098190613d2e565b604051637dba2aed60e11b8152600060048201526001600160a01b03808616602483015284166044820152606481018390527374982d2fd25ca0e0dee702e40affd93bae04d3a69063fb7455da90608401611ab8565b600c80546109e690613c19565b600e818154811061299f57600080fd5b60105460009062010000900460ff16612b055760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055612b196134a8565b601054610100900460ff1615612b415760405162461bcd60e51b815260040161098190613d7e565b60405163a4bcd45960e01b8152600060048201526001600160a01b0384166024820152604481018390527385e9690c2d4c6cae31d96f9b5afe6d111d1651579063a4bcd45990606401610af0565b600d818154811061299f57600080fd5b606081804210612bc15760405162461bcd60e51b815260040161098190613c9a565b60105462010000900460ff16612be95760405162461bcd60e51b815260040161098190613c53565b6010805462ff000019169055612bfd6134a8565b601054610100900460ff1615612c255760405162461bcd60e51b815260040161098190613d7e565b60405163eaadf2b560e01b8152600060048201526024810185905260016044820152730a7e79b7a4912ea42f82e25b9c033919b97f6fb09063eaadf2b590606401610fbe565b600a546001600160a01b0316331480612d0b5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf69190613bc5565b6001600160a01b0316336001600160a01b0316145b612d275760405162461bcd60e51b815260040161098190613be2565b60005b600e54811015612e3a57600e8181548110612d4757612d47613fd7565b6000918252602090912001546001600160a01b0390811690831603612dae5760405162461bcd60e51b815260206004820152601d60248201527f43757276652f63616e6e6f742d64656c6574652d6e756d6572616972650000006044820152606401610981565b600f8181548110612dc157612dc1613fd7565b6000918252602090912001546001600160a01b0390811690831603612e285760405162461bcd60e51b815260206004820152601b60248201527f43757276652f63616e6e6f742d64656c6574652d7265736572766500000000006044820152606401610981565b80612e3281614106565b915050612d2a565b506001600160a01b0316600090815260056020526040902080546001600160a81b0319169055565b600a546001600160a01b0316331480612f025750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ec9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eed9190613bc5565b6001600160a01b0316336001600160a01b0316145b612f1e5760405162461bcd60e51b815260040161098190613be2565b60405163231888b760e01b8152600060048201526024810186905260448101859052606481018490526084810183905260a48101829052731190da269ffe6f4567fed0c3c9bba01f883722549063231888b79060c40160006040518083038186803b158015612f8c57600080fd5b505af4158015612fa0573d6000803e3d6000fd5b505050505050505050565b600081804210612fcd5760405162461bcd60e51b815260040161098190613c9a565b601160009054906101000a90046001600160a01b03166001600160a01b0316636a8e1cd06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613020573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130449190613c7d565b156130615760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156130845760405162461bcd60e51b815260040161098190613d2e565b61308c6134a8565b601054610100900460ff16156130b45760405162461bcd60e51b815260040161098190613d7e565b60105462010000900460ff166130dc5760405162461bcd60e51b815260040161098190613c53565b6010805462ff00001916908190556040805160a0810182526001600160a01b0389811682527f000000000000000000000000000000000000000000000000000000000000000081166020830152818301899052336060830152630100000090930490921660808301525163fd17568b60e01b81527374982d2fd25ca0e0dee702e40affd93bae04d3a69063fd17568b90613180906000908590600190600401613e31565b602060405180830381865af415801561319d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c19190613ddb565b9250848310156131e35760405162461bcd60e51b815260040161098190613e7e565b50506010805462ff0000191662010000179055949350505050565b601154604080516306a8e1cd60e41b815290516060926001600160a01b031691636a8e1cd09160048083019260209291908290030181865afa158015613248573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326c9190613c7d565b156132895760405162461bcd60e51b815260040161098190613cd1565b60105460ff16156132ac5760405162461bcd60e51b815260040161098190613d2e565b6040516330771ac760e11b81526000600482015260248101839052730a7e79b7a4912ea42f82e25b9c033919b97f6fb0906360ee358e90604401600060405180830381865af4158015613303573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108bf9190810190613fa2565b600a546001600160a01b03163314806133cb5750601160009054906101000a90046001600160a01b03166001600160a01b0316639611f3d96040518163ffffffff1660e01b8152600401602060405180830381865afa158015613392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b69190613bc5565b6001600160a01b0316336001600160a01b0316145b6133e75760405162461bcd60e51b815260040161098190613be2565b6001600160a01b03811661344c5760405162461bcd60e51b815260206004820152602660248201527f43757276652f6e65772d6f776e65722d63616e6e6f742d62652d7a65726f2d6160448201526564647265737360d01b6064820152608401610981565b600a546040516001600160a01b038084169216907f0d18b5fd22306e373229b9439188228edca81207d1667f604daf6cef8aa3ee6790600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146134dd57600080fd5b565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261353990859061353f565b50505050565b6000613594826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166136169092919063ffffffff16565b80519091501561361157808060200190518101906135b29190613c7d565b6136115760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610981565b505050565b6060611af9848460008561362c565b9392505050565b60608247101561368d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610981565b600080866001600160a01b031685876040516136a9919061411f565b60006040518083038185875af1925050503d80600081146136e6576040519150601f19603f3d011682016040523d82523d6000602084013e6136eb565b606091505b50915091506136fc87838387613707565b979650505050505050565b6060831561377657825160000361376f576001600160a01b0385163b61376f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610981565b5081611af9565b611af9838381511561378b5781518083602001fd5b8060405162461bcd60e51b8152600401610981919061387d565b6040518061014001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b0316815260200160008152602001600081525090565b60006020828403121561381357600080fd5b81356001600160e01b03198116811461362557600080fd5b801515811461383957600080fd5b50565b60006020828403121561384e57600080fd5b81356136258161382b565b60005b8381101561387457818101518382015260200161385c565b50506000910152565b602081526000825180602084015261389c816040850160208701613859565b601f01601f19169190910160400192915050565b6001600160a01b038116811461383957600080fd5b600080604083850312156138d857600080fd5b82356138e3816138b0565b946020939093013593505050565b600080600080600060a0868803121561390957600080fd5b8535613914816138b0565b94506020860135613924816138b0565b94979496505050506040830135926060810135926080909101359150565b600081518084526020808501945080840160005b8381101561397257815187529582019590820190600101613956565b509495945050505050565b828152604060208201526000611af96040830184613942565b600080604083850312156139a957600080fd5b50508035926020909101359150565b6020815260006136256020830184613942565b6000806000606084860312156139e057600080fd5b83356139eb816138b0565b925060208401356139fb816138b0565b929592945050506040919091013590565b600060208284031215613a1e57600080fd5b8135613625816138b0565b60008060008060008060c08789031215613a4257600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215613a8157600080fd5b8335613a8c816138b0565b95602085013595506040909401359392505050565b600060208284031215613ab357600080fd5b5035919050565b60008060008060808587031215613ad057600080fd5b8435613adb816138b0565b93506020850135613aeb816138b0565b92506040850135613afb816138b0565b91506060850135613b0b816138b0565b939692955090935050565b600080600080600060a08688031215613b2e57600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b60008060408385031215613b6457600080fd5b8235613b6f816138b0565b91506020830135613b7f816138b0565b809150509250929050565b60008060008060808587031215613ba057600080fd5b8435613bab816138b0565b966020860135965060408601359560600135945092505050565b600060208284031215613bd757600080fd5b8151613625816138b0565b60208082526019908201527f43757276652f63616c6c65722d69732d6e6f742d6f776e657200000000000000604082015260600190565b600181811c90821680613c2d57607f821691505b602082108103613c4d57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526010908201526f10dd5c9d994bdc994b595b9d195c995960821b604082015260600190565b600060208284031215613c8f57600080fd5b81516136258161382b565b60208082526018908201527f43757276652f74782d646561646c696e652d7061737365640000000000000000604082015260600190565b60208082526039908201527f43757276652f66726f7a656e2d676c6f62616c6c792d6f6e6c792d616c6c6f7760408201527f696e672d70726f706f7274696f6e616c2d776974686472617700000000000000606082015260800190565b60208082526030908201527f43757276652f66726f7a656e2d6f6e6c792d616c6c6f77696e672d70726f706f60408201526f7274696f6e616c2d776974686472617760801b606082015260800190565b6020808252603d908201527f43757276652f656d657267656e63792d6f6e6c792d616c6c6f77696e672d656d60408201527f657267656e63792d70726f706f7274696f6e616c2d7769746864726177000000606082015260800190565b600060208284031215613ded57600080fd5b5051919050565b80516001600160a01b0390811683526020808301518216908401526040808301519084015260608083015182169084015260809182015116910152565b83815260e08101613e456020830185613df4565b82151560c0830152949350505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156108bf576108bf613e55565b6020808252601d908201527f43757276652f62656c6f772d6d696e2d7461726765742d616d6f756e74000000604082015260600190565b634e487b7160e01b600052604160045260246000fd5b600082601f830112613edc57600080fd5b8151602067ffffffffffffffff80831115613ef957613ef9613eb5565b8260051b604051601f19603f83011681018181108482111715613f1e57613f1e613eb5565b604052938452858101830193838101925087851115613f3c57600080fd5b83870191505b848210156136fc57815183529183019190830190613f42565b60008060408385031215613f6e57600080fd5b82519150602083015167ffffffffffffffff811115613f8c57600080fd5b613f9885828601613ecb565b9150509250929050565b600060208284031215613fb457600080fd5b815167ffffffffffffffff811115613fcb57600080fd5b611af984828501613ecb565b634e487b7160e01b600052603260045260246000fd5b60006101608201905083825282516020830152602083015160408301526040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c083015160e083015260e0830151610100614058818501836001600160a01b03169052565b84015161012084810191909152909301516101409092019190915292915050565b600080600080600060a0868803121561409157600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b80820281158282048414176108bf576108bf613e55565b6000826140ed57634e487b7160e01b600052601260045260246000fd5b500490565b82815260c081016136256020830184613df4565b60006001820161411857614118613e55565b5060010190565b60008251614131818460208701613859565b919091019291505056fea26469706673582212209fe70fae664b7f88f6ddb308707297efdaab6e0c0059376ecafddee9e2c0cb2164736f6c63430008150033a2646970667358221220359105fa2fb1873a9b6e325d8c73e1bb41d2f57b09dd7edd2950b2f931587f3464736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde0000000000000000000000001020e08935e9f8ee963356f4c47d7fe8a024c8a7000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : _assimFactory (address): 0xDe9c71503648C03F529305e03D259f2eBa9c8fDe
Arg [1] : _config (address): 0x1020E08935e9F8Ee963356f4C47d7fE8A024c8A7
Arg [2] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000de9c71503648c03f529305e03d259f2eba9c8fde
Arg [1] : 0000000000000000000000001020e08935e9f8ee963356f4c47d7fe8a024c8a7
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.