InitCore
The main entry point of INIT.
View Functions
POS_MANAGER
PosManager contract address.
config
Config contract address
oracle
InitOracle contract address
liqIncentiveCalculator
LiqIncentiveCalculator contract address
riskManager
RiskManager contract address
External Functions
mintTo
Mint inToken from a lending pool using the balance difference (∆balance) between the current and last stored balances. Users should transfer in the pool's underlying token before calling this function.
This is a low-level function call. Make sure to atomically send tokens and call mintTo.
Parameters:
Name | Type | Description |
---|---|---|
|
| lending pool to mint inToken |
|
| address to mint inTokens to |
Returns:
Name | Type | Description |
---|---|---|
|
| amount of inToken minted |
burnTo
Burn inToken for the pool's underlying token. Lending pool must have enough idle liquidity to transfer out the converted amount of underlying token.
This is a low-level function call. Make sure to atomically send inTokens and call burnTo.
Parameters:
Name | Type | Description |
---|---|---|
|
| lending pool to burn inToken |
|
| address to receive underlying tokens |
Returns:
Name | Type | Description |
---|---|---|
|
| amount of underlying tokens out |
borrow
Borrow pool's underlying tokens from InitCore. Lending pool must have enough idle liquidity to borrow. Debt ceiling and borrow cap must also not be reached for the borrowing to succeed. Position health must also be healthy after the borrowing.
The position's health factor will increase after a successful borrow.
Parameters:
Name | Type | Description |
---|---|---|
|
| lending pool to borrow from |
|
| token amount to borrow |
|
| position id to account the borrow from |
|
| address to receive underlying tokens |
Returns:
Name | Type | Description |
---|---|---|
|
| debt shares for the borrow |
repay
Repay pool's underlying tokens to InitCore.
The position's health factor will decrease after a successful repay.
Parameters:
Name | Type | Description |
---|---|---|
|
| lending pool to repay to |
|
| shares amount to repay |
|
| position id to repay to |
Returns:
Name | Type | Description |
---|---|---|
|
| corresponding token amount repaid |
createPos
Create a new position under the specified mode.
viewer
address does not have any effect on the on-chain logic. It is only used for tracking the actual position owner in case the integrating protocol interacts with InitCore on behalf of the user.
Parameters:
Name | Type | Description |
---|---|---|
|
| mode for the position |
|
| viewer address that represents the actual position owner |
Returns:
Name | Type | Description |
---|---|---|
|
| new position id |
setPosMode
Set a new position mode to an existing position.
The mode change might be invalid due to several reasons, for example, the debt ceiling reached on the new mode or some tokens are not supported on the new mode.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to change mode |
|
| new mode to change to |
collateralize
Collateralize inTokens to InitCore.
The position's health factor will increase after a successful collateralization.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to collateralize to |
|
| lending pool to collateralize |
decollateralize
Decollateralize inTokens from InitCore.
The position's health factor will decrease after a successful decollateralization.
Decollateralize will transfer inTokens to the specified receiver address. If the underlying token is desired, users can burn
the received inTokens.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to decollateralize from |
|
| lending pool to decollateralize |
|
| shares amount to decollateralize |
|
| address to receive the inTokens |
collateralizeWLp
Collateralize supported wrapped LPs to InitCore.
The position's health factor will increase after a successful collateralization.
Parameters:
Name | Type` | Description |
---|---|---|
|
| position id to collateralize wLp to |
|
| wrapped LP contract address |
|
| wrapped LP token id |
decollateralizeWLp
Decollateralize supported wrapped LPs from InitCore.
The position's health factor will decrease after a successful decollateralization.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to decollateralize wLp from |
|
| wrapped LP contract address |
|
| wrapped LP token id to decollateralize |
|
| wrapped LP amount to decollateralize |
|
| address to receive the underlying LP. |
liquidate
Liquidate unhealthy position by repaying partial debt and receiving a portion of the collateral, with a small liquidation premium.
A position can only be liquidated if the position is unhealthy (health factor < 1).
A liquidator can only liquidate a position until the position's health factor does not exceed the Config.maxHealthAfterLiq_e18
value.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to liquidate |
|
| lending pool address to repay for liquidation |
|
| shares amount for repay |
|
| lending pool address to receive inToken collateral from liquidation |
|
| min shares for liquidation (slippage control) |
Returns:
Name | Type | Description |
---|---|---|
|
| shares of |
liquidateWLp
Liquidate unhealthy position by repaying partial debt and receiving a portion of the WLp collateral, with a small liquidation premium.
A position can only be liquidated if the position is unhealthy (health factor < 1).
A liquidator can only liquidate a position until the position's health factor does not exceed the Config.maxHealthAfterLiq_e18
value.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to liquidate |
|
| lending pool address to repay for liquidation |
|
| shares amount for repay |
|
| wrapped LP address to receive collateral from liquidation |
|
| wrapped LP token id to receive collateral from liquidation |
|
| min LP amount for liquidation (slippage control) |
Returns:
Name | Type | Description |
---|---|---|
|
| LP amount received |
flash
Flashloan tokens from InitCore and return them in the same transaction.
flash
will invoke flashCallback
to the msg.sender
to execute arbitrary data.
The caller must implement flashCallback
function. It is also recommended that the flashCallback
function validates that the caller is InitCore. (require(msg.ender == INIT_CORE);)
Parameters:
Name | Type | Description |
---|---|---|
|
| array of pools to borrow tokens from |
|
| array of token amounts to borrow |
|
| custom data to be passed to |
multicall
Multicall to allow batched transactions from the caller. Any positions interacted in the multicall will delay the health check to the end of the multicall. This allows users to be able to borrow tokens out before providing collaterals to InitCore.
Parameters:
Name | Type | Description |
---|---|---|
|
| array of bytes to perform multicall |
Returns:
Name | Type | Description |
---|---|---|
|
| array of bytes containing the return data of each sub-call |
getCollateralCreditCurrent_e36
Get a position's collateral credit (with borrow interest accrual) with 10^36
precision.
This is not a view function.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to get collateral credit |
Returns:
Name | Type | Description |
---|---|---|
|
| collateral credit in |
getBorrowCreditCurrent_e36
Get a position's borrow credit (with borrow interest accrual) with 10^36
precision.
This is not a view function.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to get borrow credit |
Returns:
Name | Type | Description |
---|---|---|
|
| borrow credit in |
getPosHealthCurrent_e18
Get a position's health factor (with borrow interest accrual) with 10^18
precision.
This is not a view function.
Parameters:
Name | Type | Description |
---|---|---|
|
| position id to get health factor |
Returns:
Name | Type | Description |
---|---|---|
|
| health factor in |
callback
Execute a callback function from InitCore to the target address with custom data and msg.value
. This should be used in conjunction with multicall
.
The target address must implement coreCallback
function. It is also recommended that coreCallback
function validates that the caller is InitCore. (require(msg.ender == INIT_CORE);
Parameters:
Name | Type | Description |
---|---|---|
|
| call target address |
|
|
|
|
| bytes data of the low-level function call (should also include function signature) |
Returns:
Name | Type | Description |
---|---|---|
|
| bytes-encoded return data of the call |
transferToken
Transfer tokens from the caller to the specified address. This should be used in conjunction with multicall
to facilitate token transfers for depositing to lending pools.
The caller must pre-approves the InitCore before the function call.
Parameters:
Name | Type | Description |
---|---|---|
|
| token address to transfer |
|
| address to receive the token |
|
| token amount to transfer |
Last updated