APE Price: $0.68 (-3.16%)

Contract

0x52aB06B7a6EefAF50587cDb7D896A999970067BE

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
EarlyUnwindModule

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion
File 1 of 12 : EarlyUnwindModule.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

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

import "../interfaces/core/IModule.sol";
import "../helpers/Utils.sol";
import "../thirdparty/opensea/ISeaport.sol";
import "../core/Lockers.sol" as Lockers;
import "../main/payment-plan/PaymentPlanTypes.sol";
import { AddressProvider } from "../main/AddressProvider.sol";

/// @title Cyan Wallet EarlyUnwindModule Module for OpenSea
/// @author Bulgantamir Gankhuyag - <[email protected]>
/// @author Naranbayar Uuganbayar - <[email protected]>
/// @author Munkhzul Boldbaatar
contract EarlyUnwindModule is IModule {
    AddressProvider private constant addressProvider = AddressProvider(0xCF9A19D879769aDaE5e4f31503AAECDa82568E55);

    /// @inheritdoc IModule
    function handleTransaction(
        address collection,
        uint256 value,
        bytes calldata data
    ) public payable override returns (bytes memory) {
        return Utils._execute(collection, value, data);
    }

    /// @notice Allows operators to sell the locked token for Opensea offer.
    ///     Note: Can only sell if token is locked.
    function earlyUnwindOpensea(
        uint256 payAmount,
        uint256 sellPrice,
        Item calldata item,
        bytes calldata osData
    ) external {
        require(item.itemType == 1, "Item type must be ERC721");
        IERC20 currency = IERC20(addressProvider.addresses("WETH"));
        IERC721 collection = IERC721(item.contractAddress);

        require(!Lockers.isLockedByApePlan(item.contractAddress, item.tokenId), "Token has ape lock");
        require(collection.ownerOf(item.tokenId) == address(this), "Token is not owned by the wallet");

        uint256 userBalance = currency.balanceOf(address(this));
        {
            collection.approve(addressProvider.addresses("SEAPORT_CONDUIT"), item.tokenId);
            Utils._execute(addressProvider.addresses("SEAPORT_1_5"), 0, osData);
        }
        require(!Lockers.isLockedByApePlan(item.contractAddress, item.tokenId), "Token has ape lock");
        require(userBalance + sellPrice == currency.balanceOf(address(this)), "Insufficient balance");
        require(collection.ownerOf(item.tokenId) != address(this), "Token is owned by the wallet");
        currency.approve(msg.sender, payAmount);
    }

    /// @notice Allows operators to sell the locked token for Cyan offer.
    ///     Note: Can only sell if token is locked.
    function earlyUnwindCyan(uint256 payAmount, address currencyAddress) external {
        IERC20 currency = IERC20(currencyAddress == address(0) ? addressProvider.addresses("WETH") : currencyAddress);
        currency.approve(msg.sender, payAmount);
    }
}

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

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

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

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

File 3 of 12 : IERC20.sol
// 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);
}

File 4 of 12 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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);
}

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

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 6 of 12 : IERC165.sol
// 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);
}

File 7 of 12 : Lockers.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

// keccak256("wallet.YugaModule.lockedApe")
bytes32 constant APE_PLAN_LOCKER_SLOT = 0x010881fa8a1edce184936a8e4e08060bba49cb5145c9b396e6e80c0c6b0e1269;

// keccak256("wallet.ERC721Module.lockedERC721")
bytes32 constant CYAN_PLAN_LOCKER_SLOT_ERC721 = 0x25888debd3e1e584ccaebe1162c7763ec457a94078c5d0d9a1d32a926ff9973c;

// keccak256("wallet.ERC1155Module.lockedERC1155")
bytes32 constant CYAN_PLAN_LOCKER_SLOT_ERC1155 = 0xdcc609ac7fc3b6a216ce1445788736c9dbe88a58b25a13af71623e6da931efa0;

// keccak256("wallet.CryptoPunksModule.lockedCryptoPunks")
bytes32 constant CRYPTO_PUNKS_PLAN_LOCKER_SLOT = 0x67ae504a494a1bd5120fdcd8b3565de046d61ac7bb95311090f1976ec179a99a;

struct ApePlanLocker {
    /// @notice Map of the locked tokens.
    ///     Note: Collection Address => Token ID => Lock state
    mapping(address => mapping(uint256 => uint8)) tokens;
}

struct CyanPlanLockerERC721 {
    /// @notice Locked tokens count of the collection.
    ///     Note: Collection Address => Number of locked tokens
    mapping(address => uint256) count;
    /// @notice Map of the locked tokens.
    ///     Note: Collection Address => Token ID => isLocked
    mapping(address => mapping(uint256 => bool)) tokens;
}

struct CyanPlanLockerCryptoPunks {
    /// @notice Locked tokens count of the CryptoPunks.
    ///     Note: Number of locked tokens
    uint256 count;
    /// @notice Map of the locked tokens.
    ///     Note: CryptoPunk index => isLocked
    mapping(uint256 => bool) tokens;
}

struct CyanPlanLockerERC1155 {
    /// @notice Map of the locked ERC1155 tokens.
    ///     Note: Collection Address => Token ID => amount
    mapping(address => mapping(uint256 => uint256)) tokens;
}

/// @notice Checks whether the NFT is locked or not. This method checks both ERC721 lock and ApePlan lock.
/// @param collection Collection address.
/// @param tokenId Token ID.
/// @return isLocked Whether the token is locked or not.
function isLockedERC721(address collection, uint256 tokenId) view returns (bool) {
    return isLockedByCyanPlanERC721(collection, tokenId) || isLockedByApePlan(collection, tokenId);
}

/// @notice Checks whether the ERC721 token is locked or not.
/// @param collection Collection address.
/// @param tokenId Token ID.
/// @return isLocked Whether the token is locked or not.
function isLockedByCyanPlanERC721(address collection, uint256 tokenId) view returns (bool) {
    return getCyanPlanLockerERC721().tokens[collection][tokenId];
}

/// @notice Checks whether the CryptoPunks token is locked or not.
/// @param tokenId Token ID.
/// @return isLocked Whether the token is locked or not.
function isLockedByCryptoPunkPlan(uint256 tokenId) view returns (bool) {
    return getCyanPlanLockerCryptoPunks().tokens[tokenId];
}

/// @notice Checks whether the BAYC, MAYC or BAKC token is locked or not.
/// @param collection Ape collection address.
/// @param tokenId Token ID.
/// @return isLocked Whether the token is ape locked or not.
function isLockedByApePlan(address collection, uint256 tokenId) view returns (bool) {
    return getApePlanLocker().tokens[collection][tokenId] != 0;
}

/// @notice Returns amount of locked ERC1155Token items.
/// @param collection Collection address.
/// @param tokenId Token ID.
/// @return isLocked Whether the token is locked or not.
function getLockedERC1155Amount(address collection, uint256 tokenId) view returns (uint256) {
    return getCyanPlanLockerERC1155().tokens[collection][tokenId];
}

/// @notice Returns ape lock state.
/// @param collection Ape collection address.
/// @param tokenId Token ID.
/// @return Ape locks state.
function getApeLockState(address collection, uint256 tokenId) view returns (uint8) {
    return getApePlanLocker().tokens[collection][tokenId];
}

/// @dev Returns the map of the locked ERC721 tokens.
/// @return result CyanPlanLockerERC721 struct of the locked tokens.
///     Note: Collection Address => Token ID => isLocked
function getCyanPlanLockerERC721() pure returns (CyanPlanLockerERC721 storage result) {
    assembly {
        result.slot := CYAN_PLAN_LOCKER_SLOT_ERC721
    }
}

/// @dev Returns the map of the locked ERC1155 tokens.
/// @return result CyanPlanERC1155Locker struct of the locked tokens.
///     Note: Collection Address => Token ID => locked amount
function getCyanPlanLockerERC1155() pure returns (CyanPlanLockerERC1155 storage result) {
    assembly {
        result.slot := CYAN_PLAN_LOCKER_SLOT_ERC1155
    }
}

