More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 157 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Create Pair | 19285604 | 6 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19284980 | 6 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19284384 | 7 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19284256 | 7 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19283181 | 7 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19283113 | 7 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19283069 | 7 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19282933 | 8 hrs ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19282665 | 8 hrs ago | IN | 0 frxETH | 0.00000471 | ||||
Create Pair | 19280385 | 9 hrs ago | IN | 0 frxETH | 0.00000471 | ||||
Create Pair | 19272005 | 14 hrs ago | IN | 0 frxETH | 0.00000471 | ||||
Create Pair | 19271907 | 14 hrs ago | IN | 0 frxETH | 0.00000471 | ||||
Create Pair | 19190997 | 2 days ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19190833 | 2 days ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19186995 | 2 days ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19186920 | 2 days ago | IN | 0 frxETH | 0.00000565 | ||||
Create Pair | 19033210 | 6 days ago | IN | 0 frxETH | 0.00000518 | ||||
Create Pair | 18962995 | 7 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18962961 | 7 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18962874 | 7 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18961851 | 7 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18961739 | 7 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18961207 | 7 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18947891 | 8 days ago | IN | 0 frxETH | 0.00000566 | ||||
Create Pair | 18946796 | 8 days ago | IN | 0 frxETH | 0.00000471 |
Latest 25 internal transactions (View All)
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x7a07D606...c5F856C7A The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
FraxswapFactory
Compiler Version
v0.8.23+commit.f704f362
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================== FraxswapFactory ========================= // ==================================================================== import { FraxswapPair } from "./FraxswapPair.sol"; /// @notice TWAMM LP Pair Factory /// @author Frax Finance (https://github.com/FraxFinance) contract FraxswapFactory { address public feeTo; address public feeToSetter; bool public globalPause; mapping(address => mapping(address => address)) public getPair; address[] public allPairs; event PairCreated(address indexed token0, address indexed token1, address pair, uint256); error IdenticalAddress(); error ZeroAddress(); error PairExists(); constructor(address _owner) { feeToSetter = _owner; feeTo = _owner; } ///@notice Throws if called by any account other than the feeToSetter. modifier onlyFTS() { require(msg.sender == feeToSetter); // FORBIDDEN _; } function allPairsLength() external view returns (uint256) { return allPairs.length; } function createPair(address tokenA, address tokenB) external returns (address pair) { return createPair(tokenA, tokenB, 30); // default fee 0.30% } function createPair(address tokenA, address tokenB, uint256 fee) public returns (address pair) { if (tokenA == tokenB) revert IdenticalAddress(); // IDENTICAL_ADDRESSES (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); if (token0 == address(0)) revert ZeroAddress(); // ZERO_ADDRESS if (getPair[token0][token1] != address(0)) revert PairExists(); // PAIR_EXISTS // single check is sufficient bytes memory bytecode = type(FraxswapPair).creationCode; bytes32 salt = keccak256(abi.encodePacked(token0, token1)); assembly { pair := create2(0, add(bytecode, 32), mload(bytecode), salt) } FraxswapPair(pair).initialize(token0, token1, fee); getPair[token0][token1] = pair; getPair[token1][token0] = pair; // populate mapping in the reverse direction allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function setFeeTo(address _feeTo) external onlyFTS { feeTo = _feeTo; } function setFeeToSetter(address _feeToSetter) external onlyFTS { feeToSetter = _feeToSetter; } function toggleGlobalPause() external onlyFTS { require(!globalPause); globalPause = true; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.23; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // =========================== FraxswapPair =========================== // ==================================================================== import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { FraxswapERC20 } from "./FraxswapERC20.sol"; import { Math } from "./libraries/Math.sol"; import { UQ112x112 } from "./libraries/UQ112x112.sol"; import { IFraxswapFactory } from "./interfaces/IFraxswapFactory.sol"; import { LongTermOrdersLib } from "../twamm/LongTermOrders.sol"; import { IUniswapV2Callee } from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Callee.sol"; /// @notice TWAMM LP Pair Token /// @author Frax Finance (https://github.com/FraxFinance) contract FraxswapPair is FraxswapERC20 { using UQ112x112 for uint224; using LongTermOrdersLib for LongTermOrdersLib.LongTermOrders; using LongTermOrdersLib for LongTermOrdersLib.ExecuteVirtualOrdersResult; /// --------------------------- /// -----TWAMM Parameters ----- /// --------------------------- // address public owner_address; ///@notice time interval that are eligible for order expiry (to align expiries) uint256 public constant orderTimeInterval = 3600; // sync with LongTermOrders.sol ///@notice data structure to handle long term orders LongTermOrdersLib.LongTermOrders internal longTermOrders; uint112 public twammReserve0; uint112 public twammReserve1; uint256 public fee; bool public newSwapsPaused; modifier execVirtualOrders() { executeVirtualOrdersInternal(block.timestamp); _; } /// --------------------------- /// -------- Modifiers -------- /// --------------------------- ///@notice Throws if called by any account other than the owner. modifier onlyOwnerOrFactory() { require(factory == msg.sender || IFraxswapFactory(factory).feeToSetter() == msg.sender); // NOT OWNER OR FACTORY _; } ///@notice Checks if new swaps are paused. If they are, only allow closing of existing ones. modifier isNotPaused() { require(newSwapsPaused == false); // NEW LT ORDERS PAUSED _; } modifier feeCheck(uint256 newFee) { require(newFee > 0 && newFee < 101); // fee can't be zero and can't be more than 1% _; } /// --------------------------- /// --------- Events ---------- /// --------------------------- 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 An event emitted when a long term swap from token0 to token1 is performed event LongTermSwap0To1(address indexed addr, uint256 orderId, uint256 amount0In, uint256 numberOfTimeIntervals); ///@notice An event emitted when a long term swap from token1 to token0 is performed event LongTermSwap1To0(address indexed addr, uint256 orderId, uint256 amount1In, uint256 numberOfTimeIntervals); ///@notice An event emitted when a long term swap is cancelled event CancelLongTermOrder( address indexed addr, uint256 orderId, address sellToken, uint256 unsoldAmount, address buyToken, uint256 purchasedAmount ); ///@notice An event emitted when a long term swap is withdrawn event WithdrawProceedsFromLongTermOrder( address indexed addr, uint256 orderId, address indexed proceedToken, uint256 proceeds, bool orderExpired ); ///@notice An event emitted when lp fee is updated event LpFeeUpdated(uint256 fee); /// --------------------------- /// --------- Errors ---------- /// --------------------------- error InvalidToToken(); error Uint112Overflow(); error KConstantError(); error InsufficientInputAmount(); error InsufficientOutputAmount(); error InsufficientLiquidity(uint112 reserve0, uint112 reserve1); /// ------------------------------- /// -----UNISWAPV2 Parameters ----- /// ------------------------------- uint256 public constant MINIMUM_LIQUIDITY = 10 ** 3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); address public factory; address public token0; address public token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event // Track order IDs mapping(address => uint256[]) public orderIDsForUser; TWAPObservation[] public TWAPObservationHistory; struct TWAPObservation { uint256 timestamp; uint256 price0CumulativeLast; uint256 price1CumulativeLast; } function price0CumulativeLast() public view returns (uint256) { return TWAPObservationHistory.length > 0 ? TWAPObservationHistory[TWAPObservationHistory.length - 1].price0CumulativeLast : 0; } function price1CumulativeLast() public view returns (uint256) { return TWAPObservationHistory.length > 0 ? TWAPObservationHistory[TWAPObservationHistory.length - 1].price1CumulativeLast : 0; } function getTWAPHistoryLength() public view returns (uint256) { return TWAPObservationHistory.length; } uint256 private unlocked = 1; modifier lock() { require(unlocked == 1); // LOCKED unlocked = 0; _; unlocked = 1; } function getOrderIDsForUser(address user) external view returns (uint256[] memory) { return orderIDsForUser[user]; } function getOrderIDsForUserLength(address user) external view returns (uint256) { return orderIDsForUser[user].length; } function getDetailedOrdersForUser( address user, uint256 offset, uint256 limit ) external view returns (LongTermOrdersLib.Order[] memory detailed_orders) { uint256[] memory order_ids = orderIDsForUser[user]; uint256 limit_to_use = Math.min(limit, order_ids.length - offset); detailed_orders = new LongTermOrdersLib.Order[](limit_to_use); for (uint256 i = 0; i < limit_to_use; i++) { detailed_orders[i] = longTermOrders.orderMap[order_ids[offset + i]]; } } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { return (reserve0, reserve1, blockTimestampLast); } function getTwammReserves() public view returns ( uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast, uint112 _twammReserve0, uint112 _twammReserve1, uint256 _fee ) { return (reserve0, reserve1, blockTimestampLast, twammReserve0, twammReserve1, 10_000 - fee); } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint256 amountIn, address tokenIn) external view returns (uint256) { (uint112 reserveIn, uint112 reserveOut) = tokenIn == token0 ? (reserve0, reserve1) : (reserve1, reserve0); require(amountIn > 0 && reserveIn > 0 && reserveOut > 0); // INSUFFICIENT_INPUT_AMOUNT, INSUFFICIENT_LIQUIDITY uint256 amountInWithFee = amountIn * fee; uint256 numerator = amountInWithFee * reserveOut; uint256 denominator = (reserveIn * 10_000) + amountInWithFee; return numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint256 amountOut, address tokenOut) external view returns (uint256) { (uint112 reserveIn, uint112 reserveOut) = tokenOut == token0 ? (reserve1, reserve0) : (reserve0, reserve1); require(amountOut > 0 && reserveIn > 0 && reserveOut > 0); // INSUFFICIENT_OUTPUT_AMOUNT, INSUFFICIENT_LIQUIDITY uint256 numerator = reserveIn * amountOut * 10_000; uint256 denominator = (reserveOut - amountOut) * fee; return (numerator / denominator) + 1; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool)))); // TRANSFER_FAILED } constructor() { factory = msg.sender; } // called once by the factory at time of deployment. will revert if fee is bad function initialize(address _token0, address _token1, uint256 _fee) external feeCheck(_fee) { require(msg.sender == factory); // FORBIDDEN // sufficient check token0 = _token0; token1 = _token1; fee = 10_000 - _fee; // TWAMM longTermOrders.initialize(_token0); emit LpFeeUpdated(_fee); } function _getTimeElapsed() private view returns (uint32) { uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32); uint32 timeElapsed; unchecked { timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired } return timeElapsed; } // update reserves and, on the first call per block, price accumulators function _update( uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1, uint32 timeElapsed ) private { if (!(balance0 + twammReserve0 <= type(uint112).max && balance1 + twammReserve1 <= type(uint112).max)) { revert Uint112Overflow(); } // OVERFLOW uint32 blockTimestamp = uint32(block.timestamp % 2 ** 32); unchecked { if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired TWAPObservationHistory.push( TWAPObservation( blockTimestamp, price0CumulativeLast() + uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed, price1CumulativeLast() + uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed ) ); } } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IFraxswapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0) * _reserve1); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply * (rootK - rootKLast); uint256 denominator = (rootK * 5) + rootKLast; uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock execVirtualOrders returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings uint256 balance0 = IERC20(token0).balanceOf(address(this)) - twammReserve0; uint256 balance1 = IERC20(token1).balanceOf(address(this)) - twammReserve1; uint256 amount0 = balance0 - _reserve0; uint256 amount1 = balance1 - _reserve1; bool feeOn = _mintFee(_reserve0, _reserve1); uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { liquidity = Math.sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY; _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } else { liquidity = Math.min((amount0 * _totalSupply) / _reserve0, (amount1 * _totalSupply) / _reserve1); } require(liquidity > 0); // INSUFFICIENT_LIQUIDITY_MINTED _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1, _getTimeElapsed()); if (feeOn) kLast = uint256(reserve0) * reserve1; // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock execVirtualOrders returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)) - twammReserve0; uint256 balance1 = IERC20(_token1).balanceOf(address(this)) - twammReserve1; uint256 liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = (liquidity * balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = (liquidity * balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0); // INSUFFICIENT_LIQUIDITY_BURNED _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)) - twammReserve0; balance1 = IERC20(_token1).balanceOf(address(this)) - twammReserve1; _update(balance0, balance1, _reserve0, _reserve1, _getTimeElapsed()); if (feeOn) kLast = uint256(reserve0) * reserve1; // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } // 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 lock execVirtualOrders { if (!(amount0Out > 0 || amount1Out > 0)) revert InsufficientOutputAmount(); // INSUFFICIENT_OUTPUT_AMOUNT (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings if (!(amount0Out < _reserve0 && amount1Out < _reserve1)) revert InsufficientLiquidity(_reserve0, _reserve1); // INSUFFICIENT_LIQUIDITY uint256 balance0; uint256 balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; if (!(to != _token0 && to != _token1)) revert InvalidToToken(); // INVALID_TO if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)) - twammReserve0; balance1 = IERC20(_token1).balanceOf(address(this)) - twammReserve1; } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; if (!(amount0In > 0 || amount1In > 0)) revert InsufficientInputAmount(); // INSUFFICIENT_INPUT_AMOUNT { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 minusFee = 10_000 - fee; uint256 balance0Adjusted = (balance0 * 10_000) - (amount0In * minusFee); uint256 balance1Adjusted = (balance1 * 10_000) - (amount1In * minusFee); if (!(balance0Adjusted * balance1Adjusted >= uint256(_reserve0) * _reserve1 * (10_000 ** 2))) { revert KConstantError(); } // K } _update(balance0, balance1, _reserve0, _reserve1, _getTimeElapsed()); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external lock execVirtualOrders { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)) - (reserve0 + twammReserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)) - (reserve1 + twammReserve1)); } // force reserves to match balances function sync() external lock execVirtualOrders { _update( IERC20(token0).balanceOf(address(this)) - twammReserve0, IERC20(token1).balanceOf(address(this)) - twammReserve1, reserve0, reserve1, _getTimeElapsed() ); } // TWAMM ///@notice calculate the amount in for token using the balance diff to handle feeOnTransfer tokens function transferAmountIn(address token, uint256 amountIn) internal returns (uint256) { // prev balance uint256 bal = IERC20(token).balanceOf(address(this)); // transfer amount to contract // safeTransferFrom // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call( abi.encodeWithSelector(0x23b872dd, msg.sender, address(this), amountIn) ); require(success && (data.length == 0 || abi.decode(data, (bool)))); // balance change return IERC20(token).balanceOf(address(this)) - bal; } ///@notice create a long term order to swap from token0 ///@param amount0In total amount of token0 to swap ///@param numberOfTimeIntervals number of time intervals over which to execute long term order function longTermSwapFrom0To1( uint256 amount0In, uint256 numberOfTimeIntervals ) external lock isNotPaused execVirtualOrders returns (uint256 orderId) { uint256 amount0 = transferAmountIn(token0, amount0In); twammReserve0 += uint112(amount0); require(uint256(reserve0) + twammReserve0 <= type(uint112).max); // OVERFLOW orderId = longTermOrders.performLongTermSwap(token0, token1, amount0, numberOfTimeIntervals); orderIDsForUser[msg.sender].push(orderId); emit LongTermSwap0To1(msg.sender, orderId, amount0, numberOfTimeIntervals); } ///@notice create a long term order to swap from token1 ///@param amount1In total amount of token1 to swap ///@param numberOfTimeIntervals number of time intervals over which to execute long term order function longTermSwapFrom1To0( uint256 amount1In, uint256 numberOfTimeIntervals ) external lock isNotPaused execVirtualOrders returns (uint256 orderId) { uint256 amount1 = transferAmountIn(token1, amount1In); twammReserve1 += uint112(amount1); require(uint256(reserve1) + twammReserve1 <= type(uint112).max); // OVERFLOW orderId = longTermOrders.performLongTermSwap(token1, token0, amount1, numberOfTimeIntervals); orderIDsForUser[msg.sender].push(orderId); emit LongTermSwap1To0(msg.sender, orderId, amount1, numberOfTimeIntervals); } ///@notice stop the execution of a long term order function cancelLongTermSwap(uint256 orderId) external lock execVirtualOrders { (address sellToken, uint256 unsoldAmount, address buyToken, uint256 purchasedAmount) = longTermOrders .cancelLongTermSwap(orderId); bool buyToken0 = buyToken == token0; twammReserve0 -= uint112(buyToken0 ? purchasedAmount : unsoldAmount); twammReserve1 -= uint112(buyToken0 ? unsoldAmount : purchasedAmount); // update order. Used for tracking / informational longTermOrders.orderMap[orderId].isComplete = true; // transfer to owner of order _safeTransfer(buyToken, msg.sender, purchasedAmount); _safeTransfer(sellToken, msg.sender, unsoldAmount); emit CancelLongTermOrder(msg.sender, orderId, sellToken, unsoldAmount, buyToken, purchasedAmount); } ///@notice withdraw proceeds from a long term swap function withdrawProceedsFromLongTermSwap( uint256 orderId ) external lock execVirtualOrders returns (bool is_expired, address rewardTkn, uint256 totalReward) { (address proceedToken, uint256 proceeds, bool orderExpired) = longTermOrders.withdrawProceedsFromLongTermSwap( orderId ); if (proceedToken == token0) { twammReserve0 -= uint112(proceeds); } else { twammReserve1 -= uint112(proceeds); } // update order. Used for tracking / informational if (orderExpired) longTermOrders.orderMap[orderId].isComplete = true; // transfer to owner of order _safeTransfer(proceedToken, msg.sender, proceeds); emit WithdrawProceedsFromLongTermOrder(msg.sender, orderId, proceedToken, proceeds, orderExpired); return (orderExpired, proceedToken, proceeds); } ///@notice execute virtual orders in the twamm, bring it up to the blockNumber passed in ///updates the TWAP if it is the first amm tx of the block function executeVirtualOrdersInternal(uint256 blockTimestamp) internal { if (newSwapsPaused) return; // skip twamm executions if (twammUpToDate()) return; // save gas LongTermOrdersLib.ExecuteVirtualOrdersResult memory result = LongTermOrdersLib.ExecuteVirtualOrdersResult( reserve0, reserve1, twammReserve0, twammReserve1, fee ); longTermOrders.executeVirtualOrdersUntilTimestamp(blockTimestamp, result); twammReserve0 = uint112(result.newTwammReserve0); twammReserve1 = uint112(result.newTwammReserve1); uint112 newReserve0 = uint112(result.newReserve0); uint112 newReserve1 = uint112(result.newReserve1); uint32 timeElapsed = _getTimeElapsed(); // update reserve0 and reserve1 if (timeElapsed > 0 && (newReserve0 != reserve0 || newReserve1 != reserve1)) { _update(newReserve0, newReserve1, reserve0, reserve1, timeElapsed); } else { reserve0 = newReserve0; reserve1 = newReserve1; } } ///@notice convenience function to execute virtual orders. Note that this already happens ///before most interactions with the AMM function executeVirtualOrders(uint256 blockTimestamp) public lock { // blockTimestamp is valid then execute the long term orders otherwise noop if (longTermOrders.lastVirtualOrderTimestamp < blockTimestamp && blockTimestamp <= block.timestamp) { executeVirtualOrdersInternal(blockTimestamp); } } /// --------------------------- /// ------- TWAMM Views ------- /// --------------------------- ///@notice util function for getting the next orderId function getNextOrderID() public view returns (uint256) { return longTermOrders.orderId; } ///@notice util function for checking if the twamm is up to date function twammUpToDate() public view returns (bool) { return block.timestamp == longTermOrders.lastVirtualOrderTimestamp; } function getReserveAfterTwamm( uint256 blockTimestamp ) public view returns ( uint112 _reserve0, uint112 _reserve1, uint256 lastVirtualOrderTimestamp, uint112 _twammReserve0, uint112 _twammReserve1 ) { lastVirtualOrderTimestamp = longTermOrders.lastVirtualOrderTimestamp; uint112 bal0 = reserve0 + twammReserve0; // save the balance of token0 uint112 bal1 = reserve1 + twammReserve1; // save the balance of token1 LongTermOrdersLib.ExecuteVirtualOrdersResult memory result = LongTermOrdersLib.ExecuteVirtualOrdersResult( reserve0, reserve1, twammReserve0, twammReserve1, fee ); longTermOrders.executeVirtualOrdersUntilTimestampView(blockTimestamp, result); _reserve0 = uint112(bal0 - result.newTwammReserve0); _reserve1 = uint112(bal1 - result.newTwammReserve1); _twammReserve0 = uint112(result.newTwammReserve0); _twammReserve1 = uint112(result.newTwammReserve1); } ///@notice returns the current state of the twamm function getTwammState() public view returns ( uint256 token0Rate, uint256 token1Rate, uint256 lastVirtualOrderTimestamp, uint256 orderTimeInterval_rtn, uint256 rewardFactorPool0, uint256 rewardFactorPool1 ) { token0Rate = longTermOrders.OrderPool0.currentSalesRate; token1Rate = longTermOrders.OrderPool1.currentSalesRate; lastVirtualOrderTimestamp = longTermOrders.lastVirtualOrderTimestamp; orderTimeInterval_rtn = orderTimeInterval; rewardFactorPool0 = longTermOrders.OrderPool0.rewardFactor; rewardFactorPool1 = longTermOrders.OrderPool1.rewardFactor; } ///@notice returns salesRates ending on this blockTimestamp function getTwammSalesRateEnding( uint256 _blockTimestamp ) public view returns (uint256 orderPool0SalesRateEnding, uint256 orderPool1SalesRateEnding) { uint256 lastExpiryTimestamp = _blockTimestamp - (_blockTimestamp % orderTimeInterval); orderPool0SalesRateEnding = longTermOrders.OrderPool0.salesRateEndingPerTimeInterval[lastExpiryTimestamp]; orderPool1SalesRateEnding = longTermOrders.OrderPool1.salesRateEndingPerTimeInterval[lastExpiryTimestamp]; } ///@notice returns reward factors at this blockTimestamp function getTwammRewardFactor( uint256 _blockTimestamp ) public view returns (uint256 rewardFactorPool0AtTimestamp, uint256 rewardFactorPool1AtTimestamp) { uint256 lastExpiryTimestamp = _blockTimestamp - (_blockTimestamp % orderTimeInterval); rewardFactorPool0AtTimestamp = longTermOrders.OrderPool0.rewardFactorAtTimestamp[lastExpiryTimestamp]; rewardFactorPool1AtTimestamp = longTermOrders.OrderPool1.rewardFactorAtTimestamp[lastExpiryTimestamp]; } ///@notice returns the twamm Order struct function getTwammOrder( uint256 orderId ) public view returns ( uint256 id, uint256 creationTimestamp, uint256 expirationTimestamp, uint256 saleRate, address owner, address sellTokenAddr, address buyTokenAddr ) { require(orderId < longTermOrders.orderId); // INVALID ORDERID LongTermOrdersLib.Order storage order = longTermOrders.orderMap[orderId]; return ( order.id, order.creationTimestamp, order.expirationTimestamp, order.saleRate, order.owner, order.sellTokenAddr, order.buyTokenAddr ); } ///@notice returns the twamm Order withdrawable proceeds // IMPORTANT: Can be stale. Should call executeVirtualOrders first or use getTwammOrderProceeds below. // You can also .call() withdrawProceedsFromLongTermSwap // blockTimestamp should be <= current function getTwammOrderProceedsView( uint256 orderId, uint256 blockTimestamp ) public view returns (bool orderExpired, uint256 totalReward) { require(orderId < longTermOrders.orderId); // INVALID ORDERID LongTermOrdersLib.OrderPool storage orderPool = LongTermOrdersLib.getOrderPool( longTermOrders, longTermOrders.orderMap[orderId].sellTokenAddr ); (orderExpired, totalReward) = LongTermOrdersLib.orderPoolGetProceeds(orderPool, orderId, blockTimestamp); } ///@notice returns the twamm Order withdrawable proceeds // Need to update the virtual orders first function getTwammOrderProceeds(uint256 orderId) public returns (bool orderExpired, uint256 totalReward) { executeVirtualOrders(block.timestamp); return getTwammOrderProceedsView(orderId, block.timestamp); } ///@notice Pauses the execution of existing twamm orders and the creation of new twamm orders // Only callable once by anyone once the pause is toggled on the factory function togglePauseNewSwaps() external { require(!newSwapsPaused && IFraxswapFactory(factory).globalPause()); // globalPause is enabled // Pause new swaps newSwapsPaused = true; } /* ========== RESTRICTED FUNCTIONS - Owner only ========== */ ///@notice sets the pool's lp fee function setFee(uint256 newFee) external execVirtualOrders feeCheck(newFee) onlyOwnerOrFactory { fee = 10_000 - newFee; // newFee should be in basis points (100th of a pecent). 30 = 0.3% emit LpFeeUpdated(newFee); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ 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}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `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: * ``` * 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: BUSL-1.1 pragma solidity 0.8.23; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================== FraxswapERC20 =========================== // ==================================================================== /// @notice Fraxswap ERC-20 /// @author Frax Finance (https://github.com/FraxFinance) contract FraxswapERC20 { string public constant name = "Fraxswap V2"; string public constant symbol = "FS-V2"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; bytes32 public immutable DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint256) public nonces; event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); constructor() { uint256 chainId = block.chainid; DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes("1")), chainId, address(this) ) ); } function _mint(address to, uint256 value) internal { totalSupply = totalSupply + value; balanceOf[to] = balanceOf[to] + value; emit Transfer(address(0), to, value); } function _burn(address from, uint256 value) internal { balanceOf[from] = balanceOf[from] - value; totalSupply = totalSupply - value; emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint256 value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint256 value) private { balanceOf[from] = balanceOf[from] - value; balanceOf[to] = balanceOf[to] + value; emit Transfer(from, to, value); } function approve(address spender, uint256 value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint256 value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint256 value) external returns (bool) { if (allowance[from][msg.sender] != type(uint256).max) { allowance[from][msg.sender] = allowance[from][msg.sender] - value; } _transfer(from, to, value); return true; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { require(deadline >= block.timestamp); // EXPIRED bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner); // INVALID_SIGNATURE _approve(owner, spender, value); } }
// SPDX-Licence-Identifier: MIT pragma solidity ^0.8.0; // a library for performing various math operations library Math { function min(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } }
// SPDX-Licence-Identifier: MIT pragma solidity ^0.8.0; // 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) { 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) { z = x / uint224(y); } }
pragma solidity ^0.8.0; import { IUniswapV2Factory } from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; interface IFraxswapFactory is IUniswapV2Factory { function createPair(address tokenA, address tokenB, uint256 fee) external returns (address pair); function globalPause() external view returns (bool); function toggleGlobalPause() external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; // ==================================================================== // | ______ _______ | // | / _____________ __ __ / ____(_____ ____ _____ ________ | // | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ | // | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ | // | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ | // | | // ==================================================================== // ========================= LongTermOrdersLib ======================== // ==================================================================== // TWAMM long term order execution logic /// @notice This library handles the state and execution of long term orders. library LongTermOrdersLib { using LongTermOrdersLib for OrderPool; /// --------------------------- /// ---------- Events --------- /// --------------------------- ///@notice An event emitted when virtual orders are executed event VirtualOrderExecution( uint256 blockTimestamp, uint256 blockTimestampElapsed, uint256 newReserve0, uint256 newReserve1, uint256 newTwammReserve0, uint256 newTwammReserve1, uint256 token0Bought, uint256 token1Bought, uint256 token0Sold, uint256 token1Sold ); /// --------------------------- /// ----- LongTerm Orders ----- /// --------------------------- uint112 internal constant SELL_RATE_ADDITIONAL_PRECISION = 1_000_000; uint256 internal constant Q112 = 2 ** 112; uint256 internal constant orderTimeInterval = 3600; // sync with FraxswapPair.sol ///@notice information associated with a long term order ///fields should NOT be changed after Order struct is created struct Order { uint256 id; uint256 creationTimestamp; uint256 expirationTimestamp; uint256 saleRate; address owner; address sellTokenAddr; address buyTokenAddr; bool isComplete; } ///@notice structure contains full state related to long term orders struct LongTermOrders { ///@notice last virtual orders were executed immediately before this block.timestamp uint256 lastVirtualOrderTimestamp; ///@notice token0 being traded in amm address token0; ///@notice mapping from token address to pool that is selling that token ///we maintain two order pools, one for each token that is tradable in the AMM OrderPool OrderPool0; OrderPool OrderPool1; ///@notice incrementing counter for order ids, this is the next order id uint256 orderId; ///@notice mapping from order ids to Orders mapping(uint256 => Order) orderMap; } struct ExecuteVirtualOrdersResult { uint112 newReserve0; uint112 newReserve1; uint256 newTwammReserve0; uint256 newTwammReserve1; uint256 fee; } ///@notice initialize state function initialize(LongTermOrders storage longTermOrders, address token0) internal { longTermOrders.token0 = token0; longTermOrders.lastVirtualOrderTimestamp = block.timestamp; } ///@notice get the OrderPool for this token function getOrderPool( LongTermOrders storage longTermOrders, address token ) internal view returns (OrderPool storage orderPool) { orderPool = token == longTermOrders.token0 ? longTermOrders.OrderPool0 : longTermOrders.OrderPool1; } ///@notice adds long term swap to order pool function performLongTermSwap( LongTermOrders storage longTermOrders, address from, address to, uint256 amount, uint256 numberOfTimeIntervals ) internal returns (uint256) { // make sure to update virtual order state (before calling this function) //determine the selling rate based on number of blocks to expiry and total amount uint256 currentTime = block.timestamp; uint256 lastExpiryTimestamp = currentTime - (currentTime % orderTimeInterval); uint256 orderExpiry = orderTimeInterval * (numberOfTimeIntervals + 1) + lastExpiryTimestamp; uint256 sellingRate = (SELL_RATE_ADDITIONAL_PRECISION * amount) / (orderExpiry - currentTime); require(sellingRate > 0); // tokenRate cannot be zero //add order to correct pool OrderPool storage orderPool = getOrderPool(longTermOrders, from); orderPoolDepositOrder(orderPool, longTermOrders.orderId, sellingRate, orderExpiry); //add to order map longTermOrders.orderMap[longTermOrders.orderId] = Order( longTermOrders.orderId, currentTime, orderExpiry, sellingRate, msg.sender, from, to, false ); return longTermOrders.orderId++; } ///@notice cancel long term swap, pay out unsold tokens and well as purchased tokens function cancelLongTermSwap( LongTermOrders storage longTermOrders, uint256 orderId ) internal returns (address sellToken, uint256 unsoldAmount, address buyToken, uint256 purchasedAmount) { // make sure to update virtual order state (before calling this function) Order storage order = longTermOrders.orderMap[orderId]; buyToken = order.buyTokenAddr; sellToken = order.sellTokenAddr; OrderPool storage orderPool = getOrderPool(longTermOrders, sellToken); (unsoldAmount, purchasedAmount) = orderPoolCancelOrder( orderPool, orderId, longTermOrders.lastVirtualOrderTimestamp ); require(order.owner == msg.sender && (unsoldAmount > 0 || purchasedAmount > 0)); // owner and amounts check } ///@notice withdraw proceeds from a long term swap (can be expired or ongoing) function withdrawProceedsFromLongTermSwap( LongTermOrders storage longTermOrders, uint256 orderId ) internal returns (address proceedToken, uint256 proceeds, bool orderExpired) { // make sure to update virtual order state (before calling this function) Order storage order = longTermOrders.orderMap[orderId]; proceedToken = order.buyTokenAddr; OrderPool storage orderPool = getOrderPool(longTermOrders, order.sellTokenAddr); (proceeds, orderExpired) = orderPoolWithdrawProceeds( orderPool, orderId, longTermOrders.lastVirtualOrderTimestamp ); require(order.owner == msg.sender && proceeds > 0); // owner and amounts check } ///@notice computes the result of virtual trades by the token pools function computeVirtualBalances( uint256 token0Start, uint256 token1Start, uint256 token0In, uint256 token1In, uint256 fee ) internal pure returns (uint256 token0Out, uint256 token1Out) { token0Out = 0; token1Out = 0; //if no tokens are sold to the pool, we don't need to execute any orders if (token0In < 2 && token1In < 2) { // do nothing } //in the case where only one pool is selling, we just perform a normal swap else if (token0In < 2) { //constant product formula uint256 token1InWithFee = token1In * fee; token0Out = (token0Start * token1InWithFee) / ((token1Start * 10_000) + token1InWithFee); } else if (token1In < 2) { //constant product formula uint256 token0InWithFee = token0In * fee; token1Out = (token1Start * token0InWithFee) / ((token0Start * 10_000) + token0InWithFee); } //when both pools sell, we use the TWAMM formula else { uint256 newToken0 = token0Start + ((token0In * fee) / 10_000); uint256 newToken1 = token1Start + ((token1In * fee) / 10_000); token0Out = newToken0 - ((token1Start * (newToken0)) / (newToken1)); token1Out = newToken1 - ((token0Start * (newToken1)) / (newToken0)); } } ///@notice executes all virtual orders between current lastVirtualOrderTimestamp and blockTimestamp //also handles orders that expire at end of final blockTimestamp. This assumes that no orders expire inside the given interval function executeVirtualTradesAndOrderExpiries( ExecuteVirtualOrdersResult memory reserveResult, uint256 token0SellAmount, uint256 token1SellAmount ) private view returns (uint256 token0Out, uint256 token1Out) { //initial amm balance uint256 bal0 = reserveResult.newReserve0 + reserveResult.newTwammReserve0; uint256 bal1 = reserveResult.newReserve1 + reserveResult.newTwammReserve1; //updated balances from sales (token0Out, token1Out) = computeVirtualBalances( reserveResult.newReserve0, reserveResult.newReserve1, token0SellAmount, token1SellAmount, reserveResult.fee ); //update balances reserves reserveResult.newTwammReserve0 = reserveResult.newTwammReserve0 + token0Out - token0SellAmount; reserveResult.newTwammReserve1 = reserveResult.newTwammReserve1 + token1Out - token1SellAmount; reserveResult.newReserve0 = uint112(bal0 - reserveResult.newTwammReserve0); // calculate reserve0 incl LP fees reserveResult.newReserve1 = uint112(bal1 - reserveResult.newTwammReserve1); // calculate reserve1 incl LP fees } ///@notice executes all virtual orders until blockTimestamp is reached. function executeVirtualOrdersUntilTimestamp( LongTermOrders storage longTermOrders, uint256 blockTimestamp, ExecuteVirtualOrdersResult memory reserveResult ) internal { uint256 lastVirtualOrderTimestampLocal = longTermOrders.lastVirtualOrderTimestamp; // save gas uint256 nextExpiryBlockTimestamp = lastVirtualOrderTimestampLocal - (lastVirtualOrderTimestampLocal % orderTimeInterval) + orderTimeInterval; //iterate through time intervals eligible for order expiries, moving state forward OrderPool storage orderPool0 = longTermOrders.OrderPool0; OrderPool storage orderPool1 = longTermOrders.OrderPool1; while (nextExpiryBlockTimestamp <= blockTimestamp) { // Optimization for skipping blocks with no expiry if ( orderPool0.salesRateEndingPerTimeInterval[nextExpiryBlockTimestamp] > 0 || orderPool1.salesRateEndingPerTimeInterval[nextExpiryBlockTimestamp] > 0 ) { //amount sold from virtual trades uint256 blockTimestampElapsed = nextExpiryBlockTimestamp - lastVirtualOrderTimestampLocal; uint256 token0SellAmount = (orderPool0.currentSalesRate * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; uint256 token1SellAmount = (orderPool1.currentSalesRate * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; (uint256 token0Out, uint256 token1Out) = executeVirtualTradesAndOrderExpiries( reserveResult, token0SellAmount, token1SellAmount ); //distribute proceeds to pools. make sure to call this before orderPoolUpdateStateFromTimestampExpiry. orderPoolDistributePayment(orderPool0, token1Out); orderPoolDistributePayment(orderPool1, token0Out); //handle orders expiring at end of interval. call orderPoolDistributePayment before calling this. orderPoolUpdateStateFromTimestampExpiry(orderPool0, nextExpiryBlockTimestamp); orderPoolUpdateStateFromTimestampExpiry(orderPool1, nextExpiryBlockTimestamp); emit VirtualOrderExecution( nextExpiryBlockTimestamp, blockTimestampElapsed, reserveResult.newReserve0, reserveResult.newReserve1, reserveResult.newTwammReserve0, reserveResult.newTwammReserve1, token0Out, token1Out, token0SellAmount, token1SellAmount ); lastVirtualOrderTimestampLocal = nextExpiryBlockTimestamp; } nextExpiryBlockTimestamp += orderTimeInterval; } //finally, move state to current blockTimestamp if necessary if (lastVirtualOrderTimestampLocal != blockTimestamp) { //amount sold from virtual trades uint256 blockTimestampElapsed = blockTimestamp - lastVirtualOrderTimestampLocal; uint256 token0SellAmount = (orderPool0.currentSalesRate * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; uint256 token1SellAmount = (orderPool1.currentSalesRate * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; (uint256 token0Out, uint256 token1Out) = executeVirtualTradesAndOrderExpiries( reserveResult, token0SellAmount, token1SellAmount ); emit VirtualOrderExecution( blockTimestamp, blockTimestampElapsed, reserveResult.newReserve0, reserveResult.newReserve1, reserveResult.newTwammReserve0, reserveResult.newTwammReserve1, token0Out, token1Out, token0SellAmount, token1SellAmount ); //distribute proceeds to pools orderPoolDistributePayment(orderPool0, token1Out); orderPoolDistributePayment(orderPool1, token0Out); // skip call to orderPoolUpdateStateFromTimestampExpiry, this will not be an expiry timestamp. save gas } longTermOrders.lastVirtualOrderTimestamp = blockTimestamp; } ///@notice executes all virtual orders until blockTimestamp is reached (AS A VIEW) function executeVirtualOrdersUntilTimestampView( LongTermOrders storage longTermOrders, uint256 blockTimestamp, ExecuteVirtualOrdersResult memory reserveResult ) internal view { uint256 lastVirtualOrderTimestampLocal = longTermOrders.lastVirtualOrderTimestamp; // save gas uint256 nextExpiryBlockTimestamp = lastVirtualOrderTimestampLocal - (lastVirtualOrderTimestampLocal % orderTimeInterval) + orderTimeInterval; //iterate through time intervals eligible for order expiries, moving state forward OrderPool storage orderPool0 = longTermOrders.OrderPool0; OrderPool storage orderPool1 = longTermOrders.OrderPool1; // currentSales for each pool is mutated in the non-view (mutate locally) uint256 currentSalesRate0 = orderPool0.currentSalesRate; uint256 currentSalesRate1 = orderPool1.currentSalesRate; while (nextExpiryBlockTimestamp <= blockTimestamp) { // Optimization for skipping blocks with no expiry if ( orderPool0.salesRateEndingPerTimeInterval[nextExpiryBlockTimestamp] > 0 || orderPool1.salesRateEndingPerTimeInterval[nextExpiryBlockTimestamp] > 0 ) { //amount sold from virtual trades uint256 blockTimestampElapsed = nextExpiryBlockTimestamp - lastVirtualOrderTimestampLocal; uint256 token0SellAmount = (currentSalesRate0 * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; uint256 token1SellAmount = (currentSalesRate1 * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; executeVirtualTradesAndOrderExpiries(reserveResult, token0SellAmount, token1SellAmount); currentSalesRate0 -= orderPool0.salesRateEndingPerTimeInterval[nextExpiryBlockTimestamp]; currentSalesRate1 -= orderPool1.salesRateEndingPerTimeInterval[nextExpiryBlockTimestamp]; lastVirtualOrderTimestampLocal = nextExpiryBlockTimestamp; } nextExpiryBlockTimestamp += orderTimeInterval; } //finally, move state to current blockTimestamp if necessary if (lastVirtualOrderTimestampLocal != blockTimestamp) { //amount sold from virtual trades uint256 blockTimestampElapsed = blockTimestamp - lastVirtualOrderTimestampLocal; uint256 token0SellAmount = (currentSalesRate0 * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; uint256 token1SellAmount = (currentSalesRate1 * blockTimestampElapsed) / SELL_RATE_ADDITIONAL_PRECISION; executeVirtualTradesAndOrderExpiries(reserveResult, token0SellAmount, token1SellAmount); } } /// --------------------------- /// -------- OrderPool -------- /// --------------------------- ///@notice An Order Pool is an abstraction for a pool of long term orders that sells a token at a constant rate to the embedded AMM. ///the order pool handles the logic for distributing the proceeds from these sales to the owners of the long term orders through a modified ///version of the staking algorithm from https://uploads-ssl.webflow.com/5ad71ffeb79acc67c8bcdaba/5ad8d1193a40977462982470_scalable-reward-distribution-paper.pdf ///@notice you can think of this as a staking pool where all long term orders are staked. /// The pool is paid when virtual long term orders are executed, and each order is paid proportionally /// by the order's sale rate per time intervals struct OrderPool { ///@notice current rate that tokens are being sold (per time interval) uint256 currentSalesRate; ///@notice sum of (salesProceeds_k / salesRate_k) over every period k. Stored as a fixed precision floating point number uint256 rewardFactor; ///@notice this maps time interval numbers to the cumulative sales rate of orders that expire on that block (time interval) mapping(uint256 => uint256) salesRateEndingPerTimeInterval; ///@notice map order ids to the block timestamp in which they expire mapping(uint256 => uint256) orderExpiry; ///@notice map order ids to their sales rate mapping(uint256 => uint256) salesRate; ///@notice reward factor per order at time of submission mapping(uint256 => uint256) rewardFactorAtSubmission; ///@notice reward factor at a specific time interval mapping(uint256 => uint256) rewardFactorAtTimestamp; } ///@notice distribute payment amount to pool (in the case of TWAMM, proceeds from trades against amm) function orderPoolDistributePayment(OrderPool storage orderPool, uint256 amount) internal { if (orderPool.currentSalesRate != 0) { unchecked { // Addition is with overflow orderPool.rewardFactor += (amount * Q112 * SELL_RATE_ADDITIONAL_PRECISION) / orderPool.currentSalesRate; } } } ///@notice deposit an order into the order pool. function orderPoolDepositOrder( OrderPool storage orderPool, uint256 orderId, uint256 amountPerInterval, uint256 orderExpiry ) internal { orderPool.currentSalesRate += amountPerInterval; orderPool.rewardFactorAtSubmission[orderId] = orderPool.rewardFactor; orderPool.orderExpiry[orderId] = orderExpiry; orderPool.salesRate[orderId] = amountPerInterval; orderPool.salesRateEndingPerTimeInterval[orderExpiry] += amountPerInterval; } ///@notice when orders expire after a given timestamp, we need to update the state of the pool function orderPoolUpdateStateFromTimestampExpiry(OrderPool storage orderPool, uint256 blockTimestamp) internal { orderPool.currentSalesRate -= orderPool.salesRateEndingPerTimeInterval[blockTimestamp]; orderPool.rewardFactorAtTimestamp[blockTimestamp] = orderPool.rewardFactor; } ///@notice cancel order and remove from the order pool function orderPoolCancelOrder( OrderPool storage orderPool, uint256 orderId, uint256 blockTimestamp ) internal returns (uint256 unsoldAmount, uint256 purchasedAmount) { uint256 expiry = orderPool.orderExpiry[orderId]; require(expiry > blockTimestamp); //calculate amount that wasn't sold, and needs to be returned uint256 salesRate = orderPool.salesRate[orderId]; unsoldAmount = ((expiry - blockTimestamp) * salesRate) / SELL_RATE_ADDITIONAL_PRECISION; //calculate amount of other token that was purchased unchecked { // subtraction is with underflow purchasedAmount = (((orderPool.rewardFactor - orderPool.rewardFactorAtSubmission[orderId]) * salesRate) / SELL_RATE_ADDITIONAL_PRECISION) / Q112; } //update state orderPool.currentSalesRate -= salesRate; orderPool.salesRate[orderId] = 0; orderPool.orderExpiry[orderId] = 0; orderPool.salesRateEndingPerTimeInterval[expiry] -= salesRate; } ///@notice withdraw proceeds from pool for a given order. This can be done before or after the order has expired. //If the order has expired, we calculate the reward factor at time of expiry. If order has not yet expired, we //use current reward factor, and update the reward factor at time of staking (effectively creating a new order) function orderPoolWithdrawProceeds( OrderPool storage orderPool, uint256 orderId, uint256 blockTimestamp ) internal returns (uint256 totalReward, bool orderExpired) { (orderExpired, totalReward) = orderPoolGetProceeds(orderPool, orderId, blockTimestamp); if (orderExpired) { //remove stake orderPool.salesRate[orderId] = 0; } //if order has not yet expired, we just adjust the start else { orderPool.rewardFactorAtSubmission[orderId] = orderPool.rewardFactor; } } ///@notice view function for getting the current proceeds for the given order function orderPoolGetProceeds( OrderPool storage orderPool, uint256 orderId, uint256 blockTimestamp ) internal view returns (bool orderExpired, uint256 totalReward) { uint256 stakedAmount = orderPool.salesRate[orderId]; require(stakedAmount > 0); uint256 orderExpiry = orderPool.orderExpiry[orderId]; uint256 rewardFactorAtSubmission = orderPool.rewardFactorAtSubmission[orderId]; //if order has expired, we need to calculate the reward factor at expiry if (blockTimestamp >= orderExpiry) { uint256 rewardFactorAtExpiry = orderPool.rewardFactorAtTimestamp[orderExpiry]; unchecked { // subtraction is with underflow totalReward = (((rewardFactorAtExpiry - rewardFactorAtSubmission) * stakedAmount) / SELL_RATE_ADDITIONAL_PRECISION) / Q112; } orderExpired = true; } else { unchecked { // subtraction is with underflow totalReward = (((orderPool.rewardFactor - rewardFactorAtSubmission) * stakedAmount) / SELL_RATE_ADDITIONAL_PRECISION) / Q112; } orderExpired = false; } } }
pragma solidity >=0.5.0; interface IUniswapV2Callee { function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 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 ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-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 ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 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); }
pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
{ "remappings": [ "frax-std/=node_modules/frax-standard-solidity/src/", "@prb/test/=node_modules/@prb/test/", "forge-std/=node_modules/forge-std/src/", "ds-test/=node_modules/ds-test/src/", "@uniswap/v2-core/=lib/v2-core/", "@uniswap/v2-periphery/=lib/v2-periphery/", "@uniswap/v3-core/=lib/v3-core/", "@uniswap/v3-periphery/=lib/v3-periphery/", "@chainlink/=node_modules/@chainlink/", "@eth-optimism/=node_modules/@eth-optimism/", "@openzeppelin/=node_modules/@openzeppelin/", "frax-standard-solidity/=node_modules/frax-standard-solidity/", "solidity-bytes-utils/=node_modules/solidity-bytes-utils/", "v2-core/=lib/v2-core/contracts/", "v2-periphery/=lib/v2-periphery/contracts/", "v3-core/=lib/v3-core/", "v3-periphery/=lib/v3-periphery/contracts/" ], "optimizer": { "enabled": true, "runs": 1000000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": false }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"IdenticalAddress","type":"error"},{"inputs":[],"name":"PairExists","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"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"},{"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":"uint256","name":"fee","type":"uint256"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"pair","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalPause","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeToSetter","type":"address"}],"name":"setFeeToSetter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleGlobalPause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100c95760003560e01c80636b600d1c11610081578063e6a439051161005b578063e6a439051461019f578063f12d54d8146101e0578063f46901ed1461021557600080fd5b80636b600d1c14610166578063a2e74af614610179578063c9c653961461018c57600080fd5b80631e3dd18b116100b25780631e3dd18b1461013857806346b3f9131461014b578063574f2ba31461015557600080fd5b8063017e7e58146100ce578063094b741514610118575b600080fd5b6000546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6001546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b6100ee610146366004610779565b610228565b61015361025f565b005b60035460405190815260200161010f565b6100ee6101743660046107bb565b6102ec565b6101536101873660046107f7565b610681565b6100ee61019a366004610812565b6106ec565b6100ee6101ad366004610812565b600260209081526000928352604080842090915290825290205473ffffffffffffffffffffffffffffffffffffffff1681565b6001546102059074010000000000000000000000000000000000000000900460ff1681565b604051901515815260200161010f565b6101536102233660046107f7565b610701565b6003818154811061023857600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60015473ffffffffffffffffffffffffffffffffffffffff16331461028357600080fd5b60015474010000000000000000000000000000000000000000900460ff16156102ab57600080fd5b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b60008273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610353576040517f065af08d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1610610390578486610393565b85855b909250905073ffffffffffffffffffffffffffffffffffffffff82166103e5576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff828116600090815260026020908152604080832085851684529091529020541615610451576040517f3d77e89100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000604051806020016104639061076c565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f9091011660408190527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606086811b8216602084015285901b166034820152909150600090604801604051602081830303815290604052805190602001209050808251602084016000f56040517f1794bb3c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015285811660248301526044820189905291965090861690631794bb3c90606401600060405180830381600087803b15801561057357600080fd5b505af1158015610587573d6000803e3d6000fd5b5050505073ffffffffffffffffffffffffffffffffffffffff84811660008181526002602081815260408084208987168086529083528185208054978d167fffffffffffffffffffffffff000000000000000000000000000000000000000098891681179091559383528185208686528352818520805488168517905560038054600181018255958190527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9095018054909716841790965592548351928352908201527f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9910160405180910390a3505050509392505050565b60015473ffffffffffffffffffffffffffffffffffffffff1633146106a557600080fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60006106fa8383601e6102ec565b9392505050565b60015473ffffffffffffffffffffffffffffffffffffffff16331461072557600080fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61574e8061084683390190565b60006020828403121561078b57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146107b657600080fd5b919050565b6000806000606084860312156107d057600080fd5b6107d984610792565b92506107e760208501610792565b9150604084013590509250925092565b60006020828403121561080957600080fd5b6106fa82610792565b6000806040838503121561082557600080fd5b61082e83610792565b915061083c60208401610792565b9050925092905056fe60a06040526001601f5534801561001557600080fd5b50604080518082018252600b81526a233930bc39bbb0b8102b1960a91b6020918201528151808301835260018152603160f81b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f918101919091527f736229277fc30c9d8d02e6316edaeb1ea2708ef3d3c39aa1877ab5a97793cc30918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015246608082018190523060a08301529060c00160408051808303601f1901815291905280516020909101206080525060188054610100600160a81b03191633610100021790556080516156226200012c6000396000818161066f0152612ea201526156226000f3fe608060405234801561001057600080fd5b50600436106103835760003560e01c80637464fc3d116101de57806396f291271161010f578063c9738a0d116100ad578063ddca3f431161007c578063ddca3f4314610a5e578063e852bc2e14610a67578063f140a35a14610aa6578063fff6cae914610ab957600080fd5b8063c9738a0d146109ed578063d21220a714610a00578063d505accf14610a20578063dd62ed3e14610a3357600080fd5b8063ba9a7a56116100e9578063ba9a7a561461095c578063bc25cf7714610965578063bcaa64ea14610978578063c45a0155146109c857600080fd5b806396f2912714610937578063a1462c191461093f578063a9059cbb1461094957600080fd5b806381ca79981161017c57806387353fed1161015657806387353fed146108a857806389afcb44146108c857806395d89b41146108db5780639610c5f11461091757600080fd5b806381ca79981461083d57806381fd0a4614610850578063852a8dbe1461089557600080fd5b806378dd0298116101b857806378dd0298146107e15780637d316e28146107e95780637ecebe00146108155780637fa2ee6e1461083557600080fd5b80637464fc3d14610799578063748fc63b146107a2578063753bfd4b146107ab57600080fd5b80632c8488da116102b85780634894c53c116102565780635a3d5493116102305780635a3d54931461074b57806369fe0e2d146107535780636a6278421461076657806370a082311461077957600080fd5b80634894c53c146106cc5780634adc77c2146106df5780635909c0d51461074357600080fd5b8063313ce56711610292578063313ce567146106505780633644e5151461066a578063422fff051461069157806343c99081146106b957600080fd5b80632c8488da146105ec5780632e0ae3751461061657806330adf81f1461062957600080fd5b80631125f13f116103255780631f4f5b42116102ff5780631f4f5b421461058b5780631fc2fa7f1461059e57806323b872dd146105ab57806327e73836146105be57600080fd5b80631125f13f1461054e5780631794bb3c1461056f57806318160ddd1461058257600080fd5b8063094cf14911610361578063094cf14914610455578063095ea7b3146104ad5780630dfe1681146104d05780630ece72361461051557600080fd5b8063022c0d9f1461038857806306fdde031461039d5780630902f1ac146103ef575b600080fd5b61039b610396366004614f0f565b610ac1565b005b6103d96040518060400160405280600b81526020017f467261787377617020563200000000000000000000000000000000000000000081525081565b6040516103e69190614fc9565b60405180910390f35b601b54604080516dffffffffffffffffffffffffffff80841682526e01000000000000000000000000000084041660208201527c010000000000000000000000000000000000000000000000000000000090920463ffffffff16908201526060016103e6565b61045d611102565b604080516dffffffffffffffffffffffffffff9788168152958716602087015263ffffffff90941693850193909352908416606084015292909216608082015260a081019190915260c0016103e6565b6104c06104bb36600461501a565b611192565b60405190151581526020016103e6565b6019546104f09073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016103e6565b60165461052f906dffffffffffffffffffffffffffff1681565b6040516dffffffffffffffffffffffffffff90911681526020016103e6565b61056161055c366004615046565b6111a9565b6040519081526020016103e6565b61039b61057d366004615076565b6112e9565b61056160005481565b61039b6105993660046150b7565b61140d565b6018546104c09060ff1681565b6104c06105b9366004615076565b611607565b6105d16105cc3660046150b7565b6116e1565b604080519384526020840192909252908201526060016103e6565b6105ff6105fa3660046150d0565b611714565b6040805192151583526020830191909152016103e6565b61039b6106243660046150b7565b611775565b6105617f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b610658601281565b60405160ff90911681526020016103e6565b6105617f000000000000000000000000000000000000000000000000000000000000000081565b6106a461069f3660046150b7565b6117b0565b604080519283526020830191909152016103e6565b6106a46106c73660046150b7565b6117f0565b6105ff6106da3660046150b7565b611830565b6106f26106ed3660046150b7565b61184f565b60408051978852602088019690965294860193909352606085019190915273ffffffffffffffffffffffffffffffffffffffff908116608085015290811660a08401521660c082015260e0016103e6565b6105616118cc565b610561611913565b61039b6107613660046150b7565b61195a565b6105616107743660046150f2565b611aa2565b6105616107873660046150f2565b60016020526000908152604090205481565b610561601c5481565b610561610e1081565b6105616107b93660046150f2565b73ffffffffffffffffffffffffffffffffffffffff166000908152601d602052604090205490565b601454610561565b60165461052f906e01000000000000000000000000000090046dffffffffffffffffffffffffffff1681565b6105616108233660046150f2565b60036020526000908152604090205481565b601e54610561565b61056161084b3660046150d0565b611e2f565b61086361085e3660046150b7565b611fb4565b60408051931515845273ffffffffffffffffffffffffffffffffffffffff9092166020840152908201526060016103e6565b6105616108a336600461501a565b612195565b6108bb6108b636600461510f565b6121c6565b6040516103e69190615144565b6106a46108d63660046150f2565b6123fc565b6103d96040518060400160405280600581526020017f46532d563200000000000000000000000000000000000000000000000000000081525081565b61092a6109253660046150f2565b6128af565b6040516103e691906151f3565b61039b612928565b60045442146104c0565b6104c061095736600461501a565b6129fd565b6105616103e881565b61039b6109733660046150f2565b612a0a565b61098b6109863660046150b7565b612bd8565b604080516dffffffffffffffffffffffffffff9687168152948616602086015284019290925283166060830152909116608082015260a0016103e6565b6018546104f090610100900473ffffffffffffffffffffffffffffffffffffffff1681565b6105616109fb3660046150d0565b612d12565b601a546104f09073ffffffffffffffffffffffffffffffffffffffff1681565b61039b610a2e366004615237565b612e6c565b610561610a413660046152ae565b600260209081526000928352604080842090915290825290205481565b61056160175481565b600654600d54600454600754600e5460408051958652602086019490945292840191909152610e106060840152608083015260a082015260c0016103e6565b610561610ab4366004615046565b6130b8565b61039b6131f2565b601f54600114610ad057600080fd5b6000601f55610ade426133bc565b6000851180610aed5750600084115b610b23576040517f42301c2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610b7f601b546dffffffffffffffffffffffffffff808216926e01000000000000000000000000000083049091169163ffffffff7c01000000000000000000000000000000000000000000000000000000009091041690565b5091509150816dffffffffffffffffffffffffffff1687108015610bb25750806dffffffffffffffffffffffffffff1686105b610c06576040517f6243da720000000000000000000000000000000000000000000000000000000081526dffffffffffffffffffffffffffff80841660048301528216602482015260440160405180910390fd5b601954601a54600091829173ffffffffffffffffffffffffffffffffffffffff918216919081169089168214801590610c6b57508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b610ca1576040517f591c75ef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a15610cb257610cb2828a8d6135ac565b8915610cc357610cc3818a8c6135ac565b8615610d56576040517f10d1e85c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a16906310d1e85c90610d239033908f908f908e908e906004016152dc565b600060405180830381600087803b158015610d3d57600080fd5b505af1158015610d51573d6000803e3d6000fd5b505050505b6016546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526dffffffffffffffffffffffffffff9091169073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015610dd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfa9190615354565b610e04919061539c565b6016546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529195506e01000000000000000000000000000090046dffffffffffffffffffffffffffff169073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015610e97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebb9190615354565b610ec5919061539c565b92505050600089856dffffffffffffffffffffffffffff16610ee7919061539c565b8311610ef4576000610f18565b610f0e8a6dffffffffffffffffffffffffffff871661539c565b610f18908461539c565b90506000610f368a6dffffffffffffffffffffffffffff871661539c565b8311610f43576000610f67565b610f5d8a6dffffffffffffffffffffffffffff871661539c565b610f67908461539c565b90506000821180610f785750600081115b610fae576040517f098fb56100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000601754612710610fc0919061539c565b90506000610fce82856153af565b610fda876127106153af565b610fe4919061539c565b90506000610ff283856153af565b610ffe876127106153af565b611008919061539c565b90506110276dffffffffffffffffffffffffffff808a16908b166153af565b611035906305f5e1006153af565b61103f82846153af565b1015611077576040517f19886c4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505061108e848488886110896136e8565b61372b565b60408051838152602081018390529081018c9052606081018b905273ffffffffffffffffffffffffffffffffffffffff8a169033907fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229060800160405180910390a350506001601f55505050505050505050565b601b54601654601754600092839283928392839283926dffffffffffffffffffffffffffff808416936e0100000000000000000000000000008082048316947c010000000000000000000000000000000000000000000000000000000090920463ffffffff16938383169391909204169061117f9061271061539c565b949b939a50919850965094509092509050565b600061119f3384846139f6565b5060015b92915050565b6019546000908190819073ffffffffffffffffffffffffffffffffffffffff85811691161461120057601b546dffffffffffffffffffffffffffff808216916e010000000000000000000000000000900416611229565b601b546dffffffffffffffffffffffffffff6e0100000000000000000000000000008204811691165b9150915060008511801561124d57506000826dffffffffffffffffffffffffffff16115b801561126957506000816dffffffffffffffffffffffffffff16115b61127257600080fd5b600061128e866dffffffffffffffffffffffffffff85166153af565b61129a906127106153af565b9050600060175487846dffffffffffffffffffffffffffff166112bd919061539c565b6112c791906153af565b90506112d381836153f5565b6112de906001615409565b979650505050505050565b806000811180156112fa5750606581105b61130357600080fd5b601854610100900473ffffffffffffffffffffffffffffffffffffffff16331461132c57600080fd5b6019805473ffffffffffffffffffffffffffffffffffffffff8087167fffffffffffffffffffffffff000000000000000000000000000000000000000092831617909255601a80549286169290911691909117905561138d8261271061539c565b601755600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055426004556040518281527f2ade3fe6cec488ed9b13e36f5179edfbca9998fecc5926cf57335558671d5f959060200160405180910390a150505050565b601f5460011461141c57600080fd5b6000601f5561142a426133bc565b600080808061143a600486613a65565b6019549397509195509350915073ffffffffffffffffffffffffffffffffffffffff8084169116148061146d578361146f565b815b601680546000906114919084906dffffffffffffffffffffffffffff1661541c565b92506101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff160217905550806114ce57816114d0565b835b60168054600e906115049084906e01000000000000000000000000000090046dffffffffffffffffffffffffffff1661541c565b82546dffffffffffffffffffffffffffff9182166101009390930a928302919092021990911617905550600086815260156020526040902060060180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790556115878333846135ac565b6115928533866135ac565b6040805187815273ffffffffffffffffffffffffffffffffffffffff878116602083015291810186905290841660608201526080810183905233907f3c5d5e0947e8b8050cf53e91c7496de2499da1b7613ec86b8fda8705789663909060a00160405180910390a250506001601f5550505050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146116cc5773ffffffffffffffffffffffffffffffffffffffff8416600090815260026020908152604080832033845290915290205461169a90839061539c565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b6116d7848484613b06565b5060019392505050565b601e81815481106116f157600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b600080600460100154841061172857600080fd5b60008481526015602052604081206005015461175c9060049073ffffffffffffffffffffffffffffffffffffffff16613bd5565b9050611769818686613c11565b90969095509350505050565b601f5460011461178457600080fd5b6000601f556004548111801561179a5750428111155b156117a8576117a8816133bc565b506001601f55565b600080806117c0610e108561544a565b6117ca908561539c565b600090815260086020908152604080832054600f90925290912054909590945092505050565b60008080611800610e108561544a565b61180a908561539c565b6000908152600c6020908152604080832054601390925290912054909590945092505050565b60008061183c42611775565b6118468342611714565b91509150915091565b6000806000806000806000600460100154881061186b57600080fd5b505050600094855250506015602052505060409020805460018201546002830154600384015460048501546005860154600690960154949693959294919373ffffffffffffffffffffffffffffffffffffffff918216938216929190911690565b601e546000906118dc5750600090565b601e80546118ec9060019061539c565b815481106118fc576118fc61545e565b906000526020600020906003020160010154905090565b601e546000906119235750600090565b601e80546119339060019061539c565b815481106119435761194361545e565b906000526020600020906003020160020154905090565b611963426133bc565b806000811180156119745750606581105b61197d57600080fd5b601854610100900473ffffffffffffffffffffffffffffffffffffffff16331480611a535750601854604080517f094b741500000000000000000000000000000000000000000000000000000000815290513392610100900473ffffffffffffffffffffffffffffffffffffffff169163094b74159160048083019260209291908290030181865afa158015611a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3b919061548d565b73ffffffffffffffffffffffffffffffffffffffff16145b611a5c57600080fd5b611a688261271061539c565b6017556040518281527f2ade3fe6cec488ed9b13e36f5179edfbca9998fecc5926cf57335558671d5f959060200160405180910390a15050565b6000601f54600114611ab357600080fd5b6000601f55611ac1426133bc565b600080611b1d601b546dffffffffffffffffffffffffffff808216926e01000000000000000000000000000083049091169163ffffffff7c01000000000000000000000000000000000000000000000000000000009091041690565b506016546019546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529395509193506000926dffffffffffffffffffffffffffff9091169173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015611ba9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcd9190615354565b611bd7919061539c565b601654601a546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529293506000926e0100000000000000000000000000009092046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611c72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c969190615354565b611ca0919061539c565b90506000611cbe6dffffffffffffffffffffffffffff86168461539c565b90506000611cdc6dffffffffffffffffffffffffffff86168461539c565b90506000611cea8787613ce7565b60008054919250819003611d2b576103e8611d0d611d0885876153af565b613e54565b611d17919061539c565b9850611d2660006103e8613ec4565b611d80565b611d7d6dffffffffffffffffffffffffffff8916611d4983876153af565b611d5391906153f5565b6dffffffffffffffffffffffffffff8916611d6e84876153af565b611d7891906153f5565b613f6f565b98505b60008911611d8d57600080fd5b611d978a8a613ec4565b611da686868a8a6110896136e8565b8115611de157601b54611ddd906dffffffffffffffffffffffffffff6e0100000000000000000000000000008204811691166153af565b601c555b604080518581526020810185905233917f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a250506001601f5550949695505050505050565b6000601f54600114611e4057600080fd5b6000601f5560185460ff1615611e5557600080fd5b611e5e426133bc565b601a54600090611e849073ffffffffffffffffffffffffffffffffffffffff1685613f85565b9050806016600e8282829054906101000a90046dffffffffffffffffffffffffffff16611eb191906154aa565b82546101009290920a6dffffffffffffffffffffffffffff818102199093169183160217909155601654601b54919250611f05916e0100000000000000000000000000009182900484169190048316615409565b1115611f1057600080fd5b601a54601954611f3e9160049173ffffffffffffffffffffffffffffffffffffffff918216911684876141ce565b336000818152601d602090815260408083208054600181018255908452928290209092018490558151848152908101859052908101869052919350907fe1ce07267c05b1609d3bd4046ca369b74e64cd2b45ee8321ccc79783252c60b4906060015b60405180910390a2506001601f5592915050565b6000806000601f54600114611fc857600080fd5b6000601f55611fd6426133bc565b60008080611fe5600488614444565b601954929550909350915073ffffffffffffffffffffffffffffffffffffffff9081169084160361206c57601680548391906000906120359084906dffffffffffffffffffffffffffff1661541c565b92506101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff1602179055506120ca565b816016600e8282829054906101000a90046dffffffffffffffffffffffffffff16612097919061541c565b92506101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff1602179055505b801561211f57600087815260156020526040902060060180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790555b61212a8333846135ac565b604080518881526020810184905282151581830152905173ffffffffffffffffffffffffffffffffffffffff85169133917f43168622ddb54ed84ccad30626ace7077235dc531c67aaf639752c45195354489181900360600190a36001601f55969195509350915050565b601d60205281600052604060002081815481106121b157600080fd5b90600052602060002001600091509150505481565b73ffffffffffffffffffffffffffffffffffffffff83166000908152601d6020908152604080832080548251818502810185019093528083526060949383018282801561223257602002820191906000526020600020905b81548152602001906001019080831161221e575b50505050509050600061224c84868451611d78919061539c565b90508067ffffffffffffffff811115612267576122676154d1565b6040519080825280602002602001820160405280156122f457816020015b604080516101008101825260008082526020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e082015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092019101816122855790505b50925060005b818110156123f2576015600084612311848a615409565b815181106123215761232161545e565b60209081029190910181015182528181019290925260409081016000208151610100810183528154815260018201549381019390935260028101549183019190915260038101546060830152600481015473ffffffffffffffffffffffffffffffffffffffff90811660808401526005820154811660a084015260069091015490811660c083015274010000000000000000000000000000000000000000900460ff16151560e082015284518590839081106123df576123df61545e565b60209081029190910101526001016122fa565b5050509392505050565b600080601f5460011461240e57600080fd5b6000601f5561241c426133bc565b600080612478601b546dffffffffffffffffffffffffffff808216926e01000000000000000000000000000083049091169163ffffffff7c01000000000000000000000000000000000000000000000000000000009091041690565b50601954601a546016546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015294965092945073ffffffffffffffffffffffffffffffffffffffff918216939116916000916dffffffffffffffffffffffffffff9091169084906370a0823190602401602060405180830381865afa15801561250e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125329190615354565b61253c919061539c565b6016546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192506000916e0100000000000000000000000000009091046dffffffffffffffffffffffffffff169073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa1580156125d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f79190615354565b612601919061539c565b3060009081526001602052604081205491925061261e8888613ce7565b6000549091508061262f86856153af565b61263991906153f5565b9a508061264685856153af565b61265091906153f5565b995060008b118015612662575060008a115b61266b57600080fd5b61267530846144db565b612680878d8d6135ac565b61268b868d8c6135ac565b6016546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526dffffffffffffffffffffffffffff9091169073ffffffffffffffffffffffffffffffffffffffff8916906370a0823190602401602060405180830381865afa15801561270b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272f9190615354565b612739919061539c565b6016546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529196506e01000000000000000000000000000090046dffffffffffffffffffffffffffff169073ffffffffffffffffffffffffffffffffffffffff8816906370a0823190602401602060405180830381865afa1580156127cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127f09190615354565b6127fa919061539c565b935061280b85858b8b6110896136e8565b811561284657601b54612842906dffffffffffffffffffffffffffff6e0100000000000000000000000000008204811691166153af565b601c555b604080518c8152602081018c905273ffffffffffffffffffffffffffffffffffffffff8e169133917fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496910160405180910390a35050505050505050506001601f81905550915091565b73ffffffffffffffffffffffffffffffffffffffff81166000908152601d602090815260409182902080548351818402810184019094528084526060939283018282801561291c57602002820191906000526020600020905b815481526020019060010190808311612908575b50505050509050919050565b60185460ff161580156129c75750601860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f12d54d86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c79190615500565b6129d057600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b600061119f338484613b06565b601f54600114612a1957600080fd5b6000601f55612a27426133bc565b601954601a54601654601b5473ffffffffffffffffffffffffffffffffffffffff9384169390921691612b279184918691612a75916dffffffffffffffffffffffffffff91821691166154aa565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526dffffffffffffffffffffffffffff919091169073ffffffffffffffffffffffffffffffffffffffff8716906370a08231906024015b602060405180830381865afa158015612af4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b189190615354565b612b22919061539c565b6135ac565b601654601b54612bce9183918691612b68916dffffffffffffffffffffffffffff6e01000000000000000000000000000092839004811692909104166154aa565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526dffffffffffffffffffffffffffff919091169073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401612ad7565b50506001601f5550565b600454601654601b5460009283929091839182918291612c0b916dffffffffffffffffffffffffffff91821691166154aa565b601654601b54919250600091612c4b916dffffffffffffffffffffffffffff6e0100000000000000000000000000009182900481169291909104166154aa565b6040805160a081018252601b546dffffffffffffffffffffffffffff80821683526e010000000000000000000000000000918290048116602084015260165480821694840194909452920490911660608201526017546080820152909150612cb560048a8361458e565b6040810151612cd4906dffffffffffffffffffffffffffff851661539c565b97508060600151826dffffffffffffffffffffffffffff16612cf6919061539c565b9650806040015194508060600151935050505091939590929450565b6000601f54600114612d2357600080fd5b6000601f5560185460ff1615612d3857600080fd5b612d41426133bc565b601954600090612d679073ffffffffffffffffffffffffffffffffffffffff1685613f85565b601680549192508291600090612d8e9084906dffffffffffffffffffffffffffff166154aa565b82546101009290920a6dffffffffffffffffffffffffffff818102199093169183160217909155601654601b54919250612dcd91908316908316615409565b1115612dd857600080fd5b601954601a54612e069160049173ffffffffffffffffffffffffffffffffffffffff918216911684876141ce565b336000818152601d602090815260408083208054600181018255908452928290209092018490558151848152908101859052908101869052919350907f9971294258b76b481032b9c1f7f5594619d7cf40e29e224de9e71481bd0a4f8590606001611fa0565b42841015612e7957600080fd5b73ffffffffffffffffffffffffffffffffffffffff8716600090815260036020526040812080547f0000000000000000000000000000000000000000000000000000000000000000917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b9187612ef483615522565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001612f959291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561301e573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81161580159061309957508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b6130a257600080fd5b6130ad8989896139f6565b505050505050505050565b6019546000908190819073ffffffffffffffffffffffffffffffffffffffff85811691161461310e57601b546dffffffffffffffffffffffffffff6e010000000000000000000000000000820481169116613138565b601b546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004165b9150915060008511801561315c57506000826dffffffffffffffffffffffffffff16115b801561317857506000816dffffffffffffffffffffffffffff16115b61318157600080fd5b60006017548661319191906153af565b905060006131af6dffffffffffffffffffffffffffff8416836153af565b90506000826131c08661271061555a565b6dffffffffffffffffffffffffffff166131da9190615409565b90506131e681836153f5565b98975050505050505050565b601f5460011461320157600080fd5b6000601f5561320f426133bc565b6016546019546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526133b5926dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132b79190615354565b6132c1919061539c565b601654601a546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526e0100000000000000000000000000009092046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015613356573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061337a9190615354565b613384919061539c565b601b546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166110896136e8565b6001601f55565b60185460ff16156133ca5750565b60045442036133d65750565b6040805160a081018252601b546dffffffffffffffffffffffffffff80821683526e01000000000000000000000000000091829004811660208401526016548082169484019490945292049091166060820152601754608082015261343d6004838361470e565b60408101516016805460608401516dffffffffffffffffffffffffffff9081166e010000000000000000000000000000027fffffffff000000000000000000000000000000000000000000000000000000009092169316929092179190911790558051602082015160006134af6136e8565b905060008163ffffffff1611801561350d5750601b546dffffffffffffffffffffffffffff848116911614158061350d5750601b546dffffffffffffffffffffffffffff8381166e0100000000000000000000000000009092041614155b1561355257601b5461354d906dffffffffffffffffffffffffffff8086169185821691818116916e0100000000000000000000000000009004168561372b565b6135a5565b601b80546dffffffffffffffffffffffffffff8481166e010000000000000000000000000000027fffffffff00000000000000000000000000000000000000000000000000000000909216908616171790555b5050505050565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052915160009283928716916136739190615584565b6000604051808303816000865af19150503d80600081146136b0576040519150601f19603f3d011682016040523d82523d6000602084013e6136b5565b606091505b50915091508180156136df5750805115806136df5750808060200190518101906136df9190615500565b6135a557600080fd5b6000806136fa6401000000004261544a565b601b547c0100000000000000000000000000000000000000000000000000000000900463ffffffff16900392915050565b6016546dffffffffffffffffffffffffffff9061374a90821687615409565b1115801561378757506016546dffffffffffffffffffffffffffff90613784906e0100000000000000000000000000009004821686615409565b11155b6137bd576040517f350caebb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006137ce6401000000004261544a565b905060008263ffffffff161180156137f557506dffffffffffffffffffffffffffff841615155b801561381057506dffffffffffffffffffffffffffff831615155b1561390657601e60405180606001604052808363ffffffff1681526020018463ffffffff166138668861384289614a07565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1690614a32565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff160261388d6118cc565b0181526020018463ffffffff166138a7876138428a614a07565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16026138ce611913565b019052815460018181018455600093845260209384902083516003909302019182559282015192810192909255604001516002909101555b601b805463ffffffff83167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff6dffffffffffffffffffffffffffff8981166e0100000000000000000000000000009081027fffffffff000000000000000000000000000000000000000000000000000000009095168c83161794909417918216831794859055604080519382169282169290921783529290930490911660208201527f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1910160405180910390a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b600081815260118301602052604081206006810154600582015473ffffffffffffffffffffffffffffffffffffffff9081169392911690829081613aa98887613bd5565b9050613aba81888a60000154614a4e565b6004840154919650935073ffffffffffffffffffffffffffffffffffffffff1633148015613af257506000851180613af25750600083115b613afb57600080fd5b505092959194509250565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054613b3790829061539c565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054613b74908290615409565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613a589085815260200190565b600182015460009073ffffffffffffffffffffffffffffffffffffffff838116911614613c055782600901613c0a565b826002015b9392505050565b6000828152600484016020526040812054819080613c2e57600080fd5b600085815260038701602090815260408083205460058a0190925290912054818610613c8c5760008281526006890160205260409020546e010000000000000000000000000000620f42408383038602040494506001955050613cdc565b6e010000000000000000000000000000620f42406dffffffffffffffffffffffffffff1684838b60010154030281613cc657613cc66153c6565b0481613cd457613cd46153c6565b049350600094505b505050935093915050565b600080601860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d7b919061548d565b601c5473ffffffffffffffffffffffffffffffffffffffff8216158015945091925090613e40578015613e3b576000613dca611d086dffffffffffffffffffffffffffff8088169089166153af565b90506000613dd783613e54565b905080821115613e38576000613ded828461539c565b600054613dfa91906153af565b9050600082613e0a8560056153af565b613e149190615409565b90506000613e2282846153f5565b90508015613e3457613e348782613ec4565b5050505b50505b613e4c565b8015613e4c576000601c555b505092915050565b60006003821115613eb55750806000613e6e6002836153f5565b613e79906001615409565b90505b81811015613eaf57905080600281613e9481866153f5565b613e9e9190615409565b613ea891906153f5565b9050613e7c565b50919050565b8115613ebf575060015b919050565b80600054613ed29190615409565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054613f05908290615409565b73ffffffffffffffffffffffffffffffffffffffff83166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613f639085815260200190565b60405180910390a35050565b6000818310613f7e5781613c0a565b5090919050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015613ff4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140189190615354565b60408051336024820152306044820152606480820187905282518083039091018152608490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790529051919250600091829173ffffffffffffffffffffffffffffffffffffffff8816916140b59190615584565b6000604051808303816000865af19150503d80600081146140f2576040519150601f19603f3d011682016040523d82523d6000602084013e6140f7565b606091505b50915091508180156141215750805115806141215750808060200190518101906141219190615500565b61412a57600080fd5b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152839073ffffffffffffffffffffffffffffffffffffffff8816906370a0823190602401602060405180830381865afa158015614196573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ba9190615354565b6141c4919061539c565b9695505050505050565b600042816141de610e108361544a565b6141e8908361539c565b90506000816141f8866001615409565b61420490610e106153af565b61420e9190615409565b9050600061421c848361539c565b61422988620f42406153af565b61423391906153f5565b90506000811161424257600080fd5b600061424e8b8b613bd5565b9050614260818c601001548486614b40565b6040518061010001604052808c6010015481526020018681526020018481526020018381526020013373ffffffffffffffffffffffffffffffffffffffff1681526020018b73ffffffffffffffffffffffffffffffffffffffff1681526020018a73ffffffffffffffffffffffffffffffffffffffff168152602001600015158152508b60110160008d6010015481526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060a08201518160050160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060c08201518160060160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060e08201518160060160146101000a81548160ff0219169083151502179055509050508a601001600081548092919061443190615522565b909155509b9a5050505050505050505050565b600081815260118301602052604081206006810154600582015473ffffffffffffffffffffffffffffffffffffffff918216939283929091839161448a91899116613bd5565b905061449b81878960000154614bb4565b6004840154919550935073ffffffffffffffffffffffffffffffffffffffff16331480156144c95750600084115b6144d257600080fd5b50509250925092565b73ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090205461450c90829061539c565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600160205260408120919091555461454190829061539c565b600090815560405182815273ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001613f63565b82546000610e1061459f818461544a565b6145a9908461539c565b6145b39190615409565b60028601805460098801805493945091925b8785116146a65760008581526002850160205260409020541515806145f95750600085815260028401602052604090205415155b1561469357600061460a878761539c565b90506000620f424061461c83866153af565b61462691906153f5565b90506000620f424061463884866153af565b61464291906153f5565b905061464f8a8383614c01565b5050600088815260028801602052604090205461466c908661539c565b600089815260028801602052604090205490955061468a908561539c565b93508798505050505b61469f610e1086615409565b94506145c5565b8786146130ad5760006146b9878a61539c565b90506000620f42406146cb83866153af565b6146d591906153f5565b90506000620f42406146e784866153af565b6146f191906153f5565b90506146fe8a8383614c01565b5050505050505050505050505050565b82546000610e1061471f818461544a565b614729908461539c565b6147339190615409565b905060028501600986015b8583116148cb5760008381526002830160205260409020541515806147725750600083815260028201602052604090205415155b156148b8576000614783858561539c565b8354909150600090620f42409061479b9084906153af565b6147a591906153f5565b8354909150600090620f4240906147bd9085906153af565b6147c791906153f5565b90506000806147d78a8585614c01565b915091506147e58782614d28565b6147ef8683614d28565b6147f98789614d66565b6148038689614d66565b7f793ee8b0d8020fc042a920607e3cbd37f5132c011786c8dd10a685f4414ed38188868c600001518d602001518e604001518f6060015188888c8c6040516148a79a99989796959493929190998a5260208a01989098526dffffffffffffffffffffffffffff96871660408a0152949095166060880152608087019290925260a086015260c085015260e08401919091526101008301526101208201526101400190565b60405180910390a187985050505050505b6148c4610e1084615409565b925061473e565b8584146149fc5760006148de858861539c565b8354909150600090620f4240906148f69084906153af565b61490091906153f5565b8354909150600090620f4240906149189085906153af565b61492291906153f5565b90506000806149328a8585614c01565b915091507f793ee8b0d8020fc042a920607e3cbd37f5132c011786c8dd10a685f4414ed3818b868c600001518d602001518e604001518f6060015188888c8c6040516149da9a99989796959493929190998a5260208a01989098526dffffffffffffffffffffffffffff96871660408a0152949095166060880152608087019290925260a086015260c085015260e08401919091526101008301526101208201526101400190565b60405180910390a16149ec8782614d28565b6149f68683614d28565b50505050505b505050919092555050565b60006111a36e0100000000000000000000000000006dffffffffffffffffffffffffffff84166155a0565b6000613c0a6dffffffffffffffffffffffffffff8316846155e7565b60008281526003840160205260408120548190838111614a6d57600080fd5b6000858152600487016020526040902054620f424081614a8d878561539c565b614a9791906153af565b614aa191906153f5565b600087815260058901602052604090205460018901549195506e01000000000000000000000000000091620f424091900383020404925080876000016000828254614aec919061539c565b90915550506000868152600488016020908152604080832083905560038a01825280832083905584835260028a0190915281208054839290614b2f90849061539c565b925050819055505050935093915050565b81846000016000828254614b549190615409565b9091555050600184015460008481526005860160209081526040808320939093556003870181528282208490556004870181528282208590558382526002870190529081208054849290614ba9908490615409565b909155505050505050565b600080614bc2858585613c11565b925090508015614be2576000848152600486016020526040812055614bf9565b600185015460008581526005870160205260409020555b935093915050565b6000806000856040015186600001516dffffffffffffffffffffffffffff16614c2a9190615409565b90506000866060015187602001516dffffffffffffffffffffffffffff16614c529190615409565b9050614c8d87600001516dffffffffffffffffffffffffffff1688602001516dffffffffffffffffffffffffffff1688888b60800151614da6565b604089015191955093508690614ca4908690615409565b614cae919061539c565b604088015260608701518590614cc5908590615409565b614ccf919061539c565b60608801526040870151614ce3908361539c565b6dffffffffffffffffffffffffffff1687526060870151614d04908261539c565b6dffffffffffffffffffffffffffff16602090970196909652509094909350915050565b815415614d62578154700f42400000000000000000000000000000820281614d5257614d526153c6565b6001840180549290910490910190555b5050565b6000818152600283016020526040812054835490918491614d8890849061539c565b90915550506001820154600091825260069092016020526040902055565b600080600285108015614db95750600284105b614ee0576002851015614e07576000614dd284866153af565b905080614de1886127106153af565b614deb9190615409565b614df5828a6153af565b614dff91906153f5565b925050614ee0565b6002841015614e51576000614e1c84876153af565b905080614e2b896127106153af565b614e359190615409565b614e3f82896153af565b614e4991906153f5565b915050614ee0565b6000612710614e6085886153af565b614e6a91906153f5565b614e749089615409565b90506000612710614e8586886153af565b614e8f91906153f5565b614e999089615409565b905080614ea6838a6153af565b614eb091906153f5565b614eba908361539c565b935081614ec7828b6153af565b614ed191906153f5565b614edb908261539c565b925050505b9550959350505050565b73ffffffffffffffffffffffffffffffffffffffff81168114614f0c57600080fd5b50565b600080600080600060808688031215614f2757600080fd5b85359450602086013593506040860135614f4081614eea565b9250606086013567ffffffffffffffff80821115614f5d57600080fd5b818801915088601f830112614f7157600080fd5b813581811115614f8057600080fd5b896020828501011115614f9257600080fd5b9699959850939650602001949392505050565b60005b83811015614fc0578181015183820152602001614fa8565b50506000910152565b6020815260008251806020840152614fe8816040850160208701614fa5565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b6000806040838503121561502d57600080fd5b823561503881614eea565b946020939093013593505050565b6000806040838503121561505957600080fd5b82359150602083013561506b81614eea565b809150509250929050565b60008060006060848603121561508b57600080fd5b833561509681614eea565b925060208401356150a681614eea565b929592945050506040919091013590565b6000602082840312156150c957600080fd5b5035919050565b600080604083850312156150e357600080fd5b50508035926020909101359150565b60006020828403121561510457600080fd5b8135613c0a81614eea565b60008060006060848603121561512457600080fd5b833561512f81614eea565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b828110156151e657815180518552868101518786015285810151868601526060808201519086015260808082015173ffffffffffffffffffffffffffffffffffffffff9081169187019190915260a08083015182169087015260c0808301519091169086015260e0908101511515908501526101009093019290850190600101615161565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561522b5783518352928401929184019160010161520f565b50909695505050505050565b600080600080600080600060e0888a03121561525257600080fd5b873561525d81614eea565b9650602088013561526d81614eea565b95506040880135945060608801359350608088013560ff8116811461529157600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156152c157600080fd5b82356152cc81614eea565b9150602083013561506b81614eea565b73ffffffffffffffffffffffffffffffffffffffff8616815284602082015283604082015260806060820152816080820152818360a0830137600081830160a090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101949350505050565b60006020828403121561536657600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156111a3576111a361536d565b80820281158282048414176111a3576111a361536d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082615404576154046153c6565b500490565b808201808211156111a3576111a361536d565b6dffffffffffffffffffffffffffff8281168282160390808211156154435761544361536d565b5092915050565b600082615459576154596153c6565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561549f57600080fd5b8151613c0a81614eea565b6dffffffffffffffffffffffffffff8181168382160190808211156154435761544361536d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561551257600080fd5b81518015158114613c0a57600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036155535761555361536d565b5060010190565b6dffffffffffffffffffffffffffff818116838216028082169190828114613e4c57613e4c61536d565b60008251615596818460208701614fa5565b9190910192915050565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8281168282168181028316929181158285048214176155de576155de61536d565b50505092915050565b60007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff80841680615616576156166153c6565b9216919091049291505056
Deployed Bytecode Sourcemap
927:2235:8:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;958:20;;;;;;;;;;;;190:42:14;178:55;;;160:74;;148:2;133:18;958:20:8;;;;;;;;984:26;;;;;;;;;1114:25;;;;;;:::i;:::-;;:::i;3048:112::-;;;:::i;:::-;;1591:97;1666:8;:15;1591:97;;576:25:14;;;564:2;549:18;1591:97:8;430:177:14;1859:983:8;;;;;;:::i;:::-;;:::i;2936:106::-;;;;;;:::i;:::-;;:::i;1694:159::-;;;;;;:::i;:::-;;:::i;1046:62::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;1016:23;;;;;;;;;;;;;;;1767:14:14;;1760:22;1742:41;;1730:2;1715:18;1016:23:8;1602:187:14;2848:82:8;;;;;;:::i;:::-;;:::i;1114:25::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1114:25:8;:::o;3048:112::-;1542:11;;;;1528:10;:25;1520:34;;;;;;3113:11:::1;::::0;;;::::1;;;3112:12;3104:21;;;::::0;::::1;;3149:4;3135:18:::0;;;::::1;::::0;::::1;::::0;;3048:112::o;1859:983::-;1940:12;1978:6;1968:16;;:6;:16;;;1964:47;;1993:18;;;;;;;;;;;;;;1964:47;2045:14;2061;2088:6;2079:15;;:6;:15;;;:53;;2117:6;2125;2079:53;;;2098:6;2106;2079:53;2044:88;;-1:-1:-1;2044:88:8;-1:-1:-1;2146:20:8;;;2142:46;;2175:13;;;;;;;;;;;;;;2142:46;2218:37;:15;;;2253:1;2218:15;;;:7;:15;;;;;;;;:23;;;;;;;;;;;;:37;2214:62;;2264:12;;;;;;;;;;;;;;2214:62;2331:21;2355:31;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;1961:66:14;2056:2;2052:15;;;2048:24;;2355:31:8;2421:32;;2036:37:14;2107:15;;;2103:24;2089:12;;;2082:46;2355:31:8;;-1:-1:-1;2396:12:8;;2144::14;;2421:32:8;;;;;;;;;;;;2411:43;;;;;;2396:58;;2542:4;2531:8;2525:15;2520:2;2510:8;2506:17;2503:1;2495:52;2566:50;;;;;:29;2448:15:14;;;2566:50:8;;;2430:34:14;2500:15;;;2480:18;;;2473:43;2532:18;;;2525:34;;;2487:60:8;;-1:-1:-1;2566:29:8;;;;;;2342:18:14;;2566:50:8;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;2626:15:8;;;;;;;;:7;:15;;;;;;;;:23;;;;;;;;;;;;:30;;;;;;;;;;;;;;2666:15;;;;;;:23;;;;;;;;:30;;;;;;;;2751:8;:19;;-1:-1:-1;2751:19:8;;;;;;;;;;;;;;;;;;;;;;2819:15;;2785:50;;2744:74:14;;;2834:18;;;2827:34;2785:50:8;;2717:18:14;2785:50:8;;;;;;;1954:888;;;;1859:983;;;;;:::o;2936:106::-;1542:11;;;;1528:10;:25;1520:34;;;;;;3009:11:::1;:26:::0;;;::::1;;::::0;;;::::1;::::0;;;::::1;::::0;;2936:106::o;1694:159::-;1764:12;1795:30;1806:6;1814;1822:2;1795:10;:30::i;:::-;1788:37;1694:159;-1:-1:-1;;;1694:159:8:o;2848:82::-;1542:11;;;;1528:10;:25;1520:34;;;;;;2909:5:::1;:14:::0;;;::::1;;::::0;;;::::1;::::0;;;::::1;::::0;;2848:82::o;-1:-1:-1:-;;;;;;;;:::o;245:180:14:-;304:6;357:2;345:9;336:7;332:23;328:32;325:52;;;373:1;370;363:12;325:52;-1:-1:-1;396:23:14;;245:180;-1:-1:-1;245:180:14:o;612:196::-;680:20;;740:42;729:54;;719:65;;709:93;;798:1;795;788:12;709:93;612:196;;;:::o;813:328::-;890:6;898;906;959:2;947:9;938:7;934:23;930:32;927:52;;;975:1;972;965:12;927:52;998:29;1017:9;998:29;:::i;:::-;988:39;;1046:38;1080:2;1069:9;1065:18;1046:38;:::i;:::-;1036:48;;1131:2;1120:9;1116:18;1103:32;1093:42;;813:328;;;;;:::o;1146:186::-;1205:6;1258:2;1246:9;1237:7;1233:23;1229:32;1226:52;;;1274:1;1271;1264:12;1226:52;1297:29;1316:9;1297:29;:::i;1337:260::-;1405:6;1413;1466:2;1454:9;1445:7;1441:23;1437:32;1434:52;;;1482:1;1479;1472:12;1434:52;1505:29;1524:9;1505:29;:::i;:::-;1495:39;;1553:38;1587:2;1576:9;1572:18;1553:38;:::i;:::-;1543:48;;1337:260;;;;;:::o
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
POL | 100.00% | $2.09 | 8.9999 | $18.81 |
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.