OP Sepolia Testnet

Contract

0x599A58BE6367E43e2BEa28DE14BEAAdd316d1de8

Overview

ETH Balance

0 ETH

More Info

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Amount
Set Yield Tool110869222024-04-24 16:33:04591 days ago1713976384IN
0x599A58BE...d316d1de8
0 ETH0.0001296942321.50000027

Parent Transaction Hash Block From To Amount
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x4F0e005a...eCC8Da196
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
MestSharesFactoryV1

Compiler Version
v0.8.16+commit.07a7930e

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

/*

    Copyright 2024 MEST.
    SPDX-License-Identifier: Apache-2.0

*/

pragma solidity 0.8.16;

import "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IMestShare} from "../intf/IMestShare.sol";
import {IYieldTool} from "./YieldTool.sol";
import {BondingCurveLib} from "../lib/BondingCurveLib.sol";

contract MestSharesFactoryV1 is Ownable {
    using SafeERC20 for IERC20;

    address public immutable mestERC1155;
    uint256 public shareTypeNumber;

    address public protocolFeeReceiver;
    uint256 public protocolFeePercent = 5 * 1e16; // unit in 1e18, default is 5%
    uint256 public creatorFeePercent = 5 * 1e16; // unit in 1e18, default is 5%
    CurveFixedParam public generalCurveFixedParam;

    mapping(uint256 => address) public sharesMap;
    mapping(address => uint256[]) public creatorSharesMap; // index all shares one creator create

    uint256 public depositedTotalAmount; // origin ETH amount
    uint256 public yieldBuffer = 1e12; // avoid decimal error
    IYieldTool public yieldTool;

    struct CurveFixedParam {
        uint256 basePrice;
        uint256 linearPriceSlope;
        uint256 inflectionPoint;
        uint256 inflectionPrice;
    }

    // ============== event ===================
    event Create(uint256 indexed shareId, address indexed creator);
    event Trade(
        address indexed user,
        uint256 indexed share,
        bool isBuy,
        uint256 quantity,
        uint256 totalPrice,
        uint256 protocolFee,
        uint256 creatorFee,
        uint256 newSupply
    );

    // ============== constructor ==============
    constructor(address _protocolFeeReceiver, address _mestERC1155) {
        protocolFeeReceiver = _protocolFeeReceiver;
        mestERC1155 = _mestERC1155;

        generalCurveFixedParam.basePrice = 5000000000000000;
        generalCurveFixedParam.inflectionPoint = 1500;
        generalCurveFixedParam.inflectionPrice = 102500000000000000;
        generalCurveFixedParam.linearPriceSlope = 0;
    }

    // ==========================================

    fallback() external payable {}

    receive() external payable {}

    // ============ Owner Settings ==============
    function setProtocolFeeReceiver(address newReceiver) external onlyOwner {
        protocolFeeReceiver = newReceiver;
    }

    function setProtocolFeePercent(uint256 _feePercent) external onlyOwner {
        protocolFeePercent = _feePercent;
    }

    function setCreatorFeePercent(uint256 _feePercent) external onlyOwner {
        creatorFeePercent = _feePercent;
    }

    function setYieldTool(address _yieldTool) external onlyOwner {
        // check remove condition
        if(address(yieldTool) != address(0)) {
            uint256 yieldBal = yieldTool.yieldBalanceOf(address(this));
            require(yieldBal == 0, "Yield token didnt withdraw all");

            // revoke approve
            address yieldToken = yieldTool.yieldToken();
            IERC20(yieldToken).approve(address(yieldTool), 0);
        }

        // change yieldTool
        yieldTool = IYieldTool(_yieldTool);

        // yield token approve for
        address yieldToken = yieldTool.yieldToken();
        IERC20(yieldToken).approve(_yieldTool, type(uint256).max);
    }

    function setYieldBuffer(uint256 newYieldBuffer) external onlyOwner {
        yieldBuffer = newYieldBuffer;
    }

    /**
     * @notice calculate all yield profit OWNER could get
     * @return maxYieldAmount max yield amount owner could get
     */
    function maxClaimableYield() public returns(uint256 maxYieldAmount) {
        uint256 withdrawableAmount = yieldTool.yieldBalanceOf(address(this));
        maxYieldAmount = (withdrawableAmount - depositedTotalAmount) < yieldBuffer ? 0 : withdrawableAmount - depositedTotalAmount - yieldBuffer;
    }

    /**
     * @notice only for owner to get certain amount yield
     * @param amount owner claim amount
     * @param to yield receiver address
     */
    function claimYield(uint256 amount, address to) public onlyOwner {
        uint256 maxAmount = maxClaimableYield();
        require(amount <= maxAmount, "Invalid yield amount");
        yieldTool.yieldWithdraw(amount);
        _safeTransferETH(to, amount);
    }

    function withdrawAllAtokenToETH() external onlyOwner {
        uint256 withdrawableAmount = yieldTool.yieldMaxWithdrawable(address(this));
        yieldTool.yieldWithdraw(withdrawableAmount);
    }

    function depositAllETHToAToken() external onlyOwner {
        uint256 ethAmount = address(this).balance;
        _safeTransferETH(address(yieldTool), ethAmount);
        yieldTool.yieldDeposit(ethAmount);
    }

    // ================ calculate price ==============
    /**
     * @notice calculate buy price and fee
     * @return total result amount the user pays, = subTotal + protocolFee + creatorFee
     * @return subTotal the price of buying a specific number of shares, excluding transaction fees
     * @return protocolFee total protocol fee
     * @return creatorFee total creator fee
    */
    function getBuyPriceAfterFee(uint256 shareId, uint256 quantity)
        public
        view
        returns (uint256 total, uint256 subTotal, uint256 protocolFee, uint256 creatorFee)
    {
        uint256 fromSupply = IMestShare(mestERC1155).shareFromSupply(shareId);

        subTotal = _subTotal(fromSupply, quantity);
        protocolFee = subTotal * protocolFeePercent / 1 ether;
        creatorFee = subTotal * creatorFeePercent / 1 ether;
        total = subTotal + protocolFee + creatorFee;
    }

    /**
     * @notice calculate sell price and fee
     * @return total result amount the user gets, = subTotal - protocolFee - creatorFee
     * @return subTotal the price of selling a specific number of shares, excluding transaction fees
     * @return protocolFee total protocol fee
     * @return creatorFee total creator fee
    */
    function getSellPriceAfterFee(uint256 shareId, uint256 quantity)
        public
        view
        returns (uint256 total, uint256 subTotal, uint256 protocolFee, uint256 creatorFee)
    {
        uint256 fromSupply = IMestShare(mestERC1155).shareFromSupply(shareId);
        require(fromSupply >= quantity, "Exceeds supply");

        subTotal = _subTotal(fromSupply - quantity, quantity);
        protocolFee = subTotal * protocolFeePercent / 1 ether;
        creatorFee = subTotal * creatorFeePercent / 1 ether;
        total = subTotal - protocolFee - creatorFee;
    }

    /**
     * @dev Returns the area under the bonding curve, which is the price before any fees.
     * @param fromSupply The starting SAM supply.
     * @param quantity   The number of tokens to be minted.
     * @return subTotal  The area under the bonding curve.
     */
    function _subTotal(uint256 fromSupply, uint256 quantity) internal view returns (uint256 subTotal) {
        unchecked {
            subTotal = generalCurveFixedParam.basePrice * quantity;
            subTotal += BondingCurveLib.linearSum(generalCurveFixedParam.linearPriceSlope, fromSupply, quantity);
            subTotal += BondingCurveLib.sigmoid2Sum(
                generalCurveFixedParam.inflectionPoint, generalCurveFixedParam.inflectionPrice, fromSupply, quantity
            );
        }
    }

    // ================ create Shares =============

    /**
     * @notice Creating shares means registering a shareId in ERC-1155, and ERC-1155 registers automatically, only requiring an increment in the count.
     * @param creator set the payment address for the share’s creatorFee.
     */
    function createShare(address creator) public {
        sharesMap[shareTypeNumber] = creator;
        creatorSharesMap[creator].push(shareTypeNumber);

        emit Create(shareTypeNumber, creator);

        shareTypeNumber++;
    }

    /** 
     * @param shareId the id of share 
     * @param quantity the quantity of share
     * @dev in this case, slippage protection use msg.value insufficient
     */
    function buyShare(uint256 shareId, uint256 quantity) public payable {
        require(address(yieldTool) != address(0), "Invalid yieldTool");
        require(shareId < shareTypeNumber, "Invalid shareId");
        address creator = sharesMap[shareId];
        uint256 fromSupply = IMestShare(mestERC1155).shareFromSupply(shareId);
        // first buyer must be creator
        require(fromSupply > 0 || msg.sender == creator, "First buyer must be creator");

        (uint256 totalPrice, uint256 subTotalPrice, uint256 protocolFee, uint256 creatorFee) = getBuyPriceAfterFee(shareId, quantity);
        require(msg.value >= totalPrice, "Insufficient payment");
        IMestShare(mestERC1155).shareMint(msg.sender, shareId, quantity);
        emit Trade(
            msg.sender, shareId, true, quantity, totalPrice, protocolFee, creatorFee, fromSupply + quantity
        );

        // pay
        _safeTransferETH(protocolFeeReceiver, protocolFee);
        _safeTransferETH(creator, creatorFee);

        // refund
        uint256 refundAmount = msg.value - totalPrice;
        if (refundAmount > 0) {
            _safeTransferETH(msg.sender, refundAmount);
        }

        // deposit aave
        _safeTransferETH(address(yieldTool), subTotalPrice);
        yieldTool.yieldDeposit(subTotalPrice);
        depositedTotalAmount += subTotalPrice;
    }

    /**
     * @param shareId the id of share
     * @param quantity the quantity of share
     * @param minETHAmount minimum amount of ETH that a user receives, used for slippage protection. If the amount is less than this ETH value, it will revert.
     */
    function sellShare(uint256 shareId, uint256 quantity, uint256 minETHAmount) public payable {
        require(address(yieldTool) != address(0), "Invalid yieldTool");
        require(shareId < shareTypeNumber, "Invalid shareId");
        require(IMestShare(mestERC1155).shareBalanceOf(msg.sender, shareId) >= quantity, "Insufficient shares");
        address creator = sharesMap[shareId];

        (uint256 totalPrice, uint256 subTotalPrice, uint256 protocolFee, uint256 creatorFee) = getSellPriceAfterFee(shareId, quantity);
        require(totalPrice >= minETHAmount, "Insufficient minReceive");
        IMestShare(mestERC1155).shareBurn(msg.sender, shareId, quantity);
        uint256 fromSupply = IMestShare(mestERC1155).shareFromSupply(shareId);
        emit Trade(msg.sender, shareId, false, quantity, totalPrice, protocolFee, creatorFee, fromSupply);

        // withdraw from aave
        yieldTool.yieldWithdraw(subTotalPrice);
        depositedTotalAmount -= subTotalPrice;

        // pay
        _safeTransferETH(msg.sender, totalPrice);
        _safeTransferETH(protocolFeeReceiver, protocolFee);
        _safeTransferETH(creator, creatorFee);
    }

    /** 
     * @notice Transfers ETH to the recipient address
     * @dev Fails with `Eth transfer failed`
     * @param to The destination of the transfer
     * @param value The value to be transferred
     */ 
    function _safeTransferETH(address to, uint256 value) internal {
        if (value > 0) {
            (bool success,) = to.call{value: value}(new bytes(0));
            require(success, "Eth transfer failed");
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @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 {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

/*

    Copyright 2024 MEST.
    SPDX-License-Identifier: Apache-2.0

*/

pragma solidity 0.8.16;

interface IMestShare {
    function shareMint(address to, uint256 id, uint256 amount) external;
    function shareBurn(address from, uint256 id, uint256 amount) external;
    function shareFromSupply(uint256 id) external view returns(uint256);
    function shareBalanceOf(address user, uint256 id) external view returns(uint256);
}

/*

    Copyright 2024 MEST.
    SPDX-License-Identifier: Apache-2.0

*/

pragma solidity 0.8.16;
import "@openzeppelin/contracts/access/Ownable.sol";
import "../intf/IAave.sol";

interface IYieldTool {
    function yieldDeposit(uint256 amount) external;
    function yieldWithdraw(uint256 amount) external;
    function yieldBalanceOf(address owner) external returns(uint256);
    function yieldToken() external returns(address);
    function yieldMaxWithdrawable(address owner) external returns(uint256 amount);
}

contract YieldTool is Ownable, IYieldTool {
    // for aave   
    address public immutable mestFactory;
    address public immutable WETH;

    IAavePool public aavePool;
    IAaveGateway public aaveGateway;
    IAToken public aWETH;

    constructor(address _mestFactory, address _weth) public {
        mestFactory = _mestFactory;
        WETH = _weth;
    }

    modifier onlyFactory() {
        require(msg.sender == mestFactory, "Only factory");
        _;
    }

    // =============== eth =============

    fallback() external payable {}

    receive() external payable {}

    // ================= owner ================

    function setAaveInfo(address newPool, address newGateway) external onlyOwner {
        if(address(aWETH) != address(0)) {
            require(aWETH.balanceOf(mestFactory) == 0, "AToken didnt withdraw all");
            // revoke allowrance
            aWETH.approve(address(aaveGateway), 0);
        }
        aaveGateway = IAaveGateway(newGateway);
        aavePool = IAavePool(newPool);

        aWETH = IAToken(aavePool.getReserveData(WETH).aTokenAddress);
        aWETH.approve(address(aaveGateway), type(uint256).max);
    }

    // ============= yield function =========

    function yieldDeposit(uint256 amount) external onlyFactory {
        uint256 subTotalPrice = address(this).balance;
        aaveGateway.depositETH{value: subTotalPrice}(address(aavePool), mestFactory, 0);
    }

    function yieldWithdraw(uint256 amount) external onlyFactory {
        aWETH.transferFrom(mestFactory, address(this), amount);
        aaveGateway.withdrawETH(address(aavePool), amount, mestFactory);
    }

    function yieldBalanceOf(address owner) external returns(uint256 amount) {
        return aWETH.balanceOf(owner);
    }

    function yieldToken() external returns(address yieldTokenAddr) {
        yieldTokenAddr = address(aWETH);
    }

    function yieldMaxWithdrawable(address owner) external returns(uint256 amount) {
        return aWETH.balanceOf(owner);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import "./FixedPointMathLib.sol";

library BondingCurveLib {
    function sigmoid2Sum(
        uint256 inflectionPoint,
        uint256 inflectionPrice,
        uint256 fromSupply,
        uint256 quantity
    ) internal pure returns (uint256 sum) {
        // We don't need checked arithmetic for the sum.
        // The max possible sum for the quadratic region is capped at:
        // `n * (n + 1) * (2*n + 1) * h < 2**32 * 2**33 * 2**34 * 2**128 = 2**227`.
        // The max possible sum for the sqrt region is capped at:
        // `end * (2*h * sqrt(end)) < 2**32 * 2**129 * 2**16 = 2**177`.
        // The overall sum is capped by:
        // `2**161 + 2**227 <= 2**228 < 2 **256`.
        // The result will be small enough for unchecked multiplication with a 16-bit BPS.
        unchecked {
            uint256 g = inflectionPoint;
            uint256 h = inflectionPrice;

            // Early return to save gas if either `g` or `h` is zero.
            if (g * h == 0) return 0;

            uint256 s = uint256(fromSupply) + 1;
            uint256 end = s + uint256(quantity);
            uint256 quadraticEnd = FixedPointMathLib.min(g, end);

            if (s < quadraticEnd) {
                uint256 k = uint256(fromSupply); // `s - 1`.
                uint256 n = quadraticEnd - 1;
                // In practice, `h` (units: wei) will be set to be much greater than `g * g`.
                uint256 a = FixedPointMathLib.rawDiv(h, g * g);
                // Use the closed form to compute the sum.
                // sum(i ^2)/ g^2 considered as infinitesimal and use taylor series
                sum = ((n * (n + 1) * ((n << 1) + 1) - k * (k + 1) * ((k << 1) + 1)) / 6) * a;
                s = quadraticEnd;
            }

            if (s < end) {
                uint256 c = (3 * g) >> 2;
                uint256 h2 = h << 1;
                do {
                    uint256 r = FixedPointMathLib.sqrt((s - c) * g);
                    sum += FixedPointMathLib.rawDiv(h2 * r, g);
                } while (++s != end);
            }
        }
    }

    function linearSum(
        uint256 linearPriceSlope,
        uint256 fromSupply,
        uint256 quantity
    ) internal pure returns (uint256 sum) {
        // We don't need checked arithmetic for the sum because the max possible
        // intermediate value is capped at:
        // `k * m < 2**32 * 2**128 = 2**160 < 2**256`.
        // As `quantity` is 32 bits, max possible value for `sum`
        // is capped at:
        // `2**32 * 2**160 = 2**192 < 2**256`.
        // The result will be small enough for unchecked multiplication with a 16-bit BPS.
        unchecked {
            uint256 m = linearPriceSlope;
            uint256 k = uint256(fromSupply);
            uint256 n = k + uint256(quantity);
            // Use the closed form to compute the sum.
            return m * ((n * (n + 1) - k * (k + 1)) >> 1);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

pragma solidity 0.8.16;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IAToken is IERC20 {

}

interface IAavePool {
    struct ReserveConfigurationMap {
        //bit 0-15: LTV
        //bit 16-31: Liq. threshold
        //bit 32-47: Liq. bonus
        //bit 48-55: Decimals
        //bit 56: reserve is active
        //bit 57: reserve is frozen
        //bit 58: borrowing is enabled
        //bit 59: stable rate borrowing enabled
        //bit 60: asset is paused
        //bit 61: borrowing in isolation mode is enabled
        //bit 62: siloed borrowing enabled
        //bit 63: flashloaning enabled
        //bit 64-79: reserve factor
        //bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap
        //bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap
        //bit 152-167 liquidation protocol fee
        //bit 168-175 eMode category
        //bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled
        //bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals
        //bit 252-255 unused

        uint256 data;
    }

    struct ReserveData {
        //stores the reserve configuration
        ReserveConfigurationMap configuration;
        //the liquidity index. Expressed in ray
        uint128 liquidityIndex;
        //the current supply rate. Expressed in ray
        uint128 currentLiquidityRate;
        //variable borrow index. Expressed in ray
        uint128 variableBorrowIndex;
        //the current variable borrow rate. Expressed in ray
        uint128 currentVariableBorrowRate;
        //the current stable borrow rate. Expressed in ray
        uint128 currentStableBorrowRate;
        //timestamp of last update
        uint40 lastUpdateTimestamp;
        //the id of the reserve. Represents the position in the list of the active reserves
        uint16 id;
        //aToken address
        address aTokenAddress;
        //stableDebtToken address
        address stableDebtTokenAddress;
        //variableDebtToken address
        address variableDebtTokenAddress;
        //address of the interest rate strategy
        address interestRateStrategyAddress;
        //the current treasury balance, scaled
        uint128 accruedToTreasury;
        //the outstanding unbacked aTokens minted through the bridging feature
        uint128 unbacked;
        //the outstanding debt borrowed against this asset in isolation mode
        uint128 isolationModeTotalDebt;
    }

    function getReserveData(address asset) external view returns (ReserveData memory);
}

interface IAaveGateway {
    function withdrawETH(address, uint256 amount, address to) external;
    function depositETH(address, address onBehalfOf, uint16 referralCode) external payable;
}

File 12 of 12 : FixedPointMathLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
library FixedPointMathLib {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The operation failed, as the output exceeds the maximum value of uint256.
    error ExpOverflow();

    /// @dev The operation failed, as the output exceeds the maximum value of uint256.
    error FactorialOverflow();

    /// @dev The operation failed, due to an multiplication overflow.
    error MulWadFailed();

    /// @dev The operation failed, either due to a
    /// multiplication overflow, or a division by a zero.
    error DivWadFailed();

    /// @dev The multiply-divide operation failed, either due to a
    /// multiplication overflow, or a division by a zero.
    error MulDivFailed();

    /// @dev The division failed, as the denominator is zero.
    error DivFailed();

    /// @dev The full precision multiply-divide operation failed, either due
    /// to the result being larger than 256 bits, or a division by a zero.
    error FullMulDivFailed();

    /// @dev The output is undefined, as the input is less-than-or-equal to zero.
    error LnWadUndefined();

    /// @dev The output is undefined, as the input is zero.
    error Log2Undefined();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The scalar of ETH and most ERC20s.
    uint256 internal constant WAD = 1e18;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*              SIMPLIFIED FIXED POINT OPERATIONS             */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Equivalent to `(x * y) / WAD` rounded down.
    function mulWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
            if mul(y, gt(x, div(not(0), y))) {
                // Store the function selector of `MulWadFailed()`.
                mstore(0x00, 0xbac65e5b)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := div(mul(x, y), WAD)
        }
    }

    /// @dev Equivalent to `(x * y) / WAD` rounded up.
    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
            if mul(y, gt(x, div(not(0), y))) {
                // Store the function selector of `MulWadFailed()`.
                mstore(0x00, 0xbac65e5b)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD))
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded down.
    function divWad(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
            if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
                // Store the function selector of `DivWadFailed()`.
                mstore(0x00, 0x7c5f487d)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := div(mul(x, WAD), y)
        }
    }

    /// @dev Equivalent to `(x * WAD) / y` rounded up.
    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
            if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
                // Store the function selector of `DivWadFailed()`.
                mstore(0x00, 0x7c5f487d)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y))
        }
    }

    /// @dev Equivalent to `x` to the power of `y`.
    /// because `x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)`.
    function powWad(int256 x, int256 y) internal pure returns (int256) {
        // Using `ln(x)` means `x` must be greater than 0.
        return expWad((lnWad(x) * y) / int256(WAD));
    }

    /// @dev Returns `exp(x)`, denominated in `WAD`.
    function expWad(int256 x) internal pure returns (int256 r) {
        unchecked {
            // When the result is < 0.5 we return zero. This happens when
            // x <= floor(log(0.5e18) * 1e18) ~ -42e18
            if (x <= -42139678854452767551) return r;

            /// @solidity memory-safe-assembly
            assembly {
                // When the result is > (2**255 - 1) / 1e18 we can not represent it as an
                // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
                if iszero(slt(x, 135305999368893231589)) {
                    // Store the function selector of `ExpOverflow()`.
                    mstore(0x00, 0xa37bfec9)
                    // Revert with (offset, size).
                    revert(0x1c, 0x04)
                }
            }

            // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
            // for more intermediate precision and a binary basis. This base conversion
            // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
            x = (x << 78) / 5 ** 18;

            // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
            // of two such that exp(x) = exp(x') * 2**k, where k is an integer.
            // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
            int256 k = ((x << 96) / 54916777467707473351141471128 + 2 ** 95) >> 96;
            x = x - k * 54916777467707473351141471128;

            // k is in the range [-61, 195].

            // Evaluate using a (6, 7)-term rational approximation.
            // p is made monic, we'll multiply by a scale factor later.
            int256 y = x + 1346386616545796478920950773328;
            y = ((y * x) >> 96) + 57155421227552351082224309758442;
            int256 p = y + x - 94201549194550492254356042504812;
            p = ((p * y) >> 96) + 28719021644029726153956944680412240;
            p = p * x + (4385272521454847904659076985693276 << 96);

            // We leave p in 2**192 basis so we don't need to scale it back up for the division.
            int256 q = x - 2855989394907223263936484059900;
            q = ((q * x) >> 96) + 50020603652535783019961831881945;
            q = ((q * x) >> 96) - 533845033583426703283633433725380;
            q = ((q * x) >> 96) + 3604857256930695427073651918091429;
            q = ((q * x) >> 96) - 14423608567350463180887372962807573;
            q = ((q * x) >> 96) + 26449188498355588339934803723976023;

            /// @solidity memory-safe-assembly
            assembly {
                // Div in assembly because solidity adds a zero check despite the unchecked.
                // The q polynomial won't have zeros in the domain as all its roots are complex.
                // No scaling is necessary because p is already 2**96 too large.
                r := sdiv(p, q)
            }

            // r should be in the range (0.09, 0.25) * 2**96.

            // We now need to multiply r by:
            // * the scale factor s = ~6.031367120.
            // * the 2**k factor from the range reduction.
            // * the 1e18 / 2**96 factor for base conversion.
            // We do this all at once, with an intermediate result in 2**213
            // basis, so the final right shift is always by a positive amount.
            r = int256(
                (uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k)
            );
        }
    }

    /// @dev Returns `ln(x)`, denominated in `WAD`.
    function lnWad(int256 x) internal pure returns (int256 r) {
        unchecked {
            /// @solidity memory-safe-assembly
            assembly {
                if iszero(sgt(x, 0)) {
                    // Store the function selector of `LnWadUndefined()`.
                    mstore(0x00, 0x1615e638)
                    // Revert with (offset, size).
                    revert(0x1c, 0x04)
                }
            }

            // We want to convert x from 10**18 fixed point to 2**96 fixed point.
            // We do this by multiplying by 2**96 / 10**18. But since
            // ln(x * C) = ln(x) + ln(C), we can simply do nothing here
            // and add ln(2**96 / 10**18) at the end.

            // Compute k = log2(x) - 96.
            int256 k;
            /// @solidity memory-safe-assembly
            assembly {
                let v := x
                k := shl(7, lt(0xffffffffffffffffffffffffffffffff, v))
                k := or(k, shl(6, lt(0xffffffffffffffff, shr(k, v))))
                k := or(k, shl(5, lt(0xffffffff, shr(k, v))))

                // For the remaining 32 bits, use a De Bruijn lookup.
                // See: https://graphics.stanford.edu/~seander/bithacks.html
                v := shr(k, v)
                v := or(v, shr(1, v))
                v := or(v, shr(2, v))
                v := or(v, shr(4, v))
                v := or(v, shr(8, v))
                v := or(v, shr(16, v))

                // forgefmt: disable-next-item
                k := sub(or(k, byte(shr(251, mul(v, shl(224, 0x07c4acdd))),
                    0x0009010a0d15021d0b0e10121619031e080c141c0f111807131b17061a05041f)), 96)
            }

            // Reduce range of x to (1, 2) * 2**96
            // ln(2^k * x) = k * ln(2) + ln(x)
            x <<= uint256(159 - k);
            x = int256(uint256(x) >> 159);

            // Evaluate using a (8, 8)-term rational approximation.
            // p is made monic, we will multiply by a scale factor later.
            int256 p = x + 3273285459638523848632254066296;
            p = ((p * x) >> 96) + 24828157081833163892658089445524;
            p = ((p * x) >> 96) + 43456485725739037958740375743393;
            p = ((p * x) >> 96) - 11111509109440967052023855526967;
            p = ((p * x) >> 96) - 45023709667254063763336534515857;
            p = ((p * x) >> 96) - 14706773417378608786704636184526;
            p = p * x - (795164235651350426258249787498 << 96);

            // We leave p in 2**192 basis so we don't need to scale it back up for the division.
            // q is monic by convention.
            int256 q = x + 5573035233440673466300451813936;
            q = ((q * x) >> 96) + 71694874799317883764090561454958;
            q = ((q * x) >> 96) + 283447036172924575727196451306956;
            q = ((q * x) >> 96) + 401686690394027663651624208769553;
            q = ((q * x) >> 96) + 204048457590392012362485061816622;
            q = ((q * x) >> 96) + 31853899698501571402653359427138;
            q = ((q * x) >> 96) + 909429971244387300277376558375;
            /// @solidity memory-safe-assembly
            assembly {
                // Div in assembly because solidity adds a zero check despite the unchecked.
                // The q polynomial is known not to have zeros in the domain.
                // No scaling required because p is already 2**96 too large.
                r := sdiv(p, q)
            }

            // r is in the range (0, 0.125) * 2**96

            // Finalization, we need to:
            // * multiply by the scale factor s = 5.549…
            // * add ln(2**96 / 10**18)
            // * add k * ln(2)
            // * multiply by 10**18 / 2**96 = 5**18 >> 78

            // mul s * 5e18 * 2**96, base is now 5**18 * 2**192
            r *= 1677202110996718588342820967067443963516166;
            // add ln(2) * k * 5e18 * 2**192
            r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;
            // add ln(2**96 / 10**18) * 5e18 * 2**192
            r += 600920179829731861736702779321621459595472258049074101567377883020018308;
            // base conversion: mul 2**18 / 2**192
            r >>= 174;
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                  GENERAL NUMBER UTILITIES                  */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Calculates `floor(a * b / d)` with full precision.
    /// Throws if result overflows a uint256 or when `d` is zero.
    /// Credit to Remco Bloemen under MIT license: https://2π.com/21/muldiv
    function fullMulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            // forgefmt: disable-next-item
            for {} 1 {} {
                // 512-bit multiply `[prod1 prod0] = x * y`.
                // Compute the product mod `2**256` and mod `2**256 - 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**256 + prod0`.

                // Least significant 256 bits of the product.
                let prod0 := mul(x, y)
                let mm := mulmod(x, y, not(0))
                // Most significant 256 bits of the product.
                let prod1 := sub(mm, add(prod0, lt(mm, prod0)))

                // Handle non-overflow cases, 256 by 256 division.
                if iszero(prod1) {
                    if iszero(d) {
                        // Store the function selector of `FullMulDivFailed()`.
                        mstore(0x00, 0xae47f702)
                        // Revert with (offset, size).
                        revert(0x1c, 0x04)
                    }
                    result := div(prod0, d)
                    break       
                }

                // Make sure the result is less than `2**256`.
                // Also prevents `d == 0`.
                if iszero(gt(d, prod1)) {
                    // Store the function selector of `FullMulDivFailed()`.
                    mstore(0x00, 0xae47f702)
                    // Revert with (offset, size).
                    revert(0x1c, 0x04)
                }

                ///////////////////////////////////////////////
                // 512 by 256 division.
                ///////////////////////////////////////////////

                // Make division exact by subtracting the remainder from `[prod1 prod0]`.
                // Compute remainder using mulmod.
                let remainder := mulmod(x, y, d)
                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
                // Factor powers of two out of `d`.
                // Compute largest power of two divisor of `d`.
                // Always greater or equal to 1.
                let twos := and(d, sub(0, d))
                // Divide d by power of two.
                d := div(d, twos)
                // Divide [prod1 prod0] by the factors of two.
                prod0 := div(prod0, twos)
                // Shift in bits from `prod1` into `prod0`. For this we need
                // to flip `twos` such that it is `2**256 / twos`.
                // If `twos` is zero, then it becomes one.
                prod0 := or(prod0, mul(prod1, add(div(sub(0, twos), twos), 1)))
                // Invert `d mod 2**256`
                // Now that `d` is an odd number, it has an inverse
                // modulo `2**256` such that `d * inv = 1 mod 2**256`.
                // Compute the inverse by starting with a seed that is correct
                // correct for four bits. That is, `d * inv = 1 mod 2**4`.
                let inv := xor(mul(3, d), 2)
                // Now use 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.
                inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**8
                inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**16
                inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**32
                inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**64
                inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**128
                result := mul(prod0, mul(inv, sub(2, mul(d, inv)))) // inverse mod 2**256
                break
            }
        }
    }

    /// @dev Calculates `floor(x * y / d)` with full precision, rounded up.
    /// Throws if result overflows a uint256 or when `d` is zero.
    /// Credit to Uniswap-v3-core under MIT license:
    /// https://github.com/Uniswap/v3-core/blob/contracts/libraries/FullMath.sol
    function fullMulDivUp(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) {
        result = fullMulDiv(x, y, d);
        /// @solidity memory-safe-assembly
        assembly {
            if mulmod(x, y, d) {
                if iszero(add(result, 1)) {
                    // Store the function selector of `FullMulDivFailed()`.
                    mstore(0x00, 0xae47f702)
                    // Revert with (offset, size).
                    revert(0x1c, 0x04)
                }
                result := add(result, 1)
            }
        }
    }

    /// @dev Returns `floor(x * y / d)`.
    /// Reverts if `x * y` overflows, or `d` is zero.
    function mulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(d != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(d, iszero(mul(y, gt(x, div(not(0), y)))))) {
                // Store the function selector of `MulDivFailed()`.
                mstore(0x00, 0xad251c27)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := div(mul(x, y), d)
        }
    }

    /// @dev Returns `ceil(x * y / d)`.
    /// Reverts if `x * y` overflows, or `d` is zero.
    function mulDivUp(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(d != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(d, iszero(mul(y, gt(x, div(not(0), y)))))) {
                // Store the function selector of `MulDivFailed()`.
                mstore(0x00, 0xad251c27)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(mul(x, y), d))), div(mul(x, y), d))
        }
    }

    /// @dev Returns `ceil(x / d)`.
    /// Reverts if `d` is zero.
    function divUp(uint256 x, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(d) {
                // Store the function selector of `DivFailed()`.
                mstore(0x00, 0x65244e4e)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
            z := add(iszero(iszero(mod(x, d))), div(x, d))
        }
    }

    /// @dev Returns `max(0, x - y)`.
    function zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(gt(x, y), sub(x, y))
        }
    }

    /// @dev Returns the square root of `x`.
    function sqrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`.
            z := 181 // The "correct" value is 1, but this saves a multiplication later.

            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

            // Let `y = x / 2**r`.
            // We check `y >= 2**(k + 8)` but shift right by `k` bits
            // each branch to ensure that if `x >= 256`, then `y >= 256`.
            let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffffff, shr(r, x))))
            z := shl(shr(1, r), z)

            // Goal was to get `z*z*y` within a small factor of `x`. More iterations could
            // get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`.
            // We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small.
            // That's not possible if `x < 256` but we can just verify those cases exhaustively.

            // Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`.
            // Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`.
            // Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps.

            // For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)`
            // is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`,
            // with largest error when `s = 1` and when `s = 256` or `1/256`.

            // Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`.
            // Then we can estimate `sqrt(y)` using
            // `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`.

            // There is no overflow risk here since `y < 2**136` after the first branch above.
            z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181.

            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // If `x+1` is a perfect square, the Babylonian method cycles between
            // `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor.
            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
            // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
            // If you don't care whether the floor or ceil square root is returned, you can remove this statement.
            z := sub(z, lt(div(x, z), z))
        }
    }

    /// @dev Returns the cube root of `x`.
    /// Credit to bout3fiddy and pcaversaccio under AGPLv3 license:
    /// https://github.com/pcaversaccio/snekmate/blob/main/src/utils/Math.vy
    function cbrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
            r := or(r, shl(4, lt(0xffff, shr(r, x))))
            r := or(r, shl(3, lt(0xff, shr(r, x))))

            z := shl(add(div(r, 3), lt(0xf, shr(r, x))), 0xff)
            z := div(z, byte(mod(r, 3), shl(232, 0x7f624b)))

            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)
            z := div(add(add(div(x, mul(z, z)), z), z), 3)

            z := sub(z, lt(div(x, mul(z, z)), z))
        }
    }

    /// @dev Returns the factorial of `x`.
    function factorial(uint256 x) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            for {} 1 {} {
                if iszero(lt(10, x)) {
                    // forgefmt: disable-next-item
                    result := and(
                        shr(mul(22, x), 0x375f0016260009d80004ec0002d00001e0000180000180000200000400001),
                        0x3fffff
                    )
                    break
                }
                if iszero(lt(57, x)) {
                    let end := 31
                    result := 8222838654177922817725562880000000
                    if iszero(lt(end, x)) {
                        end := 10
                        result := 3628800
                    }
                    for { let w := not(0) } 1 {} {
                        result := mul(result, x)
                        x := add(x, w)
                        if eq(x, end) { break }
                    }
                    break
                }
                // Store the function selector of `FactorialOverflow()`.
                mstore(0x00, 0xaba0f2a2)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }
        }
    }

    /// @dev Returns the log2 of `x`.
    /// Equivalent to computing the index of the most significant bit (MSB) of `x`.
    function log2(uint256 x) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(x) {
                // Store the function selector of `Log2Undefined()`.
                mstore(0x00, 0x5be3aa5c)
                // Revert with (offset, size).
                revert(0x1c, 0x04)
            }

            r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))

            // For the remaining 32 bits, use a De Bruijn lookup.
            // See: https://graphics.stanford.edu/~seander/bithacks.html
            x := shr(r, x)
            x := or(x, shr(1, x))
            x := or(x, shr(2, x))
            x := or(x, shr(4, x))
            x := or(x, shr(8, x))
            x := or(x, shr(16, x))

            // forgefmt: disable-next-item
            r := or(r, byte(shr(251, mul(x, shl(224, 0x07c4acdd))),
                0x0009010a0d15021d0b0e10121619031e080c141c0f111807131b17061a05041f))
        }
    }

    /// @dev Returns the log2 of `x`, rounded up.
    function log2Up(uint256 x) internal pure returns (uint256 r) {
        unchecked {
            uint256 isNotPo2;
            assembly {
                isNotPo2 := iszero(iszero(and(x, sub(x, 1))))
            }
            return log2(x) + isNotPo2;
        }
    }

    /// @dev Returns the average of `x` and `y`.
    function avg(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = (x & y) + ((x ^ y) >> 1);
        }
    }

    /// @dev Returns the average of `x` and `y`.
    function avg(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = (x >> 1) + (y >> 1) + (((x & 1) + (y & 1)) >> 1);
        }
    }

    /// @dev Returns the absolute value of `x`.
    function abs(int256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let mask := sub(0, shr(255, x))
            z := xor(mask, add(mask, x))
        }
    }

    /// @dev Returns the absolute distance between `x` and `y`.
    function dist(int256 x, int256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let a := sub(y, x)
            z := xor(a, mul(xor(a, sub(x, y)), sgt(x, y)))
        }
    }

    /// @dev Returns the minimum of `x` and `y`.
    function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), lt(y, x)))
        }
    }

    /// @dev Returns the minimum of `x` and `y`.
    function min(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), slt(y, x)))
        }
    }

    /// @dev Returns the maximum of `x` and `y`.
    function max(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), gt(y, x)))
        }
    }

    /// @dev Returns the maximum of `x` and `y`.
    function max(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), sgt(y, x)))
        }
    }

    /// @dev Returns `x`, bounded to `minValue` and `maxValue`.
    function clamp(uint256 x, uint256 minValue, uint256 maxValue)
        internal
        pure
        returns (uint256 z)
    {
        z = min(max(x, minValue), maxValue);
    }

    /// @dev Returns `x`, bounded to `minValue` and `maxValue`.
    function clamp(int256 x, int256 minValue, int256 maxValue) internal pure returns (int256 z) {
        z = min(max(x, minValue), maxValue);
    }

    /// @dev Returns greatest common divisor of `x` and `y`.
    function gcd(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // forgefmt: disable-next-item
            for { z := x } y {} {
                let t := y
                y := mod(z, y)
                z := t
            }
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                   RAW NUMBER OPERATIONS                    */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns `x + y`, without checking for overflow.
    function rawAdd(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = x + y;
        }
    }

    /// @dev Returns `x + y`, without checking for overflow.
    function rawAdd(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = x + y;
        }
    }

    /// @dev Returns `x - y`, without checking for underflow.
    function rawSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = x - y;
        }
    }

    /// @dev Returns `x - y`, without checking for underflow.
    function rawSub(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = x - y;
        }
    }

    /// @dev Returns `x * y`, without checking for overflow.
    function rawMul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        unchecked {
            z = x * y;
        }
    }

    /// @dev Returns `x * y`, without checking for overflow.
    function rawMul(int256 x, int256 y) internal pure returns (int256 z) {
        unchecked {
            z = x * y;
        }
    }

    /// @dev Returns `x / y`, returning 0 if `y` is zero.
    function rawDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := div(x, y)
        }
    }

    /// @dev Returns `x / y`, returning 0 if `y` is zero.
    function rawSDiv(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := sdiv(x, y)
        }
    }

    /// @dev Returns `x % y`, returning 0 if `y` is zero.
    function rawMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mod(x, y)
        }
    }

    /// @dev Returns `x % y`, returning 0 if `y` is zero.
    function rawSMod(int256 x, int256 y) internal pure returns (int256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := smod(x, y)
        }
    }

    /// @dev Returns `(x + y) % d`, return 0 if `d` if zero.
    function rawAddMod(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := addmod(x, y, d)
        }
    }

    /// @dev Returns `(x * y) % d`, return 0 if `d` if zero.
    function rawMulMod(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mulmod(x, y, d)
        }
    }
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "contracts/=contracts/",
    "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
    "@rari-capital/solmate/src/=node_modules/@rari-capital/solmate/src/",
    "@ensdomains/=node_modules/@ensdomains/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "hardhat/=node_modules/hardhat/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_protocolFeeReceiver","type":"address"},{"internalType":"address","name":"_mestERC1155","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"shareId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"}],"name":"Create","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":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"share","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isBuy","type":"bool"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"protocolFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creatorFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newSupply","type":"uint256"}],"name":"Trade","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"uint256","name":"shareId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"buyShare","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"claimYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"}],"name":"createShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"creatorFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"creatorSharesMap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositAllETHToAToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositedTotalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"generalCurveFixedParam","outputs":[{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"linearPriceSlope","type":"uint256"},{"internalType":"uint256","name":"inflectionPoint","type":"uint256"},{"internalType":"uint256","name":"inflectionPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shareId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"getBuyPriceAfterFee","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"subTotal","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"creatorFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shareId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"getSellPriceAfterFee","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"subTotal","type":"uint256"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"creatorFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxClaimableYield","outputs":[{"internalType":"uint256","name":"maxYieldAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mestERC1155","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFeeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shareId","type":"uint256"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"uint256","name":"minETHAmount","type":"uint256"}],"name":"sellShare","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feePercent","type":"uint256"}],"name":"setCreatorFeePercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feePercent","type":"uint256"}],"name":"setProtocolFeePercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newReceiver","type":"address"}],"name":"setProtocolFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newYieldBuffer","type":"uint256"}],"name":"setYieldBuffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_yieldTool","type":"address"}],"name":"setYieldTool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shareTypeNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sharesMap","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAllAtokenToETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldBuffer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"yieldTool","outputs":[{"internalType":"contract IYieldTool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

0x60a060405266b1a2bc2ec5000060035566b1a2bc2ec5000060045564e8d4a51000600c553480156200003057600080fd5b5060405162001cfd38038062001cfd833981016040819052620000539162000113565b6200005e33620000a6565b600280546001600160a01b0319166001600160a01b03938416179055166080526611c37937e080006005556105dc60075567016c2734f97a400060085560006006556200014b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200010e57600080fd5b919050565b600080604083850312156200012757600080fd5b6200013283620000f6565b91506200014260208401620000f6565b90509250929050565b608051611b6562000198600039600081816104b301528181610534015281816107c20152818161091a0152818161099601528181610d8501528181610ed7015261108e0152611b656000f3fe6080604052600436106101a35760003560e01c8063715018a6116100e0578063cfe147f411610084578063e547688811610061578063e5476888146104a1578063f21cd1a8146104d5578063f2fde38b146104f5578063f6c7bb971461051557005b8063cfe147f414610456578063d45f0e8614610476578063d6e6eb9f1461048b57005b8063a57d4fd2116100bd578063a57d4fd2146103cd578063aca75a5214610403578063b5d431bd14610416578063cd9c71211461043657005b8063715018a61461037a5780638da5cb5b1461038f578063a4983421146103ad57005b806346877b1a11610147578063565bb8e711610124578063565bb8e7146103045780635e53b2cf1461032457806361fa18d51461033a5780636ff6c4b81461035a57005b806346877b1a146102ae5780634cd14dc6146102ce57806353613dd3146102ee57005b80632214087111610180578063221408711461023857806323fc126f1461024d57806339a51be514610263578063456e62ba1461029b57005b8063063a741f146101ac5780630e8b4d61146101f157806313dc6c5d1461021457005b366101aa57005b005b3480156101b857600080fd5b506101cc6101c7366004611910565b61052a565b6040805194855260208501939093529183015260608201526080015b60405180910390f35b3480156101fd57600080fd5b506005546006546007546008546101cc9392919084565b34801561022057600080fd5b5061022a600c5481565b6040519081526020016101e8565b34801561024457600080fd5b506101aa610636565b34801561025957600080fd5b5061022a60015481565b34801561026f57600080fd5b50600254610283906001600160a01b031681565b6040516001600160a01b0390911681526020016101e8565b6101aa6102a9366004611932565b610710565b3480156102ba57600080fd5b506101aa6102c9366004611973565b610b13565b3480156102da57600080fd5b506101aa6102e9366004611997565b610b3d565b3480156102fa57600080fd5b5061022a60045481565b34801561031057600080fd5b50600d54610283906001600160a01b031681565b34801561033057600080fd5b5061022a600b5481565b34801561034657600080fd5b506101aa610355366004611973565b610c05565b34801561036657600080fd5b506101aa6103753660046119c7565b610c96565b34801561038657600080fd5b506101aa610ca3565b34801561039b57600080fd5b506000546001600160a01b0316610283565b3480156103b957600080fd5b506101aa6103c83660046119c7565b610cb7565b3480156103d957600080fd5b506102836103e83660046119c7565b6009602052600090815260409020546001600160a01b031681565b6101aa610411366004611910565b610cc4565b34801561042257600080fd5b506101aa6104313660046119c7565b611077565b34801561044257600080fd5b506101cc610451366004611910565b611084565b34801561046257600080fd5b5061022a6104713660046119e0565b6111ce565b34801561048257600080fd5b506101aa6111ff565b34801561049757600080fd5b5061022a60035481565b3480156104ad57600080fd5b506102837f000000000000000000000000000000000000000000000000000000000000000081565b3480156104e157600080fd5b506101aa6104f0366004611973565b611250565b34801561050157600080fd5b506101aa610510366004611973565b61150d565b34801561052157600080fd5b5061022a611586565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d2cf9115886040518263ffffffff1660e01b815260040161058091815260200190565b602060405180830381865afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c19190611a0c565b90506105cd8187611639565b9350670de0b6b3a7640000600354856105e69190611a3b565b6105f09190611a5a565b9250670de0b6b3a7640000600454856106099190611a3b565b6106139190611a5a565b9150816106208486611a7c565b61062a9190611a7c565b94505092959194509250565b61063e611672565b600d54604051638b3102d560e01b81523060048201526000916001600160a01b031690638b3102d5906024016020604051808303816000875af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190611a0c565b600d546040516316d7ac4560e31b8152600481018390529192506001600160a01b03169063b6bd6228906024015b600060405180830381600087803b1580156106f557600080fd5b505af1158015610709573d6000803e3d6000fd5b5050505050565b600d546001600160a01b03166107615760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081e5a595b19151bdbdb607a1b60448201526064015b60405180910390fd5b60015483106107a45760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081cda185c995259608a1b6044820152606401610758565b6040516327e662e160e21b81523360048201526024810184905282907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690639f998b8490604401602060405180830381865afa158015610811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108359190611a0c565b10156108795760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742073686172657360681b6044820152606401610758565b6000838152600960205260408120546001600160a01b03169080808061089f8888611084565b9350935093509350858410156108f75760405162461bcd60e51b815260206004820152601760248201527f496e73756666696369656e74206d696e526563656976650000000000000000006044820152606401610758565b6040516317a99ced60e31b815233600482015260248101899052604481018890527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063bd4ce76890606401600060405180830381600087803b15801561096657600080fd5b505af115801561097a573d6000803e3d6000fd5b505060405163d2cf911560e01b8152600481018b9052600092507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316915063d2cf911590602401602060405180830381865afa1580156109e6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0a9190611a0c565b6040805160008152602081018b9052908101879052606081018590526080810184905260a08101829052909150899033907f29db2a6062b25ead33a5fc8d1163c4d7f54397202547c27c1c99a203446477349060c00160405180910390a3600d546040516316d7ac4560e31b8152600481018690526001600160a01b039091169063b6bd622890602401600060405180830381600087803b158015610aae57600080fd5b505af1158015610ac2573d6000803e3d6000fd5b5050505083600b6000828254610ad89190611a95565b90915550610ae8905033866116cc565b600254610afe906001600160a01b0316846116cc565b610b0886836116cc565b505050505050505050565b610b1b611672565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610b45611672565b6000610b4f611586565b905080831115610b985760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a59081e5a595b1908185b5bdd5b9d60621b6044820152606401610758565b600d546040516316d7ac4560e31b8152600481018590526001600160a01b039091169063b6bd622890602401600060405180830381600087803b158015610bde57600080fd5b505af1158015610bf2573d6000803e3d6000fd5b50505050610c0082846116cc565b505050565b60018054600090815260096020908152604080832080546001600160a01b0319166001600160a01b038716908117909155808452600a83528184208554815480880183559186529385200192909255925492519092917f748fd6a01f0f0df2e8354235caf8fdf83654b5a47b2358be7e7bffb16b726ceb91a360018054906000610c8e83611aa8565b919050555050565b610c9e611672565b600455565b610cab611672565b610cb56000611789565b565b610cbf611672565b600355565b600d546001600160a01b0316610d105760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081e5a595b19151bdbdb607a1b6044820152606401610758565b6001548210610d535760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081cda185c995259608a1b6044820152606401610758565b60008281526009602052604080822054905163d2cf911560e01b8152600481018590526001600160a01b0391821692917f0000000000000000000000000000000000000000000000000000000000000000169063d2cf911590602401602060405180830381865afa158015610dcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df09190611a0c565b90506000811180610e095750336001600160a01b038316145b610e555760405162461bcd60e51b815260206004820152601b60248201527f4669727374206275796572206d7573742062652063726561746f7200000000006044820152606401610758565b600080600080610e65888861052a565b935093509350935083341015610eb45760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b6044820152606401610758565b60405163106fcedf60e21b815233600482015260248101899052604481018890527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906341bf3b7c90606401600060405180830381600087803b158015610f2357600080fd5b505af1158015610f37573d6000803e3d6000fd5b508a92503391507f29db2a6062b25ead33a5fc8d1163c4d7f54397202547c27c1c99a20344647734905060018a888787610f71848e611a7c565b6040805196151587526020870195909552938501929092526060840152608083015260a082015260c00160405180910390a3600254610fb9906001600160a01b0316836116cc565b610fc386826116cc565b6000610fcf8534611a95565b90508015610fe157610fe133826116cc565b600d54610ff7906001600160a01b0316856116cc565b600d5460405163330a649d60e01b8152600481018690526001600160a01b039091169063330a649d90602401600060405180830381600087803b15801561103d57600080fd5b505af1158015611051573d6000803e3d6000fd5b5050505083600b60008282546110679190611a7c565b9091555050505050505050505050565b61107f611672565b600c55565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d2cf9115886040518263ffffffff1660e01b81526004016110da91815260200190565b602060405180830381865afa1580156110f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061111b9190611a0c565b90508581101561115e5760405162461bcd60e51b815260206004820152600e60248201526d4578636565647320737570706c7960901b6044820152606401610758565b61117161116b8783611a95565b87611639565b9350670de0b6b3a76400006003548561118a9190611a3b565b6111949190611a5a565b9250670de0b6b3a7640000600454856111ad9190611a3b565b6111b79190611a5a565b9150816111c48486611a95565b61062a9190611a95565b600a60205281600052604060002081815481106111ea57600080fd5b90600052602060002001600091509150505481565b611207611672565b600d54479061121f906001600160a01b0316826116cc565b600d5460405163330a649d60e01b8152600481018390526001600160a01b039091169063330a649d906024016106db565b611258611672565b600d546001600160a01b03161561141457600d54604051638812ebc960e01b81523060048201526000916001600160a01b031690638812ebc9906024016020604051808303816000875af11580156112b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d89190611a0c565b905080156113285760405162461bcd60e51b815260206004820152601e60248201527f5969656c6420746f6b656e206469646e7420776974686472617720616c6c00006044820152606401610758565b600d54604080516376d5de8560e01b815290516000926001600160a01b0316916376d5de85916004808301926020929190829003018187875af1158015611373573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113979190611ac1565b600d5460405163095ea7b360e01b81526001600160a01b0391821660048201526000602482015291925082169063095ea7b3906044016020604051808303816000875af11580156113ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114109190611ade565b5050505b600d80546001600160a01b0319166001600160a01b038316908117909155604080516376d5de8560e01b81529051600092916376d5de85916004808301926020929190829003018187875af1158015611471573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114959190611ac1565b60405163095ea7b360e01b81526001600160a01b03848116600483015260001960248301529192509082169063095ea7b3906044016020604051808303816000875af11580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190611ade565b611515611672565b6001600160a01b03811661157a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610758565b61158381611789565b50565b600d54604051638812ebc960e01b815230600482015260009182916001600160a01b0390911690638812ebc9906024016020604051808303816000875af11580156115d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f99190611a0c565b9050600c54600b548261160c9190611a95565b1061163057600c54600b546116219083611a95565b61162b9190611a95565b611633565b60005b91505090565b60055460065490820290600180850185028585018083010203901c02600754600854919092019161166b9185856117d9565b0192915050565b6000546001600160a01b03163314610cb55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610758565b801561178557604080516000808252602082019092526001600160a01b0384169083906040516116fc9190611b00565b60006040518083038185875af1925050503d8060008114611739576040519150601f19603f3d011682016040523d82523d6000602084013e61173e565b606091505b5050905080610c005760405162461bcd60e51b8152602060048201526013602482015272115d1a081d1c985b9cd9995c8819985a5b1959606a1b6044820152606401610758565b5050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000848480820283036117f157600092505050611908565b600185810190858701018381188185110284188083101561183b5760066001808a018a028a821b820102600019840180850290831b90920191909102030485800285040295509150815b81831015611902576003850260021c600185901b5b60006118e6888488030270ffffffffffffffffffffffffffffffffff811160071b81811c68ffffffffffffffffff1060061b1781811c64ffffffffff1060051b1781811c62ffffff1060041b1781811c620100000160b5600192831c1b0260121c80830401811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b8202889004989098019750600180860195859003016118505750505b50505050505b949350505050565b6000806040838503121561192357600080fd5b50508035926020909101359150565b60008060006060848603121561194757600080fd5b505081359360208301359350604090920135919050565b6001600160a01b038116811461158357600080fd5b60006020828403121561198557600080fd5b81356119908161195e565b9392505050565b600080604083850312156119aa57600080fd5b8235915060208301356119bc8161195e565b809150509250929050565b6000602082840312156119d957600080fd5b5035919050565b600080604083850312156119f357600080fd5b82356119fe8161195e565b946020939093013593505050565b600060208284031215611a1e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615611a5557611a55611a25565b500290565b600082611a7757634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115611a8f57611a8f611a25565b92915050565b81810381811115611a8f57611a8f611a25565b600060018201611aba57611aba611a25565b5060010190565b600060208284031215611ad357600080fd5b81516119908161195e565b600060208284031215611af057600080fd5b8151801515811461199057600080fd5b6000825160005b81811015611b215760208186018101518583015201611b07565b50600092019182525091905056fea26469706673582212206bd7dae1d27704f67d3a1534036c2f71f005014368bc16cdcfbdb8442fa5285164736f6c634300081000330000000000000000000000000e148b6c5d9cf5e9309753c6da3bbc810f3dc1750000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f

Deployed Bytecode

0x6080604052600436106101a35760003560e01c8063715018a6116100e0578063cfe147f411610084578063e547688811610061578063e5476888146104a1578063f21cd1a8146104d5578063f2fde38b146104f5578063f6c7bb971461051557005b8063cfe147f414610456578063d45f0e8614610476578063d6e6eb9f1461048b57005b8063a57d4fd2116100bd578063a57d4fd2146103cd578063aca75a5214610403578063b5d431bd14610416578063cd9c71211461043657005b8063715018a61461037a5780638da5cb5b1461038f578063a4983421146103ad57005b806346877b1a11610147578063565bb8e711610124578063565bb8e7146103045780635e53b2cf1461032457806361fa18d51461033a5780636ff6c4b81461035a57005b806346877b1a146102ae5780634cd14dc6146102ce57806353613dd3146102ee57005b80632214087111610180578063221408711461023857806323fc126f1461024d57806339a51be514610263578063456e62ba1461029b57005b8063063a741f146101ac5780630e8b4d61146101f157806313dc6c5d1461021457005b366101aa57005b005b3480156101b857600080fd5b506101cc6101c7366004611910565b61052a565b6040805194855260208501939093529183015260608201526080015b60405180910390f35b3480156101fd57600080fd5b506005546006546007546008546101cc9392919084565b34801561022057600080fd5b5061022a600c5481565b6040519081526020016101e8565b34801561024457600080fd5b506101aa610636565b34801561025957600080fd5b5061022a60015481565b34801561026f57600080fd5b50600254610283906001600160a01b031681565b6040516001600160a01b0390911681526020016101e8565b6101aa6102a9366004611932565b610710565b3480156102ba57600080fd5b506101aa6102c9366004611973565b610b13565b3480156102da57600080fd5b506101aa6102e9366004611997565b610b3d565b3480156102fa57600080fd5b5061022a60045481565b34801561031057600080fd5b50600d54610283906001600160a01b031681565b34801561033057600080fd5b5061022a600b5481565b34801561034657600080fd5b506101aa610355366004611973565b610c05565b34801561036657600080fd5b506101aa6103753660046119c7565b610c96565b34801561038657600080fd5b506101aa610ca3565b34801561039b57600080fd5b506000546001600160a01b0316610283565b3480156103b957600080fd5b506101aa6103c83660046119c7565b610cb7565b3480156103d957600080fd5b506102836103e83660046119c7565b6009602052600090815260409020546001600160a01b031681565b6101aa610411366004611910565b610cc4565b34801561042257600080fd5b506101aa6104313660046119c7565b611077565b34801561044257600080fd5b506101cc610451366004611910565b611084565b34801561046257600080fd5b5061022a6104713660046119e0565b6111ce565b34801561048257600080fd5b506101aa6111ff565b34801561049757600080fd5b5061022a60035481565b3480156104ad57600080fd5b506102837f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f81565b3480156104e157600080fd5b506101aa6104f0366004611973565b611250565b34801561050157600080fd5b506101aa610510366004611973565b61150d565b34801561052157600080fd5b5061022a611586565b60008060008060007f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f6001600160a01b031663d2cf9115886040518263ffffffff1660e01b815260040161058091815260200190565b602060405180830381865afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c19190611a0c565b90506105cd8187611639565b9350670de0b6b3a7640000600354856105e69190611a3b565b6105f09190611a5a565b9250670de0b6b3a7640000600454856106099190611a3b565b6106139190611a5a565b9150816106208486611a7c565b61062a9190611a7c565b94505092959194509250565b61063e611672565b600d54604051638b3102d560e01b81523060048201526000916001600160a01b031690638b3102d5906024016020604051808303816000875af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190611a0c565b600d546040516316d7ac4560e31b8152600481018390529192506001600160a01b03169063b6bd6228906024015b600060405180830381600087803b1580156106f557600080fd5b505af1158015610709573d6000803e3d6000fd5b5050505050565b600d546001600160a01b03166107615760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081e5a595b19151bdbdb607a1b60448201526064015b60405180910390fd5b60015483106107a45760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081cda185c995259608a1b6044820152606401610758565b6040516327e662e160e21b81523360048201526024810184905282907f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f6001600160a01b031690639f998b8490604401602060405180830381865afa158015610811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108359190611a0c565b10156108795760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742073686172657360681b6044820152606401610758565b6000838152600960205260408120546001600160a01b03169080808061089f8888611084565b9350935093509350858410156108f75760405162461bcd60e51b815260206004820152601760248201527f496e73756666696369656e74206d696e526563656976650000000000000000006044820152606401610758565b6040516317a99ced60e31b815233600482015260248101899052604481018890527f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f6001600160a01b03169063bd4ce76890606401600060405180830381600087803b15801561096657600080fd5b505af115801561097a573d6000803e3d6000fd5b505060405163d2cf911560e01b8152600481018b9052600092507f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f6001600160a01b0316915063d2cf911590602401602060405180830381865afa1580156109e6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0a9190611a0c565b6040805160008152602081018b9052908101879052606081018590526080810184905260a08101829052909150899033907f29db2a6062b25ead33a5fc8d1163c4d7f54397202547c27c1c99a203446477349060c00160405180910390a3600d546040516316d7ac4560e31b8152600481018690526001600160a01b039091169063b6bd622890602401600060405180830381600087803b158015610aae57600080fd5b505af1158015610ac2573d6000803e3d6000fd5b5050505083600b6000828254610ad89190611a95565b90915550610ae8905033866116cc565b600254610afe906001600160a01b0316846116cc565b610b0886836116cc565b505050505050505050565b610b1b611672565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610b45611672565b6000610b4f611586565b905080831115610b985760405162461bcd60e51b8152602060048201526014602482015273125b9d985b1a59081e5a595b1908185b5bdd5b9d60621b6044820152606401610758565b600d546040516316d7ac4560e31b8152600481018590526001600160a01b039091169063b6bd622890602401600060405180830381600087803b158015610bde57600080fd5b505af1158015610bf2573d6000803e3d6000fd5b50505050610c0082846116cc565b505050565b60018054600090815260096020908152604080832080546001600160a01b0319166001600160a01b038716908117909155808452600a83528184208554815480880183559186529385200192909255925492519092917f748fd6a01f0f0df2e8354235caf8fdf83654b5a47b2358be7e7bffb16b726ceb91a360018054906000610c8e83611aa8565b919050555050565b610c9e611672565b600455565b610cab611672565b610cb56000611789565b565b610cbf611672565b600355565b600d546001600160a01b0316610d105760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081e5a595b19151bdbdb607a1b6044820152606401610758565b6001548210610d535760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a59081cda185c995259608a1b6044820152606401610758565b60008281526009602052604080822054905163d2cf911560e01b8152600481018590526001600160a01b0391821692917f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f169063d2cf911590602401602060405180830381865afa158015610dcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df09190611a0c565b90506000811180610e095750336001600160a01b038316145b610e555760405162461bcd60e51b815260206004820152601b60248201527f4669727374206275796572206d7573742062652063726561746f7200000000006044820152606401610758565b600080600080610e65888861052a565b935093509350935083341015610eb45760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b6044820152606401610758565b60405163106fcedf60e21b815233600482015260248101899052604481018890527f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f6001600160a01b0316906341bf3b7c90606401600060405180830381600087803b158015610f2357600080fd5b505af1158015610f37573d6000803e3d6000fd5b508a92503391507f29db2a6062b25ead33a5fc8d1163c4d7f54397202547c27c1c99a20344647734905060018a888787610f71848e611a7c565b6040805196151587526020870195909552938501929092526060840152608083015260a082015260c00160405180910390a3600254610fb9906001600160a01b0316836116cc565b610fc386826116cc565b6000610fcf8534611a95565b90508015610fe157610fe133826116cc565b600d54610ff7906001600160a01b0316856116cc565b600d5460405163330a649d60e01b8152600481018690526001600160a01b039091169063330a649d90602401600060405180830381600087803b15801561103d57600080fd5b505af1158015611051573d6000803e3d6000fd5b5050505083600b60008282546110679190611a7c565b9091555050505050505050505050565b61107f611672565b600c55565b60008060008060007f0000000000000000000000004e6a30f776e914ab05d8b71fbf5475ef2ea7d23f6001600160a01b031663d2cf9115886040518263ffffffff1660e01b81526004016110da91815260200190565b602060405180830381865afa1580156110f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061111b9190611a0c565b90508581101561115e5760405162461bcd60e51b815260206004820152600e60248201526d4578636565647320737570706c7960901b6044820152606401610758565b61117161116b8783611a95565b87611639565b9350670de0b6b3a76400006003548561118a9190611a3b565b6111949190611a5a565b9250670de0b6b3a7640000600454856111ad9190611a3b565b6111b79190611a5a565b9150816111c48486611a95565b61062a9190611a95565b600a60205281600052604060002081815481106111ea57600080fd5b90600052602060002001600091509150505481565b611207611672565b600d54479061121f906001600160a01b0316826116cc565b600d5460405163330a649d60e01b8152600481018390526001600160a01b039091169063330a649d906024016106db565b611258611672565b600d546001600160a01b03161561141457600d54604051638812ebc960e01b81523060048201526000916001600160a01b031690638812ebc9906024016020604051808303816000875af11580156112b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d89190611a0c565b905080156113285760405162461bcd60e51b815260206004820152601e60248201527f5969656c6420746f6b656e206469646e7420776974686472617720616c6c00006044820152606401610758565b600d54604080516376d5de8560e01b815290516000926001600160a01b0316916376d5de85916004808301926020929190829003018187875af1158015611373573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113979190611ac1565b600d5460405163095ea7b360e01b81526001600160a01b0391821660048201526000602482015291925082169063095ea7b3906044016020604051808303816000875af11580156113ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114109190611ade565b5050505b600d80546001600160a01b0319166001600160a01b038316908117909155604080516376d5de8560e01b81529051600092916376d5de85916004808301926020929190829003018187875af1158015611471573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114959190611ac1565b60405163095ea7b360e01b81526001600160a01b03848116600483015260001960248301529192509082169063095ea7b3906044016020604051808303816000875af11580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190611ade565b611515611672565b6001600160a01b03811661157a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610758565b61158381611789565b50565b600d54604051638812ebc960e01b815230600482015260009182916001600160a01b0390911690638812ebc9906024016020604051808303816000875af11580156115d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f99190611a0c565b9050600c54600b548261160c9190611a95565b1061163057600c54600b546116219083611a95565b61162b9190611a95565b611633565b60005b91505090565b60055460065490820290600180850185028585018083010203901c02600754600854919092019161166b9185856117d9565b0192915050565b6000546001600160a01b03163314610cb55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610758565b801561178557604080516000808252602082019092526001600160a01b0384169083906040516116fc9190611b00565b60006040518083038185875af1925050503d8060008114611739576040519150601f19603f3d011682016040523d82523d6000602084013e61173e565b606091505b5050905080610c005760405162461bcd60e51b8152602060048201526013602482015272115d1a081d1c985b9cd9995c8819985a5b1959606a1b6044820152606401610758565b5050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000848480820283036117f157600092505050611908565b600185810190858701018381188185110284188083101561183b5760066001808a018a028a821b820102600019840180850290831b90920191909102030485800285040295509150815b81831015611902576003850260021c600185901b5b60006118e6888488030270ffffffffffffffffffffffffffffffffff811160071b81811c68ffffffffffffffffff1060061b1781811c64ffffffffff1060051b1781811c62ffffff1060041b1781811c620100000160b5600192831c1b0260121c80830401811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b8202889004989098019750600180860195859003016118505750505b50505050505b949350505050565b6000806040838503121561192357600080fd5b50508035926020909101359150565b60008060006060848603121561194757600080fd5b505081359360208301359350604090920135919050565b6001600160a01b038116811461158357600080fd5b60006020828403121561198557600080fd5b81356119908161195e565b9392505050565b600080604083850312156119aa57600080fd5b8235915060208301356119bc8161195e565b809150509250929050565b6000602082840312156119d957600080fd5b5035919050565b600080604083850312156119f357600080fd5b82356119fe8161195e565b946020939093013593505050565b600060208284031215611a1e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615611a5557611a55611a25565b500290565b600082611a7757634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115611a8f57611a8f611a25565b92915050565b81810381811115611a8f57611a8f611a25565b600060018201611aba57611aba611a25565b5060010190565b600060208284031215611ad357600080fd5b81516119908161195e565b600060208284031215611af057600080fd5b8151801515811461199057600080fd5b6000825160005b81811015611b215760208186018101518583015201611b07565b50600092019182525091905056fea26469706673582212206bd7dae1d27704f67d3a1534036c2f71f005014368bc16cdcfbdb8442fa5285164736f6c63430008100033

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
0x599A58BE6367E43e2BEa28DE14BEAAdd316d1de8
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.