Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculation Explanation

The math behind determining how much a user should be paid is done by calculating the difference between tokenRewardPerToken since the deploy of the contract and the s_userRewardPerTokenPaid[account] (tokenRewardPerToken value since the last user balance change (withdraw, deposit, claimRewards)). This way we store in s_rewards[account] how much the user must be paid so far by multiplying the old balance of staked tokens he had by the difference in tokenRewardPerToken and last user recorded tokenRewardPerToken (s_userRewardPerTokenPaid[account]) + the cached user rewards from before.

This way we don't have to store info regarding how much N tokens of user, were staked for since when, as this would become very difficult and expensive.

Foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

  • Forge: Ethereum testing framework (like Truffle, Hardhat and DappTools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
  • Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
  • Chisel: Fast, utilitarian, and verbose solidity REPL.

Documentation

https://book.getfoundry.sh/

Usage

Build

$ forge build

Test

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

Cast

$ cast <subcommand>

Help

$ forge --help
$ anvil --help
$ cast --help

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages