Saltar al contenido principal
Superteam Brasil
Atrás
+40 XP
11/12

DeFi Vault Simulator

Build a simplified DeFi vault that tracks deposits, shares, and exchange rates.

Your vault accepts deposits of an underlying token and mints vault shares. As the vault generates yield, the exchange rate between shares and underlying increases. Users can redeem shares for their proportional amount of underlying assets.

Key concepts:

  • Track total underlying assets and total shares issued
  • Calculate exchange rate when depositing and withdrawing
  • Ensure the first depositor doesn't get unfair advantages

This is the core mechanic behind yield aggregators like Francium and Tulip Protocol.

Casos de Prueba

First deposit of 100 should return 100 shares
Entrada: 'alice', 100Esperado: typeof result === 'number' && result === 100
Deposit should return positive share amount
Entrada: 'alice', 200Esperado: typeof result === 'number' && result > 0

Discusión