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