InceptionVaultCore
The IncepionVaultsCore
contract is the main interface for users to interact with the Inception Vault. It handles all the Inception Vault logic, which is the exact same logic used in the Parallel protocol but for a new ERC20 collateral. It also owns the global state (cumulative rate & last refresh) and perform all state updates.
The contract leverages the existing Parallel protocol architecture to perform checks and queries :
Price queries are done through the PriceFeed
Debt calculations are done through the RatesManager
Health checks, liquidation bonus and discounts calculations are done through the LiquidationManager
The contract also stores all ERC20 collaterals.
The Inception VaultConfig
is the equivalent of the CollateralConfig
in the ConfigProvider
with the exception of the collateralType
as there can only be one inceptionCollateral
per inception vault.
This configuration is set by the inception vault owner at deployment.
Param Name | Type | Description |
---|---|---|
| uint256 | LTV ratio from which an inception vault is open for liquidation |
| uint256 | Minimum LTV ratio for a vault to be considered healthy |
| uint256 | The interest rate paid over time by borrowers (e.g. 2%.) |
| uint256 | Fee applied when borrowing/opening a loan |
| uint256 | Liquidation bonus earned by liquidators |
| uint256 | Fee charged to the borrower for getting his collateral liquidated |
Write Methods
initialize(VaultConfig memory vaultConfig, IERC20 inceptionCollateral, IAddressProvider addressProvider, IAdminInceptionVault adminInceptionVault, IInceptionVaultsDataProvider inceptionVaultsDataProvider, IInceptionVaultPriceFeed inceptionPriceFeed)
initialize(VaultConfig memory vaultConfig, IERC20 inceptionCollateral, IAddressProvider addressProvider, IAdminInceptionVault adminInceptionVault, IInceptionVaultsDataProvider inceptionVaultsDataProvider, IInceptionVaultPriceFeed inceptionPriceFeed)
Initializer function to set state variables upon cloning.
Requirements :
Can only be called once
Set liquidation fee must be greater or equal than
WAD
Param Name | Type | Description |
---|---|---|
| struct |
|
| IERC20 | The address of the ERC20 token that will be set as inceptionCollateral |
| IAddressProvider |
|
| IAdminInceptionVault |
|
| IInceptionVaultsDataProvider |
|
| IInceptionVaultPriceFeed |
|
deposit(uint256 _amount)
deposit(uint256 _amount)
Deposits inception collateral ERC20 token into the vault of the owner as collateral. A new vault is created if no vault exists for the caller.
Param Name | Type | Description |
---|---|---|
| uint256 | The amount of tokens to be deposited in WEI |
depositByVaultId(uint256 _vaultId, uint256 _amount)
depositByVaultId(uint256 _vaultId, uint256 _amount)
Deposits inception collateral ERC20 token into the specified vault as collateral.
Param Name | Type | Description |
---|---|---|
| uint256 | The ID of the vault in which to deposit the inceptionCollateral |
| uint256 | The amount of tokens to be deposited in WEI |
depositAndBorrow(uint256 _depositAmount, uint256 _borrowAmount)
depositAndBorrow(uint256 _depositAmount, uint256 _borrowAmount)
Deposit inceptionCollateral ERC20 token into the vault of the msg.sender as collateral and borrows the specified amount of tokens in WEI.
Requirements :
Can only be called by the vault owner
The
AdminInceptionVault
stableX
balance must be greater or equal than the borrowed amountThe operation must not result in an unhealthy vault
Param Name | Type | Description |
---|---|---|
| uint256 | The amount of inception collateral to be deposited in WEI |
| uint256 | The amount of borrowed |
borrow(uint256 _vaultId, uint256 _amount)
borrow(uint256 _vaultId, uint256 _amount)
Borrows new PAR tokens from a vault.
Requirements :
Can only be called by the vault owner
The
AdminInceptionVault
stableX
balance must be greater or equal than the borrowed amountThe operation must not result in an unhealthy vault
Param Name | Type | Description |
---|---|---|
| uint256 | The ID of the vault from which to borrow |
| uint256 | The amount of borrowed inceptionCollateral tokens in WEI |
function withdraw(uint256 _vaultId, uint256 _amount)
function withdraw(uint256 _vaultId, uint256 _amount)
Withdraws inception collateral ERC20 token from a vault.
Requirements :
Can only be called by the vault owner
The operation must not result in an unhealthy vault
Param Name | Type | Description |
---|---|---|
| uint256 | The ID of the vault from which to withdraw the inception collateral |
| uint256 | The amount of inceptionCollateral ERC20 tokens to be withdrawn in WEI |
repay(uint256 _vaultId, uint256 _amount)
repay(uint256 _vaultId, uint256 _amount)
Repays an outstanding PAR balance to a vault and update the outstanding vault debt to the current time.
Param Name | Type | Description |
---|---|---|
| The ID of the vault for which to repay the outstanding debt balance | |
| The amount of PAR tokens in WEI to be repaid |
repayAll(uint256 _vaultId)
repayAll(uint256 _vaultId)
Repay all debt of a vault.
Param Name | Type | Description |
---|---|---|
| uint256 | The ID of the vault for which to repay the debt |
liquidate(uint256 _vaultId)
liquidate(uint256 _vaultId)
Liquidates a vault that is below the liquidation threshold by repaying its outstanding debt.
Requirements :
The vault must be unhealthy
Param Name | Type | Description |
---|---|---|
| uint256 | The ID of the vault to liquidate |
liquidatePartial(uint256 _vaultId, uint256 _amount)
liquidatePartial(uint256 _vaultId, uint256 _amount)
Liquidates a vault partially that is below the liquidation threshold by repaying part of its outstanding debt, update the outstanding vault debt to the current time and pay a liquidation bonus to the liquidator. A liquidation fee can also be applied to the borrower during the liquidation.
Requirements :
The vault must be unhealthy
Param Name | Type | Description |
---|---|---|
| uint256 | The ID of the vault to liquidate |
| uint256 | The amount of debt + liquidation fee to repay |
View Methods
getCumulativeRate()
getCumulativeRate()
Returns the current cumulativeRate
getLastRefresh()
getLastRefresh()
Returns the timestamp of the last cumulativeRate
refresh.
getVaultConfig()
getVaultConfig()
Returns the inception vault configuration.
getA()
getA()
Returns the AddressProvider
address.
getInceptionCollateral()
getInceptionCollateral()
Returns the inception vault collateral.
getAdminInceptionVault()
getAdminInceptionVault()
Returns the AdminInceptionVault
address.
getInceptionVaultsData()
getInceptionVaultsData()
Returns the InceptionVaultsDataProvider
address.
getInceptionPriceFeed()
getInceptionPriceFeed()
Returns the InceptionVaultPriceFeed
address.
Last updated