Staking Rewards | Solidity 0.8

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

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

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

    Interesting, I have never seen a modifier used really to modify :D Most common use case is just for requirements.

  • @web3student686
    @web3student686 2 года назад +4

    Hey! Many thanks for your videos. They are helping me a lot.
    Would it be possible for you to make a video with combined functions? For example: I know how to create a token, I know how to add tax to the token, I know how to add staking mechanism to the token and how to add liquidity on uniswap. But I really struggle to combine all those functions as it gets more complicated. That would be huuuuuuuge.

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

    Thank you 💕

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

    amazing

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

    Amazing. I need that!

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

    Thankyou soo much ❤️

  • @emmanueloduor8365
    @emmanueloduor8365 18 дней назад

    Please could you explain for me why you are using block.timestamp instead of block.number when you are checking the time the reward has finished. Line 53.

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

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

    i know this is a big ask, but can you make a liquidity swap tutorial, something like uniswap ?
    or a bridge tutorial ?

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

    It might help to watch his video "Staking Rewards - Math, Examples and Algorithm | DeFi" before you watch this.

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

    Hey Bro, quick question if you got the time,
    @8:23
    rewardRate[token] = _amount / duration;
    What if the duration is larger than the rewards?
    For example, if the owner wanted to put up 1000 tokens for 2 days( 172800 seconds )
    1000 / 172800 will return 0 as reward rate?
    Can you help me understand this or if I'm missing something, Thank you.

    • @smartcontractprogrammer
      @smartcontractprogrammer  Год назад +1

      tokens usually have 18 decimals so the math will be
      1000 * 10**18 / 172800

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

      @@smartcontractprogrammer That's what I figured, Thank you for confirming

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

    Hi guys...can I copy all these contract ...and everything will run smoothly..?
    Or is a fake contract...with bugs...or whatever..?

  • @mavericks.9638
    @mavericks.9638 2 года назад

    im having a hard time understanding the interface IERC20 and how it differs from a standard ERC20 implementation like OppenZepplin ERC20 contract.
    i read that in interfaces they do not implement(call) any of their functions (which are required to be external) in the solidity file.
    would you call an interface .sol file a contract?
    what does an ERC20 class need to be considered an ERC20 object class?

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

      ERC20 - contract
      IERC20 - used to call a contract without importing its code
      Example
      DAI - is a ERC20 contract. Code can be found here
      etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#code
      But you don't need to import the entire code of DAI to use it in your contract.
      Import IERC20 and you can interact with DAI

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

    Hello, what are the process for 101 class for me to be fully fullstack blockchain developer?

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

      Learn basic programming with Python
      Learn Solidity or Vyper
      Learn user interface with Javascript and ethers.js
      Learn server side scripting with node.js and ethers.js

  • @АндрейБарабанов-т3у

    Thank you for the video!
    Could you please explain how to calculate APY in synthetic staking?

    • @smartcontractprogrammer
      @smartcontractprogrammer  Год назад +2

      1. record reward per share every week
      2. Take difference of reward per share this and last week
      3. Apply APY calc using difference from 2

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

      @@smartcontractprogrammer is this what rewardPerToken returns?

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

    Could have you used a struct for the state variables?

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

      yes
      Here state variables were named the same as Synthetix's staking rewards contract

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

      @@smartcontractprogrammer thank you for the reply! Is there any benefit to doing it either or ?

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

      @@Eb_Games using struct might save gas

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

    Have a question. I can take rewards once per wallet, what i need to change in this contract to have infinity number of rewards?

  • @AbhishekYadav-jq9sp
    @AbhishekYadav-jq9sp Год назад

    i didn't got what is rewardPerToken()..?? can u elaborate..

  • @МаниМейк
    @МаниМейк Год назад

    do we not have to approve token for our contract to be able to spend it?

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

      staking token - yes
      reward token - no, for the amount locked in the staking contract

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

    does this factor in compound?

  • @nickeast4853
    @nickeast4853 Год назад +2

    u need to speak slower and the wordings u picked for the functions arent precise enough to clearly state the purpose of the functions

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

    what does 1000 block timestamp equals to?

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

    0:00 - State variables and constructor
    4:02 - Functions overview
    6:01 - setRewardsDuration
    7:40 - notifyRewardAmount
    11:15 - stake
    13:02 - earned
    14:58 - rewardPerToken
    16:42 - lastTimeRewardApplicable
    18:30 - updateRewards
    21:02 - Attach modifier updateRewards
    21:50 - getReward
    23:10 - Fix code
    23:36 - Demo on Remix
    Code
    solidity-by-example.org/defi/staking-rewards
    Take a course
    www.smartcontract.engineer/

    • @ДмитрийМищенко-щ2в
      @ДмитрийМищенко-щ2в 2 года назад

      Amazing video, thanks for your work brother. I wanna ask you, what is the best site/platform to practice writing smart contract ? (in your opinion)

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

    @smartcontractprogrammer how to stake stablecoin(USDT) and earn rewards as an usdt please help. can i put usdt address in _stakingtoken and _rewardstokens?