ETH Price: $1,803.74 (+9.75%)

Contract

0x1638438CE0960a1f6A139eF87B292c0B62Dbb3c3

Overview

ETH Balance

0.118708123448446645 ETH

ETH Value

$214.12 (@ $1,803.74/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

> 10 Internal Transactions found.

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
130400952025-04-23 13:43:498 secs ago1745415829
0x1638438C...B62Dbb3c3
0 ETH
130400922025-04-23 13:43:4314 secs ago1745415823
0x1638438C...B62Dbb3c3
0 ETH
130400862025-04-23 13:43:3126 secs ago1745415811
0x1638438C...B62Dbb3c3
0.00002814 ETH
130400832025-04-23 13:43:2532 secs ago1745415805
0x1638438C...B62Dbb3c3
0 ETH
130400802025-04-23 13:43:1938 secs ago1745415799
0x1638438C...B62Dbb3c3
0.00002814 ETH
130400772025-04-23 13:43:1344 secs ago1745415793
0x1638438C...B62Dbb3c3
0 ETH
130400742025-04-23 13:43:0750 secs ago1745415787
0x1638438C...B62Dbb3c3
0 ETH
130400652025-04-23 13:42:491 min ago1745415769
0x1638438C...B62Dbb3c3
0.00002815 ETH
130400622025-04-23 13:42:431 min ago1745415763
0x1638438C...B62Dbb3c3
0 ETH
130400592025-04-23 13:42:371 min ago1745415757
0x1638438C...B62Dbb3c3
0.00002815 ETH
130400422025-04-23 13:42:031 min ago1745415723
0x1638438C...B62Dbb3c3
0 ETH
130400422025-04-23 13:42:031 min ago1745415723
0x1638438C...B62Dbb3c3
0 ETH
130400422025-04-23 13:42:031 min ago1745415723
0x1638438C...B62Dbb3c3
0.00000038 ETH
130400242025-04-23 13:41:272 mins ago1745415687
0x1638438C...B62Dbb3c3
0 ETH
130400182025-04-23 13:41:152 mins ago1745415675
0x1638438C...B62Dbb3c3
0.0000001 ETH
130400082025-04-23 13:40:553 mins ago1745415655
0x1638438C...B62Dbb3c3
0 ETH
130399842025-04-23 13:40:073 mins ago1745415607
0x1638438C...B62Dbb3c3
0 ETH
130399782025-04-23 13:39:554 mins ago1745415595
0x1638438C...B62Dbb3c3
0 ETH
130399722025-04-23 13:39:434 mins ago1745415583
0x1638438C...B62Dbb3c3
0 ETH
130399722025-04-23 13:39:434 mins ago1745415583
0x1638438C...B62Dbb3c3
0.00003042 ETH
130399722025-04-23 13:39:434 mins ago1745415583
0x1638438C...B62Dbb3c3
0.00000005 ETH
130399582025-04-23 13:39:154 mins ago1745415555
0x1638438C...B62Dbb3c3
0 ETH
130399302025-04-23 13:38:195 mins ago1745415499
0x1638438C...B62Dbb3c3
0.0000001 ETH
130399302025-04-23 13:38:195 mins ago1745415499
0x1638438C...B62Dbb3c3
0 ETH
130399242025-04-23 13:38:075 mins ago1745415487
0x1638438C...B62Dbb3c3
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TOTC

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 200 runs

Other Settings:
cancun EvmVersion
File 1 of 8 : TOTC.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {IPileus} from "./interfaces/IPileus.sol";
import {IOCO} from "./interfaces/IOCO.sol";

/// @title TOTC Contract
/// @author pileum.org
/// @notice Manages the OCO allowance and trading mechanisms for Pileus owners.
/// @dev OCO tokens can be minted only by this contract. It supports claiming, buying,
/// settling, and withdrawing based on per-epoch rules.
/// @custom:security-contact [email protected]
contract TOTC is Ownable {
    // =============================================================
    //                           EVENTS
    // =============================================================

    /// @notice Emitted when the allowance parameters are updated.
    /// @param allowanceSlope The new slope used in allowance calculations.
    /// @param allowanceIntercept The new intercept used in allowance calculations.
    event AllowanceUpdate(int256 allowanceSlope, int256 allowanceIntercept);

    /// @notice Emitted when a user buys OCO tokens by investing ETH.
    /// @param operator The address performing the buy operation.
    /// @param epoch The epoch in which the buy is executed.
    /// @param valuePerBlock The computed ETH value allocated per block.
    /// @param remainder The remaining ETH returned to the user.
    event Buy(address indexed operator, uint32 indexed epoch, uint128 valuePerBlock, uint128 remainder);

    /// @notice Emitted when a Pileus owner claims their OCO allowance.
    /// @param operator The address initiating the claim.
    /// @param tokenId The Pileus token id used for the claim.
    /// @param to The recipient address of the minted OCO tokens (or burn indicator if address(0)).
    /// @param amount The amount of OCO tokens claimed.
    /// @param used The updated claim index after the claim.
    event Claim(address indexed operator, uint256 indexed tokenId, address indexed to, uint128 amount, uint128 used);

    /// @notice Emitted when an account settles their invested ETH into OCO tokens.
    /// @param operator The address that settled the account.
    /// @param value The invested ETH value that was settled.
    /// @param amountQ128 The settled OCO token amount in fixed-point Q128.
    /// @param duration The number of blocks over which settlement was calculated.
    event Settle(address indexed operator, uint128 value, uint256 amountQ128, uint48 duration);

    /// @notice Emitted when a Pileus token owner withdraws proceeds from unclaimed allowance.
    /// @param operator The address withdrawing the proceeds.
    /// @param amount The amount of OCO allowance withdrawn.
    /// @param valueQ128 The corresponding ETH value in fixed-point Q128.
    event Withdraw(address indexed operator, uint128 amount, uint256 valueQ128);

    /// @notice Emitted when total balances are updated for an epoch.
    /// @param totalSupply Total OCO supply that could be invested.
    /// @param supplyClaimed Total OCO supply that has been claimed.
    /// @param supplyWithdrawn Total OCO supply that has been withdrawn.
    /// @param supplySettled Total OCO supply that has been settled (in Q128 fixed-point).
    /// @param valueInvested Total ETH invested.
    /// @param valueSettled Total ETH settled.
    /// @param valueWithdrawn Total ETH withdrawn (in Q128 fixed-point).
    event TotalBalancesUpdate(
        uint128 totalSupply,
        uint128 supplyClaimed,
        uint128 supplyWithdrawn,
        uint256 supplySettled,
        uint128 valueInvested,
        uint128 valueSettled,
        uint256 valueWithdrawn
    );

    // =============================================================
    //                        STORAGE VARIABLES
    // =============================================================

    uint256 internal constant Q128 = 1 << 128;
    uint48 private immutable _epochDuration;
    IPileus public immutable pileus;
    IOCO public immutable oco;
    int256 private _allowanceSlope;
    int256 private _allowanceIntercept;

    /// @notice Information for an account's buy order.
    /// @param valuePerBlk ETH invested per block (in wei).
    /// @param lastSettle Last block index at which settlement was executed.
    struct AccountInfo {
        uint128 valuePerBlk;
        uint48 lastSettle;
    }

    /// @notice Mapping for account information per epoch.
    /// @dev The key is generated via balancesKey(epoch, account).
    mapping(uint256 balancesKey => AccountInfo) private _balances;

    /// @notice Tracks the last claimed or withdrawn allowance (in blocks) per Pileus token.
    mapping(uint256 tokenId => uint48) private _allowances;

    /// @notice Aggregated totals for allowance and ETH values per epoch.
    /// @param supplyClaimed Total claimed OCO tokens.
    /// @param supplyWithdrawn Total OCO tokens withdrawn.
    /// @param supplySettled Total settled OCO tokens (fixed-point Q128).
    /// @param valueInvested Total ETH invested (in wei).
    /// @param valueSettled Total ETH settled (in wei).
    /// @param valueWithdrawn Total ETH withdrawn (fixed-point Q128).
    struct TotalBalances {
        uint128 supplyClaimed;
        uint128 supplyWithdrawn;
        uint256 supplySettled;
        uint128 valueInvested;
        uint128 valueSettled;
        uint256 valueWithdrawn;
    }

    /// @notice Mapping of total balances by epoch.
    mapping(uint32 epoch => TotalBalances) private _totals;

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    /// @notice Initializes the TOTC contract.
    /// @param initialOwner The address of the initial contract owner.
    /// @param _pileus The address of the Pileus ERC721 contract.
    /// @param _oco The address of the OCO ERC20 contract.
    /// @param allowanceSlope The initial slope for allowance calculation.
    /// @param allowanceIntercept The initial intercept for allowance calculation.
    constructor(address initialOwner, IPileus _pileus, IOCO _oco, int256 allowanceSlope, int256 allowanceIntercept)
        Ownable(initialOwner)
    {
        pileus = _pileus;
        oco = _oco;
        _epochDuration = pileus.EPOCH_DURATION();
        _allowanceSlope = allowanceSlope;
        _allowanceIntercept = allowanceIntercept;
    }

    // =============================================================
    //                         MUTATING FUNCTIONS
    // =============================================================

    /// @notice Updates the allowance calculation parameters.
    /// @param allowanceSlope The new slope for allowance calculation.
    /// @param allowanceIntercept The new intercept for allowance calculation.
    /// @param blockNumber If non-zero, requires execution at the specified block number.
    /// @dev Only the owner can call this function.
    function setAllowance(int256 allowanceSlope, int256 allowanceIntercept, uint48 blockNumber) public onlyOwner {
        if (blockNumber > 0) {
            require(blockNumber == block.number, "Can only be executed at specified block");
        }
        _allowanceSlope = allowanceSlope;
        _allowanceIntercept = allowanceIntercept;
        emit AllowanceUpdate(allowanceSlope, allowanceIntercept);
    }

    /// @notice Claims an OCO allowance for a given Pileus token.
    /// @param tokenId The Pileus token id.
    /// @param to The recipient address to receive OCO tokens (or zero address to track burn).
    /// @param duration The duration (in blocks) to claim.
    /// @return amount The amount of OCO tokens minted as a result of the claim.
    /// @dev Caller must be the token owner or approved. If the token was minted in the current epoch,
    /// any pending withdrawal is processed before claiming.
    function claim(uint256 tokenId, address to, uint48 duration) public returns (uint128 amount) {
        require(duration > 0, "Null claimed duration");
        (address owner, uint48 mintBlock) = pileus.propsOf(tokenId);
        require(
            msg.sender == owner || pileus.getApproved(tokenId) == msg.sender
                || pileus.isApprovedForAll(owner, msg.sender),
            "Caller is not token owner nor approved"
        );
        uint32 mintEpoch = SafeCast.toUint32(mintBlock / _epochDuration);
        require(mintEpoch >= currEpoch(), "Cannot claim past epoch");
        if (mintEpoch == currEpoch()) {
            _withdraw(tokenId, mintEpoch);
        }
        uint48 claimIndex = _allowances[tokenId] + duration;
        require(claimIndex <= _epochDuration, "Duration exceeds available allowance");
        amount = getAllowanceAtEpoch(mintEpoch, duration);
        _totals[mintEpoch].supplyClaimed += amount;
        _allowances[tokenId] += duration;

        if (to == address(0)) {
            oco.trackBurn(msg.sender, amount);
        } else {
            oco.mint(to, amount);
        }

        emit Claim(msg.sender, tokenId, to, amount, claimIndex);
        if (mintEpoch == currEpoch()) {
            _emitTotalBalancesUpdate(mintEpoch);
        }
    }

    /// @notice Invests ETH to buy OCO tokens for a specified epoch.
    /// @param epoch The epoch in which to buy tokens.
    /// @return remainder The remainder of ETH returned to the buyer if not fully utilized.
    /// @dev When buying in the current epoch, the settlement is triggered and the duration is adjusted.
    /// The ETH value is divided equally over the remaining blocks.
    function buy(uint32 epoch) public payable returns (uint128) {
        uint48 duration = _epochDuration;
        uint128 value = SafeCast.toUint128(msg.value);
        require(value > 0, "Value must be higher than zero");
        require(epoch >= currEpoch(), "Cannot buy past epoch");
        if (epoch == currEpoch()) {
            settle(epoch);
            duration -= blockIndex();
        }
        require(getAllowanceAtEpoch(epoch, duration) > 0, "Nothing to buy");

        uint128 remainder = value % duration;
        uint128 valuePerBlock = value / duration;
        require(valuePerBlock > 0, "Invalid valuePerBlock");

        _balances[balancesKey(epoch, msg.sender)].valuePerBlk += valuePerBlock;
        _totals[epoch].valueInvested += (value - remainder);

        if (remainder > 0) {
            payable(msg.sender).transfer(remainder);
        }

        emit Buy(msg.sender, epoch, valuePerBlock, remainder);
        if (epoch == currEpoch()) {
            _emitTotalBalancesUpdate(epoch);
        }
        return remainder;
    }

    /// @notice Settles invested ETH into OCO tokens for the specified epoch.
    /// @param epoch The epoch to settle.
    /// @return amount The amount of OCO tokens minted as a result of settling.
    /// @dev Can only settle for the current or past epochs.
    function settle(uint32 epoch) public returns (uint128 amount) {
        require(epoch <= currEpoch(), "Cannot settle future epoch");
        AccountInfo storage acc = _balances[balancesKey(epoch, msg.sender)];
        uint48 settleIndex = epoch == currEpoch() ? blockIndex() : _epochDuration;
        if (acc.lastSettle < settleIndex) {
            uint48 duration = settleIndex - acc.lastSettle;
            uint128 value = acc.valuePerBlk * duration;
            uint256 amountQ128 = settlePrice(epoch, value);
            amount = uint128(amountQ128 / Q128);
            if (amount > 0) {
                oco.mint(msg.sender, amount);
                TotalBalances storage t = _totals[epoch];
                t.valueSettled += value;
                t.supplySettled += amountQ128;
                emit Settle(msg.sender, value, amountQ128, duration);
                if (epoch == currEpoch()) {
                    _emitTotalBalancesUpdate(epoch);
                }
            }
            acc.lastSettle = settleIndex;
        }
    }

    /// @notice Withdraws ETH proceeds from unclaimed allowance for a given Pileus token.
    /// @param tokenId The Pileus token id.
    /// @return value The amount of ETH withdrawn (in wei).
    /// @dev Caller must be the token owner or approved. Withdrawal can only occur for current or past epochs.
    function withdraw(uint256 tokenId) public returns (uint128 value) {
        (address owner, uint48 mintBlock) = pileus.propsOf(tokenId);
        require(
            msg.sender == owner || pileus.getApproved(tokenId) == msg.sender
                || pileus.isApprovedForAll(owner, msg.sender),
            "Caller is not token owner nor approved"
        );
        uint32 mintEpoch = SafeCast.toUint32(mintBlock / _epochDuration);
        require(mintEpoch <= currEpoch(), "Cannot withdraw future epoch");
        return _withdraw(tokenId, mintEpoch);
    }

    /// @notice Internal function that processes the withdrawal of ETH proceeds.
    /// @param tokenId The Pileus token id.
    /// @param mintEpoch The epoch in which the token was minted.
    /// @return value The computed ETH value withdrawn (in wei).
    /// @dev Updates the token's allowance index and emits a Withdraw event.
    function _withdraw(uint256 tokenId, uint32 mintEpoch) internal returns (uint128 value) {
        uint48 withdrawIndex = mintEpoch == currEpoch() ? blockIndex() : _epochDuration;
        uint48 lastWithdraw = _allowances[tokenId];
        if (lastWithdraw < withdrawIndex) {
            uint128 amount = getAllowanceAtEpoch(mintEpoch, withdrawIndex - lastWithdraw);
            uint256 valueQ128 = withdrawPrice(mintEpoch, amount);
            value = uint128(valueQ128 / Q128);
            TotalBalances storage t = _totals[mintEpoch];
            t.valueWithdrawn += valueQ128;
            t.supplyWithdrawn += amount;
            _allowances[tokenId] = withdrawIndex;
            if (value > 0) {
                payable(msg.sender).transfer(value);
            }
            emit Withdraw(msg.sender, amount, valueQ128);
            if (mintEpoch == currEpoch()) {
                _emitTotalBalancesUpdate(mintEpoch);
            }
        }
    }

    function _emitTotalBalancesUpdate(uint32 epoch) internal {
        TotalBalances memory t = _totals[epoch];
        uint128 totalSupply = uint128(getTotalAllowanceSupply(epoch));
        emit TotalBalancesUpdate(
            totalSupply,
            t.supplyClaimed,
            t.supplyWithdrawn,
            t.supplySettled,
            t.valueInvested,
            t.valueSettled,
            t.valueWithdrawn
        );
    }

    // =============================================================
    //                          VIEW FUNCTIONS
    // =============================================================

    /// @notice Returns the current block index within the active epoch.
    /// @return The block index relative to the epoch duration.
    function blockIndex() public view returns (uint48) {
        return uint48(block.number) % _epochDuration;
    }

    /// @notice Returns the current epoch number.
    /// @return The current epoch computed from the block number.
    function currEpoch() public view returns (uint32) {
        return SafeCast.toUint32(block.number / _epochDuration);
    }

    /// @notice Generates a unique key for an account's balance information.
    /// @param epoch The epoch for which the key is generated.
    /// @param account The account address.
    /// @return A unique uint256 key composed of the epoch and account.
    function balancesKey(uint32 epoch, address account) public pure returns (uint256) {
        return (uint256(epoch) << 160) | uint256(uint160(account));
    }

    /// @notice Retrieves the account's investment information for a given epoch.
    /// @param epoch The epoch number.
    /// @param account The address of the account.
    /// @return valuePerBlk The ETH value invested per block.
    /// @return lastSettle The last block index when settlement occurred.
    function getAccountInfo(uint32 epoch, address account) external view returns (uint128, uint48) {
        AccountInfo memory acc = _balances[balancesKey(epoch, account)];
        return (acc.valuePerBlk, acc.lastSettle);
    }

    /// @notice Returns the current allowance (in blocks) already claimed or withdrawn for a token.
    /// @param tokenId The Pileus token id.
    /// @return The current allowance index.
    function getAllowance(uint256 tokenId) external view returns (uint48) {
        return _allowances[tokenId];
    }

    /// @notice Calculates the OCO token allowance for a given epoch and duration.
    /// @param epoch The epoch for which the allowance is computed.
    /// @param duration The duration (in blocks) to calculate allowance for.
    /// @return amount The computed OCO token amount for the specified duration.
    /// @dev Uses the allowanceSlope and allowanceIntercept parameters.
    function getAllowanceAtEpoch(uint32 epoch, uint48 duration) public view returns (uint128 amount) {
        if (duration > 0 && duration <= _epochDuration) {
            int256 allowancePerEpoch = (_allowanceSlope * int256(uint256(epoch))) + _allowanceIntercept;
            if (allowancePerEpoch > 0) {
                amount = SafeCast.toUint128(Math.mulDiv(uint256(allowancePerEpoch), duration, _epochDuration * Q128));
            }
        }
    }

    /// @notice Retrieves the current allowance calculation parameters.
    /// @return allowanceSlope The current allowance slope.
    /// @return allowanceIntercept The current allowance intercept.
    function getAllowanceParams() external view returns (int256, int256) {
        return (_allowanceSlope, _allowanceIntercept);
    }

    /// @notice Computes the total OCO allowance supply for an epoch.
    /// @param epoch The epoch number.
    /// @return totalSupply The total supply of OCO tokens available for allowance,
    /// calculated as the Pileus total supply multiplied by the allowance per epoch.
    /// @dev Uses current supply or past supply depending on the epoch.
    function getTotalAllowanceSupply(uint32 epoch) public view returns (uint256 totalSupply) {
        if (epoch == currEpoch()) {
            totalSupply = pileus.getTotalSupply();
        } else {
            uint48 epochEnd = (epoch + 1) * _epochDuration;
            require(epochEnd > 0, "Epoch end must be greater than zero");
            totalSupply = pileus.getPastTotalSupply(epochEnd - 1);
        }
        totalSupply *= getAllowanceAtEpoch(epoch, _epochDuration);
    }

    /// @notice Returns the aggregated totals for a given epoch.
    /// @param epoch The epoch number.
    /// @return supplyClaimed Total claimed OCO tokens.
    /// @return supplySettled Total settled OCO tokens (fixed-point Q128).
    /// @return supplyWithdrawn Total withdrawn OCO tokens.
    /// @return valueInvested Total ETH invested (in wei).
    /// @return valueSettled Total ETH settled (in wei).
    /// @return valueWithdrawn Total ETH withdrawn (fixed-point Q128).
    function getTotals(uint32 epoch) external view returns (uint128, uint256, uint128, uint128, uint128, uint256) {
        TotalBalances memory t = _totals[epoch];
        return (t.supplyClaimed, t.supplySettled, t.supplyWithdrawn, t.valueInvested, t.valueSettled, t.valueWithdrawn);
    }

    /// @notice Calculates the settlement price for a given invested ETH value.
    /// @param epoch The epoch number.
    /// @param value The invested ETH value (in wei) to be settled.
    /// @return amount The amount of OCO tokens (in Q128 fixed-point) computed for settlement.
    /// @dev The calculation is based on the remaining available allowance and the difference
    /// between invested and settled values.
    function settlePrice(uint32 epoch, uint128 value) public view returns (uint256 amount) {
        if (value > 0) {
            TotalBalances memory t = _totals[epoch];
            uint256 supplyInvestedQ128 = (getTotalAllowanceSupply(epoch) - t.supplyClaimed) * Q128;
            if (t.valueSettled < t.valueInvested && t.supplySettled < supplyInvestedQ128) {
                amount = Math.mulDiv((supplyInvestedQ128 - t.supplySettled), value, (t.valueInvested - t.valueSettled));
            }
        }
    }

    /// @notice Calculates the withdrawal price for a given amount of allowance.
    /// @param epoch The epoch number.
    /// @param amount The amount of OCO tokens for which to compute the ETH value.
    /// @return value The ETH value (in Q128 fixed-point) corresponding to the withdrawal.
    /// @dev The computation considers the remaining invested ETH and allowance that has not yet been withdrawn.
    function withdrawPrice(uint32 epoch, uint128 amount) public view returns (uint256 value) {
        if (amount > 0) {
            TotalBalances memory t = _totals[epoch];
            uint256 valueInvestedQ128 = t.valueInvested * Q128;
            uint256 supplyInvested = getTotalAllowanceSupply(epoch) - t.supplyClaimed;
            if (t.supplyWithdrawn < supplyInvested && t.valueWithdrawn < valueInvestedQ128) {
                value =
                    Math.mulDiv((valueInvestedQ128 - t.valueWithdrawn), amount, (supplyInvested - t.supplyWithdrawn));
            }
        }
    }
}

File 2 of 8 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 8 : Math.sol
// 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;
    }
}

