Vault | Solidity 0.8

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.พ. 2025

ความคิดเห็น • 40

  • @smartcontractprogrammer
    @smartcontractprogrammer  2 ปีที่แล้ว +1

    Vault math
    th-cam.com/video/k7WNibJOBXE/w-d-xo.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/

  • @meka4996
    @meka4996 ปีที่แล้ว

    This is GOLD! Thank you

  • @franckyking93
    @franckyking93 2 ปีที่แล้ว

    Thank you, exactly what I was waiting for.

  • @mosipvp
    @mosipvp 2 ปีที่แล้ว

    as always awesome

  • @MrCoreyTexas
    @MrCoreyTexas 7 หลายเดือนก่อน

    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.

    • @smartcontractprogrammer
      @smartcontractprogrammer  7 หลายเดือนก่อน +1

      usually rounding errors are circumvented by having 18 decimals

    • @kir1llusatuk530
      @kir1llusatuk530 6 หลายเดือนก่อน

      @@smartcontractprogrammer I'm actually deal with it in my project .
      Maybe you have some kind of solution?
      Libraries , tricks , etc.

  • @defiler90
    @defiler90 2 ปีที่แล้ว

    this was awesome

  • @SuryanshShrivastava-tn4qt
    @SuryanshShrivastava-tn4qt 2 ปีที่แล้ว +1

    Hi , Please cover ERC-4626

  • @cebian6223
    @cebian6223 2 ปีที่แล้ว

    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!

  • @alexisd5410
    @alexisd5410 2 ปีที่แล้ว +1

    Hey can you explain what is the purpose of a vault contract? Im not sure I understand

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 ปีที่แล้ว +1

      collecting tokens and utilized by contract owner
      for example, collect DAI from users, contract owner deposits it into Curve to earn fee and rewards

  • @ivanlagade
    @ivanlagade 2 ปีที่แล้ว

    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?

  • @veerabadhraswamygopu7994
    @veerabadhraswamygopu7994 2 ปีที่แล้ว +1

    Love from india 😍

  • @TheGaneshshow
    @TheGaneshshow 2 ปีที่แล้ว

    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.

  • @samuelyork
    @samuelyork 2 ปีที่แล้ว +1

    what's the advantage of issuing the erc-20 receipt tokens when you could just increment a uint?

    • @franckyking93
      @franckyking93 2 ปีที่แล้ว

      I’m also interested in the answer.

    • @lukefoster5990
      @lukefoster5990 2 ปีที่แล้ว +3

      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...

    • @franckyking93
      @franckyking93 2 ปีที่แล้ว

      @@lukefoster5990 thanks.

    • @saadabbasi2063
      @saadabbasi2063 ปีที่แล้ว

      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.

  • @michaelchan6144
    @michaelchan6144 2 ปีที่แล้ว

    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?

  • @tesla3714
    @tesla3714 2 ปีที่แล้ว

    Nice, can you make a video for testing with hardhat

  • @tinghuang-dv2xd
    @tinghuang-dv2xd 9 หลายเดือนก่อน

    I'm developing the vault protocol on Solana. Do you have any good resources you've found that I can refer to?

  • @cunanh2112
    @cunanh2112 10 หลายเดือนก่อน

    @smartcontractprogrammer: I don't understand B in the formula, please explain to me ?

  • @tigerinus
    @tigerinus 2 ปีที่แล้ว

    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?

  • @TheGaneshshow
    @TheGaneshshow 2 ปีที่แล้ว +1

    what is shares = _amount means?, How this is possible?. Please explain.

    • @vitock1
      @vitock1 2 ปีที่แล้ว

      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.

    • @mitrev_g
      @mitrev_g หลายเดือนก่อน

      It is from the above mentioned formula - s = (a * T) / B
      where:
      a = amount of tokens to deposit;
      T = total supply of shares before deposit;
      B = balance of tokens held by the vault contract
      this is how you get the amount of shares you would receive per x deposited tokens.

  • @bhok5228
    @bhok5228 2 ปีที่แล้ว

    Great video

  • @alexanderkrone5902
    @alexanderkrone5902 2 ปีที่แล้ว

    in deposit you should NOT mint before receiving the token from the user.

    • @smartcontractprogrammer
      @smartcontractprogrammer  2 ปีที่แล้ว

      Way we derived the equation, we must mint before deposit.
      It's also best practice to update state variables before calling external contracts

  • @mosipvp
    @mosipvp 2 ปีที่แล้ว

    is there make sens to return bool for deposit & withdraw?

  • @stealtime
    @stealtime 2 ปีที่แล้ว

    why not use the ERC 4626 standard for this?