Sperax
  • USDs (Sperax USD)
    • Minting and Redeeming
    • Auto Yield
      • Smart Contracts can opt in for the rebase feature (Auto-yield).
    • Stability Mechanism
    • Key parameters and functions
    • Technical documents
      • Sequence diagrams
      • Smart contracts
        • Vault
        • USDs
        • CollateralManager
        • SPA Buyback
        • MasterPriceOracle
        • Yield Reserve
        • Fee Calculator
        • RebaseManager
        • Dripper
        • BaseStrategy
      • Deployed contracts
  • Buyback Contract
  • Staking Protocol
    • Locking SPA
    • Withdrawing SPA
    • Staking Rewards
  • Demeter Protocol
    • How does Demeter Work?
    • Technical documents
      • Smart contracts
        • E721 Farms
          • E721Farm
          • Camelot V3
            • CamelotV3FarmDeployer
            • CamelotV3Farm
        • Base contracts
          • Farm
          • FarmStorage
          • FarmRegistry
          • FarmDeployer
        • Features
          • ClaimableFee
          • ExpirableFarm
          • OperableDeposit
        • Rewarder
          • Rewarder
          • RewarderFactory
      • Deployed contracts
  • Getting Started on Our DApp
    • Minting & Redeeming USDs
    • Stake SPA
  • Governance
  • Bug Bounty Program
  • FAQ
    • SPA Tokenomics
    • xSPA token
    • Smart Contract Addresses
    • How to Transfer SPA from Ethereum to Arbitrum
  • Quick Links
    • Audit Reports
    • Sperax Dapp
    • Demeter Dapp
    • Discord
    • Forum
    • Snapshot
Powered by GitBook
On this page
  • State Variables
  • nftContract
  • depositToTokenId
  • Functions
  • onERC721Received
  • withdraw
  • _getLiquidity
  • Errors
  • UnauthorisedNFTContract
  • NoData

Was this helpful?

Export as PDF
  1. Demeter Protocol
  2. Technical documents
  3. Smart contracts
  4. E721 Farms

E721Farm

PreviousE721 FarmsNextCamelot V3

Was this helpful?

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

Name
Type
Description

<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

Name
Type
Description

<none>

bytes4

bytes4 The onERC721Received selector.

withdraw

Function to withdraw a deposit from the farm.

function withdraw(uint256 _depositId) external override nonReentrant;

Parameters

Name
Type
Description

_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

Name
Type
Description

_tokenId

uint256

The nft tokenId.

Returns

Name
Type
Description

<none>

uint256

The liquidity of the nft position.

Errors

UnauthorisedNFTContract

error UnauthorisedNFTContract();

NoData

error NoData();
Git Source