Skip to content

contract.ExchangeV1

Aleksey Bykhun edited this page Jan 18, 2023 · 1 revision

ExchangeV1

Git Source

Inherits: Ownable, ExchangeDomainV1

State Variables

_INTERFACE_ID_FEES

bytes4 private constant _INTERFACE_ID_FEES = 0xb7799584;

UINT256_MAX

uint256 private constant UINT256_MAX = 2 ** 256 - 1;

beneficiary

address payable public beneficiary;

buyerFeeSigner

address public buyerFeeSigner;

transferProxy

TransferProxy public transferProxy;

transferProxyForDeprecated

TransferProxyForDeprecated public transferProxyForDeprecated;

erc20TransferProxy

ERC20TransferProxy public erc20TransferProxy;

state

ExchangeStateV1 public state;

ordersHolder

ExchangeOrdersHolderV1 public ordersHolder;

Functions

constructor

constructor(
    TransferProxy _transferProxy,
    TransferProxyForDeprecated _transferProxyForDeprecated,
    ERC20TransferProxy _erc20TransferProxy,
    ExchangeStateV1 _state,
    ExchangeOrdersHolderV1 _ordersHolder,
    address payable _beneficiary,
    address _buyerFeeSigner
);

setBeneficiary

function setBeneficiary(address payable newBeneficiary) external onlyOwner;

setBuyerFeeSigner

function setBuyerFeeSigner(address newBuyerFeeSigner) external onlyOwner;

exchange

function exchange(
    Order calldata order,
    Sig calldata sig,
    uint256 buyerFee,
    Sig calldata buyerFeeSig,
    uint256 amount,
    address buyer
) external payable;

validateEthTransfer

function validateEthTransfer(uint256 value, uint256 buyerFee) internal view;

cancel

function cancel(OrderKey calldata key) external;

validateOrderSig

function validateOrderSig(Order memory order, Sig memory sig) internal view;

validateBuyerFeeSig

function validateBuyerFeeSig(Order memory order, uint256 buyerFee, Sig memory sig) internal view;

prepareBuyerFeeMessage

function prepareBuyerFeeMessage(Order memory order, uint256 fee) public pure returns (string memory);

prepareMessage

function prepareMessage(Order memory order) public pure returns (string memory);

transferWithFeesPossibility

function transferWithFeesPossibility(
    Asset memory firstType,
    uint256 value,
    address from,
    address to,
    bool hasFee,
    uint256 sellerFee,
    uint256 buyerFee,
    Asset memory secondType
) internal;

transfer

function transfer(Asset memory asset, uint256 value, address from, address to) internal;

transferWithFees

function transferWithFees(
    Asset memory firstType,
    uint256 value,
    address from,
    address to,
    uint256 sellerFee,
    uint256 buyerFee,
    Asset memory secondType
) internal;

transferFeeToBeneficiary

function transferFeeToBeneficiary(Asset memory asset, address from, uint256 total, uint256 sellerFee, uint256 buyerFee)
    internal
    returns (uint256);

emitBuy

function emitBuy(Order memory order, uint256 amount, address buyer) internal;

subFeeInBp

function subFeeInBp(uint256 value, uint256 total, uint256 feeInBp)
    internal
    pure
    returns (uint256 newValue, uint256 realFee);

subFee

function subFee(uint256 value, uint256 fee) internal pure returns (uint256 newValue, uint256 realFee);

verifyOpenAndModifyOrderState

function verifyOpenAndModifyOrderState(OrderKey memory key, uint256 selling, uint256 amount) internal;

getFeeSide

function getFeeSide(AssetType sellType, AssetType buyType) internal pure returns (FeeSide);

Events

Buy

event Buy(
    address indexed sellToken,
    uint256 indexed sellTokenId,
    uint256 sellValue,
    address owner,
    address buyToken,
    uint256 buyTokenId,
    uint256 buyValue,
    address buyer,
    uint256 amount,
    uint256 salt
);

Cancel

event Cancel(
    address indexed sellToken,
    uint256 indexed sellTokenId,
    address owner,
    address buyToken,
    uint256 buyTokenId,
    uint256 salt
);

Enums

FeeSide

enum FeeSide {
    NONE,
    SELL,
    BUY
}
Clone this wiki locally