Vault math ruclips.net/video/k7WNibJOBXE/видео.html 0:00 - State variables and constructor 1:20 - Internal functions - mint and burn 2:32 - deposit 5:00 - withdraw 6:34 - Deploy and demo Code solidity-by-example.org/defi/vault Take a course www.smartcontract.engineer/
It's worth considering what happens when your numbers don't divide evenly, in this example you doubled the tokens so it boiled down to a division of 2000/1000 =2/1=2. It's also worth considering what happens when the user puts in some more tokens after they put in the initial 1000, and how that might affect things given integer rounding errors. Also you can try having multiple users put in tokens and see how that goes.
hey man just a question, any recommendations how to brush up on my general DeFi knowledge? I am okay with the coding part but some defi knowledge like shares/token amount is a bit alien to me. Thanks!
This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly. I'm getting this error while importing IERC20.sol what to do?, please explain.
I want to give specific amount reward for each depositor lets say 1% per day per users on the smart contract internally? how can i add it on the code as function?
Its what you can do with the erc-20 receipt tokens, for example, you can transfer them to a lending contract that lets you borrow against them or lock them as a bond to sell to other users, etc...
Great video. I am new to Solidity. Out of curiousity, why do you use transfer() instead of call() which is mentioned by many best practices that call() is the better transaction method to go with?
Thanks for the fantastic content! Could you suggest some projects for people who know a bit of Solidity and want to delve deeper into the world of DeFi?
Vault math
ruclips.net/video/k7WNibJOBXE/видео.html
0:00 - State variables and constructor
1:20 - Internal functions - mint and burn
2:32 - deposit
5:00 - withdraw
6:34 - Deploy and demo
Code
solidity-by-example.org/defi/vault
Take a course
www.smartcontract.engineer/
This is GOLD! Thank you
It's worth considering what happens when your numbers don't divide evenly, in this example you doubled the tokens so it boiled down to a division of 2000/1000 =2/1=2. It's also worth considering what happens when the user puts in some more tokens after they put in the initial 1000, and how that might affect things given integer rounding errors. Also you can try having multiple users put in tokens and see how that goes.
usually rounding errors are circumvented by having 18 decimals
@@smartcontractprogrammer I'm actually deal with it in my project .
Maybe you have some kind of solution?
Libraries , tricks , etc.
Thank you, exactly what I was waiting for.
Your channel has really grown. Really happy for you :D
Lmfao, his channel grew do much there are fake scam accounts of his channel
as always awesome
Love from india 😍
this was awesome
Great video
Hey can you explain what is the purpose of a vault contract? Im not sure I understand
collecting tokens and utilized by contract owner
for example, collect DAI from users, contract owner deposits it into Curve to earn fee and rewards
Hi , Please cover ERC-4626
hey man just a question, any recommendations how to brush up on my general DeFi knowledge? I am okay with the coding part but some defi knowledge like shares/token amount is a bit alien to me. Thanks!
This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly.
I'm getting this error while importing IERC20.sol
what to do?, please explain.
I want to give specific amount reward for each depositor lets say 1% per day per users on the smart contract internally? how can i add it on the code as function?
what's the advantage of issuing the erc-20 receipt tokens when you could just increment a uint?
I’m also interested in the answer.
Its what you can do with the erc-20 receipt tokens, for example, you can transfer them to a lending contract that lets you borrow against them or lock them as a bond to sell to other users, etc...
@@lukefoster5990 thanks.
It's just like a bond (IOU)
If the vault is trusted on other ecosystems like uniswap or aave or compound, you can keep your bond/IOU as collateral.
@smartcontractprogrammer: I don't understand B in the formula, please explain to me ?
B = balance of token before transferFrom is called
I'm developing the vault protocol on Solana. Do you have any good resources you've found that I can refer to?
Sorry, no. I've never coded on Solana
what is shares = _amount means?, How this is possible?. Please explain.
This is also not clear to me, so, will be happy to know for what these shares are used and why it works like that.
Great video.
I am new to Solidity. Out of curiousity, why do you use transfer() instead of call() which is mentioned by many best practices that call() is the better transaction method to go with?
it's ERC20 transfer, not ETH transfer
Thanks for the fantastic content! Could you suggest some projects for people who know a bit of Solidity and want to delve deeper into the world of DeFi?
Yearn
Uniswap
Curve
Aave
Compound
Frax
Alchemix
Chainlink
Nice, can you make a video for testing with hardhat
is there make sens to return bool for deposit & withdraw?
Personal opinion, no
@@smartcontractprogrammer thanks
why not use the ERC 4626 standard for this?
Focusing on math, not standards
in deposit you should NOT mint before receiving the token from the user.
Way we derived the equation, we must mint before deposit.
It's also best practice to update state variables before calling external contracts