ETH Price: $3,591.06 (-2.80%)

Contract

0x44D77f6f6f64E402Aa795e8131bD60AaCE187Dd7
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Verify Header An...153836572022-08-21 11:11:28834 days ago1661080288IN
0x44D77f6f...aCE187Dd7
0 ETH0.00025847.00396143
Enable External ...148840202022-06-01 9:22:40915 days ago1654075360IN
0x44D77f6f...aCE187Dd7
0 ETH0.0008163630
Set Bridge144615962022-03-26 11:36:08982 days ago1648294568IN
0x44D77f6f...aCE187Dd7
0 ETH0.0014135430
Set WETH144615942022-03-26 11:35:56982 days ago1648294556IN
0x44D77f6f...aCE187Dd7
0 ETH0.0014132430

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
205738612024-08-21 1:58:11103 days ago1724205491
0x44D77f6f...aCE187Dd7
0.00000127 ETH
205738612024-08-21 1:58:11103 days ago1724205491
0x44D77f6f...aCE187Dd7
0.00000127 ETH
204448532024-08-03 1:52:11121 days ago1722649931
0x44D77f6f...aCE187Dd7
0.0045328 ETH
204448532024-08-03 1:52:11121 days ago1722649931
0x44D77f6f...aCE187Dd7
0.0045328 ETH
203288202024-07-17 21:04:59137 days ago1721250299
0x44D77f6f...aCE187Dd7
0.00255404 ETH
203288202024-07-17 21:04:59137 days ago1721250299
0x44D77f6f...aCE187Dd7
0.00255404 ETH
203286682024-07-17 20:34:23137 days ago1721248463
0x44D77f6f...aCE187Dd7
0.00091626 ETH
203286682024-07-17 20:34:23137 days ago1721248463
0x44D77f6f...aCE187Dd7
0.00091626 ETH
202865692024-07-11 23:32:35143 days ago1720740755
0x44D77f6f...aCE187Dd7
0.0006457 ETH
202865692024-07-11 23:32:35143 days ago1720740755
0x44D77f6f...aCE187Dd7
0.0006457 ETH
201360002024-06-20 22:44:59164 days ago1718923499
0x44D77f6f...aCE187Dd7
0.00143682 ETH
201360002024-06-20 22:44:59164 days ago1718923499
0x44D77f6f...aCE187Dd7
0.00143682 ETH
199830982024-05-30 13:56:23185 days ago1717077383
0x44D77f6f...aCE187Dd7
0.00448134 ETH
199830982024-05-30 13:56:23185 days ago1717077383
0x44D77f6f...aCE187Dd7
0.00448134 ETH
198572302024-05-12 23:30:23203 days ago1715556623
0x44D77f6f...aCE187Dd7
0.00130932 ETH
198572302024-05-12 23:30:23203 days ago1715556623
0x44D77f6f...aCE187Dd7
0.00130932 ETH
198210142024-05-07 21:57:23208 days ago1715119043
0x44D77f6f...aCE187Dd7
0.05184325 ETH
198210142024-05-07 21:57:23208 days ago1715119043
0x44D77f6f...aCE187Dd7
0.05184325 ETH
197810532024-05-02 7:49:59214 days ago1714636199
0x44D77f6f...aCE187Dd7
0.00672473 ETH
197810532024-05-02 7:49:59214 days ago1714636199
0x44D77f6f...aCE187Dd7
0.00672473 ETH
197648292024-04-30 1:26:11216 days ago1714440371
0x44D77f6f...aCE187Dd7
0.02015112 ETH
197648292024-04-30 1:26:11216 days ago1714440371
0x44D77f6f...aCE187Dd7
0.02015112 ETH
195314322024-03-28 8:30:47249 days ago1711614647
0x44D77f6f...aCE187Dd7
0.17684181 ETH
195314322024-03-28 8:30:47249 days ago1711614647
0x44D77f6f...aCE187Dd7
0.17684181 ETH
190923672024-01-26 17:48:35310 days ago1706291315
0x44D77f6f...aCE187Dd7
0.09020204 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CallProxy

Compiler Version
v0.8.8+commit.dddeac2f

Optimization Enabled:
Yes with 999999 runs

Other Settings:
default evmVersion
File 1 of 13 : CallProxy.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

import "./Utils.sol";
import "../access/Ownable.sol";
import "./interfaces/IBridge.sol";
import "./interfaces/ICallProxy.sol";
import "../swap/interfaces/IPool.sol";
import "../assets/interfaces/IWETH.sol";
import "../assets/interfaces/IPToken.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract CallProxy is ICallProxy, Ownable {
    using SafeMath for uint;
    using SafeERC20 for IERC20;

    bool public externalCallEnabled;
    address public wethAddress;
    address public bridgeAddress;

    uint256 private constant FEE_DENOMINATOR = 10**10;

    event SetWETH(address wethAddress);
    event SetBridge(address bridgeAddress);
    event EnableExternalCall();
    event DisableExternalCall();

    modifier onlyBridge() {
        require(msg.sender == bridgeAddress, "CallProxy: only Bridge can do this");
        _;
    }

    function setWETH(address _wethAddress) public onlyOwner {
        wethAddress = _wethAddress;
        emit SetWETH(_wethAddress);
    }

    function setBridge(address _bridgeAddress) public onlyOwner {
        bridgeAddress = _bridgeAddress;
        emit SetBridge(bridgeAddress);
    }

    function enableExternalCall() public onlyOwner {
        externalCallEnabled = true;
        emit EnableExternalCall();
    }

    function disableExternalCall() public onlyOwner {
        externalCallEnabled = false;
        emit DisableExternalCall();
    }

    function proxyCall(
        address ptoken,
        address receiver,
        uint256 amount,
        bytes memory callData
    ) public override onlyBridge returns(bool) {
        (bytes1 tag, ) = Utils.NextByte(callData, 0);
        if (tag == 0x01) { // swap
            // decode data
            try this.decodeCallDataForSwap(callData)
            returns(address poolAddress,bool unwrapETH,bool swapAll,uint8 tokenIndexFrom, uint8 tokenIndexTo,uint256 dx,uint256 dy,uint256 deadline)
            {
                // check from token address
                if (address(IPool(poolAddress).coins(tokenIndexFrom)) != ptoken) {
                    _transferFromContract(ptoken, receiver, amount);
                    return true;
                }

                // check swap amount
                if (swapAll) {
                    dx = amount;
                }

                // do swap
                dy = _swap(poolAddress, tokenIndexFrom, tokenIndexTo, dx, dy, deadline);

                // check if unwrap ETH is needed
                if (unwrapETH && address(IPool(poolAddress).coins(tokenIndexTo)) == wethAddress && dy != 0) {
                    IWETH(wethAddress).withdraw(dy);
                    payable(receiver).transfer(dy);
                } else if (dy != 0) {
                    IERC20 targetToken = IPool(poolAddress).coins(tokenIndexTo);
                    targetToken.safeTransfer(receiver, dy);
                }
            } catch { /* do nothing if data is invalid*/ }
        } else if (tag == 0x02) {
            try this.decodeCallDataForWithdraw(callData) returns(address ptokenAddress, address toAddress, uint256 withdrawAmount) {
                // check
                if (ptokenAddress != ptoken) {
                    _transferFromContract(ptoken, receiver, amount);
                    return true;
                }

                if (!IPToken(ptoken).checkIfDepositWithdrawEnabled()) {
                    uint256 bridgeFeeRate = IBridge(bridgeAddress).bridgeFeeRate();
                    address feeTo = IBridge(bridgeAddress).bridgeFeeCollector();

                    if (bridgeFeeRate != 0 && feeTo != address(0)) {
                        uint256 bridgeFee = withdrawAmount.mul(bridgeFeeRate).div(FEE_DENOMINATOR);
                        withdrawAmount = withdrawAmount.sub(bridgeFee);
                        _transferFromContract(ptoken, feeTo, bridgeFee);
                    }
                } else {
                    try IPToken(ptoken).withdraw(toAddress, withdrawAmount) {} catch {}
                }
            } catch { /* do nothing if data is invalid*/ }
        } else if (externalCallEnabled && tag == 0x03) { // external call
            try this.decodeCallDataForExternalCall(callData) returns(address callee,bytes memory data) {
                // approve ptoken
                IERC20(ptoken).safeApprove(callee, 0);
                IERC20(ptoken).safeApprove(callee, amount);

                // do external call
                callee.call(data);
            } catch { /* do nothing if data is invalid*/ }
        } else { /* unknown tag, do nothing */ }

        // transfer the remaining ptoken to receiver
        uint256 balance = IERC20(ptoken).balanceOf(address(this));
        if (balance != 0) {
            _transferFromContract(ptoken, receiver, balance);
        }
        return true;
    }

    function _swap(address poolAddress, uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx, uint256 minDy, uint256 deadline) internal returns(uint256 dy) {
        IERC20 tokenFrom = IERC20(IPool(poolAddress).coins(tokenIndexFrom));
        tokenFrom.safeApprove(poolAddress, 0);
        tokenFrom.safeApprove(poolAddress, dx);
        try IPool(poolAddress).swap(tokenIndexFrom, tokenIndexTo, dx, minDy, deadline) returns(uint256 _dy) {
            dy = _dy;
        } catch {
            dy = 0;
        }
    }

    function decodeCallDataForSwap(bytes memory callData) public pure returns (
        address poolAddress,
        bool unwrapETH,
        bool swapAll,
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ){
        bytes memory poolAddressBytes;
        uint8 boolPair;
        uint256 off = 1; // dismiss tag
        (poolAddressBytes, off) = Utils.NextVarBytes(callData, off);
        poolAddress = Utils.bytesToAddress(poolAddressBytes);

        (boolPair, off) = Utils.NextUint8(callData, off);
        (unwrapETH, swapAll) = _uint8ToBoolPair(boolPair);

        (tokenIndexFrom, off) = Utils.NextUint8(callData, off);

        (tokenIndexTo, off) = Utils.NextUint8(callData, off);

        (dx, off) = Utils.NextUint255(callData, off);

        (minDy, off) = Utils.NextUint255(callData, off);

        (deadline, off) = Utils.NextUint255(callData, off);
    }

    function encodeArgsForSwap(
        bytes memory poolAddress,
        bool unwrapETH,
        bool swapAll,
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) public pure returns(bytes memory) {
        bytes memory buff;
        buff = abi.encodePacked(
            Utils.WriteByte(0x01),
            Utils.WriteVarBytes(poolAddress),
            Utils.WriteUint8(_boolPairToUint8(unwrapETH, swapAll)),
            Utils.WriteUint8(tokenIndexFrom),
            Utils.WriteUint8(tokenIndexTo),
            Utils.WriteUint255(dx),
            Utils.WriteUint255(minDy),
            Utils.WriteUint255(deadline)
        );
        return buff;
    }

    function decodeCallDataForWithdraw(bytes memory callData) public pure returns(
        address ptokenAddress,
        address toAddress,
        uint256 amount
    ){
        bytes memory ptokenAddressBytes;
        bytes memory toAddressBytes;
        uint256 off = 1; // dismiss tag
        (ptokenAddressBytes, off) = Utils.NextVarBytes(callData, off);
        ptokenAddress = Utils.bytesToAddress(ptokenAddressBytes);

        (toAddressBytes, off) = Utils.NextVarBytes(callData, off);
        toAddress = Utils.bytesToAddress(toAddressBytes);

        (amount, off) = Utils.NextUint255(callData, off);
    }

    function encodeArgsForWithdraw(
        bytes memory ptokenAddress,
        bytes memory toAddress,
        uint256 amount
    ) public pure returns(bytes memory) {
        bytes memory buff;
        buff = abi.encodePacked(
            Utils.WriteByte(0x02),
            Utils.WriteVarBytes(ptokenAddress),
            Utils.WriteVarBytes(toAddress),
            Utils.WriteUint255(amount)
        );
        return buff;
    }

    function decodeCallDataForExternalCall(bytes memory callData) public pure returns(
        address callee,
        bytes memory data
    ){
        bytes memory calleeAddressBytes;
        uint256 off = 1; // dismiss tag
        (calleeAddressBytes, off) = Utils.NextVarBytes(callData, off);
        callee = Utils.bytesToAddress(calleeAddressBytes);

        (data, off) = Utils.NextVarBytes(callData, off);
    }

    function encodeArgsForExternalCall(
        bytes memory callee,
        bytes memory data
    ) public pure returns(bytes memory) {
        bytes memory buff;
        buff = abi.encodePacked(
            Utils.WriteByte(0x03),
            Utils.WriteVarBytes(callee),
            Utils.WriteVarBytes(data)
        );
        return buff;
    }

    function _transferFromContract(address token, address receiver, uint256 amount) internal {
        IERC20(token).safeTransfer(receiver, amount);
    }

    function _boolPairToUint8(bool flag1, bool flag2) internal pure returns(uint8 res) {
        assembly{
            res := add(flag1, mul(flag2, 2))
        }
    }

    function _uint8ToBoolPair(uint8 raw) internal pure returns(bool flag1, bool flag2) {
        assembly{
            flag1 := mod(raw, 2)
            flag2 := div(raw, 2)
        }
    }

    receive() external payable {}
}