/// @dev Returns the map of the locked Crypto Punks.
/// @return result CryptoPunksPlanLocker struct of the locked tokens.
///     Note: CryptoPunk index => isLocked
function getCyanPlanLockerCryptoPunks() pure returns (CyanPlanLockerCryptoPunks storage result) {
    assembly {
        result.slot := CRYPTO_PUNKS_PLAN_LOCKER_SLOT
    }
}

/// @dev Returns the map of the locked tokens.
/// @return result ApePlanLocker struct of the locked tokens.
///     Note: Collection Address => Token ID => Lock state
function getApePlanLocker() pure returns (ApePlanLocker storage result) {
    assembly {
        result.slot := APE_PLAN_LOCKER_SLOT
    }
}

File 8 of 12 : Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

library Utils {
    /// @notice Executes a transaction to the given address.
    /// @param to Target address.
    /// @param value Native token value to be sent to the address.
    /// @param data Data to be sent to the address.
    /// @return result Result of the transaciton.
    function _execute(
        address to,
        uint256 value,
        bytes memory data
    ) internal returns (bytes memory result) {
        assembly {
            let success := call(gas(), to, value, add(data, 0x20), mload(data), 0, 0)

            mstore(result, returndatasize())
            returndatacopy(add(result, 0x20), 0, returndatasize())

            if eq(success, 0) {
                revert(add(result, 0x20), returndatasize())
            }
        }
    }

    /// @notice Recover signer address from signature.
    /// @param signedHash Arbitrary length data signed on the behalf of the wallet.
    /// @param signature Signature byte array associated with signedHash.
    /// @return Recovered signer address.
    function recoverSigner(bytes32 signedHash, bytes memory signature) internal pure returns (address) {
        uint8 v;
        bytes32 r;
        bytes32 s;
        // we jump 32 (0x20) as the first slot of bytes contains the length
        // we jump 65 (0x41) per signature
        // for v we load 32 bytes ending with v (the first 31 come from s) then apply a mask
        assembly {
            r := mload(add(signature, 0x20))
            s := mload(add(signature, 0x40))
            v := byte(0, mload(add(signature, 0x60)))
        }
        require(v == 27 || v == 28, "Bad v value in signature.");

        address recoveredAddress = ecrecover(signedHash, v, r, s);
        require(recoveredAddress != address(0), "ecrecover returned 0.");
        return recoveredAddress;
    }

    /// @notice Helper method to parse the function selector from data.
    /// @param data Any data to be parsed, mostly calldata of transaction.
    /// @return result Parsed function sighash.
    function parseFunctionSelector(bytes memory data) internal pure returns (bytes4 result) {
        require(data.length >= 4, "Invalid data.");
        assembly {
            result := mload(add(data, 0x20))
        }
    }

    /// @notice Parse uint256 from given data.
    /// @param data Any data to be parsed, mostly calldata of transaction.
    /// @param position Position in the data.
    /// @return result Uint256 parsed from given data.
    function getUint256At(bytes memory data, uint8 position) internal pure returns (uint256 result) {
        assembly {
            result := mload(add(data, add(position, 0x20)))
        }
    }
}

File 9 of 12 : IModule.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface IModule {
    /// @notice Executes given transaction data to given address.
    /// @param to Target contract address.
    /// @param value Value of the given transaction.
    /// @param data Calldata of the transaction.
    /// @return Result of the execution.
    function handleTransaction(
        address to,
        uint256 value,
        bytes calldata data
    ) external payable returns (bytes memory);
}

File 10 of 12 : AddressProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

/// @title Cyan AddressProvider contract
/// @author Bulgantamir Gankhuyag - <[email protected]>
/// @author Naranbayar Uuganbayar - <[email protected]>
contract AddressProvider is Ownable {
    error AddressNotFound(bytes32 id);

    event AddressSet(bytes32 id, address newAddress);

    mapping(bytes32 => address) public addresses;

    constructor(address owner) {
        transferOwnership(owner);
    }

    // @dev Sets an address for an id replacing the address saved in the addresses map
    // @param id The id
    // @param newAddress The address to set
    function setAddress(bytes32 id, address newAddress) external onlyOwner {
        addresses[id] = newAddress;
        emit AddressSet(id, newAddress);
    }
}

