IRevolvingCreditLine

Methods

borrow

function borrow(address to, uint256 amount) external nonpayable

To borrow funds from the pool against the order book, the to address has to have a borrowed role. It is not possible to borrow after the current loan maturity has passed.

TickBorrowed event is declared in BorrowerLogic library

Parameters

NameTypeDescription

to

address

Receiving address of the borrowed funds

amount

uint256

Amount of funds to borrow emits a {Borrowed} event and one {TickBorrowed} event per borrowed tick

cancelTimelock

function cancelTimelock() external nonpayable

Cancel a timelock emits a {TimelockCancelled} event

deposit

function deposit(uint256 rate, uint256 amount, address to) external nonpayable returns (uint256 positionId)

Deposit funds to the target rate tick

Parameters

NameTypeDescription

rate

uint256

Rate to which deposit funds

amount

uint256

Amount of funds to deposit

to

address

Receiving address of the position

Returns

NameTypeDescription

positionId

uint256

ID of the newly minted position emits a {Deposited} event

detach

function detach(uint256 positionId) external nonpayable

Withdrawn the unborrowed part of a borrowed position

Parameters

NameTypeDescription

positionId

uint256

ID of the position emits a {Detached} event

executeTimelock

function executeTimelock() external nonpayable

Execute a ready timelock emits a {TimelockExecuted} event

exit

function exit(uint256 positionId, uint256 borrowedAmountToExit) external nonpayable

Exit a position from the current loan

Will reallocate the borrowed part of the position as well as realized accrualas, and withdraw the unborrowed part of the positionborrowedAmountToExit set to type(uint256).max means a full exitpartial exits are only possible for fully matched positionsfull exits will burn the position and need pool approval to transfer itExitedAmountRedistributedInTick event is declared in LenderLogic library

Parameters

NameTypeDescription

positionId

uint256

ID of the position

borrowedAmountToExit

uint256

Address of the fees controller emits an {Exited} event and one {ExitedAmountRedistributedInTick} event per recipient tick

getCurrentAccruals

function getCurrentAccruals() external nonpayable returns (uint256 currentAccruals)

Retrieves the current accruals of the ongoing loan

Returns

NameTypeDescription

currentAccruals

uint256

undefined

getEpoch

function getEpoch(uint256 rate, uint256 epochId) external view returns (uint256 deposited, uint256 borrowed, uint256 accruals, uint256 loanId, bool isBaseEpoch, uint256 precedingLoanId, uint256 positionsCount)

Gets the target epoch data

Parameters

NameTypeDescription

rate

uint256

Rate of the queried tick

epochId

uint256

ID of the queried epoch

Returns

NameTypeDescription

deposited

uint256

Amount of funds deposited into the epoch

borrowed

uint256

Amount of funds borrowed from the epoch

accruals

uint256

Accruals generated by the epoch

loanId

uint256

ID of the first loan of the epoch

isBaseEpoch

bool

Boolean to signify whether the epoch is a base epoch or not

precedingLoanId

uint256

Id of the loan before that epoch loan

positionsCount

uint256

Number of positions in the epoch

getLoanDuration

function getLoanDuration() external view returns (uint256 loanDuration)

Retrieve the pool loan duration

Returns

NameTypeDescription

loanDuration

uint256

The pool loan duration

getMaturity

function getMaturity() external view returns (uint256 maturity)

Retrieve the current maturity

Returns

NameTypeDescription

maturity

uint256

The current maturity

getPosition

function getPosition(uint256 positionId) external view returns (address owner, uint256 rate, uint256 depositedAmount, enum PositionStatus status)

Retrieve the general high level information of a position

Parameters

NameTypeDescription

positionId

uint256

ID of the position

Returns

NameTypeDescription

owner

address

Owner of the position

rate

uint256

Rate of the position

depositedAmount

uint256

Base deposit of the position

status

enum PositionStatus

Current status of the position

getPositionCurrentValue

function getPositionCurrentValue(uint256 positionId) external view returns (uint256 positionCurrentValue)

Retrieve the current overall value of the position, including both borrowed and unborrowed amounts

Parameters

NameTypeDescription

positionId

uint256

ID of the position

Returns

NameTypeDescription

positionCurrentValue

uint256

Current value of the position

getPositionRepartition

function getPositionRepartition(uint256 positionId) external view returns (uint256 unborrowedAmount, uint256 borrowedAmount)

Retrieve the repartition between borrowed amount and unborrowed amount of the position

Parameters

NameTypeDescription

positionId

uint256

ID of the position

Returns

NameTypeDescription

unborrowedAmount

uint256

Amount that is not currently borrowed, and can be withdrawn

borrowedAmount

uint256

Amount that is currently borrowed

getTimelock

function getTimelock() external view returns (struct PoolTimelock timelock)

