ETH Price: $3,164.85 (+1.18%)
Gas: 1 Gwei

Contract

0x44DE78EB54EE54C4151e62834D3B5a29005Bde98
 
Transaction Hash
Method
Block
From
To
Untake197619152024-04-29 15:39:3575 days ago1714405175IN
0x44DE78EB...9005Bde98
0 ETH0.0011920611.71703598
Untake197279992024-04-24 21:45:5980 days ago1713995159IN
0x44DE78EB...9005Bde98
0 ETH0.0015065112.96775542
Take196884982024-04-19 9:09:4785 days ago1713517787IN
0x44DE78EB...9005Bde98
0 ETH0.0018706713.00897518
Take196759122024-04-17 14:52:5987 days ago1713365579IN
0x44DE78EB...9005Bde98
0 ETH0.0060146443.2599181
Take196610442024-04-15 12:55:3589 days ago1713185735IN
0x44DE78EB...9005Bde98
0 ETH0.0026061418.74611647
Untake196492492024-04-13 21:14:4791 days ago1713042887IN
0x44DE78EB...9005Bde98
0 ETH0.02018492188.02563129
Take196301962024-04-11 5:07:2393 days ago1712812043IN
0x44DE78EB...9005Bde98
0 ETH0.0017948714.7185199
Take196134012024-04-08 20:43:4796 days ago1712609027IN
0x44DE78EB...9005Bde98
0 ETH0.0040800629.34055641
Take195926952024-04-05 23:04:3598 days ago1712358275IN
0x44DE78EB...9005Bde98
0 ETH0.002323916.15671604
Take195725302024-04-03 3:20:59101 days ago1712114459IN
0x44DE78EB...9005Bde98
0 ETH0.0044717125.81121874
Take195638632024-04-01 22:10:11103 days ago1712009411IN
0x44DE78EB...9005Bde98
0 ETH0.0034136428.50337069
Untake194833582024-03-21 13:33:23114 days ago1711028003IN
0x44DE78EB...9005Bde98
0 ETH0.0036756535.84602517
Take194833382024-03-21 13:29:11114 days ago1711027751IN
0x44DE78EB...9005Bde98
0 ETH0.0054194630.44043613
Untake192126362024-02-12 14:47:47152 days ago1707749267IN
0x44DE78EB...9005Bde98
0 ETH0.0049942942.99870553
Untake191938202024-02-09 23:23:47154 days ago1707521027IN
0x44DE78EB...9005Bde98
0 ETH0.0042021345.72613088
Untake191776382024-02-07 16:54:59157 days ago1707324899IN
0x44DE78EB...9005Bde98
0 ETH0.005738753.99909806
Untake191770092024-02-07 14:48:23157 days ago1707317303IN
0x44DE78EB...9005Bde98
0 ETH0.0060504351.02669457
Take191715482024-02-06 20:23:47158 days ago1707251027IN
0x44DE78EB...9005Bde98
0 ETH0.0047588636.18878113
Take191429302024-02-02 19:55:35162 days ago1706903735IN
0x44DE78EB...9005Bde98
0 ETH0.0031695922.26665876
Take191416332024-02-02 15:34:47162 days ago1706888087IN
0x44DE78EB...9005Bde98
0 ETH0.002395925.00348066
Take191414592024-02-02 14:59:59162 days ago1706885999IN
0x44DE78EB...9005Bde98
0 ETH0.0031042323.50997352
Take191413942024-02-02 14:46:59162 days ago1706885219IN
0x44DE78EB...9005Bde98
0 ETH0.0058577734.25059162
Take191286542024-01-31 19:50:47164 days ago1706730647IN
0x44DE78EB...9005Bde98
0 ETH0.0024097725.15132652
Take191285862024-01-31 19:37:11164 days ago1706729831IN
0x44DE78EB...9005Bde98
0 ETH0.003980929.52690851
Take191283822024-01-31 18:55:59164 days ago1706727359IN
0x44DE78EB...9005Bde98
0 ETH0.0028068930.83715238
View all transactions

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To
188352182023-12-21 15:45:23205 days ago1703173523  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ITOProtocolV1

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion
File 1 of 9 : ITOProtocolV1.sol
// SPDX-License-Identifier: BUSL-1.1
// Developed by Moai Labs LLC, owned by EPOCH DAO
pragma solidity 0.8.17;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract ITOProtocolV1 is Ownable {
    using SafeERC20 for IERC20Metadata;

    struct LPPosition {
        address maker;
        uint16 lpFeeBp;
        uint32 startDate;
        uint32 endDate;
        IERC20Metadata downsideToken;
        IERC20Metadata upsideToken;
        uint256 upsideTokenBalance;
        uint256 upsidePerDownside;
        uint256 downsideTokenBalance;
    }
    LPPosition[] public lpPositions;
    mapping(uint256 => mapping(address => uint256)) public downsideTokenAmounts;

    // LP Fees
    mapping(address => mapping(address => uint256)) public accumulatedFees;

    // Protocol Fee
    mapping(address => uint256) public protocolFeeBalances;
    uint16 public protocolFeeBp = 100;
    address public protocolFeeRecipientAddress;

    uint16 constant MAX_FEE_BP = 4999;
    uint16 constant BP_MULTIPLIER = 10000;

    uint256 MULTIPLIER = (10**18);

    // Events
    // @dev Minimal data included, data can be fetched from historical blockchain calls
    event Supply(uint256 _positionId);
    event Remove(uint256 _positionId, uint256 _downsideTokenAmount, uint256 _upsideTokenAmount);
    event Take(uint256 _positionId, uint256 _downsideTokenAmount, uint256 _upsideTokenAmount, address _taker);
    event Untake(uint256 _positionId, uint256 _downsideTokenAmount, uint256 _upsideTokenAmount, address _taker);
    event ProtocolFeeClaimed(address _tokenAddress, uint256 _tokenAmount);
    event LPFeeClaimed(address _recipient, address _tokenAddress, uint256 _tokenAmount);
    event ProtocolFeeSet(address _protocolFeeRecipientAddress, uint16 _protocolFeeBp);

    // Errors
    error FeeTooHigh();
    error NotOwner();
    error PositionNotEnded();
    error PositionNotStarted();
    error PositionEnded();
    error InvalidDuration();
    error OutputTooLow();
    error FeeChanged();
    error InvalidFeeConfiguration();

    constructor(address _newOwner) {
        _transferOwnership(_newOwner);
        protocolFeeRecipientAddress = _newOwner;
    }

    /// @notice Allows LPs to create a position
    /// @param _downsideToken Address of the downside token
    /// @param _upsideToken Address of the upside token
    /// @param _upsideTokenAmount The number of upside tokens to provide to this position
    /// @param _exchangeRate The number of upside tokens to pay per downside token
    /// @dev _exchangeRate should be computed like so: ((upsideAmountWei / downsideAmountWei) * 10**18)
    /// @dev Example 1: 1000 USDC as downside, 1 WETH as upside, _exchangeRate = 1000000000000000000000000000
    /// @dev Example 2: 1000 DAI as downside, 1 WETH as upside, _exchangeRate = 1000000000000000
    /// @dev Example 3: 40000 USDC as downside, 1 WBTC as upside, _exchangeRate = 2500000000000000
    /// @param _startDate Unix timestamp of when this position should begin
    /// @param _endDate Unix timestamp of when this position should end
    /// @param _feeBp The maximum liquidity provider fee to charge
    function supply(
        address _downsideToken,
        address _upsideToken,
        uint256 _upsideTokenAmount,
        uint256 _exchangeRate,
        uint32 _startDate,
        uint32 _endDate,
        uint16 _feeBp
    ) external {
        if(_feeBp > MAX_FEE_BP) {
            revert FeeTooHigh();
        }
        if(block.timestamp > _startDate || _startDate > _endDate) {
            revert InvalidDuration();
        }

        lpPositions.push(LPPosition(
            msg.sender,
            _feeBp,
            _startDate,
            _endDate,
            IERC20Metadata(_downsideToken),
            IERC20Metadata(_upsideToken),
            _upsideTokenAmount,
            _exchangeRate,
            0
        ));
        IERC20Metadata(_upsideToken).safeTransferFrom(msg.sender, address(this), _upsideTokenAmount);
        emit Supply(lpPositions.length - 1);
    }

    /// @notice Allows LPs to remove tokens from their position
    /// @dev Note that downside tokens cannot be withdrawn until the end date of the position has been reached
    /// @param _positionId The ID of the position you want to remove from
    /// @param _upsideTokenAmount The number of upside tokens to remove from the position
    /// @param _downsideTokenAmount The number of downside tokens to remove from the position
    function remove(uint256 _positionId, uint256 _upsideTokenAmount, uint256 _downsideTokenAmount) external {
        LPPosition memory d = lpPositions[_positionId];

        if(d.maker != msg.sender) {
            revert NotOwner();
        }

        if(_downsideTokenAmount != 0) {
            if(d.endDate > block.timestamp) {
                revert PositionNotEnded();
            }
        }
        lpPositions[_positionId].downsideTokenBalance -= _downsideTokenAmount;
        lpPositions[_positionId].upsideTokenBalance -= _upsideTokenAmount;

        if(lpPositions[_positionId].downsideTokenBalance == 0 && lpPositions[_positionId].upsideTokenBalance == 0) {
            delete lpPositions[_positionId];
        }

        if(_downsideTokenAmount != 0) {
            d.downsideToken.safeTransfer(msg.sender, _downsideTokenAmount);
        }
        if(_upsideTokenAmount != 0) {
            d.upsideToken.safeTransfer(msg.sender, _upsideTokenAmount);
        }

        emit Remove(_positionId, _downsideTokenAmount, _upsideTokenAmount);
    }

    /// @notice Returns the exact token amounts taken as protocolFee and lpFee given a downside amount
    /// @param _positionId The position ID you wish to calculate fees for
    /// @param _downsideTokenAmount The number of downside tokens you want to calculate fees for
    /// @return protocolFeeTokens The number of downside tokens taken as protocol fee
    /// @return lpFeeTokens The number of downside tokens taken as the LP fee
    function computeFee(uint256 _positionId, uint256 _downsideTokenAmount) public view returns(
        uint256 protocolFeeTokens,
        uint256 lpFeeTokens
    ) {
        uint256 _protocolFeeBp = protocolFeeBp;
        if(_protocolFeeBp != 0) {
            protocolFeeTokens = (_downsideTokenAmount * _protocolFeeBp) / BP_MULTIPLIER;
        }
        uint256 _lpFeeBp = lpPositions[_positionId].lpFeeBp;
        if(_lpFeeBp != 0) {
            lpFeeTokens = (_downsideTokenAmount * _lpFeeBp) / BP_MULTIPLIER;
        }

        return (protocolFeeTokens, lpFeeTokens);
    }

    /// @notice Allows takers to take up the deal (even partially)
    /// @param _positionId The unique ID for the position you wish to interact with
    /// @param _maxDownsideTokenIn The maximum number of downside tokens you wish to provide to this position
    /// @param _minUpsideTokenOut The minimum number of upside tokens to receive before reverting
    /// @param _maxProtocolFeeBp The maximum protocol fee BP you wish to accept before reverting
    /// @dev _maxProtocolFeeBp should typically be set to the current protocol fee
    /// @dev _minUpsideTokenOut can be set to 0 to always partial fill if necessary
    /// @dev None of these params determine exchange rate. Exchange rate is set by supplier of position
    function take(
        uint256 _positionId,
        uint256 _maxDownsideTokenIn,
        uint256 _minUpsideTokenOut,
        uint256 _maxProtocolFeeBp
    ) external {
        LPPosition memory d = lpPositions[_positionId];

        if(d.startDate > block.timestamp) {
            revert PositionNotStarted();
        }
        if(block.timestamp > d.endDate) {
            revert PositionEnded();
        }

        if(protocolFeeBp > _maxProtocolFeeBp) {
            revert FeeChanged();
        }

        (uint256 protocolFee, uint256 lpFee) = computeFee(_positionId, _maxDownsideTokenIn);
        uint256 _downsideTokenBalanceAfterFees = _maxDownsideTokenIn - protocolFee - lpFee;
        uint256 upsideTokenAmount = (_downsideTokenBalanceAfterFees * d.upsidePerDownside) / MULTIPLIER;
        protocolFee = _maxDownsideTokenIn - _downsideTokenBalanceAfterFees - lpFee;

        if(upsideTokenAmount > d.upsideTokenBalance) {
            upsideTokenAmount = d.upsideTokenBalance;

            _downsideTokenBalanceAfterFees = (upsideTokenAmount * MULTIPLIER) / d.upsidePerDownside;
            _maxDownsideTokenIn = (_downsideTokenBalanceAfterFees * BP_MULTIPLIER) / (BP_MULTIPLIER - (d.lpFeeBp + protocolFeeBp));
            (, lpFee) = computeFee(_positionId, _maxDownsideTokenIn);
            protocolFee = _maxDownsideTokenIn - _downsideTokenBalanceAfterFees - lpFee;
        }
        if(_minUpsideTokenOut > upsideTokenAmount) {
            revert OutputTooLow();
        }

        protocolFeeBalances[address(d.downsideToken)] += protocolFee;
        accumulatedFees[d.maker][address(d.downsideToken)] += lpFee;

        lpPositions[_positionId].downsideTokenBalance += _downsideTokenBalanceAfterFees;
        lpPositions[_positionId].upsideTokenBalance -= upsideTokenAmount;

        downsideTokenAmounts[_positionId][msg.sender] += _downsideTokenBalanceAfterFees;

        d.downsideToken.safeTransferFrom(msg.sender, address(this), _maxDownsideTokenIn);
        d.upsideToken.safeTransfer(msg.sender, upsideTokenAmount);

        emit Take(_positionId, _downsideTokenBalanceAfterFees, upsideTokenAmount, msg.sender);
    }

    /// @notice Allows users to return upside tokens (even partially) for a specified number of downsideTokens
    /// @dev Cannot be called once the position has ended
    /// @param _positionId The unique ID for the position you wish to interact with
    /// @param _downsideTokenAmount The number of downside tokens to return
    function untake(uint256 _positionId, uint256 _downsideTokenAmount) external {
        LPPosition memory d = lpPositions[_positionId];

        if(block.timestamp > d.endDate) {
            revert PositionEnded();
        }

        uint256 upsideTokenAmount = (_downsideTokenAmount * d.upsidePerDownside) / MULTIPLIER;

        downsideTokenAmounts[_positionId][msg.sender] -= _downsideTokenAmount;
        lpPositions[_positionId].downsideTokenBalance -= _downsideTokenAmount;
        lpPositions[_positionId].upsideTokenBalance += upsideTokenAmount;

        d.upsideToken.safeTransferFrom(msg.sender, address(this), upsideTokenAmount);
        d.downsideToken.safeTransfer(msg.sender, _downsideTokenAmount);

        emit Untake(_positionId, _downsideTokenAmount, upsideTokenAmount, msg.sender);
    }

    /// @notice Allows owner to set protocol fee recipient address and protocol fee percentage (max)
    /// @dev Only callable by owner
    /// @param _protocolFeeRecipientAddress The address where protocol fees should flow to
    /// @param _protocolFeeBp The protocol fee in basis points (100 = 1%)
    function setProtocolFee(address _protocolFeeRecipientAddress, uint16 _protocolFeeBp) external onlyOwner {
        if(_protocolFeeBp > MAX_FEE_BP) {
            revert FeeTooHigh();
        }

        if(_protocolFeeRecipientAddress == address(0) && _protocolFeeBp != 0) {
            revert InvalidFeeConfiguration();
        }

        protocolFeeRecipientAddress = _protocolFeeRecipientAddress;
        protocolFeeBp = _protocolFeeBp;

        emit ProtocolFeeSet(_protocolFeeRecipientAddress, _protocolFeeBp);
    }

    /// @notice Allows anyone to process protocol fees for a given token address
    /// @notice Fees are sent to the protocolFeeRecipientAddress
    /// @param _tokenAddresses List of the number of tokens to claim
    /// @param _amounts The amount of tokens to process
    function claimProtocolFees(address[] calldata _tokenAddresses, uint256[] calldata _amounts) external {
        for(uint256 i; i < _tokenAddresses.length; ++i) {
            protocolFeeBalances[_tokenAddresses[i]] -= _amounts[i];

            IERC20Metadata(_tokenAddresses[i]).safeTransfer(protocolFeeRecipientAddress, _amounts[i]);

            emit ProtocolFeeClaimed(_tokenAddresses[i], _amounts[i]);
        }
    }

    /// @notice Allows claiming of multiple tokens (partial or full)
    /// @param _tokenAddresses List of the token addresses you wish to claim fees for
    /// @param _tokenAmounts List of the number of tokens to claim
    /// @param _recipient The address where the fees should be sent to
    function claimPositionFees(address[] calldata _tokenAddresses, uint256[] calldata _tokenAmounts, address _recipient) external {
        for(uint256 i; i < _tokenAddresses.length; ++i) {
            accumulatedFees[msg.sender][_tokenAddresses[i]] -= _tokenAmounts[i];

            IERC20Metadata(_tokenAddresses[i]).safeTransfer(_recipient, _tokenAmounts[i]);

            emit LPFeeClaimed(_recipient, _tokenAddresses[i], _tokenAmounts[i]);
        }
    }

    /// @notice Returns the array length of lpPositions
    /// @dev This will include empty positions
    function lpPositionsCount() external view returns(uint256) {
        return lpPositions.length;
    }
}