File 2 of 13 : IPool.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

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

interface IPool {
    function coins(uint256 index) external view returns(IERC20);
    function getA() external view returns (uint256);
    function getTokenIndex(address token) external view returns (uint8);

    function getVirtualPrice() external view returns (uint256);

    function calculateSwap(uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx) external view returns (uint256 dy);
    function calculateRemoveLiquidity(uint256 amount) external view returns (uint256[] memory);
    function calculateTokenAmount(uint256[] calldata amounts, bool deposit) external view returns (uint256);
    function calculateWithdrawOneToken(uint256 tokenAmount, uint8 tokenIndex) external view returns (uint256 amount);

    function swap(uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx, uint256 minDy, uint256 deadline) external returns (uint256);
    function addLiquidity(uint256[] memory amounts, uint256 minToMint, uint256 deadline) external returns (uint256);
    function removeLiquidity(uint256 amount, uint256[] calldata minAmounts, uint256 deadline) external returns (uint256[] memory);
    function removeLiquidityOneToken(uint256 tokenAmount, uint8 tokenIndex, uint256 minAmount, uint256 deadline) external returns (uint256);
    function removeLiquidityImbalance(uint256[] calldata amounts, uint256 maxBurnAmount, uint256 deadline) external returns (uint256);

    function applySwapFee(uint256 newSwapFee) external;
    function applyAdminFee(uint256 newAdminFee) external;
    function getAdminBalance(uint256 index) external view returns (uint256);
    function withdrawAdminFee(address receiver) external;
    function rampA(uint256 _futureA, uint256 _futureTime) external;
    function stopRampA() external;
}

File 3 of 13 : ICallProxy.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

interface ICallProxy {
    function proxyCall(
        address ptoken,
        address receiver,
        uint256 amount,
        bytes memory callData
    ) external returns(bool);

    function encodeArgsForWithdraw(
        bytes memory ptokenAddress,
        bytes memory toAddress,
        uint256 amount
    ) external pure returns(bytes memory);
}

File 4 of 13 : IBridge.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

interface IBridge {
    function bridgeFeeRate() external view returns (uint256);
    function bridgeFeeCollector() external view returns (address);

    function bridgeOut(
        address fromAssetHash,
        uint64 toChainId,
        bytes memory toAddress,
        uint256 amount,
        bytes memory callData
    ) external returns(bool);

    function depositAndBridgeOut(
        address originalTokenAddress,
        address pTokenAddress,
        uint64 toChainId,
        bytes memory toAddress,
        uint256 amount,
        bytes memory callData
    ) external returns(bool);

    function bridgeOutAndWithdraw(
        address pTokenAddress,
        uint64 toChainId,
        bytes memory toAddress,
        uint256 amount
    ) external returns(bool);
}

File 5 of 13 : Utils.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

