@1inch/farming 中文文档教程
Farming contracts
About
这个存储库提供了 2 种耕作方式(奖励)。 强烈建议通过从 ERC20Farmable
智能合约派生它们来使用池/共享/实用程序令牌的第二个选项。 如果为时已晚,您还应该考虑第一个选项:
FarmingPool.sol
offers smart contract where you can stake/deposit specific tokens to get continiously distributed rewards.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
或者
$ yarn add @1inch/farming
Usage
!!! NOTICE: WAIT UNTILL FULLY AUDITED !!!
安装后,您可以通过导入来使用库中的合同。 只需使用 ERC20Farmable
而不是 ERC20
来派生自:
pragma solidity ^0.8.0;
import "@1inch/farming/contracts/ERC20Farmable.sol";
contract AMMPoolToken is ERC20Farmable {
constructor() ERC20("AMMPoolToken", "AMM") {
}
}
Optimizations
存储访问:
1 个用于农业参数的存储槽,仅在农业重启时更新: <代码>坚固性 uint40 公共完成; uint32 公共持续时间; uint184 公共奖励;
1 个存储槽 用于农业状态,已更新仅在改变农业代币数量时: <代码>坚固性 uint40 公共检查点; uint216 public farmedPerTokenStored;
每个农民有 1 个存储位,根据存款更新/withdrawals(感谢 @snjax):
mapping(address => int256) public corrections;
紧凑的地址数组用于存储每个用户/钱包的农场。 数组长度存储在第一个数组项的高位:
Farming contracts
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:
FarmingPool.sol
offers smart contract where you can stake/deposit specific tokens to get continiously distributed rewards.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:
solidity uint40 public finished; uint32 public duration; uint184 public reward;
1 storage slot for farming state, updated only on changing number of farming tokens:
solidity 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:
你可能也喜欢
- 23mofang-ui 中文文档教程
- 3d-bullet-raub 中文文档教程
- 4leaf-hooks-useinput 中文文档教程
- 99cloud-yl-cmdb-instance-selector 中文文档教程
- @100tal-seg/seg-react-material-template 中文文档教程
- @1coinswap/sdk 中文文档教程
- @2o3t/electron-ipc-promise 中文文档教程
- @3dwayfinder/wayfinder-vue-components 中文文档教程
- @8base-react/app-provider 中文文档教程
- @aantonov/dep-injector 中文文档教程