EthRouter

Git Source

Inherits: ERC721TokenReceiver

Author: out.eth (@outdoteth)

This contract is used to route buy, sell, and change orders to multiple pools in one transaction. It will route the orders to either a private pool or a public pool. If the order goes to a public pool, then users can choose whether or not they would like to pay royalties. The only base token which is supported is native ETH.

State Variables

royaltyRegistry

address public royaltyRegistry;

Functions

receive

receive() external payable;

constructor

constructor(address _royaltyRegistry);

buy

Executes a series of buy operations against public or private pools.

function buy(Buy[] calldata buys, uint256 deadline, bool payRoyalties) public payable;

Parameters

NameTypeDescription

buys

Buy[]

The buy operations to execute.

deadline

uint256

The deadline for the transaction to be mined. Will revert if timestamp is greater than deadline. If it's set to 0 then there is no deadline.

payRoyalties

bool

Whether to pay royalties or not.

sell

Executes a series of sell operations against public or private pools.

function sell(Sell[] calldata sells, uint256 minOutputAmount, uint256 deadline, bool payRoyalties) public;

Parameters

NameTypeDescription

sells

Sell[]

The sell operations to execute.

minOutputAmount

uint256

The minimum amount of output tokens that must be received for the transaction to succeed.

deadline

uint256

The deadline for the transaction to be mined. Will revert if timestamp is greater than deadline. Set to 0 for there to be no deadline.

payRoyalties

bool

Whether to pay royalties or not.

deposit

Executes a deposit to a private pool (transfers NFTs and ETH to the pool).

function deposit(
    address payable privatePool,
    address nft,
    uint256[] calldata tokenIds,
    uint256 minPrice,
    uint256 maxPrice,
    uint256 deadline
) public payable;

Parameters

NameTypeDescription

privatePool

address payable

The private pool to deposit to.

nft

address

The NFT contract address.

tokenIds

uint256[]

The token IDs of the NFTs to deposit.

minPrice

uint256

The minimum price of the pool. Will revert if price is smaller than this.

maxPrice

uint256

The maximum price of the pool. Will revert if price is greater than this.

deadline

uint256

The deadline for the transaction to be mined. Will revert if timestamp is greater than deadline. Set to 0 for deadline to be ignored.

change

Executes a series of change operations against a private pool.

function change(Change[] calldata changes, uint256 deadline) public payable;

Parameters

NameTypeDescription

changes

Change[]

The change operations to execute.

deadline

uint256

The deadline for the transaction to be mined. Will revert if timestamp is greater than deadline. Set to 0 for deadline to be ignored.

getRoyalty

Gets the royalty and recipient for a given NFT and sale price. Looks up the royalty info from the manifold registry.

function getRoyalty(address nft, uint256 tokenId, uint256 salePrice)
    public
    view
    returns (uint256 royaltyFee, address recipient);

Parameters

NameTypeDescription

nft

address

tokenId

uint256

The token ID of the NFT.

salePrice

uint256

The sale price of the NFT.

Returns

NameTypeDescription

royaltyFee

uint256

The royalty fee to pay.

recipient

address

The address to pay the royalty fee to.

Errors

DeadlinePassed

error DeadlinePassed();

OutputAmountTooSmall

error OutputAmountTooSmall();

PriceOutOfRange

error PriceOutOfRange();

InvalidRoyaltyFee

error InvalidRoyaltyFee();

Structs

Buy

struct Buy {
    address payable pool;
    address nft;
    uint256[] tokenIds;
    uint256[] tokenWeights;
    PrivatePool.MerkleMultiProof proof;
    uint256 baseTokenAmount;
    bool isPublicPool;
}

Sell

struct Sell {
    address payable pool;
    address nft;
    uint256[] tokenIds;
    uint256[] tokenWeights;
    PrivatePool.MerkleMultiProof proof;
    IStolenNftOracle.Message[] stolenNftProofs;
    bool isPublicPool;
    bytes32[][] publicPoolProofs;
}

Change

struct Change {
    address payable pool;
    address nft;
    uint256[] inputTokenIds;
    uint256[] inputTokenWeights;
    PrivatePool.MerkleMultiProof inputProof;
    uint256[] outputTokenIds;
    uint256[] outputTokenWeights;
    PrivatePool.MerkleMultiProof outputProof;
}

Last updated