Retrieve the current timelock

Returns

NameTypeDescription

timelock

PoolTimelock

The current timelock, may be empty

optOut

function optOut(uint256 positionId) external nonpayable

Opt out a borrowed position from a loan and remove it from the borrowable funds

Parameters

NameTypeDescription

positionId

uint256

The ID of the position emits an {OptedOut} event

repay

function repay() external nonpayable

Repay borrowed funds with interest to the pool emits a {Repaid} event and one {TickRepaid} event per repayed tick

TickRepaid event is declared in BorrowerLogic library

setFeesController

function setFeesController(contract IFeesController feesController) external nonpayable

Set the fees controller contract address

Parameters

NameTypeDescription

feesController

contract IFeesController

Address of the fees controller emits a {FeesControllerSet} event

setMaxBorrowableAmount

function setMaxBorrowableAmount(uint256 maxBorrowableAmount) external nonpayable

Update the maximum borrowable amount

Parameters

NameTypeDescription

maxBorrowableAmount

uint256

New value of the maximum borrowable amount emits a {MaxBorrowableAmountSet} event

setMinDepositAmount

function setMinDepositAmount(uint256 minDepositAmount) external nonpayable

Update the minimum deposit amount

Parameters

NameTypeDescription

minDepositAmount

uint256

New value of the minimum deposit amount emits a {MinDepositAmountSet} event

setPositionDescriptor

function setPositionDescriptor(contract IPositionDescriptor positionDescriptor) external nonpayable

Set the position descriptor contract address

Parameters

NameTypeDescription

positionDescriptor

contract IPositionDescriptor

Address of the position descriptor emits a {PositionDescriptorSet} event

setRolloverPeriod

function setRolloverPeriod(uint256 rolloverPeriod) external nonpayable

Update the loan finalization period

Parameters

NameTypeDescription

rolloverPeriod

uint256

New value of the loan finalization period emits a {RolloverPeriodSet} event

startNonStandardRepaymentProcedure

function startNonStandardRepaymentProcedure(contract INonStandardRepaymentModule nonStandardRepaymentModule, uint256 delay) external nonpayable

Starts a non-standard repayment procedure by initiating a timelock for - Stops all native actions possible in the pool - Sends the unborrowed funds to the non standard repayment procedure contract - Initializes the non standard repayment procedure contract

Parameters

NameTypeDescription

nonStandardRepaymentModule

contract INonStandardRepaymentModule

Address of the non standard repayment module contract

delay

uint256

Timelock delay emits a {NonStandardRepaymentProcedureStarted} event

startRescueProcedure

function startRescueProcedure(address recipient, uint256 delay) external nonpayable

Start a rescue procedure by initiating a timelock for - Stops all native actions possible in the pool - Sends the unborrowed funds to a recipient address

Parameters

NameTypeDescription

recipient

address

Address to which the funds will be sent

delay

uint256

Timelock delay emits a {RescueProcedureStarted} event

togglePool

function togglePool() external nonpayable

Closes and Opens the pool If the pool is OPEN, changes the pool phase to CLOSED, stops all actions in the pool If the pool is CLOSED, changes the pool phase to OPEN, opens up all actions in the pool again Emits a {Open} or {Closed} event

updateRate

function updateRate(uint256 positionId, uint256 newRate) external nonpayable

Update the rate of a position

Parameters

NameTypeDescription

positionId

uint256

ID of the position

newRate

uint256

New rate of the position emits a {RateUpdated} event

withdraw

function withdraw(uint256 positionId, uint256 amountToWithdraw) external nonpayable

Withdraw funds from the order book

amountToWithdraw set to type(uint256).max means a full withdrawamountToWithdraw must be set between 0 and positionCurrentValuefull withdrawals need the pool approval to transfer the positiona successful full withdraw will burn the position

Parameters

NameTypeDescription

positionId

uint256

ID of the position

amountToWithdraw

uint256

Address of the fees controller emits a {Withdrawn} event

withdrawFees

function withdrawFees() external nonpayable

Withdraw fees to the fees controller emits a {FeesWithdrawn} event

Events

Borrowed

event Borrowed(uint256 borrowedAmount, uint256 fees, address to)

Emitted during a borow

Parameters

NameTypeDescription

borrowedAmount

uint256

undefined

fees

uint256

undefined

to

address

undefined

Closed

event Closed()

Emitted when the pool is closed

Deposited

event Deposited(uint256 indexed positionId, address to, uint256 amount, uint256 rate, uint256 epochId)

Emitted when a deposit is made on the pool

Parameters

NameTypeDescription

positionId indexed

uint256

undefined

to

address

undefined

amount

uint256

undefined

rate

uint256

undefined

epochId

uint256

undefined

Detached

