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:
_pool
address
lending pool to mint inToken
_to
address
address to mint inTokens to
Returns:
shares
uint256
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:
_pool
address
lending pool to burn inToken
_to
address
address to receive underlying tokens
Returns:
amt
uint256
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:
_pool
address
lending pool to borrow from
_amt
uint256
token amount to borrow
_posId
uint256
position id to account the borrow from
_to
address
address to receive underlying tokens
Returns:
shares
uint256
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:
_pool
address
lending pool to repay to
_shares
uint256
shares amount to repay
_posId
uint256
position id to repay to
Returns:
amt
uint256
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:
_mode
uint16
mode for the position
_viewer
address
viewer address that represents the actual position owner
Returns:
posId
uint256
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:
_posId
uint256
position id to change mode
_mode
uint16
new mode to change to
collateralize
Collateralize inTokens to InitCore.
The position's health factor will increase after a successful collateralization.
Parameters:
_posId
uint256
position id to collateralize to
_pool
address
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:
_posId
uint256
position id to decollateralize from
_pool
address
lending pool to decollateralize
_shares
uint256
shares amount to decollateralize
_to
address
address to receive the inTokens
collateralizeWLp
Collateralize supported wrapped LPs to InitCore.
The position's health factor will increase after a successful collateralization.
Parameters:
_posId
uint256
position id to collateralize wLp to
_wLp
address
wrapped LP contract address
_tokenId
uint256
wrapped LP token id
decollateralizeWLp
Decollateralize supported wrapped LPs from InitCore.
The position's health factor will decrease after a successful decollateralization.
Parameters:
_posId
uint256
position id to decollateralize wLp from
_wLp
address
wrapped LP contract address
_tokenId
uint256
wrapped LP token id to decollateralize
_amt
uint256
wrapped LP amount to decollateralize
_to
address
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:
_posId
uint256
position id to liquidate
_poolToRepay
address
lending pool address to repay for liquidation
_repayShares
uint256
shares amount for repay
_poolOut
address
lending pool address to receive inToken collateral from liquidation
_minShares
uint256
min shares for liquidation (slippage control)
Returns:
shares
uint256
shares of _poolOut
received
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:
_posId
uint256
position id to liquidate
_poolToRepay
address
lending pool address to repay for liquidation
_repayShares
uint256
shares amount for repay
_wLp
address
wrapped LP address to receive collateral from liquidation
_tokenId
uint256
wrapped LP token id to receive collateral from liquidation
_minlpOut
uint256
min LP amount for liquidation (slippage control)
Returns:
lpAmtOut
uint256
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:
_pools
address
array of pools to borrow tokens from
_amts
uint256[]
array of token amounts to borrow
_data
bytes
custom data to be passed to flashCallback
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:
_data
bytes[]
array of bytes to perform multicall
Returns:
results
bytes[]
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:
_posId
uint256
position id to get collateral credit
Returns:
collCredit_e36
uint256
collateral credit in 10^36
precision with interest accrual
getBorrowCreditCurrent_e36
Get a position's borrow credit (with borrow interest accrual) with 10^36
precision.
This is not a view function.
Parameters:
_posId
uint256
position id to get borrow credit
Returns:
borrowCredit_e36
uint256
borrow credit in 10^36
precision with interest accrual
getPosHealthCurrent_e18
Get a position's health factor (with borrow interest accrual) with 10^18
precision.
This is not a view function.
Parameters:
_posId
uint256
position id to get health factor
Returns:
health_e18
uint256
health factor in 10^18
precision with interest accrual
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:
_to
address
call target address
_value
uint256
msg.value
to pass to the call
_data
bytes
bytes data of the low-level function call (should also include function signature)
Returns:
result
bytes
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:
_token
address
token address to transfer
_to
address
address to receive the token
_amt
uint256
token amount to transfer
Last updated