Deposit, borrow, withdraw, repay
Core operations
This tutorial will show you how to manage deposit and borrow positions in the Silo protocol.
Everything you need in one file
The tutorial source code is ready to be executed as a Foundry test in this file. The file contains all use cases and all comments from this page. Refer to the file for a forking setup and smart contract interfaces.
Code interacts with the wstETH / WETH silo market. SILO0 is the wstETH ERC4626 vault, SILO1 is the WETH ERC4626 vault. Silo protocol is permissionless, anyone can deploy the market for the same pair of assets using different market setup.
Deposit
Deposit assets to the silo using ERC4626 deposit function. This example deposits 1 wstETH.
Withdraw all
Withdraw deposit from the silo using ERC4626 withdraw function. It is better to redeem(shares) instead of withdraw(assets) to withdraw full deposit. Interest rate changes the deposited assets continually. In the next block, the assets will have grown large, but the shares will not have changed. This is critical for UI integrations, but on smart contracts level, the asset's amount will not change during one transaction.
Borrow
Borrow WETH with wstETH collateral. To borrow in Silo1 (WETH) the user must provide collateral in Silo0 (wstETH).
Repay all
Repay borrowed WETH with wstETH as collateral. It is better to repayShares(shares) instead of repay(assets) to repay the entire debt. Interest rate changes the debt asset continually. In the next block, the assets will have grown larger, but the shares will not have changed. This is critical for UI integrations, but on SC level, the asset' amount will not change during one transaction.
Last updated