📂
DAO Envelop. NIFTSY
  • Envelop (NIFTSY) documentation
  • Documents
    • Key terms
    • F.A.Q.
    • White paper
      • Disclaimers
      • Introduction
      • Key terms
      • Industry (market) analysis and NIFTSY's place in it
        • Figures and facts
        • Possible implementations of Envelop
      • Protocol. Oracle. Index
        • Protocol
          • NFT as a new order ETF and a brief history of NIFTSY
        • Oracle
        • Index
      • The architecture of the Project and the role of the Token
        • DAO. Token. IDO
        • The token as a linking element in the project
        • IDO (Initial DAO offering)
      • Roadmap. Part. #01
      • Roadmap. Part #02
      • Conclusion
      • List of references
    • Lite paper
      • Abstract
      • Disclaimers
      • Market challenges - our solutions
      • The main hypostases and parts of the Project
      • Development strategy and market coverage
      • Additions
    • White paper (Spanish)
      • Descargo de responsabilidad
      • Introducción
      • Términos clave
      • Análisis de la industria (mercado) y el lugar de NIFTSY en el
        • Figuras y hechos
        • Posibles implementaciones de NIFTSY
      • Protocolo. Oráculo. Índice
        • Protocolo
        • NFTs como un nuevo de EFT y una breve historia de NIFTS
        • Oraculo
        • Índice
        • Untitled
      • La arquitectura del proyecto y el rol del token
        • DAO. Token. IDO
        • El token como un elemento vinculante en el proyecto
        • IDO
      • Mapa de ruta
      • Conclusiones
      • Lista de referencias
    • Lite paper (Spanish)
      • Abstracto
      • Descargo de responsabilidad
      • Los desafíos del mercado y nuestras soluciones
      • La hipótesis principal y partes del proyecto
      • Estrategia de desarrollo y cobertura de mercado
      • Adiciones
    • White paper (BAHASA INDONESIA)
      • PENAFIAN
      • PENGANTAR
      • ​KATA KUNCI
      • ANALISIS INDUSTRI (PASAR)) DAN KEDUDUKAN niftsy DI DALAMNYA
      • Angka dan Fakta
      • Kemungkinan implementasi NIFTSY
      • PROTOKOL. ORACLE. INDEKS
        • Protokol
        • Oracle
        • Indeks
      • ARSITEKTUR PROYEK DAN PERAN TOKEN
      • DAO. Token. IDO
      • Token sebagai elemen penghubung dalam proyek
      • IDO
      • ROADMAP
      • KESIMPULAN
      • DAFTAR REFERENSI
    • LITE PAPER (BAHASA INDONESIA)
      • Abstrak
      • Penafian
      • Tantangan pasar - solusi kami
      • Hipotesis utama dan bagian dari Proyek
      • Strategi pengembangan dan cakupan pasar
      • Tambahan
    • Tokenomics
      • General provisions
      • Links
  • Technical documentation
    • URLs of dAPPs
    • Technical paper
      • Introduction
      • Protocol
      • Oracle
      • Index
      • Stack
      • Conclusion
    • Smart-contracts
      • Deployment addresses v2
      • Deployment addresses v1
      • Deployment addresses v0
      • Security and smart contracts
      • Contract NiftsyERC20.sol
      • Protocol
        • V0
          • Audit
          • Contracts
            • WrapperWithERC20Collateral (V.0)
            • WrapperDistributor721.sol
            • WrapperFarming.sol
        • V1
          • Audit
          • Contracts
            • WrapperV1
            • AdvancedWhiteList.sol
            • EnvelopwNFT721
            • EnvelopwNFT1155
            • Saft
            • SBT smart-contract Factory
          • Gas measurements for Protocol version 1
      • Launchpad
        • V0
          • Launchpad.sol
        • V1
          • NFTKiosk.sol
          • DefaultPriceModel.sol
      • Subscription service
      • Factory (smart-contracts) minting
      • P2P NFT/wNFT trading service
    • Envelop dApps Troubleshooting
  • Tutorials
    • Introduction to tutorials
    • dApps
      • Minting
        • Version 0
          • Release notes
          • Instruction
          • Video
        • Version 1.1
          • Release notes
          • Instruction
          • Video
      • Main app
        • Version 0
          • Release notes
          • Instruction
          • Aptos instruction
          • Video
        • Version 1.0
          • Release notes
          • Instruction
        • Version 1.1
          • Release notes
          • Instruction
          • Video
      • Cross-NFT
        • Version 0
          • Release notes
          • Instruction
          • Video
      • Launchpad (wINO)
        • Version 0
          • Release notes
          • Instruction
          • Video
        • Version 1
          • Release notes
          • Instruction
            • NFT trading
            • ERC20 tokens trading
          • Video
      • Farming
        • Version 0
          • Release notes
          • Instruction
      • SAFT wNFT
        • Version 0
          • Release notices
          • Instruction
          • Video
        • Version 1.0
          • Release notices
          • Insctruction
          • Video
        • Version 1.1
          • Release notices
          • Insctruction
          • Video
    • Oracle
      • Version 0
        • Release notices
      • Version 1
        • Release notices
    • Subscription service
      • Version 0
        • Release notes
      • Version 1
        • Release notes
    • Metamask settings for different networks
    • How to wrap your NFT
    • How to make SAFT wNFT
    • How to unwrap your wNFT
    • How to mint Soulbound tokens with Envelop
    • How to use Wrapper from Safe Gnosis
    • Video tutorials
  • Bounty
    • Bounty FAQ
    • General conditions
    • Bounty rules
    • Approximate (maximum) activity estimates
    • Bug Bounty
  • Legal
    • Privacy-policy
    • Legal FAQ
    • DAO
    • Archive
      • Licence
  • ARHIVE
    • Archive tutorials
      • Wrap NFT
    • Others
      • Marketplace (Scotch.sale)
      • How do I buy on DEXs?
        • Uniswap
        • PancakeSwap
        • QuickSwap
