MidasPair721

MidasPair721

Contract used to trade through the Liquidity Book and also acts as the manager of liquidity positions.

constructor

constructor(address _factory) {}

Parameters

Name

Type

Description

_factory

address

The address of the factory which creates the pair

SellNFT

BuyNFT

event BuyNFT(uint256 indexed nftTokenId, address indexed from, uint24 tradeBin, uint128 indexed lpTokenId);

ERC721PositionMinted

event ERC721PositionMinted(uint256 lpTokenId, uint24 binLower, uint24 binStep, uint256 binAmount, uint256[] nftTokenIds);

ERC20PositionMinted

event ERC20PositionMinted(uint256 lpTokenId, uint24 binLower, uint24 binStep, uint256 binAmount);

PositionBurned

ClaimFee

FlashLoan

NewRoyaltyFee

initialize

Function to initialize the pair which is strict to MidasFactory.

getTokenX

Pure function to get the NFT address of this pair.

getTokenY

Pure function to get the FT address of this pair.

getLPToken

Pure function to get the LP Token address of this pair.

factory

View function to get the factory address of this pair.

getReserves

View function to get the NFT and FT reserves of this pair.

Return Values

Name

Type

Description

reserveX

uint128

The reserves of NFT

reserveY

uint128

The reserves of FT

getIDs

View function to get current index price info of this pair.

Return Values

Name

Type

Description

bestOfferID

uint24

The best offer id of this pair

floorPriceID

uint24

The floor price id of this pair

currentPositionID

uint128

The latest position ID

getGlobalFees

View function to get the global fees information, the total fees and those for protocol

Return Values

Name

Type

Description

feesTotal

uint128

The unclaimed total fees

feesProtocol

uint128

The unclaimed protocol fees

feeParameters

View function to get the fee parameters of this pair.

Return Values

Name

Type

Description

rate

uint128

The fee rate of the LP could collected from trades

protocolRate

uint128

The protocol fee rate which is collected through the fee

royaltyRate

uint128

The royalty rate of this pair

getBin

View function to get the reserves of bin at id.

Parameters

Name

Type

Description

_id

uint24

The bin id

Return Values

Name

Type

Description

reserveX

uint128

The reserves of NFT in the bin

reserveY

uint128

The reserves of FT in the bin

getLpInfos

View function to get the LP info via LP tokenId.

Parameters

Name

Type

Description

_LPtokenID

uint128

The ID of LP Token

Return Values

Name

Type

Description

originBin

uint24

The start bin of this position

binStep

uint24

The bin step of this position

fee

uint128

The unclaimed fee for this position

getPriceFromBin

View function to get the price mapping to the specific bin id.

Parameters

Name

Type

Description

_id

uint24

The id of bin

Return Values

Name

Type

Description

price

uint128

The price mapping to the specific bin id

getLPFromNFT

View function to get the LP tokenId of the specific NFT.

Parameters

Name

Type

Description

_id

uint24

The token id of the NFT

Return Values

Name

Type

Description

_LPtoken

uint128

The ID of the LP token

getBinParamFromLP

View function to get the quote price of the specific position.

Parameters

Name

Type

Description

_lpTokenID

uint128

The ID of the LP token

_amount

uint256

The amount of NFT is going to buy

Return Values

Name

Type

Description

_totalPrice

uint128

The quote price of NFTs

getLpReserve

View function to get the reserves of the specific position.

Parameters

Name

Type

Description

_lpTokenID

uint128

The id of LP Token

Return Values

Name

Type

Description

amountX

uint128

The amount of NFTs in this position

amountY

uint128

The amount of FT in this position

sellNFT

Function to buy the NFT asset at the spot price.

Parameters

Name

Type

Description

NFTID

uint256

The token id of the NFT to be sold

_to

address

The address of the recipient

Return Values

Name

Type

Description

_amountOut

uint128

The amount of FT the receiver can get

buyNFT

Function to buy the NFT asset at the spot price.

Parameters

Name

Type

Description

NFTID

uint256

The token id of the NFT to be bought

_to

address

The address of the recipient

mintNFT

Performs a low level add liquidity of NFT. This needs to be called from a contract which performs important safety checks.

Parameters

Name

Type

Description

_ids

uint24[] calldata

The list of ids to add liquidity

_NFTIDs

uint256[] calldata

The token id of the NFT

_to

address

The address of the recipient

isLimited

bool

Determine whether the liquidity position is a limit order

Return Values

Name

Type

Description

_ids.length

uint256

The amount of NFT to add

_LPtokenID

uint128

The ID of the LP token

mintFT

Performs a low level add liquidity of FT. This needs to be called from a contract which performs important safety checks.

Parameters

Name

Type

Description

_ids

uint24[] calldata

The list of ids to add liquidity

_to

address

The address of the recipient

Return Values

Name

Type

Description

_amountYAddedToPair

uint128

The amount of FT to add

_LPtokenID

uint128

The ID of the LP token

burn

Performs a low level remove liquidity. This needs to be called from a contract which performs important safety checks

Parameters

Name

Type

Description

_LPtokenID

uint128

The ID of the LP token

_nftReceiver

address

The address of the NFT assets recipient

_to

address

The address of the FT assets recipient

Return Values

Name

Type

Description

amountY

uint128

The amount of FT sent to _to

collectProtocolFees

Collect the protocol fees and send them to the fee recipient.

Return Values

Name

Type

Description

amountY

uint128

The amount of FT sent to the fee recipient.

collectLPFees

Collect the LP fees and send them to the fee recipient.

Return Values

Name

Type

Description

amountFee

uint128

The amount of FT sent to the fee recipient.

collectRoyaltyFees

Collect the royalty fees and send them to the royalty fee recipient.

Return Values

Name

Type

Description

_royaltyFees

uint128

The amount of FT sent to the fee recipient.

updateRoyalty

Update the royalty info of the NFT according to EIP2981.

Parameters

Name

Type

Description

_newRate

uint256

The ID of the LP token

newrecipients

address payable[] calldata

The addresses of the recipient

newshares

uint256[] calldata

The shares of these recipients

updateSafetyLock

Update the safety locker status which is strict to factory.

Parameters

Name

Type

Description

newLock

bool

The status of this pair's safety locker

flashLoan

Parameters

Name

Type

Description

receiver

IMidasFlashLoanCallback

The implementation of receiver

_tokenIds

uint256[] calldata

The list of NFT tokenIds to be borrowed

data

bytes calldata

The data to be transferred along with function revoking

Last updated