File 4 of 8 : SafeCast.sol
// 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))
        }
    }
}

File 5 of 8 : IPileus.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;

interface IPileus {
    function EPOCH_DURATION() external view returns (uint48);
    function propsOf(uint256 tokenId) external view returns (address, uint48);
    function getApproved(uint256 tokenId) external view returns (address);
    function getPastTotalSupply(uint256 timepoint) external view returns (uint256);
    function getTotalSupply() external view returns (uint256);
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 6 of 8 : IOCO.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;

interface IOCO {
    function mint(address to, uint256 amount) external;
    function trackBurn(address to, uint256 amount) external;
}

File 7 of 8 : Context.sol
// 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;
    }
}

File 8 of 8 : Panic.sol
// 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)
        }
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/community-contracts/=lib/openzeppelin-community-contracts/contracts/",
    "@axelar-network/axelar-gmp-sdk-solidity/=lib/openzeppelin-community-contracts/node_modules/@axelar-network/axelar-gmp-sdk-solidity/",
    "@openzeppelin-contracts-upgradeable/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts-upgradeable/",
    "@openzeppelin-contracts/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts-upgradeable/contracts/",
    "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-community-contracts/=lib/openzeppelin-community-contracts/contracts/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"contract IPileus","name":"_pileus","type":"address"},{"internalType":"contract IOCO","name":"_oco","type":"address"},{"internalType":"int256","name":"allowanceSlope","type":"int256"},{"internalType":"int256","name":"allowanceIntercept","type":"int256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int256","name":"allowanceSlope","type":"int256"},{"indexed":false,"internalType":"int256","name":"allowanceIntercept","type":"int256"}],"name":"AllowanceUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"uint32","name":"epoch","type":"uint32"},{"indexed":false,"internalType":"uint128","name":"valuePerBlock","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"remainder","type":"uint128"}],"name":"Buy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"used","type":"uint128"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint128","name":"value","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amountQ128","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"duration","type":"uint48"}],"name":"Settle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"totalSupply","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"supplyClaimed","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"supplyWithdrawn","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"supplySettled","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"valueInvested","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"valueSettled","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"valueWithdrawn","type":"uint256"}],"name":"TotalBalancesUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"valueQ128","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"},{"internalType":"address","name":"account","type":"address"}],"name":"balancesKey","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"blockIndex","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"}],"name":"buy","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint48","name":"duration","type":"uint48"}],"name":"claim","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currEpoch","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"},{"internalType":"address","name":"account","type":"address"}],"name":"getAccountInfo","outputs":[{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getAllowance","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"},{"internalType":"uint48","name":"duration","type":"uint48"}],"name":"getAllowanceAtEpoch","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllowanceParams","outputs":[{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"}],"name":"getTotalAllowanceSupply","outputs":[{"internalType":"uint256","name":"totalSupply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"}],"name":"getTotals","outputs":[{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oco","outputs":[{"internalType":"contract IOCO","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pileus","outputs":[{"internalType":"contract IPileus","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"allowanceSlope","type":"int256"},{"internalType":"int256","name":"allowanceIntercept","type":"int256"},{"internalType":"uint48","name":"blockNumber","type":"uint48"}],"name":"setAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"}],"name":"settle","outputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"},{"internalType":"uint128","name":"value","type":"uint128"}],"name":"settlePrice","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint128","name":"value","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"epoch","type":"uint32"},{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"withdrawPrice","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"}]

60e060405234801561000f575f5ffd5b5060405161274238038061274283398101604081905261002e9161015c565b846001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b610065816100f6565b506001600160a01b0380851660a081905290841660c052604080516329c2e7c360e21b8152905163a70b9f0c916004808201926020929091908290030181865afa1580156100b5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100d991906101b6565b65ffffffffffff16608052600191909155600255506101e2915050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381168114610159575f5ffd5b50565b5f5f5f5f5f60a08688031215610170575f5ffd5b855161017b81610145565b602087015190955061018c81610145565b604087015190945061019d81610145565b6060870151608090970151959894975095949392505050565b5f602082840312156101c6575f5ffd5b815165ffffffffffff811681146101db575f5ffd5b9392505050565b60805160a05160c05161249c6102a65f395f818161019801528181610b4f0152818161115301526111d301525f81816102e50152818161074101528181610802015281816108a101528181610d5201528181610df101528181610e90015281816116d1015261180201525f81816105200152818161067c015281816106f70152818161093801528181610a8001528181610f1e01528181610ff3015281816112c10152818161162e01528181611759015281816118a10152611c4c015261249c5ff3fe608060405260043610610126575f3560e01c80638da5cb5b116100a8578063c6a184921161006d578063c6a184921461038a578063c942b2e5146103a9578063c960174e14610482578063e2cec1a5146104b5578063ee3c43bb146104dc578063f2fde38b146104fb575f5ffd5b80638da5cb5b146102b85780639568baed146102d4578063b1fcd0ce14610307578063bed440d31461034c578063c538a4311461036b575f5ffd5b806361a6287f116100ee57806361a6287f14610228578063715018a61461024757806378639f981461025d5780637db5bd521461027c5780638879315d1461028f575f5ffd5b806317b3bc591461012a57806322501ad01461015a57806327eff9fd146101875780632c38ffcd146101d25780632e1a7d4d14610209575b5f5ffd5b348015610135575f5ffd5b5061013e61051a565b60405165ffffffffffff90911681526020015b60405180910390f35b348015610165575f5ffd5b50610179610174366004611fc1565b61054a565b604051908152602001610151565b348015610192575f5ffd5b506101ba7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610151565b3480156101dd575f5ffd5b506101f16101ec366004612014565b610667565b6040516001600160801b039091168152602001610151565b348015610214575f5ffd5b506101f161022336600461203e565b61073c565b348015610233575f5ffd5b506101f1610242366004612055565b6109e2565b348015610252575f5ffd5b5061025b610ccd565b005b348015610268575f5ffd5b506101f1610277366004612082565b610ce0565b6101f161028a366004612055565b6112be565b34801561029a575f5ffd5b506102a361161e565b60405163ffffffff9091168152602001610151565b3480156102c3575f5ffd5b505f546001600160a01b03166101ba565b3480156102df575f5ffd5b506101ba7f000000000000000000000000000000000000000000000000000000000000000081565b348015610312575f5ffd5b506103266103213660046120c1565b611659565b604080516001600160801b03909316835265ffffffffffff909116602083015201610151565b348015610357575f5ffd5b50610179610366366004612055565b6116b4565b348015610376575f5ffd5b5061025b6103853660046120eb565b6118d8565b348015610395575f5ffd5b506101796103a43660046120c1565b61199e565b3480156103b4575f5ffd5b5061043f6103c3366004612055565b63ffffffff165f90815260056020908152604091829020825160c08101845281546001600160801b03808216808452600160801b92839004821695840186905260018501549684018790526002850154808316606086018190529390049091166080840181905260039094015460a09093018390529590929190565b604080516001600160801b0397881681526020810196909652938616938501939093529084166060840152909216608082015260a081019190915260c001610151565b34801561048d575f5ffd5b5061013e61049c36600461203e565b5f9081526004602052604090205465ffffffffffff1690565b3480156104c0575f5ffd5b5060015460025460408051928352602083019190915201610151565b3480156104e7575f5ffd5b506101796104f6366004611fc1565b6119ba565b348015610506575f5ffd5b5061025b610515366004612116565b611ad3565b5f6105457f000000000000000000000000000000000000000000000000000000000000000043612145565b905090565b5f6001600160801b038216156106615763ffffffff83165f908152600560209081526040808320815160c08101835281546001600160801b03808216808452600160801b9283900482169684019690965260018401549483019490945260028301548085166060840152819004909316608082015260039091015460a082015292916105d5876116b4565b6105df9190612184565b6105e99190612197565b905081606001516001600160801b031682608001516001600160801b03161080156106175750808260400151105b1561065e5761065b82604001518261062f9190612184565b856001600160801b03168460800151856060015161064d91906121ae565b6001600160801b0316611b10565b92505b50505b92915050565b5f5f8265ffffffffffff161180156106af57507f000000000000000000000000000000000000000000000000000000000000000065ffffffffffff168265ffffffffffff1611155b15610661575f6002548463ffffffff166001546106cc91906121cd565b6106d691906121fc565b90505f8113156107355761073261072d828565ffffffffffff16600160801b7f000000000000000000000000000000000000000000000000000000000000000065ffffffffffff166107289190612197565b611b10565b611bc7565b91505b5092915050565b5f5f5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638a1353fb856040518263ffffffff1660e01b815260040161078d91815260200190565b6040805180830381865afa1580156107a7573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107cb919061221b565b9092509050336001600160a01b0383161480610876575060405163020604bf60e21b81526004810185905233906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063081812fc90602401602060405180830381865afa158015610847573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061086b9190612248565b6001600160a01b0316145b8061090a575060405163e985e9c560e01b81526001600160a01b0383811660048301523360248301527f0000000000000000000000000000000000000000000000000000000000000000169063e985e9c590604401602060405180830381865afa1580156108e6573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061090a9190612263565b61092f5760405162461bcd60e51b815260040161092690612282565b60405180910390fd5b5f61096a61095d7f0000000000000000000000000000000000000000000000000000000000000000846122c8565b65ffffffffffff16611bfe565b905061097461161e565b63ffffffff168163ffffffff1611156109cf5760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f74207769746864726177206675747572652065706f6368000000006044820152606401610926565b6109d98582611c2e565b95945050505050565b5f6109eb61161e565b63ffffffff168263ffffffff161115610a465760405162461bcd60e51b815260206004820152601a60248201527f43616e6e6f7420736574746c65206675747572652065706f63680000000000006044820152606401610926565b5f60035f610a54853361199e565b81526020019081526020015f2090505f610a6c61161e565b63ffffffff168463ffffffff1614610aa4577f0000000000000000000000000000000000000000000000000000000000000000610aac565b610aac61051a565b825490915065ffffffffffff808316600160801b909204161015610cc65781545f90610ae790600160801b900465ffffffffffff16836122f3565b83549091505f90610b0a9065ffffffffffff8416906001600160801b0316612311565b90505f610b17878361054a565b9050610b27600160801b82612333565b95506001600160801b03861615610ca2576040516340c10f1960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990610b869033908a90600401612346565b5f604051808303815f87803b158015610b9d575f5ffd5b505af1158015610baf573d5f5f3e3d5ffd5b5050505063ffffffff87165f908152600560205260409020600281018054849190601090610bee908490600160801b90046001600160801b0316612368565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555081816001015f828254610c259190612387565b9091555050604080516001600160801b03851681526020810184905265ffffffffffff861681830152905133917fa8a00bfd06926ec776566c67be2ea25273412ebcfbdbce5e161451ad56659b8f919081900360600190a2610c8561161e565b63ffffffff168863ffffffff1603610ca057610ca088611e12565b505b5050825465ffffffffffff60801b1916600160801b65ffffffffffff841602178355505b5050919050565b610cd5611f1d565b610cde5f611f49565b565b5f5f8265ffffffffffff1611610d305760405162461bcd60e51b8152602060048201526015602482015274273ab6361031b630b4b6b2b210323ab930ba34b7b760591b6044820152606401610926565b604051638a1353fb60e01b8152600481018590525f9081906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638a1353fb906024016040805180830381865afa158015610d96573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dba919061221b565b9092509050336001600160a01b0383161480610e65575060405163020604bf60e21b81526004810187905233906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063081812fc90602401602060405180830381865afa158015610e36573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e5a9190612248565b6001600160a01b0316145b80610ef9575060405163e985e9c560e01b81526001600160a01b0383811660048301523360248301527f0000000000000000000000000000000000000000000000000000000000000000169063e985e9c590604401602060405180830381865afa158015610ed5573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ef99190612263565b610f155760405162461bcd60e51b815260040161092690612282565b5f610f4361095d7f0000000000000000000000000000000000000000000000000000000000000000846122c8565b9050610f4d61161e565b63ffffffff168163ffffffff161015610fa85760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f7420636c61696d20706173742065706f63680000000000000000006044820152606401610926565b610fb061161e565b63ffffffff168163ffffffff1603610fce57610fcc8782611c2e565b505b5f87815260046020526040812054610fef90879065ffffffffffff1661239a565b90507f000000000000000000000000000000000000000000000000000000000000000065ffffffffffff168165ffffffffffff16111561107d5760405162461bcd60e51b8152602060048201526024808201527f4475726174696f6e206578636565647320617661696c61626c6520616c6c6f77604482015263616e636560e01b6064820152608401610926565b6110878287610667565b63ffffffff83165f908152600560205260408120805492975087929091906110b99084906001600160801b0316612368565b82546001600160801b039182166101009390930a9283029190920219909116179055505f888152600460205260408120805488929061110190849065ffffffffffff1661239a565b92506101000a81548165ffffffffffff021916908365ffffffffffff1602179055505f6001600160a01b0316876001600160a01b0316036111bc576040516305ad189960e51b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b5a313209061118a9033908990600401612346565b5f604051808303815f87803b1580156111a1575f5ffd5b505af11580156111b3573d5f5f3e3d5ffd5b50505050611238565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f199061120a908a908990600401612346565b5f604051808303815f87803b158015611221575f5ffd5b505af1158015611233573d5f5f3e3d5ffd5b505050505b604080516001600160801b038716815265ffffffffffff831660208201526001600160a01b038916918a9133917fd74e97bdb11746c7acfbd74527f8915de088cd51c2ba295b5c716c06d028dc9f910160405180910390a461129861161e565b63ffffffff168263ffffffff16036112b3576112b382611e12565b505050509392505050565b5f7f0000000000000000000000000000000000000000000000000000000000000000816112ea34611bc7565b90505f816001600160801b0316116113445760405162461bcd60e51b815260206004820152601e60248201527f56616c7565206d75737420626520686967686572207468616e207a65726f00006044820152606401610926565b61134c61161e565b63ffffffff168463ffffffff16101561139f5760405162461bcd60e51b8152602060048201526015602482015274086c2dcdcdee840c4eaf240e0c2e6e840cae0dec6d605b1b6044820152606401610926565b6113a761161e565b63ffffffff168463ffffffff16036113d8576113c2846109e2565b506113cb61051a565b6113d590836122f3565b91505b5f6113e38584610667565b6001600160801b03161161142a5760405162461bcd60e51b815260206004820152600e60248201526d4e6f7468696e6720746f2062757960901b6044820152606401610926565b5f61143d65ffffffffffff8416836123b8565b90505f61145265ffffffffffff8516846123e5565b90505f816001600160801b0316116114a45760405162461bcd60e51b8152602060048201526015602482015274496e76616c69642076616c7565506572426c6f636b60581b6044820152606401610926565b8060035f6114b2893361199e565b815260208101919091526040015f90812080549091906114dc9084906001600160801b0316612368565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550818361150c91906121ae565b63ffffffff87165f908152600560205260408120600201805490919061153c9084906001600160801b0316612368565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505f826001600160801b031611156115a55760405133906001600160801b03841680156108fc02915f818181858888f193505050501580156115a3573d5f5f3e3d5ffd5b505b604080516001600160801b0380841682528416602082015263ffffffff88169133917f099c80a72263ee0fdf60a4370b3e72b1eb181d6a547d933f15981206d01078a3910160405180910390a36115fa61161e565b63ffffffff168663ffffffff16036116155761161586611e12565b50949350505050565b5f61054561165465ffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001643612333565b611bfe565b5f5f5f60035f611669878761199e565b815260208082019290925260409081015f208151808301909252546001600160801b038116808352600160801b90910465ffffffffffff169190920181905290969095509350505050565b5f6116bd61161e565b63ffffffff168263ffffffff1603611756577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c4e41b226040518163ffffffff1660e01b8152600401602060405180830381865afa15801561172b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061174f9190612412565b905061189b565b5f7f0000000000000000000000000000000000000000000000000000000000000000611783846001612429565b63ffffffff166117939190612445565b90505f8165ffffffffffff16116117f85760405162461bcd60e51b815260206004820152602360248201527f45706f636820656e64206d7573742062652067726561746572207468616e207a60448201526265726f60e81b6064820152608401610926565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016638e539e8c6118326001846122f3565b6040516001600160e01b031960e084901b16815265ffffffffffff9091166004820152602401602060405180830381865afa158015611873573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118979190612412565b9150505b6118c5827f0000000000000000000000000000000000000000000000000000000000000000610667565b610661906001600160801b031682612197565b6118e0611f1d565b65ffffffffffff81161561195557438165ffffffffffff16146119555760405162461bcd60e51b815260206004820152602760248201527f43616e206f6e6c792062652065786563757465642061742073706563696669656044820152666420626c6f636b60c81b6064820152608401610926565b6001839055600282905560408051848152602081018490527f2259a4323a81d616baebfb2fe433c0e0b44a9ca13f4e28ffdb4a10d47b0375a891015b60405180910390a1505050565b6001600160a01b031660a09190911b63ffffffff60a01b161790565b5f6001600160801b038216156106615763ffffffff83165f908152600560209081526040808320815160c08101835281546001600160801b038082168352600160801b9182900481169583019590955260018301549382019390935260028201548085166060830181905290849004909416608082015260039091015460a08201529291611a489190612197565b90505f825f01516001600160801b0316611a61876116b4565b611a6b9190612184565b90508083602001516001600160801b0316108015611a8c5750818360a00151105b15611aca57611ac78360a0015183611aa49190612184565b866001600160801b031685602001516001600160801b0316846107289190612184565b93505b50505092915050565b611adb611f1d565b6001600160a01b038116611b0457604051631e4fbdf760e01b81525f6004820152602401610926565b611b0d81611f49565b50565b5f838302815f1985870982811083820303915050805f03611b4457838281611b3a57611b3a612131565b0492505050611bc0565b808411611b5b57611b5b6003851502601118611f98565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b5f6001600160801b03821115611bfa576040516306dfcc6560e41b81526080600482015260248101839052604401610926565b5090565b5f63ffffffff821115611bfa576040516306dfcc6560e41b81526020600482015260248101839052604401610926565b5f5f611c3861161e565b63ffffffff168363ffffffff1614611c70577f0000000000000000000000000000000000000000000000000000000000000000611c78565b611c7861051a565b5f8581526004602052604090205490915065ffffffffffff90811690821681101561065e575f611cac856101ec84866122f3565b90505f611cb986836119ba565b9050611cc9600160801b82612333565b63ffffffff87165f9081526005602052604081206003810180549398509092849290611cf6908490612387565b9091555050805483908290601090611d1f908490600160801b90046001600160801b0316612368565b82546101009290920a6001600160801b038181021990931691831602179091555f8a8152600460205260409020805465ffffffffffff191665ffffffffffff89161790558716159050611da05760405133906001600160801b03881680156108fc02915f818181858888f19350505050158015611d9e573d5f5f3e3d5ffd5b505b604080516001600160801b03851681526020810184905233917fe60d451977add447c195366df60ddde0e91a20b0ea9623cd8d8cc9a0d47d5b35910160405180910390a2611dec61161e565b63ffffffff168763ffffffff1603611e0757611e0787611e12565b505050505092915050565b63ffffffff81165f908152600560209081526040808320815160c08101835281546001600160801b038082168352600160801b918290048116958301959095526001830154938201939093526002820154808516606083015292909204909216608082015260039091015460a082015290611e8c836116b4565b90507f2d0a633db2b0915bcd688c247c68ef1d4241d595cb71aeda58a4d9b34a767afc81835f015184602001518560400151866060015187608001518860a0015160405161199197969594939291906001600160801b0397881681529587166020870152938616604086015260608501929092528416608084015290921660a082015260c081019190915260e00190565b5f546001600160a01b03163314610cde5760405163118cdaa760e01b8152336004820152602401610926565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b715f52806020526024601cfd5b803563ffffffff81168114611fbc575f5ffd5b919050565b5f5f60408385031215611fd2575f5ffd5b611fdb83611fa9565b915060208301356001600160801b0381168114611ff6575f5ffd5b809150509250929050565b65ffffffffffff81168114611b0d575f5ffd5b5f5f60408385031215612025575f5ffd5b61202e83611fa9565b91506020830135611ff681612001565b5f6020828403121561204e575f5ffd5b5035919050565b5f60208284031215612065575f5ffd5b611bc082611fa9565b6001600160a01b0381168114611b0d575f5ffd5b5f5f5f60608486031215612094575f5ffd5b8335925060208401356120a68161206e565b915060408401356120b681612001565b809150509250925092565b5f5f604083850312156120d2575f5ffd5b6120db83611fa9565b91506020830135611ff68161206e565b5f5f5f606084860312156120fd575f5ffd5b833592506020840135915060408401356120b681612001565b5f60208284031215612126575f5ffd5b8135611bc08161206e565b634e487b7160e01b5f52601260045260245ffd5b5f65ffffffffffff83168061215c5761215c612131565b8065ffffffffffff84160691505092915050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561066157610661612170565b808202811582820484141761066157610661612170565b6001600160801b03828116828216039081111561066157610661612170565b8082025f8212600160ff1b841416156121e8576121e8612170565b818105831482151761066157610661612170565b8082018281125f83128015821682158216171561065e5761065e612170565b5f5f6040838503121561222c575f5ffd5b82516122378161206e565b6020840151909250611ff681612001565b5f60208284031215612258575f5ffd5b8151611bc08161206e565b5f60208284031215612273575f5ffd5b81518015158114611bc0575f5ffd5b60208082526026908201527f43616c6c6572206973206e6f7420746f6b656e206f776e6572206e6f722061706040820152651c1c9bdd995960d21b606082015260800190565b5f65ffffffffffff8316806122df576122df612131565b8065ffffffffffff84160491505092915050565b65ffffffffffff828116828216039081111561066157610661612170565b6001600160801b03818116838216029081169081811461073557610735612170565b5f8261234157612341612131565b500490565b6001600160a01b039290921682526001600160801b0316602082015260400190565b6001600160801b03818116838216019081111561066157610661612170565b8082018082111561066157610661612170565b65ffffffffffff818116838216019081111561066157610661612170565b5f6001600160801b038316806123d0576123d0612131565b806001600160801b0384160691505092915050565b5f6001600160801b038316806123fd576123fd612131565b806001600160801b0384160491505092915050565b5f60208284031215612422575f5ffd5b5051919050565b63ffffffff818116838216019081111561066157610661612170565b65ffffffffffff81811683821602908116908181146107355761073561217056fea2646970667358221220ba4008cc4717b34b586f015b9f2f6e4c731bee17cc13dd1d6f28535540ed5b8564736f6c634300081b0033000000000000000000000000610ac56bd97c7817e787a7d5caf0346c4594037a000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe3ffffffffffffd410ce76eee4afee0000000000000000000000000000000000000000000000040b28f74f044a9034000000000000000000000000000000000000

Deployed Bytecode

0x608060405260043610610126575f3560e01c80638da5cb5b116100a8578063c6a184921161006d578063c6a184921461038a578063c942b2e5146103a9578063c960174e14610482578063e2cec1a5146104b5578063ee3c43bb146104dc578063f2fde38b146104fb575f5ffd5b80638da5cb5b146102b85780639568baed146102d4578063b1fcd0ce14610307578063bed440d31461034c578063c538a4311461036b575f5ffd5b806361a6287f116100ee57806361a6287f14610228578063715018a61461024757806378639f981461025d5780637db5bd521461027c5780638879315d1461028f575f5ffd5b806317b3bc591461012a57806322501ad01461015a57806327eff9fd146101875780632c38ffcd146101d25780632e1a7d4d14610209575b5f5ffd5b348015610135575f5ffd5b5061013e61051a565b60405165ffffffffffff90911681526020015b60405180910390f35b348015610165575f5ffd5b50610179610174366004611fc1565b61054a565b604051908152602001610151565b348015610192575f5ffd5b506101ba7f000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe381565b6040516001600160a01b039091168152602001610151565b3480156101dd575f5ffd5b506101f16101ec366004612014565b610667565b6040516001600160801b039091168152602001610151565b348015610214575f5ffd5b506101f161022336600461203e565b61073c565b348015610233575f5ffd5b506101f1610242366004612055565b6109e2565b348015610252575f5ffd5b5061025b610ccd565b005b348015610268575f5ffd5b506101f1610277366004612082565b610ce0565b6101f161028a366004612055565b6112be565b34801561029a575f5ffd5b506102a361161e565b60405163ffffffff9091168152602001610151565b3480156102c3575f5ffd5b505f546001600160a01b03166101ba565b3480156102df575f5ffd5b506101ba7f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b81565b348015610312575f5ffd5b506103266103213660046120c1565b611659565b604080516001600160801b03909316835265ffffffffffff909116602083015201610151565b348015610357575f5ffd5b50610179610366366004612055565b6116b4565b348015610376575f5ffd5b5061025b6103853660046120eb565b6118d8565b348015610395575f5ffd5b506101796103a43660046120c1565b61199e565b3480156103b4575f5ffd5b5061043f6103c3366004612055565b63ffffffff165f90815260056020908152604091829020825160c08101845281546001600160801b03808216808452600160801b92839004821695840186905260018501549684018790526002850154808316606086018190529390049091166080840181905260039094015460a09093018390529590929190565b604080516001600160801b0397881681526020810196909652938616938501939093529084166060840152909216608082015260a081019190915260c001610151565b34801561048d575f5ffd5b5061013e61049c36600461203e565b5f9081526004602052604090205465ffffffffffff1690565b3480156104c0575f5ffd5b5060015460025460408051928352602083019190915201610151565b3480156104e7575f5ffd5b506101796104f6366004611fc1565b6119ba565b348015610506575f5ffd5b5061025b610515366004612116565b611ad3565b5f6105457f0000000000000000000000000000000000000000000000000000000000f0c3f043612145565b905090565b5f6001600160801b038216156106615763ffffffff83165f908152600560209081526040808320815160c08101835281546001600160801b03808216808452600160801b9283900482169684019690965260018401549483019490945260028301548085166060840152819004909316608082015260039091015460a082015292916105d5876116b4565b6105df9190612184565b6105e99190612197565b905081606001516001600160801b031682608001516001600160801b03161080156106175750808260400151105b1561065e5761065b82604001518261062f9190612184565b856001600160801b03168460800151856060015161064d91906121ae565b6001600160801b0316611b10565b92505b50505b92915050565b5f5f8265ffffffffffff161180156106af57507f0000000000000000000000000000000000000000000000000000000000f0c3f065ffffffffffff168265ffffffffffff1611155b15610661575f6002548463ffffffff166001546106cc91906121cd565b6106d691906121fc565b90505f8113156107355761073261072d828565ffffffffffff16600160801b7f0000000000000000000000000000000000000000000000000000000000f0c3f065ffffffffffff166107289190612197565b611b10565b611bc7565b91505b5092915050565b5f5f5f7f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b6001600160a01b0316638a1353fb856040518263ffffffff1660e01b815260040161078d91815260200190565b6040805180830381865afa1580156107a7573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107cb919061221b565b9092509050336001600160a01b0383161480610876575060405163020604bf60e21b81526004810185905233906001600160a01b037f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b169063081812fc90602401602060405180830381865afa158015610847573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061086b9190612248565b6001600160a01b0316145b8061090a575060405163e985e9c560e01b81526001600160a01b0383811660048301523360248301527f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b169063e985e9c590604401602060405180830381865afa1580156108e6573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061090a9190612263565b61092f5760405162461bcd60e51b815260040161092690612282565b60405180910390fd5b5f61096a61095d7f0000000000000000000000000000000000000000000000000000000000f0c3f0846122c8565b65ffffffffffff16611bfe565b905061097461161e565b63ffffffff168163ffffffff1611156109cf5760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f74207769746864726177206675747572652065706f6368000000006044820152606401610926565b6109d98582611c2e565b95945050505050565b5f6109eb61161e565b63ffffffff168263ffffffff161115610a465760405162461bcd60e51b815260206004820152601a60248201527f43616e6e6f7420736574746c65206675747572652065706f63680000000000006044820152606401610926565b5f60035f610a54853361199e565b81526020019081526020015f2090505f610a6c61161e565b63ffffffff168463ffffffff1614610aa4577f0000000000000000000000000000000000000000000000000000000000f0c3f0610aac565b610aac61051a565b825490915065ffffffffffff808316600160801b909204161015610cc65781545f90610ae790600160801b900465ffffffffffff16836122f3565b83549091505f90610b0a9065ffffffffffff8416906001600160801b0316612311565b90505f610b17878361054a565b9050610b27600160801b82612333565b95506001600160801b03861615610ca2576040516340c10f1960e01b81526001600160a01b037f000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe316906340c10f1990610b869033908a90600401612346565b5f604051808303815f87803b158015610b9d575f5ffd5b505af1158015610baf573d5f5f3e3d5ffd5b5050505063ffffffff87165f908152600560205260409020600281018054849190601090610bee908490600160801b90046001600160801b0316612368565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555081816001015f828254610c259190612387565b9091555050604080516001600160801b03851681526020810184905265ffffffffffff861681830152905133917fa8a00bfd06926ec776566c67be2ea25273412ebcfbdbce5e161451ad56659b8f919081900360600190a2610c8561161e565b63ffffffff168863ffffffff1603610ca057610ca088611e12565b505b5050825465ffffffffffff60801b1916600160801b65ffffffffffff841602178355505b5050919050565b610cd5611f1d565b610cde5f611f49565b565b5f5f8265ffffffffffff1611610d305760405162461bcd60e51b8152602060048201526015602482015274273ab6361031b630b4b6b2b210323ab930ba34b7b760591b6044820152606401610926565b604051638a1353fb60e01b8152600481018590525f9081906001600160a01b037f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b1690638a1353fb906024016040805180830381865afa158015610d96573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dba919061221b565b9092509050336001600160a01b0383161480610e65575060405163020604bf60e21b81526004810187905233906001600160a01b037f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b169063081812fc90602401602060405180830381865afa158015610e36573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e5a9190612248565b6001600160a01b0316145b80610ef9575060405163e985e9c560e01b81526001600160a01b0383811660048301523360248301527f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b169063e985e9c590604401602060405180830381865afa158015610ed5573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ef99190612263565b610f155760405162461bcd60e51b815260040161092690612282565b5f610f4361095d7f0000000000000000000000000000000000000000000000000000000000f0c3f0846122c8565b9050610f4d61161e565b63ffffffff168163ffffffff161015610fa85760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f7420636c61696d20706173742065706f63680000000000000000006044820152606401610926565b610fb061161e565b63ffffffff168163ffffffff1603610fce57610fcc8782611c2e565b505b5f87815260046020526040812054610fef90879065ffffffffffff1661239a565b90507f0000000000000000000000000000000000000000000000000000000000f0c3f065ffffffffffff168165ffffffffffff16111561107d5760405162461bcd60e51b8152602060048201526024808201527f4475726174696f6e206578636565647320617661696c61626c6520616c6c6f77604482015263616e636560e01b6064820152608401610926565b6110878287610667565b63ffffffff83165f908152600560205260408120805492975087929091906110b99084906001600160801b0316612368565b82546001600160801b039182166101009390930a9283029190920219909116179055505f888152600460205260408120805488929061110190849065ffffffffffff1661239a565b92506101000a81548165ffffffffffff021916908365ffffffffffff1602179055505f6001600160a01b0316876001600160a01b0316036111bc576040516305ad189960e51b81526001600160a01b037f000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe3169063b5a313209061118a9033908990600401612346565b5f604051808303815f87803b1580156111a1575f5ffd5b505af11580156111b3573d5f5f3e3d5ffd5b50505050611238565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe316906340c10f199061120a908a908990600401612346565b5f604051808303815f87803b158015611221575f5ffd5b505af1158015611233573d5f5f3e3d5ffd5b505050505b604080516001600160801b038716815265ffffffffffff831660208201526001600160a01b038916918a9133917fd74e97bdb11746c7acfbd74527f8915de088cd51c2ba295b5c716c06d028dc9f910160405180910390a461129861161e565b63ffffffff168263ffffffff16036112b3576112b382611e12565b505050509392505050565b5f7f0000000000000000000000000000000000000000000000000000000000f0c3f0816112ea34611bc7565b90505f816001600160801b0316116113445760405162461bcd60e51b815260206004820152601e60248201527f56616c7565206d75737420626520686967686572207468616e207a65726f00006044820152606401610926565b61134c61161e565b63ffffffff168463ffffffff16101561139f5760405162461bcd60e51b8152602060048201526015602482015274086c2dcdcdee840c4eaf240e0c2e6e840cae0dec6d605b1b6044820152606401610926565b6113a761161e565b63ffffffff168463ffffffff16036113d8576113c2846109e2565b506113cb61051a565b6113d590836122f3565b91505b5f6113e38584610667565b6001600160801b03161161142a5760405162461bcd60e51b815260206004820152600e60248201526d4e6f7468696e6720746f2062757960901b6044820152606401610926565b5f61143d65ffffffffffff8416836123b8565b90505f61145265ffffffffffff8516846123e5565b90505f816001600160801b0316116114a45760405162461bcd60e51b8152602060048201526015602482015274496e76616c69642076616c7565506572426c6f636b60581b6044820152606401610926565b8060035f6114b2893361199e565b815260208101919091526040015f90812080549091906114dc9084906001600160801b0316612368565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550818361150c91906121ae565b63ffffffff87165f908152600560205260408120600201805490919061153c9084906001600160801b0316612368565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505f826001600160801b031611156115a55760405133906001600160801b03841680156108fc02915f818181858888f193505050501580156115a3573d5f5f3e3d5ffd5b505b604080516001600160801b0380841682528416602082015263ffffffff88169133917f099c80a72263ee0fdf60a4370b3e72b1eb181d6a547d933f15981206d01078a3910160405180910390a36115fa61161e565b63ffffffff168663ffffffff16036116155761161586611e12565b50949350505050565b5f61054561165465ffffffffffff7f0000000000000000000000000000000000000000000000000000000000f0c3f01643612333565b611bfe565b5f5f5f60035f611669878761199e565b815260208082019290925260409081015f208151808301909252546001600160801b038116808352600160801b90910465ffffffffffff169190920181905290969095509350505050565b5f6116bd61161e565b63ffffffff168263ffffffff1603611756577f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b6001600160a01b031663c4e41b226040518163ffffffff1660e01b8152600401602060405180830381865afa15801561172b573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061174f9190612412565b905061189b565b5f7f0000000000000000000000000000000000000000000000000000000000f0c3f0611783846001612429565b63ffffffff166117939190612445565b90505f8165ffffffffffff16116117f85760405162461bcd60e51b815260206004820152602360248201527f45706f636820656e64206d7573742062652067726561746572207468616e207a60448201526265726f60e81b6064820152608401610926565b6001600160a01b037f000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b16638e539e8c6118326001846122f3565b6040516001600160e01b031960e084901b16815265ffffffffffff9091166004820152602401602060405180830381865afa158015611873573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118979190612412565b9150505b6118c5827f0000000000000000000000000000000000000000000000000000000000f0c3f0610667565b610661906001600160801b031682612197565b6118e0611f1d565b65ffffffffffff81161561195557438165ffffffffffff16146119555760405162461bcd60e51b815260206004820152602760248201527f43616e206f6e6c792062652065786563757465642061742073706563696669656044820152666420626c6f636b60c81b6064820152608401610926565b6001839055600282905560408051848152602081018490527f2259a4323a81d616baebfb2fe433c0e0b44a9ca13f4e28ffdb4a10d47b0375a891015b60405180910390a1505050565b6001600160a01b031660a09190911b63ffffffff60a01b161790565b5f6001600160801b038216156106615763ffffffff83165f908152600560209081526040808320815160c08101835281546001600160801b038082168352600160801b9182900481169583019590955260018301549382019390935260028201548085166060830181905290849004909416608082015260039091015460a08201529291611a489190612197565b90505f825f01516001600160801b0316611a61876116b4565b611a6b9190612184565b90508083602001516001600160801b0316108015611a8c5750818360a00151105b15611aca57611ac78360a0015183611aa49190612184565b866001600160801b031685602001516001600160801b0316846107289190612184565b93505b50505092915050565b611adb611f1d565b6001600160a01b038116611b0457604051631e4fbdf760e01b81525f6004820152602401610926565b611b0d81611f49565b50565b5f838302815f1985870982811083820303915050805f03611b4457838281611b3a57611b3a612131565b0492505050611bc0565b808411611b5b57611b5b6003851502601118611f98565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b5f6001600160801b03821115611bfa576040516306dfcc6560e41b81526080600482015260248101839052604401610926565b5090565b5f63ffffffff821115611bfa576040516306dfcc6560e41b81526020600482015260248101839052604401610926565b5f5f611c3861161e565b63ffffffff168363ffffffff1614611c70577f0000000000000000000000000000000000000000000000000000000000f0c3f0611c78565b611c7861051a565b5f8581526004602052604090205490915065ffffffffffff90811690821681101561065e575f611cac856101ec84866122f3565b90505f611cb986836119ba565b9050611cc9600160801b82612333565b63ffffffff87165f9081526005602052604081206003810180549398509092849290611cf6908490612387565b9091555050805483908290601090611d1f908490600160801b90046001600160801b0316612368565b82546101009290920a6001600160801b038181021990931691831602179091555f8a8152600460205260409020805465ffffffffffff191665ffffffffffff89161790558716159050611da05760405133906001600160801b03881680156108fc02915f818181858888f19350505050158015611d9e573d5f5f3e3d5ffd5b505b604080516001600160801b03851681526020810184905233917fe60d451977add447c195366df60ddde0e91a20b0ea9623cd8d8cc9a0d47d5b35910160405180910390a2611dec61161e565b63ffffffff168763ffffffff1603611e0757611e0787611e12565b505050505092915050565b63ffffffff81165f908152600560209081526040808320815160c08101835281546001600160801b038082168352600160801b918290048116958301959095526001830154938201939093526002820154808516606083015292909204909216608082015260039091015460a082015290611e8c836116b4565b90507f2d0a633db2b0915bcd688c247c68ef1d4241d595cb71aeda58a4d9b34a767afc81835f015184602001518560400151866060015187608001518860a0015160405161199197969594939291906001600160801b0397881681529587166020870152938616604086015260608501929092528416608084015290921660a082015260c081019190915260e00190565b5f546001600160a01b03163314610cde5760405163118cdaa760e01b8152336004820152602401610926565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b715f52806020526024601cfd5b803563ffffffff81168114611fbc575f5ffd5b919050565b5f5f60408385031215611fd2575f5ffd5b611fdb83611fa9565b915060208301356001600160801b0381168114611ff6575f5ffd5b809150509250929050565b65ffffffffffff81168114611b0d575f5ffd5b5f5f60408385031215612025575f5ffd5b61202e83611fa9565b91506020830135611ff681612001565b5f6020828403121561204e575f5ffd5b5035919050565b5f60208284031215612065575f5ffd5b611bc082611fa9565b6001600160a01b0381168114611b0d575f5ffd5b5f5f5f60608486031215612094575f5ffd5b8335925060208401356120a68161206e565b915060408401356120b681612001565b809150509250925092565b5f5f604083850312156120d2575f5ffd5b6120db83611fa9565b91506020830135611ff68161206e565b5f5f5f606084860312156120fd575f5ffd5b833592506020840135915060408401356120b681612001565b5f60208284031215612126575f5ffd5b8135611bc08161206e565b634e487b7160e01b5f52601260045260245ffd5b5f65ffffffffffff83168061215c5761215c612131565b8065ffffffffffff84160691505092915050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561066157610661612170565b808202811582820484141761066157610661612170565b6001600160801b03828116828216039081111561066157610661612170565b8082025f8212600160ff1b841416156121e8576121e8612170565b818105831482151761066157610661612170565b8082018281125f83128015821682158216171561065e5761065e612170565b5f5f6040838503121561222c575f5ffd5b82516122378161206e565b6020840151909250611ff681612001565b5f60208284031215612258575f5ffd5b8151611bc08161206e565b5f60208284031215612273575f5ffd5b81518015158114611bc0575f5ffd5b60208082526026908201527f43616c6c6572206973206e6f7420746f6b656e206f776e6572206e6f722061706040820152651c1c9bdd995960d21b606082015260800190565b5f65ffffffffffff8316806122df576122df612131565b8065ffffffffffff84160491505092915050565b65ffffffffffff828116828216039081111561066157610661612170565b6001600160801b03818116838216029081169081811461073557610735612170565b5f8261234157612341612131565b500490565b6001600160a01b039290921682526001600160801b0316602082015260400190565b6001600160801b03818116838216019081111561066157610661612170565b8082018082111561066157610661612170565b65ffffffffffff818116838216019081111561066157610661612170565b5f6001600160801b038316806123d0576123d0612131565b806001600160801b0384160691505092915050565b5f6001600160801b038316806123fd576123fd612131565b806001600160801b0384160491505092915050565b5f60208284031215612422575f5ffd5b5051919050565b63ffffffff818116838216019081111561066157610661612170565b65ffffffffffff81811683821602908116908181146107355761073561217056fea2646970667358221220ba4008cc4717b34b586f015b9f2f6e4c731bee17cc13dd1d6f28535540ed5b8564736f6c634300081b0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000610ac56bd97c7817e787a7d5caf0346c4594037a000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe3ffffffffffffd410ce76eee4afee0000000000000000000000000000000000000000000000040b28f74f044a9034000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : initialOwner (address): 0x610Ac56bD97C7817e787A7D5cAf0346c4594037A
Arg [1] : _pileus (address): 0x600966eAfD19b5Fc051A1ea4175ea20fF305134B
Arg [2] : _oco (address): 0xf919250541a98A36eADEf0e2f03FE0A9CA707fE3
Arg [3] : allowanceSlope (int256): -70599777822791478862446529639759421080443289600000000000000000
Arg [4] : allowanceIntercept (int256): 1663438023868150189486677747842492883722567680000000000000000000

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000610ac56bd97c7817e787a7d5caf0346c4594037a
Arg [1] : 000000000000000000000000600966eafd19b5fc051a1ea4175ea20ff305134b
Arg [2] : 000000000000000000000000f919250541a98a36eadef0e2f03fe0a9ca707fe3
Arg [3] : ffffffffffffd410ce76eee4afee000000000000000000000000000000000000
Arg [4] : 0000000000040b28f74f044a9034000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.