Router.sol
Router
The router is the entry point for interacting with the LombardFi system. All of the transfers from user to pool are executed by the router. Much of the verification logic is done in the router to compress the size of the Pool contract.
poolFactory
Address of the PoolFactory.
oracleManager
Address of the OracleManager.
treasury
Address of the protocol treasury.
Receives the origination fee at pool creation.
nonZero
Verify that an integer is greater than 0.
Throws an error if the uint256 is equal to 0
Parameters
amt
uint256
The integer to check.
nonZeroAddress
Verify that an address is not the zero address.
Throws an error if the address is the zero address.
Parameters
_address
address
The address to check.
setFactory
Set the PoolFactory implementation address.
Callable only by the owner.
Throws an error if the supplied address is the zero address.
Parameters
_poolFactory
contract IPoolFactory
The new implementation.
setOracleManager
Set the OracleManager implementation address.
Callable only by the owner.
Throws an error if the address is the zero address.
Parameters
_oracleManager
contract IOracleManager
The new implementation.
setTreasury
Set the treasury address. Callable only by the owner.
Throws an error if the address is the zero address.
Parameters
_treasury
address
The new recipient.
pause
Pause the contract. Callable only by the owner.
unpause
Unpause the contract. Callable only by the owner.
The contract must be paused to unpause it.
deposit
Deposit into a pool.
The contract must not be paused. _amt
must be nonzero.
A pool with the _pid
must exist.
Caller must not be the pool's borrower.
Caller must be the whitelisted lender if the pool has one.
Caller must have approved this contract to spend _amt
of the pool's lent asset.
The pool must not be active or mature.
The pool must have sufficient open capacity for _amt
.
Parameters
_pid
uint256
The id of the pool to deposit in.
_amt
uint256
The amount of the pool's lent asset to deposit.
borrow
Borrow the available amount of lent asset from a pool. Transfers the pool's lent asset from pool to borrower. Transfers collateral from borrower to pool.
The contract must not be paused.
A pool with the _pid
must exist.
Caller must be the pool's borrower.
Lengths of _collateralAssets
and amts
must match.
_collateralAssets
must be the pool's collateral assets or a subset.
The pool must be active.
The pool's minimum deposit must have been reached.
The loan amount and value of the supplied collateral must satisfy the loan-to-value ratio.
Parameters
_pid
uint256
The id of the pool to borrow from.
_collateralAssets
address[]
The assets to deposit as collateral
_amts
uint256[]
The amounts corresponding to the collaterals
repay
Repay a part of the loan. Transfers the pool's lent asset from borrower to pool. Transfers collateral from pool to borrower.
A pool with the _pid
must exist. _amt
must be nonzero.
The contract must not be paused.
Pool must be active if the router is under normal operation.
Caller must be the pool's borrower.
The pool must be active.
Parameters
_pid
uint256
The id of the pool to repay in.
_amt
uint256
The amount of the pool's lent asset to repay.
redeem
Redeem notional and yield from a mature pool or redeem notional from an unsuccessful pool. Transfers the pool's lent asset from pool to caller. Transfers collateral from caller to pool.
The contract must not be paused.
A pool with the _pid
must exist.
Caller must not be the pool's borrower.
The pool must be mature or active with less deposits than the minimum.
Caller must have made a deposit.
Caller can redeem only once per pool.
Parameters
_pid
uint256
The id of the pool to redeem from.
withdrawLeftovers
Withdraw redundant yield from a pool. Transfers a part of the upfront for the unrealised size back to the borrower.
The contract must not be paused.
A pool with the _pid
must exist.
Caller must be the pool's borrower.
Borrower can withdraw only once.
The pool must be active.
Parameters
_pid
uint256
The id of the pool to withdraw leftovers from.
getBorrowingPower
Utility function that returns the value of collateral. Prices are fetched from the OracleManager.
Also used for off-chain data retrieval.
Parameters
_collateralAssets
address[]
Array of collateral assets.
_amts
uint256[]
The amounts corresponding to the collateral assets.
Return Values
_borrowingPower
uint256
The total value of the collateral.
_assetsAreValidPoolCollateral
Utility function that checks whether an array of addresses match pool collateral. They must be a subset.
Parameters
_pool
contract IPool
The pool to check the assets against.
_assets
address[]
The array of ERC20 token addresses to check against the pool.
Return Values
[0]
bool
Whether the given assets are valid subset of pool collateral.
_verifyCallerIsNotBorrower
Private function that verifies that the caller is not the pool's borrower.
Parameters
_pool
contract IPool
The pool contract.
_getPool
Private function that gets a pool address from a pool id.
Throws an error if a pool with the _pid
does not exist.
Parameters
_pid
uint256
The id of the pool to get the address of.
Return Values
_pool
contract IPool
The pool contract.
Last updated