File 2 of 9 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        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);
    }
}

File 3 of 9 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}

File 4 of 9 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 5 of 9 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/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);
}

File 6 of 9 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}

File 7 of 9 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/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;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 8 of 9 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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);
        }
    }
}

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

Settings
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FeeChanged","type":"error"},{"inputs":[],"name":"FeeTooHigh","type":"error"},{"inputs":[],"name":"InvalidDuration","type":"error"},{"inputs":[],"name":"InvalidFeeConfiguration","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"OutputTooLow","type":"error"},{"inputs":[],"name":"PositionEnded","type":"error"},{"inputs":[],"name":"PositionNotEnded","type":"error"},{"inputs":[],"name":"PositionNotStarted","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_recipient","type":"address"},{"indexed":false,"internalType":"address","name":"_tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"LPFeeClaimed","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":false,"internalType":"address","name":"_tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"ProtocolFeeClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_protocolFeeRecipientAddress","type":"address"},{"indexed":false,"internalType":"uint16","name":"_protocolFeeBp","type":"uint16"}],"name":"ProtocolFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_positionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_downsideTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_upsideTokenAmount","type":"uint256"}],"name":"Remove","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_positionId","type":"uint256"}],"name":"Supply","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_positionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_downsideTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_upsideTokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_taker","type":"address"}],"name":"Take","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_positionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_downsideTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_upsideTokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_taker","type":"address"}],"name":"Untake","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"accumulatedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokenAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_tokenAmounts","type":"uint256[]"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"claimPositionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokenAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"claimProtocolFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_positionId","type":"uint256"},{"internalType":"uint256","name":"_downsideTokenAmount","type":"uint256"}],"name":"computeFee","outputs":[{"internalType":"uint256","name":"protocolFeeTokens","type":"uint256"},{"internalType":"uint256","name":"lpFeeTokens","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"downsideTokenAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lpPositions","outputs":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"uint16","name":"lpFeeBp","type":"uint16"},{"internalType":"uint32","name":"startDate","type":"uint32"},{"internalType":"uint32","name":"endDate","type":"uint32"},{"internalType":"contract IERC20Metadata","name":"downsideToken","type":"address"},{"internalType":"contract IERC20Metadata","name":"upsideToken","type":"address"},{"internalType":"uint256","name":"upsideTokenBalance","type":"uint256"},{"internalType":"uint256","name":"upsidePerDownside","type":"uint256"},{"internalType":"uint256","name":"downsideTokenBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpPositionsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"protocolFeeBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFeeBp","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFeeRecipientAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_positionId","type":"uint256"},{"internalType":"uint256","name":"_upsideTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_downsideTokenAmount","type":"uint256"}],"name":"remove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_protocolFeeRecipientAddress","type":"address"},{"internalType":"uint16","name":"_protocolFeeBp","type":"uint16"}],"name":"setProtocolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_downsideToken","type":"address"},{"internalType":"address","name":"_upsideToken","type":"address"},{"internalType":"uint256","name":"_upsideTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_exchangeRate","type":"uint256"},{"internalType":"uint32","name":"_startDate","type":"uint32"},{"internalType":"uint32","name":"_endDate","type":"uint32"},{"internalType":"uint16","name":"_feeBp","type":"uint16"}],"name":"supply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_positionId","type":"uint256"},{"internalType":"uint256","name":"_maxDownsideTokenIn","type":"uint256"},{"internalType":"uint256","name":"_minUpsideTokenOut","type":"uint256"},{"internalType":"uint256","name":"_maxProtocolFeeBp","type":"uint256"}],"name":"take","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_positionId","type":"uint256"},{"internalType":"uint256","name":"_downsideTokenAmount","type":"uint256"}],"name":"untake","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526005805461ffff19166064179055670de0b6b3a76400006006553480156200002b57600080fd5b5060405162001e3838038062001e388339810160408190526200004e91620000e2565b620000593362000092565b620000648162000092565b600580546001600160a01b03909216620100000262010000600160b01b031990921691909117905562000114565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000f557600080fd5b81516001600160a01b03811681146200010d57600080fd5b9392505050565b611d1480620001246000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c80638da5cb5b116100b2578063c95fe5b611610081578063d4a67c6d11610066578063d4a67c6d1461031c578063effcacec14610347578063f2fde38b1461035a57600080fd5b8063c95fe5b6146102f6578063cf0ce5281461030957600080fd5b80638da5cb5b146102915780638fc26d40146102a257806398753c46146102b5578063b4f98c30146102d657600080fd5b80633a16b768116101095780634e733824116100ee5780634e7338241461026e578063715018a6146102765780637ed72fda1461027e57600080fd5b80633a16b7681461022a57806345ec6e041461023d57600080fd5b8063119c76f71461013b57806317145715146101b45780631df67f5f146101ed5780632ff284c214610202575b600080fd5b61014e610149366004611864565b61036d565b604080516001600160a01b039a8b16815261ffff9990991660208a015263ffffffff97881690890152949095166060870152918616608086015290941660a084015260c083019390935260e0820152610100810191909152610120015b60405180910390f35b6101df6101c2366004611899565b600260209081526000928352604080842090915290825290205481565b6040519081526020016101ab565b6102006101fb36600461190a565b6103e5565b005b610215610210366004611976565b610568565b604080519283526020830191909152016101ab565b6102006102383660046119aa565b6105f1565b600554610256906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016101ab565b6001546101df565b6102006106e1565b61020061028c3660046119d4565b6106f5565b6000546001600160a01b0316610256565b6102006102b0366004611a00565b6109d8565b6005546102c39061ffff1681565b60405161ffff90911681526020016101ab565b6101df6102e4366004611a81565b60046020526000908152604090205481565b610200610304366004611976565b610b4c565b610200610317366004611aa3565b610d5e565b6101df61032a366004611ad5565b600360209081526000928352604080842090915290825290205481565b610200610355366004611b13565b611139565b610200610368366004611a81565b6113b6565b6001818154811061037d57600080fd5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001600160a01b03808616975061ffff600160a01b8704169663ffffffff600160b01b8804811697600160d01b90041695821694909116929189565b60005b838110156105615782828281811061040257610402611b8b565b905060200201356004600087878581811061041f5761041f611b8b565b90506020020160208101906104349190611a81565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546104639190611bb7565b90915550506005546104ce906201000090046001600160a01b031684848481811061049057610490611b8b565b905060200201358787858181106104a9576104a9611b8b565b90506020020160208101906104be9190611a81565b6001600160a01b0316919061144b565b7f0f7f5b155b0b0ac6890709a2c7bf1b8bb3f675fff1e7840b4dd3c9acde59048b85858381811061050157610501611b8b565b90506020020160208101906105169190611a81565b84848481811061052857610528611b8b565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a161055a81611bd0565b90506103e8565b5050505050565b600554600090819061ffff168015610594576127106105878286611be9565b6105919190611c00565b92505b6000600186815481106105a9576105a9611b8b565b6000918252602090912060069091020154600160a01b900461ffff16905080156105e7576127106105da8287611be9565b6105e49190611c00565b92505b50505b9250929050565b6105f96114e0565b61138761ffff821611156106205760405163cd4e616760e01b815260040160405180910390fd5b6001600160a01b03821615801561063a575061ffff811615155b156106585760405163369276d760e11b815260040160405180910390fd5b600580547fffffffffffffffffffff0000000000000000000000000000000000000000000016620100006001600160a01b03851690810261ffff19169190911761ffff84169081179092556040805191825260208201929092527fc5b233d08091c29ef4fa1665420c369a96819e217b74f76e5e64745003f7fbf2910160405180910390a15050565b6106e96114e0565b6106f3600061153a565b565b60006001848154811061070a5761070a611b8b565b60009182526020918290206040805161012081018252600690930290910180546001600160a01b0380821680865261ffff600160a01b8404169686019690965263ffffffff600160b01b8304811694860194909452600160d01b9091049092166060840152600181015482166080840152600281015490911660a0830152600381015460c0830152600481015460e083015260050154610100820152915033146107c7576040516330cd747160e01b815260040160405180910390fd5b81156107f85742816060015163ffffffff1611156107f8576040516375abe65b60e11b815260040160405180910390fd5b816001858154811061080c5761080c611b8b565b9060005260206000209060060201600501600082825461082c9190611bb7565b92505081905550826001858154811061084757610847611b8b565b906000526020600020906006020160030160008282546108679190611bb7565b9091555050600180548590811061088057610880611b8b565b90600052602060002090600602016005015460001480156108c55750600184815481106108af576108af611b8b565b9060005260206000209060060201600301546000145b1561095257600184815481106108dd576108dd611b8b565b60009182526020822060069091020180547fffff00000000000000000000000000000000000000000000000000000000000016815560018101805473ffffffffffffffffffffffffffffffffffffffff1990811690915560028201805490911690556003810182905560048101829055600501555b8115610971576080810151610971906001600160a01b0316338461144b565b82156109905760a0810151610990906001600160a01b0316338561144b565b60408051858152602081018490529081018490527fe26e44b49401e2c8d21cfcb6628ae520c5a95ebd3b087893b427af4fa3d4e0d9906060015b60405180910390a150505050565b60005b84811015610b44578383828181106109f5576109f5611b8b565b33600090815260036020908152604082209202939093013592909150888885818110610a2357610a23611b8b565b9050602002016020810190610a389190611a81565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610a679190611bb7565b90915550610a9c905082858584818110610a8357610a83611b8b565b905060200201358888858181106104a9576104a9611b8b565b7f7643db038b35f94894e86d0571d9683cab130be8788071149652ff88a0dafb1c82878784818110610ad057610ad0611b8b565b9050602002016020810190610ae59190611a81565b868685818110610af757610af7611b8b565b90506020020135604051610b2c939291906001600160a01b039384168152919092166020820152604081019190915260600190565b60405180910390a1610b3d81611bd0565b90506109db565b505050505050565b600060018381548110610b6157610b61611b8b565b60009182526020918290206040805161012081018252600690930290910180546001600160a01b03808216855261ffff600160a01b8304169585019590955263ffffffff600160b01b8204811693850193909352600160d01b900490911660608301819052600182015484166080840152600282015490931660a0830152600381015460c0830152600481015460e0830152600501546101008201529150421115610c1f5760405163672bf1d360e11b815260040160405180910390fd5b60006006548260e0015184610c349190611be9565b610c3e9190611c00565b6000858152600260209081526040808320338452909152812080549293508592909190610c6c908490611bb7565b925050819055508260018581548110610c8757610c87611b8b565b90600052602060002090600602016005016000828254610ca79190611bb7565b925050819055508060018581548110610cc257610cc2611b8b565b90600052602060002090600602016003016000828254610ce29190611c22565b909155505060a0820151610d01906001600160a01b0316333084611597565b6080820151610d1a906001600160a01b0316338561144b565b60408051858152602081018590529081018290523360608201527f4f9adb34db7385b64ed42229c939cc08c8c0bbc4154230e96a0b842e5c0fe783906080016109ca565b600060018581548110610d7357610d73611b8b565b60009182526020918290206040805161012081018252600690930290910180546001600160a01b03808216855261ffff600160a01b8304169585019590955263ffffffff600160b01b82048116938501849052600160d01b909104166060840152600181015484166080840152600281015490931660a0830152600383015460c0830152600483015460e08301526005909201546101008201529150421015610e2f576040516309ca244760e31b815260040160405180910390fd5b806060015163ffffffff16421115610e5a5760405163672bf1d360e11b815260040160405180910390fd5b60055461ffff16821015610e8157604051630bc296ad60e21b815260040160405180910390fd5b600080610e8e8787610568565b9092509050600081610ea08489611bb7565b610eaa9190611bb7565b905060006006548560e0015183610ec19190611be9565b610ecb9190611c00565b905082610ed8838a611bb7565b610ee29190611bb7565b93508460c00151811115610f7b575060c084015160e0850151600654610f089083611be9565b610f129190611c00565b6005546020870151919350610f2d9161ffff90911690611c35565b610f3990612710611c57565b61ffff16610f4961271084611be9565b610f539190611c00565b9750610f5f8989610568565b9350839050610f6e838a611bb7565b610f789190611bb7565b93505b80871115610f9c576040516392ea111960e01b815260040160405180910390fd5b60808501516001600160a01b031660009081526004602052604081208054869290610fc8908490611c22565b909155505084516001600160a01b03908116600090815260036020908152604080832060808a01519094168352929052908120805485929061100b908490611c22565b925050819055508160018a8154811061102657611026611b8b565b906000526020600020906006020160050160008282546110469190611c22565b925050819055508060018a8154811061106157611061611b8b565b906000526020600020906006020160030160008282546110819190611bb7565b90915550506000898152600260209081526040808320338452909152812080548492906110af908490611c22565b909155505060808501516110ce906001600160a01b031633308b611597565b60a08501516110e7906001600160a01b0316338361144b565b604080518a8152602081018490529081018290523360608201527fb57e19c4d9c6a4152d6e5e1c03616b47e09af534e8c94cd83ce713f3f198f01b9060800160405180910390a1505050505050505050565b61138761ffff821611156111605760405163cd4e616760e01b815260040160405180910390fd5b8263ffffffff1642118061117f57508163ffffffff168363ffffffff16115b1561119d57604051637616640160e01b815260040160405180910390fd5b6001604051806101200160405280336001600160a01b031681526020018361ffff1681526020018563ffffffff1681526020018463ffffffff168152602001896001600160a01b03168152602001886001600160a01b031681526020018781526020018681526020016000815250908060018154018082558091505060019003906000526020600020906006020160009091909190915060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548161ffff021916908361ffff16021790555060408201518160000160166101000a81548163ffffffff021916908363ffffffff160217905550606082015181600001601a6101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a08201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816003015560e082015181600401556101008201518160050155505061136d333087896001600160a01b0316611597909392919063ffffffff16565b600180547f1862f918d5600ec0980589e8cc806b3c79b1e762fcbf44cc2947ba12499207eb9161139c91611bb7565b60405190815260200160405180910390a150505050505050565b6113be6114e0565b6001600160a01b03811661143f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6114488161153a565b50565b6040516001600160a01b0383166024820152604481018290526114db90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115d5565b505050565b6000546001600160a01b031633146106f35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611436565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526115cf9085906323b872dd60e01b90608401611477565b50505050565b600061162a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116bd9092919063ffffffff16565b905080516000148061164b57508080602001905181019061164b9190611c72565b6114db5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611436565b60606116cc84846000856116d4565b949350505050565b60608247101561174c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611436565b600080866001600160a01b031685876040516117689190611cb8565b60006040518083038185875af1925050503d80600081146117a5576040519150601f19603f3d011682016040523d82523d6000602084013e6117aa565b606091505b50915091506117bb878383876117c6565b979650505050505050565b6060831561183557825160000361182e576001600160a01b0385163b61182e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611436565b50816116cc565b6116cc838381511561184a5781518083602001fd5b8060405162461bcd60e51b81526004016114369190611cd4565b60006020828403121561187657600080fd5b5035919050565b80356001600160a01b038116811461189457600080fd5b919050565b600080604083850312156118ac57600080fd5b823591506118bc6020840161187d565b90509250929050565b60008083601f8401126118d757600080fd5b50813567ffffffffffffffff8111156118ef57600080fd5b6020830191508360208260051b85010111156105ea57600080fd5b6000806000806040858703121561192057600080fd5b843567ffffffffffffffff8082111561193857600080fd5b611944888389016118c5565b9096509450602087013591508082111561195d57600080fd5b5061196a878288016118c5565b95989497509550505050565b6000806040838503121561198957600080fd5b50508035926020909101359150565b803561ffff8116811461189457600080fd5b600080604083850312156119bd57600080fd5b6119c68361187d565b91506118bc60208401611998565b6000806000606084860312156119e957600080fd5b505081359360208301359350604090920135919050565b600080600080600060608688031215611a1857600080fd5b853567ffffffffffffffff80821115611a3057600080fd5b611a3c89838a016118c5565b90975095506020880135915080821115611a5557600080fd5b50611a62888289016118c5565b9094509250611a7590506040870161187d565b90509295509295909350565b600060208284031215611a9357600080fd5b611a9c8261187d565b9392505050565b60008060008060808587031215611ab957600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215611ae857600080fd5b611af18361187d565b91506118bc6020840161187d565b803563ffffffff8116811461189457600080fd5b600080600080600080600060e0888a031215611b2e57600080fd5b611b378861187d565b9650611b456020890161187d565b95506040880135945060608801359350611b6160808901611aff565b9250611b6f60a08901611aff565b9150611b7d60c08901611998565b905092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115611bca57611bca611ba1565b92915050565b600060018201611be257611be2611ba1565b5060010190565b8082028115828204841417611bca57611bca611ba1565b600082611c1d57634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115611bca57611bca611ba1565b61ffff818116838216019080821115611c5057611c50611ba1565b5092915050565b61ffff828116828216039080821115611c5057611c50611ba1565b600060208284031215611c8457600080fd5b81518015158114611a9c57600080fd5b60005b83811015611caf578181015183820152602001611c97565b50506000910152565b60008251611cca818460208701611c94565b9190910192915050565b6020815260008251806020840152611cf3816040850160208701611c94565b601f01601f1916919091016040019291505056fea164736f6c6343000811000a0000000000000000000000002fa4ab54543be08001e322e14311d900a5fcc004

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101365760003560e01c80638da5cb5b116100b2578063c95fe5b611610081578063d4a67c6d11610066578063d4a67c6d1461031c578063effcacec14610347578063f2fde38b1461035a57600080fd5b8063c95fe5b6146102f6578063cf0ce5281461030957600080fd5b80638da5cb5b146102915780638fc26d40146102a257806398753c46146102b5578063b4f98c30146102d657600080fd5b80633a16b768116101095780634e733824116100ee5780634e7338241461026e578063715018a6146102765780637ed72fda1461027e57600080fd5b80633a16b7681461022a57806345ec6e041461023d57600080fd5b8063119c76f71461013b57806317145715146101b45780631df67f5f146101ed5780632ff284c214610202575b600080fd5b61014e610149366004611864565b61036d565b604080516001600160a01b039a8b16815261ffff9990991660208a015263ffffffff97881690890152949095166060870152918616608086015290941660a084015260c083019390935260e0820152610100810191909152610120015b60405180910390f35b6101df6101c2366004611899565b600260209081526000928352604080842090915290825290205481565b6040519081526020016101ab565b6102006101fb36600461190a565b6103e5565b005b610215610210366004611976565b610568565b604080519283526020830191909152016101ab565b6102006102383660046119aa565b6105f1565b600554610256906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016101ab565b6001546101df565b6102006106e1565b61020061028c3660046119d4565b6106f5565b6000546001600160a01b0316610256565b6102006102b0366004611a00565b6109d8565b6005546102c39061ffff1681565b60405161ffff90911681526020016101ab565b6101df6102e4366004611a81565b60046020526000908152604090205481565b610200610304366004611976565b610b4c565b610200610317366004611aa3565b610d5e565b6101df61032a366004611ad5565b600360209081526000928352604080842090915290825290205481565b610200610355366004611b13565b611139565b610200610368366004611a81565b6113b6565b6001818154811061037d57600080fd5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001600160a01b03808616975061ffff600160a01b8704169663ffffffff600160b01b8804811697600160d01b90041695821694909116929189565b60005b838110156105615782828281811061040257610402611b8b565b905060200201356004600087878581811061041f5761041f611b8b565b90506020020160208101906104349190611a81565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546104639190611bb7565b90915550506005546104ce906201000090046001600160a01b031684848481811061049057610490611b8b565b905060200201358787858181106104a9576104a9611b8b565b90506020020160208101906104be9190611a81565b6001600160a01b0316919061144b565b7f0f7f5b155b0b0ac6890709a2c7bf1b8bb3f675fff1e7840b4dd3c9acde59048b85858381811061050157610501611b8b565b90506020020160208101906105169190611a81565b84848481811061052857610528611b8b565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a161055a81611bd0565b90506103e8565b5050505050565b600554600090819061ffff168015610594576127106105878286611be9565b6105919190611c00565b92505b6000600186815481106105a9576105a9611b8b565b6000918252602090912060069091020154600160a01b900461ffff16905080156105e7576127106105da8287611be9565b6105e49190611c00565b92505b50505b9250929050565b6105f96114e0565b61138761ffff821611156106205760405163cd4e616760e01b815260040160405180910390fd5b6001600160a01b03821615801561063a575061ffff811615155b156106585760405163369276d760e11b815260040160405180910390fd5b600580547fffffffffffffffffffff0000000000000000000000000000000000000000000016620100006001600160a01b03851690810261ffff19169190911761ffff84169081179092556040805191825260208201929092527fc5b233d08091c29ef4fa1665420c369a96819e217b74f76e5e64745003f7fbf2910160405180910390a15050565b6106e96114e0565b6106f3600061153a565b565b60006001848154811061070a5761070a611b8b565b60009182526020918290206040805161012081018252600690930290910180546001600160a01b0380821680865261ffff600160a01b8404169686019690965263ffffffff600160b01b8304811694860194909452600160d01b9091049092166060840152600181015482166080840152600281015490911660a0830152600381015460c0830152600481015460e083015260050154610100820152915033146107c7576040516330cd747160e01b815260040160405180910390fd5b81156107f85742816060015163ffffffff1611156107f8576040516375abe65b60e11b815260040160405180910390fd5b816001858154811061080c5761080c611b8b565b9060005260206000209060060201600501600082825461082c9190611bb7565b92505081905550826001858154811061084757610847611b8b565b906000526020600020906006020160030160008282546108679190611bb7565b9091555050600180548590811061088057610880611b8b565b90600052602060002090600602016005015460001480156108c55750600184815481106108af576108af611b8b565b9060005260206000209060060201600301546000145b1561095257600184815481106108dd576108dd611b8b565b60009182526020822060069091020180547fffff00000000000000000000000000000000000000000000000000000000000016815560018101805473ffffffffffffffffffffffffffffffffffffffff1990811690915560028201805490911690556003810182905560048101829055600501555b8115610971576080810151610971906001600160a01b0316338461144b565b82156109905760a0810151610990906001600160a01b0316338561144b565b60408051858152602081018490529081018490527fe26e44b49401e2c8d21cfcb6628ae520c5a95ebd3b087893b427af4fa3d4e0d9906060015b60405180910390a150505050565b60005b84811015610b44578383828181106109f5576109f5611b8b565b33600090815260036020908152604082209202939093013592909150888885818110610a2357610a23611b8b565b9050602002016020810190610a389190611a81565b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610a679190611bb7565b90915550610a9c905082858584818110610a8357610a83611b8b565b905060200201358888858181106104a9576104a9611b8b565b7f7643db038b35f94894e86d0571d9683cab130be8788071149652ff88a0dafb1c82878784818110610ad057610ad0611b8b565b9050602002016020810190610ae59190611a81565b868685818110610af757610af7611b8b565b90506020020135604051610b2c939291906001600160a01b039384168152919092166020820152604081019190915260600190565b60405180910390a1610b3d81611bd0565b90506109db565b505050505050565b600060018381548110610b6157610b61611b8b565b60009182526020918290206040805161012081018252600690930290910180546001600160a01b03808216855261ffff600160a01b8304169585019590955263ffffffff600160b01b8204811693850193909352600160d01b900490911660608301819052600182015484166080840152600282015490931660a0830152600381015460c0830152600481015460e0830152600501546101008201529150421115610c1f5760405163672bf1d360e11b815260040160405180910390fd5b60006006548260e0015184610c349190611be9565b610c3e9190611c00565b6000858152600260209081526040808320338452909152812080549293508592909190610c6c908490611bb7565b925050819055508260018581548110610c8757610c87611b8b565b90600052602060002090600602016005016000828254610ca79190611bb7565b925050819055508060018581548110610cc257610cc2611b8b565b90600052602060002090600602016003016000828254610ce29190611c22565b909155505060a0820151610d01906001600160a01b0316333084611597565b6080820151610d1a906001600160a01b0316338561144b565b60408051858152602081018590529081018290523360608201527f4f9adb34db7385b64ed42229c939cc08c8c0bbc4154230e96a0b842e5c0fe783906080016109ca565b600060018581548110610d7357610d73611b8b565b60009182526020918290206040805161012081018252600690930290910180546001600160a01b03808216855261ffff600160a01b8304169585019590955263ffffffff600160b01b82048116938501849052600160d01b909104166060840152600181015484166080840152600281015490931660a0830152600383015460c0830152600483015460e08301526005909201546101008201529150421015610e2f576040516309ca244760e31b815260040160405180910390fd5b806060015163ffffffff16421115610e5a5760405163672bf1d360e11b815260040160405180910390fd5b60055461ffff16821015610e8157604051630bc296ad60e21b815260040160405180910390fd5b600080610e8e8787610568565b9092509050600081610ea08489611bb7565b610eaa9190611bb7565b905060006006548560e0015183610ec19190611be9565b610ecb9190611c00565b905082610ed8838a611bb7565b610ee29190611bb7565b93508460c00151811115610f7b575060c084015160e0850151600654610f089083611be9565b610f129190611c00565b6005546020870151919350610f2d9161ffff90911690611c35565b610f3990612710611c57565b61ffff16610f4961271084611be9565b610f539190611c00565b9750610f5f8989610568565b9350839050610f6e838a611bb7565b610f789190611bb7565b93505b80871115610f9c576040516392ea111960e01b815260040160405180910390fd5b60808501516001600160a01b031660009081526004602052604081208054869290610fc8908490611c22565b909155505084516001600160a01b03908116600090815260036020908152604080832060808a01519094168352929052908120805485929061100b908490611c22565b925050819055508160018a8154811061102657611026611b8b565b906000526020600020906006020160050160008282546110469190611c22565b925050819055508060018a8154811061106157611061611b8b565b906000526020600020906006020160030160008282546110819190611bb7565b90915550506000898152600260209081526040808320338452909152812080548492906110af908490611c22565b909155505060808501516110ce906001600160a01b031633308b611597565b60a08501516110e7906001600160a01b0316338361144b565b604080518a8152602081018490529081018290523360608201527fb57e19c4d9c6a4152d6e5e1c03616b47e09af534e8c94cd83ce713f3f198f01b9060800160405180910390a1505050505050505050565b61138761ffff821611156111605760405163cd4e616760e01b815260040160405180910390fd5b8263ffffffff1642118061117f57508163ffffffff168363ffffffff16115b1561119d57604051637616640160e01b815260040160405180910390fd5b6001604051806101200160405280336001600160a01b031681526020018361ffff1681526020018563ffffffff1681526020018463ffffffff168152602001896001600160a01b03168152602001886001600160a01b031681526020018781526020018681526020016000815250908060018154018082558091505060019003906000526020600020906006020160009091909190915060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548161ffff021916908361ffff16021790555060408201518160000160166101000a81548163ffffffff021916908363ffffffff160217905550606082015181600001601a6101000a81548163ffffffff021916908363ffffffff16021790555060808201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a08201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060c0820151816003015560e082015181600401556101008201518160050155505061136d333087896001600160a01b0316611597909392919063ffffffff16565b600180547f1862f918d5600ec0980589e8cc806b3c79b1e762fcbf44cc2947ba12499207eb9161139c91611bb7565b60405190815260200160405180910390a150505050505050565b6113be6114e0565b6001600160a01b03811661143f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6114488161153a565b50565b6040516001600160a01b0383166024820152604481018290526114db90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526115d5565b505050565b6000546001600160a01b031633146106f35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611436565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526115cf9085906323b872dd60e01b90608401611477565b50505050565b600061162a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116bd9092919063ffffffff16565b905080516000148061164b57508080602001905181019061164b9190611c72565b6114db5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611436565b60606116cc84846000856116d4565b949350505050565b60608247101561174c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611436565b600080866001600160a01b031685876040516117689190611cb8565b60006040518083038185875af1925050503d80600081146117a5576040519150601f19603f3d011682016040523d82523d6000602084013e6117aa565b606091505b50915091506117bb878383876117c6565b979650505050505050565b6060831561183557825160000361182e576001600160a01b0385163b61182e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611436565b50816116cc565b6116cc838381511561184a5781518083602001fd5b8060405162461bcd60e51b81526004016114369190611cd4565b60006020828403121561187657600080fd5b5035919050565b80356001600160a01b038116811461189457600080fd5b919050565b600080604083850312156118ac57600080fd5b823591506118bc6020840161187d565b90509250929050565b60008083601f8401126118d757600080fd5b50813567ffffffffffffffff8111156118ef57600080fd5b6020830191508360208260051b85010111156105ea57600080fd5b6000806000806040858703121561192057600080fd5b843567ffffffffffffffff8082111561193857600080fd5b611944888389016118c5565b9096509450602087013591508082111561195d57600080fd5b5061196a878288016118c5565b95989497509550505050565b6000806040838503121561198957600080fd5b50508035926020909101359150565b803561ffff8116811461189457600080fd5b600080604083850312156119bd57600080fd5b6119c68361187d565b91506118bc60208401611998565b6000806000606084860312156119e957600080fd5b505081359360208301359350604090920135919050565b600080600080600060608688031215611a1857600080fd5b853567ffffffffffffffff80821115611a3057600080fd5b611a3c89838a016118c5565b90975095506020880135915080821115611a5557600080fd5b50611a62888289016118c5565b9094509250611a7590506040870161187d565b90509295509295909350565b600060208284031215611a9357600080fd5b611a9c8261187d565b9392505050565b60008060008060808587031215611ab957600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215611ae857600080fd5b611af18361187d565b91506118bc6020840161187d565b803563ffffffff8116811461189457600080fd5b600080600080600080600060e0888a031215611b2e57600080fd5b611b378861187d565b9650611b456020890161187d565b95506040880135945060608801359350611b6160808901611aff565b9250611b6f60a08901611aff565b9150611b7d60c08901611998565b905092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115611bca57611bca611ba1565b92915050565b600060018201611be257611be2611ba1565b5060010190565b8082028115828204841417611bca57611bca611ba1565b600082611c1d57634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115611bca57611bca611ba1565b61ffff818116838216019080821115611c5057611c50611ba1565b5092915050565b61ffff828116828216039080821115611c5057611c50611ba1565b600060208284031215611c8457600080fd5b81518015158114611a9c57600080fd5b60005b83811015611caf578181015183820152602001611c97565b50506000910152565b60008251611cca818460208701611c94565b9190910192915050565b6020815260008251806020840152611cf3816040850160208701611c94565b601f01601f1916919091016040019291505056fea164736f6c6343000811000a

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

0000000000000000000000002fa4ab54543be08001e322e14311d900a5fcc004

-----Decoded View---------------
Arg [0] : _newOwner (address): 0x2fa4Ab54543bE08001e322E14311D900A5fcC004

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000002fa4ab54543be08001e322e14311d900a5fcc004


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

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