Powered by GitBook
On this page
  • General mechanics
  • Important note
  • Method WrapForFarming
  • Method harvest
  • Method getAvailableRewardAmount
  • Method getCurrenntAPYByTokenId
  • Method getPlanAPYByTokenId
  • Method getRewardSettings
  1. Technical documentation
  2. Smart-contracts
  3. Protocol
  4. V0
  5. Contracts

WrapperFarming.sol

PreviousWrapperDistributor721.solNextV1

Last updated 3 years ago

General mechanics

The contract inherits the methods of the WrapperWithERC20Collateral.sol contract. Its description can be found . Inheritance means that the WrapperFarming contract has methods similar to those of the WrapperWithERC20Collateral.sol contract. The main function of the contract is to provide farming, a reward for locking ERC-20 tokens on the farming contract. In order to participate in farming, the user needs to deposit their ERC-20 tokens into the farming contract.

The deposit of tokens is done through a wraparound mechanism - by creating a special container - an ERC-721 token with collateral in the form of ERC-20 tokens sent to the farming contract. The user deposits their assets (ERC-20 tokens) into the collateral of such an ERC-721 token for a specified period of time. The user cannot withdraw (unwrap the ERC-721 token) before this period of time. The user receives a reward in the form of such ERC-20 tokens like in the collateral. The reward is added to the collateral of the ERC-721 token.

After receiving the reward for holding ERC-20 tokens on the farming contract, the user can unwrap the ERC-721 token - receive the ERC-20 tokens held on the farming contract and the reward in the same. A significant role in farming is played by the farming settings - for which periods for which types of tokens the user can transfer their ERC-20 tokens to the farming contract and what % on the frozen amount will be credited to them. Not all ERC-20 tokens can be used for farming. Only those tokens, for which contract address the owner of the farming contract has made settings of periods and % reward.

Important note

The user can send any ERC-20 tokens to the farming. But the reward will be credited and paid only for those types of ERC-20 tokens for which the owner of the farming contract has made farming periods and % reward settings.

Method WrapForFarming

The method creates an ERC-721 token with Collateral in the form of ERC-20 tokens that the user chooses to use for farming. The method verifies that:

  • the recipient of the ERC-721 is not a null address

  • the farming is not stopped for all users

If all conditions are met, the ERC-20 tokens are transferred from the user's address to the farming contract address. Before it the user must give the allowance for the farming contract to use his ERC-20 tokens (on the token contract). An ERC-721 token is then created, which is owned by the user who invoked the contract method. A record of the characteristics of the created wNFT and its the collateral with ERC-20 tokens is created in the Protocol repository. The method captures the farming start date for the created ERC-721 token. A Staked event is created for the transaction in the blockchain, specifying:

  • token id of the created ERC-721 token;

  • contract address of the ERC-20 tokens that the user chooses to farm;

  • the number of ERC-20 tokens that the user decided to send to the farming.