library Utils {

    function WriteByte(bytes1 b) internal pure returns (bytes memory) {
        return WriteUint8(uint8(b));
    }

    function WriteUint8(uint8 v) internal pure returns (bytes memory) {
        bytes memory buff;
        assembly{
            buff := mload(0x40)
            mstore(buff, 1)
            mstore(add(buff, 0x20), shl(248, v))
            // mstore(add(buff, 0x20), byte(0x1f, v))
            mstore(0x40, add(buff, 0x21))
        }
        return buff;
    }

    function WriteUint16(uint16 v) internal pure returns (bytes memory) {
        bytes memory buff;

        assembly{
            buff := mload(0x40)
            let byteLen := 0x02
            mstore(buff, byteLen)
            for {
                let mindex := 0x00
                let vindex := 0x1f
            } lt(mindex, byteLen) {
                mindex := add(mindex, 0x01)
                vindex := sub(vindex, 0x01)
            }{
                mstore8(add(add(buff, 0x20), mindex), byte(vindex, v))
            }
            mstore(0x40, add(buff, 0x22))
        }
        return buff;
    }

    function WriteUint32(uint32 v) internal pure returns(bytes memory) {
        bytes memory buff;
        assembly{
            buff := mload(0x40)
            let byteLen := 0x04
            mstore(buff, byteLen)
            for {
                let mindex := 0x00
                let vindex := 0x1f
            } lt(mindex, byteLen) {
                mindex := add(mindex, 0x01)
                vindex := sub(vindex, 0x01)
            }{
                mstore8(add(add(buff, 0x20), mindex), byte(vindex, v))
            }
            mstore(0x40, add(buff, 0x24))
        }
        return buff;
    }

    function WriteUint64(uint64 v) internal pure returns(bytes memory) {
        bytes memory buff;

        assembly{
            buff := mload(0x40)
            let byteLen := 0x08
            mstore(buff, byteLen)
            for {
                let mindex := 0x00
                let vindex := 0x1f
            } lt(mindex, byteLen) {
                mindex := add(mindex, 0x01)
                vindex := sub(vindex, 0x01)
            }{
                mstore8(add(add(buff, 0x20), mindex), byte(vindex, v))
            }
            mstore(0x40, add(buff, 0x28))
        }
        return buff;
    }

    function WriteUint255(uint256 v) internal pure returns (bytes memory) {
        require(v <= 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "Value exceeds uint255 range");
        bytes memory buff;

        assembly{
            buff := mload(0x40)
            let byteLen := 0x20
            mstore(buff, byteLen)
            for {
                let mindex := 0x00
                let vindex := 0x1f
            } lt(mindex, byteLen) {
                mindex := add(mindex, 0x01)
                vindex := sub(vindex, 0x01)
            }{
                mstore8(add(add(buff, 0x20), mindex), byte(vindex, v))
            }
            mstore(0x40, add(buff, 0x40))
        }
        return buff;
    }

    function WriteVarBytes(bytes memory data) internal pure returns (bytes memory) {
        uint64 l = uint64(data.length);
        return abi.encodePacked(WriteVarUint(l), data);
    }

    function WriteVarUint(uint64 v) internal pure returns (bytes memory) {
        if (v < 0xFD){
    		return WriteUint8(uint8(v));
    	} else if (v <= 0xFFFF) {
    		return abi.encodePacked(WriteByte(0xFD), WriteUint16(uint16(v)));
    	} else if (v <= 0xFFFFFFFF) {
            return abi.encodePacked(WriteByte(0xFE), WriteUint32(uint32(v)));
    	} else {
    		return abi.encodePacked(WriteByte(0xFF), WriteUint64(uint64(v)));
    	}
    }

    function NextByte(bytes memory buff, uint256 offset) internal pure returns (bytes1, uint256) {
        require(offset + 1 <= buff.length && offset < offset + 1, "NextByte, Offset exceeds maximum");
        bytes1 v;
        assembly{
            v := mload(add(add(buff, 0x20), offset))
        }
        return (v, offset + 1);
    }

    function NextUint8(bytes memory buff, uint256 offset) internal pure returns (uint8, uint256) {
        require(offset + 1 <= buff.length && offset < offset + 1, "NextUint8, Offset exceeds maximum");
        uint8 v;
        assembly{
            let tmpbytes := mload(0x40)
            let bvalue := mload(add(add(buff, 0x20), offset))
            mstore8(tmpbytes, byte(0, bvalue))
            mstore(0x40, add(tmpbytes, 0x01))
            v := mload(sub(tmpbytes, 0x1f))
        }
        return (v, offset + 1);
    }

    function NextUint16(bytes memory buff, uint256 offset) internal pure returns (uint16, uint256) {
        require(offset + 2 <= buff.length && offset < offset + 2, "NextUint16, offset exceeds maximum");

        uint16 v;
        assembly {
            let tmpbytes := mload(0x40)
            let bvalue := mload(add(add(buff, 0x20), offset))
            mstore8(tmpbytes, byte(0x01, bvalue))
            mstore8(add(tmpbytes, 0x01), byte(0, bvalue))
            mstore(0x40, add(tmpbytes, 0x02))
            v := mload(sub(tmpbytes, 0x1e))
        }
        return (v, offset + 2);
    }

    function NextUint32(bytes memory buff, uint256 offset) internal pure returns (uint32, uint256) {
        require(offset + 4 <= buff.length && offset < offset + 4, "NextUint32, offset exceeds maximum");
        uint32 v;
        assembly {
            let tmpbytes := mload(0x40)
            let byteLen := 0x04
            for {
                let tindex := 0x00
                let bindex := sub(byteLen, 0x01)
                let bvalue := mload(add(add(buff, 0x20), offset))
            } lt(tindex, byteLen) {
                tindex := add(tindex, 0x01)
                bindex := sub(bindex, 0x01)
            }{
                mstore8(add(tmpbytes, tindex), byte(bindex, bvalue))
            }
            mstore(0x40, add(tmpbytes, byteLen))
            v := mload(sub(tmpbytes, sub(0x20, byteLen)))
        }
        return (v, offset + 4);
    }

    function NextUint64(bytes memory buff, uint256 offset) internal pure returns (uint64, uint256) {
        require(offset + 8 <= buff.length && offset < offset + 8, "NextUint64, offset exceeds maximum");
        uint64 v;
        assembly {
            let tmpbytes := mload(0x40)
            let byteLen := 0x08
            for {
                let tindex := 0x00
                let bindex := sub(byteLen, 0x01)
                let bvalue := mload(add(add(buff, 0x20), offset))
            } lt(tindex, byteLen) {
                tindex := add(tindex, 0x01)
                bindex := sub(bindex, 0x01)
            }{
                mstore8(add(tmpbytes, tindex), byte(bindex, bvalue))
            }
            mstore(0x40, add(tmpbytes, byteLen))
            v := mload(sub(tmpbytes, sub(0x20, byteLen)))
        }
        return (v, offset + 8);
    }

    function NextUint255(bytes memory buff, uint256 offset) internal pure returns (uint256, uint256) {
        require(offset + 32 <= buff.length && offset < offset + 32, "NextUint255, offset exceeds maximum");
        uint256 v;
        assembly {
            let tmpbytes := mload(0x40)
            let byteLen := 0x20
            for {
                let tindex := 0x00
                let bindex := sub(byteLen, 0x01)
                let bvalue := mload(add(add(buff, 0x20), offset))
            } lt(tindex, byteLen) {
                tindex := add(tindex, 0x01)
                bindex := sub(bindex, 0x01)
            }{
                mstore8(add(tmpbytes, tindex), byte(bindex, bvalue))
            }
            mstore(0x40, add(tmpbytes, byteLen))
            v := mload(tmpbytes)
        }
        require(v <= 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, "Value exceeds the range");
        return (v, offset + 32);
    }

    function NextVarBytes(bytes memory buff, uint256 offset) internal pure returns(bytes memory, uint256) {
        uint len;
        (len, offset) = NextVarUint(buff, offset);
        require(offset + len <= buff.length && offset <= offset + len, "NextVarBytes, offset exceeds maximum");
        bytes memory tempBytes;
        assembly{
            switch iszero(len)
            case 0 {
                // Get a location of some free memory and store it in tempBytes as
                // Solidity does for memory variables.
                tempBytes := mload(0x40)

                // The first word of the slice result is potentially a partial
                // word read from the original array. To read it, we calculate
                // the length of that partial word and start copying that many
                // bytes into the array. The first word we copy will start with
                // data we don't care about, but the last `lengthmod` bytes will
                // land at the beginning of the contents of the new array. When
                // we're done copying, we overwrite the full first word with
                // the actual length of the slice.
                let lengthmod := and(len, 31)

                // The multiplication in the next line is necessary
                // because when slicing multiples of 32 bytes (lengthmod == 0)
                // the following copy loop was copying the origin's length
                // and then ending prematurely not copying everything it should.
                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                let end := add(mc, len)

                for {
                    // The multiplication in the next line has the same exact purpose
                    // as the one above.
                    let cc := add(add(add(buff, lengthmod), mul(0x20, iszero(lengthmod))), offset)
                } lt(mc, end) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    mstore(mc, mload(cc))
                }

                mstore(tempBytes, len)

                //update free-memory pointer
                //allocating the array padded to 32 bytes like the compiler does now
                mstore(0x40, and(add(mc, 31), not(31)))
            }
            //if we want a zero-length slice let's just return a zero-length array
            default {
                tempBytes := mload(0x40)

                mstore(0x40, add(tempBytes, 0x20))
            }
        }

        return (tempBytes, offset + len);
    }

    function NextVarUint(bytes memory buff, uint256 offset) internal pure returns(uint, uint256) {
        bytes1 v;
        (v, offset) = NextByte(buff, offset);

        uint value;
        if (v == 0xFD) {
            // return NextUint16(buff, offset);
            (value, offset) = NextUint16(buff, offset);
            require(value >= 0xFD && value <= 0xFFFF, "NextUint16, value outside range");
            return (value, offset);
        } else if (v == 0xFE) {
            // return NextUint32(buff, offset);
            (value, offset) = NextUint32(buff, offset);
            require(value > 0xFFFF && value <= 0xFFFFFFFF, "NextVarUint, value outside range");
            return (value, offset);
        } else if (v == 0xFF) {
            // return NextUint64(buff, offset);
            (value, offset) = NextUint64(buff, offset);
            require(value > 0xFFFFFFFF, "NextVarUint, value outside range");
            return (value, offset);
        } else{
            // return (uint8(v), offset);
            value = uint8(v);
            require(value < 0xFD, "NextVarUint, value outside range");
            return (value, offset);
        }
    }

    function bytesToAddress(bytes memory _bs) internal pure returns (address addr) {
        require(_bs.length == 20, "bytes length does not match address");
        assembly {
            // for _bs, first word store _bs.length, second word store _bs.value
            // load 32 bytes from mem[_bs+20], convert it into Uint160, meaning we take last 20 bytes as addr (address).
            addr := mload(add(_bs, 0x14))
        }
    }

    function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {
        bool success = true;

        assembly {
            // we know _preBytes_offset is 0
            let fslot := sload(_preBytes.slot)
            // Arrays of 31 bytes or less have an even value in their slot,
            // while longer arrays have an odd value. The actual length is
            // the slot divided by two for odd values, and the lowest order
            // byte divided by two for even values.
            // If the slot is even, bitwise and the slot with 255 and divide by
            // two to get the length. If the slot is odd, bitwise and the slot
            // with -1 and divide by two.
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)

            // if lengths don't match the arrays are not equal
            switch eq(slength, mlength)
            case 1 {
                // fslot can contain both the length and contents of the array
                // if slength < 32 bytes so let's prepare for that
                // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                // slength != 0
                if iszero(iszero(slength)) {
                    switch lt(slength, 32)
                    case 1 {
                        // blank the last byte which is the length
                        fslot := mul(div(fslot, 0x100), 0x100)

                        if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
                            // unsuccess:
                            success := 0
                        }
                    }
                    default {
                        // cb is a circuit breaker in the for loop since there's
                        //  no said feature for inline assembly loops
                        // cb = 1 - don't breaker
                        // cb = 0 - break
                        let cb := 1

                        // get the keccak hash to get the contents of the array
                        mstore(0x0, _preBytes.slot)
                        let sc := keccak256(0x0, 0x20)

                        let mc := add(_postBytes, 0x20)
                        let end := add(mc, mlength)

                        // the next line is the loop condition:
                        // while(uint(mc < end) + cb == 2)
                        for {} eq(add(lt(mc, end), cb), 2) {
                            sc := add(sc, 1)
                            mc := add(mc, 0x20)
                        } {
                            if iszero(eq(sload(sc), mload(mc))) {
                                // unsuccess:
                                success := 0
                                cb := 0
                            }
                        }
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }
}

File 6 of 13 : IWETH.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

interface IWETH {
    function deposit() external payable;
    function withdraw(uint wad) external;

    function transfer(address dst, uint wad) external returns (bool);
}

File 7 of 13 : IPToken.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

interface IPToken {
    function mint(address to, uint256 amount) external;
    function burn(uint256 amount) external;

    function deposit(address to, uint256 amount) external;
    function withdraw(address to, uint256 amount) external;

    function tokenUnderlying() external view returns(address);

    function checkAuthorizedCaller(address caller) external view returns (bool);
    function checkIfDepositWithdrawEnabled() external view returns (bool);
}

File 8 of 13 : Ownable.sol
// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/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 Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @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 9 of 13 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 10 of 13 : 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;
    }
}

