Source Code
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 46 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Approve | 25553545 | 17 hrs ago | IN | 0 HYPE | 0.00002955 | ||||
| Approve | 25099757 | 5 days ago | IN | 0 HYPE | 0.00003342 | ||||
| Approve | 24124949 | 17 days ago | IN | 0 HYPE | 0.00000635 | ||||
| Approve | 23511174 | 23 days ago | IN | 0 HYPE | 0.00016301 | ||||
| Approve | 23501570 | 24 days ago | IN | 0 HYPE | 0.000009 | ||||
| Approve | 23483073 | 24 days ago | IN | 0 HYPE | 0.00001157 | ||||
| Approve | 23239778 | 27 days ago | IN | 0 HYPE | 0.00002495 | ||||
| Approve | 22225019 | 38 days ago | IN | 0 HYPE | 0.00009273 | ||||
| Approve | 22197248 | 38 days ago | IN | 0 HYPE | 0.00145875 | ||||
| Approve | 22100270 | 40 days ago | IN | 0 HYPE | 0.0003229 | ||||
| Approve | 22096216 | 40 days ago | IN | 0 HYPE | 0.00041605 | ||||
| Approve | 21497225 | 46 days ago | IN | 0 HYPE | 0.00046676 | ||||
| Approve | 21245054 | 49 days ago | IN | 0 HYPE | 0.00006289 | ||||
| Approve | 20892676 | 53 days ago | IN | 0 HYPE | 0.00000926 | ||||
| Approve | 20745974 | 55 days ago | IN | 0 HYPE | 0.00000539 | ||||
| Approve | 20624841 | 56 days ago | IN | 0 HYPE | 0.0002264 | ||||
| Approve | 20585004 | 57 days ago | IN | 0 HYPE | 0.00001507 | ||||
| Approve | 20426833 | 59 days ago | IN | 0 HYPE | 0.00007605 | ||||
| Approve | 20379039 | 59 days ago | IN | 0 HYPE | 0.00000535 | ||||
| Approve | 20318000 | 60 days ago | IN | 0 HYPE | 0.00001645 | ||||
| Approve | 20317914 | 60 days ago | IN | 0 HYPE | 0.00000543 | ||||
| Approve | 20273843 | 60 days ago | IN | 0 HYPE | 0.00000488 | ||||
| Approve | 20254837 | 61 days ago | IN | 0 HYPE | 0.00005144 | ||||
| Approve | 20234833 | 61 days ago | IN | 0 HYPE | 0.00001677 | ||||
| Approve | 20218422 | 61 days ago | IN | 0 HYPE | 0.00011702 |
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers.
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | ||||
|---|---|---|---|---|---|---|---|
| 25614603 | 1 hr ago | 0 HYPE | |||||
| 25614603 | 1 hr ago | 0 HYPE | |||||
| 25614603 | 1 hr ago | 0 HYPE | |||||
| 25614603 | 1 hr ago | 0 HYPE | |||||
| 25614603 | 1 hr ago | 0 HYPE | |||||
| 25614603 | 1 hr ago | 0 HYPE | |||||
| 25613467 | 1 hr ago | 0 HYPE | |||||
| 25613467 | 1 hr ago | 0 HYPE | |||||
| 25613467 | 1 hr ago | 0 HYPE | |||||
| 25613467 | 1 hr ago | 0 HYPE | |||||
| 25613467 | 1 hr ago | 0 HYPE | |||||
| 25613467 | 1 hr ago | 0 HYPE | |||||
| 25605542 | 3 hrs ago | 0 HYPE | |||||
| 25605542 | 3 hrs ago | 0 HYPE | |||||
| 25605542 | 3 hrs ago | 0 HYPE | |||||
| 25605542 | 3 hrs ago | 0 HYPE | |||||
| 25605542 | 3 hrs ago | 0 HYPE | |||||
| 25605535 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE | |||||
| 25605534 | 3 hrs ago | 0 HYPE |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Pair
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 300 runs
Other Settings:
cancun 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^2) = xy^3 + x^3y 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(
"Ramses StableSwap - ",
IERC20Extended(token0).symbol(),
"/",
IERC20Extended(token1).symbol()
)
);
__symbol = string(
string.concat("Stable - ", IERC20Extended(token0).symbol(), "/", IERC20Extended(token1).symbol())
);
} else {
__name = string(
string.concat(
"Ramses 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;
/// @notice sets the voter
/// @param _voter the voter address
function setVoter(address _voter) 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 Thrown when attempting to reward past periods
error CANT_REWARD_PAST();
/// @notice Throw when gauge can't determine if using secondsInRange from the pool is safe
error NEED_TEAM_TO_UPDATE();
/// @notice Thrown when owner is not an authorized NFP manager
error NOT_AUTHORIZED_CLAIMER(address owner);
/*//////////////////////////////////////////////////////////////
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": 300
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"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
60a0604052346102f9576100116102fd565b6100196102fd565b81516001600160401b03811161020c57600354600181811c911680156102ef575b60208210146101ee57601f811161028c575b50602092601f821160011461022b57928192935f92610220575b50508160011b915f199060031b1c1916176003555b80516001600160401b03811161020c57600454600181811c91168015610202575b60208210146101ee57601f811161018b575b50602091601f821160011461012b579181925f92610120575b50508160011b915f199060031b1c1916176004555b600160055533608052604051613333908161032082396080518181816103d80152818161045e01528181610c7801528181610cc801528181610d6501526117eb0152f35b015190505f806100c7565b601f1982169260045f52805f20915f5b8581106101735750836001951061015b575b505050811b016004556100dc565b01515f1960f88460031b161c191690555f808061014d565b9192602060018192868501518155019401920161013b565b60045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f830160051c810191602084106101e4575b601f0160051c01905b8181106101d957506100ae565b5f81556001016101cc565b90915081906101c3565b634e487b7160e01b5f52602260045260245ffd5b90607f169061009c565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610066565b601f1982169360035f52805f20915f5b868110610274575083600195961061025c575b505050811b0160035561007b565b01515f1960f88460031b161c191690555f808061024e565b9192602060018192868501518155019401920161023b565b60035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f830160051c810191602084106102e5575b601f0160051c01905b8181106102da575061004c565b5f81556001016102cd565b90915081906102c4565b90607f169061003a565b5f80fd5b60405190602082016001600160401b0381118382101761020c576040525f825256fe60806040526004361015610011575f80fd5b5f5f3560e01c8063022c0d9f14611eea57806306fdde0314611e565780630902f1ac14611df8578063095ea7b314611d4d5780630dfe168114611d2657806313345fe114611beb57806313966db514611b9457806318160ddd14611b765780631df8c71714611b3d57806322be3de114611b1a57806323b872dd14611a30578063252c09d7146119d7578063313ce567146119bb578063392f37e9146119485780634690484014611921578063517b3f82146118605780635881c475146118395780636373ea691461181b57806369fe0e2d146117cb5780636a6278421461149b57806370a08231146114645780637464fc3d1461144657806389afcb44146110b45780638a7b8cf21461107d57806395d89b4114610fb15780639e8cc04b14610f57578063a9059cbb14610f25578063ba9a7a5614610f08578063bc25cf7714610d28578063bf944dbc14610d0a578063c245febc14610cec578063c45a015514610ca8578063cd962a0614610c58578063d21220a714610c31578063dd62ed3e14610be3578063ddca3f4314610bc5578063e4bbb5a81461041b578063e74b981b146103af578063ebeb31db14610391578063f140a35a146103115763fff6cae9146101dd575f80fd5b3461030e578060031936011261030e576101f56127e7565b602460206001600160a01b0360085416604051928380926370a0823160e01b82523060048301525afa80156103035782906102d0575b6024915060206001600160a01b0360095416604051938480926370a0823160e01b82523060048301525afa9081156102c557839161028b575b6102839250600b54916001600160701b03808460701c1693169161297f565b600160055580f35b90506020823d6020116102bd575b816102a6602093836123e9565b810103126102b957610283915190610264565b5f80fd5b3d9150610299565b6040513d85823e3d90fd5b506020813d6020116102fb575b816102ea602093836123e9565b810103126102b9576024905161022b565b3d91506102dd565b6040513d84823e3d90fd5b80fd5b503461030e57604036600319011261030e576103666004356103316122e6565b90600b54916103616001600160701b03808560701c16941692620f424061035a6010548361240b565b0490612450565b612ab3565b5f1981019190821161037d57602082604051908152f35b634e487b7160e01b81526011600452602490fd5b503461030e578060031936011261030e576020600654604051908152f35b503461030e57602036600319011261030e576001600160a01b036103d16122d0565b6103ff33837f0000000000000000000000000000000000000000000000000000000000000000163314612668565b166bffffffffffffffffffffffff60a01b600a541617600a5580f35b503461030e57606036600319011261030e576104356122d0565b9061043e6122e6565b9160443580151591828203610bc1576001600160a01b03809161048533837f0000000000000000000000000000000000000000000000000000000000000000163314612668565b1694856bffffffffffffffffffffffff60a01b60085416176008551691826bffffffffffffffffffffffff60a01b600954161760095560ff8019601354169116176013555f146109f8576040516395d89b4160e01b81528281600481875afa9081156102c55783916109de575b506040516395d89b4160e01b81528381600481865afa9081156109d3576105896001600494603460208996819688916109b9575b506040519687947f52616d73657320537461626c6553776170202d20000000000000000000000000828701528051918291018587015e840190602f60f81b84830152805192839101603583015e010185838201520301601f1981018352826123e9565b94604051928380926395d89b4160e01b82525afa9081156102c5578390819261099c575b506040516395d89b4160e01b81529192829060049082905afa9081156102c55760209260298461063094600194889161097a575b5060405196879468029ba30b136329016960bd1b828701528051918291018587015e840190602f60f81b84830152805192839101602a83015e010185838201520301601f1981018352826123e9565b905b825167ffffffffffffffff81116108865761064e60145461245d565b601f8111610912575b506020601f82116001146108a55782939482939261089a575b50508160011b915f199060031b1c1916176014555b815167ffffffffffffffff8111610886576106a160155461245d565b601f811161081e575b50602092601f82116001146107b2579282938293926107a7575b50508160011b915f199060031b1c1916176015555b6106fc6040516106e8816123b9565b428152826020820152826040820152612759565b600460206001600160a01b03600854166040519283809263313ce56760e01b82525afa801561030357610736918391610778575b506127d6565b601155600460206001600160a01b03600954166040519283809263313ce56760e01b82525afa80156103035761077291839161077857506127d6565b60125580f35b61079a915060203d6020116107a0575b61079281836123e9565b8101906127bd565b5f610730565b503d610788565b015190505f806106c4565b60158352601f198216935f5160206132be5f395f51905f5291845b86811061080657508360019596106107ee575b505050811b016015556106d9565b01515f1960f88460031b161c191690555f80806107e0565b919260206001819286850151815501940192016107cd565b60158352601f820160051c5f5160206132be5f395f51905f52019060208310610871575b601f0160051c5f5160206132be5f395f51905f5201905b81811061086657506106aa565b838155600101610859565b5f5160206132be5f395f51905f529150610842565b634e487b7160e01b82526041600452602482fd5b015190505f80610670565b601483525f5160206132de5f395f51905f5290601f198316845b8181106108fa575095836001959697106108e2575b505050811b01601455610685565b01515f1960f88460031b161c191690555f80806108d4565b9192602060018192868b0151815501940192016108bf565b60148352601f820160051c5f5160206132de5f395f51905f52019060208310610965575b601f0160051c5f5160206132de5f395f51905f5201905b81811061095a5750610657565b83815560010161094d565b5f5160206132de5f395f51905f529150610936565b61099691503d808a833e61098e81836123e9565b8101906126f6565b5f6105e1565b600492506109b3903d8084833e61098e81836123e9565b916105ad565b6109cd91503d808a833e61098e81836123e9565b5f610526565b6040513d86823e3d90fd5b6109f291503d8085833e61098e81836123e9565b5f6104f2565b6040516395d89b4160e01b81528281600481875afa9081156102c5578391610ba7575b506040516395d89b4160e01b81528381600481865afa9081156109d357610aa7600160049460326020899681968891610b8d575b506040519687947102930b6b9b2b9902b37b630ba34b6329016960751b828701528051918291018587015e840190602f60f81b84830152805192839101603383015e010185838201520301601f1981018352826123e9565b94604051928380926395d89b4160e01b82525afa9081156102c55783908192610b70575b506040516395d89b4160e01b81529192829060049082905afa9081156102c557602092602b84610b50946001948891610b56575b506040519687946a02b37b630ba34b6329016960ad1b828701528051918291018587015e840190602f60f81b84830152805192839101602c83015e010185838201520301601f1981018352826123e9565b90610632565b610b6a91503d808a833e61098e81836123e9565b5f610aff565b60049250610b87903d8084833e61098e81836123e9565b91610acb565b610ba191503d808a833e61098e81836123e9565b5f610a4f565b610bbb91503d8085833e61098e81836123e9565b5f610a1b565b8380fd5b503461030e578060031936011261030e576020601054604051908152f35b503461030e57604036600319011261030e576001600160a01b036040610c076122d0565b9282610c116122e6565b9416815260016020522091165f52602052602060405f2054604051908152f35b503461030e578060031936011261030e5760206001600160a01b0360095416604051908152f35b503461030e57602036600319011261030e57610c9f336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314612668565b600435600f5580f35b503461030e578060031936011261030e5760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b503461030e578060031936011261030e576020600d54604051908152f35b503461030e578060031936011261030e576020600c54604051908152f35b503461030e57602036600319011261030e57610d426122d0565b610d4a6127e7565b6040516334ad98e160e21b81523060048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156102c5578391610ed9575b5015610eca576001600160a01b03600854166001600160a01b036009541690604051906370a0823160e01b8252306004830152602082602481845afa918215610ebf5784908693610e87575b50610e03610e09936001600160701b03600b541690612450565b91612807565b6040516370a0823160e01b815230600482015291602083602481855afa9283156109d3578493610e51575b50610e03610283936001600160701b03600b5460701c1690612450565b92506020833d602011610e7f575b81610e6c602093836123e9565b810103126102b957915191610e03610e34565b3d9150610e5f565b9250506020823d602011610eb7575b81610ea3602093836123e9565b810103126102b95790519083610e03610de9565b3d9150610e96565b6040513d87823e3d90fd5b635712a7b360e11b8252600482fd5b610efb915060203d602011610f01575b610ef381836123e9565b8101906126c2565b5f610d9d565b503d610ee9565b503461030e578060031936011261030e5760206040516103e88152f35b503461030e57604036600319011261030e57610f4c610f426122d0565b6024359033612e24565b602060405160018152f35b503461030e57610f73610f693661238f565b92919083916124ce565b825b8151841015610f9d57610f95600191610f8e86856124ba565b51906124ad565b930192610f75565b610fa983602092612432565b604051908152f35b503461030e578060031936011261030e57604051908060155490610fd48261245d565b8085529160018116908115611056575060011461100c575b61100884610ffc818603826123e9565b604051918291826122fc565b0390f35b601581525f5160206132be5f395f51905f52939250905b80821061103c57509091508101602001610ffc82610fec565b919260018160209254838588010152019101909291611023565b60ff191660208087019190915292151560051b85019092019250610ffc9150839050610fec565b503461030e578060031936011261030e57606061109861268c565b6040805191805183526020810151602084015201516040820152f35b503461030e57602036600319011261030e576110ce6122d0565b6110d66127e7565b6110fb600b546001600160701b038116916001600160701b038260701c169160e01c90565b509290916001600160a01b0360085416916001600160a01b036009541694604051916370a0823160e01b8352306004840152602083602481885afa928315611439578193611405575b506040516370a0823160e01b815230600482015296602088602481845afa9586156103035787988398976113ce575b50308352826020526111af6111a36111a36111a86111968860408920549c612c40565b986002549384918d61240b565b612432565b9a8a61240b565b96881515806113c5575b156113b65730156113a257308452836020526040842054818110611389579184826020936024969530845283865203604083205580600254036002556040519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef843092a361122b8a8983612807565b611236898985612807565b6040516370a0823160e01b815230600482015293849182905afa9182156102c5578392611354575b506020602491604051928380926370a0823160e01b82523060048301525afa928315611348579261130d575b5096611299929160409861297f565b6112ea575b6001600160a01b0384519184835283602084015216907fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496853392a3600160055582519182526020820152f35b611305600b546001600160701b03808260701c1691166128ca565b600e5561129e565b929150966020833d602011611340575b8161132a602093836123e9565b810103126102b95791519196909190604061128a565b3d915061131d565b604051903d90823e3d90fd5b9091506020813d602011611381575b81611370602093836123e9565b810103126102b9575190602061125e565b3d9150611363565b63391434e360e21b855230600452602452604452606483fd5b634b637e8f60e11b84526004849052602484fd5b63ca7551f760e01b8452600484fd5b508715156111b9565b965096506020863d6020116113fd575b816113eb602093836123e9565b810103126102b957879551965f611173565b3d91506113de565b9092506020813d602011611431575b81611421602093836123e9565b810103126102b95751915f611144565b3d9150611414565b50604051903d90823e3d90fd5b503461030e578060031936011261030e576020600e54604051908152f35b503461030e57602036600319011261030e5760406020916001600160a01b0361148b6122d0565b1681528083522054604051908152f35b503461030e57602036600319011261030e576024906114b86122d0565b6114c06127e7565b6114e5600b546001600160701b038116916001600160701b038260701c169160e01c90565b5093909160206001600160a01b0360085416604051938480926370a0823160e01b82523060048301525afa9182156109d3578492611796575b506024919260206001600160a01b0360095416604051948580926370a0823160e01b82523060048301525afa928315610ebf578593611762575b506001600160701b0381169261156e8486612450565b946001600160701b038816936115848584612450565b95876115908b87612c40565b966002549283155f146117385750506115b39150876115ae9161240b565b612ee1565b6103e719810190811161172457976115cf6103e861dead61320f565b60ff6013541661166d575b881561165e5750916115f993916115f48960209b95613003565b61297f565b61163b575b604051918252838201527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f60403392a26001600555604051908152f35b611656600b546001600160701b03808260701c1691166128ca565b600e556115fe565b6314e13d6d60e31b8152600490fd5b633b9aca0061167c888a6128ca565b1061171557670de0b6b3a76400008802888104670de0b6b3a76400001489151715611701576011546116ad91612432565b670de0b6b3a76400008802888104670de0b6b3a764000014891517156116ed576012546116d991612432565b146115da57631bca023d60e31b8152600490fd5b634e487b7160e01b83526011600452602483fd5b634e487b7160e01b82526011600452602482fd5b63a932492f60e01b8152600490fd5b634e487b7160e01b89526011600452602489fd5b61174c6111a3916111a3866117539661240b565b938a61240b565b908180821091180218976115da565b9092506020813d60201161178e575b8161177e602093836123e9565b810103126102b95751915f611558565b3d9150611771565b91506020823d6020116117c3575b816117b1602093836123e9565b810103126102b957602491519161151e565b3d91506117a4565b503461030e57602036600319011261030e57611812336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314612668565b60043560105580f35b503461030e578060031936011261030e576020600f54604051908152f35b503461030e5761100861185461184e3661238f565b916124ce565b60405191829182612326565b503461030e57604036600319011261030e5761187a6122d0565b9061188361268c565b9061188c6125ba565b5091835142146118d8575b6020610fa986866118cf6111a36111a38960406118c68b6118b9885142612450565b9586918c8a015190612450565b95015190612450565b91602435612ab3565b600654919350600119820191821161037d5750916118cf6111a36111a36020969460406118c661191361190d610fa99a61235f565b50612640565b985050509496505050611897565b503461030e578060031936011261030e5760206001600160a01b03600a5416604051908152f35b503461030e578060031936011261030e5760e0601154601254600b5460ff601354166001600160701b036001600160a01b0360085416926001600160a01b0360095416946040519687526020870152818116604087015260701c1660608501521515608084015260a083015260c0820152f35b503461030e578060031936011261030e57602060405160128152f35b503461030e57602036600319011261030e57600435600654811015611a2c576119ff9061235f565b50805461100860026001840154930154604051938493846040919493926060820195825260208201520152565b5080fd5b503461030e57606036600319011261030e57611a4a6122d0565b611a526122e6565b604435916001600160a01b0381168085526001602052604085206001600160a01b0333165f5260205260405f2054905f198203611a96575b5050610f4c9350612e24565b848210611aff578015611aeb573315611ad75785604091610f4c97526001602052206001600160a01b0333165f526020528360405f20910390555f80611a8a565b634a1406b160e11b86526004869052602486fd5b63e602df0560e01b86526004869052602486fd5b6064868684637dc7a0d960e11b835233600452602452604452fd5b503461030e578060031936011261030e57602060ff601354166040519015158152f35b503461030e578060031936011261030e57611008611b596125ba565b604080519384526020840192909252908201529081906060820190565b503461030e578060031936011261030e576020600254604051908152f35b503461030e578060031936011261030e57611bad6127e7565b600b546001600160701b038082169160701c16611bca8183612c40565b611bd8575b82600160055580f35b611be1916128ca565b600e555f80611bcf565b503461030e57608036600319011261030e57611c056122d0565b9060643590604435602435611c1982612495565b94611c2760405196876123e9565b828652601f19611c3684612495565b013660208801376006545f19810193908411611d1257611c5c86611c629296959661240b565b85612450565b925b848410611c7957604051806110088982612326565b856001611d0c92611cfa611c8d84896124ad565b611cf2611caf611c9c8361235f565b5054611ca78c61235f565b505490612450565b6111a38b6002611cda81611ce9611ce3876111a38e611ccd8d61235f565b5001548f611cda8a61235f565b50015490612450565b9861235f565b5001549261235f565b908789612ab3565b611d04828c6124ba565b5201946124ad565b92611c64565b634e487b7160e01b85526011600452602485fd5b503461030e578060031936011261030e5760206001600160a01b0360085416604051908152f35b503461030e57604036600319011261030e57611d676122d0565b602435903315611de4576001600160a01b0316918215611dd057604090338152600160205220825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b634a1406b160e11b81526004819052602490fd5b63e602df0560e01b83526004839052602483fd5b503461030e578060031936011261030e5760606001600160701b0363ffffffff611e3d600b546001600160701b038116916001600160701b038260701c169160e01c90565b9193908160405195168552166020840152166040820152f35b503461030e578060031936011261030e57604051908060145490611e798261245d565b80855291600181169081156110565750600114611ea05761100884610ffc818603826123e9565b601481525f5160206132de5f395f51905f52939250905b808210611ed057509091508101602001610ffc82610fec565b919260018160209254838588010152019101909291611eb7565b50346102b95760803660031901126102b957604435906001600160a01b0382166024356004358285036102b95760643567ffffffffffffffff81116102b957366023820112156102b95780600401359067ffffffffffffffff82116102b95736602483830101116102b957611f5d6127e7565b821590811580926122c7575b156122b857611f93600b546001600160701b038116916001600160701b038260701c169160e01c90565b509290916001600160701b03831694858710806122a6575b15612297576001600160a01b03600854169a6001600160a01b0360095416938c8b14158061228d575b1561227e5788828e9261226d575b505050888061225c575b5050806121cb575b505060206024979899604051988980926370a0823160e01b82523060048301525afa96871561218b578997612196575b506020602491604051928380926370a0823160e01b82523060048301525afa90811561218b578991612159575b5084840380881115612151578703965b6001600160701b0384169487860380841115612149578303955b8915801590612140575b15612131576120ce906120c88b6120c2620f42406120bb6120b4826120ad601054809761240b565b048a612450565b938d61240b565b0488612450565b906128ca565b926128ca565b1161212257906120df93929161297f565b6040519384526020840152604083015260608201527fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d82260803392a3600160055580f35b63a932492f60e01b8a5260048afd5b63367e619960e11b8c5260048cfd5b50861515612085565b508a9561207b565b508896612061565b90506020813d602011612183575b81612174602093836123e9565b810103126102b957515f612051565b3d9150612167565b6040513d8b823e3d90fd5b9096506020813d6020116121c3575b816121b2602093836123e9565b810103126102b95751956020612024565b3d91506121a5565b883b156102b9578760a488835f9460246040519788968795639a7bff7960e01b87523360048801528387015260448601526080606486015282608486015201848401378181018301859052601f01601f19168101030181838c5af1801561225157612237575b80611ff4565b60249798505f612246916123e9565b60205f989750612231565b6040513d5f823e3d90fd5b6122669185612807565b5f88611fec565b61227692612807565b8b8882611fe2565b630de2b4ad60e31b5f5260045ffd5b50848b1415611fd4565b63827e7b7f60e01b5f5260045ffd5b506001600160701b0385168810611fab565b6309f7208b60e21b5f5260045ffd5b50841515611f69565b600435906001600160a01b03821682036102b957565b602435906001600160a01b03821682036102b957565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b60206040818301928281528451809452019201905f5b8181106123495750505090565b825184526020938401939092019160010161233c565b60065481101561237b5760065f52600360205f20910201905f90565b634e487b7160e01b5f52603260045260245ffd5b60609060031901126102b9576004356001600160a01b03811681036102b957906024359060443590565b6060810190811067ffffffffffffffff8211176123d557604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176123d557604052565b8181029291811591840414171561241e57565b634e487b7160e01b5f52601160045260245ffd5b811561243c570490565b634e487b7160e01b5f52601260045260245ffd5b9190820391821161241e57565b90600182811c9216801561248b575b602083101461247757565b634e487b7160e01b5f52602260045260245ffd5b91607f169161246c565b67ffffffffffffffff81116123d55760051b60200190565b9190820180921161241e57565b805182101561237b5760209160051b010190565b6124d783612495565b926124e560405194856123e9565b808452601f196124f482612495565b013660208601376006545f1981019190821161241e578015818004600114171561241e5761252490829492612450565b905f5b84831061253657505050505090565b600183019081841161241e5761259c8261259461256261255760019661235f565b5054611ca78961235f565b6111a36002612586612580846111a38d8c611cda81611ce98d61235f565b9561235f565b5001546002611cda8b61235f565b908786612ab3565b6125a682896124ba565b5201916001810180911161241e5791612527565b4290600c5491600d549163ffffffff6125ee600b546001600160701b038116916001600160701b038260701c169160e01c90565b9092164263ffffffff16810361260357505050565b6001600160701b0361263661263d9597949861263061263095612627859642612450565b9586911661240b565b906124ad565b971661240b565b91565b9060405161264d816123b9565b60406002829480548452600181015460208501520154910152565b156126705750565b6001600160a01b0390632bc10c3360e01b5f521660045260245ffd5b5f6040805161269a816123b9565b82815282602082015201526006545f19810190811161241e5761190d6126bf9161235f565b90565b908160209103126102b9575180151581036102b95790565b67ffffffffffffffff81116123d557601f01601f191660200190565b6020818303126102b95780519067ffffffffffffffff82116102b9570181601f820112156102b95780519061272a826126da565b9261273860405194856123e9565b828452602083830101116102b957815f9260208093018386015e8301015290565b600654600160401b8110156123d5576001810160065560065481101561237b5760065f526003027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0190604081600292518455602081015160018501550151910155565b908160209103126102b9575160ff811681036102b95790565b60ff16604d811161241e57600a0a90565b6002600554146127f8576002600555565b633ee5aeb560e01b5f5260045ffd5b919091803b156102b9575f92838093604051906001600160a01b03602083019463a9059cbb60e01b865216602483015260448201526044815261284b6064826123e9565b51925af13d156128c3573d61285f816126da565b9061286d60405192836123e9565b81523d5f602083013e5b81612894575b501561288557565b6355ee504b60e01b5f5260045ffd5b80518015925082156128a9575b50505f61287d565b6128bc92506020809183010191016126c2565b5f806128a1565b6060612877565b60135460ff161561297557670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e5760115461290291612432565b90670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e57670de0b6b3a76400009161296b6129416129719360125490612432565b846129648161295c81612954868961240b565b04968061240b565b04928061240b565b04906124ad565b9061240b565b0490565b906126bf9161240b565b91926001600160701b0383111580612aa2575b15612a93576001600160701b0360409381927f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad196600b5460e01c918242039242141580612a88575b80612a7d575b612a5f575b5050506107086129fd6129f661268c565b5142612450565b11612a34575b16918263ffffffff60e01b4260e01b16918360701b9060701b16171780600b55835192835260701c166020820152a1565b612a5a600c54600d54875191612a49836123b9565b428352602083015287820152612759565b612a03565b828580931602600c5401600c551602600d5401600d555f80806129e5565b5084811615156129e0565b5084821615156129da565b6395a5c7f960e01b5f5260045ffd5b506001600160701b03821115612992565b9291909160ff601354165f14612bfc57612acd81836128ca565b91670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e57612afc6011548092612432565b92670de0b6b3a7640000830292808404670de0b6b3a7640000149015171561241e57612b2b6012548094612432565b946001600160a01b03806008541691161493845f14612bf757945b8415612bb457670de0b6b3a7640000870296808804670de0b6b3a7640000149015171561241e57612b9981612b9f93612b9461297199612b8f88670de0b6b3a76400009d612432565b6124ad565b61301c565b90612450565b9215612bac57509061240b565b90509061240b565b670de0b6b3a7640000870296808804670de0b6b3a7640000149015171561241e57612b9981612b9f93612b9461297199612b8f89670de0b6b3a76400009d612432565b612b46565b9091926126bf936001600160a01b0380600854169116145f14612c3357612c27612c2d925b8261240b565b926124ad565b90612432565b612c27612c2d9293612c21565b91906001600160a01b03600a541690600e549382151594855f14612dfa57600f549181612c70575b50505050505b565b60135460ff1615612d6d576001600160701b0380612c929394951691166128ca565b90808211612caa575b505050505b5f80808080612c68565b612cc991612cc3612cbd6115ae93612ee1565b91612ee1565b90613146565b670de0b6b3a76400000390670de0b6b3a7640000821161241e57612ced828261240b565b91670de0b6b3a7640000830292808404670de0b6b3a7640000149015171561241e57612d189161240b565b69d3c21bcecceda1000000039069d3c21bcecceda1000000821161241e57670de0b6b3a7640000916111a3612d4f9260025461240b565b0480612d5d575b8080612c9b565b612d6691613003565b5f80612d56565b6115ae612d8a916001600160701b0380612d9095971691166128ca565b92612ee1565b808311612da1575b50505050612ca0565b612dd481612dcf620f4240612dc6612dbf6111a396612ddd99612450565b968761240b565b049485926124ad565b612450565b9160025461240b565b80612dea575b8080612d98565b612df391613003565b5f80612de3565b92505050612e0457565b612e1f600b546001600160701b03808260701c1691166128ca565b600e55565b6001600160a01b0316908115612ece576001600160a01b0316918215612ebb57815f525f60205260405f2054818110612ea257817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b63ec442f0560e01b5f525f60045260245ffd5b634b637e8f60e11b5f525f60045260245ffd5b60018111156126bf57806001600160801b821015612ff2575b600482600160401b612fa4941015612fe5575b640100000000811015612fd8575b62010000811015612fcb575b610100811015612fbf575b6010811015612fb3575b1015612fab575b60030260011c612f538184612432565b0160011c612f618184612432565b0160011c612f6f8184612432565b0160011c612f7d8184612432565b0160011c612f8b8184612432565b0160011c612f998184612432565b0160011c8092612432565b8111900390565b60011b612f43565b811c9160021b91612f3c565b60081c91811b91612f32565b60101c9160081b91612f27565b60201c9160101b91612f1b565b60401c9160201b91612f0d565b5050608081901c600160401b612efa565b906001600160a01b03821615612ebb57612c6e9161320f565b905f5b60ff811061302d5750505090565b83613078670de0b6b3a764000061305a81613053858261304d828061240b565b0461240b565b048761240b565b04670de0b6b3a7640000612964848261304d8a8261304d828061240b565b8380821015613102579061308b91612450565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e57816126306130c092612c2d6001958961327c565b945b85818111156130eb57906130d591612450565b11156130e5576001905b0161301f565b50505090565b6130f491612450565b11156130e5576001906130df565b61310b91612450565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e5781612b9961314092612c2d6001958961327c565b946130c2565b906ec097ce7bc90715b34b9f10000000008202905f196ec097ce7bc90715b34b9f100000000084099282808510940393808503941461320357838211156131eb576ec097ce7bc90715b34b9f1000000000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b50906126bf9250612432565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206001600160a01b035f93613248866002546124ad565b6002551693841584146132675780600254036002555b604051908152a3565b8484528382526040842081815401905561325e565b8060030260038104820361241e57612964670de0b6b3a76400006132b08193826132a9886126bf9961240b565b049061240b565b04928261304d828061240b56fe55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec475ce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4eca2646970667358221220aa2b51e9d5d4cc7ac06c836897ea219aa65d323465781e4b681b512d91fcfbea64736f6c634300081c0033
Deployed Bytecode
0x60806040526004361015610011575f80fd5b5f5f3560e01c8063022c0d9f14611eea57806306fdde0314611e565780630902f1ac14611df8578063095ea7b314611d4d5780630dfe168114611d2657806313345fe114611beb57806313966db514611b9457806318160ddd14611b765780631df8c71714611b3d57806322be3de114611b1a57806323b872dd14611a30578063252c09d7146119d7578063313ce567146119bb578063392f37e9146119485780634690484014611921578063517b3f82146118605780635881c475146118395780636373ea691461181b57806369fe0e2d146117cb5780636a6278421461149b57806370a08231146114645780637464fc3d1461144657806389afcb44146110b45780638a7b8cf21461107d57806395d89b4114610fb15780639e8cc04b14610f57578063a9059cbb14610f25578063ba9a7a5614610f08578063bc25cf7714610d28578063bf944dbc14610d0a578063c245febc14610cec578063c45a015514610ca8578063cd962a0614610c58578063d21220a714610c31578063dd62ed3e14610be3578063ddca3f4314610bc5578063e4bbb5a81461041b578063e74b981b146103af578063ebeb31db14610391578063f140a35a146103115763fff6cae9146101dd575f80fd5b3461030e578060031936011261030e576101f56127e7565b602460206001600160a01b0360085416604051928380926370a0823160e01b82523060048301525afa80156103035782906102d0575b6024915060206001600160a01b0360095416604051938480926370a0823160e01b82523060048301525afa9081156102c557839161028b575b6102839250600b54916001600160701b03808460701c1693169161297f565b600160055580f35b90506020823d6020116102bd575b816102a6602093836123e9565b810103126102b957610283915190610264565b5f80fd5b3d9150610299565b6040513d85823e3d90fd5b506020813d6020116102fb575b816102ea602093836123e9565b810103126102b9576024905161022b565b3d91506102dd565b6040513d84823e3d90fd5b80fd5b503461030e57604036600319011261030e576103666004356103316122e6565b90600b54916103616001600160701b03808560701c16941692620f424061035a6010548361240b565b0490612450565b612ab3565b5f1981019190821161037d57602082604051908152f35b634e487b7160e01b81526011600452602490fd5b503461030e578060031936011261030e576020600654604051908152f35b503461030e57602036600319011261030e576001600160a01b036103d16122d0565b6103ff33837f000000000000000000000000d0a07e160511c40ccd5340e94660e9c9c01b0d27163314612668565b166bffffffffffffffffffffffff60a01b600a541617600a5580f35b503461030e57606036600319011261030e576104356122d0565b9061043e6122e6565b9160443580151591828203610bc1576001600160a01b03809161048533837f000000000000000000000000d0a07e160511c40ccd5340e94660e9c9c01b0d27163314612668565b1694856bffffffffffffffffffffffff60a01b60085416176008551691826bffffffffffffffffffffffff60a01b600954161760095560ff8019601354169116176013555f146109f8576040516395d89b4160e01b81528281600481875afa9081156102c55783916109de575b506040516395d89b4160e01b81528381600481865afa9081156109d3576105896001600494603460208996819688916109b9575b506040519687947f52616d73657320537461626c6553776170202d20000000000000000000000000828701528051918291018587015e840190602f60f81b84830152805192839101603583015e010185838201520301601f1981018352826123e9565b94604051928380926395d89b4160e01b82525afa9081156102c5578390819261099c575b506040516395d89b4160e01b81529192829060049082905afa9081156102c55760209260298461063094600194889161097a575b5060405196879468029ba30b136329016960bd1b828701528051918291018587015e840190602f60f81b84830152805192839101602a83015e010185838201520301601f1981018352826123e9565b905b825167ffffffffffffffff81116108865761064e60145461245d565b601f8111610912575b506020601f82116001146108a55782939482939261089a575b50508160011b915f199060031b1c1916176014555b815167ffffffffffffffff8111610886576106a160155461245d565b601f811161081e575b50602092601f82116001146107b2579282938293926107a7575b50508160011b915f199060031b1c1916176015555b6106fc6040516106e8816123b9565b428152826020820152826040820152612759565b600460206001600160a01b03600854166040519283809263313ce56760e01b82525afa801561030357610736918391610778575b506127d6565b601155600460206001600160a01b03600954166040519283809263313ce56760e01b82525afa80156103035761077291839161077857506127d6565b60125580f35b61079a915060203d6020116107a0575b61079281836123e9565b8101906127bd565b5f610730565b503d610788565b015190505f806106c4565b60158352601f198216935f5160206132be5f395f51905f5291845b86811061080657508360019596106107ee575b505050811b016015556106d9565b01515f1960f88460031b161c191690555f80806107e0565b919260206001819286850151815501940192016107cd565b60158352601f820160051c5f5160206132be5f395f51905f52019060208310610871575b601f0160051c5f5160206132be5f395f51905f5201905b81811061086657506106aa565b838155600101610859565b5f5160206132be5f395f51905f529150610842565b634e487b7160e01b82526041600452602482fd5b015190505f80610670565b601483525f5160206132de5f395f51905f5290601f198316845b8181106108fa575095836001959697106108e2575b505050811b01601455610685565b01515f1960f88460031b161c191690555f80806108d4565b9192602060018192868b0151815501940192016108bf565b60148352601f820160051c5f5160206132de5f395f51905f52019060208310610965575b601f0160051c5f5160206132de5f395f51905f5201905b81811061095a5750610657565b83815560010161094d565b5f5160206132de5f395f51905f529150610936565b61099691503d808a833e61098e81836123e9565b8101906126f6565b5f6105e1565b600492506109b3903d8084833e61098e81836123e9565b916105ad565b6109cd91503d808a833e61098e81836123e9565b5f610526565b6040513d86823e3d90fd5b6109f291503d8085833e61098e81836123e9565b5f6104f2565b6040516395d89b4160e01b81528281600481875afa9081156102c5578391610ba7575b506040516395d89b4160e01b81528381600481865afa9081156109d357610aa7600160049460326020899681968891610b8d575b506040519687947102930b6b9b2b9902b37b630ba34b6329016960751b828701528051918291018587015e840190602f60f81b84830152805192839101603383015e010185838201520301601f1981018352826123e9565b94604051928380926395d89b4160e01b82525afa9081156102c55783908192610b70575b506040516395d89b4160e01b81529192829060049082905afa9081156102c557602092602b84610b50946001948891610b56575b506040519687946a02b37b630ba34b6329016960ad1b828701528051918291018587015e840190602f60f81b84830152805192839101602c83015e010185838201520301601f1981018352826123e9565b90610632565b610b6a91503d808a833e61098e81836123e9565b5f610aff565b60049250610b87903d8084833e61098e81836123e9565b91610acb565b610ba191503d808a833e61098e81836123e9565b5f610a4f565b610bbb91503d8085833e61098e81836123e9565b5f610a1b565b8380fd5b503461030e578060031936011261030e576020601054604051908152f35b503461030e57604036600319011261030e576001600160a01b036040610c076122d0565b9282610c116122e6565b9416815260016020522091165f52602052602060405f2054604051908152f35b503461030e578060031936011261030e5760206001600160a01b0360095416604051908152f35b503461030e57602036600319011261030e57610c9f336001600160a01b037f000000000000000000000000d0a07e160511c40ccd5340e94660e9c9c01b0d27163314612668565b600435600f5580f35b503461030e578060031936011261030e5760206040516001600160a01b037f000000000000000000000000d0a07e160511c40ccd5340e94660e9c9c01b0d27168152f35b503461030e578060031936011261030e576020600d54604051908152f35b503461030e578060031936011261030e576020600c54604051908152f35b503461030e57602036600319011261030e57610d426122d0565b610d4a6127e7565b6040516334ad98e160e21b81523060048201526020816024817f000000000000000000000000d0a07e160511c40ccd5340e94660e9c9c01b0d276001600160a01b03165afa9081156102c5578391610ed9575b5015610eca576001600160a01b03600854166001600160a01b036009541690604051906370a0823160e01b8252306004830152602082602481845afa918215610ebf5784908693610e87575b50610e03610e09936001600160701b03600b541690612450565b91612807565b6040516370a0823160e01b815230600482015291602083602481855afa9283156109d3578493610e51575b50610e03610283936001600160701b03600b5460701c1690612450565b92506020833d602011610e7f575b81610e6c602093836123e9565b810103126102b957915191610e03610e34565b3d9150610e5f565b9250506020823d602011610eb7575b81610ea3602093836123e9565b810103126102b95790519083610e03610de9565b3d9150610e96565b6040513d87823e3d90fd5b635712a7b360e11b8252600482fd5b610efb915060203d602011610f01575b610ef381836123e9565b8101906126c2565b5f610d9d565b503d610ee9565b503461030e578060031936011261030e5760206040516103e88152f35b503461030e57604036600319011261030e57610f4c610f426122d0565b6024359033612e24565b602060405160018152f35b503461030e57610f73610f693661238f565b92919083916124ce565b825b8151841015610f9d57610f95600191610f8e86856124ba565b51906124ad565b930192610f75565b610fa983602092612432565b604051908152f35b503461030e578060031936011261030e57604051908060155490610fd48261245d565b8085529160018116908115611056575060011461100c575b61100884610ffc818603826123e9565b604051918291826122fc565b0390f35b601581525f5160206132be5f395f51905f52939250905b80821061103c57509091508101602001610ffc82610fec565b919260018160209254838588010152019101909291611023565b60ff191660208087019190915292151560051b85019092019250610ffc9150839050610fec565b503461030e578060031936011261030e57606061109861268c565b6040805191805183526020810151602084015201516040820152f35b503461030e57602036600319011261030e576110ce6122d0565b6110d66127e7565b6110fb600b546001600160701b038116916001600160701b038260701c169160e01c90565b509290916001600160a01b0360085416916001600160a01b036009541694604051916370a0823160e01b8352306004840152602083602481885afa928315611439578193611405575b506040516370a0823160e01b815230600482015296602088602481845afa9586156103035787988398976113ce575b50308352826020526111af6111a36111a36111a86111968860408920549c612c40565b986002549384918d61240b565b612432565b9a8a61240b565b96881515806113c5575b156113b65730156113a257308452836020526040842054818110611389579184826020936024969530845283865203604083205580600254036002556040519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef843092a361122b8a8983612807565b611236898985612807565b6040516370a0823160e01b815230600482015293849182905afa9182156102c5578392611354575b506020602491604051928380926370a0823160e01b82523060048301525afa928315611348579261130d575b5096611299929160409861297f565b6112ea575b6001600160a01b0384519184835283602084015216907fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496853392a3600160055582519182526020820152f35b611305600b546001600160701b03808260701c1691166128ca565b600e5561129e565b929150966020833d602011611340575b8161132a602093836123e9565b810103126102b95791519196909190604061128a565b3d915061131d565b604051903d90823e3d90fd5b9091506020813d602011611381575b81611370602093836123e9565b810103126102b9575190602061125e565b3d9150611363565b63391434e360e21b855230600452602452604452606483fd5b634b637e8f60e11b84526004849052602484fd5b63ca7551f760e01b8452600484fd5b508715156111b9565b965096506020863d6020116113fd575b816113eb602093836123e9565b810103126102b957879551965f611173565b3d91506113de565b9092506020813d602011611431575b81611421602093836123e9565b810103126102b95751915f611144565b3d9150611414565b50604051903d90823e3d90fd5b503461030e578060031936011261030e576020600e54604051908152f35b503461030e57602036600319011261030e5760406020916001600160a01b0361148b6122d0565b1681528083522054604051908152f35b503461030e57602036600319011261030e576024906114b86122d0565b6114c06127e7565b6114e5600b546001600160701b038116916001600160701b038260701c169160e01c90565b5093909160206001600160a01b0360085416604051938480926370a0823160e01b82523060048301525afa9182156109d3578492611796575b506024919260206001600160a01b0360095416604051948580926370a0823160e01b82523060048301525afa928315610ebf578593611762575b506001600160701b0381169261156e8486612450565b946001600160701b038816936115848584612450565b95876115908b87612c40565b966002549283155f146117385750506115b39150876115ae9161240b565b612ee1565b6103e719810190811161172457976115cf6103e861dead61320f565b60ff6013541661166d575b881561165e5750916115f993916115f48960209b95613003565b61297f565b61163b575b604051918252838201527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f60403392a26001600555604051908152f35b611656600b546001600160701b03808260701c1691166128ca565b600e556115fe565b6314e13d6d60e31b8152600490fd5b633b9aca0061167c888a6128ca565b1061171557670de0b6b3a76400008802888104670de0b6b3a76400001489151715611701576011546116ad91612432565b670de0b6b3a76400008802888104670de0b6b3a764000014891517156116ed576012546116d991612432565b146115da57631bca023d60e31b8152600490fd5b634e487b7160e01b83526011600452602483fd5b634e487b7160e01b82526011600452602482fd5b63a932492f60e01b8152600490fd5b634e487b7160e01b89526011600452602489fd5b61174c6111a3916111a3866117539661240b565b938a61240b565b908180821091180218976115da565b9092506020813d60201161178e575b8161177e602093836123e9565b810103126102b95751915f611558565b3d9150611771565b91506020823d6020116117c3575b816117b1602093836123e9565b810103126102b957602491519161151e565b3d91506117a4565b503461030e57602036600319011261030e57611812336001600160a01b037f000000000000000000000000d0a07e160511c40ccd5340e94660e9c9c01b0d27163314612668565b60043560105580f35b503461030e578060031936011261030e576020600f54604051908152f35b503461030e5761100861185461184e3661238f565b916124ce565b60405191829182612326565b503461030e57604036600319011261030e5761187a6122d0565b9061188361268c565b9061188c6125ba565b5091835142146118d8575b6020610fa986866118cf6111a36111a38960406118c68b6118b9885142612450565b9586918c8a015190612450565b95015190612450565b91602435612ab3565b600654919350600119820191821161037d5750916118cf6111a36111a36020969460406118c661191361190d610fa99a61235f565b50612640565b985050509496505050611897565b503461030e578060031936011261030e5760206001600160a01b03600a5416604051908152f35b503461030e578060031936011261030e5760e0601154601254600b5460ff601354166001600160701b036001600160a01b0360085416926001600160a01b0360095416946040519687526020870152818116604087015260701c1660608501521515608084015260a083015260c0820152f35b503461030e578060031936011261030e57602060405160128152f35b503461030e57602036600319011261030e57600435600654811015611a2c576119ff9061235f565b50805461100860026001840154930154604051938493846040919493926060820195825260208201520152565b5080fd5b503461030e57606036600319011261030e57611a4a6122d0565b611a526122e6565b604435916001600160a01b0381168085526001602052604085206001600160a01b0333165f5260205260405f2054905f198203611a96575b5050610f4c9350612e24565b848210611aff578015611aeb573315611ad75785604091610f4c97526001602052206001600160a01b0333165f526020528360405f20910390555f80611a8a565b634a1406b160e11b86526004869052602486fd5b63e602df0560e01b86526004869052602486fd5b6064868684637dc7a0d960e11b835233600452602452604452fd5b503461030e578060031936011261030e57602060ff601354166040519015158152f35b503461030e578060031936011261030e57611008611b596125ba565b604080519384526020840192909252908201529081906060820190565b503461030e578060031936011261030e576020600254604051908152f35b503461030e578060031936011261030e57611bad6127e7565b600b546001600160701b038082169160701c16611bca8183612c40565b611bd8575b82600160055580f35b611be1916128ca565b600e555f80611bcf565b503461030e57608036600319011261030e57611c056122d0565b9060643590604435602435611c1982612495565b94611c2760405196876123e9565b828652601f19611c3684612495565b013660208801376006545f19810193908411611d1257611c5c86611c629296959661240b565b85612450565b925b848410611c7957604051806110088982612326565b856001611d0c92611cfa611c8d84896124ad565b611cf2611caf611c9c8361235f565b5054611ca78c61235f565b505490612450565b6111a38b6002611cda81611ce9611ce3876111a38e611ccd8d61235f565b5001548f611cda8a61235f565b50015490612450565b9861235f565b5001549261235f565b908789612ab3565b611d04828c6124ba565b5201946124ad565b92611c64565b634e487b7160e01b85526011600452602485fd5b503461030e578060031936011261030e5760206001600160a01b0360085416604051908152f35b503461030e57604036600319011261030e57611d676122d0565b602435903315611de4576001600160a01b0316918215611dd057604090338152600160205220825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b634a1406b160e11b81526004819052602490fd5b63e602df0560e01b83526004839052602483fd5b503461030e578060031936011261030e5760606001600160701b0363ffffffff611e3d600b546001600160701b038116916001600160701b038260701c169160e01c90565b9193908160405195168552166020840152166040820152f35b503461030e578060031936011261030e57604051908060145490611e798261245d565b80855291600181169081156110565750600114611ea05761100884610ffc818603826123e9565b601481525f5160206132de5f395f51905f52939250905b808210611ed057509091508101602001610ffc82610fec565b919260018160209254838588010152019101909291611eb7565b50346102b95760803660031901126102b957604435906001600160a01b0382166024356004358285036102b95760643567ffffffffffffffff81116102b957366023820112156102b95780600401359067ffffffffffffffff82116102b95736602483830101116102b957611f5d6127e7565b821590811580926122c7575b156122b857611f93600b546001600160701b038116916001600160701b038260701c169160e01c90565b509290916001600160701b03831694858710806122a6575b15612297576001600160a01b03600854169a6001600160a01b0360095416938c8b14158061228d575b1561227e5788828e9261226d575b505050888061225c575b5050806121cb575b505060206024979899604051988980926370a0823160e01b82523060048301525afa96871561218b578997612196575b506020602491604051928380926370a0823160e01b82523060048301525afa90811561218b578991612159575b5084840380881115612151578703965b6001600160701b0384169487860380841115612149578303955b8915801590612140575b15612131576120ce906120c88b6120c2620f42406120bb6120b4826120ad601054809761240b565b048a612450565b938d61240b565b0488612450565b906128ca565b926128ca565b1161212257906120df93929161297f565b6040519384526020840152604083015260608201527fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d82260803392a3600160055580f35b63a932492f60e01b8a5260048afd5b63367e619960e11b8c5260048cfd5b50861515612085565b508a9561207b565b508896612061565b90506020813d602011612183575b81612174602093836123e9565b810103126102b957515f612051565b3d9150612167565b6040513d8b823e3d90fd5b9096506020813d6020116121c3575b816121b2602093836123e9565b810103126102b95751956020612024565b3d91506121a5565b883b156102b9578760a488835f9460246040519788968795639a7bff7960e01b87523360048801528387015260448601526080606486015282608486015201848401378181018301859052601f01601f19168101030181838c5af1801561225157612237575b80611ff4565b60249798505f612246916123e9565b60205f989750612231565b6040513d5f823e3d90fd5b6122669185612807565b5f88611fec565b61227692612807565b8b8882611fe2565b630de2b4ad60e31b5f5260045ffd5b50848b1415611fd4565b63827e7b7f60e01b5f5260045ffd5b506001600160701b0385168810611fab565b6309f7208b60e21b5f5260045ffd5b50841515611f69565b600435906001600160a01b03821682036102b957565b602435906001600160a01b03821682036102b957565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b60206040818301928281528451809452019201905f5b8181106123495750505090565b825184526020938401939092019160010161233c565b60065481101561237b5760065f52600360205f20910201905f90565b634e487b7160e01b5f52603260045260245ffd5b60609060031901126102b9576004356001600160a01b03811681036102b957906024359060443590565b6060810190811067ffffffffffffffff8211176123d557604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176123d557604052565b8181029291811591840414171561241e57565b634e487b7160e01b5f52601160045260245ffd5b811561243c570490565b634e487b7160e01b5f52601260045260245ffd5b9190820391821161241e57565b90600182811c9216801561248b575b602083101461247757565b634e487b7160e01b5f52602260045260245ffd5b91607f169161246c565b67ffffffffffffffff81116123d55760051b60200190565b9190820180921161241e57565b805182101561237b5760209160051b010190565b6124d783612495565b926124e560405194856123e9565b808452601f196124f482612495565b013660208601376006545f1981019190821161241e578015818004600114171561241e5761252490829492612450565b905f5b84831061253657505050505090565b600183019081841161241e5761259c8261259461256261255760019661235f565b5054611ca78961235f565b6111a36002612586612580846111a38d8c611cda81611ce98d61235f565b9561235f565b5001546002611cda8b61235f565b908786612ab3565b6125a682896124ba565b5201916001810180911161241e5791612527565b4290600c5491600d549163ffffffff6125ee600b546001600160701b038116916001600160701b038260701c169160e01c90565b9092164263ffffffff16810361260357505050565b6001600160701b0361263661263d9597949861263061263095612627859642612450565b9586911661240b565b906124ad565b971661240b565b91565b9060405161264d816123b9565b60406002829480548452600181015460208501520154910152565b156126705750565b6001600160a01b0390632bc10c3360e01b5f521660045260245ffd5b5f6040805161269a816123b9565b82815282602082015201526006545f19810190811161241e5761190d6126bf9161235f565b90565b908160209103126102b9575180151581036102b95790565b67ffffffffffffffff81116123d557601f01601f191660200190565b6020818303126102b95780519067ffffffffffffffff82116102b9570181601f820112156102b95780519061272a826126da565b9261273860405194856123e9565b828452602083830101116102b957815f9260208093018386015e8301015290565b600654600160401b8110156123d5576001810160065560065481101561237b5760065f526003027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0190604081600292518455602081015160018501550151910155565b908160209103126102b9575160ff811681036102b95790565b60ff16604d811161241e57600a0a90565b6002600554146127f8576002600555565b633ee5aeb560e01b5f5260045ffd5b919091803b156102b9575f92838093604051906001600160a01b03602083019463a9059cbb60e01b865216602483015260448201526044815261284b6064826123e9565b51925af13d156128c3573d61285f816126da565b9061286d60405192836123e9565b81523d5f602083013e5b81612894575b501561288557565b6355ee504b60e01b5f5260045ffd5b80518015925082156128a9575b50505f61287d565b6128bc92506020809183010191016126c2565b5f806128a1565b6060612877565b60135460ff161561297557670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e5760115461290291612432565b90670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e57670de0b6b3a76400009161296b6129416129719360125490612432565b846129648161295c81612954868961240b565b04968061240b565b04928061240b565b04906124ad565b9061240b565b0490565b906126bf9161240b565b91926001600160701b0383111580612aa2575b15612a93576001600160701b0360409381927f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad196600b5460e01c918242039242141580612a88575b80612a7d575b612a5f575b5050506107086129fd6129f661268c565b5142612450565b11612a34575b16918263ffffffff60e01b4260e01b16918360701b9060701b16171780600b55835192835260701c166020820152a1565b612a5a600c54600d54875191612a49836123b9565b428352602083015287820152612759565b612a03565b828580931602600c5401600c551602600d5401600d555f80806129e5565b5084811615156129e0565b5084821615156129da565b6395a5c7f960e01b5f5260045ffd5b506001600160701b03821115612992565b9291909160ff601354165f14612bfc57612acd81836128ca565b91670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e57612afc6011548092612432565b92670de0b6b3a7640000830292808404670de0b6b3a7640000149015171561241e57612b2b6012548094612432565b946001600160a01b03806008541691161493845f14612bf757945b8415612bb457670de0b6b3a7640000870296808804670de0b6b3a7640000149015171561241e57612b9981612b9f93612b9461297199612b8f88670de0b6b3a76400009d612432565b6124ad565b61301c565b90612450565b9215612bac57509061240b565b90509061240b565b670de0b6b3a7640000870296808804670de0b6b3a7640000149015171561241e57612b9981612b9f93612b9461297199612b8f89670de0b6b3a76400009d612432565b612b46565b9091926126bf936001600160a01b0380600854169116145f14612c3357612c27612c2d925b8261240b565b926124ad565b90612432565b612c27612c2d9293612c21565b91906001600160a01b03600a541690600e549382151594855f14612dfa57600f549181612c70575b50505050505b565b60135460ff1615612d6d576001600160701b0380612c929394951691166128ca565b90808211612caa575b505050505b5f80808080612c68565b612cc991612cc3612cbd6115ae93612ee1565b91612ee1565b90613146565b670de0b6b3a76400000390670de0b6b3a7640000821161241e57612ced828261240b565b91670de0b6b3a7640000830292808404670de0b6b3a7640000149015171561241e57612d189161240b565b69d3c21bcecceda1000000039069d3c21bcecceda1000000821161241e57670de0b6b3a7640000916111a3612d4f9260025461240b565b0480612d5d575b8080612c9b565b612d6691613003565b5f80612d56565b6115ae612d8a916001600160701b0380612d9095971691166128ca565b92612ee1565b808311612da1575b50505050612ca0565b612dd481612dcf620f4240612dc6612dbf6111a396612ddd99612450565b968761240b565b049485926124ad565b612450565b9160025461240b565b80612dea575b8080612d98565b612df391613003565b5f80612de3565b92505050612e0457565b612e1f600b546001600160701b03808260701c1691166128ca565b600e55565b6001600160a01b0316908115612ece576001600160a01b0316918215612ebb57815f525f60205260405f2054818110612ea257817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b63ec442f0560e01b5f525f60045260245ffd5b634b637e8f60e11b5f525f60045260245ffd5b60018111156126bf57806001600160801b821015612ff2575b600482600160401b612fa4941015612fe5575b640100000000811015612fd8575b62010000811015612fcb575b610100811015612fbf575b6010811015612fb3575b1015612fab575b60030260011c612f538184612432565b0160011c612f618184612432565b0160011c612f6f8184612432565b0160011c612f7d8184612432565b0160011c612f8b8184612432565b0160011c612f998184612432565b0160011c8092612432565b8111900390565b60011b612f43565b811c9160021b91612f3c565b60081c91811b91612f32565b60101c9160081b91612f27565b60201c9160101b91612f1b565b60401c9160201b91612f0d565b5050608081901c600160401b612efa565b906001600160a01b03821615612ebb57612c6e9161320f565b905f5b60ff811061302d5750505090565b83613078670de0b6b3a764000061305a81613053858261304d828061240b565b0461240b565b048761240b565b04670de0b6b3a7640000612964848261304d8a8261304d828061240b565b8380821015613102579061308b91612450565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e57816126306130c092612c2d6001958961327c565b945b85818111156130eb57906130d591612450565b11156130e5576001905b0161301f565b50505090565b6130f491612450565b11156130e5576001906130df565b61310b91612450565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561241e5781612b9961314092612c2d6001958961327c565b946130c2565b906ec097ce7bc90715b34b9f10000000008202905f196ec097ce7bc90715b34b9f100000000084099282808510940393808503941461320357838211156131eb576ec097ce7bc90715b34b9f1000000000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b50906126bf9250612432565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206001600160a01b035f93613248866002546124ad565b6002551693841584146132675780600254036002555b604051908152a3565b8484528382526040842081815401905561325e565b8060030260038104820361241e57612964670de0b6b3a76400006132b08193826132a9886126bf9961240b565b049061240b565b04928261304d828061240b56fe55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec475ce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4eca2646970667358221220aa2b51e9d5d4cc7ac06c836897ea219aa65d323465781e4b681b512d91fcfbea64736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.