Parameters:

Name
Type
Description

_receiver

address

Recipient address of ERC-721 token

_erc20Collateral

array

An array of values:

  • ERC-20 token contract address

  • number of ERC-20 tokens

_unwrapAfter

uint256

Date after which farming reward can be received, unwrap ERC-721 token, receive ERC-20 tokens that have been frozen at the farming contract address + farming reward tokens

Method harvest

The method can only be triggered by the owner of an ERC-721 token with ERC-20 tokens wrapped in it. The method is triggered if there is a reward token amount available for accrual that is not 0. The method adds ERC-20 tokens to the ERC-721 token collateral amount. The method for the transaction in the blockchain creates a Harvest event specifying:

  • token id of the created ERC-721 token;

  • the contract address of the ERC-20 tokens for which the user received the farming reward;

  • remuneration amount.

Parameters:

Name
Type
Description

_wrappedTokenId

uint256

Token id ERC-721 token

_erc20

address

Address of the ERC-20 token contract that the user has transferred to the contract for farming and for which the user wishes to be rewarded

Method getAvailableRewardAmount

The method for token id of ERC-721 token and contract address of ERC-20 tokens that are stored in Collateral (are in farming) returns the available amount of reward for farming. The method analyses how much time has elapsed from the creation of the ERC-721 token with collateral in the form of ERC-20 tokens to the current moment. Relative to the time period obtained, the method determines the % reward according to the farming settings for that type of ERC-20 tokens. And applies the % to the number of ERC-20 tokens in the ERC-721 token collateral (being farmed) in the calculation. This calculates the available amount of reward for farming.

Parameters:

Name
Type
Description

_wrappedTokenId

uint256

Token id ERC-721 token

_erc20

address

Address of the ERC-20 token contract that the user has transferred to the contract for farming and for which the user wishes to be rewarded

Returns values:

Name
Type
Description

rewardAccrued

uint256

Number of ERC-20 tokens availabled for harvest

Method getCurrenntAPYByTokenId

The method for token id of ERC-721 token and contract address of ERC-20 tokens that are collateralized (in farming) returns % of the farming reward if the reward would have been received at the current time. The method analyses how much time has elapsed from the creation of the ERC-721 token with collateral in the form of ERC-20 tokens to the current moment. Relative to the time period obtained, the method determines the % reward according to the farming settings for that type of ERC-20 token.

Parameters:

Name
Type
Description

_wrappedTokenId

uint256

Token id ERC-721 token

_erc20

address

Address of the ERC-20 token contract that the user has transferred to the contract for farming and for which the user wishes to be rewarded

Returns values:

Name
Type
Description

percents

uint256

Percentage of remuneration for farming ERC-20 tokens of a specific type

Method getPlanAPYByTokenId

The method for token id of ERC-721 token and contract address of ERC-20 tokens that are stored in collateral (are in farming) returns a scheduled % reward for farming. The user may not have specified the token lock period on the farming contract (farming on demand), or they may have.

Accordingly, the method analyses:

  • how much time has elapsed from the creation of the ERC-721 token with collateral in the form of ERC-20 tokens to the current moment

  • or how long the farming will last (when the farming is urgent - the period of time for which the user locks ERC-20 tokens on the farming contract has been specified by the user). In relation to the time period obtained, the method determines the % reward according to the farming settings for that type of ERC-20 tokens.

Parameters:

Name
Type
Description

_wrappedTokenId

uint256

Token id ERC-721 token

_erc20

address

Address of the ERC-20 token contract that the user has transferred to the contract for farming and for which the user wishes to be rewarded

Returns values:

Name
Type
Description

percents

uint256

Scheduled remuneration percentage for farming ERC-20 tokens of a specific type

Method getRewardSettings

The method for ERC-20 token contract address returns the available farming period and % reward settings. These settings are made by the owner of the farming contract.

Parameters:

Name
Type
Description

_farmingTokenAddress

address

ERC-20 contract address of the tokens for which the user is requesting farming conditions

Returns values:

Name
Type
Description

settings

tuple

The array of available periods of farming and % of reward for requested ERC-20 token

here