MidasRouter
MidasRouter
Main contract to interact with to swap and manage liquidity on Midaswap.
constructor
receive
Receive function that only accepts ETH from the WETH contract
addLiquidityERC721
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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