event Detached(uint256 indexed positionId, uint256 receivedAmount, uint256 withdrawalFees)

Emitted when the unborrowed part of a borrowed position is detached

Parameters

NameTypeDescription

positionId indexed

uint256

undefined

receivedAmount

uint256

undefined

withdrawalFees

uint256

undefined

Exited

event Exited(uint256 indexed positionId, bool isFullyExited, uint256 unborrowedAmount, uint256 borrowedAmountToExit, uint256 receivedAmount, uint256 exitFees)

Emitted when a position is fully exited

Parameters

NameTypeDescription

positionId indexed

uint256

undefined

isFullyExited

bool

undefined

unborrowedAmount

uint256

undefined

borrowedAmountToExit

uint256

undefined

receivedAmount

uint256

undefined

exitFees

uint256

undefined

FeesControllerSet

event FeesControllerSet(address feesController)

Emitted when the fees controller is set

Parameters

NameTypeDescription

feesController

address

undefined

FeesWithdrawn

event FeesWithdrawn(uint256 fees)

Emitted when fees are withdrawn to the fees controller

Parameters

NameTypeDescription

fees

uint256

undefined

MaxBorrowableAmountSet

event MaxBorrowableAmountSet(uint256 maxBorrowableAmount)

Emitted when the maximum borrowable amount has been set

Parameters

NameTypeDescription

maxBorrowableAmount

uint256

undefined

MinDepositAmountSet

event MinDepositAmountSet(uint256 minDepositAmount)

Emitted when the minimum deposit amount has been set

Parameters

NameTypeDescription

minDepositAmount

uint256

undefined

NonStandardRepaymentProcedureStarted

event NonStandardRepaymentProcedureStarted(address nonStandardRepaymentModule, uint256 delay)

Emitted when a non-standard repayment procedure has started

Parameters

NameTypeDescription

nonStandardRepaymentModule

address

undefined

delay

uint256

undefined

Opened

event Opened()

Emitted when the pool is opened

OptedOut

event OptedOut(uint256 indexed positionId, uint256 loanId)

Emitted when a borrowed position is signalling its intention to not be a part of the next loan

Parameters

NameTypeDescription

positionId indexed

uint256

undefined

loanId

uint256

undefined

PositionDescriptorSet

event PositionDescriptorSet(address positionDescriptor)

Emitted when the position descriptor is set

Parameters

NameTypeDescription

positionDescriptor

address

undefined

RateUpdated

event RateUpdated(uint256 indexed positionId, uint256 newRate, uint256 movedAmount)

Emitted when a position's rate is updated

Parameters

NameTypeDescription

positionId indexed

uint256

undefined

newRate

uint256

undefined

movedAmount

uint256

undefined

Repaid

event Repaid(uint256 repaidAmount, uint256 fees)

Emitted during a repayment

Parameters

NameTypeDescription

repaidAmount

uint256

undefined

fees

uint256

undefined

RescueProcedureStarted

event RescueProcedureStarted(address recipient, uint256 delay)

Emitted when a rescue procedure has started

Parameters

NameTypeDescription

recipient

address

undefined

delay

uint256

undefined

RolloverPeriodSet

event RolloverPeriodSet(uint256 rolloverPeriod)

Emitted when the loan finalization period has been set

Parameters

NameTypeDescription

rolloverPeriod

uint256

undefined

TimelockCancelled

event TimelockCancelled()

Emitted when a timelock has been cancelled

TimelockExecuted

event TimelockExecuted(uint256 transferredAmount)

Emitted when a timelock has been executed

Parameters

NameTypeDescription

transferredAmount

uint256

undefined

Withdrawn

event Withdrawn(uint256 indexed positionId, uint256 amountToWithdraw, uint256 receivedAmount, uint256 withdrawalFees)

Emitted when a position is withdrawn

Parameters

NameTypeDescription

positionId indexed

uint256

undefined

amountToWithdraw

uint256

undefined

receivedAmount

uint256

undefined

withdrawalFees

uint256

undefined

Errors

TIMELOCK_ALREADY_EXECUTED

error TIMELOCK_ALREADY_EXECUTED()

Thrown when trying to interact with an already executed timelock

TIMELOCK_ALREADY_INITIATED

error TIMELOCK_ALREADY_INITIATED()

Thrown when trying to interact with an already initiated timelock

TIMELOCK_DELAY_TOO_SMALL

error TIMELOCK_DELAY_TOO_SMALL()

Thrown when the input delay for a timelock is too small

TIMELOCK_INEXISTANT

error TIMELOCK_INEXISTANT()

Thrown when trying to interact with inexistant timelock

TIMELOCK_NOT_READY

error TIMELOCK_NOT_READY()

Thrown when trying to interact with an already executed timelock

Last updated