E721Farm

Git Source

Inherits: Farm, IERC721Receiver

Author: Sperax Foundation.

This contract contains the core logic for E721 farms.

State Variables

nftContract

address public nftContract;

depositToTokenId

mapping(uint256 => uint256) public depositToTokenId;

Functions

onERC721Received

Function is called when user transfers the NFT to this farm.

function onERC721Received(address, address _from, uint256 _tokenId, bytes calldata _data)
    external
    override
    returns (bytes4);

Parameters

NameTypeDescription

<none>

address

_from

address

The address of the owner.

_tokenId

uint256

NFT Id generated by other protocol (e.g. Camelot or Uniswap).

_data

bytes

The data should be the lockup flag (bool).

Returns

NameTypeDescription

<none>

bytes4

bytes4 The onERC721Received selector.

withdraw

Function to withdraw a deposit from the farm.

function withdraw(uint256 _depositId) external override nonReentrant;

Parameters

NameTypeDescription

_depositId

uint256

The id of the deposit to be withdrawn.

_getLiquidity

Function to get the liquidity. Must be defined by the farm.

This function should be overridden to add the respective logic.

function _getLiquidity(uint256 _tokenId) internal view virtual returns (uint256);

Parameters

NameTypeDescription

_tokenId

uint256

The nft tokenId.

Returns

NameTypeDescription

<none>

uint256

The liquidity of the nft position.

Errors

UnauthorisedNFTContract

error UnauthorisedNFTContract();

NoData

error NoData();