File 11 of 12 : PaymentPlanTypes.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

// DataTypes
enum PawnCreateType {
    REGULAR,
    BEND_DAO,
    REFINANCE
}
enum PaymentPlanStatus {
    BNPL_CREATED,
    BNPL_FUNDED,
    BNPL_ACTIVE,
    BNPL_DEFAULTED,
    BNPL_REJECTED,
    BNPL_COMPLETED,
    BNPL_LIQUIDATED,
    PAWN_ACTIVE,
    PAWN_DEFAULTED,
    PAWN_COMPLETED,
    PAWN_LIQUIDATED
}
struct Plan {
    uint256 amount;
    uint32 downPaymentPercent;
    uint32 interestRate;
    uint32 serviceFeeRate;
    uint32 term;
    uint8 totalNumberOfPayments;
    uint8 counterPaidPayments;
    uint8 autoRepayStatus;
}
struct PaymentPlan {
    Plan plan;
    uint256 createdDate;
    address cyanWalletAddress;
    PaymentPlanStatus status;
}

struct Item {
    uint256 amount;
    uint256 tokenId;
    address contractAddress;
    address cyanVaultAddress;
    // 1 -> ERC721
    // 2 -> ERC1155
    // 3 -> CryptoPunks
    uint8 itemType;
}

struct PaymentAmountInfo {
    uint256 loanAmount;
    uint256 interestAmount;
    uint256 serviceAmount;
}

// Errors
error InvalidSender();
error InvalidBlockNumber();
error InvalidSignature();
error InvalidServiceFeeRate();
error InvalidTokenPrice();
error InvalidInterestRate();
error InvalidDownPaymentPercent();
error InvalidDownPayment();
error InvalidAmount();
error InvalidTerm();
error InvalidPaidCount();
error InvalidStage();
error InvalidAddress();
error InvalidAutoRepaymentDate();
error InvalidAutoRepaymentStatus();
error InvalidTotalNumberOfPayments();
error InvalidReviveDate();
error InvalidItem();
error InvalidBaseDiscountRate();
error InvalidApeCoinPlan();
error InvalidBendDaoPlan();
error InvalidCurrency();
error InvalidCyanBuyer();
error InvalidSelector();

error EthTransferFailed();

error PaymentPlanAlreadyExists();
error PaymentPlanNotFound();

File 12 of 12 : ISeaport.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/// @title Seaport Contract interface
interface ISeaport {
    enum OrderType {
        FULL_OPEN,
        PARTIAL_OPEN,
        FULL_RESTRICTED,
        PARTIAL_RESTRICTED,
        CONTRACT
    }
    enum ItemType {
        NATIVE,
        ERC20,
        ERC721,
        ERC1155,
        ERC721_WITH_CRITERIA,
        ERC1155_WITH_CRITERIA
    }
    enum Side {
        OFFER,
        CONSIDERATION
    }

    struct OfferItem {
        ItemType itemType;
        address token;
        uint256 identifierOrCriteria;
        uint256 startAmount;
        uint256 endAmount;
    }
    struct ConsiderationItem {
        ItemType itemType;
        address token;
        uint256 identifierOrCriteria;
        uint256 startAmount;
        uint256 endAmount;
        address payable recipient;
    }
    struct OrderParameters {
        address offerer;
        address zone;
        OfferItem[] offer;
        ConsiderationItem[] consideration;
        OrderType orderType;
        uint256 startTime;
        uint256 endTime;
        bytes32 zoneHash;
        uint256 salt;
        bytes32 conduitKey;
        uint256 totalOriginalConsiderationItems;
    }
    struct FulfillmentComponent {
        uint256 orderIndex;
        uint256 itemIndex;
    }
    struct Fulfillment {
        FulfillmentComponent[] offerComponents;
        FulfillmentComponent[] considerationComponents;
    }
    struct CriteriaResolver {
        uint256 orderIndex;
        Side side;
        uint256 index;
        uint256 identifier;
        bytes32[] criteriaProof;
    }
    struct AdvancedOrder {
        OrderParameters parameters;
        uint120 numerator;
        uint120 denominator;
        bytes signature;
        bytes extraData;
    }
    struct ReceivedItem {
        ItemType itemType;
        address token;
        uint256 identifier;
        uint256 amount;
        address payable recipient;
    }
    struct Execution {
        ReceivedItem item;
        address offerer;
        bytes32 conduitKey;
    }

