Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@1inch/farming

Package Overview
Dependencies
Maintainers
5
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@1inch/farming

Set of contracts for farming incentives

  • 1.0.3
  • npm
  • Socket score

Version published
Weekly downloads
223
increased by62.77%
Maintainers
5
Weekly downloads
 
Created
Source

1inch network

Farming contracts

Build Status Coverage Status

About

This repository offers 2 ways to have farming (incentives). Highly recommend to use second option for pools/share/utility tokens by deriving them from ERC20Farmable smart contract. If it's too late you should consider first option as well:

  1. FarmingPool.sol offers smart contract where you can stake/deposit specific tokens to get continiously distributed rewards.
  2. ERC20Farmable.sol allows derived tokens to have farming without necessarity to stake/deposit token into pool. Moreover it allows to have multiple farmings simultaneously and setup new farms permissionlessly.

Installation

!!! NOTICE: WAIT UNTILL FULLY AUDITED !!!

$ npm install @1inch/farming

or

$ yarn add @1inch/farming

Usage

!!! NOTICE: WAIT UNTILL FULLY AUDITED !!!

Once installed, you can use the contracts in the library by importing them. Just use ERC20Farmable instead of ERC20 to derive from:

pragma solidity ^0.8.0;

import "@1inch/farming/contracts/ERC20Farmable.sol";

contract AMMPoolToken is ERC20Farmable {
    constructor() ERC20("AMMPoolToken", "AMM") {
    }
}

Optimizations

  • Storage access:
    • 1 storage slot for farming params, updated only on farming restarting:

      uint40 public finished;
      uint32 public duration;
      uint184 public reward;
      
    • 1 storage slot for farming state, updated only on changing number of farming tokens:

      uint40 public checkpoint;
      uint216 public farmedPerTokenStored;
      
    • 1 storage slot per each farmer, updated on deposits/withdrawals (kudos to @snjax):

      mapping(address => int256) public corrections;
      
  • Compact address array is used for storing farms per user/wallet. Array length is stored in high bits of the first array item:

FAQs

Package last updated on 23 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc