ERC-20
Overview
Max Total Supply
100 ERC20 ***
Holders
0
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 6 Decimals)
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
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 Name:
Pool
Compiler Version
v0.8.6+commit.11564f7e
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.6; import "@yield-protocol/utils-v2/contracts/token/IERC20.sol"; import "@yield-protocol/utils-v2/contracts/token/IERC20Metadata.sol"; import "@yield-protocol/utils-v2/contracts/token/ERC20Permit.sol"; import "@yield-protocol/utils-v2/contracts/token/SafeERC20Namer.sol"; import "@yield-protocol/utils-v2/contracts/token/MinimalTransferHelper.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU256U128.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU256U112.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU256I256.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU128U112.sol"; import "@yield-protocol/utils-v2/contracts/cast/CastU128I128.sol"; import "@yield-protocol/yieldspace-interfaces/IPool.sol"; import "@yield-protocol/yieldspace-interfaces/IPoolFactory.sol"; import "@yield-protocol/vault-interfaces/IFYToken.sol"; import "./YieldMath.sol"; /// @dev The Pool contract exchanges base for fyToken at a price defined by a specific formula. contract Pool is IPool, ERC20Permit { using CastU256U128 for uint256; using CastU256U112 for uint256; using CastU256I256 for uint256; using CastU128U112 for uint128; using CastU128I128 for uint128; using MinimalTransferHelper for IERC20; event Trade(uint32 maturity, address indexed from, address indexed to, int256 bases, int256 fyTokens); event Liquidity(uint32 maturity, address indexed from, address indexed to, address indexed fyTokenTo, int256 bases, int256 fyTokens, int256 poolTokens); event Sync(uint112 baseCached, uint112 fyTokenCached, uint256 cumulativeBalancesRatio); int128 public immutable override ts; // 1 / Seconds in 10 years, in 64.64 int128 public immutable override g1; // To be used when selling base to the pool int128 public immutable override g2; // To be used when selling fyToken to the pool uint32 public immutable override maturity; uint96 public immutable override scaleFactor; // Scale up to 18 low decimal tokens to get the right precision in YieldMath IERC20 public immutable override base; IFYToken public immutable override fyToken; uint112 private baseCached; // uses single storage slot, accessible via getCache uint112 private fyTokenCached; // uses single storage slot, accessible via getCache uint32 private blockTimestampLast; // uses single storage slot, accessible via getCache uint256 public cumulativeBalancesRatio; // Fixed point factor with 27 decimals (ray) constructor() ERC20Permit( string(abi.encodePacked("Yield ", SafeERC20Namer.tokenName(IPoolFactory(msg.sender).nextFYToken()), " LP Token")), string(abi.encodePacked(SafeERC20Namer.tokenSymbol(IPoolFactory(msg.sender).nextFYToken()), "LP")), SafeERC20Namer.tokenDecimals(IPoolFactory(msg.sender).nextBase()) ) { IPoolFactory _factory = IPoolFactory(msg.sender); IFYToken _fyToken = IFYToken(_factory.nextFYToken()); IERC20 _base = IERC20(_factory.nextBase()); fyToken = _fyToken; base = _base; uint256 _maturity = _fyToken.maturity(); require (_maturity <= type(uint32).max, "Pool: Maturity too far in the future"); maturity = uint32(_maturity); ts = _factory.ts(); g1 = _factory.g1(); g2 = _factory.g2(); scaleFactor = uint96(10 ** (18 - SafeERC20Namer.tokenDecimals(address(_base)))); } /// @dev Trading can only be done before maturity modifier beforeMaturity() { require( block.timestamp < maturity, "Pool: Too late" ); _; } // ---- Balances management ---- /// @dev Updates the cache to match the actual balances. function sync() external { _update(_getBaseBalance(), _getFYTokenBalance(), baseCached, fyTokenCached); } /// @dev Returns the cached balances & last updated timestamp. /// @return Cached base token balance. /// @return Cached virtual FY token balance. /// @return Timestamp that balances were last cached. function getCache() external view override returns (uint112, uint112, uint32) { return (baseCached, fyTokenCached, blockTimestampLast); } /// @dev Returns the "virtual" fyToken balance, which is the real balance plus the pool token supply. function getFYTokenBalance() public view override returns(uint112) { return _getFYTokenBalance(); } /// @dev Returns the base balance function getBaseBalance() public view override returns(uint112) { return _getBaseBalance(); } /// @dev Returns the "virtual" fyToken balance, which is the real balance plus the pool token supply. function _getFYTokenBalance() internal view returns(uint112) { return (fyToken.balanceOf(address(this)) + _totalSupply).u112(); } /// @dev Returns the base balance function _getBaseBalance() internal view returns(uint112) { return base.balanceOf(address(this)).u112(); } /// @dev Retrieve any base tokens not accounted for in the cache function retrieveBase(address to) external override returns(uint128 retrieved) { retrieved = _getBaseBalance() - baseCached; // Cache can never be above balances base.safeTransfer(to, retrieved); // Now the current balances match the cache, so no need to update the TWAR } /// @dev Retrieve any fyTokens not accounted for in the cache function retrieveFYToken(address to) external override returns(uint128 retrieved) { retrieved = _getFYTokenBalance() - fyTokenCached; // Cache can never be above balances IERC20(address(fyToken)).safeTransfer(to, retrieved); // Now the balances match the cache, so no need to update the TWAR } /// @dev Update cache and, on the first call per block, ratio accumulators function _update(uint128 baseBalance, uint128 fyBalance, uint112 _baseCached, uint112 _fyTokenCached) private { uint32 blockTimestamp = uint32(block.timestamp); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _baseCached != 0 && _fyTokenCached != 0) { // We multiply by 1e27 here so that r = t * y/x is a fixed point factor with 27 decimals uint256 scaledFYTokenCached = uint256(_fyTokenCached) * 1e27; cumulativeBalancesRatio += scaledFYTokenCached * timeElapsed / _baseCached; } baseCached = baseBalance.u112(); fyTokenCached = fyBalance.u112(); blockTimestampLast = blockTimestamp; emit Sync(baseCached, fyTokenCached, cumulativeBalancesRatio); } // ---- Liquidity ---- /// @dev Mint liquidity tokens in exchange for adding base and fyToken /// The amount of liquidity tokens to mint is calculated from the amount of unaccounted for fyToken in this contract. /// A proportional amount of base tokens need to be present in this contract, also unaccounted for. /// @param to Wallet receiving the minted liquidity tokens. /// @param remainder Wallet receiving any surplus base. /// @param minRatio Minimum ratio of base to fyToken in the pool. /// @param maxRatio Maximum ratio of base to fyToken in the pool. /// @return The amount of liquidity tokens minted. function mint(address to, address remainder, uint256 minRatio, uint256 maxRatio) external override returns (uint256, uint256, uint256) { return _mintInternal(to, remainder, 0, minRatio, maxRatio); } /// @dev Mint liquidity tokens in exchange for adding only base /// The amount of liquidity tokens is calculated from the amount of fyToken to buy from the pool, /// plus the amount of unaccounted for fyToken in this contract. /// The base tokens need to be present in this contract, unaccounted for. /// @param to Wallet receiving the minted liquidity tokens. /// @param remainder Wallet receiving any surplus base. /// @param fyTokenToBuy Amount of `fyToken` being bought in the Pool, from this we calculate how much base it will be taken in. /// @param minRatio Minimum ratio of base to fyToken in the pool. /// @param maxRatio Maximum ratio of base to fyToken in the pool. /// @return The amount of liquidity tokens minted. function mintWithBase(address to, address remainder, uint256 fyTokenToBuy, uint256 minRatio, uint256 maxRatio) external override returns (uint256, uint256, uint256) { return _mintInternal(to, remainder, fyTokenToBuy, minRatio, maxRatio); } /// @dev Mint liquidity tokens, with an optional internal trade to buy fyToken beforehand. /// The amount of liquidity tokens is calculated from the amount of fyToken to buy from the pool, /// plus the amount of unaccounted for fyToken in this contract. /// The base tokens need to be present in this contract, unaccounted for. /// @param to Wallet receiving the minted liquidity tokens. /// @param remainder Wallet receiving any surplus base. /// @param fyTokenToBuy Amount of `fyToken` being bought in the Pool, from this we calculate how much base it will be taken in. /// @param minRatio Minimum ratio of base to fyToken in the pool. /// @param maxRatio Minimum ratio of base to fyToken in the pool. function _mintInternal(address to, address remainder, uint256 fyTokenToBuy, uint256 minRatio, uint256 maxRatio) internal returns (uint256 baseIn, uint256 fyTokenIn, uint256 tokensMinted) { // Gather data uint256 supply = _totalSupply; (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); uint256 _realFYTokenCached = _fyTokenCached - supply; // The fyToken cache includes the virtual fyToken, equal to the supply uint256 baseBalance = base.balanceOf(address(this)); uint256 fyTokenBalance = fyToken.balanceOf(address(this)); uint256 baseAvailable = baseBalance - _baseCached; // Check the burn wasn't sandwiched require ( _realFYTokenCached == 0 || ( uint256(_baseCached) * 1e18 / _realFYTokenCached >= minRatio && uint256(_baseCached) * 1e18 / _realFYTokenCached <= maxRatio ), "Pool: Reserves ratio changed" ); // Calculate token amounts if (supply == 0) { // Initialize at 1 pool token minted per base token supplied baseIn = baseAvailable; tokensMinted = baseIn; } else if (_realFYTokenCached == 0) { // Edge case, no fyToken in the Pool after initialization baseIn = baseAvailable; tokensMinted = supply * baseIn / _baseCached; } else { // There is an optional virtual trade before the mint uint256 baseToSell; if (fyTokenToBuy > 0) { baseToSell = _buyFYTokenPreview( fyTokenToBuy.u128(), _baseCached, _fyTokenCached ); } // We use all the available fyTokens, plus a virtual trade if it happened, surplus is in base tokens fyTokenIn = fyTokenBalance - _realFYTokenCached; tokensMinted = (supply * (fyTokenToBuy + fyTokenIn)) / (_realFYTokenCached - fyTokenToBuy); baseIn = baseToSell + ((_baseCached + baseToSell) * tokensMinted) / supply; require(baseAvailable >= baseIn, "Pool: Not enough base token in"); } // Update TWAR _update( (_baseCached + baseIn).u128(), (_fyTokenCached + fyTokenIn + tokensMinted).u128(), // Account for the "virtual" fyToken from the new minted LP tokens _baseCached, _fyTokenCached ); // Execute mint _mint(to, tokensMinted); // Return any unused base if (baseAvailable - baseIn > 0) base.safeTransfer(remainder, baseAvailable - baseIn); emit Liquidity(maturity, msg.sender, to, address(0), -(baseIn.i256()), -(fyTokenIn.i256()), tokensMinted.i256()); } /// @dev Burn liquidity tokens in exchange for base and fyToken. /// The liquidity tokens need to be in this contract. /// @param baseTo Wallet receiving the base. /// @param fyTokenTo Wallet receiving the fyToken. /// @param minRatio Minimum ratio of base to fyToken in the pool. /// @param maxRatio Maximum ratio of base to fyToken in the pool. /// @return The amount of tokens burned and returned (tokensBurned, bases, fyTokens). function burn(address baseTo, address fyTokenTo, uint256 minRatio, uint256 maxRatio) external override returns (uint256, uint256, uint256) { return _burnInternal(baseTo, fyTokenTo, false, minRatio, maxRatio); } /// @dev Burn liquidity tokens in exchange for base. /// The liquidity provider needs to have called `pool.approve`. /// @param to Wallet receiving the base and fyToken. /// @param minRatio Minimum ratio of base to fyToken in the pool. /// @param maxRatio Minimum ratio of base to fyToken in the pool. /// @return tokensBurned The amount of lp tokens burned. /// @return baseOut The amount of base tokens returned. function burnForBase(address to, uint256 minRatio, uint256 maxRatio) external override returns (uint256 tokensBurned, uint256 baseOut) { (tokensBurned, baseOut, ) = _burnInternal(to, address(0), true, minRatio, maxRatio); } /// @dev Burn liquidity tokens in exchange for base. /// The liquidity provider needs to have called `pool.approve`. /// @param baseTo Wallet receiving the base. /// @param fyTokenTo Wallet receiving the fyToken. /// @param tradeToBase Whether the resulting fyToken should be traded for base tokens. /// @param minRatio Minimum ratio of base to fyToken in the pool. /// @param maxRatio Minimum ratio of base to fyToken in the pool. /// @return tokensBurned The amount of pool tokens burned. /// @return tokenOut The amount of base tokens returned. /// @return fyTokenOut The amount of fyTokens returned. function _burnInternal(address baseTo, address fyTokenTo, bool tradeToBase, uint256 minRatio, uint256 maxRatio) internal returns (uint256 tokensBurned, uint256 tokenOut, uint256 fyTokenOut) { // Gather data tokensBurned = _balanceOf[address(this)]; uint256 supply = _totalSupply; (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); uint256 _realFYTokenCached = _fyTokenCached - supply; // The fyToken cache includes the virtual fyToken, equal to the supply // Check the burn wasn't sandwiched require ( _realFYTokenCached == 0 || ( uint256(_baseCached) * 1e18 / _realFYTokenCached >= minRatio && uint256(_baseCached) * 1e18 / _realFYTokenCached <= maxRatio ), "Pool: Reserves ratio changed" ); // Calculate trade tokenOut = (tokensBurned * _baseCached) / supply; fyTokenOut = (tokensBurned * _realFYTokenCached) / supply; if (tradeToBase) { tokenOut += YieldMath.baseOutForFYTokenIn( // This is a virtual sell (_baseCached - tokenOut.u128()) * scaleFactor, // Cache, minus virtual burn (_fyTokenCached - fyTokenOut.u128()) * scaleFactor, // Cache, minus virtual burn fyTokenOut.u128() * scaleFactor, // Sell the virtual fyToken obtained maturity - uint32(block.timestamp), // This can't be called after maturity ts, g2 ) / scaleFactor; fyTokenOut = 0; } // Update TWAR _update( (_baseCached - tokenOut).u128(), (_fyTokenCached - fyTokenOut - tokensBurned).u128(), _baseCached, _fyTokenCached ); // Transfer assets _burn(address(this), tokensBurned); base.safeTransfer(baseTo, tokenOut); if (fyTokenOut > 0) IERC20(address(fyToken)).safeTransfer(fyTokenTo, fyTokenOut); emit Liquidity(maturity, msg.sender, baseTo, fyTokenTo, tokenOut.i256(), fyTokenOut.i256(), -(tokensBurned.i256())); } // ---- Trading ---- /// @dev Sell base for fyToken. /// The trader needs to have transferred the amount of base to sell to the pool before in the same transaction. /// @param to Wallet receiving the fyToken being bought /// @param min Minimm accepted amount of fyToken /// @return Amount of fyToken that will be deposited on `to` wallet function sellBase(address to, uint128 min) external override returns(uint128) { // Calculate trade (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); uint112 _baseBalance = _getBaseBalance(); uint112 _fyTokenBalance = _getFYTokenBalance(); uint128 baseIn = _baseBalance - _baseCached; uint128 fyTokenOut = _sellBasePreview( baseIn, _baseCached, _fyTokenBalance ); // Slippage check require( fyTokenOut >= min, "Pool: Not enough fyToken obtained" ); // Update TWAR _update( _baseBalance, _fyTokenBalance - fyTokenOut, _baseCached, _fyTokenCached ); // Transfer assets IERC20(address(fyToken)).safeTransfer(to, fyTokenOut); emit Trade(maturity, msg.sender, to, -(baseIn.i128()), fyTokenOut.i128()); return fyTokenOut; } /// @dev Returns how much fyToken would be obtained by selling `baseIn` base /// @param baseIn Amount of base hypothetically sold. /// @return Amount of fyToken hypothetically bought. function sellBasePreview(uint128 baseIn) external view override returns(uint128) { (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); return _sellBasePreview(baseIn, _baseCached, _fyTokenCached); } /// @dev Returns how much fyToken would be obtained by selling `baseIn` base function _sellBasePreview( uint128 baseIn, uint112 baseBalance, uint112 fyTokenBalance ) private view beforeMaturity returns(uint128) { uint128 fyTokenOut = YieldMath.fyTokenOutForBaseIn( baseBalance * scaleFactor, fyTokenBalance * scaleFactor, baseIn * scaleFactor, maturity - uint32(block.timestamp), // This can't be called after maturity ts, g1 ) / scaleFactor; require( fyTokenBalance - fyTokenOut >= baseBalance + baseIn, "Pool: fyToken balance too low" ); return fyTokenOut; } /// @dev Buy base for fyToken /// The trader needs to have called `fyToken.approve` /// @param to Wallet receiving the base being bought /// @param tokenOut Amount of base being bought that will be deposited in `to` wallet /// @param max Maximum amount of fyToken that will be paid for the trade /// @return Amount of fyToken that will be taken from caller function buyBase(address to, uint128 tokenOut, uint128 max) external override returns(uint128) { // Calculate trade uint128 fyTokenBalance = _getFYTokenBalance(); (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); uint128 fyTokenIn = _buyBasePreview( tokenOut, _baseCached, _fyTokenCached ); require( fyTokenBalance - _fyTokenCached >= fyTokenIn, "Pool: Not enough fyToken in" ); // Slippage check require( fyTokenIn <= max, "Pool: Too much fyToken in" ); // Update TWAR _update( _baseCached - tokenOut, _fyTokenCached + fyTokenIn, _baseCached, _fyTokenCached ); // Transfer assets base.safeTransfer(to, tokenOut); emit Trade(maturity, msg.sender, to, tokenOut.i128(), -(fyTokenIn.i128())); return fyTokenIn; } /// @dev Returns how much fyToken would be required to buy `tokenOut` base. /// @param tokenOut Amount of base hypothetically desired. /// @return Amount of fyToken hypothetically required. function buyBasePreview(uint128 tokenOut) external view override returns(uint128) { (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); return _buyBasePreview(tokenOut, _baseCached, _fyTokenCached); } /// @dev Returns how much fyToken would be required to buy `tokenOut` base. function _buyBasePreview( uint128 tokenOut, uint112 baseBalance, uint112 fyTokenBalance ) private view beforeMaturity returns(uint128) { return YieldMath.fyTokenInForBaseOut( baseBalance * scaleFactor, fyTokenBalance * scaleFactor, tokenOut * scaleFactor, maturity - uint32(block.timestamp), // This can't be called after maturity ts, g2 ) / scaleFactor; } /// @dev Sell fyToken for base /// The trader needs to have transferred the amount of fyToken to sell to the pool before in the same transaction. /// @param to Wallet receiving the base being bought /// @param min Minimm accepted amount of base /// @return Amount of base that will be deposited on `to` wallet function sellFYToken(address to, uint128 min) external override returns(uint128) { // Calculate trade (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); uint112 _fyTokenBalance = _getFYTokenBalance(); uint112 _baseBalance = _getBaseBalance(); uint128 fyTokenIn = _fyTokenBalance - _fyTokenCached; uint128 baseOut = _sellFYTokenPreview( fyTokenIn, _baseCached, _fyTokenCached ); // Slippage check require( baseOut >= min, "Pool: Not enough base obtained" ); // Update TWAR _update( _baseBalance - baseOut, _fyTokenBalance, _baseCached, _fyTokenCached ); // Transfer assets base.safeTransfer(to, baseOut); emit Trade(maturity, msg.sender, to, baseOut.i128(), -(fyTokenIn.i128())); return baseOut; } /// @dev Returns how much base would be obtained by selling `fyTokenIn` fyToken. /// @param fyTokenIn Amount of fyToken hypothetically sold. /// @return Amount of base hypothetically bought. function sellFYTokenPreview(uint128 fyTokenIn) external view override returns(uint128) { (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); return _sellFYTokenPreview(fyTokenIn, _baseCached, _fyTokenCached); } /// @dev Returns how much base would be obtained by selling `fyTokenIn` fyToken. function _sellFYTokenPreview( uint128 fyTokenIn, uint112 baseBalance, uint112 fyTokenBalance ) private view beforeMaturity returns(uint128) { return YieldMath.baseOutForFYTokenIn( baseBalance * scaleFactor, fyTokenBalance * scaleFactor, fyTokenIn * scaleFactor, maturity - uint32(block.timestamp), // This can't be called after maturity ts, g2 ) / scaleFactor; } /// @dev Buy fyToken for base /// The trader needs to have called `base.approve` /// @param to Wallet receiving the fyToken being bought /// @param fyTokenOut Amount of fyToken being bought that will be deposited in `to` wallet /// @param max Maximum amount of base token that will be paid for the trade /// @return Amount of base that will be taken from caller's wallet function buyFYToken(address to, uint128 fyTokenOut, uint128 max) external override returns(uint128) { // Calculate trade uint128 baseBalance = _getBaseBalance(); (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); uint128 baseIn = _buyFYTokenPreview( fyTokenOut, _baseCached, _fyTokenCached ); require( baseBalance - _baseCached >= baseIn, "Pool: Not enough base token in" ); // Slippage check require( baseIn <= max, "Pool: Too much base token in" ); // Update TWAR _update( _baseCached + baseIn, _fyTokenCached - fyTokenOut, _baseCached, _fyTokenCached ); // Transfer assets IERC20(address(fyToken)).safeTransfer(to, fyTokenOut); emit Trade(maturity, msg.sender, to, -(baseIn.i128()), fyTokenOut.i128()); return baseIn; } /// @dev Returns how much base would be required to buy `fyTokenOut` fyToken. /// @param fyTokenOut Amount of fyToken hypothetically desired. /// @return Amount of base hypothetically required. function buyFYTokenPreview(uint128 fyTokenOut) external view override returns(uint128) { (uint112 _baseCached, uint112 _fyTokenCached) = (baseCached, fyTokenCached); return _buyFYTokenPreview(fyTokenOut, _baseCached, _fyTokenCached); } /// @dev Returns how much base would be required to buy `fyTokenOut` fyToken. function _buyFYTokenPreview( uint128 fyTokenOut, uint128 baseBalance, uint128 fyTokenBalance ) private view beforeMaturity returns(uint128) { uint128 baseIn = YieldMath.baseInForFYTokenOut( baseBalance * scaleFactor, fyTokenBalance * scaleFactor, fyTokenOut * scaleFactor, maturity - uint32(block.timestamp), // This can't be called after maturity ts, g1 ) / scaleFactor; require( fyTokenBalance - fyTokenOut >= baseBalance + baseIn, "Pool: fyToken balance too low" ); return baseIn; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // Taken from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; import "./IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/53516bc555a454862470e7860a9b5254db4d00f5/contracts/token/ERC20/ERC20Permit.sol pragma solidity ^0.8.0; import "./ERC20.sol"; import "./IERC2612.sol"; /** * @dev Extension of {ERC20} that allows token holders to use their tokens * without sending any transactions by setting {IERC20-allowance} with a * signature using the {permit} method, and then spend them via * {IERC20-transferFrom}. * * The {permit} signature mechanism conforms to the {IERC2612} interface. */ abstract contract ERC20Permit is ERC20, IERC2612 { mapping (address => uint256) public override nonces; bytes32 public immutable PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 private immutable _DOMAIN_SEPARATOR; uint256 public immutable deploymentChainId; constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_, decimals_) { deploymentChainId = block.chainid; _DOMAIN_SEPARATOR = _calculateDomainSeparator(block.chainid); } /// @dev Calculate the DOMAIN_SEPARATOR. function _calculateDomainSeparator(uint256 chainId) private view returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version())), chainId, address(this) ) ); } /// @dev Return the DOMAIN_SEPARATOR. function DOMAIN_SEPARATOR() external view returns (bytes32) { return block.chainid == deploymentChainId ? _DOMAIN_SEPARATOR : _calculateDomainSeparator(block.chainid); } /// @dev Setting the version as a function so that it can be overriden function version() public pure virtual returns(string memory) { return "1"; } /** * @dev See {IERC2612-permit}. * * In cases where the free option is not a concern, deadline can simply be * set to uint(-1), so it should be seen as an optional parameter */ function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external virtual override { require(deadline >= block.timestamp, "ERC20Permit: expired deadline"); bytes32 hashStruct = keccak256( abi.encode( PERMIT_TYPEHASH, owner, spender, amount, nonces[owner]++, deadline ) ); bytes32 hash = keccak256( abi.encodePacked( "\x19\x01", block.chainid == deploymentChainId ? _DOMAIN_SEPARATOR : _calculateDomainSeparator(block.chainid), hashStruct ) ); address signer = ecrecover(hash, v, r, s); require( signer != address(0) && signer == owner, "ERC20Permit: invalid signature" ); _setAllowance(owner, spender, amount); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "../token/IERC20Metadata.sol"; import "../utils/AddressStringUtil.sol"; // produces token descriptors from inconsistent or absent ERC20 symbol implementations that can return string or bytes32 // this library will always produce a string symbol to represent the token library SafeERC20Namer { function bytes32ToString(bytes32 x) private pure returns (string memory) { bytes memory bytesString = new bytes(32); uint256 charCount = 0; for (uint256 j = 0; j < 32; j++) { bytes1 char = x[j]; if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (uint256 j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } // assumes the data is in position 2 function parseStringData(bytes memory b) private pure returns (string memory) { uint256 charCount = 0; // first parse the charCount out of the data for (uint256 i = 32; i < 64; i++) { charCount <<= 8; charCount += uint8(b[i]); } bytes memory bytesStringTrimmed = new bytes(charCount); for (uint256 i = 0; i < charCount; i++) { bytesStringTrimmed[i] = b[i + 64]; } return string(bytesStringTrimmed); } // uses a heuristic to produce a token name from the address // the heuristic returns the full hex of the address string in upper case function addressToName(address token) private pure returns (string memory) { return AddressStringUtil.toAsciiString(token, 40); } // uses a heuristic to produce a token symbol from the address // the heuristic returns the first 6 hex of the address string in upper case function addressToSymbol(address token) private pure returns (string memory) { return AddressStringUtil.toAsciiString(token, 6); } // calls an external view token contract method that returns a symbol or name, and parses the output into a string function callAndParseStringReturn(address token, bytes4 selector) private view returns (string memory) { (bool success, bytes memory data) = token.staticcall(abi.encodeWithSelector(selector)); // if not implemented, or returns empty data, return empty string if (!success || data.length == 0) { return ""; } // bytes32 data always has length 32 if (data.length == 32) { bytes32 decoded = abi.decode(data, (bytes32)); return bytes32ToString(decoded); } else if (data.length > 64) { return abi.decode(data, (string)); } return ""; } // attempts to extract the token symbol. if it does not implement symbol, returns a symbol derived from the address function tokenSymbol(address token) public view returns (string memory) { string memory symbol = callAndParseStringReturn(token, IERC20Metadata.symbol.selector); if (bytes(symbol).length == 0) { // fallback to 6 uppercase hex of address return addressToSymbol(token); } return symbol; } // attempts to extract the token name. if it does not implement name, returns a name derived from the address function tokenName(address token) public view returns (string memory) { string memory name = callAndParseStringReturn(token, IERC20Metadata.name.selector); if (bytes(name).length == 0) { // fallback to full hex of address return addressToName(token); } return name; } /// @notice Provides a safe ERC20.decimals version which returns '18' as fallback value. /// @param token The address of the ERC-20 token contract. /// @return (uint8) Token decimals. function tokenDecimals(address token) public view returns (uint8) { (bool success, bytes memory data) = token.staticcall(abi.encodeWithSelector(IERC20Metadata.decimals.selector)); return success && data.length == 32 ? abi.decode(data, (uint8)) : 18; } }
// SPDX-License-Identifier: MIT // Taken from https://github.com/Uniswap/uniswap-lib/blob/master/contracts/libraries/TransferHelper.sol pragma solidity >=0.6.0; import "./IERC20.sol"; import "../utils/RevertMsgExtractor.sol"; // helper methods for transferring ERC20 tokens that do not consistently return true/false library MinimalTransferHelper { /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with the underlying revert message if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( IERC20 token, address to, uint256 value ) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); if (!(success && (data.length == 0 || abi.decode(data, (bool))))) revert(RevertMsgExtractor.getRevertMsg(data)); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU256U128 { /// @dev Safely cast an uint256 to an uint128 function u128(uint256 x) internal pure returns (uint128 y) { require (x <= type(uint128).max, "Cast overflow"); y = uint128(x); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU256U112 { /// @dev Safely cast an uint256 to an uint112 function u112(uint256 x) internal pure returns (uint112 y) { require (x <= type(uint112).max, "Cast overflow"); y = uint112(x); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU256I256 { /// @dev Safely cast an uint256 to an int256 function i256(uint256 x) internal pure returns (int256 y) { require (x <= uint256(type(int256).max), "Cast overflow"); y = int256(x); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU128U112 { /// @dev Safely cast an uint128 to an uint112 function u112(uint128 x) internal pure returns (uint112 y) { require (x <= uint128(type(uint112).max), "Cast overflow"); y = uint112(x); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library CastU128I128 { /// @dev Safely cast an uint128 to an int128 function i128(uint128 x) internal pure returns (int128 y) { require (x <= uint128(type(int128).max), "Cast overflow"); y = int128(x); } }
// SPDX-License-Identifier: MIT pragma solidity >= 0.8.0; import "@yield-protocol/utils-v2/contracts/token/IERC20.sol"; import "@yield-protocol/utils-v2/contracts/token/IERC2612.sol"; import "@yield-protocol/vault-interfaces/IFYToken.sol"; interface IPool is IERC20, IERC2612 { function ts() external view returns(int128); function g1() external view returns(int128); function g2() external view returns(int128); function maturity() external view returns(uint32); function scaleFactor() external view returns(uint96); function getCache() external view returns (uint112, uint112, uint32); function base() external view returns(IERC20); function fyToken() external view returns(IFYToken); function getBaseBalance() external view returns(uint112); function getFYTokenBalance() external view returns(uint112); function retrieveBase(address to) external returns(uint128 retrieved); function retrieveFYToken(address to) external returns(uint128 retrieved); function sellBase(address to, uint128 min) external returns(uint128); function buyBase(address to, uint128 baseOut, uint128 max) external returns(uint128); function sellFYToken(address to, uint128 min) external returns(uint128); function buyFYToken(address to, uint128 fyTokenOut, uint128 max) external returns(uint128); function sellBasePreview(uint128 baseIn) external view returns(uint128); function buyBasePreview(uint128 baseOut) external view returns(uint128); function sellFYTokenPreview(uint128 fyTokenIn) external view returns(uint128); function buyFYTokenPreview(uint128 fyTokenOut) external view returns(uint128); function mint(address to, address remainder, uint256 minRatio, uint256 maxRatio) external returns (uint256, uint256, uint256); function mintWithBase(address to, address remainder, uint256 fyTokenToBuy, uint256 minRatio, uint256 maxRatio) external returns (uint256, uint256, uint256); function burn(address baseTo, address fyTokenTo, uint256 minRatio, uint256 maxRatio) external returns (uint256, uint256, uint256); function burnForBase(address to, uint256 minRatio, uint256 maxRatio) external returns (uint256, uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IPoolFactory { event PoolCreated(address indexed base, address indexed fyToken, address pool); function POOL_BYTECODE_HASH() external pure returns (bytes32); function calculatePoolAddress(address base, address fyToken) external view returns (address); function getPool(address base, address fyToken) external view returns (address); function createPool(address base, address fyToken) external returns (address); function nextBase() external view returns (address); function nextFYToken() external view returns (address); function ts() external view returns (int128); function g1() external view returns (int128); function g2() external view returns (int128); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@yield-protocol/utils-v2/contracts/token/IERC20.sol"; interface IFYToken is IERC20 { /// @dev Asset that is returned on redemption. function underlying() external view returns (address); /// @dev Unix time at which redemption of fyToken for underlying are possible function maturity() external view returns (uint256); /// @dev Record price data at maturity function mature() external; /// @dev Mint fyToken providing an equal amount of underlying to the protocol function mintWithUnderlying(address to, uint256 amount) external; /// @dev Burn fyToken after maturity for an amount of underlying. function redeem(address to, uint256 amount) external returns (uint256); /// @dev Mint fyToken. /// This function can only be called by other Yield contracts, not users directly. /// @param to Wallet to mint the fyToken in. /// @param fyTokenAmount Amount of fyToken to mint. function mint(address to, uint256 fyTokenAmount) external; /// @dev Burn fyToken. /// This function can only be called by other Yield contracts, not users directly. /// @param from Wallet to burn the fyToken from. /// @param fyTokenAmount Amount of fyToken to burn. function burn(address from, uint256 fyTokenAmount) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.6; import "./Math64x64.sol"; library Exp64x64 { /** * Raise given number x into power specified as a simple fraction y/z and then * multiply the result by the normalization factor 2^(128 * (1 - y/z)). * Revert if z is zero, or if both x and y are zeros. * * @param x number to raise into given power y/z * @param y numerator of the power to raise x into * @param z denominator of the power to raise x into * @return x raised into power y/z and then multiplied by 2^(128 * (1 - y/z)) */ function pow(uint128 x, uint128 y, uint128 z) internal pure returns(uint128) { unchecked { require(z != 0); if(x == 0) { require(y != 0); return 0; } else { uint256 l = uint256(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - log_2(x)) * y / z; if(l > 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) return 0; else return pow_2(uint128(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - l)); } } } /** * Calculate base 2 logarithm of an unsigned 128-bit integer number. Revert * in case x is zero. * * @param x number to calculate base 2 logarithm of * @return base 2 logarithm of x, multiplied by 2^121 */ function log_2(uint128 x) internal pure returns(uint128) { unchecked { require(x != 0); uint b = x; uint l = 0xFE000000000000000000000000000000; if(b < 0x10000000000000000) {l -= 0x80000000000000000000000000000000; b <<= 64;} if(b < 0x1000000000000000000000000) {l -= 0x40000000000000000000000000000000; b <<= 32;} if(b < 0x10000000000000000000000000000) {l -= 0x20000000000000000000000000000000; b <<= 16;} if(b < 0x1000000000000000000000000000000) {l -= 0x10000000000000000000000000000000; b <<= 8;} if(b < 0x10000000000000000000000000000000) {l -= 0x8000000000000000000000000000000; b <<= 4;} if(b < 0x40000000000000000000000000000000) {l -= 0x4000000000000000000000000000000; b <<= 2;} if(b < 0x80000000000000000000000000000000) {l -= 0x2000000000000000000000000000000; b <<= 1;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000000000;} /* b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x1000;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x800;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x400;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x200;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x100;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x80;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x40;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x20;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x10;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x8;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x4;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) {b >>= 1; l |= 0x2;} b = b * b >> 127; if(b >= 0x100000000000000000000000000000000) l |= 0x1; */ return uint128(l); } } /** * Calculate 2 raised into given power. * * @param x power to raise 2 into, multiplied by 2^121 * @return 2 raised into given power */ function pow_2(uint128 x) internal pure returns(uint128) { unchecked { uint r = 0x80000000000000000000000000000000; if(x & 0x1000000000000000000000000000000 > 0) r = r * 0xb504f333f9de6484597d89b3754abe9f >> 127; if(x & 0x800000000000000000000000000000 > 0) r = r * 0x9837f0518db8a96f46ad23182e42f6f6 >> 127; if(x & 0x400000000000000000000000000000 > 0) r = r * 0x8b95c1e3ea8bd6e6fbe4628758a53c90 >> 127; if(x & 0x200000000000000000000000000000 > 0) r = r * 0x85aac367cc487b14c5c95b8c2154c1b2 >> 127; if(x & 0x100000000000000000000000000000 > 0) r = r * 0x82cd8698ac2ba1d73e2a475b46520bff >> 127; if(x & 0x80000000000000000000000000000 > 0) r = r * 0x8164d1f3bc0307737be56527bd14def4 >> 127; if(x & 0x40000000000000000000000000000 > 0) r = r * 0x80b1ed4fd999ab6c25335719b6e6fd20 >> 127; if(x & 0x20000000000000000000000000000 > 0) r = r * 0x8058d7d2d5e5f6b094d589f608ee4aa2 >> 127; if(x & 0x10000000000000000000000000000 > 0) r = r * 0x802c6436d0e04f50ff8ce94a6797b3ce >> 127; if(x & 0x8000000000000000000000000000 > 0) r = r * 0x8016302f174676283690dfe44d11d008 >> 127; if(x & 0x4000000000000000000000000000 > 0) r = r * 0x800b179c82028fd0945e54e2ae18f2f0 >> 127; if(x & 0x2000000000000000000000000000 > 0) r = r * 0x80058baf7fee3b5d1c718b38e549cb93 >> 127; if(x & 0x1000000000000000000000000000 > 0) r = r * 0x8002c5d00fdcfcb6b6566a58c048be1f >> 127; if(x & 0x800000000000000000000000000 > 0) r = r * 0x800162e61bed4a48e84c2e1a463473d9 >> 127; if(x & 0x400000000000000000000000000 > 0) r = r * 0x8000b17292f702a3aa22beacca949013 >> 127; if(x & 0x200000000000000000000000000 > 0) r = r * 0x800058b92abbae02030c5fa5256f41fe >> 127; if(x & 0x100000000000000000000000000 > 0) r = r * 0x80002c5c8dade4d71776c0f4dbea67d6 >> 127; if(x & 0x80000000000000000000000000 > 0) r = r * 0x8000162e44eaf636526be456600bdbe4 >> 127; if(x & 0x40000000000000000000000000 > 0) r = r * 0x80000b1721fa7c188307016c1cd4e8b6 >> 127; if(x & 0x20000000000000000000000000 > 0) r = r * 0x8000058b90de7e4cecfc487503488bb1 >> 127; if(x & 0x10000000000000000000000000 > 0) r = r * 0x800002c5c8678f36cbfce50a6de60b14 >> 127; if(x & 0x8000000000000000000000000 > 0) r = r * 0x80000162e431db9f80b2347b5d62e516 >> 127; if(x & 0x4000000000000000000000000 > 0) r = r * 0x800000b1721872d0c7b08cf1e0114152 >> 127; if(x & 0x2000000000000000000000000 > 0) r = r * 0x80000058b90c1aa8a5c3736cb77e8dff >> 127; if(x & 0x1000000000000000000000000 > 0) r = r * 0x8000002c5c8605a4635f2efc2362d978 >> 127; if(x & 0x800000000000000000000000 > 0) r = r * 0x800000162e4300e635cf4a109e3939bd >> 127; if(x & 0x400000000000000000000000 > 0) r = r * 0x8000000b17217ff81bef9c551590cf83 >> 127; if(x & 0x200000000000000000000000 > 0) r = r * 0x800000058b90bfdd4e39cd52c0cfa27c >> 127; if(x & 0x100000000000000000000000 > 0) r = r * 0x80000002c5c85fe6f72d669e0e76e411 >> 127; if(x & 0x80000000000000000000000 > 0) r = r * 0x8000000162e42ff18f9ad35186d0df28 >> 127; if(x & 0x40000000000000000000000 > 0) r = r * 0x80000000b17217f84cce71aa0dcfffe7 >> 127; if(x & 0x20000000000000000000000 > 0) r = r * 0x8000000058b90bfc07a77ad56ed22aaa >> 127; if(x & 0x10000000000000000000000 > 0) r = r * 0x800000002c5c85fdfc23cdead40da8d6 >> 127; if(x & 0x8000000000000000000000 > 0) r = r * 0x80000000162e42fefc25eb1571853a66 >> 127; if(x & 0x4000000000000000000000 > 0) r = r * 0x800000000b17217f7d97f692baacded5 >> 127; if(x & 0x2000000000000000000000 > 0) r = r * 0x80000000058b90bfbead3b8b5dd254d7 >> 127; if(x & 0x1000000000000000000000 > 0) r = r * 0x8000000002c5c85fdf4eedd62f084e67 >> 127; if(x & 0x800000000000000000000 > 0) r = r * 0x800000000162e42fefa58aef378bf586 >> 127; if(x & 0x400000000000000000000 > 0) r = r * 0x8000000000b17217f7d24a78a3c7ef02 >> 127; if(x & 0x200000000000000000000 > 0) r = r * 0x800000000058b90bfbe9067c93e474a6 >> 127; if(x & 0x100000000000000000000 > 0) r = r * 0x80000000002c5c85fdf47b8e5a72599f >> 127; if(x & 0x80000000000000000000 > 0) r = r * 0x8000000000162e42fefa3bdb315934a2 >> 127; if(x & 0x40000000000000000000 > 0) r = r * 0x80000000000b17217f7d1d7299b49c46 >> 127; if(x & 0x20000000000000000000 > 0) r = r * 0x8000000000058b90bfbe8e9a8d1c4ea0 >> 127; if(x & 0x10000000000000000000 > 0) r = r * 0x800000000002c5c85fdf4745969ea76f >> 127; if(x & 0x8000000000000000000 > 0) r = r * 0x80000000000162e42fefa3a0df5373bf >> 127; if(x & 0x4000000000000000000 > 0) r = r * 0x800000000000b17217f7d1cff4aac1e1 >> 127; if(x & 0x2000000000000000000 > 0) r = r * 0x80000000000058b90bfbe8e7db95a2f1 >> 127; if(x & 0x1000000000000000000 > 0) r = r * 0x8000000000002c5c85fdf473e61ae1f8 >> 127; if(x & 0x800000000000000000 > 0) r = r * 0x800000000000162e42fefa39f121751c >> 127; if(x & 0x400000000000000000 > 0) r = r * 0x8000000000000b17217f7d1cf815bb96 >> 127; if(x & 0x200000000000000000 > 0) r = r * 0x800000000000058b90bfbe8e7bec1e0d >> 127; if(x & 0x100000000000000000 > 0) r = r * 0x80000000000002c5c85fdf473dee5f17 >> 127; if(x & 0x80000000000000000 > 0) r = r * 0x8000000000000162e42fefa39ef5438f >> 127; if(x & 0x40000000000000000 > 0) r = r * 0x80000000000000b17217f7d1cf7a26c8 >> 127; if(x & 0x20000000000000000 > 0) r = r * 0x8000000000000058b90bfbe8e7bcf4a4 >> 127; if(x & 0x10000000000000000 > 0) r = r * 0x800000000000002c5c85fdf473de72a2 >> 127; /* if(x & 0x8000000000000000 > 0) r = r * 0x80000000000000162e42fefa39ef3765 >> 127; if(x & 0x4000000000000000 > 0) r = r * 0x800000000000000b17217f7d1cf79b37 >> 127; if(x & 0x2000000000000000 > 0) r = r * 0x80000000000000058b90bfbe8e7bcd7d >> 127; if(x & 0x1000000000000000 > 0) r = r * 0x8000000000000002c5c85fdf473de6b6 >> 127; if(x & 0x800000000000000 > 0) r = r * 0x800000000000000162e42fefa39ef359 >> 127; if(x & 0x400000000000000 > 0) r = r * 0x8000000000000000b17217f7d1cf79ac >> 127; if(x & 0x200000000000000 > 0) r = r * 0x800000000000000058b90bfbe8e7bcd6 >> 127; if(x & 0x100000000000000 > 0) r = r * 0x80000000000000002c5c85fdf473de6a >> 127; if(x & 0x80000000000000 > 0) r = r * 0x8000000000000000162e42fefa39ef35 >> 127; if(x & 0x40000000000000 > 0) r = r * 0x80000000000000000b17217f7d1cf79a >> 127; if(x & 0x20000000000000 > 0) r = r * 0x8000000000000000058b90bfbe8e7bcd >> 127; if(x & 0x10000000000000 > 0) r = r * 0x800000000000000002c5c85fdf473de6 >> 127; if(x & 0x8000000000000 > 0) r = r * 0x80000000000000000162e42fefa39ef3 >> 127; if(x & 0x4000000000000 > 0) r = r * 0x800000000000000000b17217f7d1cf79 >> 127; if(x & 0x2000000000000 > 0) r = r * 0x80000000000000000058b90bfbe8e7bc >> 127; if(x & 0x1000000000000 > 0) r = r * 0x8000000000000000002c5c85fdf473de >> 127; if(x & 0x800000000000 > 0) r = r * 0x800000000000000000162e42fefa39ef >> 127; if(x & 0x400000000000 > 0) r = r * 0x8000000000000000000b17217f7d1cf7 >> 127; if(x & 0x200000000000 > 0) r = r * 0x800000000000000000058b90bfbe8e7b >> 127; if(x & 0x100000000000 > 0) r = r * 0x80000000000000000002c5c85fdf473d >> 127; if(x & 0x80000000000 > 0) r = r * 0x8000000000000000000162e42fefa39e >> 127; if(x & 0x40000000000 > 0) r = r * 0x80000000000000000000b17217f7d1cf >> 127; if(x & 0x20000000000 > 0) r = r * 0x8000000000000000000058b90bfbe8e7 >> 127; if(x & 0x10000000000 > 0) r = r * 0x800000000000000000002c5c85fdf473 >> 127; if(x & 0x8000000000 > 0) r = r * 0x80000000000000000000162e42fefa39 >> 127; if(x & 0x4000000000 > 0) r = r * 0x800000000000000000000b17217f7d1c >> 127; if(x & 0x2000000000 > 0) r = r * 0x80000000000000000000058b90bfbe8e >> 127; if(x & 0x1000000000 > 0) r = r * 0x8000000000000000000002c5c85fdf47 >> 127; if(x & 0x800000000 > 0) r = r * 0x800000000000000000000162e42fefa3 >> 127; if(x & 0x400000000 > 0) r = r * 0x8000000000000000000000b17217f7d1 >> 127; if(x & 0x200000000 > 0) r = r * 0x800000000000000000000058b90bfbe8 >> 127; if(x & 0x100000000 > 0) r = r * 0x80000000000000000000002c5c85fdf4 >> 127; if(x & 0x80000000 > 0) r = r * 0x8000000000000000000000162e42fefa >> 127; if(x & 0x40000000 > 0) r = r * 0x80000000000000000000000b17217f7d >> 127; if(x & 0x20000000 > 0) r = r * 0x8000000000000000000000058b90bfbe >> 127; if(x & 0x10000000 > 0) r = r * 0x800000000000000000000002c5c85fdf >> 127; if(x & 0x8000000 > 0) r = r * 0x80000000000000000000000162e42fef >> 127; if(x & 0x4000000 > 0) r = r * 0x800000000000000000000000b17217f7 >> 127; if(x & 0x2000000 > 0) r = r * 0x80000000000000000000000058b90bfb >> 127; if(x & 0x1000000 > 0) r = r * 0x8000000000000000000000002c5c85fd >> 127; if(x & 0x800000 > 0) r = r * 0x800000000000000000000000162e42fe >> 127; if(x & 0x400000 > 0) r = r * 0x8000000000000000000000000b17217f >> 127; if(x & 0x200000 > 0) r = r * 0x800000000000000000000000058b90bf >> 127; if(x & 0x100000 > 0) r = r * 0x80000000000000000000000002c5c85f >> 127; if(x & 0x80000 > 0) r = r * 0x8000000000000000000000000162e42f >> 127; if(x & 0x40000 > 0) r = r * 0x80000000000000000000000000b17217 >> 127; if(x & 0x20000 > 0) r = r * 0x8000000000000000000000000058b90b >> 127; if(x & 0x10000 > 0) r = r * 0x800000000000000000000000002c5c85 >> 127; if(x & 0x8000 > 0) r = r * 0x80000000000000000000000000162e42 >> 127; if(x & 0x4000 > 0) r = r * 0x800000000000000000000000000b1721 >> 127; if(x & 0x2000 > 0) r = r * 0x80000000000000000000000000058b90 >> 127; if(x & 0x1000 > 0) r = r * 0x8000000000000000000000000002c5c8 >> 127; if(x & 0x800 > 0) r = r * 0x800000000000000000000000000162e4 >> 127; if(x & 0x400 > 0) r = r * 0x8000000000000000000000000000b172 >> 127; if(x & 0x200 > 0) r = r * 0x800000000000000000000000000058b9 >> 127; if(x & 0x100 > 0) r = r * 0x80000000000000000000000000002c5c >> 127; if(x & 0x80 > 0) r = r * 0x8000000000000000000000000000162e >> 127; if(x & 0x40 > 0) r = r * 0x80000000000000000000000000000b17 >> 127; if(x & 0x20 > 0) r = r * 0x8000000000000000000000000000058b >> 127; if(x & 0x10 > 0) r = r * 0x800000000000000000000000000002c5 >> 127; if(x & 0x8 > 0) r = r * 0x80000000000000000000000000000162 >> 127; if(x & 0x4 > 0) r = r * 0x800000000000000000000000000000b1 >> 127; if(x & 0x2 > 0) r = r * 0x80000000000000000000000000000058 >> 127; if(x & 0x1 > 0) r = r * 0x8000000000000000000000000000002c >> 127; */ r >>= 127 -(x >> 121); return uint128(r); } } } /** * Ethereum smart contract library implementing Yield Math model. */ library YieldMath { using Math64x64 for int128; using Math64x64 for uint128; using Math64x64 for int256; using Math64x64 for uint256; using Exp64x64 for uint128; uint128 public constant ONE = 0x10000000000000000; // In 64.64 uint128 public constant TWO = 0x20000000000000000; // In 64.64 uint256 public constant MAX = type(uint128).max; // Used for overflow checks uint256 public constant VAR = 1e12; // The logarithm math used is not precise to the wei, but can deviate up to 1e12 from the real value. /** * Calculate a YieldSpace pool invariant according to the whitepaper */ function invariant(uint128 baseReserves, uint128 fyTokenReserves, uint256 totalSupply, uint128 timeTillMaturity, int128 ts) public pure returns(uint128) { if (totalSupply == 0) return 0; unchecked { // a = (1 - ts * timeTillMaturity) int128 a = int128(ONE).sub(ts.mul(timeTillMaturity.fromUInt())); require (a > 0, "YieldMath: Too far from maturity"); uint256 sum = uint256(baseReserves.pow(uint128 (a), ONE)) + uint256(fyTokenReserves.pow(uint128 (a), ONE)) >> 1; require(sum < MAX, "YieldMath: Sum overflow"); uint256 result = uint256(uint128(sum).pow(ONE, uint128(a))) / totalSupply; require (result < MAX, "YieldMath: Result overflow"); return uint128(result); } } /** * Calculate the amount of fyToken a user would get for given amount of Base. * https://www.desmos.com/calculator/5nf2xuy6yb * @param baseReserves base reserves amount * @param fyTokenReserves fyToken reserves amount * @param baseAmount base amount to be traded * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return the amount of fyToken a user would get for given amount of Base */ function fyTokenOutForBaseIn( uint128 baseReserves, uint128 fyTokenReserves, uint128 baseAmount, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns(uint128) { unchecked { uint128 a = _computeA(timeTillMaturity, ts, g); // za = baseReserves ** a uint256 za = baseReserves.pow(a, ONE); // ya = fyTokenReserves ** a uint256 ya = fyTokenReserves.pow(a, ONE); // zx = baseReserves + baseAmount uint256 zx = uint256(baseReserves) + uint256(baseAmount); require(zx <= MAX, "YieldMath: Too much base in"); // zxa = zx ** a uint256 zxa = uint128(zx).pow(a, ONE); // sum = za + ya - zxa uint256 sum = za + ya - zxa; // z < MAX, y < MAX, a < 1. It can only underflow, not overflow. require(sum <= MAX, "YieldMath: Insufficient fyToken reserves"); // result = fyTokenReserves - (sum ** (1/a)) uint256 result = uint256(fyTokenReserves) - uint256(uint128(sum).pow(ONE, a)); require(result <= MAX, "YieldMath: Rounding induced error"); result = result > VAR ? result - VAR : 0; // Subtract error guard, flooring the result at zero return uint128(result); } } /** * Calculate the amount of base a user would get for certain amount of fyToken. * https://www.desmos.com/calculator/6jlrre7ybt * @param baseReserves base reserves amount * @param fyTokenReserves fyToken reserves amount * @param fyTokenAmount fyToken amount to be traded * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return the amount of Base a user would get for given amount of fyToken */ function baseOutForFYTokenIn( uint128 baseReserves, uint128 fyTokenReserves, uint128 fyTokenAmount, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns(uint128) { unchecked { uint128 a = _computeA(timeTillMaturity, ts, g); // za = baseReserves ** a uint256 za = baseReserves.pow(a, ONE); // ya = fyTokenReserves ** a uint256 ya = fyTokenReserves.pow(a, ONE); // yx = fyDayReserves + fyTokenAmount uint256 yx = uint256(fyTokenReserves) + uint256(fyTokenAmount); require(yx <= MAX, "YieldMath: Too much fyToken in"); // yxa = yx ** a uint256 yxa = uint128(yx).pow(a, ONE); // sum = za + ya - yxa uint256 sum = za + ya - yxa; // z < MAX, y < MAX, a < 1. It can only underflow, not overflow. require(sum <= MAX, "YieldMath: Insufficient base reserves"); // result = baseReserves - (sum ** (1/a)) uint256 result = uint256(baseReserves) - uint256(uint128(sum).pow(ONE, a)); require(result <= MAX, "YieldMath: Rounding induced error"); result = result > VAR ? result - VAR : 0; // Subtract error guard, flooring the result at zero return uint128(result); } } /** * Calculate the amount of fyToken a user could sell for given amount of Base. * https://www.desmos.com/calculator/0rgnmtckvy * @param baseReserves base reserves amount * @param fyTokenReserves fyToken reserves amount * @param baseAmount Base amount to be traded * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return the amount of fyToken a user could sell for given amount of Base */ function fyTokenInForBaseOut( uint128 baseReserves, uint128 fyTokenReserves, uint128 baseAmount, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns(uint128) { unchecked { uint128 a = _computeA(timeTillMaturity, ts, g); // za = baseReserves ** a uint256 za = baseReserves.pow(a, ONE); // ya = fyTokenReserves ** a uint256 ya = fyTokenReserves.pow(a, ONE); // zx = baseReserves - baseAmount uint256 zx = uint256(baseReserves) - uint256(baseAmount); require(zx <= MAX, "YieldMath: Too much base out"); // zxa = zx ** a uint256 zxa = uint128(zx).pow(a, ONE); // sum = za + ya - zxa uint256 sum = za + ya - zxa; // z < MAX, y < MAX, a < 1. It can only underflow, not overflow. require(sum <= MAX, "YieldMath: Resulting fyToken reserves too high"); // result = (sum ** (1/a)) - fyTokenReserves uint256 result = uint256(uint128(sum).pow(ONE, a)) - uint256(fyTokenReserves); require(result <= MAX, "YieldMath: Rounding induced error"); result = result < MAX - VAR ? result + VAR : MAX; // Add error guard, ceiling the result at max return uint128(result); } } /** * Calculate the amount of base a user would have to pay for certain amount of fyToken. * https://www.desmos.com/calculator/ws5oqj8x5i * @param baseReserves Base reserves amount * @param fyTokenReserves fyToken reserves amount * @param fyTokenAmount fyToken amount to be traded * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return the amount of base a user would have to pay for given amount of * fyToken */ function baseInForFYTokenOut( uint128 baseReserves, uint128 fyTokenReserves, uint128 fyTokenAmount, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns(uint128) { unchecked { uint128 a = _computeA(timeTillMaturity, ts, g); // za = baseReserves ** a uint256 za = baseReserves.pow(a, ONE); // ya = fyTokenReserves ** a uint256 ya = fyTokenReserves.pow(a, ONE); // yx = baseReserves - baseAmount uint256 yx = uint256(fyTokenReserves) - uint256(fyTokenAmount); require(yx <= MAX, "YieldMath: Too much fyToken out"); // yxa = yx ** a uint256 yxa = uint128(yx).pow(a, ONE); // sum = za + ya - yxa uint256 sum = za + ya - yxa; // z < MAX, y < MAX, a < 1. It can only underflow, not overflow. require(sum <= MAX, "YieldMath: Resulting base reserves too high"); // result = (sum ** (1/a)) - baseReserves uint256 result = uint256(uint128(sum).pow(ONE, a)) - uint256(baseReserves); require(result <= MAX, "YieldMath: Rounding induced error"); result = result < MAX - VAR ? result + VAR : MAX; // Add error guard, ceiling the result at max return uint128(result); } } /** * Calculate the max amount of fyTokens that can be bought from the pool without making the interest rate negative. * See section 6.3 of the YieldSpace White paper * @param baseReserves Base reserves amount * @param fyTokenReserves fyToken reserves amount * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return max amount of fyTokens that can be bought from the pool */ function maxFYTokenOut( uint128 baseReserves, uint128 fyTokenReserves, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns(uint128) { if (baseReserves == fyTokenReserves) return 0; unchecked { uint128 a = _computeA(timeTillMaturity, ts, g); // xa = baseReserves ** a uint128 xa = baseReserves.pow(a, ONE); // ya = fyTokenReserves ** a uint128 ya = fyTokenReserves.pow(a, ONE); int128 xy2 = (xa + ya).divu(TWO); uint inaccessible = uint256(uint128(xy2).pow(ONE, a)); require(inaccessible <= MAX, "YieldMath: Rounding induced error"); inaccessible = inaccessible < MAX - VAR ? inaccessible + VAR : MAX; // Add error guard, ceiling the result at max return uint128(inaccessible) > fyTokenReserves ? 0 : fyTokenReserves - uint128(inaccessible); } } /** * Calculate the max amount of fyTokens that can be sold to into the pool. * @param baseReserves Base reserves amount * @param fyTokenReserves fyToken reserves amount * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return max amount of fyTokens that can be sold to into the pool */ function maxFYTokenIn( uint128 baseReserves, uint128 fyTokenReserves, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns(uint128) { unchecked { uint128 b = _computeB(timeTillMaturity, ts, g); // xa = baseReserves ** a uint128 xa = baseReserves.pow(b, ONE); // ya = fyTokenReserves ** a uint128 ya = fyTokenReserves.pow(b, ONE); uint result = (xa + ya).pow(ONE, b) - fyTokenReserves; require(result <= MAX, "YieldMath: Rounding induced error"); result = result > VAR ? result - VAR : 0; // Subtract error guard, flooring the result at zero return uint128(result); } } /** * Calculate the max amount of base that can be sold to into the pool without making the interest rate negative. * @param baseReserves Base reserves amount * @param fyTokenReserves fyToken reserves amount * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return max amount of base that can be sold to into the pool */ function maxBaseIn( uint128 baseReserves, uint128 fyTokenReserves, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns (uint128) { uint128 _maxFYTokenOut = maxFYTokenOut(baseReserves, fyTokenReserves, timeTillMaturity, ts, g); if (_maxFYTokenOut > 0) return baseInForFYTokenOut(baseReserves, fyTokenReserves, _maxFYTokenOut, timeTillMaturity, ts, g); return 0; } /** * Calculate the max amount of base that can be bought from the pool. * @param baseReserves Base reserves amount * @param fyTokenReserves fyToken reserves amount * @param timeTillMaturity time till maturity in seconds * @param ts time till maturity coefficient, multiplied by 2^64 * @param g fee coefficient, multiplied by 2^64 * @return max amount of base that can be bought from the pool */ function maxBaseOut( uint128 baseReserves, uint128 fyTokenReserves, uint128 timeTillMaturity, int128 ts, int128 g) public pure returns (uint128) { uint128 _maxFYTokenIn = maxFYTokenIn(baseReserves, fyTokenReserves, timeTillMaturity, ts, g); return baseOutForFYTokenIn(baseReserves, fyTokenReserves, _maxFYTokenIn, timeTillMaturity, ts, g); } function _computeA(uint128 timeTillMaturity, int128 ts, int128 g) private pure returns (uint128) { unchecked { // t = ts * timeTillMaturity int128 t = ts.mul(timeTillMaturity.fromUInt()); require(t >= 0, "YieldMath: t must be positive"); // Meaning neither T or ts can be negative // a = (1 - gt) int128 a = int128(ONE).sub(g.mul(t)); require(a > 0, "YieldMath: Too far from maturity"); require(a <= int128(ONE), "YieldMath: g must be positive"); return uint128(a); } } function _computeB(uint128 timeTillMaturity, int128 ts, int128 g) private pure returns (uint128) { unchecked { // t = ts * timeTillMaturity int128 t = ts.mul(timeTillMaturity.fromUInt()); require(t >= 0, "YieldMath: t must be positive"); // Meaning neither T or ts can be negative // b = (1 - t/g) int128 b = int128(ONE).sub(t.div(g)); require(b > 0, "YieldMath: Too far from maturity"); require(b <= int128(ONE), "YieldMath: g must be positive"); return uint128(b); } } }
// SPDX-License-Identifier: MIT // Inspired on token.sol from DappHub. Natspec adpated from OpenZeppelin. pragma solidity ^0.8.0; import "./IERC20Metadata.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}. * * We have followed general OpenZeppelin guidelines: functions revert instead * of 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. * * Calls to {transferFrom} do not check for allowance if the caller is the owner * of the funds. This allows to reduce the number of approvals that are necessary. * * Finally, {transferFrom} does not decrease the allowance if it is set to * type(uint256).max. This reduces the gas costs without any likely impact. */ contract ERC20 is IERC20Metadata { uint256 internal _totalSupply; mapping (address => uint256) internal _balanceOf; mapping (address => mapping (address => uint256)) internal _allowance; string public override name = "???"; string public override symbol = "???"; uint8 public override decimals = 18; /** * @dev Sets the values for {name}, {symbol} and {decimals}. */ constructor(string memory name_, string memory symbol_, uint8 decimals_) { name = name_; symbol = symbol_; decimals = decimals_; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() external view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address guy) external view virtual override returns (uint256) { return _balanceOf[guy]; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) external view virtual override returns (uint256) { return _allowance[owner][spender]; } /** * @dev See {IERC20-approve}. */ function approve(address spender, uint wad) external virtual override returns (bool) { return _setAllowance(msg.sender, spender, wad); } /** * @dev See {IERC20-transfer}. * * Requirements: * * - the caller must have a balance of at least `wad`. */ function transfer(address dst, uint wad) external virtual override returns (bool) { return _transfer(msg.sender, dst, wad); } /** * @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: * * - `src` must have a balance of at least `wad`. * - the caller is not `src`, it must have allowance for ``src``'s tokens of at least * `wad`. */ /// if_succeeds {:msg "TransferFrom - decrease allowance"} msg.sender != src ==> old(_allowance[src][msg.sender]) >= wad; function transferFrom(address src, address dst, uint wad) external virtual override returns (bool) { _decreaseAllowance(src, wad); return _transfer(src, dst, wad); } /** * @dev Moves tokens `wad` from `src` to `dst`. * * Emits a {Transfer} event. * * Requirements: * * - `src` must have a balance of at least `amount`. */ /// if_succeeds {:msg "Transfer - src decrease"} old(_balanceOf[src]) >= _balanceOf[src]; /// if_succeeds {:msg "Transfer - dst increase"} _balanceOf[dst] >= old(_balanceOf[dst]); /// if_succeeds {:msg "Transfer - supply"} old(_balanceOf[src]) + old(_balanceOf[dst]) == _balanceOf[src] + _balanceOf[dst]; function _transfer(address src, address dst, uint wad) internal virtual returns (bool) { require(_balanceOf[src] >= wad, "ERC20: Insufficient balance"); unchecked { _balanceOf[src] = _balanceOf[src] - wad; } _balanceOf[dst] = _balanceOf[dst] + wad; emit Transfer(src, dst, wad); return true; } /** * @dev Sets the allowance granted to `spender` by `owner`. * * Emits an {Approval} event indicating the updated allowance. */ function _setAllowance(address owner, address spender, uint wad) internal virtual returns (bool) { _allowance[owner][spender] = wad; emit Approval(owner, spender, wad); return true; } /** * @dev Decreases the allowance granted to the caller by `src`, unless src == msg.sender or _allowance[src][msg.sender] == MAX * * Emits an {Approval} event indicating the updated allowance, if the allowance is updated. * * Requirements: * * - `spender` must have allowance for the caller of at least * `wad`, unless src == msg.sender */ /// if_succeeds {:msg "Decrease allowance - underflow"} old(_allowance[src][msg.sender]) <= _allowance[src][msg.sender]; function _decreaseAllowance(address src, uint wad) internal virtual returns (bool) { if (src != msg.sender) { uint256 allowed = _allowance[src][msg.sender]; if (allowed != type(uint).max) { require(allowed >= wad, "ERC20: Insufficient approval"); unchecked { _setAllowance(src, msg.sender, allowed - wad); } } } return true; } /** @dev Creates `wad` tokens and assigns them to `dst`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. */ /// if_succeeds {:msg "Mint - balance overflow"} old(_balanceOf[dst]) >= _balanceOf[dst]; /// if_succeeds {:msg "Mint - supply overflow"} old(_totalSupply) >= _totalSupply; function _mint(address dst, uint wad) internal virtual returns (bool) { _balanceOf[dst] = _balanceOf[dst] + wad; _totalSupply = _totalSupply + wad; emit Transfer(address(0), dst, wad); return true; } /** * @dev Destroys `wad` tokens from `src`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `src` must have at least `wad` tokens. */ /// if_succeeds {:msg "Burn - balance underflow"} old(_balanceOf[src]) <= _balanceOf[src]; /// if_succeeds {:msg "Burn - supply underflow"} old(_totalSupply) <= _totalSupply; function _burn(address src, uint wad) internal virtual returns (bool) { unchecked { require(_balanceOf[src] >= wad, "ERC20: Insufficient balance"); _balanceOf[src] = _balanceOf[src] - wad; _totalSupply = _totalSupply - wad; emit Transfer(src, address(0), wad); } return true; } }
// SPDX-License-Identifier: MIT // Code adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237/ pragma solidity ^0.8.0; /** * @dev Interface of the ERC2612 standard as defined in the EIP. * * Adds the {permit} method, which can be used to change one's * {IERC20-allowance} without having to send a transaction, by signing a * message. This allows users to spend tokens without having to hold Ether. * * See https://eips.ethereum.org/EIPS/eip-2612. */ interface IERC2612 { /** * @dev Sets `amount` 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: * * - `owner` cannot be the zero address. * - `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 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; /** * @dev Returns the current ERC2612 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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; library AddressStringUtil { // converts an address to the uppercase hex string, extracting only len bytes (up to 20, multiple of 2) function toAsciiString(address addr, uint256 len) internal pure returns (string memory) { require(len % 2 == 0 && len > 0 && len <= 40, "AddressStringUtil: INVALID_LEN"); bytes memory s = new bytes(len); uint256 addrNum = uint256(uint160(addr)); for (uint256 ii = 0; ii < len ; ii +=2) { uint8 b = uint8(addrNum >> (4 * (38 - ii))); s[ii] = char(b >> 4); s[ii + 1] = char(b & 0x0f); } return string(s); } // hi and lo are only 4 bits and between 0 and 16 // this method converts those values to the unicode/ascii code point for the hex representation // uses upper case for the characters function char(uint8 b) private pure returns (bytes1 c) { if (b < 10) { return bytes1(b + 0x30); } else { return bytes1(b + 0x37); } } }
// SPDX-License-Identifier: MIT // Taken from https://github.com/sushiswap/BoringSolidity/blob/441e51c0544cf2451e6116fe00515e71d7c42e2c/contracts/BoringBatchable.sol pragma solidity >=0.6.0; library RevertMsgExtractor { /// @dev Helper function to extract a useful revert message from a failed call. /// If the returned data is malformed or not correctly abi encoded then this call can fail itself. function getRevertMsg(bytes memory returnData) internal pure returns (string memory) { // If the _res length is less than 68, then the transaction failed silently (without a revert message) if (returnData.length < 68) return "Transaction reverted silently"; assembly { // Slice the sighash. returnData := add(returnData, 0x04) } return abi.decode(returnData, (string)); // All that remains is the revert string } }
// SPDX-License-Identifier: BUSL-1.1 /* * Math 64.64 Smart Contract Library. Copyright © 2019 by Consulting. * Author: Mikhail Vladimirov <[email protected]> */ pragma solidity 0.8.6; /** * 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 Math64x64 { /* * 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); } } } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": { "@yield-protocol/utils-v2/contracts/token/SafeERC20Namer.sol": { "SafeERC20Namer": "0x39bb9cBe0221D769E30bD08d185842065BcE1706" }, "@yield-protocol/yieldspace-v2/contracts/YieldMath.sol": { "YieldMath": "0x856ddd1a74b6e620d043efd6f74d81b8bf34868d" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"maturity","type":"uint32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"fyTokenTo","type":"address"},{"indexed":false,"internalType":"int256","name":"bases","type":"int256"},{"indexed":false,"internalType":"int256","name":"fyTokens","type":"int256"},{"indexed":false,"internalType":"int256","name":"poolTokens","type":"int256"}],"name":"Liquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint112","name":"baseCached","type":"uint112"},{"indexed":false,"internalType":"uint112","name":"fyTokenCached","type":"uint112"},{"indexed":false,"internalType":"uint256","name":"cumulativeBalancesRatio","type":"uint256"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"maturity","type":"uint32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"int256","name":"bases","type":"int256"},{"indexed":false,"internalType":"int256","name":"fyTokens","type":"int256"}],"name":"Trade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guy","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"base","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"baseTo","type":"address"},{"internalType":"address","name":"fyTokenTo","type":"address"},{"internalType":"uint256","name":"minRatio","type":"uint256"},{"internalType":"uint256","name":"maxRatio","type":"uint256"}],"name":"burn","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"minRatio","type":"uint256"},{"internalType":"uint256","name":"maxRatio","type":"uint256"}],"name":"burnForBase","outputs":[{"internalType":"uint256","name":"tokensBurned","type":"uint256"},{"internalType":"uint256","name":"baseOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint128","name":"tokenOut","type":"uint128"},{"internalType":"uint128","name":"max","type":"uint128"}],"name":"buyBase","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"tokenOut","type":"uint128"}],"name":"buyBasePreview","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint128","name":"fyTokenOut","type":"uint128"},{"internalType":"uint128","name":"max","type":"uint128"}],"name":"buyFYToken","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"fyTokenOut","type":"uint128"}],"name":"buyFYTokenPreview","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cumulativeBalancesRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deploymentChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fyToken","outputs":[{"internalType":"contract IFYToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"g1","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"g2","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBaseBalance","outputs":[{"internalType":"uint112","name":"","type":"uint112"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCache","outputs":[{"internalType":"uint112","name":"","type":"uint112"},{"internalType":"uint112","name":"","type":"uint112"},{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFYTokenBalance","outputs":[{"internalType":"uint112","name":"","type":"uint112"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maturity","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"remainder","type":"address"},{"internalType":"uint256","name":"minRatio","type":"uint256"},{"internalType":"uint256","name":"maxRatio","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"remainder","type":"address"},{"internalType":"uint256","name":"fyTokenToBuy","type":"uint256"},{"internalType":"uint256","name":"minRatio","type":"uint256"},{"internalType":"uint256","name":"maxRatio","type":"uint256"}],"name":"mintWithBase","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"retrieveBase","outputs":[{"internalType":"uint128","name":"retrieved","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"retrieveFYToken","outputs":[{"internalType":"uint128","name":"retrieved","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"scaleFactor","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint128","name":"min","type":"uint128"}],"name":"sellBase","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"baseIn","type":"uint128"}],"name":"sellBasePreview","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint128","name":"min","type":"uint128"}],"name":"sellFYToken","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"fyTokenIn","type":"uint128"}],"name":"sellFYTokenPreview","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sync","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ts","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
61020060405260036101c0819052623f3f3f60e81b6101e0908152620000279190816200097a565b50604080518082019091526003808252623f3f3f60e81b602090920191825262000054916004916200097a565b506005805460ff191660121790557f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c96080523480156200009357600080fd5b507339bb9cbe0221d769e30bd08d185842065bce170663e54f7522336001600160a01b031663b51616aa6040518163ffffffff1660e01b815260040160206040518083038186803b158015620000e857600080fd5b505afa158015620000fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000123919062000a20565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b1580156200016357600080fd5b505af415801562000178573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620001a2919081019062000a77565b604051602001620001b4919062000c3a565b6040516020818303038152906040527339bb9cbe0221d769e30bd08d185842065bce170663033b9b4f336001600160a01b031663b51616aa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200021757600080fd5b505afa1580156200022c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000252919062000a20565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160006040518083038186803b1580156200029257600080fd5b505af4158015620002a7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620002d1919081019062000a77565b604051602001620002e3919062000c12565b6040516020818303038152906040527339bb9cbe0221d769e30bd08d185842065bce1706638ee573ac336001600160a01b031663d8406cb46040518163ffffffff1660e01b815260040160206040518083038186803b1580156200034657600080fd5b505afa1580156200035b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000381919062000a20565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b158015620003c157600080fd5b505af4158015620003d6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003fc919062000b49565b8282828260039080519060200190620004179291906200097a565b5081516200042d9060049060208501906200097a565b506005805460ff191660ff9290921691909117905550504660c08190526200045590620008c4565b60a0818152505050505060003390506000816001600160a01b031663b51616aa6040518163ffffffff1660e01b815260040160206040518083038186803b158015620004a057600080fd5b505afa158015620004b5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004db919062000a20565b90506000826001600160a01b031663d8406cb46040518163ffffffff1660e01b815260040160206040518083038186803b1580156200051957600080fd5b505afa1580156200052e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000554919062000a20565b6001600160601b0319606084811b82166101a05282901b16610180526040805163204f83f960e01b815290519192506000916001600160a01b0385169163204f83f9916004808301926020929190829003018186803b158015620005b757600080fd5b505afa158015620005cc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005f2919062000b2f565b905063ffffffff811115620006595760405162461bcd60e51b8152602060048201526024808201527f506f6f6c3a204d6174757269747920746f6f2066617220696e207468652066756044820152637475726560e01b606482015260840160405180910390fd5b8063ffffffff166101408163ffffffff1660e01b81525050836001600160a01b031663e86d60bf6040518163ffffffff1660e01b815260040160206040518083038186803b158015620006ab57600080fd5b505afa158015620006c0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006e6919062000a52565b600f0b60e081600f0b60801b81525050836001600160a01b031663bdd8a3666040518163ffffffff1660e01b815260040160206040518083038186803b1580156200073057600080fd5b505afa15801562000745573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200076b919062000a52565b600f0b61010081600f0b60801b81525050836001600160a01b0316636970a9246040518163ffffffff1660e01b815260040160206040518083038186803b158015620007b657600080fd5b505afa158015620007cb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007f1919062000a52565b600f90810b900b60801b610120526040516323b95ceb60e21b81526001600160a01b03831660048201527339bb9cbe0221d769e30bd08d185842065bce170690638ee573ac9060240160206040518083038186803b1580156200085357600080fd5b505af415801562000868573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200088e919062000b49565b6200089b90601262000d87565b620008a890600a62000cc6565b60a01b6001600160a01b031916610160525062000e4992505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6003604051620008f8919062000b6e565b60408051918290038220828201825260018352603160f81b602093840152815180840194909452838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606084015260808301949094523060a0808401919091528451808403909101815260c09092019093528051920191909120919050565b828054620009889062000de0565b90600052602060002090601f016020900481019282620009ac5760008555620009f7565b82601f10620009c757805160ff1916838001178555620009f7565b82800160010185558215620009f7579182015b82811115620009f7578251825591602001919060010190620009da565b5062000a0592915062000a09565b5090565b5b8082111562000a05576000815560010162000a0a565b60006020828403121562000a3357600080fd5b81516001600160a01b038116811462000a4b57600080fd5b9392505050565b60006020828403121562000a6557600080fd5b815180600f0b811462000a4b57600080fd5b60006020828403121562000a8a57600080fd5b81516001600160401b038082111562000aa257600080fd5b818401915084601f83011262000ab757600080fd5b81518181111562000acc5762000acc62000e33565b604051601f8201601f19908116603f0116810190838211818310171562000af75762000af762000e33565b8160405282815287602084870101111562000b1157600080fd5b62000b2483602083016020880162000dad565b979650505050505050565b60006020828403121562000b4257600080fd5b5051919050565b60006020828403121562000b5c57600080fd5b815160ff8116811462000a4b57600080fd5b600080835481600182811c91508083168062000b8b57607f831692505b602080841082141562000bac57634e487b7160e01b86526022600452602486fd5b81801562000bc3576001811462000bd55762000c04565b60ff1986168952848901965062000c04565b60008a81526020902060005b8681101562000bfc5781548b82015290850190830162000be1565b505084890196505b509498975050505050505050565b6000825162000c2681846020870162000dad565b6104c560f41b920191825250600201919050565b6502cb4b2b632160d51b81526000825162000c5d81600685016020870162000dad565b68102628102a37b5b2b760b91b6006939091019283015250600f01919050565b600181815b8085111562000cbe57816000190482111562000ca25762000ca262000e1d565b8085161562000cb057918102915b93841c939080029062000c82565b509250929050565b600062000a4b60ff84168360008262000ce25750600162000d81565b8162000cf15750600062000d81565b816001811462000d0a576002811462000d155762000d35565b600191505062000d81565b60ff84111562000d295762000d2962000e1d565b50506001821b62000d81565b5060208310610133831016604e8410600b841016171562000d5a575081810a62000d81565b62000d66838362000c7d565b806000190482111562000d7d5762000d7d62000e1d565b0290505b92915050565b600060ff821660ff84168082101562000da45762000da462000e1d565b90039392505050565b60005b8381101562000dca57818101518382015260200162000db0565b8381111562000dda576000848401525b50505050565b600181811c9082168062000df557607f821691505b6020821081141562000e1757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b60805160a05160c05160e05160801c6101005160801c6101205160801c6101405160e01c6101605160a01c6101805160601c6101a05160601c61387862001046600039600081816106e601528181610ecb01528181610fbf0152818161145a0152818161195b01528181612115015261269801526000818161049c01528181610ab701528181610cd7015281816112cb015281816118be01528181611c45015281816120db0152612b1a0152600081816104f80152818161161f01528181611670015281816116a301528181611e6701528181611eca01528181611f1a015281816123f401528181612445015281816124780152818161279301528181612c0801528181612c590152612c8c0152600081816103c401528181610b1501528181610d3501528181610f29015281816114b8015281816115af015281816116cf01528181611cae01528181611f5b0152818161216e01528181612386015281816124a40152818161272501528181612b980152612cb801526000818161053701528181611fec015261253b01526000818161063d015281816117660152612d4901526000818161074e0152818161173b01528181611fc1015281816125100152612d1e0152600081816106840152818161090301526110e0015260008181610939015261111501526000818161044e015261105701526138786000f3fe608060405234801561001057600080fd5b50600436106102d35760003560e01c80639ebdc9b411610186578063d3d00f24116100e3578063dd62ed3e11610097578063fdb0732d11610071578063fdb0732d14610783578063fe2846b114610796578063fff6cae9146107a957600080fd5b8063dd62ed3e14610710578063e86d60bf14610749578063fa2968791461077057600080fd5b8063d7020d0a116100c8578063d7020d0a146106ce578063dc3bfba9146106e1578063dd3633711461070857600080fd5b8063d3d00f24146106a6578063d505accf146106b957600080fd5b8063bc3d1c4e1161013a578063bdd8a3661161011f578063bdd8a36614610638578063c03edd221461065f578063cd0d00961461067f57600080fd5b8063bc3d1c4e14610612578063bcc1694f1461062557600080fd5b8063aea0f2011161016b578063aea0f201146105e3578063b0f28921146105ec578063b3f1c93d146105ff57600080fd5b80639ebdc9b4146105bd578063a9059cbb146105d057600080fd5b806330adf81f11610234578063683dd191116101e857806370a08231116101cd57806370a082311461056c5780637ecebe001461059557806395d89b41146105b557600080fd5b8063683dd191146104f35780636970a9241461053257600080fd5b80633644e515116102195780633644e5151461048f5780635001f3b51461049757806354fd4d50146104d657600080fd5b806330adf81f14610449578063313ce5671461047057600080fd5b80631eb728fc1161028b578063210a499111610270578063210a4991146103fb57806323b872dd1461042357806327bab0631461043657600080fd5b80631eb728fc14610391578063204f83f9146103bf57600080fd5b80630a0d8686116102bc5780630a0d86861461031957806313e7bc8c1461035457806318160ddd1461037f57600080fd5b806306fdde03146102d8578063095ea7b3146102f6575b600080fd5b6102e06107b1565b6040516102ed919061354a565b60405180910390f35b610309610304366004613313565b61083f565b60405190151581526020016102ed565b600754604080516001600160701b038084168252600160701b8404166020820152600160e01b90920463ffffffff16908201526060016102ed565b61036761036236600461343f565b610853565b6040516001600160801b0390911681526020016102ed565b6000545b6040519081526020016102ed565b6103a461039f3660046131d3565b610880565b604080519384526020840192909252908201526060016102ed565b6103e67f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff90911681526020016102ed565b61040e61040936600461333d565b6108a3565b604080519283526020830191909152016102ed565b610309610431366004613155565b6108c2565b61036761044436600461343f565b6108da565b6103837f000000000000000000000000000000000000000000000000000000000000000081565b60055461047d9060ff1681565b60405160ff90911681526020016102ed565b6103836108ff565b6104be7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102ed565b6040805180820190915260018152603160f81b60208201526102e0565b61051a7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160601b0390911681526020016102ed565b6105597f000000000000000000000000000000000000000000000000000000000000000081565b604051600f9190910b81526020016102ed565b61038361057a366004613107565b6001600160a01b031660009081526001602052604090205490565b6103836105a3366004613107565b60066020526000908152604090205481565b6102e061095b565b6103676105cb3660046132ca565b610968565b6103096105de366004613313565b610b95565b61038360085481565b6103676105fa36600461343f565b610ba2565b6103a461060d366004613191565b610bc7565b610367610620366004613293565b610bea565b610367610633366004613293565b610db6565b6105597f000000000000000000000000000000000000000000000000000000000000000081565b610667610f75565b6040516001600160701b0390911681526020016102ed565b6103837f000000000000000000000000000000000000000000000000000000000000000081565b6103676106b4366004613107565b610f7f565b6106cc6106c7366004613220565b610feb565b005b6103a46106dc366004613191565b611275565b6104be7f000000000000000000000000000000000000000000000000000000000000000081565b610667611288565b61038361071e366004613122565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6105597f000000000000000000000000000000000000000000000000000000000000000081565b61036761077e366004613107565b611292565b61036761079136600461343f565b6112f2565b6103676107a43660046132ca565b611317565b6106cc611504565b600380546107be9061371a565b80601f01602080910402602001604051908101604052809291908181526020018280546107ea9061371a565b80156108375780601f1061080c57610100808354040283529160200191610837565b820191906000526020600020905b81548152906001019060200180831161081a57829003601f168201915b505050505081565b600061084c338484611542565b9392505050565b6007546000906001600160701b0380821691600160701b9004166108788483836115ab565b949350505050565b60008060006108928888888888611871565b925092509250955095509592505050565b6000806108b585600060018787611d36565b5090969095509350505050565b60006108ce84836121ea565b50610878848484612293565b6007546000906001600160701b0380821691600160701b900416610878848383612382565b60007f0000000000000000000000000000000000000000000000000000000000000000461461093657610931466125be565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b600480546107be9061371a565b600080610973612672565b6007546001600160701b03918216925080821691600160701b90910416600061099d878484612721565b90506001600160801b0381166109bc6001600160701b03841686613696565b6001600160801b03161015610a185760405162461bcd60e51b815260206004820152601b60248201527f506f6f6c3a204e6f7420656e6f756768206679546f6b656e20696e000000000060448201526064015b60405180910390fd5b856001600160801b0316816001600160801b03161115610a7a5760405162461bcd60e51b815260206004820152601960248201527f506f6f6c3a20546f6f206d756368206679546f6b656e20696e000000000000006044820152606401610a0f565b610aaa610a90886001600160701b038616613696565b610aa3836001600160701b03861661357d565b85856127d7565b610ae76001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016896001600160801b038a16612974565b6001600160a01b038816337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000000000000610b466001600160801b038c16612a97565b610b58866001600160801b0316612a97565b610b6190613770565b6040805163ffffffff9094168452600f92830b6020850152910b9082015260600160405180910390a3979650505050505050565b600061084c338484612293565b6007546000906001600160701b0380821691600160701b900416610878848383612721565b6000806000610bda878760008888611871565b9250925092509450945094915050565b6007546000906001600160701b0380821691600160701b90041682610c0d612672565b90506000610c19612af6565b90506000610c27848461366e565b6001600160701b031690506000610c3f828787612382565b9050876001600160801b0316816001600160801b03161015610ca35760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c3a204e6f7420656e6f7567682062617365206f627461696e656400006044820152606401610a0f565b610cca610cb9826001600160701b038616613696565b856001600160701b031688886127d7565b610d076001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168a6001600160801b038416612974565b6001600160a01b038916337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000000000000610d666001600160801b038616612a97565b610d78876001600160801b0316612a97565b610d8190613770565b6040805163ffffffff9094168452600f92830b6020850152910b9082015260600160405180910390a398975050505050505050565b6007546000906001600160701b0380821691600160701b90041682610dd9612af6565b90506000610de5612672565b90506000610df3858461366e565b6001600160701b031690506000610e0b8287856115ab565b9050876001600160801b0316816001600160801b03161015610e955760405162461bcd60e51b815260206004820152602160248201527f506f6f6c3a204e6f7420656e6f756768206679546f6b656e206f627461696e6560448201527f64000000000000000000000000000000000000000000000000000000000000006064820152608401610a0f565b610ebe846001600160701b031682856001600160701b0316610eb79190613696565b88886127d7565b610efb6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168a6001600160801b038416612974565b6001600160a01b038916337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000000000000610f5a6001600160801b038716612a97565b610f6390613770565b610d81866001600160801b0316612a97565b6000610931612672565b600754600090600160701b90046001600160701b0316610f9d612672565b610fa7919061366e565b6001600160701b03169050610fe66001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383612974565b919050565b4284101561103b5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610a0f565b6001600160a01b038716600090815260066020526040812080547f0000000000000000000000000000000000000000000000000000000000000000918a918a918a91908661108883613755565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060007f000000000000000000000000000000000000000000000000000000000000000046146111135761110e466125be565b611135565b7f00000000000000000000000000000000000000000000000000000000000000005b6040517f1901000000000000000000000000000000000000000000000000000000000000602082015260228101919091526042810183905260620160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa1580156111db573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906112115750896001600160a01b0316816001600160a01b0316145b61125d5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610a0f565b6112688a8a8a611542565b5050505050505050505050565b6000806000610bda878760008888611d36565b6000610931612af6565b6007546000906001600160701b03166112a9612af6565b6112b3919061366e565b6001600160701b03169050610fe66001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383612974565b6007546000906001600160701b0380821691600160701b900416610878848383612b94565b600080611322612af6565b6007546001600160701b03918216925080821691600160701b90910416600061134c878484612b94565b90506001600160801b03811661136b6001600160701b03851686613696565b6001600160801b031610156113c25760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c3a204e6f7420656e6f756768206261736520746f6b656e20696e00006044820152606401610a0f565b856001600160801b0316816001600160801b031611156114245760405162461bcd60e51b815260206004820152601c60248201527f506f6f6c3a20546f6f206d756368206261736520746f6b656e20696e000000006044820152606401610a0f565b61144d61143a826001600160701b03861661357d565b610aa3896001600160701b038616613696565b61148a6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016896001600160801b038a16612974565b6001600160a01b038816337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f00000000000000000000000000000000000000000000000000000000000000006114e96001600160801b038616612a97565b6114f290613770565b610b618c6001600160801b0316612a97565b61154061150f612af6565b6001600160701b0316611520612672565b6007546001600160701b039182169181811691600160701b9004166127d7565b565b6001600160a01b03838116600081815260026020908152604080832094871680845294825280832086905551858152919392917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a35060019392505050565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff1642106116135760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b60006001600160601b037f00000000000000000000000000000000000000000000000000000000000000001673856ddd1a74b6e620d043efd6f74d81b8bf34868d634052893261166383886135fa565b6116966001600160601b037f000000000000000000000000000000000000000000000000000000000000000016886135fa565b6116c96001600160601b037f0000000000000000000000000000000000000000000000000000000000000000168b613629565b6116f3427f00000000000000000000000000000000000000000000000000000000000000006136cd565b6040516001600160e01b031960e087901b1681526001600160701b0394851660048201529390921660248401526001600160801b0316604483015263ffffffff1660648201527f0000000000000000000000000000000000000000000000000000000000000000600f90810b60848301527f0000000000000000000000000000000000000000000000000000000000000000900b60a482015260c40160206040518083038186803b1580156117a757600080fd5b505af41580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df919061345c565b6117e991906135c0565b90506117fe856001600160701b03861661357d565b6001600160801b031661181a826001600160701b038616613696565b6001600160801b031610156108785760405162461bcd60e51b815260206004820152601d60248201527f506f6f6c3a206679546f6b656e2062616c616e636520746f6f206c6f770000006044820152606401610a0f565b60008054600754829182916001600160701b0380821691600160701b9004168361189b84836136b6565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b15801561190057600080fd5b505afa158015611914573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119389190613479565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b15801561199d57600080fd5b505afa1580156119b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119d59190613479565b905060006119ec6001600160701b038716846136b6565b9050831580611a5057508b84611a136001600160701b038916670de0b6b3a764000061364f565b611a1d91906135e6565b10158015611a5057508a84611a436001600160701b038916670de0b6b3a764000061364f565b611a4d91906135e6565b11155b611a9c5760405162461bcd60e51b815260206004820152601c60248201527f506f6f6c3a20526573657276657320726174696f206368616e676564000000006044820152606401610a0f565b86611aac57809950899750611bd1565b83611ad9579850886001600160701b038616611ac8828961364f565b611ad291906135e6565b9750611bd1565b60008d15611b1257611b06611aed8f612deb565b886001600160701b0316886001600160701b0316612b94565b6001600160801b031690505b611b1c85846136b6565b9950611b288e866136b6565b8a8f611b3491906135a8565b611b3e908a61364f565b611b4891906135e6565b98508789611b5f836001600160701b038b166135a8565b611b69919061364f565b611b7391906135e6565b611b7d90826135a8565b9a508a821015611bcf5760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c3a204e6f7420656e6f756768206261736520746f6b656e20696e00006044820152606401610a0f565b505b611c10611bef611bea8c6001600160701b038a166135a8565b612deb565b610eb78a611c068d6001600160701b038b166135a8565b611bea91906135a8565b611c1a8f89612e34565b506000611c278b836136b6565b1115611c6c57611c6c8e611c3b8c846136b6565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190612974565b60006001600160a01b03168f6001600160a01b0316336001600160a01b03167f05e533e65fa7a345b42a006257cdd31febe912eacbbaaa92299c7a931895c5297f0000000000000000000000000000000000000000000000000000000000000000611cd68f612ece565b611cdf906137af565b611ce88f612ece565b611cf1906137af565b611cfa8f612ece565b6040805163ffffffff9095168552602085019390935291830152606082015260800160405180910390a450505050505050955095509592505050565b3060009081526001602052604081205481546007549192918291906001600160701b0380821691600160701b90041683611d7084836136b6565b9050801580611dd457508881611d976001600160701b038616670de0b6b3a764000061364f565b611da191906135e6565b10158015611dd457508781611dc76001600160701b038616670de0b6b3a764000061364f565b611dd191906135e6565b11155b611e205760405162461bcd60e51b815260206004820152601c60248201527f506f6f6c3a20526573657276657320726174696f206368616e676564000000006044820152606401610a0f565b83611e346001600160701b0385168961364f565b611e3e91906135e6565b955083611e4b828961364f565b611e5591906135e6565b94508915612089576001600160601b037f00000000000000000000000000000000000000000000000000000000000000001673856ddd1a74b6e620d043efd6f74d81b8bf34868d63e03824d682611eab8a612deb565b611ebe906001600160701b038916613696565b611ec89190613629565b7f00000000000000000000000000000000000000000000000000000000000000006001600160601b0316611efb8a612deb565b611f0e906001600160701b038916613696565b611f189190613629565b7f00000000000000000000000000000000000000000000000000000000000000006001600160601b0316611f4b8b612deb565b611f559190613629565b611f7f427f00000000000000000000000000000000000000000000000000000000000000006136cd565b60405160e086901b6001600160e01b03191681526001600160801b03948516600482015292841660248401529216604482015263ffffffff90911660648201527f0000000000000000000000000000000000000000000000000000000000000000600f90810b60848301527f0000000000000000000000000000000000000000000000000000000000000000900b60a482015260c40160206040518083038186803b15801561202d57600080fd5b505af4158015612041573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612065919061345c565b61206f91906135c0565b612082906001600160801b0316876135a8565b9550600094505b6120c36120a2611bea886001600160701b0387166136b6565b610aa3896120b9896001600160701b0388166136b6565b611bea91906136b6565b6120cd3088612f30565b506121026001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168d88612974565b841561213c5761213c6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168c87612974565b6001600160a01b03808c16908d16337f05e533e65fa7a345b42a006257cdd31febe912eacbbaaa92299c7a931895c5297f00000000000000000000000000000000000000000000000000000000000000006121968b612ece565b61219f8b612ece565b6121a88e612ece565b6121b1906137af565b6040805163ffffffff9095168552602085019390935291830152606082015260800160405180910390a450505050955095509592505050565b60006001600160a01b038316331461228a576001600160a01b0383166000908152600260209081526040808320338452909152902054600019811461228857828110156122795760405162461bcd60e51b815260206004820152601c60248201527f45524332303a20496e73756666696369656e7420617070726f76616c000000006044820152606401610a0f565b6122868433858403611542565b505b505b50600192915050565b6001600160a01b0383166000908152600160205260408120548211156122fb5760405162461bcd60e51b815260206004820152601b60248201527f45524332303a20496e73756666696369656e742062616c616e636500000000006044820152606401610a0f565b6001600160a01b03808516600090815260016020526040808220805486900390559185168152205461232e9083906135a8565b6001600160a01b0380851660008181526001602052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906115999086815260200190565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff1642106123ea5760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b6001600160601b037f00000000000000000000000000000000000000000000000000000000000000001673856ddd1a74b6e620d043efd6f74d81b8bf34868d63e03824d661243883876135fa565b61246b6001600160601b037f000000000000000000000000000000000000000000000000000000000000000016876135fa565b61249e6001600160601b037f0000000000000000000000000000000000000000000000000000000000000000168a613629565b6124c8427f00000000000000000000000000000000000000000000000000000000000000006136cd565b6040516001600160e01b031960e087901b1681526001600160701b0394851660048201529390921660248401526001600160801b0316604483015263ffffffff1660648201527f0000000000000000000000000000000000000000000000000000000000000000600f90810b60848301527f0000000000000000000000000000000000000000000000000000000000000000900b60a482015260c40160206040518083038186803b15801561257c57600080fd5b505af4158015612590573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b4919061345c565b61087891906135c0565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60036040516125f091906134ae565b60408051918290038220828201825260018352603160f81b602093840152815180840194909452838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606084015260808301949094523060a0808401919091528451808403909101815260c09092019093528051920191909120919050565b600080546040516370a0823160e01b815230600482015261093191906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b1580156126da57600080fd5b505afa1580156126ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127129190613479565b61271c91906135a8565b612ff0565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff1642106127895760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b6001600160601b037f00000000000000000000000000000000000000000000000000000000000000001673856ddd1a74b6e620d043efd6f74d81b8bf34868d639a7d157061243883876135fa565b60075442906000906127f690600160e01b900463ffffffff16836136cd565b905060008163ffffffff1611801561281657506001600160701b03841615155b801561282a57506001600160701b03831615155b1561288e5760006128506001600160701b0385166b033b2e3c9fd0803ce800000061364f565b90506001600160701b03851661286c63ffffffff84168361364f565b61287691906135e6565b6008600082825461288791906135a8565b9091555050505b6128a0866001600160801b0316613039565b600780546dffffffffffffffffffffffffffff19166001600160701b03929092169190911790556128d96001600160801b038616613039565b600780546001600160701b03908116600160701b93821684027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1617600160e01b63ffffffff8716021791829055600854604080518484168152949093049091166020840152908201527f17be3acebd510daa18778e1ee1fbaf88237b124dc0803c3be2fd4f99f3e69d339060600160405180910390a1505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916129fe9190613492565b6000604051808303816000865af19150503d8060008114612a3b576040519150601f19603f3d011682016040523d82523d6000602084013e612a40565b606091505b5091509150818015612a6a575080511580612a6a575080806020019051810190612a6a9190613370565b612a9057612a778161308b565b60405162461bcd60e51b8152600401610a0f919061354a565b5050505050565b60006f7fffffffffffffffffffffffffffffff6001600160801b0383161115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b5090565b6040516370a0823160e01b8152306004820152600090610931906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b158015612b5c57600080fd5b505afa158015612b70573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271c9190613479565b60007f000000000000000000000000000000000000000000000000000000000000000063ffffffff164210612bfc5760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b60006001600160601b037f00000000000000000000000000000000000000000000000000000000000000001673856ddd1a74b6e620d043efd6f74d81b8bf34868d635fd8dc08612c4c8388613629565b612c7f6001600160601b037f00000000000000000000000000000000000000000000000000000000000000001688613629565b612cb26001600160601b037f0000000000000000000000000000000000000000000000000000000000000000168b613629565b612cdc427f00000000000000000000000000000000000000000000000000000000000000006136cd565b60405160e086901b6001600160e01b03191681526001600160801b03948516600482015292841660248401529216604482015263ffffffff90911660648201527f0000000000000000000000000000000000000000000000000000000000000000600f90810b60848301527f0000000000000000000000000000000000000000000000000000000000000000900b60a482015260c40160206040518083038186803b158015612d8a57600080fd5b505af4158015612d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc2919061345c565b612dcc91906135c0565b9050612dd8818561357d565b6001600160801b031661181a8685613696565b60006001600160801b03821115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b6001600160a01b038216600090815260016020526040812054612e589083906135a8565b6001600160a01b03841660009081526001602052604081209190915554612e809083906135a8565b60009081556040518381526001600160a01b03851691907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a350600192915050565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b6001600160a01b038216600090815260016020526040812054821115612f985760405162461bcd60e51b815260206004820152601b60248201527f45524332303a20496e73756666696369656e742062616c616e636500000000006044820152606401610a0f565b6001600160a01b03831660008181526001602090815260408083208054879003905582548690038355518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101612ebd565b60006001600160701b03821115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b60006001600160701b036001600160801b0383161115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b60606044825110156130d057505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b600482019150818060200190518101906130ea9190613392565b92915050565b80356001600160a01b0381168114610fe657600080fd5b60006020828403121561311957600080fd5b61084c826130f0565b6000806040838503121561313557600080fd5b61313e836130f0565b915061314c602084016130f0565b90509250929050565b60008060006060848603121561316a57600080fd5b613173846130f0565b9250613181602085016130f0565b9150604084013590509250925092565b600080600080608085870312156131a757600080fd5b6131b0856130f0565b93506131be602086016130f0565b93969395505050506040820135916060013590565b600080600080600060a086880312156131eb57600080fd5b6131f4866130f0565b9450613202602087016130f0565b94979496505050506040830135926060810135926080909101359150565b600080600080600080600060e0888a03121561323b57600080fd5b613244886130f0565b9650613252602089016130f0565b95506040880135945060608801359350608088013560ff8116811461327657600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156132a657600080fd5b6132af836130f0565b915060208301356132bf8161382a565b809150509250929050565b6000806000606084860312156132df57600080fd5b6132e8846130f0565b925060208401356132f88161382a565b915060408401356133088161382a565b809150509250925092565b6000806040838503121561332657600080fd5b61332f836130f0565b946020939093013593505050565b60008060006060848603121561335257600080fd5b61335b846130f0565b95602085013595506040909401359392505050565b60006020828403121561338257600080fd5b8151801515811461084c57600080fd5b6000602082840312156133a457600080fd5b815167ffffffffffffffff808211156133bc57600080fd5b818401915084601f8301126133d057600080fd5b8151818111156133e2576133e2613814565b604051601f8201601f19908116603f0116810190838211818310171561340a5761340a613814565b8160405282815287602084870101111561342357600080fd5b6134348360208301602088016136ea565b979650505050505050565b60006020828403121561345157600080fd5b813561084c8161382a565b60006020828403121561346e57600080fd5b815161084c8161382a565b60006020828403121561348b57600080fd5b5051919050565b600082516134a48184602087016136ea565b9190910192915050565b600080835481600182811c9150808316806134ca57607f831692505b60208084108214156134ea57634e487b7160e01b86526022600452602486fd5b8180156134fe576001811461350f5761353c565b60ff1986168952848901965061353c565b60008a81526020902060005b868110156135345781548b82015290850190830161351b565b505084890196505b509498975050505050505050565b60208152600082518060208401526135698160408501602087016136ea565b601f01601f19169190910160400192915050565b60006001600160801b0380831681851680830382111561359f5761359f6137e8565b01949350505050565b600082198211156135bb576135bb6137e8565b500190565b60006001600160801b03808416806135da576135da6137fe565b92169190910492915050565b6000826135f5576135f56137fe565b500490565b60006001600160701b0380831681851681830481118215151615613620576136206137e8565b02949350505050565b60006001600160801b0380831681851681830481118215151615613620576136206137e8565b6000816000190483118215151615613669576136696137e8565b500290565b60006001600160701b038381169083168181101561368e5761368e6137e8565b039392505050565b60006001600160801b038381169083168181101561368e5761368e6137e8565b6000828210156136c8576136c86137e8565b500390565b600063ffffffff8381169083168181101561368e5761368e6137e8565b60005b838110156137055781810151838201526020016136ed565b83811115613714576000848401525b50505050565b600181811c9082168061372e57607f821691505b6020821081141561374f57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613769576137696137e8565b5060010190565b600081600f0b7fffffffffffffffffffffffffffffffff800000000000000000000000000000008114156137a6576137a66137e8565b60000392915050565b60007f80000000000000000000000000000000000000000000000000000000000000008214156137e1576137e16137e8565b5060000390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160801b038116811461383f57600080fd5b5056fea2646970667358221220db8559cc882d991a9fcf8e6fe8e43d025021b32aa7685dfeef5a68d7f872764064736f6c63430008060033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102d35760003560e01c80639ebdc9b411610186578063d3d00f24116100e3578063dd62ed3e11610097578063fdb0732d11610071578063fdb0732d14610783578063fe2846b114610796578063fff6cae9146107a957600080fd5b8063dd62ed3e14610710578063e86d60bf14610749578063fa2968791461077057600080fd5b8063d7020d0a116100c8578063d7020d0a146106ce578063dc3bfba9146106e1578063dd3633711461070857600080fd5b8063d3d00f24146106a6578063d505accf146106b957600080fd5b8063bc3d1c4e1161013a578063bdd8a3661161011f578063bdd8a36614610638578063c03edd221461065f578063cd0d00961461067f57600080fd5b8063bc3d1c4e14610612578063bcc1694f1461062557600080fd5b8063aea0f2011161016b578063aea0f201146105e3578063b0f28921146105ec578063b3f1c93d146105ff57600080fd5b80639ebdc9b4146105bd578063a9059cbb146105d057600080fd5b806330adf81f11610234578063683dd191116101e857806370a08231116101cd57806370a082311461056c5780637ecebe001461059557806395d89b41146105b557600080fd5b8063683dd191146104f35780636970a9241461053257600080fd5b80633644e515116102195780633644e5151461048f5780635001f3b51461049757806354fd4d50146104d657600080fd5b806330adf81f14610449578063313ce5671461047057600080fd5b80631eb728fc1161028b578063210a499111610270578063210a4991146103fb57806323b872dd1461042357806327bab0631461043657600080fd5b80631eb728fc14610391578063204f83f9146103bf57600080fd5b80630a0d8686116102bc5780630a0d86861461031957806313e7bc8c1461035457806318160ddd1461037f57600080fd5b806306fdde03146102d8578063095ea7b3146102f6575b600080fd5b6102e06107b1565b6040516102ed919061354a565b60405180910390f35b610309610304366004613313565b61083f565b60405190151581526020016102ed565b600754604080516001600160701b038084168252600160701b8404166020820152600160e01b90920463ffffffff16908201526060016102ed565b61036761036236600461343f565b610853565b6040516001600160801b0390911681526020016102ed565b6000545b6040519081526020016102ed565b6103a461039f3660046131d3565b610880565b604080519384526020840192909252908201526060016102ed565b6103e67f0000000000000000000000000000000000000000000000000000000061ce723081565b60405163ffffffff90911681526020016102ed565b61040e61040936600461333d565b6108a3565b604080519283526020830191909152016102ed565b610309610431366004613155565b6108c2565b61036761044436600461343f565b6108da565b6103837f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60055461047d9060ff1681565b60405160ff90911681526020016102ed565b6103836108ff565b6104be7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6040516001600160a01b0390911681526020016102ed565b6040805180820190915260018152603160f81b60208201526102e0565b61051a7f000000000000000000000000000000000000000000000000000000e8d4a5100081565b6040516001600160601b0390911681526020016102ed565b6105597f0000000000000000000000000000000000000000000000010d79435e50d7943581565b604051600f9190910b81526020016102ed565b61038361057a366004613107565b6001600160a01b031660009081526001602052604090205490565b6103836105a3366004613107565b60066020526000908152604090205481565b6102e061095b565b6103676105cb3660046132ca565b610968565b6103096105de366004613313565b610b95565b61038360085481565b6103676105fa36600461343f565b610ba2565b6103a461060d366004613191565b610bc7565b610367610620366004613293565b610bea565b610367610633366004613293565b610db6565b6105597f000000000000000000000000000000000000000000000000f33333333333333381565b610667610f75565b6040516001600160701b0390911681526020016102ed565b6103837f000000000000000000000000000000000000000000000000000000000000000181565b6103676106b4366004613107565b610f7f565b6106cc6106c7366004613220565b610feb565b005b6103a46106dc366004613191565b611275565b6104be7f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa53381565b610667611288565b61038361071e366004613122565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6105597f0000000000000000000000000000000000000000000000000000000d9c2460c181565b61036761077e366004613107565b611292565b61036761079136600461343f565b6112f2565b6103676107a43660046132ca565b611317565b6106cc611504565b600380546107be9061371a565b80601f01602080910402602001604051908101604052809291908181526020018280546107ea9061371a565b80156108375780601f1061080c57610100808354040283529160200191610837565b820191906000526020600020905b81548152906001019060200180831161081a57829003601f168201915b505050505081565b600061084c338484611542565b9392505050565b6007546000906001600160701b0380821691600160701b9004166108788483836115ab565b949350505050565b60008060006108928888888888611871565b925092509250955095509592505050565b6000806108b585600060018787611d36565b5090969095509350505050565b60006108ce84836121ea565b50610878848484612293565b6007546000906001600160701b0380821691600160701b900416610878848383612382565b60007f0000000000000000000000000000000000000000000000000000000000000001461461093657610931466125be565b905090565b507fd00bec0332b0e3d410c497a7ff3fc6db44be815893bc59e9028c9c7819a125ce90565b600480546107be9061371a565b600080610973612672565b6007546001600160701b03918216925080821691600160701b90910416600061099d878484612721565b90506001600160801b0381166109bc6001600160701b03841686613696565b6001600160801b03161015610a185760405162461bcd60e51b815260206004820152601b60248201527f506f6f6c3a204e6f7420656e6f756768206679546f6b656e20696e000000000060448201526064015b60405180910390fd5b856001600160801b0316816001600160801b03161115610a7a5760405162461bcd60e51b815260206004820152601960248201527f506f6f6c3a20546f6f206d756368206679546f6b656e20696e000000000000006044820152606401610a0f565b610aaa610a90886001600160701b038616613696565b610aa3836001600160701b03861661357d565b85856127d7565b610ae76001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816896001600160801b038a16612974565b6001600160a01b038816337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000061ce7230610b466001600160801b038c16612a97565b610b58866001600160801b0316612a97565b610b6190613770565b6040805163ffffffff9094168452600f92830b6020850152910b9082015260600160405180910390a3979650505050505050565b600061084c338484612293565b6007546000906001600160701b0380821691600160701b900416610878848383612721565b6000806000610bda878760008888611871565b9250925092509450945094915050565b6007546000906001600160701b0380821691600160701b90041682610c0d612672565b90506000610c19612af6565b90506000610c27848461366e565b6001600160701b031690506000610c3f828787612382565b9050876001600160801b0316816001600160801b03161015610ca35760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c3a204e6f7420656e6f7567682062617365206f627461696e656400006044820152606401610a0f565b610cca610cb9826001600160701b038616613696565b856001600160701b031688886127d7565b610d076001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168a6001600160801b038416612974565b6001600160a01b038916337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000061ce7230610d666001600160801b038616612a97565b610d78876001600160801b0316612a97565b610d8190613770565b6040805163ffffffff9094168452600f92830b6020850152910b9082015260600160405180910390a398975050505050505050565b6007546000906001600160701b0380821691600160701b90041682610dd9612af6565b90506000610de5612672565b90506000610df3858461366e565b6001600160701b031690506000610e0b8287856115ab565b9050876001600160801b0316816001600160801b03161015610e955760405162461bcd60e51b815260206004820152602160248201527f506f6f6c3a204e6f7420656e6f756768206679546f6b656e206f627461696e6560448201527f64000000000000000000000000000000000000000000000000000000000000006064820152608401610a0f565b610ebe846001600160701b031682856001600160701b0316610eb79190613696565b88886127d7565b610efb6001600160a01b037f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa533168a6001600160801b038416612974565b6001600160a01b038916337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000061ce7230610f5a6001600160801b038716612a97565b610f6390613770565b610d81866001600160801b0316612a97565b6000610931612672565b600754600090600160701b90046001600160701b0316610f9d612672565b610fa7919061366e565b6001600160701b03169050610fe66001600160a01b037f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa533168383612974565b919050565b4284101561103b5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610a0f565b6001600160a01b038716600090815260066020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a91908661108883613755565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e00160405160208183030381529060405280519060200120905060007f000000000000000000000000000000000000000000000000000000000000000146146111135761110e466125be565b611135565b7fd00bec0332b0e3d410c497a7ff3fc6db44be815893bc59e9028c9c7819a125ce5b6040517f1901000000000000000000000000000000000000000000000000000000000000602082015260228101919091526042810183905260620160408051601f198184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa1580156111db573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906112115750896001600160a01b0316816001600160a01b0316145b61125d5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610a0f565b6112688a8a8a611542565b5050505050505050505050565b6000806000610bda878760008888611d36565b6000610931612af6565b6007546000906001600160701b03166112a9612af6565b6112b3919061366e565b6001600160701b03169050610fe66001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168383612974565b6007546000906001600160701b0380821691600160701b900416610878848383612b94565b600080611322612af6565b6007546001600160701b03918216925080821691600160701b90910416600061134c878484612b94565b90506001600160801b03811661136b6001600160701b03851686613696565b6001600160801b031610156113c25760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c3a204e6f7420656e6f756768206261736520746f6b656e20696e00006044820152606401610a0f565b856001600160801b0316816001600160801b031611156114245760405162461bcd60e51b815260206004820152601c60248201527f506f6f6c3a20546f6f206d756368206261736520746f6b656e20696e000000006044820152606401610a0f565b61144d61143a826001600160701b03861661357d565b610aa3896001600160701b038616613696565b61148a6001600160a01b037f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa53316896001600160801b038a16612974565b6001600160a01b038816337fb8aaa3347fac66c4197e2ddb56d1b1e06fa6f7ae158c01cb2e7f9f9efb4975bb7f0000000000000000000000000000000000000000000000000000000061ce72306114e96001600160801b038616612a97565b6114f290613770565b610b618c6001600160801b0316612a97565b61154061150f612af6565b6001600160701b0316611520612672565b6007546001600160701b039182169181811691600160701b9004166127d7565b565b6001600160a01b03838116600081815260026020908152604080832094871680845294825280832086905551858152919392917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a35060019392505050565b60007f0000000000000000000000000000000000000000000000000000000061ce723063ffffffff1642106116135760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b60006001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a510001673856ddd1a74b6e620d043efd6f74d81b8bf34868d634052893261166383886135fa565b6116966001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a5100016886135fa565b6116c96001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a51000168b613629565b6116f3427f0000000000000000000000000000000000000000000000000000000061ce72306136cd565b6040516001600160e01b031960e087901b1681526001600160701b0394851660048201529390921660248401526001600160801b0316604483015263ffffffff1660648201527f0000000000000000000000000000000000000000000000000000000d9c2460c1600f90810b60848301527f000000000000000000000000000000000000000000000000f333333333333333900b60a482015260c40160206040518083038186803b1580156117a757600080fd5b505af41580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df919061345c565b6117e991906135c0565b90506117fe856001600160701b03861661357d565b6001600160801b031661181a826001600160701b038616613696565b6001600160801b031610156108785760405162461bcd60e51b815260206004820152601d60248201527f506f6f6c3a206679546f6b656e2062616c616e636520746f6f206c6f770000006044820152606401610a0f565b60008054600754829182916001600160701b0380821691600160701b9004168361189b84836136b6565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a082319060240160206040518083038186803b15801561190057600080fd5b505afa158015611914573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119389190613479565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa53316906370a082319060240160206040518083038186803b15801561199d57600080fd5b505afa1580156119b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119d59190613479565b905060006119ec6001600160701b038716846136b6565b9050831580611a5057508b84611a136001600160701b038916670de0b6b3a764000061364f565b611a1d91906135e6565b10158015611a5057508a84611a436001600160701b038916670de0b6b3a764000061364f565b611a4d91906135e6565b11155b611a9c5760405162461bcd60e51b815260206004820152601c60248201527f506f6f6c3a20526573657276657320726174696f206368616e676564000000006044820152606401610a0f565b86611aac57809950899750611bd1565b83611ad9579850886001600160701b038616611ac8828961364f565b611ad291906135e6565b9750611bd1565b60008d15611b1257611b06611aed8f612deb565b886001600160701b0316886001600160701b0316612b94565b6001600160801b031690505b611b1c85846136b6565b9950611b288e866136b6565b8a8f611b3491906135a8565b611b3e908a61364f565b611b4891906135e6565b98508789611b5f836001600160701b038b166135a8565b611b69919061364f565b611b7391906135e6565b611b7d90826135a8565b9a508a821015611bcf5760405162461bcd60e51b815260206004820152601e60248201527f506f6f6c3a204e6f7420656e6f756768206261736520746f6b656e20696e00006044820152606401610a0f565b505b611c10611bef611bea8c6001600160701b038a166135a8565b612deb565b610eb78a611c068d6001600160701b038b166135a8565b611bea91906135a8565b611c1a8f89612e34565b506000611c278b836136b6565b1115611c6c57611c6c8e611c3b8c846136b6565b6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48169190612974565b60006001600160a01b03168f6001600160a01b0316336001600160a01b03167f05e533e65fa7a345b42a006257cdd31febe912eacbbaaa92299c7a931895c5297f0000000000000000000000000000000000000000000000000000000061ce7230611cd68f612ece565b611cdf906137af565b611ce88f612ece565b611cf1906137af565b611cfa8f612ece565b6040805163ffffffff9095168552602085019390935291830152606082015260800160405180910390a450505050505050955095509592505050565b3060009081526001602052604081205481546007549192918291906001600160701b0380821691600160701b90041683611d7084836136b6565b9050801580611dd457508881611d976001600160701b038616670de0b6b3a764000061364f565b611da191906135e6565b10158015611dd457508781611dc76001600160701b038616670de0b6b3a764000061364f565b611dd191906135e6565b11155b611e205760405162461bcd60e51b815260206004820152601c60248201527f506f6f6c3a20526573657276657320726174696f206368616e676564000000006044820152606401610a0f565b83611e346001600160701b0385168961364f565b611e3e91906135e6565b955083611e4b828961364f565b611e5591906135e6565b94508915612089576001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a510001673856ddd1a74b6e620d043efd6f74d81b8bf34868d63e03824d682611eab8a612deb565b611ebe906001600160701b038916613696565b611ec89190613629565b7f000000000000000000000000000000000000000000000000000000e8d4a510006001600160601b0316611efb8a612deb565b611f0e906001600160701b038916613696565b611f189190613629565b7f000000000000000000000000000000000000000000000000000000e8d4a510006001600160601b0316611f4b8b612deb565b611f559190613629565b611f7f427f0000000000000000000000000000000000000000000000000000000061ce72306136cd565b60405160e086901b6001600160e01b03191681526001600160801b03948516600482015292841660248401529216604482015263ffffffff90911660648201527f0000000000000000000000000000000000000000000000000000000d9c2460c1600f90810b60848301527f0000000000000000000000000000000000000000000000010d79435e50d79435900b60a482015260c40160206040518083038186803b15801561202d57600080fd5b505af4158015612041573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612065919061345c565b61206f91906135c0565b612082906001600160801b0316876135a8565b9550600094505b6120c36120a2611bea886001600160701b0387166136b6565b610aa3896120b9896001600160701b0388166136b6565b611bea91906136b6565b6120cd3088612f30565b506121026001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48168d88612974565b841561213c5761213c6001600160a01b037f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa533168c87612974565b6001600160a01b03808c16908d16337f05e533e65fa7a345b42a006257cdd31febe912eacbbaaa92299c7a931895c5297f0000000000000000000000000000000000000000000000000000000061ce72306121968b612ece565b61219f8b612ece565b6121a88e612ece565b6121b1906137af565b6040805163ffffffff9095168552602085019390935291830152606082015260800160405180910390a450505050955095509592505050565b60006001600160a01b038316331461228a576001600160a01b0383166000908152600260209081526040808320338452909152902054600019811461228857828110156122795760405162461bcd60e51b815260206004820152601c60248201527f45524332303a20496e73756666696369656e7420617070726f76616c000000006044820152606401610a0f565b6122868433858403611542565b505b505b50600192915050565b6001600160a01b0383166000908152600160205260408120548211156122fb5760405162461bcd60e51b815260206004820152601b60248201527f45524332303a20496e73756666696369656e742062616c616e636500000000006044820152606401610a0f565b6001600160a01b03808516600090815260016020526040808220805486900390559185168152205461232e9083906135a8565b6001600160a01b0380851660008181526001602052604090819020939093559151908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906115999086815260200190565b60007f0000000000000000000000000000000000000000000000000000000061ce723063ffffffff1642106123ea5760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b6001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a510001673856ddd1a74b6e620d043efd6f74d81b8bf34868d63e03824d661243883876135fa565b61246b6001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a5100016876135fa565b61249e6001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a51000168a613629565b6124c8427f0000000000000000000000000000000000000000000000000000000061ce72306136cd565b6040516001600160e01b031960e087901b1681526001600160701b0394851660048201529390921660248401526001600160801b0316604483015263ffffffff1660648201527f0000000000000000000000000000000000000000000000000000000d9c2460c1600f90810b60848301527f0000000000000000000000000000000000000000000000010d79435e50d79435900b60a482015260c40160206040518083038186803b15801561257c57600080fd5b505af4158015612590573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b4919061345c565b61087891906135c0565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60036040516125f091906134ae565b60408051918290038220828201825260018352603160f81b602093840152815180840194909452838201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606084015260808301949094523060a0808401919091528451808403909101815260c09092019093528051920191909120919050565b600080546040516370a0823160e01b815230600482015261093191906001600160a01b037f00000000000000000000000030fadeeaab2d7a23cb1c35c05e2f8145001fa53316906370a082319060240160206040518083038186803b1580156126da57600080fd5b505afa1580156126ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127129190613479565b61271c91906135a8565b612ff0565b60007f0000000000000000000000000000000000000000000000000000000061ce723063ffffffff1642106127895760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b6001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a510001673856ddd1a74b6e620d043efd6f74d81b8bf34868d639a7d157061243883876135fa565b60075442906000906127f690600160e01b900463ffffffff16836136cd565b905060008163ffffffff1611801561281657506001600160701b03841615155b801561282a57506001600160701b03831615155b1561288e5760006128506001600160701b0385166b033b2e3c9fd0803ce800000061364f565b90506001600160701b03851661286c63ffffffff84168361364f565b61287691906135e6565b6008600082825461288791906135a8565b9091555050505b6128a0866001600160801b0316613039565b600780546dffffffffffffffffffffffffffff19166001600160701b03929092169190911790556128d96001600160801b038616613039565b600780546001600160701b03908116600160701b93821684027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1617600160e01b63ffffffff8716021791829055600854604080518484168152949093049091166020840152908201527f17be3acebd510daa18778e1ee1fbaf88237b124dc0803c3be2fd4f99f3e69d339060600160405180910390a1505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916129fe9190613492565b6000604051808303816000865af19150503d8060008114612a3b576040519150601f19603f3d011682016040523d82523d6000602084013e612a40565b606091505b5091509150818015612a6a575080511580612a6a575080806020019051810190612a6a9190613370565b612a9057612a778161308b565b60405162461bcd60e51b8152600401610a0f919061354a565b5050505050565b60006f7fffffffffffffffffffffffffffffff6001600160801b0383161115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b5090565b6040516370a0823160e01b8152306004820152600090610931906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a082319060240160206040518083038186803b158015612b5c57600080fd5b505afa158015612b70573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271c9190613479565b60007f0000000000000000000000000000000000000000000000000000000061ce723063ffffffff164210612bfc5760405162461bcd60e51b815260206004820152600e60248201526d506f6f6c3a20546f6f206c61746560901b6044820152606401610a0f565b60006001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a510001673856ddd1a74b6e620d043efd6f74d81b8bf34868d635fd8dc08612c4c8388613629565b612c7f6001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a510001688613629565b612cb26001600160601b037f000000000000000000000000000000000000000000000000000000e8d4a51000168b613629565b612cdc427f0000000000000000000000000000000000000000000000000000000061ce72306136cd565b60405160e086901b6001600160e01b03191681526001600160801b03948516600482015292841660248401529216604482015263ffffffff90911660648201527f0000000000000000000000000000000000000000000000000000000d9c2460c1600f90810b60848301527f000000000000000000000000000000000000000000000000f333333333333333900b60a482015260c40160206040518083038186803b158015612d8a57600080fd5b505af4158015612d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc2919061345c565b612dcc91906135c0565b9050612dd8818561357d565b6001600160801b031661181a8685613696565b60006001600160801b03821115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b6001600160a01b038216600090815260016020526040812054612e589083906135a8565b6001600160a01b03841660009081526001602052604081209190915554612e809083906135a8565b60009081556040518381526001600160a01b03851691907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a350600192915050565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b6001600160a01b038216600090815260016020526040812054821115612f985760405162461bcd60e51b815260206004820152601b60248201527f45524332303a20496e73756666696369656e742062616c616e636500000000006044820152606401610a0f565b6001600160a01b03831660008181526001602090815260408083208054879003905582548690038355518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101612ebd565b60006001600160701b03821115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b60006001600160701b036001600160801b0383161115612af25760405162461bcd60e51b815260206004820152600d60248201526c43617374206f766572666c6f7760981b6044820152606401610a0f565b60606044825110156130d057505060408051808201909152601d81527f5472616e73616374696f6e2072657665727465642073696c656e746c79000000602082015290565b600482019150818060200190518101906130ea9190613392565b92915050565b80356001600160a01b0381168114610fe657600080fd5b60006020828403121561311957600080fd5b61084c826130f0565b6000806040838503121561313557600080fd5b61313e836130f0565b915061314c602084016130f0565b90509250929050565b60008060006060848603121561316a57600080fd5b613173846130f0565b9250613181602085016130f0565b9150604084013590509250925092565b600080600080608085870312156131a757600080fd5b6131b0856130f0565b93506131be602086016130f0565b93969395505050506040820135916060013590565b600080600080600060a086880312156131eb57600080fd5b6131f4866130f0565b9450613202602087016130f0565b94979496505050506040830135926060810135926080909101359150565b600080600080600080600060e0888a03121561323b57600080fd5b613244886130f0565b9650613252602089016130f0565b95506040880135945060608801359350608088013560ff8116811461327657600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156132a657600080fd5b6132af836130f0565b915060208301356132bf8161382a565b809150509250929050565b6000806000606084860312156132df57600080fd5b6132e8846130f0565b925060208401356132f88161382a565b915060408401356133088161382a565b809150509250925092565b6000806040838503121561332657600080fd5b61332f836130f0565b946020939093013593505050565b60008060006060848603121561335257600080fd5b61335b846130f0565b95602085013595506040909401359392505050565b60006020828403121561338257600080fd5b8151801515811461084c57600080fd5b6000602082840312156133a457600080fd5b815167ffffffffffffffff808211156133bc57600080fd5b818401915084601f8301126133d057600080fd5b8151818111156133e2576133e2613814565b604051601f8201601f19908116603f0116810190838211818310171561340a5761340a613814565b8160405282815287602084870101111561342357600080fd5b6134348360208301602088016136ea565b979650505050505050565b60006020828403121561345157600080fd5b813561084c8161382a565b60006020828403121561346e57600080fd5b815161084c8161382a565b60006020828403121561348b57600080fd5b5051919050565b600082516134a48184602087016136ea565b9190910192915050565b600080835481600182811c9150808316806134ca57607f831692505b60208084108214156134ea57634e487b7160e01b86526022600452602486fd5b8180156134fe576001811461350f5761353c565b60ff1986168952848901965061353c565b60008a81526020902060005b868110156135345781548b82015290850190830161351b565b505084890196505b509498975050505050505050565b60208152600082518060208401526135698160408501602087016136ea565b601f01601f19169190910160400192915050565b60006001600160801b0380831681851680830382111561359f5761359f6137e8565b01949350505050565b600082198211156135bb576135bb6137e8565b500190565b60006001600160801b03808416806135da576135da6137fe565b92169190910492915050565b6000826135f5576135f56137fe565b500490565b60006001600160701b0380831681851681830481118215151615613620576136206137e8565b02949350505050565b60006001600160801b0380831681851681830481118215151615613620576136206137e8565b6000816000190483118215151615613669576136696137e8565b500290565b60006001600160701b038381169083168181101561368e5761368e6137e8565b039392505050565b60006001600160801b038381169083168181101561368e5761368e6137e8565b6000828210156136c8576136c86137e8565b500390565b600063ffffffff8381169083168181101561368e5761368e6137e8565b60005b838110156137055781810151838201526020016136ed565b83811115613714576000848401525b50505050565b600181811c9082168061372e57607f821691505b6020821081141561374f57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613769576137696137e8565b5060010190565b600081600f0b7fffffffffffffffffffffffffffffffff800000000000000000000000000000008114156137a6576137a66137e8565b60000392915050565b60007f80000000000000000000000000000000000000000000000000000000000000008214156137e1576137e16137e8565b5060000390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160801b038116811461383f57600080fd5b5056fea2646970667358221220db8559cc882d991a9fcf8e6fe8e43d025021b32aa7685dfeef5a68d7f872764064736f6c63430008060033
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.