Smart contracts architecture
Last updated
Last updated
Silo is the main component of the protocol, which consists of two 4626 vaults with one token asset underpinning each vault. The silo, also referred to as a lending market, implements lending logic and manages and isolates risk. Silos are permissionless to deploy via Silo Factory and are immutable to change by default after deployments except when the deployer uses upgradable settings.
Each silo market is represented by two ERC-4626 vaults. Silo0 is a vault for the first silo asset, silo1 is a vault for the second asset. Standardized yield-bearing vault deposits represent borrowable deposits to the lending market.
For more information, see the ERC-4626 tokenized vault standard.
When a user deposits into a silo, they can choose to make the deposit available for borrowing or not. Borrowable deposits earn interest, while non-borrowable deposits do not. One advantage of making a deposit non-borrowable is that the depositor can always withdraw from the silo even when it has no available liquidity.
The Silo Protocol Hooks System provides an extensible mechanism for interacting with core actions like deposits, withdrawals, borrowing, repayments, leverage operations, collateral transitions, switching collateral, flash loans, and liquidations. Hooks allow external systems to execute custom logic before or after protocol actions, offering flexibility for validation, logging, or integration with external contracts. While the protocol is fully functional without them, hooks enhance its modularity and allow for seamless interaction with other decentralized systems. For more information, see Hooks.md.
Liquidations ensure the markets - silos -remain solvent. Anyone can perform liquidations when collateral exceeds the set liquidation threshold (LT.)
Silo liquidation module key concepts:
Silo accepts any liquidation mechanism, including the partial liquidation. The Liquidation module is implemented utilizing the Silo Hooks System and is presented as a hook. For more details on implementation see PartialLiquidation.sol.
Liquidations are always permissionless and incentivized to perform. After completing a liquidation, a liquidator receives a reward in the form of a liquidation fee. The deployer sets the fee for each market and can't change it. Developers can resolve a fee from the SiloConfig contract.
The silo liquidation module is designed to do partial liquidations. However, full liquidation can be forced if liquidation leaves some 'dust'.
For each asset in a silo, there are two ERC-20 tokens deployed and one ERC20R:
Vault shares (ERC-20). Due to EIP-4626 tokenized Vaults specification, each silo implements EIP-20 to represent shares. This token represents user-deposited assets that can be borrowed (Borrowable deposit.)
Share protected collateral token (ERC-20). This token represents user-deposited assets that can't be borrowed (Protected collateral).
Share debt token (ERC20R). These tokens are minted to represent debt.
A silo uses the mint and burn functions to operate the two underlying token assets. Meanwhile, the transfer is still available and can be used by any third-party application (Wallet, DEX, etc.). The two underlying token assets support hooks and notify third-party smart contracts about transfer operations. This simple hook provides enough information to reverse engineer the exact action happening in the core protocol.
For more information, see Share token transfer hook, Share debt token transfer hook. GaugeHookReceiver notifies the gauge whenever the balance is updated is a good example of how to use the share token transfer hook.
The price oracle role is to provide the silo with the correct value of an asset. To function correctly in the silo, each oracle should implement ISiloOracle interface. The two-asset silo can use one oracle for both token assets, two oracles for each asset, or no oracle.
Each token may use up to two oracles, solvency oracle and maxLtv oracle. The Solvency oracle is used to calculate whether the user is solvent. MaxLtv oracle is used to calculate the collateral's borrowing power, or how much it can borrow in value. MaxLtv is always set below the Liquidation Threshold (LT), which is a value used for solvency math.
In brief, each token asset underlying the silo can use both solvency and maxLtv oracles, one solvency oracle, one maxLtv oracle, or none. If both solvency and maxLtv oracles are set, each is used for its designed purpose. If only solvency oracle is set, maxLtv calculations will fall back to using solvency oracle. If only maxLtv oracle is set, maxLtv calculation will use it, but solvency calculations will default prices to "1". If no oracle is set, all prices are assumed to be "1", that is, if token0 has no oracle set, it means token1 has oracle that is returning the value of token1 denominated in token0.
Oracles available to deployers to use
Chainlink V3 oracle is an oracle module that is responsible for pulling the correct price of a given asset from Chainlink Price Feeds.
Uniswap V3 oracle is an oracle module that is responsible for pulling the correct price of a given asset from UniswapV3 pools. It performs security checks and returns TWAP prices when requested.
DIA oracle is an oracle module that is responsible for pulling the correct prices of a given asset from DIA Price Feeds.
The interest rate model (IRM) is a mathematical algorithm the protocol uses to automatically set the borrowing interest rate (also known as the borrowing APY). The interest rate model is set for each of the silo's two assets with specific configuration.
Silo Interest model V2 is a dynamic interest rate model. In control-theoretic parlance, we designed a PI controller with a deadband in the proportional term and some other modifications. With the current model, we achieve the following goals:
Optimal operation where the system reaches a stable equilibrium state at an optimal utilization level Uopt, i.e., to keep the utilization in a neighborhood of Uopt while holding the interest rate relatively constant.
Utilization stays below a critical level Ucrit even in volatile market conditions as a safety measure to ensure liquidity.
An attractive interest rate for borrowers. The interest rate quickly reacts when utilization drops too low (below a certain level, Ulow).
Guaranteed returns on deposits even if the utilization is low, the Silo interest rate model will keep a small but non-zero interest rate.