Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imduchuyyy/reward-by-block
https://github.com/imduchuyyy/reward-by-block
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/imduchuyyy/reward-by-block
- Owner: imduchuyyy
- Created: 2022-04-11T06:55:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-11T06:58:38.000Z (almost 3 years ago)
- Last Synced: 2024-11-13T08:42:44.236Z (2 months ago)
- Language: Rust
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Farming
1. Farm have `total_reward`, `start_block` and `reward_per_block`
2. Farm start with `acc_token_per_share` is 0 and `last_reward_block` is block where Farm has been
created
3. Every action of Farmer will update Farm
4. Update farm will update `acc_token_per_share` and `last_reward_block`
5. Update farm by:
- Get `lp_supply` = balance_of (Farm lp token address)
- `acc_token_per_share` = (`block now` - `last_reward_block`) * `reward_per_block` / `lp_supply`
- `last_reward_block` is block where Farm was update
6. Farmer can `deposit` lp token, when Farmer call `deposit`, flow is:
- Update Farm with rule was defined at step 5
- `amount` amount of deposit
- `last_reward` = `amount` * `Farm.acc_token_per_share`
7. Farmer can `claim` lb token, when Farmer call `claim`, flow is:
- Update Farm with rule was defined at step 5
- Calculate reward = `Farmer.amount` * `Farm.acc_token_per_share` - `Farmer.last_reward`
- `Farmer.last_reward` = `Farmer.amount` * `Farm.acc_token_per_share`