    struct OfferData {
        AdvancedOrder[] orders;
        CriteriaResolver[] criteriaResolvers;
        Fulfillment[] fulfillments;
        address recipient;
    }

    function matchAdvancedOrders(
        AdvancedOrder[] calldata orders,
        CriteriaResolver[] calldata criteriaResolvers,
        Fulfillment[] calldata fulfillments,
        address recipient
    ) external payable returns (Execution[] calldata executions);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"payAmount","type":"uint256"},{"internalType":"address","name":"currencyAddress","type":"address"}],"name":"earlyUnwindCyan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"payAmount","type":"uint256"},{"internalType":"uint256","name":"sellPrice","type":"uint256"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"address","name":"cyanVaultAddress","type":"address"},{"internalType":"uint8","name":"itemType","type":"uint8"}],"internalType":"struct Item","name":"item","type":"tuple"},{"internalType":"bytes","name":"osData","type":"bytes"}],"name":"earlyUnwindOpensea","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"handleTransaction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"}]

608060405234801561001057600080fd5b50610bea806100206000396000f3fe6080604052600436106100345760003560e01c806335d381d61461003957806373f8e3281461005b578063ab6a377b1461007b575b600080fd5b34801561004557600080fd5b5061005961005436600461095c565b6100a4565b005b34801561006757600080fd5b506100596100763660046109d5565b6101af565b61008e610089366004610a4a565b61087b565b60405161009b9190610aa6565b60405180910390f35b60006001600160a01b038216156100bb5781610135565b60405163699f200f60e01b8152630ae8aa8960e31b600482015273cf9a19d879769adae5e4f31503aaecda82568e559063699f200f90602401602060405180830381865afa158015610111573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101359190610af4565b60405163095ea7b360e01b8152336004820152602481018590529091506001600160a01b0382169063095ea7b3906044016020604051808303816000875af1158015610185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a99190610b18565b50505050565b6101bf60a0840160808501610b3a565b60ff166001146102165760405162461bcd60e51b815260206004820152601860248201527f4974656d2074797065206d75737420626520455243373231000000000000000060448201526064015b60405180910390fd5b60405163699f200f60e01b8152630ae8aa8960e31b600482015260009073cf9a19d879769adae5e4f31503aaecda82568e559063699f200f90602401602060405180830381865afa15801561026f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102939190610af4565b905060006102a76060860160408701610b5d565b90506102c66102bc6060870160408801610b5d565b86602001356108c7565b156103085760405162461bcd60e51b8152602060048201526012602482015271546f6b656e2068617320617065206c6f636b60701b604482015260640161020d565b6040516331a9108f60e11b81526020860135600482015230906001600160a01b03831690636352211e90602401602060405180830381865afa158015610352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103769190610af4565b6001600160a01b0316146103cc5760405162461bcd60e51b815260206004820181905260248201527f546f6b656e206973206e6f74206f776e6564206279207468652077616c6c6574604482015260640161020d565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015610413573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104379190610b7a565b60405163699f200f60e01b81527f534541504f52545f434f4e44554954000000000000000000000000000000000060048201529091506001600160a01b0383169063095ea7b39073cf9a19d879769adae5e4f31503aaecda82568e559063699f200f90602401602060405180830381865afa1580156104ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104de9190610af4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b03909116600482015260208901356024820152604401600060405180830381600087803b15801561054157600080fd5b505af1158015610555573d6000803e3d6000fd5b505060405163699f200f60e01b81526a534541504f52545f315f3560a81b600482015261061c925073cf9a19d879769adae5e4f31503aaecda82568e55915063699f200f90602401602060405180830381865afa1580156105ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105de9190610af4565b600087878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061091692505050565b5061063a6106306060880160408901610b5d565b87602001356108c7565b1561067c5760405162461bcd60e51b8152602060048201526012602482015271546f6b656e2068617320617065206c6f636b60701b604482015260640161020d565b6040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e49190610b7a565b6106ee8883610b93565b1461073b5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015260640161020d565b6040516331a9108f60e11b81526020870135600482015230906001600160a01b03841690636352211e90602401602060405180830381865afa158015610785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a99190610af4565b6001600160a01b0316036107ff5760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e206973206f776e6564206279207468652077616c6c657400000000604482015260640161020d565b60405163095ea7b360e01b8152336004820152602481018990526001600160a01b0384169063095ea7b3906044016020604051808303816000875af115801561084c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108709190610b18565b505050505050505050565b60606108be858585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061091692505050565b95945050505050565b6001600160a01b03821660009081527f010881fa8a1edce184936a8e4e08060bba49cb5145c9b396e6e80c0c6b0e12696020908152604080832084845290915290205460ff1615155b92915050565b606060008083516020850186885af13d82523d6000602084013e8061093c573d60208301fd5b509392505050565b6001600160a01b038116811461095957600080fd5b50565b6000806040838503121561096f57600080fd5b82359150602083013561098181610944565b809150509250929050565b60008083601f84011261099e57600080fd5b50813567ffffffffffffffff8111156109b657600080fd5b6020830191508360208285010111156109ce57600080fd5b9250929050565b60008060008060008587036101008112156109ef57600080fd5b863595506020870135945060a0603f1982011215610a0c57600080fd5b5060408601925060e086013567ffffffffffffffff811115610a2d57600080fd5b610a398882890161098c565b969995985093965092949392505050565b60008060008060608587031215610a6057600080fd5b8435610a6b81610944565b935060208501359250604085013567ffffffffffffffff811115610a8e57600080fd5b610a9a8782880161098c565b95989497509550505050565b600060208083528351808285015260005b81811015610ad357858101830151858201604001528201610ab7565b506000604082860101526040601f19601f8301168501019250505092915050565b600060208284031215610b0657600080fd5b8151610b1181610944565b9392505050565b600060208284031215610b2a57600080fd5b81518015158114610b1157600080fd5b600060208284031215610b4c57600080fd5b813560ff81168114610b1157600080fd5b600060208284031215610b6f57600080fd5b8135610b1181610944565b600060208284031215610b8c57600080fd5b5051919050565b8082018082111561091057634e487b7160e01b600052601160045260246000fdfea2646970667358221220cdc79ef77f3e9d81198304a1db7850664c879634e09b9a02a40efe9ae91555f464736f6c63430008130033

