Search
K
Links

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 MIMO 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 MIMO 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
liquidationRatio
uint256
LTV ratio from which an inception vault is open for liquidation
minCollateralRatio
uint256
Minimum LTV ratio for a vault to be considered healthy
borrowRate
uint256
The interest rate paid over time by borrowers (e.g. 2%.)
originationFee
uint256
Fee applied when borrowing/opening a loan
liquidationBonus
uint256
Liquidation bonus earned by liquidators
liquidationFee
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)

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
vaultConfig
struct
VaultConfig struct with all inception vault configuration parameters
inceptionCollateral
IERC20
The address of the ERC20 token that will be set as inceptionCollateral
addressProvider
IAddressProvider
AddressProvider address
adminInceptionVault
IAdminInceptionVault
AdminInceptionVault address
inceptionVaultsDataProvider
IInceptionVaultsDataProvider
InceptionVaultsDataProvider address
inceptionPriceFeed
IInceptionVaultPriceFeed
InceptionVaultPriceFeed address

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
_amount
uint256
The amount of tokens to be deposited in WEI

depositByVaultId(uint256 _vaultId, uint256 _amount)

Deposits inception collateral ERC20 token into the specified vault as collateral.
Param Name
Type
Description
_vaultId
uint256
The ID of the vault in which to deposit the inceptionCollateral
_amount
uint256
The amount of tokens to be deposited in WEI

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 amount
  • The operation must not result in an unhealthy vault
Param Name
Type
Description
_depositAmount
uint256
The amount of inception collateral to be deposited in WEI
_borrowAmount
uint256
The amount of borrowed StableX tokens in WEI

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 amount
  • The operation must not result in an unhealthy vault
Param Name
Type
Description
_vaultId
uint256
The ID of the vault from which to borrow
_amount
uint256
The amount of borrowed inceptionCollateral tokens in WEI

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
_vaultId
uint256
The ID of the vault from which to withdraw the inception collateral
_amount
uint256
The amount of inceptionCollateral ERC20 tokens to be withdrawn in WEI

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
_vaultId
The ID of the vault for which to repay the outstanding debt balance
_amount
The amount of PAR tokens in WEI to be repaid

repayAll(uint256 _vaultId)

Repay all debt of a vault.
Param Name
Type
Description
_vaultId
uint256
The ID of the vault for which to repay the debt

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
_vaultId
uint256
The ID of the vault to liquidate

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
_vaultId
uint256
The ID of the vault to liquidate
_amount
uint256
The amount of debt + liquidation fee to repay

View Methods

getCumulativeRate()

Returns the current cumulativeRate

getLastRefresh()

Returns the timestamp of the last cumulativeRate refresh.

getVaultConfig()

Returns the inception vault configuration.

getA()

Returns the AddressProvider address.

getInceptionCollateral()

Returns the inception vault collateral.

getAdminInceptionVault()

Returns the AdminInceptionVault address.

getInceptionVaultsData()

Returns the InceptionVaultsDataProvider address.

getInceptionPriceFeed()

Returns the InceptionVaultPriceFeed address.