Silo
ISilo
Silo is the main component of the protocol. It implements lending logic, manages and isolates risk, acts as a vault for assets, and performs liquidations. Each Silo is composed of the unique asset for which it was created (ie. UNI) and bridge assets (ie. ETH and SiloDollar). There may be multiple bridge assets at any given time.
Main Silo contact that inherits from Base contract. It implements all user/UI facing methods.
function ASSET_DECIMAL_POINTS() external view returns (uint256)
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function VERSION() external view returns (uint256)
It tells us which
SiloRepository.siloFactory(version)
created this SiloName | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function accrueInterest(address _asset) external nonpayable
Function to update interests for
_asset
token since the last saved stateName | Type | Description |
---|---|---|
_asset | address | The address of the token to be updated |
function allSiloAssets(uint256) external view returns (address)
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function assetInterestData(address) external view returns (uint256 harvestedProtocolFees, uint256 protocolFees, uint64 interestRateTimestamp, enum IBaseSilo.AssetStatus status)
Name | Type | Description |
---|---|---|
_0 | address | undefined |
Name | Type | Description |
---|---|---|
harvestedProtocolFees | uint256 | undefined |
protocolFees | uint256 | undefined |
interestRateTimestamp | uint64 | undefined |
status | enum IBaseSilo.AssetStatus | undefined |
function assetStorage(address _asset) external view returns (struct IBaseSilo.AssetStorage)
Get asset storage data
Name | Type | Description |
---|---|---|
_asset | address | asset address |
Name | Type | Description |
---|---|---|
_0 | IBaseSilo.AssetStorage | AssetStorage struct |
function borrow(address _asset, uint256 _amount) external nonpayable
Borrow
_amount
of _asset
tokens from the Silo to msg.sender
Name | Type | Description |
---|---|---|
_asset | address | The address of the token to borrow |
_amount | uint256 | The amount of the token to borrow |
function borrowFor(address _asset, address _borrower, address _receiver, uint256 _amount) external nonpayable
Router function to borrow
_amount
of _asset
tokens from the Silo for the _receiver
Name | Type | Description |
---|---|---|
_asset | address | The address of the token to borrow |
_borrower | address | The address of the debt tokens receiver |
_receiver | address | The address of the asset receiver |
_amount | uint256 | The amount of the token to borrow |
function borrowPossible(address _asset, address _borrower) external view returns (bool)
Check if borrowing an asset for given account is possible
Borrowing an asset that has been already deposited (and vice versa) is disallowed
Name | Type | Description |
---|---|---|
_asset | address | asset we want to deposit |
_borrower | address | borrower address |
Name | Type | Description |
---|---|---|
_0 | bool | true if asset can be borrowed by borrower |
function deposit(address _asset, uint256 _amount, bool _collateralOnly) external nonpayable
Deposit
_amount
of _asset
tokens from msg.sender
to the SiloName | Type | Description |
---|---|---|
_asset | address | The address of the token to deposit |
_amount | uint256 | The amount of the token to deposit |
_collateralOnly | bool | True if depositing collateral only |
function depositFor(address _asset, address _depositor, uint256 _amount, bool _collateralOnly) external nonpayable
Router function to deposit
_amount
of _asset
tokens to the Silo for the _depositor
Name | Type | Description |
---|---|---|
_asset | address | The address of the token to deposit |
_depositor | address | The address of the recipient of collateral tokens |
_amount | uint256 | The amount of the token to deposit |
_collateralOnly | bool | True if depositing collateral only |
function depositPossible(address _asset, address _depositor) external view returns (bool)
Check if depositing an asset for given account is possible
Depositing an asset that has been already borrowed (and vice versa) is disallowed
Name | Type | Description |
---|---|---|
_asset | address | asset we want to deposit |
_depositor | address | depositor address |
Name | Type | Description |
---|---|---|
_0 | bool | true if asset can be deposited by depositor |
function flashLiquidate(address[] _users, bytes _flashReceiverData) external nonpayable returns (address[] assets, uint256[][] receivedCollaterals, uint256[][] shareAmountsToRepay)
this methods does not requires to have tokens in order to liquidate user
during liquidation process, msg.sender will be notified once all collateral will be send to him msg.sender needs to be
IFlashLiquidationReceiver
Name | Type | Description |
---|---|---|
_users | address[] | array of users to liquidate |
_flashReceiverData | bytes | this data will be forward to msg.sender on notification |
Name | Type | Description |
---|---|---|
assets | address[] | array of all processed assets (collateral + debt, including removed) |
receivedCollaterals | uint256[][] | seizedCollaterals[userId][assetId] => amount amounts of collaterals send to _flashReceiver |
shareAmountsToRepay | uint256[][] | shareAmountsToRepaid[userId][assetId] => amount required amounts of debt to be repaid |
function getAssets() external view returns (address[] assets)
Returns all initialized (synced) assets of Silo including current and removed bridge assets
Name | Type | Description |
---|---|---|
assets | address[] | array of initialized assets of Silo |
function getAssetsWithState() external view returns (address[] assets, struct IBaseSilo.AssetStorage[] assetsStorage)
Returns all initialized (synced) assets of Silo including current and removed bridge assets with corresponding state
Name | Type | Description |
---|---|---|
assets | address[] | array of initialized assets of Silo |
assetsStorage | IBaseSilo.AssetStorage[] | array of assets state corresponding to assets array |
function harvestProtocolFees(address[] _assets) external nonpayable
harvest protocol fees from an array of assets
Name | Type | Description |
---|---|---|
_assets | address[] | array of assets we want to harvest fees from |
function initAssetsTokens() external nonpayable
this is exposed only for test purposes, but it is safe to leave it like that
function interestData(address _asset) external view returns (struct IBaseSilo.AssetInterestData)
Get asset interest data
Name | Type | Description |
---|---|---|
_asset | address | asset address |
Name | Type | Description |
---|---|---|
_0 | IBaseSilo.AssetInterestData | AssetInterestData struct |
function isSolvent(address _user) external view returns (bool)
Calculates solvency of an account
Name | Type | Description |
---|---|---|
_user | address | wallet address for which solvency is calculated |
Name | Type | Description |
---|---|---|
_0 | bool | true if solvent, false otherwise |
function repay(address _asset, uint256 _amount) external nonpayable
Repay
_amount
of _asset
tokens from msg.sender
to the SiloName | Type | Description |
---|---|---|
_asset | address | The address of the token to repay |
_amount | uint256 | amount of asset to repay, includes interests |
function repayFor(address _asset, address _borrower, uint256 _amount) external nonpayable
Allows to repay in behalf of borrower to execute liquidation
Name | Type | Description |
---|---|---|
_asset | address | The address of the token to repay |
_borrower | address | The address of the user to have debt tokens burned |
_amount | uint256 | amount of asset to repay, includes interests |
function siloAsset() external view returns (address)
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function siloRepository() external view returns (contract ISiloRepository)
Get Silo Repository contract address
Name | Type | Description |
---|---|---|
_0 | contract ISiloRepository | undefined |
function state(address) external view returns (contract IShareToken collateralToken, contract IShareToken collateralOnlyToken, contract IShareToken debtToken, uint256 totalDeposits, uint256 collateralOnlyDeposits, uint256 totalBorrowAmount)
Name | Type | Description |
---|---|---|
_0 | address | undefined |
Name | Type | Description |
---|---|---|
collateralToken | contract IShareToken | undefined |
collateralOnlyToken | contract IShareToken | undefined |
debtToken | contract IShareToken | undefined |
totalDeposits | uint256 | undefined |
collateralOnlyDeposits | uint256 | undefined |
totalBorrowAmount | uint256 | undefined |
function syncBridgeAssets() external nonpayable
Synchronize current bridge assets with Silo
This function needs to be called on Silo deployment to setup all assets for Silo. It needs to be called every time a bridged asset is added or removed. When bridge asset is removed, depositing and borrowing should be disabled during asset sync.
function utilizationData(address _asset) external view returns (struct IBaseSilo.UtilizationData data)
helper method for InterestRateModel calculations
Name | Type | Description |
---|---|---|
_asset | address | undefined |
Name | Type | Description |
---|---|---|
data | IBaseSilo.UtilizationData | undefined |
function withdraw(address _asset, uint256 _amount, bool _collateralOnly) external nonpayable
Withdraw
_amount
of _asset
tokens from the Silo to msg.sender
Name | Type | Description |
---|---|---|
_asset | address | The address of the token to withdraw |
_amount | uint256 | The amount of the token to withdraw |
_collateralOnly | bool | True if withdrawing collateral only deposit |
function withdrawFor(address _asset, address _depositor, address _receiver, uint256 _amount, bool _collateralOnly) external nonpayable
Router function to withdraw
_amount
of _asset
tokens from the Silo for the _depositor
Name | Type | Description |
---|---|---|
_asset | address | The address of the token to withdraw |
_depositor | address | The address of the collateral tokens source account |
_receiver | address | The address of the asset receiver |
_amount | uint256 | The amount of the token to withdraw |
_collateralOnly | bool | True if withdrawing collateral only deposit |
event Borrow(address indexed asset, address indexed user, uint256 amount)
Emitted on asset borrow
Name | Type | Description |
---|---|---|
asset indexed | address | undefined |
user indexed | address | undefined |
amount | uint256 | undefined |
event Deposit(address indexed asset, address indexed depositor, uint256 amount, bool collateralOnly)
Emitted when deposit is made
Name | Type | Description |
---|---|---|
asset indexed | address | undefined |
depositor indexed | address | undefined |
amount | uint256 | undefined |
collateralOnly | bool | undefined |
event Liquidate(address indexed asset, address indexed user, uint256 shareAmountRepaid, uint256 seizedCollateral)
Emitted on user liquidation
Name | Type | Description |
---|---|---|
asset indexed | address | undefined |
user indexed | address | undefined |
shareAmountRepaid | uint256 | undefined |
seizedCollateral | uint256 | undefined |
event Repay(address indexed asset, address indexed user, uint256 amount)
Emitted on asset repay
Name | Type | Description |
---|---|---|
asset indexed | address | undefined |
user indexed | address | undefined |
amount | uint256 | undefined |
event Withdraw(address indexed asset, address indexed depositor, address indexed receiver, uint256 amount, bool collateralOnly)
Emitted when withdraw is made
Name | Type | Description |
---|---|---|
asset indexed | address | undefined |
depositor indexed | address | undefined |
receiver indexed | address | undefined |
amount | uint256 | undefined |
collateralOnly | bool |