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

import { TradeInfo, Assets, Fees } from "../utils/DataTypes.sol";

/// @title NF3 OTC Broking Protocol Interface
/// @author NF3 Exchange
/// @dev This interface defines all the functions related to broking features of the platform.

interface IBrokers {
    /// -----------------------------------------------------------------------
    /// Errors
    /// -----------------------------------------------------------------------

    enum BrokersErrorCodes {
        CALLER_IS_NOT_BROKER,
        ZERO_ADDRESS,
        TIME_HAS_EXPIRED,
        INVALID_KITTY,
        INVALID_PUNK,
        INVALID_NONCE,
        INVALID_ASSET_TYPE,
        INSUFFICIENT_TOKEN_AMOUNT_FOR_FEE_DEDUCTION,
        FEE_TOKEN_MISSING_FROM_CONTRA
    }

    error BrokersError(BrokersErrorCodes code);

    /// -----------------------------------------------------------------------
    /// Events
    /// -----------------------------------------------------------------------

    /// @dev Emits when swap has done.
    /// @param tradeInfo Details of the trade setup by broker
    /// @param broker Broker address
    event BrokerSwapped(TradeInfo tradeInfo, address indexed broker);

    /// @dev Emits when first user's assets go to second user's asset as well as the fee.
    /// @param assets Asset that got transferred
    /// @param from Transferred assets from this user
    /// @param to Transferred assets to this user
    event AssetsTransferred(Assets assets, address from, address to);

    /// @dev Emits when fee has transferred to the broker and NF3 platform.
    /// @param from User from which fees got transferred
    /// @param fees Fee details that got transferred
    event FeeTransferred(address from, Fees fees);

    /// @dev Emits when new broker has registered.
    /// @param broker Broker address
    event BrokerRegistered(address indexed broker);

    /// @dev Emits when status has changed.
    /// @param owner User whose nonce is updated
    /// @param nonce Value of updated nonce
    event NonceSet(address owner, uint256 nonce);

    /// -----------------------------------------------------------------------
    /// Broker Action
    /// -----------------------------------------------------------------------

    /// @dev Broker swap funtion.
    /// @dev This function is called by only broker.
    /// @param tradeInfo Details of the trade setup by broker
    /// @param makerSignature Trade maker's signature
    /// @param makerContra Maker's contra option
    /// @param takerSignature Trade taker's signature
    /// @param takerContra Taker's contra option
    function swap(
        TradeInfo calldata tradeInfo,
        bytes memory makerSignature,
        bool makerContra,
        bytes memory takerSignature,
        bool takerContra
    ) external;
}
[{"inputs":[{"internalType":"enum BrokersSignatureUtils.BrokerSignatureUtilsErrorCodes","name":"code","type":"uint8"}],"name":"BrokerSignatureUtilsError","type":"error"},{"inputs":[{"internalType":"enum IBrokers.BrokersErrorCodes","name":"code","type":"uint8"}],"name":"BrokersError","type":"error"},{"anonymous":false,"inputs":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct AssetData[]","name":"assets","type":"tuple[]"}],"indexed":false,"internalType":"struct Assets","name":"assets","type":"tuple"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"AssetsTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"broker","type":"address"}],"name":"BrokerRegistered","type":"event"},{"anonymous":false,"inputs":[{"components":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct AssetData[]","name":"assets","type":"tuple[]"}],"internalType":"struct Assets","name":"makerAssets","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct AssetData[]","name":"assets","type":"tuple[]"}],"internalType":"struct Assets","name":"takerAssets","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"broker","type":"address"},{"internalType":"address","name":"platform","type":"address"},{"internalType":"uint256","name":"brokerAmount","type":"uint256"},{"internalType":"uint256","name":"platformAmount","type":"uint256"}],"internalType":"struct Fees","name":"makerFees","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"broker","type":"address"},{"internalType":"address","name":"platform","type":"address"},{"internalType":"uint256","name":"brokerAmount","type":"uint256"},{"internalType":"uint256","name":"platformAmount","type":"uint256"}],"internalType":"struct Fees","name":"takerFees","type":"tuple"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"makerNonce","type":"uint256"},{"internalType":"uint256","name":"takerNonce","type":"uint256"}],"indexed":false,"internalType":"struct TradeInfo","name":"tradeInfo","type":"tuple"},{"indexed":true,"internalType":"address","name":"broker","type":"address"}],"name":"BrokerSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"broker","type":"address"},{"internalType":"address","name":"platform","type":"address"},{"internalType":"uint256","name":"brokerAmount","type":"uint256"},{"internalType":"uint256","name":"platformAmount","type":"uint256"}],"indexed":false,"internalType":"struct Fees","name":"fees","type":"tuple"}],"name":"FeeTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"NonceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"__nonce","type":"uint256"}],"name":"getNonce","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct AssetData[]","name":"assets","type":"tuple[]"}],"internalType":"struct Assets","name":"makerAssets","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct AssetData[]","name":"assets","type":"tuple[]"}],"internalType":"struct Assets","name":"takerAssets","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"broker","type":"address"},{"internalType":"address","name":"platform","type":"address"},{"internalType":"uint256","name":"brokerAmount","type":"uint256"},{"internalType":"uint256","name":"platformAmount","type":"uint256"}],"internalType":"struct Fees","name":"makerFees","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"broker","type":"address"},{"internalType":"address","name":"platform","type":"address"},{"internalType":"uint256","name":"brokerAmount","type":"uint256"},{"internalType":"uint256","name":"platformAmount","type":"uint256"}],"internalType":"struct Fees","name":"takerFees","type":"tuple"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"makerNonce","type":"uint256"},{"internalType":"uint256","name":"takerNonce","type":"uint256"}],"internalType":"struct TradeInfo","name":"tradeInfo","type":"tuple"},{"internalType":"bytes","name":"makerSignature","type":"bytes"},{"internalType":"bool","name":"makerContra","type":"bool"},{"internalType":"bytes","name":"takerSignature","type":"bytes"},{"internalType":"bool","name":"takerContra","type":"bool"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]