I'm implementing a smart contract that allows users to stake one ERC20 token and receive rewards in another ERC20 token from a pool that is funded by accumulated transaction fees by the protocol.

What's the best/easiest way or an example to calculate stakers' rewards, considering their rewards will be entirely based on user activity/accumulated transaction fees?

In other words, stakers' rewards are not constant as in the event of no transactions on the protocol, there will be zero increase in the total available rewards.

The current prominent staking contracts appear to be based on rewardsPerBlock or rewardsPerToken models, but this does not seem to be relevant to what I'm trying to achieve. Am I missing a trick here?

Thank you

1 Answer 1


it's actually very similar to AMM's paying out fee's / yield farming rewards. There's tons of examples online, but here's a sushi one I always look to back to that works: https://github.com/BakerDAO-Fi/yield-farming-contracts/blob/main/src/MasterChef.sol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.