Staking Rewards - Math, Examples and Algorithm | DeFi

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024

Комментарии • 18

  • @smartcontractprogrammer
    @smartcontractprogrammer  2 года назад +1

    0:00 - Overview
    2:00 - Math
    5:51 - Examples 1
    10:50 - More Math
    18:24 - Examples 2
    37:42 - Algorithm
    Code
    solidity-by-example.org/defi/staking-rewards/
    Notes
    github.com/t4sk/notes
    Take a course
    www.smartcontract.engineer/

  • @bradsandilands6087
    @bradsandilands6087 Год назад +3

    Such a clever way to efficiently calculate rewards. Very good explanation as usual thanks.

  • @bearwolffish
    @bearwolffish 2 года назад +3

    lowkey mvp

  • @kszarkiewicz
    @kszarkiewicz 5 дней назад

    you're awesome

  • @MrCoreyTexas
    @MrCoreyTexas 2 месяца назад

    I was getting thrown off by exactly what R was, so I made it simple for me. Pretend that up to 1000 reward tokens are going to be given out over 1000 seconds. So R is just 1, each second, 1 reward token is up for grabs. Provided some tokens are actually staked. If 0 tokens are staked in a 1 second period, no rewards are available for that second. Let me know if I have this wrong.

  • @teewhy3828
    @teewhy3828 2 года назад +2

    Can you derive APR from the rewards per token?

  • @vishalkulkarni3977
    @vishalkulkarni3977 2 года назад +1

    what if carol stakes 100 at 6 sec and alice withdraw a100 at 6 sec how is total supply token is calculat,Ti is calculated?

  • @exserentia
    @exserentia 2 года назад +1

    Am I getting this right..
    So one person's cost to execute the function scales linearly against the number of operations executed by all users between entering and exiting?
    It seems horribly inefficient to have to calculate these values on chain, per each staking and unstaking action.. and you must create new storage for the total rewards as well as staked-total data each time they change which accumulates over time.
    Not to mention there's probably no storage cleanup due to inefficiencies of having to calculate who remains in pool.

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 года назад +1

      No. The algorithm is efficient. It's basically users shares * (current reward per token - user's last reward per token)

  • @rajatarora9269
    @rajatarora9269 2 года назад

    It would be great if you build a smart-contract on the above logic described. I am not saying to spoon-feed us but at-least we people have some reference.

  • @ProspersPlace
    @ProspersPlace 2 года назад +1

    Do you do any free lancing?

  • @tieule363
    @tieule363 Год назад

    How to implement pause reward ?

  • @juliomendez177
    @juliomendez177 2 года назад

    What fields of knowledge and at what level do you have to have in mathematics to be able to develop defi?
    Is there a place to learn it?

  • @MrCoreyTexas
    @MrCoreyTexas 2 месяца назад

    Again, I don't know why you just don't call totalSupply totalStaked. Naming variables in programming is actually a lot of the work :)

  • @DeepakKumar-vn5qx
    @DeepakKumar-vn5qx 2 года назад

    what is the k stands for here?

    • @MrCoreyTexas
      @MrCoreyTexas 2 месяца назад

      k is just the time the user stakes their tokens, and n is the time where they unstake. Maybe it would have been better to just have the time be from a to b? k and n are used a lot in mathematics though as a convention. Note that the letter k comes before the letter n in the alphabet, and in the example, k is before n in time in seconds.