File 11 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 12 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

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

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

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

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

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

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

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

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

File 13 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

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

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 999999
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[],"name":"DisableExternalCall","type":"event"},{"anonymous":false,"inputs":[],"name":"EnableExternalCall","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":"bridgeAddress","type":"address"}],"name":"SetBridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"wethAddress","type":"address"}],"name":"SetWETH","type":"event"},{"inputs":[],"name":"bridgeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"decodeCallDataForExternalCall","outputs":[{"internalType":"address","name":"callee","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"decodeCallDataForSwap","outputs":[{"internalType":"address","name":"poolAddress","type":"address"},{"internalType":"bool","name":"unwrapETH","type":"bool"},{"internalType":"bool","name":"swapAll","type":"bool"},{"internalType":"uint8","name":"tokenIndexFrom","type":"uint8"},{"internalType":"uint8","name":"tokenIndexTo","type":"uint8"},{"internalType":"uint256","name":"dx","type":"uint256"},{"internalType":"uint256","name":"minDy","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"decodeCallDataForWithdraw","outputs":[{"internalType":"address","name":"ptokenAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"disableExternalCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableExternalCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"callee","type":"bytes"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"encodeArgsForExternalCall","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"poolAddress","type":"bytes"},{"internalType":"bool","name":"unwrapETH","type":"bool"},{"internalType":"bool","name":"swapAll","type":"bool"},{"internalType":"uint8","name":"tokenIndexFrom","type":"uint8"},{"internalType":"uint8","name":"tokenIndexTo","type":"uint8"},{"internalType":"uint256","name":"dx","type":"uint256"},{"internalType":"uint256","name":"minDy","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"encodeArgsForSwap","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"ptokenAddress","type":"bytes"},{"internalType":"bytes","name":"toAddress","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"encodeArgsForWithdraw","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"externalCallEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ptoken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"proxyCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bridgeAddress","type":"address"}],"name":"setBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wethAddress","type":"address"}],"name":"setWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wethAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b506200001d3362000023565b62000073565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6136a380620000836000396000f3fe6080604052600436106100f75760003560e01c8063abb2fef31161008a578063e545398411610059578063e5453984146102ff578063e5d1977a1461031f578063f0403b861461039b578063f2fde38b146103ee57600080fd5b8063abb2fef31461024f578063cec5369f14610291578063dea39a53146102b1578063e30750ca146102df57600080fd5b8063799c2406116100c6578063799c2406146101c25780638da5cb5b146101d75780638dd1480214610202578063a3c573eb1461022257600080fd5b8063159edafd146101035780634f0e0ef3146101395780635b769f3c1461018b57806378ee6788146101ad57600080fd5b366100fe57005b600080fd5b34801561010f57600080fd5b5061012361011e366004612f2d565b61040e565b604051610130919061300b565b60405180910390f35b34801561014557600080fd5b506001546101669073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610130565b34801561019757600080fd5b506101ab6101a6366004613040565b610494565b005b3480156101b957600080fd5b506101ab610594565b3480156101ce57600080fd5b506101ab61067d565b3480156101e357600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610166565b34801561020e57600080fd5b506101ab61021d366004613040565b61074f565b34801561022e57600080fd5b506002546101669073ffffffffffffffffffffffffffffffffffffffff1681565b34801561025b57600080fd5b506000546102819074010000000000000000000000000000000000000000900460ff1681565b6040519015158152602001610130565b34801561029d57600080fd5b506101236102ac36600461305d565b610843565b3480156102bd57600080fd5b506102d16102cc3660046130ca565b6108d6565b6040516101309291906130ff565b3480156102eb57600080fd5b506101236102fa36600461314b565b61090c565b34801561030b57600080fd5b5061028161031a3660046131ee565b6109f1565b34801561032b57600080fd5b5061033f61033a3660046130ca565b6115ac565b6040805173ffffffffffffffffffffffffffffffffffffffff909916895296151560208901529415159587019590955260ff92831660608701529116608085015260a084015260c083019190915260e082015261010001610130565b3480156103a757600080fd5b506103bb6103b63660046130ca565b61164b565b6040805173ffffffffffffffffffffffffffffffffffffffff948516815293909216602084015290820152606001610130565b3480156103fa57600080fd5b506101ab610409366004613040565b61169e565b60608061043a7f03000000000000000000000000000000000000000000000000000000000000006117ce565b6104438561180f565b61044c8561180f565b60405160200161045e9392919061325a565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018152919052949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461051a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fe390bcec6614d6b1f8ae47a4d9d46531ce328e3d293ecd6ddd015cb01eff0300906020015b60405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff163314610615576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001781556040517f241ca0ba639ce0eaf3519529de69af9268c68ea84edd7ab0a6e0a1dd67d31a759190a1565b60005473ffffffffffffffffffffffffffffffffffffffff1633146106fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1681556040517ff25b97c23fde44d33ae2a10c1b1a799ee3e25dd8e8183d9ad96a580b5b039cf79190a1565b60005473ffffffffffffffffffffffffffffffffffffffff1633146107d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fe605ac02ea219003ec58fc9cf4d4b3c5f2d62ec39807b1c63886ddd47a6fcd6e90602001610589565b60608061086f7f02000000000000000000000000000000000000000000000000000000000000006117ce565b6108788661180f565b6108818661180f565b61088a86611846565b60405160200161089d949392919061329d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190529150505b9392505050565b600060608060016108e7858261192f565b90925090506108f582611a8f565b9350610901858261192f565b509395939450505050565b6060806109387f01000000000000000000000000000000000000000000000000000000000000006117ce565b6109418b61180f565b60408051600180825260028d028e0160f890811b6020840152602183018281528d821b604185015260428401928352908c901b60628401526063830190935290919061098c8a611846565b6109958a611846565b61099e8a611846565b6040516020016109b59897969594939291906132f4565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00181529190529a9950505050505050505050565b60025460009073ffffffffffffffffffffffffffffffffffffffff163314610a9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f43616c6c50726f78793a206f6e6c79204272696467652063616e20646f20746860448201527f69730000000000000000000000000000000000000000000000000000000000006064820152608401610511565b6000610aa8836000611b2a565b5090507f01000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161415610f1e576040517fe5d1977a000000000000000000000000000000000000000000000000000000008152309063e5d1977a90610b3190869060040161300b565b6101006040518083038186803b158015610b4a57600080fd5b505afa925050508015610b98575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252610b9591810190613399565b60015b610ba1576114ea565b8d73ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1663c6610657876040518263ffffffff1660e01b8152600401610bfa919060ff91909116815260200190565b60206040518083038186803b158015610c1257600080fd5b505afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a9190613429565b73ffffffffffffffffffffffffffffffffffffffff1614610c8257610c708e8e8e611bd8565b600199505050505050505050506115a4565b8515610c8c578b92505b610c9a888686868686611bfe565b9150868015610d6357506001546040517fc661065700000000000000000000000000000000000000000000000000000000815260ff8616600482015273ffffffffffffffffffffffffffffffffffffffff918216918a169063c66106579060240160206040518083038186803b158015610d1357600080fd5b505afa158015610d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4b9190613429565b73ffffffffffffffffffffffffffffffffffffffff16145b8015610d6e57508115155b15610e43576001546040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff90911690632e1a7d4d90602401600060405180830381600087803b158015610ddf57600080fd5b505af1158015610df3573d6000803e3d6000fd5b505050508c73ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610e3d573d6000803e3d6000fd5b50610f11565b8115610f11576040517fc661065700000000000000000000000000000000000000000000000000000000815260ff8516600482015260009073ffffffffffffffffffffffffffffffffffffffff8a169063c66106579060240160206040518083038186803b158015610eb457600080fd5b505afa158015610ec8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eec9190613429565b9050610f0f73ffffffffffffffffffffffffffffffffffffffff82168f85611dd8565b505b50505050505050506114ea565b7f02000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008216141561131a576040517ff0403b86000000000000000000000000000000000000000000000000000000008152309063f0403b8690610fa490869060040161300b565b60606040518083038186803b158015610fbc57600080fd5b505afa92505050801561100a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261100791810190613446565b60015b611013576114ea565b8873ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461105e57611051898989611bd8565b60019450505050506115a4565b8873ffffffffffffffffffffffffffffffffffffffff16637ddd28d66040518163ffffffff1660e01b815260040160206040518083038186803b1580156110a457600080fd5b505afa1580156110b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110dc9190613489565b61128f57600254604080517f986d338b000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163986d338b916004808301926020929190829003018186803b15801561114b57600080fd5b505afa15801561115f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118391906134a6565b90506000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cf94e0056040518163ffffffff1660e01b815260040160206040518083038186803b1580156111ef57600080fd5b505afa158015611203573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112279190613429565b9050811580159061124d575073ffffffffffffffffffffffffffffffffffffffff811615155b1561128857600061126d6402540be4006112678686611eac565b90611eb8565b90506112798482611ec4565b93506112868c8383611bd8565b505b5050611312565b6040517ff3fef3a300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152602482018390528a169063f3fef3a390604401600060405180830381600087803b1580156112ff57600080fd5b505af1925050508015611310575060015b505b5050506114ea565b60005474010000000000000000000000000000000000000000900460ff16801561138557507f03000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008216145b156114ea576040517fdea39a53000000000000000000000000000000000000000000000000000000008152309063dea39a53906113c690869060040161300b565b60006040518083038186803b1580156113de57600080fd5b505afa92505050801561143157506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261142e91908101906134bf565b60015b61143a576114ea565b61145c73ffffffffffffffffffffffffffffffffffffffff8916836000611ed0565b61147d73ffffffffffffffffffffffffffffffffffffffff89168388611ed0565b8173ffffffffffffffffffffffffffffffffffffffff16816040516114a2919061354c565b6000604051808303816000865af19150503d80600081146114df576040519150601f19603f3d011682016040523d82523d6000602084013e6114e4565b606091505b50505050505b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8816906370a082319060240160206040518083038186803b15801561155257600080fd5b505afa158015611566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158a91906134a6565b9050801561159d5761159d878783611bd8565b6001925050505b949350505050565b60008080808080808060608160016115c48c8261192f565b90935090506115d283611a8f565b9a506115de8c82612061565b600182169b50600282049a5090925090506115f98c82612061565b90985090506116088c82612061565b90975090506116178c82612146565b90965090506116268c82612146565b90955090506116358c82612146565b8092508195505050505050919395975091939597565b60008080606080600161165e878261192f565b909350905061166c83611a8f565b9550611678878261192f565b909250905061168682611a8f565b94506116928782612146565b50959794965050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461171f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b73ffffffffffffffffffffffffffffffffffffffff81166117c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610511565b6117cb816122d1565b50565b60408051600181527fff0000000000000000000000000000000000000000000000000000000000000083166020820152602181019091526060905b92915050565b805160609061181d81612346565b8360405160200161182f929190613568565b604051602081830303815290604052915050919050565b60607f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211156118d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f56616c756520657863656564732075696e743235352072616e676500000000006044820152606401610511565b60405160208082526000601f5b8282101561191f5785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016118df565b5050506040818101905292915050565b606060008061193e858561245e565b865190955090915061195082866135c6565b11158015611967575061196381856135c6565b8411155b6119f2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4e65787456617242797465732c206f66667365742065786365656473206d617860448201527f696d756d000000000000000000000000000000000000000000000000000000006064820152608401610511565b606081158015611a0d57604051915060208201604052611a75565b6040519150601f8316801560200281840101848101888315602002848c0101015b81831015611a46578051835260209283019201611a2e565b5050848452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b5080611a8183876135c6565b9350935050505b9250929050565b60008151601414611b22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f6279746573206c656e67746820646f6573206e6f74206d61746368206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610511565b506014015190565b6000808351836001611b3c91906135c6565b11158015611b535750611b508360016135c6565b83105b611bb9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e657874427974652c204f66667365742065786365656473206d6178696d756d6044820152606401610511565b8383016020015180611bcc8560016135c6565b92509250509250929050565b611bf973ffffffffffffffffffffffffffffffffffffffff84168383611dd8565b505050565b6040517fc661065700000000000000000000000000000000000000000000000000000000815260ff86166004820152600090819073ffffffffffffffffffffffffffffffffffffffff89169063c66106579060240160206040518083038186803b158015611c6b57600080fd5b505afa158015611c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca39190613429565b9050611cc773ffffffffffffffffffffffffffffffffffffffff8216896000611ed0565b611ce873ffffffffffffffffffffffffffffffffffffffff82168987611ed0565b6040517f9169558600000000000000000000000000000000000000000000000000000000815260ff80891660048301528716602482015260448101869052606481018590526084810184905273ffffffffffffffffffffffffffffffffffffffff89169063916955869060a401602060405180830381600087803b158015611d6f57600080fd5b505af1925050508015611dbd575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611dba918101906134a6565b60015b611dca5760009150611dcd565b91505b509695505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611bf99084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261274c565b60006108cf82846135de565b60006108cf828461361b565b60006108cf8284613656565b801580611f7f57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f4557600080fd5b505afa158015611f59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7d91906134a6565b155b61200b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610511565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611bf99084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611e2a565b600080835183600161207391906135c6565b1115801561208a57506120878360016135c6565b83105b612116576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4e65787455696e74382c204f66667365742065786365656473206d6178696d7560448201527f6d000000000000000000000000000000000000000000000000000000000000006064820152608401610511565b6000604051846020870101518060001a82535060018101604052601f81035191505080846001611bcc91906135c6565b600080835183602061215891906135c6565b1115801561216f575061216c8360206135c6565b83105b6121fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4e65787455696e743235352c206f66667365742065786365656473206d61786960448201527f6d756d00000000000000000000000000000000000000000000000000000000006064820152608401610511565b600060405160206000600182038760208a0101515b838310156122305780821a83860153600183019250600182039150612210565b50505081016040525190507f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156122c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f56616c75652065786365656473207468652072616e67650000000000000000006044820152606401610511565b80611bcc8560206135c6565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060fd8267ffffffffffffffff16101561237957604080516001815260f884901b602082015260218101909152611809565b61ffff8267ffffffffffffffff16116123e5576123b57ffd000000000000000000000000000000000000000000000000000000000000006117ce565b6123be83612858565b6040516020016123cf929190613568565b6040516020818303038152906040529050919050565b63ffffffff8267ffffffffffffffff161161242c576124237ffe000000000000000000000000000000000000000000000000000000000000006117ce565b6123be836128b9565b6124557fff000000000000000000000000000000000000000000000000000000000000006117ce565b6123be8361291a565b600080600061246d8585611b2a565b9450905060007ffd000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000083161415612554576124c7868661297b565b955061ffff16905060fd81108015906124e2575061ffff8111155b612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4e65787455696e7431362c2076616c7565206f7574736964652072616e6765006044820152606401610511565b9250839150611a889050565b7ffe000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008316141561262d576125a88686612a69565b955063ffffffff16905061ffff811180156125c7575063ffffffff8111155b612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e65787456617255696e742c2076616c7565206f7574736964652072616e67656044820152606401610511565b7fff0000000000000000000000000000000000000000000000000000000000000080831614156126dc576126618686612b8d565b955067ffffffffffffffff16905063ffffffff8111612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e65787456617255696e742c2076616c7565206f7574736964652072616e67656044820152606401610511565b5060f881901c60fd8110612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e65787456617255696e742c2076616c7565206f7574736964652072616e67656044820152606401610511565b60006127ae826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612cb19092919063ffffffff16565b805190915015611bf957808060200190518101906127cc9190613489565b611bf9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610511565b6040516002808252606091906000601f5b828210156128a95785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01612869565b5050506022810160405292915050565b6040516004808252606091906000601f5b8282101561290a5785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016128ca565b5050506024810160405292915050565b6040516008808252606091906000601f5b8282101561296b5785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0161292b565b5050506028810160405292915050565b600080835183600261298d91906135c6565b111580156129a457506129a18360026135c6565b83105b612a30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4e65787455696e7431362c206f66667365742065786365656473206d6178696d60448201527f756d0000000000000000000000000000000000000000000000000000000000006064820152608401610511565b6000604051846020870101518060011a82538060001a60018301535060028101604052601e81035191505080846002611bcc91906135c6565b6000808351836004612a7b91906135c6565b11158015612a925750612a8f8360046135c6565b83105b612b1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4e65787455696e7433322c206f66667365742065786365656473206d6178696d60448201527f756d0000000000000000000000000000000000000000000000000000000000006064820152608401610511565b600060405160046000600182038760208a0101515b83831015612b535780821a83860153600183019250600182039150612b33565b5050500160408190527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151905080611bcc8560046135c6565b6000808351836008612b9f91906135c6565b11158015612bb65750612bb38360086135c6565b83105b612c42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4e65787455696e7436342c206f66667365742065786365656473206d6178696d60448201527f756d0000000000000000000000000000000000000000000000000000000000006064820152608401610511565b600060405160086000600182038760208a0101515b83831015612c775780821a83860153600183019250600182039150612c57565b5050500160408190527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151905080611bcc8560086135c6565b60606115a484846000858573ffffffffffffffffffffffffffffffffffffffff85163b612d3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610511565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612d63919061354c565b60006040518083038185875af1925050503d8060008114612da0576040519150601f19603f3d011682016040523d82523d6000602084013e612da5565b606091505b5091509150612db5828286612dc0565b979650505050505050565b60608315612dcf5750816108cf565b825115612ddf5782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610511919061300b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715612e8957612e89612e13565b604052919050565b600067ffffffffffffffff821115612eab57612eab612e13565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112612ee857600080fd5b8135612efb612ef682612e91565b612e42565b818152846020838601011115612f1057600080fd5b816020850160208301376000918101602001919091529392505050565b60008060408385031215612f4057600080fd5b823567ffffffffffffffff80821115612f5857600080fd5b612f6486838701612ed7565b93506020850135915080821115612f7a57600080fd5b50612f8785828601612ed7565b9150509250929050565b60005b83811015612fac578181015183820152602001612f94565b83811115612fbb576000848401525b50505050565b60008151808452612fd9816020860160208601612f91565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006108cf6020830184612fc1565b73ffffffffffffffffffffffffffffffffffffffff811681146117cb57600080fd5b60006020828403121561305257600080fd5b81356108cf8161301e565b60008060006060848603121561307257600080fd5b833567ffffffffffffffff8082111561308a57600080fd5b61309687838801612ed7565b945060208601359150808211156130ac57600080fd5b506130b986828701612ed7565b925050604084013590509250925092565b6000602082840312156130dc57600080fd5b813567ffffffffffffffff8111156130f357600080fd5b6115a484828501612ed7565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006115a46040830184612fc1565b80151581146117cb57600080fd5b60ff811681146117cb57600080fd5b600080600080600080600080610100898b03121561316857600080fd5b883567ffffffffffffffff81111561317f57600080fd5b61318b8b828c01612ed7565b985050602089013561319c8161312e565b965060408901356131ac8161312e565b955060608901356131bc8161313c565b945060808901356131cc8161313c565b979a969950949793969560a0850135955060c08501359460e001359350915050565b6000806000806080858703121561320457600080fd5b843561320f8161301e565b9350602085013561321f8161301e565b925060408501359150606085013567ffffffffffffffff81111561324257600080fd5b61324e87828801612ed7565b91505092959194509250565b6000845161326c818460208901612f91565b845190830190613280818360208901612f91565b8451910190613293818360208801612f91565b0195945050505050565b600085516132af818460208a01612f91565b8551908301906132c3818360208a01612f91565b85519101906132d6818360208901612f91565b84519101906132e9818360208801612f91565b019695505050505050565b6000895160206133078285838f01612f91565b8a519184019161331a8184848f01612f91565b8a5192019161332c8184848e01612f91565b895192019161333e8184848d01612f91565b88519201916133508184848c01612f91565b87519201916133628184848b01612f91565b86519201916133748184848a01612f91565b85519201916133868184848901612f91565b919091019b9a5050505050505050505050565b600080600080600080600080610100898b0312156133b657600080fd5b88516133c18161301e565b60208a01519098506133d28161312e565b60408a01519097506133e38161312e565b60608a01519096506133f48161313c565b60808a01519095506134058161313c565b60a08a015160c08b015160e0909b0151999c989b5096999598909790945092505050565b60006020828403121561343b57600080fd5b81516108cf8161301e565b60008060006060848603121561345b57600080fd5b83516134668161301e565b60208501519093506134778161301e565b80925050604084015190509250925092565b60006020828403121561349b57600080fd5b81516108cf8161312e565b6000602082840312156134b857600080fd5b5051919050565b600080604083850312156134d257600080fd5b82516134dd8161301e565b602084015190925067ffffffffffffffff8111156134fa57600080fd5b8301601f8101851361350b57600080fd5b8051613519612ef682612e91565b81815286602083850101111561352e57600080fd5b61353f826020830160208601612f91565b8093505050509250929050565b6000825161355e818460208701612f91565b9190910192915050565b6000835161357a818460208801612f91565b83519083019061358e818360208801612f91565b01949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156135d9576135d9613597565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561361657613616613597565b500290565b600082613651577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008282101561366857613668613597565b50039056fea264697066735822122091ecdd2f8810a8b19bef7feae1e616206dc57d905dd07e422d2549088f62024164736f6c63430008080033

