ETH Price: $2,714.81 (-8.03%)

Contract

0xfE96910cF84318d1B8a5e2a6962774711467C0be

Overview

ETH Balance

Taiko Alethia LogoTaiko Alethia LogoTaiko Alethia Logo0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To
41262024-05-28 15:58:47611 days ago1716911927  Contract Creation0 ETH
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
JamBalanceManager

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "./interfaces/IJamBalanceManager.sol";
import "./interfaces/IPermit2.sol";
import "./interfaces/IDaiLikePermit.sol";
import "./libraries/JamOrder.sol";
import "./libraries/Signature.sol";
import "./libraries/common/SafeCast160.sol";
import "./libraries/common/BMath.sol";
import "./base/JamTransfer.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";

/// @title JamBalanceManager
/// @notice The reason a balance manager exists is to prevent interaction to the settlement contract draining user funds
/// By having another contract that allowances are made to, we can enforce that it is only used to draw in user balances to settlement and not sent out
contract JamBalanceManager is IJamBalanceManager {
    address private immutable operator;

    using SafeERC20 for IERC20;

    IPermit2 private immutable PERMIT2;
    address private immutable DAI_TOKEN;
    uint256 private immutable _chainId;

    constructor(address _operator, address _permit2, address _daiAddress) {
        // Operator can be defined at creation time with `msg.sender`
        // Pass in the settlement - and that can be the only caller.
        operator = _operator;
        _chainId = block.chainid;
        PERMIT2 = IPermit2(_permit2);
        DAI_TOKEN = _daiAddress;
    }

    modifier onlyOperator(address account) {
        require(account == operator, "INVALID_CALLER");
        _;
    }

    /// @inheritdoc IJamBalanceManager
    function transferTokens(
        TransferData calldata data
    ) onlyOperator(msg.sender) external {
        IPermit2.AllowanceTransferDetails[] memory batchTransferDetails;
        uint nftsInd;
        uint batchLen;
        for (uint i; i < data.tokens.length; ++i) {
            if (data.tokenTransferTypes[i] == Commands.SIMPLE_TRANSFER) {
                IERC20(data.tokens[i]).safeTransferFrom(
                    data.from, data.receiver, BMath.getPercentage(data.amounts[i], data.fillPercent)
                );
            } else if (data.tokenTransferTypes[i] == Commands.PERMIT2_TRANSFER) {
                if (batchLen == 0){
                    batchTransferDetails = new IPermit2.AllowanceTransferDetails[](data.tokens.length - i);
                }
                batchTransferDetails[batchLen++] = IPermit2.AllowanceTransferDetails({
                    from: data.from,
                    to: data.receiver,
                    amount: SafeCast160.toUint160(BMath.getPercentage(data.amounts[i], data.fillPercent)),
                    token: data.tokens[i]
                });
                continue;
            } else if (data.tokenTransferTypes[i] == Commands.NATIVE_TRANSFER) {
                require(data.tokens[i] == JamOrder.NATIVE_TOKEN, "INVALID_NATIVE_TOKEN_ADDRESS");
                require(data.fillPercent == BMath.HUNDRED_PERCENT, "INVALID_FILL_PERCENT");
                if (data.receiver != operator){
                    JamTransfer(operator).transferNativeFromContract(
                        data.receiver, BMath.getPercentage(data.amounts[i], data.fillPercent)
                    );
                }
            } else if (data.tokenTransferTypes[i] == Commands.NFT_ERC721_TRANSFER) {
                require(data.fillPercent == BMath.HUNDRED_PERCENT, "INVALID_FILL_PERCENT");
                require(data.amounts[i] == 1, "INVALID_ERC721_AMOUNT");
                IERC721(data.tokens[i]).safeTransferFrom(data.from, data.receiver, data.nftIds[nftsInd++]);
            } else if (data.tokenTransferTypes[i] == Commands.NFT_ERC1155_TRANSFER) {
                require(data.fillPercent == BMath.HUNDRED_PERCENT, "INVALID_FILL_PERCENT");
                IERC1155(data.tokens[i]).safeTransferFrom(data.from, data.receiver, data.nftIds[nftsInd++], data.amounts[i], "");
            } else {
                revert("INVALID_TRANSFER_TYPE");
            }
            if (batchLen != 0){
                assembly {mstore(batchTransferDetails, sub(mload(batchTransferDetails), 1))}
            }
        }
        require(nftsInd == data.nftIds.length, "INVALID_NFT_IDS_LENGTH");
        require(batchLen == batchTransferDetails.length, "INVALID_BATCH_PERMIT2_LENGTH");

        if (batchLen != 0){
            PERMIT2.transferFrom(batchTransferDetails);
        }
    }

    /// @inheritdoc IJamBalanceManager
    function transferTokensWithPermits(
        TransferData calldata data,
        Signature.TakerPermitsInfo calldata takerPermitsInfo
    ) onlyOperator(msg.sender) external {
        IPermit2.AllowanceTransferDetails[] memory batchTransferDetails;
        IPermit2.PermitDetails[] memory batchToApprove = new IPermit2.PermitDetails[](takerPermitsInfo.noncesPermit2.length);
        Indices memory indices = Indices(0, 0, 0, 0);
        for (uint i; i < data.tokens.length; ++i) {
            if (data.tokenTransferTypes[i] == Commands.SIMPLE_TRANSFER || data.tokenTransferTypes[i] == Commands.CALL_PERMIT_THEN_TRANSFER) {
                if (data.tokenTransferTypes[i] == Commands.CALL_PERMIT_THEN_TRANSFER){
                    permitToken(
                        data.from, data.tokens[i], takerPermitsInfo.deadline, takerPermitsInfo.permitSignatures[indices.permitSignaturesInd++]
                    );
                }
                IERC20(data.tokens[i]).safeTransferFrom(
                    data.from, data.receiver, BMath.getPercentage(data.amounts[i], data.fillPercent)
                );
            } else if (data.tokenTransferTypes[i] == Commands.PERMIT2_TRANSFER || data.tokenTransferTypes[i] == Commands.CALL_PERMIT2_THEN_TRANSFER) {
                if (data.tokenTransferTypes[i] == Commands.CALL_PERMIT2_THEN_TRANSFER){
                    batchToApprove[indices.batchToApproveInd] = IPermit2.PermitDetails({
                        token: data.tokens[i],
                        amount: type(uint160).max,
                        expiration: takerPermitsInfo.deadline,
                        nonce: takerPermitsInfo.noncesPermit2[indices.batchToApproveInd]
                    });
                    ++indices.batchToApproveInd;
                }

                if (indices.batchLen == 0){
                    batchTransferDetails = new IPermit2.AllowanceTransferDetails[](data.tokens.length - i);
                }
                batchTransferDetails[indices.batchLen++] = IPermit2.AllowanceTransferDetails({
                    from: data.from,
                    to: data.receiver,
                    amount: SafeCast160.toUint160(BMath.getPercentage(data.amounts[i], data.fillPercent)),
                    token: data.tokens[i]
                });
                continue;
            } else if (data.tokenTransferTypes[i] == Commands.NATIVE_TRANSFER) {
                require(data.tokens[i] == JamOrder.NATIVE_TOKEN, "INVALID_NATIVE_TOKEN_ADDRESS");
                require(data.fillPercent == BMath.HUNDRED_PERCENT, "INVALID_FILL_PERCENT");
                if (data.receiver != operator){
                    JamTransfer(operator).transferNativeFromContract(
                        data.receiver, BMath.getPercentage(data.amounts[i], data.fillPercent)
                    );
                }
            } else if (data.tokenTransferTypes[i] == Commands.NFT_ERC721_TRANSFER) {
                require(data.fillPercent == BMath.HUNDRED_PERCENT, "INVALID_FILL_PERCENT");
                require(data.amounts[i] == 1, "INVALID_ERC721_AMOUNT");
                IERC721(data.tokens[i]).safeTransferFrom(data.from, data.receiver, data.nftIds[indices.nftsInd++]);
            } else if (data.tokenTransferTypes[i] == Commands.NFT_ERC1155_TRANSFER) {
                require(data.fillPercent == BMath.HUNDRED_PERCENT, "INVALID_FILL_PERCENT");
                IERC1155(data.tokens[i]).safeTransferFrom(data.from, data.receiver, data.nftIds[indices.nftsInd++], data.amounts[i], "");
            } else {
                revert("INVALID_TRANSFER_TYPE");
            }

            // Shortening array
            if (indices.batchLen != 0){
                assembly {mstore(batchTransferDetails, sub(mload(batchTransferDetails), 1))}
            }
        }
        require(indices.batchToApproveInd == batchToApprove.length, "INVALID_NUMBER_OF_TOKENS_TO_APPROVE");
        require(indices.batchLen == batchTransferDetails.length, "INVALID_BATCH_PERMIT2_LENGTH");
        require(indices.permitSignaturesInd == takerPermitsInfo.permitSignatures.length, "INVALID_NUMBER_OF_PERMIT_SIGNATURES");
        require(indices.nftsInd == data.nftIds.length, "INVALID_NFT_IDS_LENGTH");

        if (batchToApprove.length != 0) {
            // Update approvals for new taker's data.tokens
            PERMIT2.permit({
                owner: data.from,
                permitBatch: IPermit2.PermitBatch({
                    details: batchToApprove,
                    spender: address(this),
                    sigDeadline: takerPermitsInfo.deadline
                }),
                signature: takerPermitsInfo.signatureBytesPermit2
            });
        }

        // Batch transfer
        if (indices.batchLen != 0){
            PERMIT2.transferFrom(batchTransferDetails);
        }
    }

    /// @dev Call permit function on token contract, supports both ERC20Permit and DaiPermit formats
    /// @param takerAddress address
    /// @param tokenAddress address
    /// @param deadline timestamp when the signature expires
    /// @param permitSignature signature
    function permitToken(
        address takerAddress, address tokenAddress, uint deadline, bytes calldata permitSignature
    ) private {
        (bytes32 r, bytes32 s, uint8 v) = Signature.getRsv(permitSignature);

        if (tokenAddress == DAI_TOKEN){
            if (_chainId == 137){
                IDaiLikePermit(tokenAddress).permit(
                    takerAddress, address(this), IDaiLikePermit(tokenAddress).getNonce(takerAddress), deadline, true, v, r, s
                );
            } else {
                IDaiLikePermit(tokenAddress).permit(
                    takerAddress, address(this), IERC20Permit(tokenAddress).nonces(takerAddress), deadline, true, v, r, s
                );
            }
        } else {
            IERC20Permit(tokenAddress).permit(takerAddress, address(this), type(uint).max, deadline, v, r, s);
        }

    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "../libraries/JamOrder.sol";
import "../libraries/common/BMath.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
import "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";

/// @title JamTransfer
/// @notice Functions for transferring tokens from SettlementContract
abstract contract JamTransfer {

    event NativeTransfer(address indexed receiver, uint256 amount);
    using SafeERC20 for IERC20;

    /// @dev Transfer tokens from this contract to receiver
    /// @param tokens tokens' addresses
    /// @param amounts tokens' amounts
    /// @param nftIds NFTs' ids
    /// @param tokenTransferTypes command sequence of transfer types
    /// @param receiver address
    function transferTokensFromContract(
        address[] calldata tokens,
        uint256[] memory amounts,
        uint256[] calldata nftIds,
        bytes calldata tokenTransferTypes,
        address receiver,
        uint16 fillPercent,
        bool transferExactAmounts
    ) internal {
        uint nftInd;
        for (uint i; i < tokens.length; ++i) {
            if (tokenTransferTypes[i] == Commands.SIMPLE_TRANSFER) {
                uint tokenBalance = IERC20(tokens[i]).balanceOf(address(this));
                uint partialFillAmount = BMath.getPercentage(amounts[i], fillPercent);
                require(tokenBalance >= partialFillAmount, "INVALID_OUTPUT_TOKEN_BALANCE");
                IERC20(tokens[i]).safeTransfer(receiver, transferExactAmounts ? partialFillAmount : tokenBalance);
            } else if (tokenTransferTypes[i] == Commands.NATIVE_TRANSFER){
                require(tokens[i] == JamOrder.NATIVE_TOKEN, "INVALID_NATIVE_TOKEN");
                uint tokenBalance = address(this).balance;
                uint partialFillAmount = BMath.getPercentage(amounts[i], fillPercent);
                require(tokenBalance >= partialFillAmount, "INVALID_OUTPUT_NATIVE_BALANCE");
                (bool sent, ) = payable(receiver).call{value: transferExactAmounts ?  partialFillAmount : tokenBalance}("");
                require(sent, "FAILED_TO_SEND_ETH");
                emit NativeTransfer(receiver, transferExactAmounts ? partialFillAmount : tokenBalance);
            } else if (tokenTransferTypes[i] == Commands.NFT_ERC721_TRANSFER) {
                uint tokenBalance = IERC721(tokens[i]).balanceOf(address(this));
                require(amounts[i] == 1 && tokenBalance >= 1, "INVALID_OUTPUT_ERC721_AMOUNT");
                IERC721(tokens[i]).safeTransferFrom(address(this), receiver, nftIds[nftInd++]);
            } else if (tokenTransferTypes[i] == Commands.NFT_ERC1155_TRANSFER) {
                uint tokenBalance = IERC1155(tokens[i]).balanceOf(address(this), nftIds[nftInd]);
                require(tokenBalance >= amounts[i], "INVALID_OUTPUT_ERC1155_BALANCE");
                IERC1155(tokens[i]).safeTransferFrom(
                    address(this), receiver, nftIds[nftInd++], transferExactAmounts ?  amounts[i] : tokenBalance, ""
                );
            } else {
                revert("INVALID_TRANSFER_TYPE");
            }
        }
        require(nftInd == nftIds.length, "INVALID_BUY_NFT_IDS_LENGTH");
    }

    /// @dev Transfer native tokens to receiver from this contract
    /// @param receiver address
    /// @param amount amount of native tokens
    function transferNativeFromContract(address receiver, uint256 amount) public {
        (bool sent, ) = payable(receiver).call{value: amount}("");
        require(sent, "FAILED_TO_SEND_ETH");
    }

    /// @dev Calculate new amounts of tokens if solver transferred excess to contract during settleBatch
    /// @param curInd index of current order
    /// @param orders array of orders
    /// @param fillPercents[] fill percentage
    /// @return array of new amounts
    function calculateNewAmounts(
        uint256 curInd,
        JamOrder.Data[] calldata orders,
        uint16[] memory fillPercents
    ) internal returns (uint256[] memory) {
        JamOrder.Data calldata curOrder = orders[curInd];
        uint256[] memory newAmounts = new uint256[](curOrder.buyTokens.length);
        uint16 curFillPercent = fillPercents.length == 0 ? BMath.HUNDRED_PERCENT : fillPercents[curInd];
        for (uint i; i < curOrder.buyTokens.length; ++i) {
            if (curOrder.buyTokenTransfers[i] == Commands.SIMPLE_TRANSFER || curOrder.buyTokenTransfers[i] == Commands.NATIVE_TRANSFER) {
                uint256 fullAmount;
                for (uint j = curInd; j < orders.length; ++j) {
                    for (uint k; k < orders[j].buyTokens.length; ++k) {
                        if (orders[j].buyTokens[k] == curOrder.buyTokens[i]) {
                            fullAmount += orders[j].buyAmounts[k];
                            require(fillPercents.length == 0 || curFillPercent == fillPercents[j], "DIFF_FILL_PERCENT_FOR_SAME_TOKEN");
                        }
                    }
                }
                uint256 tokenBalance = curOrder.buyTokenTransfers[i] == Commands.NATIVE_TRANSFER ?
                    address(this).balance : IERC20(curOrder.buyTokens[i]).balanceOf(address(this));
                // if at least two takers buy same token, we need to divide the whole tokenBalance among them.
                // for edge case with newAmounts[i] overflow, solver should submit tx with transferExactAmounts=true
                newAmounts[i] = BMath.getInvertedPercentage(tokenBalance * curOrder.buyAmounts[i] / fullAmount, curFillPercent);
                if (newAmounts[i] < curOrder.buyAmounts[i]) {
                    newAmounts[i] = curOrder.buyAmounts[i];
                }
            } else {
                newAmounts[i] = curOrder.buyAmounts[i];
            }
        }
        return newAmounts;
    }


    /// @dev Check if there are duplicate tokens
    /// @param tokens tokens' addresses
    /// @param nftIds NFTs' ids
    /// @param tokenTransferTypes command sequence of transfer types
    /// @return true if there are duplicate tokens
    function hasDuplicate(
        address[] calldata tokens, uint256[] calldata nftIds, bytes calldata tokenTransferTypes
    ) internal pure returns (bool) {
        if (tokens.length == 0) {
            return false;
        }
        uint curNftInd;
        for (uint i; i < tokens.length - 1; ++i) {
            uint tmpNftInd = curNftInd;
            for (uint j = i + 1; j < tokens.length; ++j) {
                if (tokenTransferTypes[j] == Commands.NFT_ERC721_TRANSFER || tokenTransferTypes[j] == Commands.NFT_ERC1155_TRANSFER){
                    ++tmpNftInd;
                }
                if (tokens[i] == tokens[j]) {
                    if (tokenTransferTypes[i] == Commands.NFT_ERC721_TRANSFER ||
                        tokenTransferTypes[i] == Commands.NFT_ERC1155_TRANSFER){
                        if (nftIds[curNftInd] == nftIds[tmpNftInd]){
                            return true;
                        }
                    } else {
                        return true;
                    }
                }
            }
            if (tokenTransferTypes[i] == Commands.NFT_ERC721_TRANSFER || tokenTransferTypes[i] == Commands.NFT_ERC1155_TRANSFER){
                ++curNftInd;
            }
        }
        return false;
    }
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IDaiLikePermit {
    /// @param holder The address of the token owner.
    /// @param spender The address of the token spender.
    /// @param nonce The owner's nonce, increases at each call to permit.
    /// @param expiry The timestamp at which the permit is no longer valid.
    /// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0.
    /// @param v Must produce valid secp256k1 signature from the owner along with r and s.
    /// @param r Must produce valid secp256k1 signature from the owner along with v and s.
    /// @param s Must produce valid secp256k1 signature from the owner along with r and v.
    function permit(
        address holder,
        address spender,
        uint256 nonce,
        uint256 expiry,
        bool allowed,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    // DAI's Polygon getNonce, instead of `nonces(address)` function
    function getNonce(address user) external view returns (uint256 nonce);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "../libraries/Signature.sol";

/// @title IJamBalanceManager
/// @notice User approvals are made here. This handles the complexity of multiple allowance types. 
interface IJamBalanceManager {

    /// @dev All information needed to transfer tokens
    struct TransferData {
        address from;
        address receiver;
        address[] tokens;
        uint256[] amounts;
        uint256[] nftIds;
        bytes tokenTransferTypes;
        uint16 fillPercent;
    }

    /// @dev indices for transferTokensWithPermits function
    struct Indices {
        uint64 batchToApproveInd; // current `batchToApprove` index
        uint64 permitSignaturesInd; // current `takerPermitsInfo.permitSignatures` index
        uint64 nftsInd; // current `data.nftIds` index
        uint64 batchLen; // current length of `batchTransferDetails`
    }

    /// @notice Transfer tokens from taker to solverContract/settlementContract/makerAddress.
    /// Or transfer tokens directly from maker to taker for settleInternal case
    /// @param transferData data for transfer
    function transferTokens(
        TransferData calldata transferData
    ) external;

    /// @notice Transfer tokens from taker to solverContract/settlementContract
    /// @param transferData data for transfer
    /// @param takerPermitsInfo taker permits info
    function transferTokensWithPermits(
        TransferData calldata transferData,
        Signature.TakerPermitsInfo calldata takerPermitsInfo
    ) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;


// Part of IAllowanceTransfer(https://github.com/Uniswap/permit2/blob/main/src/interfaces/IAllowanceTransfer.sol)
interface IPermit2 {

    // ------------------
    // IAllowanceTransfer
    // ------------------

    /// @notice Details for a token transfer.
    struct AllowanceTransferDetails {
        // the owner of the token
        address from;
        // the recipient of the token
        address to;
        // the amount of the token
        uint160 amount;
        // the token to be transferred
        address token;
    }

    /// @notice The permit data for a token
    struct PermitDetails {
        // ERC20 token address
        address token;
        // the maximum amount allowed to spend
        uint160 amount;
        // timestamp at which a spender's token allowances become invalid
        uint48 expiration;
        // an incrementing value indexed per owner,token,and spender for each signature
        uint48 nonce;
    }

    /// @notice The permit message signed for multiple token allowances
    struct PermitBatch {
        // the permit data for multiple token allowances
        PermitDetails[] details;
        // address permissioned on the allowed tokens
        address spender;
        // deadline on the permit signature
        uint256 sigDeadline;
    }

    /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.
    /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]
    /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals.
    function allowance(address user, address token, address spender)
    external
    view
    returns (uint160 amount, uint48 expiration, uint48 nonce);

    /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature
    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce
    /// @param owner The owner of the tokens being approved
    /// @param permitBatch Data signed over by the owner specifying the terms of approval
    /// @param signature The owner's signature over the permit data
    function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external;

    /// @notice Transfer approved tokens in a batch
    /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers
    /// @dev Requires the from addresses to have approved at least the desired amount
    /// of tokens to msg.sender.
    function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external;

}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

library BMath {

    uint16 internal constant HUNDRED_PERCENT = 10000;

    function getPercentage(uint256 value, uint16 percent) internal pure returns (uint256){
        if (percent >= HUNDRED_PERCENT){
            return value;
        }
        return value * percent / HUNDRED_PERCENT;
    }

    function getInvertedPercentage(uint256 value, uint16 percent) internal pure returns (uint256){
        if (percent >= HUNDRED_PERCENT){
            return value;
        }
        return value * HUNDRED_PERCENT / percent;
    }

}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library SafeCast160 {
    /// @notice Thrown when a valude greater than type(uint160).max is cast to uint160
    error UnsafeCast();

    /// @notice Safely casts uint256 to uint160
    /// @param value The uint256 to be cast
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) revert UnsafeCast();
        return uint160(value);
    }
}

File 15 of 16 : JamOrder.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

/// @title Commands
/// @notice Commands are used to specify how tokens are transferred in Data.buyTokenTransfers and Data.sellTokenTransfers
library Commands {
    bytes1 internal constant SIMPLE_TRANSFER = 0x00; // simple transfer with standard transferFrom
    bytes1 internal constant PERMIT2_TRANSFER = 0x01; // transfer using permit2.transfer
    bytes1 internal constant CALL_PERMIT_THEN_TRANSFER = 0x02; // call permit then simple transfer
    bytes1 internal constant CALL_PERMIT2_THEN_TRANSFER = 0x03; // call permit2.permit then permit2.transfer
    bytes1 internal constant NATIVE_TRANSFER = 0x04;
    bytes1 internal constant NFT_ERC721_TRANSFER = 0x05;
    bytes1 internal constant NFT_ERC1155_TRANSFER = 0x06;
}

/// @title JamOrder
library JamOrder {

    address internal constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    /// @dev Data representing a Jam Order.
    struct Data {
        address taker;
        address receiver;
        uint256 expiry;
        uint256 nonce;
        address executor; // only msg.sender=executor is allowed to execute (if executor=address(0), then order can be executed by anyone)
        uint16 minFillPercent; // 100% = 10000, if taker allows partial fills, then it could be less than 100%
        bytes32 hooksHash; // keccak256(pre interactions + post interactions)
        address[] sellTokens;
        address[] buyTokens;
        uint256[] sellAmounts;
        uint256[] buyAmounts;
        uint256[] sellNFTIds;
        uint256[] buyNFTIds;
        bytes sellTokenTransfers; // Commands sequence of sellToken transfer types
        bytes buyTokenTransfers; // Commands sequence of buyToken transfer types
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library Signature {

    enum Type {
        NONE,    // 0
        EIP712,  //1
        EIP1271, //2
        ETHSIGN  //3
    }

    struct TypedSignature {
        Type signatureType;
        bytes signatureBytes;
    }

    struct TakerPermitsInfo {
        bytes[] permitSignatures;
        bytes signatureBytesPermit2;
        uint48[] noncesPermit2;
        uint48 deadline;
    }

    function getRsv(bytes memory sig) internal pure returns (bytes32, bytes32, uint8){
        require(sig.length == 65, "Invalid signature length");
        bytes32 r;
        bytes32 s;
        uint8 v;
        assembly {
            r := mload(add(sig, 32))
            s := mload(add(sig, 64))
            v := and(mload(add(sig, 65)), 255)
        }
        if (v < 27) v += 27;
        require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "Invalid sig value S");
        require(v == 27 || v == 28, "Invalid sig value V");
        return (r, s, v);
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_permit2","type":"address"},{"internalType":"address","name":"_daiAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"UnsafeCast","type":"error"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"nftIds","type":"uint256[]"},{"internalType":"bytes","name":"tokenTransferTypes","type":"bytes"},{"internalType":"uint16","name":"fillPercent","type":"uint16"}],"internalType":"struct IJamBalanceManager.TransferData","name":"data","type":"tuple"}],"name":"transferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"nftIds","type":"uint256[]"},{"internalType":"bytes","name":"tokenTransferTypes","type":"bytes"},{"internalType":"uint16","name":"fillPercent","type":"uint16"}],"internalType":"struct IJamBalanceManager.TransferData","name":"data","type":"tuple"},{"components":[{"internalType":"bytes[]","name":"permitSignatures","type":"bytes[]"},{"internalType":"bytes","name":"signatureBytesPermit2","type":"bytes"},{"internalType":"uint48[]","name":"noncesPermit2","type":"uint48[]"},{"internalType":"uint48","name":"deadline","type":"uint48"}],"internalType":"struct Signature.TakerPermitsInfo","name":"takerPermitsInfo","type":"tuple"}],"name":"transferTokensWithPermits","outputs":[],"stateMutability":"nonpayable","type":"function"}]

61010034620000e157601f62002b6238819003918201601f19168301916001600160401b03831184841017620000e657808492606094604052833981010312620000e1576200004e81620000fc565b906200006b60406200006360208401620000fc565b9201620000fc565b6080929092524660e0526001600160a01b031660a05260c052604051612a50908162000112823960805181818160c5015281816107c301528181610852015281816108e6015261106e015260a051818181610e5d01528181610f0b015261177e015260c0518161248c015260e051816124b70152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203620000e15756fe60806040526004361015610013575b600080fd5b60003560e01c80638c575a9f1461003b5763eb8d21161461003357600080fd5b61000e611003565b3461000e577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60408136011261000e5760043567ffffffffffffffff811161000e5761008b903690600401610ff5565b9067ffffffffffffffff6024351161000e576080906024353603011261000e576100ec73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633146117de565b606061010c6101056044602435016024356004016118ad565b9050611c51565b90610115611bf0565b600081526000602082015260006040820152818101906000825260005b61013f60408701876118ad565b9050811015610d5e576101b061018b6101658361015f60a08b018b611901565b90611982565b357fff000000000000000000000000000000000000000000000000000000000000001690565b7fff000000000000000000000000000000000000000000000000000000000000001690565b158015610d00575b1561039657807f02000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006102176101656102cb9561015f60a08d018d611901565b16146102fb575b6102a061025c61024361023e8461023860408d018d6118ad565b90611a0a565b611a28565b73ffffffffffffffffffffffffffffffffffffffff1690565b61026589611a28565b61027160208b01611a28565b9061029a8b61029460c061028c8961023860608601866118ad565b359201611996565b90612998565b92611e61565b6102c26102b5855167ffffffffffffffff1690565b67ffffffffffffffff1690565b6102d057611873565b610132565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8551018552611873565b61039165ffffffffffff61030e89611a28565b61032261023e8561023860408e018e6118ad565b906103316064602435016121a3565b91610387610344600460243501806118ad565b67ffffffffffffffff61036260208d015167ffffffffffffffff1690565b6103808d602061037184612189565b67ffffffffffffffff16910152565b16916121b6565b9490931691612457565b61021e565b7f01000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006103ec6101658461015f60a08c018c611901565b16148015610ca2575b156106e6577f03000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006104506101658461015f60a08c018c611901565b16146105d0575b61046c6102b5845167ffffffffffffffff1690565b156105a3575b6102cb9061059d61048288611a28565b61055561049160208b01611a28565b6105388b61051b6104d661023e896102386104cb6104c66104b98461023860608b018b6118ad565b3561029460c08a01611996565b6129cf565b9560408101906118ad565b936104fe6104e2611bf0565b73ffffffffffffffffffffffffffffffffffffffff9098168852565b73ffffffffffffffffffffffffffffffffffffffff166020870152565b73ffffffffffffffffffffffffffffffffffffffff166040850152565b73ffffffffffffffffffffffffffffffffffffffff166060830152565b67ffffffffffffffff610570875167ffffffffffffffff1690565b61058a61057c82612189565b67ffffffffffffffff168952565b16906105968289611cf9565b5286611cf9565b50611873565b92506102cb6105c86105c3856105bc60408a018a6118ad565b9050611bd9565b611c51565b939050610472565b6106b56105e761023e8361023860408b018b6118ad565b6106956105f86064602435016121a3565b6106866106356106306106156044602435016024356004016118ad565b61062a6102b58c5167ffffffffffffffff1690565b91611a0a565b6121a3565b9161065d610641611bf0565b73ffffffffffffffffffffffffffffffffffffffff9096168652565b73ffffffffffffffffffffffffffffffffffffffff602086015265ffffffffffff166040850152565b65ffffffffffff166060830152565b6106aa6102b5855167ffffffffffffffff1690565b906105968289611cf9565b506106e16106d36106ce845167ffffffffffffffff1690565b612189565b67ffffffffffffffff168352565b610457565b7f04000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000061073c6101658461015f60a08c018c611901565b160361093a5761078a73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff61078361023e8561023860408d018d6118ad565b1614611b74565b60c08601906107a861271061ffff6107a185611996565b16146119a5565b6020870173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff61080183611a28565b1603610813575b506102cb91506102a0565b61081f61083b91611a28565b926102946108348461023860608d018d6118ad565b3591611996565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163b1561000e576040517f7c317e0f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301526102cb91600081806044810103818373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af1801561092d575b15610808578061092161092792611a79565b80611af7565b87610808565b610935611b02565b61090f565b7f05000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006109906101658461015f60a08c018c611901565b1603610ae8576109ab61271061ffff6107a160c08a01611996565b6109c860016109c18361023860608b018b6118ad565b3514611b0f565b6109e261024361024361023e8461023860408c018c6118ad565b906109ec87611a28565b6109f860208901611a28565b90610a4b610a0960808b018b6118ad565b67ffffffffffffffff610a2760408a015167ffffffffffffffff1690565b610a44610a3382612189565b67ffffffffffffffff1660408c0152565b1691611a0a565b35843b1561000e576040517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316600482015292909116602483015260448201526102cb926000908290606490829084905af18015610adb575b610ac8575b506102a0565b80610921610ad592611a79565b87610ac2565b610ae3611b02565b610abd565b7f06000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000610b3e6101658461015f60a08c018c611901565b1603610c3f57610b5961271061ffff6107a160c08a01611996565b610b7361024361024361023e8461023860408c018c6118ad565b90610b7d87611a28565b91610b8a60208901611a28565b92610b9b610a0960808b018b6118ad565b35610bad8461023860608d018d6118ad565b3592803b1561000e576040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff93841660048201529590921660248601526044850152606484019190915260a06084840152600060a484018190526102cb9391829060c490829084905af18015610adb57610ac857506102a0565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e56414c49445f5452414e534645525f5459504500000000000000000000006044820152606490fd5b0390fd5b507f03000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000610cf96101658461015f60a08c018c611901565b16146103f5565b507f02000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000610d576101658461015f60a08c018c611901565b16146101b8565b5083610e23610e0360408894610d92610d7f825167ffffffffffffffff1690565b67ffffffffffffffff87519116146121e0565b610dba610da7885167ffffffffffffffff1690565b67ffffffffffffffff8a51911614611d80565b610df4610dd2602083015167ffffffffffffffff1690565b67ffffffffffffffff610dea600460243501806118ad565b929050161461226b565b015167ffffffffffffffff1690565b67ffffffffffffffff610e1960808601866118ad565b9290501614611d1b565b8051610eef575b505051610e409067ffffffffffffffff166102b5565b610e4657005b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016803b1561000e57610ec26000929183926040519485809481937f0d58b1db00000000000000000000000000000000000000000000000000000000835260048301611de5565b03925af18015610ee2575b610ed357005b80610921610ee092611a79565b005b610eea611b02565b610ecd565b9091610f3173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001693611a28565b65ffffffffffff610f466064602435016121a3565b610f4e611c10565b948552306020860152166040840152610f706024803501602435600401611901565b9190853b1561000e57610e40956102b59560008094610fbe604051978896879586947f2a2d80d100000000000000000000000000000000000000000000000000000000865260048601612335565b03925af18015610fe8575b610fd5575b5091610e2a565b80610921610fe292611a79565b84610fce565b610ff0611b02565b610fc9565b908160e091031261000e5790565b503461000e576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261000e57600490813567ffffffffffffffff811161000e576110559036908401610ff5565b73ffffffffffffffffffffffffffffffffffffffff92837f0000000000000000000000000000000000000000000000000000000000000000169261109a8433146117de565b606092600095869387966040928385019960a08601995b6110bb8c886118ad565b905081101561174b578b6110da61018b610165848f61015f908d611901565b61116257906111286110f961024361023e84610238611132978e6118ad565b6111028a611a28565b61110d8c8c01611a28565b9061029a8c61029460c061028c8961023860608601866118ad565b8961113757611873565b6110b1565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8b51018b52611873565b7f01000000000000000000000000000000000000000000000000000000000000008c611191818b9e9d9e611901565b92906111c3610165877fff00000000000000000000000000000000000000000000000000000000000000968794611982565b16036113015750508a156112cd575b9061059d6112c0826112c68d9e6112b78e61129a8f8f61127d6111329c61123861023e6111fe86611a28565b9b61023861120d8a8901611a28565b946112326104c66112258561023860608e018e6118ad565b3561029460c08d01611996565b986118ad565b95611260611244611bf0565b73ffffffffffffffffffffffffffffffffffffffff909c168c52565b8a019073ffffffffffffffffffffffffffffffffffffffff169052565b87019073ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff166060850152565b80938491611873565b9e611cf9565b528c611cf9565b999850808787828b946112e08f856118ad565b6112eb929150611bd9565b6112f490611c51565b9c9d9350935050506111d2565b918982849d9e9d7f0400000000000000000000000000000000000000000000000000000000000000899561133d6101658a61015f819b89611901565b160361145f57505061023e61136f9461023873eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee9594610783946118ad565b60c087019061138661271061ffff6107a185611996565b888801858561139483611a28565b16036113a6575b506111329150611128565b6113b26113c791611a28565b926102946108348461023860608e018e6118ad565b853b1561000e57600061142d91611132948a5193849283927f7c317e0f0000000000000000000000000000000000000000000000000000000084528c84016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b0381838a5af18015611452575b1561139b578061092161144c92611a79565b3861139b565b61145a611b02565b61143a565b90919293507f0500000000000000000000000000000000000000000000000000000000000000826114976101658861015f8689611901565b16036115c357505061023e83610238610243946114dc60016109c16114e299610238896114d261271061ffff6107a160c06102439f01611996565b60608101906118ad565b8d6118ad565b906114ec88611a28565b6114f78a8a01611a28565b9061151a61150860808c018c6118ad565b61151488929892611873565b97611a0a565b3591843b1561000e5761113294600092838b61158d8e51978896879586947f42842e0e000000000000000000000000000000000000000000000000000000008652850160409194939294606082019573ffffffffffffffffffffffffffffffffffffffff80921683521660208201520152565b03925af180156115b6575b6115a3575b50611128565b806109216115b092611a79565b3861159d565b6115be611b02565b611598565b6101659193509361015f7f0600000000000000000000000000000000000000000000000000000000000000956115f894611901565b16036116e55761162661024361024361023e8f61023886916114dc6127108f6107a160c061ffff9201611996565b9061163088611a28565b9161163c8a8a01611a28565b9061164d61150860808c018c6118ad565b35916116608461023860608e018e6118ad565b3591803b1561000e576111329560008b61158d82968f51988997889687957ff242432a0000000000000000000000000000000000000000000000000000000087528601929060c0949273ffffffffffffffffffffffffffffffffffffffff80921685521660208401526040830152606082015260a06080820152600060a08201520190565b610c9e8587519182917f08c379a0000000000000000000000000000000000000000000000000000000008352820160609060208152601560208201527f494e56414c49445f5452414e534645525f54595045000000000000000000000060408201520190565b84868b858c61176a8761176160808f018f6118ad565b91905014611d1b565b61177683518214611d80565b61177c57005b7f000000000000000000000000000000000000000000000000000000000000000016803b1561000e57610ec29360008094518096819582947f0d58b1db0000000000000000000000000000000000000000000000000000000084528301611de5565b156117e557565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f494e56414c49445f43414c4c45520000000000000000000000000000000000006044820152fd5b507f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146118a1570190565b6118a9611843565b0190565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561000e570180359067ffffffffffffffff821161000e57602001918160051b3603831361000e57565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561000e570180359067ffffffffffffffff821161000e5760200191813603831361000e57565b507f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9082101561198e570190565b6118a9611952565b3561ffff8116810361000e5790565b156119ac57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f494e56414c49445f46494c4c5f50455243454e540000000000000000000000006044820152fd5b9190811015611a1b575b60051b0190565b611a23611952565b611a14565b3573ffffffffffffffffffffffffffffffffffffffff8116810361000e5790565b507f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff8111611a8d57604052565b611a95611a49565b604052565b6040810190811067ffffffffffffffff821117611a8d57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117611a8d57604052565b600091031261000e57565b506040513d6000823e3d90fd5b15611b1657565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e56414c49445f4552433732315f414d4f554e5400000000000000000000006044820152fd5b15611b7b57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f494e56414c49445f4e41544956455f544f4b454e5f41444452455353000000006044820152fd5b91908203918211611be657565b611bee611843565b565b604051906080820182811067ffffffffffffffff821117611a8d57604052565b604051906060820182811067ffffffffffffffff821117611a8d57604052565b60209067ffffffffffffffff8111611c495760051b0190565b611a23611a49565b90611c5b82611c30565b604090611c6a82519182611ab6565b8381527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611c988295611c30565b019160005b838110611caa5750505050565b60209082516080810181811067ffffffffffffffff821117611cec575b8452600081528260008183015260008583015260006060830152828601015201611c9d565b611cf4611a49565b611cc7565b6020918151811015611d0e575b60051b010190565b611d16611952565b611d06565b15611d2257565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e56414c49445f4e46545f4944535f4c454e475448000000000000000000006044820152fd5b15611d8757565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f494e56414c49445f42415443485f5045524d4954325f4c454e475448000000006044820152fd5b60208082019080835283518092528060408094019401926000905b838210611e0f57505050505090565b8451805173ffffffffffffffffffffffffffffffffffffffff90811688528185015181168886015281830151811688840152606091820151169087015260809095019493820193600190910190611e00565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000602080830191825273ffffffffffffffffffffffffffffffffffffffff948516602484015294841660448301526064808301969096529481529293611f41939290916000918291611ed7608487611ab6565b169260405194611ee686611a9a565b8786527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656488870152519082855af13d15611f66573d91611f2583611f6e565b92611f336040519485611ab6565b83523d60008785013e6120bf565b80519081611f4e57505050565b82611bee93611f61938301019101611fb7565b611fcf565b6060916120bf565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f60209267ffffffffffffffff8111611faa575b01160190565b611fb2611a49565b611fa4565b9081602091031261000e5751801515810361000e5790565b15611fd657565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b1561206157565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b919290156120e257508151156120d3575090565b6120df903b151561205a565b90565b8251909150156120f55750805190602001fd5b604051907f08c379a000000000000000000000000000000000000000000000000000000000825281602080600483015282519283602484015260005b848110612172575050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f836000604480968601015201168101030190fd5b818101830151868201604401528593508201612131565b60019067ffffffffffffffff8091169081146118a1570190565b3565ffffffffffff8116810361000e5790565b90916121cf928110156121d3575b60051b810190611901565b9091565b6121db611952565b6121c4565b156121e757565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f494e56414c49445f4e554d4245525f4f465f544f4b454e535f544f5f4150505260448201527f4f564500000000000000000000000000000000000000000000000000000000006064820152fd5b1561227257565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f494e56414c49445f4e554d4245525f4f465f5045524d49545f5349474e41545560448201527f52455300000000000000000000000000000000000000000000000000000000006064820152fd5b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0938186528686013760008582860101520116010190565b9493919492909273ffffffffffffffffffffffffffffffffffffffff80941681526060602090808284015260c08301885196828086015287518092528360e086019801926000915b8383106123ca575050505050866123b66040926120df98990151608085019073ffffffffffffffffffffffffffffffffffffffff169052565b015160a082015260408185039101526122f6565b8451805182168b52808701518216878c015260408082015165ffffffffffff908116918d019190915290830151168a8301526080909901989385019360019092019161237d565b92919261241d82611f6e565b9161242b6040519384611ab6565b82948184528183011161000e578281602093846000960137010152565b9081602091031261000e575190565b926124689061246d92953691612411565b6128ae565b9491939073ffffffffffffffffffffffffffffffffffffffff809316927f0000000000000000000000000000000000000000000000000000000000000000168314600014612726577f000000000000000000000000000000000000000000000000000000000000000060890361262f576040517f2d0335ab00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316600482015291602083602481875afa928315612622575b6000936125f2575b50833b1561000e576040517f8fcbaf0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152306024820152604481019290925260648201939093526001608482015260ff90941660a485015260c484019290925260e4830152600090829081838161010481015b03925af180156125e5575b6125d85750565b80610921611bee92611a79565b6125ed611b02565b6125d1565b61261491935060203d811161261b575b61260c8183611ab6565b810190612448565b9138612539565b503d612602565b61262a611b02565b612531565b6040517f7ecebe0000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316600482015291602083602481875afa928315612622576000936125f25750833b1561000e576040517f8fcbaf0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152306024820152604481019290925260648201939093526001608482015260ff90941660a485015260c484019290925260e48301526000908290818381610104810103925af180156125e5576125d85750565b8295939194953b1561000e576040517fd505accf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90951660048601523060248601527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6044860152606485019190915260ff909216608484015260a483019390935260c482015290600090829081838160e481016125c6565b60ff601b9116019060ff8211611be657565b156127eb57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964207369672076616c75652053000000000000000000000000006044820152fd5b1561285057565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964207369672076616c75652056000000000000000000000000006044820152fd5b90604182510361293a5760208201519060ff604160408501519401511691601b831061292a575b6129017f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08511156127e4565b61291a60ff8416601b811490811561291f575b50612849565b929190565b601c91501438612914565b91612934906127d2565b916128d5565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e67746800000000000000006044820152fd5b9061ffff1661271091828210156129c9578181029181830414901517156129bd570490565b6129c5611843565b0490565b91505090565b73ffffffffffffffffffffffffffffffffffffffff908181116129f0571690565b60046040517fc4bd89a9000000000000000000000000000000000000000000000000000000008152fdfea2646970667358221220ea3a43eb2e4b5b255ca15a36a75e9e643e478e4414082c1c78637bef169f4a5e64736f6c63430008110033000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x60806040526004361015610013575b600080fd5b60003560e01c80638c575a9f1461003b5763eb8d21161461003357600080fd5b61000e611003565b3461000e577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60408136011261000e5760043567ffffffffffffffff811161000e5761008b903690600401610ff5565b9067ffffffffffffffff6024351161000e576080906024353603011261000e576100ec73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b1633146117de565b606061010c6101056044602435016024356004016118ad565b9050611c51565b90610115611bf0565b600081526000602082015260006040820152818101906000825260005b61013f60408701876118ad565b9050811015610d5e576101b061018b6101658361015f60a08b018b611901565b90611982565b357fff000000000000000000000000000000000000000000000000000000000000001690565b7fff000000000000000000000000000000000000000000000000000000000000001690565b158015610d00575b1561039657807f02000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006102176101656102cb9561015f60a08d018d611901565b16146102fb575b6102a061025c61024361023e8461023860408d018d6118ad565b90611a0a565b611a28565b73ffffffffffffffffffffffffffffffffffffffff1690565b61026589611a28565b61027160208b01611a28565b9061029a8b61029460c061028c8961023860608601866118ad565b359201611996565b90612998565b92611e61565b6102c26102b5855167ffffffffffffffff1690565b67ffffffffffffffff1690565b6102d057611873565b610132565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8551018552611873565b61039165ffffffffffff61030e89611a28565b61032261023e8561023860408e018e6118ad565b906103316064602435016121a3565b91610387610344600460243501806118ad565b67ffffffffffffffff61036260208d015167ffffffffffffffff1690565b6103808d602061037184612189565b67ffffffffffffffff16910152565b16916121b6565b9490931691612457565b61021e565b7f01000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006103ec6101658461015f60a08c018c611901565b16148015610ca2575b156106e6577f03000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006104506101658461015f60a08c018c611901565b16146105d0575b61046c6102b5845167ffffffffffffffff1690565b156105a3575b6102cb9061059d61048288611a28565b61055561049160208b01611a28565b6105388b61051b6104d661023e896102386104cb6104c66104b98461023860608b018b6118ad565b3561029460c08a01611996565b6129cf565b9560408101906118ad565b936104fe6104e2611bf0565b73ffffffffffffffffffffffffffffffffffffffff9098168852565b73ffffffffffffffffffffffffffffffffffffffff166020870152565b73ffffffffffffffffffffffffffffffffffffffff166040850152565b73ffffffffffffffffffffffffffffffffffffffff166060830152565b67ffffffffffffffff610570875167ffffffffffffffff1690565b61058a61057c82612189565b67ffffffffffffffff168952565b16906105968289611cf9565b5286611cf9565b50611873565b92506102cb6105c86105c3856105bc60408a018a6118ad565b9050611bd9565b611c51565b939050610472565b6106b56105e761023e8361023860408b018b6118ad565b6106956105f86064602435016121a3565b6106866106356106306106156044602435016024356004016118ad565b61062a6102b58c5167ffffffffffffffff1690565b91611a0a565b6121a3565b9161065d610641611bf0565b73ffffffffffffffffffffffffffffffffffffffff9096168652565b73ffffffffffffffffffffffffffffffffffffffff602086015265ffffffffffff166040850152565b65ffffffffffff166060830152565b6106aa6102b5855167ffffffffffffffff1690565b906105968289611cf9565b506106e16106d36106ce845167ffffffffffffffff1690565b612189565b67ffffffffffffffff168352565b610457565b7f04000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000061073c6101658461015f60a08c018c611901565b160361093a5761078a73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff61078361023e8561023860408d018d6118ad565b1614611b74565b60c08601906107a861271061ffff6107a185611996565b16146119a5565b6020870173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b1673ffffffffffffffffffffffffffffffffffffffff61080183611a28565b1603610813575b506102cb91506102a0565b61081f61083b91611a28565b926102946108348461023860608d018d6118ad565b3591611996565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b163b1561000e576040517f7c317e0f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909316600484015260248301526102cb91600081806044810103818373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b165af1801561092d575b15610808578061092161092792611a79565b80611af7565b87610808565b610935611b02565b61090f565b7f05000000000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000006109906101658461015f60a08c018c611901565b1603610ae8576109ab61271061ffff6107a160c08a01611996565b6109c860016109c18361023860608b018b6118ad565b3514611b0f565b6109e261024361024361023e8461023860408c018c6118ad565b906109ec87611a28565b6109f860208901611a28565b90610a4b610a0960808b018b6118ad565b67ffffffffffffffff610a2760408a015167ffffffffffffffff1690565b610a44610a3382612189565b67ffffffffffffffff1660408c0152565b1691611a0a565b35843b1561000e576040517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316600482015292909116602483015260448201526102cb926000908290606490829084905af18015610adb575b610ac8575b506102a0565b80610921610ad592611a79565b87610ac2565b610ae3611b02565b610abd565b7f06000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000610b3e6101658461015f60a08c018c611901565b1603610c3f57610b5961271061ffff6107a160c08a01611996565b610b7361024361024361023e8461023860408c018c6118ad565b90610b7d87611a28565b91610b8a60208901611a28565b92610b9b610a0960808b018b6118ad565b35610bad8461023860608d018d6118ad565b3592803b1561000e576040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff93841660048201529590921660248601526044850152606484019190915260a06084840152600060a484018190526102cb9391829060c490829084905af18015610adb57610ac857506102a0565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e56414c49445f5452414e534645525f5459504500000000000000000000006044820152606490fd5b0390fd5b507f03000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000610cf96101658461015f60a08c018c611901565b16146103f5565b507f02000000000000000000000000000000000000000000000000000000000000007fff00000000000000000000000000000000000000000000000000000000000000610d576101658461015f60a08c018c611901565b16146101b8565b5083610e23610e0360408894610d92610d7f825167ffffffffffffffff1690565b67ffffffffffffffff87519116146121e0565b610dba610da7885167ffffffffffffffff1690565b67ffffffffffffffff8a51911614611d80565b610df4610dd2602083015167ffffffffffffffff1690565b67ffffffffffffffff610dea600460243501806118ad565b929050161461226b565b015167ffffffffffffffff1690565b67ffffffffffffffff610e1960808601866118ad565b9290501614611d1b565b8051610eef575b505051610e409067ffffffffffffffff166102b5565b610e4657005b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316803b1561000e57610ec26000929183926040519485809481937f0d58b1db00000000000000000000000000000000000000000000000000000000835260048301611de5565b03925af18015610ee2575b610ed357005b80610921610ee092611a79565b005b610eea611b02565b610ecd565b9091610f3173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba31693611a28565b65ffffffffffff610f466064602435016121a3565b610f4e611c10565b948552306020860152166040840152610f706024803501602435600401611901565b9190853b1561000e57610e40956102b59560008094610fbe604051978896879586947f2a2d80d100000000000000000000000000000000000000000000000000000000865260048601612335565b03925af18015610fe8575b610fd5575b5091610e2a565b80610921610fe292611a79565b84610fce565b610ff0611b02565b610fc9565b908160e091031261000e5790565b503461000e576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261000e57600490813567ffffffffffffffff811161000e576110559036908401610ff5565b73ffffffffffffffffffffffffffffffffffffffff92837f000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b169261109a8433146117de565b606092600095869387966040928385019960a08601995b6110bb8c886118ad565b905081101561174b578b6110da61018b610165848f61015f908d611901565b61116257906111286110f961024361023e84610238611132978e6118ad565b6111028a611a28565b61110d8c8c01611a28565b9061029a8c61029460c061028c8961023860608601866118ad565b8961113757611873565b6110b1565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8b51018b52611873565b7f01000000000000000000000000000000000000000000000000000000000000008c611191818b9e9d9e611901565b92906111c3610165877fff00000000000000000000000000000000000000000000000000000000000000968794611982565b16036113015750508a156112cd575b9061059d6112c0826112c68d9e6112b78e61129a8f8f61127d6111329c61123861023e6111fe86611a28565b9b61023861120d8a8901611a28565b946112326104c66112258561023860608e018e6118ad565b3561029460c08d01611996565b986118ad565b95611260611244611bf0565b73ffffffffffffffffffffffffffffffffffffffff909c168c52565b8a019073ffffffffffffffffffffffffffffffffffffffff169052565b87019073ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff166060850152565b80938491611873565b9e611cf9565b528c611cf9565b999850808787828b946112e08f856118ad565b6112eb929150611bd9565b6112f490611c51565b9c9d9350935050506111d2565b918982849d9e9d7f0400000000000000000000000000000000000000000000000000000000000000899561133d6101658a61015f819b89611901565b160361145f57505061023e61136f9461023873eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee9594610783946118ad565b60c087019061138661271061ffff6107a185611996565b888801858561139483611a28565b16036113a6575b506111329150611128565b6113b26113c791611a28565b926102946108348461023860608e018e6118ad565b853b1561000e57600061142d91611132948a5193849283927f7c317e0f0000000000000000000000000000000000000000000000000000000084528c84016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b0381838a5af18015611452575b1561139b578061092161144c92611a79565b3861139b565b61145a611b02565b61143a565b90919293507f0500000000000000000000000000000000000000000000000000000000000000826114976101658861015f8689611901565b16036115c357505061023e83610238610243946114dc60016109c16114e299610238896114d261271061ffff6107a160c06102439f01611996565b60608101906118ad565b8d6118ad565b906114ec88611a28565b6114f78a8a01611a28565b9061151a61150860808c018c6118ad565b61151488929892611873565b97611a0a565b3591843b1561000e5761113294600092838b61158d8e51978896879586947f42842e0e000000000000000000000000000000000000000000000000000000008652850160409194939294606082019573ffffffffffffffffffffffffffffffffffffffff80921683521660208201520152565b03925af180156115b6575b6115a3575b50611128565b806109216115b092611a79565b3861159d565b6115be611b02565b611598565b6101659193509361015f7f0600000000000000000000000000000000000000000000000000000000000000956115f894611901565b16036116e55761162661024361024361023e8f61023886916114dc6127108f6107a160c061ffff9201611996565b9061163088611a28565b9161163c8a8a01611a28565b9061164d61150860808c018c6118ad565b35916116608461023860608e018e6118ad565b3591803b1561000e576111329560008b61158d82968f51988997889687957ff242432a0000000000000000000000000000000000000000000000000000000087528601929060c0949273ffffffffffffffffffffffffffffffffffffffff80921685521660208401526040830152606082015260a06080820152600060a08201520190565b610c9e8587519182917f08c379a0000000000000000000000000000000000000000000000000000000008352820160609060208152601560208201527f494e56414c49445f5452414e534645525f54595045000000000000000000000060408201520190565b84868b858c61176a8761176160808f018f6118ad565b91905014611d1b565b61177683518214611d80565b61177c57005b7f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316803b1561000e57610ec29360008094518096819582947f0d58b1db0000000000000000000000000000000000000000000000000000000084528301611de5565b156117e557565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f494e56414c49445f43414c4c45520000000000000000000000000000000000006044820152fd5b507f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146118a1570190565b6118a9611843565b0190565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561000e570180359067ffffffffffffffff821161000e57602001918160051b3603831361000e57565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561000e570180359067ffffffffffffffff821161000e5760200191813603831361000e57565b507f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9082101561198e570190565b6118a9611952565b3561ffff8116810361000e5790565b156119ac57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f494e56414c49445f46494c4c5f50455243454e540000000000000000000000006044820152fd5b9190811015611a1b575b60051b0190565b611a23611952565b611a14565b3573ffffffffffffffffffffffffffffffffffffffff8116810361000e5790565b507f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff8111611a8d57604052565b611a95611a49565b604052565b6040810190811067ffffffffffffffff821117611a8d57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117611a8d57604052565b600091031261000e57565b506040513d6000823e3d90fd5b15611b1657565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f494e56414c49445f4552433732315f414d4f554e5400000000000000000000006044820152fd5b15611b7b57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f494e56414c49445f4e41544956455f544f4b454e5f41444452455353000000006044820152fd5b91908203918211611be657565b611bee611843565b565b604051906080820182811067ffffffffffffffff821117611a8d57604052565b604051906060820182811067ffffffffffffffff821117611a8d57604052565b60209067ffffffffffffffff8111611c495760051b0190565b611a23611a49565b90611c5b82611c30565b604090611c6a82519182611ab6565b8381527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611c988295611c30565b019160005b838110611caa5750505050565b60209082516080810181811067ffffffffffffffff821117611cec575b8452600081528260008183015260008583015260006060830152828601015201611c9d565b611cf4611a49565b611cc7565b6020918151811015611d0e575b60051b010190565b611d16611952565b611d06565b15611d2257565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f494e56414c49445f4e46545f4944535f4c454e475448000000000000000000006044820152fd5b15611d8757565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f494e56414c49445f42415443485f5045524d4954325f4c454e475448000000006044820152fd5b60208082019080835283518092528060408094019401926000905b838210611e0f57505050505090565b8451805173ffffffffffffffffffffffffffffffffffffffff90811688528185015181168886015281830151811688840152606091820151169087015260809095019493820193600190910190611e00565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000602080830191825273ffffffffffffffffffffffffffffffffffffffff948516602484015294841660448301526064808301969096529481529293611f41939290916000918291611ed7608487611ab6565b169260405194611ee686611a9a565b8786527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656488870152519082855af13d15611f66573d91611f2583611f6e565b92611f336040519485611ab6565b83523d60008785013e6120bf565b80519081611f4e57505050565b82611bee93611f61938301019101611fb7565b611fcf565b6060916120bf565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f60209267ffffffffffffffff8111611faa575b01160190565b611fb2611a49565b611fa4565b9081602091031261000e5751801515810361000e5790565b15611fd657565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b1561206157565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b919290156120e257508151156120d3575090565b6120df903b151561205a565b90565b8251909150156120f55750805190602001fd5b604051907f08c379a000000000000000000000000000000000000000000000000000000000825281602080600483015282519283602484015260005b848110612172575050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f836000604480968601015201168101030190fd5b818101830151868201604401528593508201612131565b60019067ffffffffffffffff8091169081146118a1570190565b3565ffffffffffff8116810361000e5790565b90916121cf928110156121d3575b60051b810190611901565b9091565b6121db611952565b6121c4565b156121e757565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f494e56414c49445f4e554d4245525f4f465f544f4b454e535f544f5f4150505260448201527f4f564500000000000000000000000000000000000000000000000000000000006064820152fd5b1561227257565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f494e56414c49445f4e554d4245525f4f465f5045524d49545f5349474e41545560448201527f52455300000000000000000000000000000000000000000000000000000000006064820152fd5b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0938186528686013760008582860101520116010190565b9493919492909273ffffffffffffffffffffffffffffffffffffffff80941681526060602090808284015260c08301885196828086015287518092528360e086019801926000915b8383106123ca575050505050866123b66040926120df98990151608085019073ffffffffffffffffffffffffffffffffffffffff169052565b015160a082015260408185039101526122f6565b8451805182168b52808701518216878c015260408082015165ffffffffffff908116918d019190915290830151168a8301526080909901989385019360019092019161237d565b92919261241d82611f6e565b9161242b6040519384611ab6565b82948184528183011161000e578281602093846000960137010152565b9081602091031261000e575190565b926124689061246d92953691612411565b6128ae565b9491939073ffffffffffffffffffffffffffffffffffffffff809316927f0000000000000000000000000000000000000000000000000000000000000000168314600014612726577f0000000000000000000000000000000000000000000000000000000000028c5860890361262f576040517f2d0335ab00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316600482015291602083602481875afa928315612622575b6000936125f2575b50833b1561000e576040517f8fcbaf0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152306024820152604481019290925260648201939093526001608482015260ff90941660a485015260c484019290925260e4830152600090829081838161010481015b03925af180156125e5575b6125d85750565b80610921611bee92611a79565b6125ed611b02565b6125d1565b61261491935060203d811161261b575b61260c8183611ab6565b810190612448565b9138612539565b503d612602565b61262a611b02565b612531565b6040517f7ecebe0000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316600482015291602083602481875afa928315612622576000936125f25750833b1561000e576040517f8fcbaf0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152306024820152604481019290925260648201939093526001608482015260ff90941660a485015260c484019290925260e48301526000908290818381610104810103925af180156125e5576125d85750565b8295939194953b1561000e576040517fd505accf00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90951660048601523060248601527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6044860152606485019190915260ff909216608484015260a483019390935260c482015290600090829081838160e481016125c6565b60ff601b9116019060ff8211611be657565b156127eb57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964207369672076616c75652053000000000000000000000000006044820152fd5b1561285057565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e76616c6964207369672076616c75652056000000000000000000000000006044820152fd5b90604182510361293a5760208201519060ff604160408501519401511691601b831061292a575b6129017f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08511156127e4565b61291a60ff8416601b811490811561291f575b50612849565b929190565b601c91501438612914565b91612934906127d2565b916128d5565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e67746800000000000000006044820152fd5b9061ffff1661271091828210156129c9578181029181830414901517156129bd570490565b6129c5611843565b0490565b91505090565b73ffffffffffffffffffffffffffffffffffffffff908181116129f0571690565b60046040517fc4bd89a9000000000000000000000000000000000000000000000000000000008152fdfea2646970667358221220ea3a43eb2e4b5b255ca15a36a75e9e643e478e4414082c1c78637bef169f4a5e64736f6c63430008110033

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

000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _operator (address): 0xbEbEbEb035351f58602E0C1C8B59ECBfF5d5f47b
Arg [1] : _permit2 (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
Arg [2] : _daiAddress (address): 0x0000000000000000000000000000000000000000

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000bebebeb035351f58602e0c1c8b59ecbff5d5f47b
Arg [1] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000


Block Transaction Gas Used Reward
view all blocks sequenced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
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  ]

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.