Deployed Bytecode

0x6080604052600436106100345760003560e01c806335d381d61461003957806373f8e3281461005b578063ab6a377b1461007b575b600080fd5b34801561004557600080fd5b5061005961005436600461095c565b6100a4565b005b34801561006757600080fd5b506100596100763660046109d5565b6101af565b61008e610089366004610a4a565b61087b565b60405161009b9190610aa6565b60405180910390f35b60006001600160a01b038216156100bb5781610135565b60405163699f200f60e01b8152630ae8aa8960e31b600482015273cf9a19d879769adae5e4f31503aaecda82568e559063699f200f90602401602060405180830381865afa158015610111573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101359190610af4565b60405163095ea7b360e01b8152336004820152602481018590529091506001600160a01b0382169063095ea7b3906044016020604051808303816000875af1158015610185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a99190610b18565b50505050565b6101bf60a0840160808501610b3a565b60ff166001146102165760405162461bcd60e51b815260206004820152601860248201527f4974656d2074797065206d75737420626520455243373231000000000000000060448201526064015b60405180910390fd5b60405163699f200f60e01b8152630ae8aa8960e31b600482015260009073cf9a19d879769adae5e4f31503aaecda82568e559063699f200f90602401602060405180830381865afa15801561026f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102939190610af4565b905060006102a76060860160408701610b5d565b90506102c66102bc6060870160408801610b5d565b86602001356108c7565b156103085760405162461bcd60e51b8152602060048201526012602482015271546f6b656e2068617320617065206c6f636b60701b604482015260640161020d565b6040516331a9108f60e11b81526020860135600482015230906001600160a01b03831690636352211e90602401602060405180830381865afa158015610352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103769190610af4565b6001600160a01b0316146103cc5760405162461bcd60e51b815260206004820181905260248201527f546f6b656e206973206e6f74206f776e6564206279207468652077616c6c6574604482015260640161020d565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015610413573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104379190610b7a565b60405163699f200f60e01b81527f534541504f52545f434f4e44554954000000000000000000000000000000000060048201529091506001600160a01b0383169063095ea7b39073cf9a19d879769adae5e4f31503aaecda82568e559063699f200f90602401602060405180830381865afa1580156104ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104de9190610af4565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b03909116600482015260208901356024820152604401600060405180830381600087803b15801561054157600080fd5b505af1158015610555573d6000803e3d6000fd5b505060405163699f200f60e01b81526a534541504f52545f315f3560a81b600482015261061c925073cf9a19d879769adae5e4f31503aaecda82568e55915063699f200f90602401602060405180830381865afa1580156105ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105de9190610af4565b600087878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061091692505050565b5061063a6106306060880160408901610b5d565b87602001356108c7565b1561067c5760405162461bcd60e51b8152602060048201526012602482015271546f6b656e2068617320617065206c6f636b60701b604482015260640161020d565b6040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa1580156106c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e49190610b7a565b6106ee8883610b93565b1461073b5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742062616c616e6365000000000000000000000000604482015260640161020d565b6040516331a9108f60e11b81526020870135600482015230906001600160a01b03841690636352211e90602401602060405180830381865afa158015610785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a99190610af4565b6001600160a01b0316036107ff5760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e206973206f776e6564206279207468652077616c6c657400000000604482015260640161020d565b60405163095ea7b360e01b8152336004820152602481018990526001600160a01b0384169063095ea7b3906044016020604051808303816000875af115801561084c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108709190610b18565b505050505050505050565b60606108be858585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061091692505050565b95945050505050565b6001600160a01b03821660009081527f010881fa8a1edce184936a8e4e08060bba49cb5145c9b396e6e80c0c6b0e12696020908152604080832084845290915290205460ff1615155b92915050565b606060008083516020850186885af13d82523d6000602084013e8061093c573d60208301fd5b509392505050565b6001600160a01b038116811461095957600080fd5b50565b6000806040838503121561096f57600080fd5b82359150602083013561098181610944565b809150509250929050565b60008083601f84011261099e57600080fd5b50813567ffffffffffffffff8111156109b657600080fd5b6020830191508360208285010111156109ce57600080fd5b9250929050565b60008060008060008587036101008112156109ef57600080fd5b863595506020870135945060a0603f1982011215610a0c57600080fd5b5060408601925060e086013567ffffffffffffffff811115610a2d57600080fd5b610a398882890161098c565b969995985093965092949392505050565b60008060008060608587031215610a6057600080fd5b8435610a6b81610944565b935060208501359250604085013567ffffffffffffffff811115610a8e57600080fd5b610a9a8782880161098c565b95989497509550505050565b600060208083528351808285015260005b81811015610ad357858101830151858201604001528201610ab7565b506000604082860101526040601f19601f8301168501019250505092915050565b600060208284031215610b0657600080fd5b8151610b1181610944565b9392505050565b600060208284031215610b2a57600080fd5b81518015158114610b1157600080fd5b600060208284031215610b4c57600080fd5b813560ff81168114610b1157600080fd5b600060208284031215610b6f57600080fd5b8135610b1181610944565b600060208284031215610b8c57600080fd5b5051919050565b8082018082111561091057634e487b7160e01b600052601160045260246000fdfea2646970667358221220cdc79ef77f3e9d81198304a1db7850664c879634e09b9a02a40efe9ae91555f464736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.