Deployed Bytecode

0x6080604052600436106100f75760003560e01c8063abb2fef31161008a578063e545398411610059578063e5453984146102ff578063e5d1977a1461031f578063f0403b861461039b578063f2fde38b146103ee57600080fd5b8063abb2fef31461024f578063cec5369f14610291578063dea39a53146102b1578063e30750ca146102df57600080fd5b8063799c2406116100c6578063799c2406146101c25780638da5cb5b146101d75780638dd1480214610202578063a3c573eb1461022257600080fd5b8063159edafd146101035780634f0e0ef3146101395780635b769f3c1461018b57806378ee6788146101ad57600080fd5b366100fe57005b600080fd5b34801561010f57600080fd5b5061012361011e366004612f2d565b61040e565b604051610130919061300b565b60405180910390f35b34801561014557600080fd5b506001546101669073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610130565b34801561019757600080fd5b506101ab6101a6366004613040565b610494565b005b3480156101b957600080fd5b506101ab610594565b3480156101ce57600080fd5b506101ab61067d565b3480156101e357600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610166565b34801561020e57600080fd5b506101ab61021d366004613040565b61074f565b34801561022e57600080fd5b506002546101669073ffffffffffffffffffffffffffffffffffffffff1681565b34801561025b57600080fd5b506000546102819074010000000000000000000000000000000000000000900460ff1681565b6040519015158152602001610130565b34801561029d57600080fd5b506101236102ac36600461305d565b610843565b3480156102bd57600080fd5b506102d16102cc3660046130ca565b6108d6565b6040516101309291906130ff565b3480156102eb57600080fd5b506101236102fa36600461314b565b61090c565b34801561030b57600080fd5b5061028161031a3660046131ee565b6109f1565b34801561032b57600080fd5b5061033f61033a3660046130ca565b6115ac565b6040805173ffffffffffffffffffffffffffffffffffffffff909916895296151560208901529415159587019590955260ff92831660608701529116608085015260a084015260c083019190915260e082015261010001610130565b3480156103a757600080fd5b506103bb6103b63660046130ca565b61164b565b6040805173ffffffffffffffffffffffffffffffffffffffff948516815293909216602084015290820152606001610130565b3480156103fa57600080fd5b506101ab610409366004613040565b61169e565b60608061043a7f03000000000000000000000000000000000000000000000000000000000000006117ce565b6104438561180f565b61044c8561180f565b60405160200161045e9392919061325a565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018152919052949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461051a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fe390bcec6614d6b1f8ae47a4d9d46531ce328e3d293ecd6ddd015cb01eff0300906020015b60405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff163314610615576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001781556040517f241ca0ba639ce0eaf3519529de69af9268c68ea84edd7ab0a6e0a1dd67d31a759190a1565b60005473ffffffffffffffffffffffffffffffffffffffff1633146106fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1681556040517ff25b97c23fde44d33ae2a10c1b1a799ee3e25dd8e8183d9ad96a580b5b039cf79190a1565b60005473ffffffffffffffffffffffffffffffffffffffff1633146107d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fe605ac02ea219003ec58fc9cf4d4b3c5f2d62ec39807b1c63886ddd47a6fcd6e90602001610589565b60608061086f7f02000000000000000000000000000000000000000000000000000000000000006117ce565b6108788661180f565b6108818661180f565b61088a86611846565b60405160200161089d949392919061329d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190529150505b9392505050565b600060608060016108e7858261192f565b90925090506108f582611a8f565b9350610901858261192f565b509395939450505050565b6060806109387f01000000000000000000000000000000000000000000000000000000000000006117ce565b6109418b61180f565b60408051600180825260028d028e0160f890811b6020840152602183018281528d821b604185015260428401928352908c901b60628401526063830190935290919061098c8a611846565b6109958a611846565b61099e8a611846565b6040516020016109b59897969594939291906132f4565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00181529190529a9950505050505050505050565b60025460009073ffffffffffffffffffffffffffffffffffffffff163314610a9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f43616c6c50726f78793a206f6e6c79204272696467652063616e20646f20746860448201527f69730000000000000000000000000000000000000000000000000000000000006064820152608401610511565b6000610aa8836000611b2a565b5090507f01000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161415610f1e576040517fe5d1977a000000000000000000000000000000000000000000000000000000008152309063e5d1977a90610b3190869060040161300b565b6101006040518083038186803b158015610b4a57600080fd5b505afa925050508015610b98575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252610b9591810190613399565b60015b610ba1576114ea565b8d73ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1663c6610657876040518263ffffffff1660e01b8152600401610bfa919060ff91909116815260200190565b60206040518083038186803b158015610c1257600080fd5b505afa158015610c26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4a9190613429565b73ffffffffffffffffffffffffffffffffffffffff1614610c8257610c708e8e8e611bd8565b600199505050505050505050506115a4565b8515610c8c578b92505b610c9a888686868686611bfe565b9150868015610d6357506001546040517fc661065700000000000000000000000000000000000000000000000000000000815260ff8616600482015273ffffffffffffffffffffffffffffffffffffffff918216918a169063c66106579060240160206040518083038186803b158015610d1357600080fd5b505afa158015610d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4b9190613429565b73ffffffffffffffffffffffffffffffffffffffff16145b8015610d6e57508115155b15610e43576001546040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff90911690632e1a7d4d90602401600060405180830381600087803b158015610ddf57600080fd5b505af1158015610df3573d6000803e3d6000fd5b505050508c73ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610e3d573d6000803e3d6000fd5b50610f11565b8115610f11576040517fc661065700000000000000000000000000000000000000000000000000000000815260ff8516600482015260009073ffffffffffffffffffffffffffffffffffffffff8a169063c66106579060240160206040518083038186803b158015610eb457600080fd5b505afa158015610ec8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eec9190613429565b9050610f0f73ffffffffffffffffffffffffffffffffffffffff82168f85611dd8565b505b50505050505050506114ea565b7f02000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008216141561131a576040517ff0403b86000000000000000000000000000000000000000000000000000000008152309063f0403b8690610fa490869060040161300b565b60606040518083038186803b158015610fbc57600080fd5b505afa92505050801561100a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261100791810190613446565b60015b611013576114ea565b8873ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461105e57611051898989611bd8565b60019450505050506115a4565b8873ffffffffffffffffffffffffffffffffffffffff16637ddd28d66040518163ffffffff1660e01b815260040160206040518083038186803b1580156110a457600080fd5b505afa1580156110b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110dc9190613489565b61128f57600254604080517f986d338b000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163986d338b916004808301926020929190829003018186803b15801561114b57600080fd5b505afa15801561115f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118391906134a6565b90506000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cf94e0056040518163ffffffff1660e01b815260040160206040518083038186803b1580156111ef57600080fd5b505afa158015611203573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112279190613429565b9050811580159061124d575073ffffffffffffffffffffffffffffffffffffffff811615155b1561128857600061126d6402540be4006112678686611eac565b90611eb8565b90506112798482611ec4565b93506112868c8383611bd8565b505b5050611312565b6040517ff3fef3a300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152602482018390528a169063f3fef3a390604401600060405180830381600087803b1580156112ff57600080fd5b505af1925050508015611310575060015b505b5050506114ea565b60005474010000000000000000000000000000000000000000900460ff16801561138557507f03000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008216145b156114ea576040517fdea39a53000000000000000000000000000000000000000000000000000000008152309063dea39a53906113c690869060040161300b565b60006040518083038186803b1580156113de57600080fd5b505afa92505050801561143157506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261142e91908101906134bf565b60015b61143a576114ea565b61145c73ffffffffffffffffffffffffffffffffffffffff8916836000611ed0565b61147d73ffffffffffffffffffffffffffffffffffffffff89168388611ed0565b8173ffffffffffffffffffffffffffffffffffffffff16816040516114a2919061354c565b6000604051808303816000865af19150503d80600081146114df576040519150601f19603f3d011682016040523d82523d6000602084013e6114e4565b606091505b50505050505b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8816906370a082319060240160206040518083038186803b15801561155257600080fd5b505afa158015611566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158a91906134a6565b9050801561159d5761159d878783611bd8565b6001925050505b949350505050565b60008080808080808060608160016115c48c8261192f565b90935090506115d283611a8f565b9a506115de8c82612061565b600182169b50600282049a5090925090506115f98c82612061565b90985090506116088c82612061565b90975090506116178c82612146565b90965090506116268c82612146565b90955090506116358c82612146565b8092508195505050505050919395975091939597565b60008080606080600161165e878261192f565b909350905061166c83611a8f565b9550611678878261192f565b909250905061168682611a8f565b94506116928782612146565b50959794965050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461171f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610511565b73ffffffffffffffffffffffffffffffffffffffff81166117c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610511565b6117cb816122d1565b50565b60408051600181527fff0000000000000000000000000000000000000000000000000000000000000083166020820152602181019091526060905b92915050565b805160609061181d81612346565b8360405160200161182f929190613568565b604051602081830303815290604052915050919050565b60607f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211156118d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f56616c756520657863656564732075696e743235352072616e676500000000006044820152606401610511565b60405160208082526000601f5b8282101561191f5785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016118df565b5050506040818101905292915050565b606060008061193e858561245e565b865190955090915061195082866135c6565b11158015611967575061196381856135c6565b8411155b6119f2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4e65787456617242797465732c206f66667365742065786365656473206d617860448201527f696d756d000000000000000000000000000000000000000000000000000000006064820152608401610511565b606081158015611a0d57604051915060208201604052611a75565b6040519150601f8316801560200281840101848101888315602002848c0101015b81831015611a46578051835260209283019201611a2e565b5050848452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b5080611a8183876135c6565b9350935050505b9250929050565b60008151601414611b22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f6279746573206c656e67746820646f6573206e6f74206d61746368206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610511565b506014015190565b6000808351836001611b3c91906135c6565b11158015611b535750611b508360016135c6565b83105b611bb9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e657874427974652c204f66667365742065786365656473206d6178696d756d6044820152606401610511565b8383016020015180611bcc8560016135c6565b92509250509250929050565b611bf973ffffffffffffffffffffffffffffffffffffffff84168383611dd8565b505050565b6040517fc661065700000000000000000000000000000000000000000000000000000000815260ff86166004820152600090819073ffffffffffffffffffffffffffffffffffffffff89169063c66106579060240160206040518083038186803b158015611c6b57600080fd5b505afa158015611c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca39190613429565b9050611cc773ffffffffffffffffffffffffffffffffffffffff8216896000611ed0565b611ce873ffffffffffffffffffffffffffffffffffffffff82168987611ed0565b6040517f9169558600000000000000000000000000000000000000000000000000000000815260ff80891660048301528716602482015260448101869052606481018590526084810184905273ffffffffffffffffffffffffffffffffffffffff89169063916955869060a401602060405180830381600087803b158015611d6f57600080fd5b505af1925050508015611dbd575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611dba918101906134a6565b60015b611dca5760009150611dcd565b91505b509695505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611bf99084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261274c565b60006108cf82846135de565b60006108cf828461361b565b60006108cf8284613656565b801580611f7f57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f4557600080fd5b505afa158015611f59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7d91906134a6565b155b61200b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610511565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611bf99084907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611e2a565b600080835183600161207391906135c6565b1115801561208a57506120878360016135c6565b83105b612116576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4e65787455696e74382c204f66667365742065786365656473206d6178696d7560448201527f6d000000000000000000000000000000000000000000000000000000000000006064820152608401610511565b6000604051846020870101518060001a82535060018101604052601f81035191505080846001611bcc91906135c6565b600080835183602061215891906135c6565b1115801561216f575061216c8360206135c6565b83105b6121fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4e65787455696e743235352c206f66667365742065786365656473206d61786960448201527f6d756d00000000000000000000000000000000000000000000000000000000006064820152608401610511565b600060405160206000600182038760208a0101515b838310156122305780821a83860153600183019250600182039150612210565b50505081016040525190507f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156122c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f56616c75652065786365656473207468652072616e67650000000000000000006044820152606401610511565b80611bcc8560206135c6565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060fd8267ffffffffffffffff16101561237957604080516001815260f884901b602082015260218101909152611809565b61ffff8267ffffffffffffffff16116123e5576123b57ffd000000000000000000000000000000000000000000000000000000000000006117ce565b6123be83612858565b6040516020016123cf929190613568565b6040516020818303038152906040529050919050565b63ffffffff8267ffffffffffffffff161161242c576124237ffe000000000000000000000000000000000000000000000000000000000000006117ce565b6123be836128b9565b6124557fff000000000000000000000000000000000000000000000000000000000000006117ce565b6123be8361291a565b600080600061246d8585611b2a565b9450905060007ffd000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000083161415612554576124c7868661297b565b955061ffff16905060fd81108015906124e2575061ffff8111155b612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4e65787455696e7431362c2076616c7565206f7574736964652072616e6765006044820152606401610511565b9250839150611a889050565b7ffe000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008316141561262d576125a88686612a69565b955063ffffffff16905061ffff811180156125c7575063ffffffff8111155b612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e65787456617255696e742c2076616c7565206f7574736964652072616e67656044820152606401610511565b7fff0000000000000000000000000000000000000000000000000000000000000080831614156126dc576126618686612b8d565b955067ffffffffffffffff16905063ffffffff8111612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e65787456617255696e742c2076616c7565206f7574736964652072616e67656044820152606401610511565b5060f881901c60fd8110612548576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4e65787456617255696e742c2076616c7565206f7574736964652072616e67656044820152606401610511565b60006127ae826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612cb19092919063ffffffff16565b805190915015611bf957808060200190518101906127cc9190613489565b611bf9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610511565b6040516002808252606091906000601f5b828210156128a95785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01612869565b5050506022810160405292915050565b6040516004808252606091906000601f5b8282101561290a5785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff016128ca565b5050506024810160405292915050565b6040516008808252606091906000601f5b8282101561296b5785811a82602086010153600191909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0161292b565b5050506028810160405292915050565b600080835183600261298d91906135c6565b111580156129a457506129a18360026135c6565b83105b612a30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4e65787455696e7431362c206f66667365742065786365656473206d6178696d60448201527f756d0000000000000000000000000000000000000000000000000000000000006064820152608401610511565b6000604051846020870101518060011a82538060001a60018301535060028101604052601e81035191505080846002611bcc91906135c6565b6000808351836004612a7b91906135c6565b11158015612a925750612a8f8360046135c6565b83105b612b1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4e65787455696e7433322c206f66667365742065786365656473206d6178696d60448201527f756d0000000000000000000000000000000000000000000000000000000000006064820152608401610511565b600060405160046000600182038760208a0101515b83831015612b535780821a83860153600183019250600182039150612b33565b5050500160408190527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151905080611bcc8560046135c6565b6000808351836008612b9f91906135c6565b11158015612bb65750612bb38360086135c6565b83105b612c42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4e65787455696e7436342c206f66667365742065786365656473206d6178696d60448201527f756d0000000000000000000000000000000000000000000000000000000000006064820152608401610511565b600060405160086000600182038760208a0101515b83831015612c775780821a83860153600183019250600182039150612c57565b5050500160408190527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151905080611bcc8560086135c6565b60606115a484846000858573ffffffffffffffffffffffffffffffffffffffff85163b612d3a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610511565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612d63919061354c565b60006040518083038185875af1925050503d8060008114612da0576040519150601f19603f3d011682016040523d82523d6000602084013e612da5565b606091505b5091509150612db5828286612dc0565b979650505050505050565b60608315612dcf5750816108cf565b825115612ddf5782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610511919061300b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715612e8957612e89612e13565b604052919050565b600067ffffffffffffffff821115612eab57612eab612e13565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112612ee857600080fd5b8135612efb612ef682612e91565b612e42565b818152846020838601011115612f1057600080fd5b816020850160208301376000918101602001919091529392505050565b60008060408385031215612f4057600080fd5b823567ffffffffffffffff80821115612f5857600080fd5b612f6486838701612ed7565b93506020850135915080821115612f7a57600080fd5b50612f8785828601612ed7565b9150509250929050565b60005b83811015612fac578181015183820152602001612f94565b83811115612fbb576000848401525b50505050565b60008151808452612fd9816020860160208601612f91565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006108cf6020830184612fc1565b73ffffffffffffffffffffffffffffffffffffffff811681146117cb57600080fd5b60006020828403121561305257600080fd5b81356108cf8161301e565b60008060006060848603121561307257600080fd5b833567ffffffffffffffff8082111561308a57600080fd5b61309687838801612ed7565b945060208601359150808211156130ac57600080fd5b506130b986828701612ed7565b925050604084013590509250925092565b6000602082840312156130dc57600080fd5b813567ffffffffffffffff8111156130f357600080fd5b6115a484828501612ed7565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006115a46040830184612fc1565b80151581146117cb57600080fd5b60ff811681146117cb57600080fd5b600080600080600080600080610100898b03121561316857600080fd5b883567ffffffffffffffff81111561317f57600080fd5b61318b8b828c01612ed7565b985050602089013561319c8161312e565b965060408901356131ac8161312e565b955060608901356131bc8161313c565b945060808901356131cc8161313c565b979a969950949793969560a0850135955060c08501359460e001359350915050565b6000806000806080858703121561320457600080fd5b843561320f8161301e565b9350602085013561321f8161301e565b925060408501359150606085013567ffffffffffffffff81111561324257600080fd5b61324e87828801612ed7565b91505092959194509250565b6000845161326c818460208901612f91565b845190830190613280818360208901612f91565b8451910190613293818360208801612f91565b0195945050505050565b600085516132af818460208a01612f91565b8551908301906132c3818360208a01612f91565b85519101906132d6818360208901612f91565b84519101906132e9818360208801612f91565b019695505050505050565b6000895160206133078285838f01612f91565b8a519184019161331a8184848f01612f91565b8a5192019161332c8184848e01612f91565b895192019161333e8184848d01612f91565b88519201916133508184848c01612f91565b87519201916133628184848b01612f91565b86519201916133748184848a01612f91565b85519201916133868184848901612f91565b919091019b9a5050505050505050505050565b600080600080600080600080610100898b0312156133b657600080fd5b88516133c18161301e565b60208a01519098506133d28161312e565b60408a01519097506133e38161312e565b60608a01519096506133f48161313c565b60808a01519095506134058161313c565b60a08a015160c08b015160e0909b0151999c989b5096999598909790945092505050565b60006020828403121561343b57600080fd5b81516108cf8161301e565b60008060006060848603121561345b57600080fd5b83516134668161301e565b60208501519093506134778161301e565b80925050604084015190509250925092565b60006020828403121561349b57600080fd5b81516108cf8161312e565b6000602082840312156134b857600080fd5b5051919050565b600080604083850312156134d257600080fd5b82516134dd8161301e565b602084015190925067ffffffffffffffff8111156134fa57600080fd5b8301601f8101851361350b57600080fd5b8051613519612ef682612e91565b81815286602083850101111561352e57600080fd5b61353f826020830160208601612f91565b8093505050509250929050565b6000825161355e818460208701612f91565b9190910192915050565b6000835161357a818460208801612f91565b83519083019061358e818360208801612f91565b01949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156135d9576135d9613597565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561361657613616613597565b500290565b600082613651577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008282101561366857613668613597565b50039056fea264697066735822122091ecdd2f8810a8b19bef7feae1e616206dc57d905dd07e422d2549088f62024164736f6c63430008080033

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.