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.
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.
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.
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?
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
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
@smartcontractprogrammer how to stake stablecoin(USDT) and earn rewards as an usdt please help. can i put usdt address in _stakingtoken and _rewardstokens?
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/
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)
Interesting, I have never seen a modifier used really to modify :D Most common use case is just for requirements.
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.
tokens usually have 18 decimals so the math will be
1000 * 10**18 / 172800
@@smartcontractprogrammer That's what I figured, Thank you for confirming
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.
Amazing. I need that!
Thank you 💕
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.
because reward rate is calculated with time
amazing
Thankyou soo much ❤️
Thank you for the video!
Could you please explain how to calculate APY in synthetic staking?
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
@@smartcontractprogrammer is this what rewardPerToken returns?
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?
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
i know this is a big ask, but can you make a liquidity swap tutorial, something like uniswap ?
or a bridge tutorial ?
maybe
Could have you used a struct for the state variables?
yes
Here state variables were named the same as Synthetix's staking rewards contract
@@smartcontractprogrammer thank you for the reply! Is there any benefit to doing it either or ?
@@Eb_Games using struct might save gas
Hello, what are the process for 101 class for me to be fully fullstack blockchain developer?
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
It might help to watch his video "Staking Rewards - Math, Examples and Algorithm | DeFi" before you watch this.
Have a question. I can take rewards once per wallet, what i need to change in this contract to have infinity number of rewards?
set duration to 100 years?
@@smartcontractprogrammer make sense
Hi guys...can I copy all these contract ...and everything will run smoothly..?
Or is a fake contract...with bugs...or whatever..?
❤
do we not have to approve token for our contract to be able to spend it?
staking token - yes
reward token - no, for the amount locked in the staking contract
i didn't got what is rewardPerToken()..?? can u elaborate..
Watch video on math and algorithm
does this factor in compound?
what does 1000 block timestamp equals to?
1000 milliseconds.
u need to speak slower and the wordings u picked for the functions arent precise enough to clearly state the purpose of the functions
@smartcontractprogrammer how to stake stablecoin(USDT) and earn rewards as an usdt please help. can i put usdt address in _stakingtoken and _rewardstokens?