Source Code
Overview
S Balance
0 S
More Info
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
5218428 | 5 days ago | 0 S |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xB61E0D2C...8A39E984e The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
PairFactory
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 100 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import {IPairFactory} from "../interfaces/IPairFactory.sol"; import {IPair} from "./../interfaces/IPair.sol"; import {Pair} from "./../Pair.sol"; contract PairFactory is IPairFactory { /// @inheritdoc IPairFactory address public immutable voter; /// @inheritdoc IPairFactory address public treasury; address public accessHub; address public immutable feeRecipientFactory; uint256 public fee; /// @dev max swap fee set to 10% uint256 public constant MAX_FEE = 100_000; uint256 public feeSplit; mapping(address token0 => mapping(address token1 => mapping(bool stable => address pair))) public getPair; address[] public allPairs; /// @dev simplified check if its a pair, given that `stable` flag might not be available in peripherals mapping(address pair => bool isPair) public isPair; /// @dev pair => fee mapping(address pair => uint256 fee) public _pairFee; /// @dev whether the pair has skim enabled or not mapping(address pair => bool skimEnabled) public skimEnabled; /// @dev if enabled, fee split to treasury if no gauge bool public feeSplitWhenNoGauge; /// @inheritdoc IPairFactory bytes32 public immutable pairCodeHash; constructor( address _voter, address _treasury, address _accessHub, address _feeRecipientFactory ) { /// @dev default of 0.30% fee = 3000; voter = _voter; treasury = _treasury; accessHub = _accessHub; feeRecipientFactory = _feeRecipientFactory; pairCodeHash = keccak256(type(Pair).creationCode); } modifier onlyGovernanceOrVoter() { require(msg.sender == accessHub || msg.sender == voter); _; } modifier onlyGovernance() { require(msg.sender == accessHub, NOT_AUTHORIZED()); _; } /// @inheritdoc IPairFactory function allPairsLength() external view returns (uint256) { return allPairs.length; } /// @inheritdoc IPairFactory /** @dev for GLOBAL */ function setFee(uint256 _fee) external onlyGovernanceOrVoter { /// @dev ensure it's not zero require(_fee != 0, ZERO_FEE()); /// @dev ensure less than or equal to MAX_FEE require(_fee <= MAX_FEE, FEE_TOO_HIGH()); /// @dev set the global fee fee = _fee; emit SetFee(_fee); } /// @inheritdoc IPairFactory /** @dev for INDIVIDUAL PAIRS */ function setPairFee( address _pair, uint256 _fee ) external onlyGovernanceOrVoter { /// @dev ensure less than or equal to MAX_FEE require(_fee <= MAX_FEE, FEE_TOO_HIGH()); /// @dev if _fee is set to 0, fallback to default fee for the pair uint256 __fee = (_fee == 0 ? fee : _fee); /// @dev set to the new fee IPair(_pair).setFee(__fee); /// @dev store the fee _pairFee[_pair] = __fee; emit SetPairFee(_pair, _fee); } /// @inheritdoc IPairFactory function pairFee(address _pair) public view returns (uint256 feeForPair) { return _pairFee[_pair]; } /// @inheritdoc IPairFactory function setTreasury(address _treasury) external onlyGovernance { treasury = _treasury; emit NewTreasury(msg.sender, _treasury); } /// @inheritdoc IPairFactory /// @notice allow feeSplit directly to treasury if (gauge) does not exist function setFeeSplitWhenNoGauge(bool status) external onlyGovernance { feeSplitWhenNoGauge = status; emit FeeSplitWhenNoGauge(msg.sender, status); } /// @inheritdoc IPairFactory /// @notice set the percent of fee growth to mint in BP e.g. (9500 to mint 95% of fees) /// @dev gated to voter or AccessHub function setFeeSplit(uint256 _feeSplit) external onlyGovernanceOrVoter { /// @dev ensure feeSplit is within bounds require(_feeSplit <= 10_000, INVALID_FEE_SPLIT()); /// @dev update the global feeSplit for newly created pairs feeSplit = _feeSplit; emit SetFeeSplit(_feeSplit); } /// @inheritdoc IPairFactory function setPairFeeSplit( address _pair, uint256 _feeSplit ) external onlyGovernanceOrVoter { /// @dev ensure feeSplit is within bounds require(_feeSplit <= 10_000, INVALID_FEE_SPLIT()); /// @dev set the feeSplit for the specific pair IPair(_pair).setFeeSplit(_feeSplit); emit SetPairFeeSplit(_pair, _feeSplit); } /// @inheritdoc IPairFactory function createPair( address tokenA, address tokenB, bool stable ) external returns (address pair) { /// @dev ensure that tokenA and tokenB are not the same require(tokenA != tokenB, IA()); /// @dev calculate token0 and token1 of the pair by sorting the addresses (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); /// @dev require token is not the 0 address /// @dev we only check token0 because address(0) would be sorted first require(token0 != address(0), ZA()); /// @dev ensure the pairing does not already exist require(getPair[token0][token1][stable] == address(0), PE()); /// @dev pair creation logic bytes32 salt = keccak256(abi.encodePacked(token0, token1, stable)); pair = address(new Pair{salt: salt}()); /// @dev initialize the pair upon creation IPair(pair).initialize(token0, token1, stable); /// @dev should almost always always default to the global fee IPair(pair).setFee(pairFee(pair)); /// @dev if we want an active fee split for gaugeless pairs if (feeSplitWhenNoGauge) { /// @dev set the fee recipient as the treasury IPair(pair).setFeeRecipient(treasury); /// @dev set the global fee split to the pair IPair(pair).setFeeSplit(feeSplit); } /// @dev populate mapping getPair[token0][token1][stable] = pair; /// @dev populate mapping in the reverse direction getPair[token1][token0][stable] = pair; /// @dev push to the allPairs set allPairs.push(pair); /// @dev set the pair status as true isPair[pair] = true; emit PairCreated(token0, token1, pair, allPairs.length); } /// @inheritdoc IPairFactory /// @dev gated to voter or AccessHub function setFeeRecipient(address _pair, address _feeRecipient) external { /// @dev only voter can call upon creation require(msg.sender == voter, NOT_AUTHORIZED()); /// @dev set the fee receiving contract for a pair IPair(_pair).setFeeRecipient(_feeRecipient); emit SetFeeRecipient(_pair, _feeRecipient); } /// @inheritdoc IPairFactory /// @dev function restrict or enable skim functionality on legacy pairs function setSkimEnabled( address _pair, bool _status ) external onlyGovernance { skimEnabled[_pair] = skimEnabled[_pair] != _status ? _status : skimEnabled[_pair]; emit SkimStatus(_pair, _status); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; interface IPairFactory { error FEE_TOO_HIGH(); error ZERO_FEE(); /// @dev invalid assortment error IA(); /// @dev zero address error ZA(); /// @dev pair exists error PE(); error NOT_AUTHORIZED(); error INVALID_FEE_SPLIT(); event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); event SetFee(uint256 indexed fee); event SetPairFee(address indexed pair, uint256 indexed fee); event SetFeeSplit(uint256 indexed _feeSplit); event SetPairFeeSplit(address indexed pair, uint256 indexed _feeSplit); event SkimStatus(address indexed _pair, bool indexed _status); event NewTreasury(address indexed _caller, address indexed _newTreasury); event FeeSplitWhenNoGauge(address indexed _caller, bool indexed _status); event SetFeeRecipient(address indexed pair, address indexed feeRecipient); /// @notice returns the total length of legacy pairs /// @return _length the length function allPairsLength() external view returns (uint256 _length); /// @notice calculates if the address is a legacy pair /// @param pair the address to check /// @return _boolean the bool return function isPair(address pair) external view returns (bool _boolean); /// @notice calculates the pairCodeHash /// @return _hash the pair code hash function pairCodeHash() external view returns (bytes32 _hash); /// @param tokenA address of tokenA /// @param tokenB address of tokenB /// @param stable whether it uses the stable curve /// @return _pair the address of the pair function getPair( address tokenA, address tokenB, bool stable ) external view returns (address _pair); /// @notice creates a new legacy pair /// @param tokenA address of tokenA /// @param tokenB address of tokenB /// @param stable whether it uses the stable curve /// @return pair the address of the created pair function createPair( address tokenA, address tokenB, bool stable ) external returns (address pair); /// @notice the address of the voter /// @return _voter the address of the voter function voter() external view returns (address _voter); /// @notice returns the address of a pair based on the index /// @param _index the index to check for a pair /// @return _pair the address of the pair at the index function allPairs(uint256 _index) external view returns (address _pair); /// @notice the swap fee of a pair /// @param _pair the address of the pair /// @return _fee the fee function pairFee(address _pair) external view returns (uint256 _fee); /// @notice the split of fees /// @return _split the feeSplit function feeSplit() external view returns (uint256 _split); /// @notice sets the swap fee for a pair /// @param _pair the address of the pair /// @param _fee the fee for the pair function setPairFee(address _pair, uint256 _fee) external; /// @notice set the swap fees of the pair /// @param _fee the fee, scaled to MAX 10% of 100_000 function setFee(uint256 _fee) external; /// @notice the address for the treasury /// @return _treasury address of the treasury function treasury() external view returns (address _treasury); /// @notice sets the pairFees contract /// @param _pair the address of the pair /// @param _pairFees the address of the new Pair Fees function setFeeRecipient(address _pair, address _pairFees) external; /// @notice sets the feeSplit for a pair /// @param _pair the address of the pair /// @param _feeSplit the feeSplit function setPairFeeSplit(address _pair, uint256 _feeSplit) external; /// @notice whether there is feeSplit when there's no gauge /// @return _boolean whether there is a feesplit when no gauge function feeSplitWhenNoGauge() external view returns (bool _boolean); /// @notice whether a pair can be skimmed /// @param _pair the pair address /// @return _boolean whether skim is enabled function skimEnabled(address _pair) external view returns (bool _boolean); /// @notice set whether skim is enabled for a specific pair function setSkimEnabled(address _pair, bool _status) external; /// @notice sets a new treasury address /// @param _treasury the new treasury address function setTreasury(address _treasury) external; /// @notice set whether there should be a feesplit without gauges /// @param status whether enabled or not function setFeeSplitWhenNoGauge(bool status) external; /// @notice sets the feesSplit globally /// @param _feeSplit the fee split function setFeeSplit(uint256 _feeSplit) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; interface IPair { error NOT_AUTHORIZED(); error UNSTABLE_RATIO(); /// @dev safe transfer failed error STF(); error OVERFLOW(); /// @dev skim disabled error SD(); /// @dev insufficient liquidity minted error ILM(); /// @dev insufficient liquidity burned error ILB(); /// @dev insufficient output amount error IOA(); /// @dev insufficient input amount error IIA(); error IL(); error IT(); error K(); event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); /// @notice initialize the pool, called only once programatically function initialize( address _token0, address _token1, bool _stable ) external; /// @notice calculate the current reserves of the pool and their last 'seen' timestamp /// @return _reserve0 amount of token0 in reserves /// @return _reserve1 amount of token1 in reserves /// @return _blockTimestampLast the timestamp when the pool was last updated function getReserves() external view returns ( uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast ); /// @notice mint the pair tokens (LPs) /// @param to where to mint the LP tokens to /// @return liquidity amount of LP tokens to mint function mint(address to) external returns (uint256 liquidity); /// @notice burn the pair tokens (LPs) /// @param to where to send the underlying /// @return amount0 amount of amount0 /// @return amount1 amount of amount1 function burn( address to ) external returns (uint256 amount0, uint256 amount1); /// @notice direct swap through the pool function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; /// @notice force balances to match reserves, can be used to harvest rebases from rebasing tokens or other external factors /// @param to where to send the excess tokens to function skim(address to) external; /// @notice force reserves to match balances, prevents skim excess if skim is enabled function sync() external; /// @notice set the pair fees contract address function setFeeRecipient(address _pairFees) external; /// @notice set the feesplit variable function setFeeSplit(uint256 _feeSplit) external; /// @notice sets the swap fee of the pair /// @dev max of 10_000 (10%) /// @param _fee the fee function setFee(uint256 _fee) external; /// @notice 'mint' the fees as LP tokens /// @dev this is used for protocol/voter fees function mintFee() external; /// @notice calculates the amount of tokens to receive post swap /// @param amountIn the token amount /// @param tokenIn the address of the token function getAmountOut( uint256 amountIn, address tokenIn ) external view returns (uint256 amountOut); /// @notice returns various metadata about the pair function metadata() external view returns ( uint256 _decimals0, uint256 _decimals1, uint256 _reserve0, uint256 _reserve1, bool _stable, address _token0, address _token1 ); /// @notice returns the feeSplit of the pair function feeSplit() external view returns (uint256); /// @notice returns the fee of the pair function fee() external view returns (uint256); /// @notice returns the feeRecipient of the pair function feeRecipient() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IERC20Extended} from "./interfaces/IERC20Extended.sol"; import {UQ112x112} from "./libraries/UQ112x112.sol"; import {IPairCallee} from "./interfaces/IPairCallee.sol"; import {IPairFactory} from "./interfaces/IPairFactory.sol"; import {IPair} from "./interfaces/IPair.sol"; contract Pair is IPair, ERC20, ReentrancyGuard { using UQ112x112 for uint224; /// @dev Structure to capture time period obervations every 30 minutes, used for local oracles struct Observation { uint256 timestamp; uint256 reserve0Cumulative; uint256 reserve1Cumulative; } Observation[] public observations; uint256 internal _unlocked; /// @notice Capture oracle reading every 30 minutes uint256 constant periodSize = 1800; /// @notice min liquidity amount which is burned on creation uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3; /// @notice legacy factory address address public immutable factory; /// @notice token0 in the pool address public token0; /// @notice token1 in the pool address public token1; /// @notice where the swap fees accrue to address public feeRecipient; /// @dev uses single storage slot, accessible via getReserves uint112 private reserve0; /// @dev uses single storage slot, accessible via getReserves uint112 private reserve1; /// @dev uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; uint256 public reserve0CumulativeLast; uint256 public reserve1CumulativeLast; /// @dev reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 public kLast; /// @dev the portion that goes to feeRecipient, rest goes to LPs. 100% of the fees goes to feeRecipient if it's set to 10000 uint256 public feeSplit; uint256 public fee; uint256 internal decimals0; uint256 internal decimals1; /// @dev first MINIMUM_LIQUIDITY tokens are permanently locked uint256 internal constant MINIMUM_K = 10 ** 9; /// @dev 1m = 100% uint256 internal constant FEE_DENOM = 1_000_000; /// @notice whether the pool uses the xy(x^2 * y + y^2 * x) >= k swap curve bool public stable; string internal _name; string internal _symbol; constructor() ERC20("", "") { /// @dev initialize the factory address factory = msg.sender; } /// @inheritdoc IPair function initialize( address _token0, address _token1, bool _stable ) external { /// @dev prevent anyone other than the factory from calling require(msg.sender == factory, NOT_AUTHORIZED()); token0 = _token0; token1 = _token1; string memory __name; string memory __symbol; stable = _stable; if (_stable) { __name = string( string.concat( "Legacy Correlated- ", IERC20Extended(token0).symbol(), "/", IERC20Extended(token1).symbol() ) ); __symbol = string( string.concat( "cAMM-", IERC20Extended(token0).symbol(), "/", IERC20Extended(token1).symbol() ) ); } else { __name = string( string.concat( "Legacy Volatile- ", IERC20Extended(token0).symbol(), "/", IERC20Extended(token1).symbol() ) ); __symbol = string( string.concat( "vAMM-", IERC20Extended(token0).symbol(), "/", IERC20Extended(token1).symbol() ) ); } _name = __name; _symbol = __symbol; observations.push(Observation(block.timestamp, 0, 0)); decimals0 = 10 ** IERC20Extended(token0).decimals(); decimals1 = 10 ** IERC20Extended(token1).decimals(); } /// @inheritdoc IPair function getReserves() public view returns ( uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast ) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call( abi.encodeCall(IERC20Extended.transfer, (to, value)) ); if (!(success && (data.length == 0 || abi.decode(data, (bool))))) { revert STF(); } } /// @dev update reserves and, on the first call per block, reserve accumulators function _update( uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1 ) private { /// @dev ensure no overflow require( balance0 <= type(uint112).max && balance1 <= type(uint112).max, OVERFLOW() ); /// @dev store blockstamp uint256 blockTimestamp = block.timestamp; /// @dev declare uint256 timeElapsed; /// @dev overflow is desired unchecked { /// @dev time elapsed since the last update timeElapsed = blockTimestamp - uint256(blockTimestampLast); /// @dev if timeElapsed is gt 0 and the reserves are not 0 if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { /// @dev update the cumulatives reserve0CumulativeLast += _reserve0 * timeElapsed; reserve1CumulativeLast += _reserve1 * timeElapsed; } } /// @dev fetch the last observation Observation memory _point = lastObservation(); /// @dev compare the last observation with current timestamp, if greater than 30 minutes, record a new event timeElapsed = blockTimestamp - _point.timestamp; /// @dev if > the periodSize (usually 30m twar) if (timeElapsed > periodSize) { observations.push( Observation( blockTimestamp, reserve0CumulativeLast, reserve1CumulativeLast ) ); } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = uint32(blockTimestamp); emit Sync(reserve0, reserve1); } /// @dev if fee is on, mint liquidity up to the entire growth in sqrt(k) function _mintFee( uint112 _reserve0, uint112 _reserve1 ) private returns (bool feeOn) { /// @dev gas savings address _feeRecipient = feeRecipient; /// @dev gas savings uint256 _kLast = kLast; /// @dev we define fee being on as the existence of the fee recipient feeOn = _feeRecipient != address(0); /// @dev if there are any fees not going to LP providers if (feeOn) { /// @dev portion of fees that go to feeRecipient uint256 _feeSplit = feeSplit; /// @dev if the reserve calculation is not 0 if (_kLast != 0) { /// @dev if a stableswap/correlated pair with curve: xy(x^2y + y^2x) >= k if (stable) { /// @dev fetch current k value uint256 k = _k(_reserve0, _reserve1); /// @dev if k is greater than the _kLast variable if (k > _kLast) { uint256 fourthRoot_e18 = Math.sqrt( Math.mulDiv(Math.sqrt(_kLast), 1e36, Math.sqrt(k)) ); uint256 numerator = _feeSplit * (1e18 - fourthRoot_e18) * 1e18; uint256 denominator = ((10_000 * 1e18) - (_feeSplit * (1e18 - fourthRoot_e18))); /// @dev new liquidity to be minted uint256 feeAsLiquidity = (totalSupply() * numerator) / denominator / 1e18; if (feeAsLiquidity > 0) { _mint(_feeRecipient, feeAsLiquidity); } } } /// @dev if !stable else { uint256 rootK = Math.sqrt( _k(uint256(_reserve0), uint256(_reserve1)) ); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { /// @dev calculate fee amounts to send uint256 diffK = rootK - rootKLast; uint256 dueToProtocol = (diffK * _feeSplit) / 10_000; uint256 dueToLp = rootKLast + diffK - dueToProtocol; /// @dev new liquidity to be minted /// @dev n = s*P/d uint256 feeAsLiquidity = (totalSupply() * dueToProtocol) / dueToLp; if (feeAsLiquidity > 0) { _mint(_feeRecipient, feeAsLiquidity); } } } } } /// @dev if !feeOn else if (_kLast != 0) { /// @dev update kLast to reflect reserves kLast = _k(reserve0, reserve1); } } /// @inheritdoc IPair /// @dev this low-level function should be called from a contract which performs important safety checks function mint( address to ) external nonReentrant returns (uint256 liquidity) { /// @dev gas savings (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 balance0 = IERC20Extended(token0).balanceOf(address(this)); uint256 balance1 = IERC20Extended(token1).balanceOf(address(this)); uint256 amount0 = balance0 - _reserve0; uint256 amount1 = balance1 - _reserve1; bool feeOn = _mintFee(_reserve0, _reserve1); /// @dev gas savings, must be defined here since totalSupply can update in _mintFee uint256 _totalSupply = totalSupply(); if (_totalSupply == 0) { liquidity = Math.sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY; /// @dev permanently lock the first MINIMUM_LIQUIDITY tokens _mint(address(0xdead), MINIMUM_LIQUIDITY); if (stable) { require(_k(amount0, amount1) >= MINIMUM_K, K()); require( ((amount0 * 1e18) / decimals0 == (amount1 * 1e18) / decimals1), UNSTABLE_RATIO() ); } } else { liquidity = Math.min( (amount0 * _totalSupply) / _reserve0, (amount1 * _totalSupply) / _reserve1 ); } require(liquidity != 0, ILM()); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); /// @dev reserve0 and reserve1 are up-to-date if (feeOn) kLast = _k(uint256(reserve0), uint256(reserve1)); emit Mint(msg.sender, amount0, amount1); } /// @inheritdoc IPair /// @dev this low-level function should be called from a contract which performs important safety checks function burn( address to ) external nonReentrant returns (uint256 amount0, uint256 amount1) { /// @dev gas savings (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); /// @dev gas savings address _token0 = token0; /// @dev gas savings address _token1 = token1; uint256 balance0 = IERC20Extended(_token0).balanceOf(address(this)); uint256 balance1 = IERC20Extended(_token1).balanceOf(address(this)); /// @dev fetch the balance of the liquidity of the Pair uint256 liquidity = balanceOf(address(this)); /// @dev attempt to mint fees and calculate if feeOn is active bool feeOn = _mintFee(_reserve0, _reserve1); /// @dev gas savings, must be defined here since totalSupply can update in _mintFee uint256 _totalSupply = totalSupply(); /// @dev using balances ensures pro-rata distribution amount0 = (liquidity * balance0) / _totalSupply; /// @dev using balances ensures pro-rata distribution amount1 = (liquidity * balance1) / _totalSupply; /// @dev require the amounts are not zero, else it's insufficient liquidity burned and revert require(amount0 != 0 && amount1 != 0, ILB()); /// @dev burn the liquidity tokens _burn(address(this), liquidity); /// @dev safe transfer the two underlying tokens (incase of tax tokens etc) _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); /// @dev fetch updated balances balance0 = IERC20Extended(_token0).balanceOf(address(this)); balance1 = IERC20Extended(_token1).balanceOf(address(this)); /// @dev update with the new balances _update(balance0, balance1, _reserve0, _reserve1); /// @dev reserve0 and reserve1 are up-to-date if (feeOn) kLast = _k(reserve0, reserve1); emit Burn(msg.sender, amount0, amount1, to); } /// @inheritdoc IPair /// @dev this low-level function should be called from a contract which performs important safety checks function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external nonReentrant { /// @dev require at least one is not 0, else revert for Insufficient Output Amount require(amount0Out != 0 || amount1Out != 0, IOA()); /// @dev gas savings (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); /// @dev ensure there is enough liquidity for the swap require(amount0Out <= _reserve0 && amount1Out <= _reserve1, IL()); /// @dev gas savings address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, IT()); /// @dev optimistically transfer tokens if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); /// @dev optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); if (data.length > 0) IPairCallee(to).hook(msg.sender, amount0Out, amount1Out, data); uint256 balance0 = IERC20Extended(_token0).balanceOf(address(this)); uint256 balance1 = IERC20Extended(_token1).balanceOf(address(this)); uint256 amount0In; uint256 amount1In; unchecked { amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; } require(amount0In != 0 || amount1In != 0, IIA()); /// @dev FEE_DENOM as the denominator invariant for calculating swap fees uint256 balance0Adjusted = balance0 - ((amount0In * fee) / FEE_DENOM); uint256 balance1Adjusted = balance1 - ((amount1In * fee) / FEE_DENOM); require( _k(balance0Adjusted, balance1Adjusted) >= _k(uint256(_reserve0), uint256(_reserve1)), K() ); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } /// @inheritdoc IPair function skim(address to) external nonReentrant { /// @dev if skim disabled, revert /// @dev by default it is disabled as it uses a mapping in the pair factory contract require((IPairFactory(factory).skimEnabled(address(this))), SD()); /// @dev gas savings address _token0 = token0; /// @dev gas savings address _token1 = token1; _safeTransfer( _token0, to, IERC20Extended(_token0).balanceOf(address(this)) - reserve0 ); _safeTransfer( _token1, to, IERC20Extended(_token1).balanceOf(address(this)) - reserve1 ); } /// @inheritdoc IPair function sync() external nonReentrant { /// @dev update the reserves to match balances _update( IERC20Extended(token0).balanceOf(address(this)), IERC20Extended(token1).balanceOf(address(this)), reserve0, reserve1 ); } /// @inheritdoc IPair function setFeeRecipient(address _feeRecipient) external { /// @dev gate to the PairFactory require(msg.sender == factory, NOT_AUTHORIZED()); feeRecipient = _feeRecipient; } /// @inheritdoc IPair function setFeeSplit(uint256 _feeSplit) external { /// @dev gate to the PairFactory require(msg.sender == factory, NOT_AUTHORIZED()); feeSplit = _feeSplit; } /// @inheritdoc IPair function setFee(uint256 _fee) external { /// @dev gate to the PairFactory require(msg.sender == factory, NOT_AUTHORIZED()); fee = _fee; } /// @inheritdoc IPair function mintFee() external nonReentrant { /// @dev fetch the current public reserves uint112 _reserve0 = reserve0; uint112 _reserve1 = reserve1; /// @dev mint the accumulated fees bool feeOn = _mintFee(_reserve0, _reserve1); /// @dev if minting was successful if (feeOn) kLast = _k(uint256(_reserve0), uint256(_reserve1)); } function _k(uint256 x, uint256 y) internal view returns (uint256) { if (stable) { uint256 _x = (x * 10 ** 18) / decimals0; uint256 _y = (y * 10 ** 18) / decimals1; uint256 _a = (_x * _y) / 10 ** 18; uint256 _b = ((_x * _x) / 10 ** 18 + (_y * _y) / 10 ** 18); /// @dev x3y+y3x >= k return (_a * _b) / 10 ** 18; } else { /// @dev xy >= k return x * y; } } function _f(uint256 x0, uint256 y) internal pure returns (uint256) { return (x0 * ((((y * y) / 1e18) * y) / 1e18)) / 1e18 + (((((x0 * x0) / 1e18) * x0) / 1e18) * y) / 1e18; } function _d(uint256 x0, uint256 y) internal pure returns (uint256) { return (3 * x0 * ((y * y) / 1e18)) / 1e18 + ((((x0 * x0) / 1e18) * x0) / 1e18); } function _get_y( uint256 x0, uint256 xy, uint256 y ) internal pure returns (uint256) { for (uint256 i = 0; i < 255; ++i) { uint256 y_prev = y; uint256 k = _f(x0, y); if (k < xy) { uint256 dy = ((xy - k) * 1e18) / _d(x0, y); y = y + dy; } else { uint256 dy = ((k - xy) * 1e18) / _d(x0, y); y = y - dy; } if (y > y_prev) { if (y - y_prev <= 1) { return y; } } else { if (y_prev - y <= 1) { return y; } } } return y; } /// @inheritdoc IPair function getAmountOut( uint256 amountIn, address tokenIn ) external view returns (uint256) { (uint256 _reserve0, uint256 _reserve1) = (reserve0, reserve1); /// @dev remove fee from amount received amountIn -= (amountIn * fee) / FEE_DENOM; return _getAmountOut(amountIn, tokenIn, _reserve0, _reserve1) - 1; } function _getAmountOut( uint256 amountIn, address tokenIn, uint256 _reserve0, uint256 _reserve1 ) internal view returns (uint256) { if (stable) { uint256 xy = _k(_reserve0, _reserve1); _reserve0 = (_reserve0 * 1e18) / decimals0; _reserve1 = (_reserve1 * 1e18) / decimals1; (uint256 reserveA, uint256 reserveB) = tokenIn == token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountIn = tokenIn == token0 ? (amountIn * 1e18) / decimals0 : (amountIn * 1e18) / decimals1; uint256 y = reserveB - _get_y(amountIn + reserveA, xy, reserveB); return (y * (tokenIn == token0 ? decimals1 : decimals0)) / 1e18; } else { (uint256 reserveA, uint256 reserveB) = tokenIn == token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); return (amountIn * reserveB) / (reserveA + amountIn); } } function metadata() external view returns ( uint256 _decimals0, uint256 _decimals1, uint256 _reserve0, uint256 _reserve1, bool _stable, address _token0, address _token1 ) { return ( decimals0, decimals1, reserve0, reserve1, stable, token0, token1 ); } function observationLength() external view returns (uint256) { return observations.length; } function lastObservation() public view returns (Observation memory) { return observations[observations.length - 1]; } /// @dev produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices() public view returns ( uint256 reserve0Cumulative, uint256 reserve1Cumulative, uint256 blockTimestamp ) { blockTimestamp = block.timestamp; reserve0Cumulative = reserve0CumulativeLast; reserve1Cumulative = reserve1CumulativeLast; /// @dev if time has elapsed since the last update on the pair, mock the accumulated price values ( uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast ) = getReserves(); if (_blockTimestampLast != uint32(blockTimestamp)) { /// @dev subtraction overflow is desired uint256 timeElapsed = blockTimestamp - uint256(_blockTimestampLast); reserve0Cumulative += _reserve0 * timeElapsed; reserve1Cumulative += _reserve1 * timeElapsed; } } /// @dev gives the current twap price measured from amountIn * tokenIn gives amountOut function current( address tokenIn, uint256 amountIn ) external view returns (uint256 amountOut) { Observation memory _observation = lastObservation(); ( uint256 reserve0Cumulative, uint256 reserve1Cumulative, ) = currentCumulativePrices(); if (block.timestamp == _observation.timestamp) { _observation = observations[observations.length - 2]; } uint256 timeElapsed = block.timestamp - _observation.timestamp; uint256 _reserve0 = (reserve0Cumulative - _observation.reserve0Cumulative) / timeElapsed; uint256 _reserve1 = (reserve1Cumulative - _observation.reserve1Cumulative) / timeElapsed; amountOut = _getAmountOut(amountIn, tokenIn, _reserve0, _reserve1); } /// @dev as per `current`, however allows user configured granularity, up to the full window size function quote( address tokenIn, uint256 amountIn, uint256 granularity ) external view returns (uint256 amountOut) { uint256[] memory _prices = sample(tokenIn, amountIn, granularity, 1); uint256 priceAverageCumulative; for (uint256 i = 0; i < _prices.length; ++i) { priceAverageCumulative += _prices[i]; } return priceAverageCumulative / granularity; } /// @dev returns a memory set of twap prices function prices( address tokenIn, uint256 amountIn, uint256 points ) external view returns (uint256[] memory) { return sample(tokenIn, amountIn, points, 1); } function sample( address tokenIn, uint256 amountIn, uint256 points, uint256 window ) public view returns (uint256[] memory) { uint256[] memory _prices = new uint256[](points); uint256 length = observations.length - 1; uint256 i = length - (points * window); uint256 nextIndex = 0; uint256 index = 0; for (; i < length; i += window) { nextIndex = i + window; uint256 timeElapsed = observations[nextIndex].timestamp - observations[i].timestamp; uint256 _reserve0 = (observations[nextIndex].reserve0Cumulative - observations[i].reserve0Cumulative) / timeElapsed; uint256 _reserve1 = (observations[nextIndex].reserve1Cumulative - observations[i].reserve1Cumulative) / timeElapsed; _prices[index] = _getAmountOut( amountIn, tokenIn, _reserve0, _reserve1 ); /// @dev index < length; length cannot overflow unchecked { index = index + 1; } } return _prices; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC-20 * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @dev Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 1); } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 1); } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; interface IERC20Extended is IERC20, IERC20Metadata, IERC20Permit { function mint(address account, uint256 amount) external; function burn(uint256 amount) external; function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function burnFrom(address account, uint256 value) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) // range: [0, 2**112 - 1] // resolution: 1 / 2**112 library UQ112x112 { uint224 constant Q112 = 2 ** 112; // encode a uint112 as a UQ112x112 function encode(uint112 y) internal pure returns (uint224 z) { unchecked { z = uint224(y) * Q112; // never overflows } } // divide a UQ112x112 by a uint112, returning a UQ112x112 function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) { unchecked { z = x / uint224(y); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; interface IPairCallee { function hook( address sender, uint256 amount0, uint256 amount1, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612]. * * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
{ "remappings": [ "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/", "forge-std/=dependencies/forge-std-1.9.4/src/", "permit2/=lib/permit2/", "@openzeppelin-3.4.2/=node_modules/@openzeppelin-3.4.2/", "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std-1.9.4/=dependencies/forge-std-1.9.4/src/", "hardhat/=node_modules/hardhat/", "solmate/=node_modules/solmate/" ], "optimizer": { "enabled": true, "runs": 100 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_voter","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_accessHub","type":"address"},{"internalType":"address","name":"_feeRecipientFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FEE_TOO_HIGH","type":"error"},{"inputs":[],"name":"IA","type":"error"},{"inputs":[],"name":"INVALID_FEE_SPLIT","type":"error"},{"inputs":[],"name":"NOT_AUTHORIZED","type":"error"},{"inputs":[],"name":"PE","type":"error"},{"inputs":[],"name":"ZA","type":"error"},{"inputs":[],"name":"ZERO_FEE","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_caller","type":"address"},{"indexed":true,"internalType":"bool","name":"_status","type":"bool"}],"name":"FeeSplitWhenNoGauge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_caller","type":"address"},{"indexed":true,"internalType":"address","name":"_newTreasury","type":"address"}],"name":"NewTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"PairCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"SetFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":true,"internalType":"address","name":"feeRecipient","type":"address"}],"name":"SetFeeRecipient","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_feeSplit","type":"uint256"}],"name":"SetFeeSplit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":true,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"SetPairFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":true,"internalType":"uint256","name":"_feeSplit","type":"uint256"}],"name":"SetPairFeeSplit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_pair","type":"address"},{"indexed":true,"internalType":"bool","name":"_status","type":"bool"}],"name":"SkimStatus","type":"event"},{"inputs":[],"name":"MAX_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"}],"name":"_pairFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accessHub","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"bool","name":"stable","type":"bool"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipientFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeSplit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeSplitWhenNoGauge","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"bool","name":"stable","type":"bool"}],"name":"getPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"}],"name":"isPair","outputs":[{"internalType":"bool","name":"isPair","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pairCodeHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pair","type":"address"}],"name":"pairFee","outputs":[{"internalType":"uint256","name":"feeForPair","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pair","type":"address"},{"internalType":"address","name":"_feeRecipient","type":"address"}],"name":"setFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeSplit","type":"uint256"}],"name":"setFeeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setFeeSplitWhenNoGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pair","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setPairFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pair","type":"address"},{"internalType":"uint256","name":"_feeSplit","type":"uint256"}],"name":"setPairFeeSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pair","type":"address"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"setSkimEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"}],"name":"skimEnabled","outputs":[{"internalType":"bool","name":"skimEnabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x60806040526004361015610011575f80fd5b5f5f3560e01c80631e3dd18b14610dd4578063270401cb14610ce25780633ff43b2614610610578063407c301e14610bec57806346c96aac14610ba7578063574f2ba314610b8957806361d027b314610b625780636373ea6914610b445780636801cc3014610adf57806369fe0e2d14610a2757806382dfdce41461066c57806383b274f214610649578063841fa66b1461061057806390291058146105a85780639aab92481461056d578063a93a897d14610448578063bc063e1a1461042a578063cd962a0614610383578063d2b6638414610344578063d32af6c1146102ff578063ddca3f43146102e1578063e0bd111d14610217578063e5e31b13146101d8578063e7589b39146101af5763f0f442601461012d575f80fd5b346101ac5760203660031901126101ac57610146610e42565b6001546001600160a01b0316330361019d5781546001600160a01b0319166001600160a01b03919091169081178255337f567657fa3f286518b318f4a29870674f433f622fdfc819691acb13105b2282258380a380f35b633d83866f60e01b8252600482fd5b80fd5b50346101ac57806003193601126101ac576001546040516001600160a01b039091168152602090f35b50346101ac5760203660031901126101ac5760209060ff906040906001600160a01b03610203610e42565b168152600684522054166040519015158152f35b50346101ac5760403660031901126101ac57610231610e42565b602435801515918282036102dd576001546001600160a01b031633036102ce576001600160a01b03168084526008602052604084205490919060ff16151583146102b8575b8184526008602052604084209060ff8019835416911515161790557f13af6400168c56d7a03760d35e1d3d7e60d3f86c654d857e5c77ed8a83ffc1198380a380f35b50808352600860205260ff604084205416610276565b633d83866f60e01b8452600484fd5b8380fd5b50346101ac57806003193601126101ac576020600254604051908152f35b50346101ac57806003193601126101ac576040517f0000000000000000000000000c85b0a29758aef3c02aa57b0d82ce94fb4ffe8d6001600160a01b03168152602090f35b50346101ac5760203660031901126101ac5760209060ff906040906001600160a01b0361036f610e42565b168152600884522054166040519015158152f35b50346101ac5760203660031901126101ac5760043560018060a01b0360015416331480156103f8575b156103f45761271081116103e557806003557f2b29780fbcadbddb5194d8c2c6a834e1cd71e5a38456738fb1c9d39c7821066b8280a280f35b63740efc0360e01b8252600482fd5b5080fd5b50337f000000000000000000000000a1c2decb3730ab0331fe217ad036bd5bd54ced286001600160a01b0316146103ac565b50346101ac57806003193601126101ac576020604051620186a08152f35b50346101ac5760403660031901126101ac57610462610e42565b6024359060018060a01b03600154163314801561053b575b1561053757620186a08211610528578161052157600254905b6001600160a01b031690813b156102dd57836040516369fe0e2d60e01b8152826004820152818160248183885af1801561051657610501575b50829052600760205260408420557fc792b1e9d2b63c63a75f8146a0b5bd7f568bdd6a0b97b9c31d585398718d4c468380a380f35b8161050b91610e7d565b6102dd57835f6104cc565b6040513d84823e3d90fd5b8190610493565b6345fbd9c160e01b8352600483fd5b8280fd5b50337f000000000000000000000000a1c2decb3730ab0331fe217ad036bd5bd54ced286001600160a01b03161461047a565b50346101ac57806003193601126101ac5760206040517f0dc4685c81026aadd4024bd0557a2549eaf5ee8c8a89a4b6e0aa92f682a2282a8152f35b50346101ac5760203660031901126101ac576004358015158091036103f4576001546001600160a01b0316330361019d5760ff196009541660ff821617600955337f09f29919de9bbce805ed8b6088457163a7508940470e70a1c67a8d58a70b433d8380a380f35b50346101ac5760203660031901126101ac576020906040906001600160a01b03610638610e42565b168152600783522054604051908152f35b50346101ac57806003193601126101ac57602060ff600954166040519015158152f35b50346101ac5760603660031901126101ac57610686610e42565b61068e610e58565b610696610e6e565b916001600160a01b03828116908216808214610a18571015610a12575b6001600160a01b038116908115610a03578185526004602090815260408087206001600160a01b038681165f9081529184529082902096151580895296909252862054166109f45760405160208101916001600160601b03199060601b16825260018060a01b038416936001600160601b03199060601b1660348201528460f81b604882015260298152610748604982610e7d565b5190206040516135b38082019082821067ffffffffffffffff8311176109e057908291610eb48339039086f580156109d5576001600160a01b031692833b156109925784604051631c9776b560e31b81528360048201528460248201528260448201528181606481838a5af18015610516576109c0575b508490526007602052846040812054853b156103f457604051906369fe0e2d60e01b825260048201528181602481838a5af18015610516576109ab575b505060ff60095416610909575b8185526004602081815260408088205f878152908352818120858a52835281892080546001600160a01b038a166001600160a01b03199182168117909255888b52948452828a2087835284529082902094895293909152862080549091169091179055600554600160401b8110156108f55760209461089082600160409401600555610e16565b81549060031b9087821b9160018060a01b03901b19161790558481526006865220600160ff198254161790557f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9604060055481519086825287820152a3604051908152f35b634e487b7160e01b85526041600452602485fd5b845485906001600160a01b0316853b156103f4576040519063e74b981b60e01b825260048201528181602481838a5af1801561051657610996575b50600354853b156103f457604051906366cb150360e11b825260048201528181602481838a5af180156105165761097d575b5050610809565b8161098791610e7d565b61099257845f610976565b8480fd5b816109a091610e7d565b61099257845f610944565b816109b591610e7d565b61099257845f6107fc565b816109ca91610e7d565b61099257845f6107bf565b6040513d86823e3d90fd5b634e487b7160e01b88526041600452602488fd5b636d47e01d60e01b8552600485fd5b637759ce3f60e01b8552600485fd5b906106b3565b630f05c93b60e31b8652600486fd5b50346101ac5760203660031901126101ac5760043560018060a01b036001541633148015610aad575b156103f4578015610a9e57620186a08111610a8f57806002557e172ddfc5ae88d08b3de01a5a187667c37a5a53989e8c175055cb6c993792a78280a280f35b6345fbd9c160e01b8252600482fd5b631d6263ff60e11b8252600482fd5b50337f000000000000000000000000a1c2decb3730ab0331fe217ad036bd5bd54ced286001600160a01b031614610a50565b50346101ac5760603660031901126101ac57602090610afc610e42565b610b04610e58565b610b0c610e6e565b6001600160a01b0392831684526004855260408085209284165f90815292865291829020901515845284529182902054915191168152f35b50346101ac57806003193601126101ac576020600354604051908152f35b50346101ac57806003193601126101ac57546040516001600160a01b039091168152602090f35b50346101ac57806003193601126101ac576020600554604051908152f35b50346101ac57806003193601126101ac576040517f000000000000000000000000a1c2decb3730ab0331fe217ad036bd5bd54ced286001600160a01b03168152602090f35b50346101ac5760403660031901126101ac57610c06610e42565b6024359060018060a01b036001541633148015610cb0575b15610537576127108211610ca1576001600160a01b0316803b1561053757826040516366cb150360e11b8152836004820152818160248183875af1801561051657610c8c575b50807f40c433a8082166fcd8218fba9d4247bb08e03016d0056fc857d6363673ded03191a380f35b81610c9691610e7d565b61053757825f610c64565b63740efc0360e01b8352600483fd5b50337f000000000000000000000000a1c2decb3730ab0331fe217ad036bd5bd54ced286001600160a01b031614610c1e565b5034610dc1576040366003190112610dc157610cfc610e42565b610d04610e58565b907f000000000000000000000000a1c2decb3730ab0331fe217ad036bd5bd54ced286001600160a01b03163303610dc5576001600160a01b0316803b15610dc15760405163e74b981b60e01b81526001600160a01b0390921660048301819052915f8160248183865af18015610db657610da1575b507fd9d6b85b6d670cd443496fc6d03390f739bbff47f96a8e33fb0cdd52ad26f5c28380a380f35b610dae9193505f90610e7d565b5f915f610d79565b6040513d5f823e3d90fd5b5f80fd5b633d83866f60e01b5f5260045ffd5b34610dc1576020366003190112610dc157600435600554811015610dc157610dfd602091610e16565b905460405160039290921b1c6001600160a01b03168152f35b600554811015610e2e5760055f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffd5b600435906001600160a01b0382168203610dc157565b602435906001600160a01b0382168203610dc157565b604435908115158203610dc157565b90601f8019910116810190811067ffffffffffffffff821117610e9f57604052565b634e487b7160e01b5f52604160045260245ffdfe60a0604052346102f9576100116102fd565b6100196102fd565b81516001600160401b03811161020c57600354600181811c911680156102ef575b60208210146101ee57601f811161028c575b50602092601f821160011461022b57928192935f92610220575b50508160011b915f199060031b1c1916176003555b80516001600160401b03811161020c57600454600181811c91168015610202575b60208210146101ee57601f811161018b575b50602091601f821160011461012b579181925f92610120575b50508160011b915f199060031b1c1916176004555b600160055533608052604051613293908161032082396080518181816103d50152818161046901528181610c6101528181610cbd01528181610d6501526117ac0152f35b015190505f806100c7565b601f1982169260045f52805f20915f5b8581106101735750836001951061015b575b505050811b016004556100dc565b01515f1960f88460031b161c191690555f808061014d565b9192602060018192868501518155019401920161013b565b60045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f830160051c810191602084106101e4575b601f0160051c01905b8181106101d957506100ae565b5f81556001016101cc565b90915081906101c3565b634e487b7160e01b5f52602260045260245ffd5b90607f169061009c565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610066565b601f1982169360035f52805f20915f5b868110610274575083600195961061025c575b505050811b0160035561007b565b01515f1960f88460031b161c191690555f808061024e565b9192602060018192868501518155019401920161023b565b60035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c810191602084106102e5575b601f0160051c01905b8181106102da575061004c565b5f81556001016102cd565b90915081906102c4565b90607f169061003a565b5f80fd5b60405190602082016001600160401b0381118382101761020c576040525f825256fe60806040526004361015610011575f80fd5b5f5f3560e01c8063022c0d9f14611eab57806306fdde0314611e045780630902f1ac14611dc0578063095ea7b314611d155780630dfe168114611cec57806313345fe114611bb157806313966db514611b5a57806318160ddd14611b3c5780631df8c71714611b0357806322be3de114611ae057806323b872dd146119fe578063252c09d7146119a5578063313ce56714611989578063392f37e91461191257806346904840146118e9578063517b3f82146118285780635881c475146118015780636373ea69146117e357806369fe0e2d146117985780636a6278421461147b57806370a08231146114435780637464fc3d1461142557806389afcb44146110c45780638a7b8cf21461108d57806395d89b4114610fae5780639e8cc04b14610f54578063a9059cbb14610f22578063ba9a7a5614610f05578063bc25cf7714610d28578063bf944dbc14610d0a578063c245febc14610cec578063c45a015514610ca7578063cd962a0614610c4d578063d21220a714610c24578063dd62ed3e14610bd1578063ddca3f4314610bb3578063e4bbb5a814610435578063e74b981b146103b9578063ebeb31db1461039b578063f140a35a146103175763fff6cae9146101dd575f80fd5b346103145780600319360112610314576101f5612767565b6008546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa80156103095782906102d6575b6009546040516370a0823160e01b81523060048201529250602090839060249082906001600160a01b03165afa9081156102cb578391610291575b600b5461028993506001600160701b03607082901c8116939116916128f5565b600160055580f35b90506020823d6020116102c3575b816102ac60209383612389565b810103126102bf57610289915190610269565b5f80fd5b3d915061029f565b6040513d85823e3d90fd5b506020813d602011610301575b816102f060209383612389565b810103126102bf576024905161022e565b3d91506102e3565b6040513d84823e3d90fd5b80fd5b503461031457604036600319011261031457610370600435610337612287565b600b546010546001600160701b03607083901c8116949216929161036b91620f42409061036490836123aa565b04906123ef565b612a4d565b5f1981019190821161038757602082604051908152f35b634e487b7160e01b81526011600452602490fd5b50346103145780600319360112610314576020600654604051908152f35b5034610314576020366003190112610314576103d3612271565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361042657600a80546001600160a01b0319166001600160a01b039290921691909117905580f35b633d83866f60e01b8252600482fd5b50346103145760603660031901126103145761044f612271565b90610458612287565b9160443580151591828203610baf577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610ba05760018060a01b0316938460018060a01b0319600854161760085560018060a01b0316918260018060a01b0319600954161760095560ff8019601354169116176013555f146109de576040516395d89b4160e01b81528281600481875afa9081156102cb5783916109c4575b506040516395d89b4160e01b81528381600481865afa9081156109b95761058f60016004946033602089968196889161099f575b506040519687947202632b3b0b1bc9021b7b93932b630ba32b2169606d1b828701528051918291018587015e840190602f60f81b84830152805192839101603483015e010185838201520301601f198101835282612389565b94604051928380926395d89b4160e01b82525afa9081156102cb5783908192610982575b506040516395d89b4160e01b81529192829060049082905afa9081156102cb57602092602584610632946001948891610960575b506040519687946463414d4d2d60d81b828701528051918291018587015e840190602f60f81b84830152805192839101602683015e010185838201520301601f198101835282612389565b905b82516001600160401b03811161087c5761064f6014546123fc565b601f81116108fd575b506020601f821160011461089b57829394829392610890575b50508160011b915f199060031b1c1916176014555b81516001600160401b03811161087c576106a16015546123fc565b601f8111610819575b50602092601f82116001146107b8579282938293926107ad575b50508160011b915f199060031b1c1916176015555b6106fc6040516106e88161235a565b4281528260208201528260408201526126d9565b60085460405163313ce56760e01b815290602090829060049082906001600160a01b03165afa80156103095761073991839161077e575b50612756565b60115560095460405163313ce56760e01b815290602090829060049082906001600160a01b03165afa80156103095761077891839161077e5750612756565b60125580f35b6107a0915060203d6020116107a6575b6107988183612389565b81019061273d565b5f610733565b503d61078e565b015190505f806106c4565b601f198216936015845280842091845b86811061080157508360019596106107e9575b505050811b016015556106d9565b01515f1960f88460031b161c191690555f80806107db565b919260206001819286850151815501940192016107c8565b601583527f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec475601f830160051c81019160208410610872575b601f0160051c01905b81811061086757506106aa565b83815560010161085a565b9091508190610851565b634e487b7160e01b82526041600452602482fd5b015190505f80610671565b6014835280832090601f198316845b8181106108e5575095836001959697106108cd575b505050811b01601455610686565b01515f1960f88460031b161c191690555f80806108bf565b9192602060018192868b0151815501940192016108aa565b601483527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec601f830160051c81019160208410610956575b601f0160051c01905b81811061094b5750610658565b83815560010161093e565b9091508190610935565b61097c91503d808a833e6109748183612389565b810190612677565b5f6105e7565b60049250610999903d8084833e6109748183612389565b916105b3565b6109b391503d808a833e6109748183612389565b5f610536565b6040513d86823e3d90fd5b6109d891503d8085833e6109748183612389565b5f610502565b6040516395d89b4160e01b81528281600481875afa9081156102cb578391610b86575b506040516395d89b4160e01b81528381600481865afa9081156109b957610a8c600160049460316020899681968891610b6c575b506040519687947002632b3b0b1bc902b37b630ba34b632969607d1b828701528051918291018587015e840190602f60f81b84830152805192839101603283015e010185838201520301601f198101835282612389565b94604051928380926395d89b4160e01b82525afa9081156102cb5783908192610b4f575b506040516395d89b4160e01b81529192829060049082905afa9081156102cb57602092602584610b2f946001948891610b35575b506040519687946476414d4d2d60d81b828701528051918291018587015e840190602f60f81b84830152805192839101602683015e010185838201520301601f198101835282612389565b90610634565b610b4991503d808a833e6109748183612389565b5f610ae4565b60049250610b66903d8084833e6109748183612389565b91610ab0565b610b8091503d808a833e6109748183612389565b5f610a35565b610b9a91503d8085833e6109748183612389565b5f610a01565b633d83866f60e01b8452600484fd5b8380fd5b50346103145780600319360112610314576020601054604051908152f35b5034610314576040366003190112610314576040610bed612271565b91610bf6612287565b9260018060a01b031681526001602052209060018060a01b03165f52602052602060405f2054604051908152f35b50346103145780600319360112610314576009546040516001600160a01b039091168152602090f35b5034610314576020366003190112610314577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610c9857600435600f5580f35b633d83866f60e01b8152600490fd5b50346103145780600319360112610314576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346103145780600319360112610314576020600d54604051908152f35b50346103145780600319360112610314576020600c54604051908152f35b503461031457602036600319011261031457610d42612271565b610d4a612767565b6040516334ad98e160e21b81523060048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156102cb578391610ed6575b5015610ec7576008546009546040516370a0823160e01b81523060048201526001600160a01b0391821692909116602082602481845afa918215610ebc5784908693610e84575b50600b54610e0593610dff916001600160701b0316906123ef565b91612787565b6040516370a0823160e01b815230600482015291602083602481855afa9283156109b9578493610e4e575b50600b5461028993610dff9160701c6001600160701b0316906123ef565b92506020833d602011610e7c575b81610e6960209383612389565b810103126102bf57915191610dff610e30565b3d9150610e5c565b9250506020823d602011610eb4575b81610ea060209383612389565b810103126102bf5790519083610dff610de4565b3d9150610e93565b6040513d87823e3d90fd5b631c20015160e11b8252600482fd5b610ef8915060203d602011610efe575b610ef08183612389565b810190612644565b5f610d9d565b503d610ee6565b503461031457806003193601126103145760206040516103e88152f35b503461031457604036600319011261031457610f49610f3f612271565b6024359033612dc9565b602060405160018152f35b503461031457610f70610f6636612330565b929190839161248a565b825b8151841015610f9a57610f92600191610f8b8685612476565b5190612469565b930192610f72565b610fa6836020926123d1565b604051908152f35b5034610314578060031936011261031457604051908060045490610fd1826123fc565b80855291600181169081156110665750600114611009575b61100584610ff981860382612389565b6040519182918261229d565b0390f35b600481527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b939250905b80821061104c57509091508101602001610ff982610fe9565b919260018160209254838588010152019101909291611033565b60ff191660208087019190915292151560051b85019092019250610ff99150839050610fe9565b503461031457806003193601126103145760606110a861260e565b6040805191805183526020810151602084015201516040820152f35b5034610314576020366003190112610314576110de612271565b6110e6612767565b6110ee612434565b506008546009546040516370a0823160e01b81523060048201526001600160a01b039182169694959190921693909290602083602481885afa9283156114185781936113e4575b506040516370a0823160e01b815230600482015296602088602481845afa9586156103095787988398976113ad575b50308352826020526111a06111946111946111996111878860408920549c612bdc565b986002549384918d6123aa565b6123d1565b9a8a6123aa565b96881515806113a4575b1561139557301561138157308452836020526040842054818110611368579184826020936024969530845283865203604083205580600254036002556040519081525f51602061323e5f395f51905f52843092a36112098a8983612787565b611214898985612787565b6040516370a0823160e01b815230600482015293849182905afa9182156102cb578392611333575b506020602491604051928380926370a0823160e01b82523060048301525afa92831561132757926112ec575b509661127792916040986128f5565b6112c7575b83519083825282602083015260018060a01b0316907fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496853392a3600160055582519182526020820152f35b600b546112e4906001600160701b03607082901c81169116612840565b600e5561127c565b929150966020833d60201161131f575b8161130960209383612389565b810103126102bf57915191969091906040611268565b3d91506112fc565b604051903d90823e3d90fd5b9091506020813d602011611360575b8161134f60209383612389565b810103126102bf575190602061123c565b3d9150611342565b63391434e360e21b855230600452602452604452606483fd5b634b637e8f60e11b84526004849052602484fd5b6310a8222760e21b8452600484fd5b508715156111aa565b965096506020863d6020116113dc575b816113ca60209383612389565b810103126102bf57879551965f611164565b3d91506113bd565b9092506020813d602011611410575b8161140060209383612389565b810103126102bf5751915f611135565b3d91506113f3565b50604051903d90823e3d90fd5b50346103145780600319360112610314576020600e54604051908152f35b5034610314576020366003190112610314576020906040906001600160a01b0361146b612271565b1681528083522054604051908152f35b503461031457602036600319011261031457602490611498612271565b6114a0612767565b6114a8612434565b506008546040516370a0823160e01b815230600482015291959293919260209184919082906001600160a01b03165afa9182156109b9578492611763575b506009546040516370a0823160e01b8152306004820152929390602090849060249082906001600160a01b03165afa928315610ebc57859361172f575b506001600160701b0381169261153984866123ef565b946001600160701b0388169361154f85846123ef565b958761155b8b87612bdc565b966002549283155f1461170557505061157e915087611579916123aa565b612e73565b6103e71981019081116116f1579761159a6103e861dead6131a2565b60ff6013541661163a575b881561162b5750916115c493916115bf8960209b95612f96565b6128f5565b611606575b604051918252838201527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f60403392a26001600555604051908152f35b600b54611623906001600160701b03607082901c81169116612840565b600e556115c9565b63ad69186f60e01b8152600490fd5b633b9aca00611649888a612840565b106116e257670de0b6b3a76400008802888104670de0b6b3a764000014891517156116ce5760115461167a916123d1565b670de0b6b3a76400008802888104670de0b6b3a764000014891517156116ba576012546116a6916123d1565b146115a557631bca023d60e31b8152600490fd5b634e487b7160e01b83526011600452602483fd5b634e487b7160e01b82526011600452602482fd5b63a932492f60e01b8152600490fd5b634e487b7160e01b89526011600452602489fd5b6117196111949161119486611720966123aa565b938a6123aa565b908180821091180218976115a5565b9092506020813d60201161175b575b8161174b60209383612389565b810103126102bf5751915f611523565b3d915061173e565b91506020823d602011611790575b8161177e60209383612389565b810103126102bf5760249151916114e6565b3d9150611771565b5034610314576020366003190112610314577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610c985760043560105580f35b50346103145780600319360112610314576020600f54604051908152f35b50346103145761100561181c61181636612330565b9161248a565b604051918291826122c7565b503461031457604036600319011261031457611842612271565b9061184b61260e565b90611854612576565b5091835142146118a0575b6020610fa6868661189761119461119489604061188e8b6118818851426123ef565b9586918c8a0151906123ef565b950151906123ef565b91602435612a4d565b600654919350600119820191821161038757509161189761119461119460209694604061188e6118db6118d5610fa69a612300565b506125e6565b98505050949650505061185f565b5034610314578060031936011261031457600a546040516001600160a01b039091168152602090f35b5034610314578060031936011261031457601154601254600b546013546008546009546040805196875260208701959095526001600160701b038085169587019590955260709390931c909316606085015260ff16151560808401526001600160a01b0391821660a08401521660c082015260e090f35b5034610314578060031936011261031457602060405160128152f35b5034610314576020366003190112610314576004356006548110156119fa576119cd90612300565b50805461100560026001840154930154604051938493846040919493926060820195825260208201520152565b5080fd5b503461031457606036600319011261031457611a18612271565b611a20612287565b6001600160a01b038216808452600160208181526040808720335f9081529252902054604435949290918201611a5d575b5050610f499350612dc9565b848210611ac5578015611ab1573315611a9d5785604091610f49975260016020522060018060a01b0333165f526020528360405f20910390555f80611a51565b634a1406b160e11b86526004869052602486fd5b63e602df0560e01b86526004869052602486fd5b6064868684637dc7a0d960e11b835233600452602452604452fd5b5034610314578060031936011261031457602060ff601354166040519015158152f35b5034610314578060031936011261031457611005611b1f612576565b604080519384526020840192909252908201529081906060820190565b50346103145780600319360112610314576020600254604051908152f35b5034610314578060031936011261031457611b73612767565b600b546001600160701b038082169160701c16611b908183612bdc565b611b9e575b82600160055580f35b611ba791612840565b600e555f80611b95565b503461031457608036600319011261031457611bcb612271565b9060643590604435602435611bdf82612452565b94611bed6040519687612389565b828652601f19611bfc84612452565b013660208801376006545f19810193908411611cd857611c2286611c28929695966123aa565b856123ef565b925b848410611c3f576040518061100589826122c7565b856001611cd292611cc0611c538489612469565b611cb8611c75611c6283612300565b5054611c6d8c612300565b5054906123ef565b6111948b6002611ca081611caf611ca9876111948e611c938d612300565b5001548f611ca08a612300565b500154906123ef565b98612300565b50015492612300565b908789612a4d565b611cca828c612476565b520194612469565b92611c2a565b634e487b7160e01b85526011600452602485fd5b50346103145780600319360112610314576008546040516001600160a01b039091168152602090f35b503461031457604036600319011261031457611d2f612271565b602435903315611dac576001600160a01b0316918215611d9857604090338152600160205220825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b634a1406b160e11b81526004819052602490fd5b63e602df0560e01b83526004839052602483fd5b5034610314578060031936011261031457606063ffffffff611de0612434565b604080516001600160701b0394851681529290931660208301529290921690820152f35b5034610314578060031936011261031457604051908060035490611e27826123fc565b80855291600181169081156110665750600114611e4e5761100584610ff981860382612389565b600381527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b939250905b808210611e9157509091508101602001610ff982610fe9565b919260018160209254838588010152019101909291611e78565b50346102bf5760803660031901126102bf57604435906001600160a01b0382166024356004358285036102bf576064356001600160401b0381116102bf57366023820112156102bf578060040135906001600160401b0382116102bf5736602483830101116102bf57611f1c612767565b82159081158092612268575b1561225957611f35612434565b506001600160701b0382169490939192908587111580612246575b15612237576008546009546001600160a01b039182169c9116938a8d14158061222d575b1561221e5788828e9261220d575b50505088806121fc575b50508061216b575b505060206024979899604051988980926370a0823160e01b82523060048301525afa96871561212b578997612136575b506020602491604051928380926370a0823160e01b82523060048301525afa90811561212b5789916120f9575b50848403808811156120f1578703965b6001600160701b03841694878603808411156120e9578303955b89158015906120e0575b156120d15761206e906120688b612062620f424061205b6120548261204d60105480976123aa565b048a6123ef565b938d6123aa565b04886123ef565b90612840565b92612840565b116120c2579061207f9392916128f5565b6040519384526020840152604083015260608201527fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d82260803392a3600160055580f35b63a932492f60e01b8a5260048afd5b635d05ca8f60e11b8c5260048cfd5b50861515612025565b508a9561201b565b508896612001565b90506020813d602011612123575b8161211460209383612389565b810103126102bf57515f611ff1565b3d9150612107565b6040513d8b823e3d90fd5b9096506020813d602011612163575b8161215260209383612389565b810103126102bf5751956020611fc4565b3d9150612145565b883b156102bf578760a488835f9460246040519788968795639a7bff7960e01b87523360048801528387015260448601526080606486015282608486015201848401378181018301859052601f01601f19168101030181838c5af180156121f1576121d7575b80611f94565b60249798505f6121e691612389565b60205f9897506121d1565b6040513d5f823e3d90fd5b6122069185612787565b5f88611f8c565b61221692612787565b8b8882611f82565b63a8fa826d60e01b5f5260045ffd5b50848b1415611f74565b63083ff6a160e01b5f5260045ffd5b506001600160701b038516881115611f50565b635ff1d88160e11b5f5260045ffd5b50841515611f28565b600435906001600160a01b03821682036102bf57565b602435906001600160a01b03821682036102bf57565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b60206040818301928281528451809452019201905f5b8181106122ea5750505090565b82518452602093840193909201916001016122dd565b60065481101561231c5760065f52600360205f20910201905f90565b634e487b7160e01b5f52603260045260245ffd5b60609060031901126102bf576004356001600160a01b03811681036102bf57906024359060443590565b606081019081106001600160401b0382111761237557604052565b634e487b7160e01b5f52604160045260245ffd5b90601f801991011681019081106001600160401b0382111761237557604052565b818102929181159184041417156123bd57565b634e487b7160e01b5f52601160045260245ffd5b81156123db570490565b634e487b7160e01b5f52601260045260245ffd5b919082039182116123bd57565b90600182811c9216801561242a575b602083101461241657565b634e487b7160e01b5f52602260045260245ffd5b91607f169161240b565b600b546001600160701b0380821692607083901c9091169160e01c90565b6001600160401b0381116123755760051b60200190565b919082018092116123bd57565b805182101561231c5760209160051b010190565b61249383612452565b926124a16040519485612389565b808452601f196124b082612452565b013660208601376006545f198101919082116123bd57801581800460011417156123bd576124e0908294926123ef565b905f5b8483106124f257505050505090565b60018301908184116123bd576125588261255061251e612513600196612300565b5054611c6d89612300565b611194600261254261253c846111948d8c611ca081611caf8d612300565b95612300565b5001546002611ca08b612300565b908786612a4d565b6125628289612476565b520191600181018091116123bd57916124e3565b4290600c5491600d549163ffffffff61258d612434565b9092164263ffffffff1681036125a257505050565b906125d46125e3949693976125ce6125bd6125ce95426123ef565b9384906001600160701b03166123aa565b90612469565b966001600160701b03166123aa565b91565b906040516125f38161235a565b60406002829480548452600181015460208501520154910152565b5f6040805161261c8161235a565b82815282602082015201526006545f1981019081116123bd576118d561264191612300565b90565b908160209103126102bf575180151581036102bf5790565b6001600160401b03811161237557601f01601f191660200190565b6020818303126102bf578051906001600160401b0382116102bf570181601f820112156102bf578051906126aa8261265c565b926126b86040519485612389565b828452602083830101116102bf57815f9260208093018386015e8301015290565b600654600160401b811015612375576001810160065560065481101561231c5760065f526003027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0190604081600292518455602081015160018501550151910155565b908160209103126102bf575160ff811681036102bf5790565b60ff16604d81116123bd57600a0a90565b600260055414612778576002600555565b633ee5aeb560e01b5f5260045ffd5b5f929183809360405190602082019363a9059cbb60e01b855260018060a01b031660248301526044820152604481526127c1606482612389565b51925af13d15612839573d6127d58161265c565b906127e36040519283612389565b81523d5f602083013e5b8161280a575b50156127fb57565b63817275ab60e01b5f5260045ffd5b805180159250821561281f575b50505f6127f3565b6128329250602080918301019101612644565b5f80612817565b60606127ed565b60135460ff16156128eb57670de0b6b3a7640000810290808204670de0b6b3a764000014901517156123bd57601154612878916123d1565b90670de0b6b3a7640000810290808204670de0b6b3a764000014901517156123bd57670de0b6b3a7640000916128e16128b76128e793601254906123d1565b846128da816128d2816128ca86896123aa565b0496806123aa565b0492806123aa565b0490612469565b906123aa565b0490565b90612641916123aa565b9192916001600160701b0381111580612a3c575b15612a2d577f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad193604093600b5460e01c918242039242141580612a1b575b80612a09575b6129df575b50505061070861296a61296361260e565b51426123ef565b116129b4575b607091821b600160701b600160e01b03166001600160701b039182169081174260e01b6001600160e01b03191617600b819055845191825290921c166020820152a1565b6129da600c54600d548551916129c98361235a565b4283526020830152858201526126d9565b612970565b600c80546001600160701b039283168502019055600d8054929091169092020190555f8080612952565b506001600160701b038216151561294d565b506001600160701b0381161515612947565b6395a5c7f960e01b5f5260045ffd5b506001600160701b03821115612909565b9291909160ff601354165f14612b9757612a678183612840565b91670de0b6b3a7640000810290808204670de0b6b3a764000014901517156123bd57612a9660115480926123d1565b92670de0b6b3a7640000830292808404670de0b6b3a764000014901517156123bd57612ac560125480946123d1565b60085490956001600160a01b03908116911614938415612b9257945b8415612b4f57670de0b6b3a7640000870296808804670de0b6b3a764000014901517156123bd57612b3481612b3a93612b2f6128e799612b2a88670de0b6b3a76400009d6123d1565b612469565b612faf565b906123ef565b9215612b475750906123aa565b9050906123aa565b670de0b6b3a7640000870296808804670de0b6b3a764000014901517156123bd57612b3481612b3a93612b2f6128e799612b2a89670de0b6b3a76400009d6123d1565b612ae1565b6008546126419492939192916001600160a01b03908116911603612bcf57612bc3612bc9925b826123aa565b92612469565b906123d1565b612bc3612bc99293612bbd565b600a54600e546001600160a01b039091168015801595949193919290612d9d57600f549181612c0e575b50505050505b565b60135460ff1615612d0e5791929091612c33916001600160701b039081169116612840565b90808211612c4b575b505050505b5f80808080612c06565b612c6a91612c64612c5e61157993612e73565b91612e73565b906130d9565b670de0b6b3a76400000390670de0b6b3a764000082116123bd57612c8e82826123aa565b91670de0b6b3a7640000830292808404670de0b6b3a764000014901517156123bd57612cb9916123aa565b69021e19e0c9bab2400000039069021e19e0c9bab240000082116123bd57670de0b6b3a764000091611194612cf0926002546123aa565b0480612cfe575b8080612c3c565b612d0791612f96565b5f80612cf7565b9092612d3491612d2e91611579916001600160701b039182169116612840565b92612e73565b808311612d45575b50505050612c41565b612d7781612d72612710612d69612d6261119496612d80996123ef565b96876123aa565b04948592612469565b6123ef565b916002546123aa565b80612d8d575b8080612d3c565b612d9691612f96565b5f80612d86565b92505050612da757565b600b54612dc4906001600160701b03607082901c81169116612840565b600e55565b6001600160a01b0316908115612e60576001600160a01b0316918215612e4d57815f525f60205260405f2054818110612e3457815f51602061323e5f395f51905f5292602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b63ec442f0560e01b5f525f60045260245ffd5b634b637e8f60e11b5f525f60045260245ffd5b600181111561264157806001600160801b821015612f85575b612f3791600490600160401b811015612f78575b640100000000811015612f6b575b62010000811015612f5e575b610100811015612f52575b6010811015612f46575b1015612f3e575b60030260011c612ee681846123d1565b0160011c612ef481846123d1565b0160011c612f0281846123d1565b0160011c612f1081846123d1565b0160011c612f1e81846123d1565b0160011c612f2c81846123d1565b0160011c80926123d1565b8111900390565b60011b612ed6565b811c9160021b91612ecf565b60081c91811b91612ec5565b60101c9160081b91612eba565b60201c9160101b91612eae565b60401c9160201b91612ea0565b5050608081901c600160401b612e8c565b906001600160a01b03821615612e4d57612c0c916131a2565b905f5b60ff8110612fc05750505090565b8361300b670de0b6b3a7640000612fed81612fe68582612fe082806123aa565b046123aa565b04876123aa565b04670de0b6b3a76400006128da8482612fe08a82612fe082806123aa565b8380821015613095579061301e916123ef565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156123bd57816125ce61305392612bc9600195896131fc565b945b858181111561307e5790613068916123ef565b1115613078576001905b01612fb2565b50505090565b613087916123ef565b111561307857600190613072565b61309e916123ef565b670de0b6b3a7640000810290808204670de0b6b3a764000014901517156123bd5781612b346130d392612bc9600195896131fc565b94613055565b906ec097ce7bc90715b34b9f10000000008202905f196ec097ce7bc90715b34b9f1000000000840992828085109403938085039414613196578382111561317e576ec097ce7bc90715b34b9f1000000000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b509061264192506123d1565b5f51602061323e5f395f51905f5260205f926131c085600254612469565b6002556001600160a01b031693841584146131e75780600254036002555b604051908152a3565b848452838252604084208181540190556131de565b806003026003810482036123bd576128da670de0b6b3a764000061323081938261322988612641996123aa565b04906123aa565b049282612fe082806123aa56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212209bfe12cc35f3decc52b2c4a654f13cff8dee9366e794445ced0c5a1c1044dab964736f6c634300081c0033a26469706673582212205d83fd04dfafd3736c6f8909a2adceb17392aacc12b07324b64ddc1020f4ee6064736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.