MidasRouter

MidasRouter

Main contract to interact with to swap and manage liquidity on Midaswap.

constructor

constructor(IWETH _weth, IMidasFactory721 _factory)

receive

receive() external payable

Receive function that only accepts ETH from the WETH contract

addLiquidityERC721

function addLiquidityERC721(address _tokenX, address _tokenY, uint24[] calldata _ids, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to add liquidity of NFTs and wrap the position with an ERC-721 token.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_ids

uint24[] calldata

The list of ids to add liquidity

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

idAmount

uint256

The amount of ids

lpTokenId

uint128

The ID of the LP token

addLiquidityERC20

function addLiquidityERC20(address _tokenX, address _tokenY, uint24[] calldata _ids, uint256 _deadline) external override ensure(_deadline)

Function to add liquidity of FT and wrap the position with an ERC-721 token.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_ids

uint24[] calldata

The list of ids to add liquidity

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

idAmount

uint256

The amount of ids

lpTokenId

uint128

The ID of the LP token

addLiquidityETH

function addLiquidityETH(address _tokenX, address _tokenY, uint24[] calldata _ids, uint256 _deadline) external override ensure(_deadline)

Function to add liquidity of ETH and wrap the position with an ERC-721 token.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_ids

uint24[] calldata

The list of ids to add liquidity

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

idAmount

uint256

The amount of ids

lpTokenId

uint128

The ID of the LP token

removeLiquidity

function removeLiquidity(address _tokenX, address _tokenY, uint128 _lpTokenId, uint256 _deadline) external override ensure(_deadline)

Function to remove liquidity and burn the LP token.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_lpTokenId

uint128

The ID of LP token

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

nftAmount

uint256

The amount of NFT

ftAmount

uint256

The amount of FT

removeLiquidityETH

function removeLiquidityETH(address _tokenX, address _tokenY, uint128 _lpTokenId, uint256 _deadline) external override ensure(_deadline)

Function to remove liquidity of ETH and burn the LP token.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_lpTokenId

uint128

The ID of LP token

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

nftAmount

uint256

The amount of NFT

ftAmount

uint256

The amount of FT

sellItems

function sellItems(address _tokenX, address _tokenY, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to sell NFTs and receive FT.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

_ftAmount

uint256

The amount of FT to receive

sellItemsToETH

function sellItemsToETH(address _tokenX, address _tokenY, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to sell NFTs and receive ETH.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

_ftAmount

uint256

The amount of FT to receive

buyItems

function buyItems(address _tokenX, address _tokenY, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to buy NFTs and give out FT.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

_ftAmount

uint256

The amount of FT to receive

buyItemsWithETH

function buyItems(address _tokenX, address _tokenY, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to buy NFTs and give out ETH.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

_ftAmount

uint256

The amount of FT to receive

openLimitOrder

function openLimitOrder(address _tokenX, address _tokenY, uint24[] calldata _ids, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to open a limit order to sell NFTs at spot prices.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_ids

uint24[] calldata

The list of ids of limited price

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

_ftAmount

uint256

The amount of FT to receive

_lpTokenId

uint128

The ID of LP token to redeem the income

openMultiLimitOrders

function openMultiLimitOrders(address _tokenX, address _tokenY, uint24[] calldata _ids, uint256[] calldata _tokenIds, uint256 _deadline) external override ensure(_deadline)

Function to open multiple limit orders to sell NFTs at spot prices.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_ids

uint24[] calldata

The list of ids of limited price

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

_deadline

uint256

The deadline of the tx

Return Values

Name

Type

Description

lpTokenIds

uint128[] memory

The IDs of LP token to redeem the income

claimFee

function claimFee(address _tokenX, address _tokenY, uint128 _lpTokenId) external override

Function for LPs to claim the swap fees from one position.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_lpTokenId

uint128

The ID of LP token

Return Values

Name

Type

Description

_feeClaimed

uint128

The amount of fee to be claimed

claimAll

function claimAll(address _tokenX, address _tokenY, uint128[] calldata _lpTokenId) external override

Function for LPs to claim the swap fees from multiple positions.

Parameters

Name

Type

Description

_tokenX

address

The address of ERC-721 asset

_tokenY

address

The address of ERC-20 asset

_lpTokenId

uint128[] calldata

The IDs of LP token

Return Values

Name

Type

Description

_feeClaimed

uint128

The amount of fee to be claimed

getAmountsToAdd

function getAmountsToAdd(address _pair, uint24[] calldata _ids) public view

Function to get a quote for the FT amount to add.

Parameters

Name

Type

Description

_pair

address

The address of the Midas pair

_ids

uint24[] calldata

The list of ids of limited price

Return Values

Name

Type

Description

ftAmount

uint256

The amount of FT needed to add

getMinAmountIn

function getMinAmountIn(address _pair, uint256[] calldata _tokenIds) public view

Function to get a quote for buying specific NFTs.

Parameters

Name

Type

Description

_pair

address

The address of the Midas pair

_tokenIds

uint256[] calldata

The list of tokenIds of NFT to be added

Return Values

Name

Type

Description

totalAmount

uint256

The amount of FT needed to pay

Last updated