Lender.sol
This document describes the functions, attributes and modifiers in Lender.sol
Lender
Author: Sourabh Marathe, Julian Traversa, Rob Robbins
The lender contract executes loans on behalf of users
The contract holds the principal tokens and mints an ERC-5095 tokens to users to represent their loans
State Variables
HOLD
minimum wait before the admin may withdraw funds or change the fee rate
admin
address that is allowed to set and withdraw fees, disable principals, etc. It is commonly used in the authorized modifier.
marketPlace
address of the MarketPlace contract, used to access the markets mapping
paused
mapping that determines if a principal has been paused by the admin
halted
flag that allows admin to stop all lending and minting across the entire protocol
swivelAddr
contract used to execute swaps on Swivel's exchange
pendleAddr
a SushiSwap router used by Pendle to execute swaps
apwineAddr
a pool router used by APWine to execute swaps
premiums
a mapping that tracks the amount of unswapped premium by market. This underlying is later transferred to the Redeemer during Swivel's redeem call
feenominator
this value determines the amount of fees paid on loans
feeChange
represents a point in time where the feenominator may change
MIN_FEENOMINATOR
represents a minimum that the feenominator must exceed
fees
maps underlying tokens to the amount of fees accumulated for that token
withdrawals
maps a token address to a point in time, a hold, after which a withdrawal can be made
_NOT_ENTERED
_ENTERED
_status
MAX_VALUE
maximum amount of value that can flow through a protocol in a day (in USD)
protocolFlow
maps protocols to how much value, in USD, has flowed through each protocol
periodStart
timestamp from which values flowing through protocol has begun
etherPrice
estimated price of ether, set by the admin
Functions
authorized
ensures that only a certain address can call the function
Parameters
Name | Type | Description |
---|---|---|
|
| address that msg.sender must be to be authorized |
unpaused
reverts on all markets where the paused mapping returns true
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| principal value according to the MarketPlace's Principals Enum |
matured
reverts if called after maturity
Parameters
Name | Type | Description |
---|---|---|
|
| maturity (timestamp) of the market |
nonReentrant
prevents users from re-entering contract
constructor
initializes the Lender contract
Parameters
Name | Type | Description |
---|---|---|
|
| the Swivel contract |
|
| the Pendle contract |
|
| the APWine contract |
approve
approves the redeemer contract to spend the principal tokens held by the lender contract.
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| the address being approved, in this case the redeemer contract |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if the approval was successful |
approve
bulk approves the usage of addresses at the given ERC20 addresses.
the lengths of the inputs must match because the arrays are paired by index
Parameters
Name | Type | Description |
---|---|---|
|
| array of ERC20 token addresses that will be approved on |
|
| array of addresses that will be approved |
Returns
Name | Type | Description |
---|---|---|
|
| true if successful |
approve
approves market contracts that require lender approval
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| APWine's router contract |
|
| Element's vault contract |
|
| Notional's token contract |
|
| Sense's periphery contract |
setAdmin
sets the admin address
Parameters
Name | Type | Description |
---|---|---|
|
| address of a new admin |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
setFee
sets the feenominator to the given value
Parameters
Name | Type | Description |
---|---|---|
|
| the new value of the feenominator, fees are not collected when the feenominator is 0 |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
setMarketPlace
sets the address of the marketplace contract which contains the addresses of all the fixed rate markets
Parameters
Name | Type | Description |
---|---|---|
|
| the address of the marketplace contract |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if the address was set |
setEtherPrice
sets the ethereum price which is used in rate limiting
Parameters
Name | Type | Description |
---|---|---|
|
| the new price |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if the price was set |
mint
mint swaps the sender's principal tokens for Illuminate's ERC5095 tokens in effect, this opens a new fixed rate position for the sender on Illuminate
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount being minted |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if the mint was successful |
lend
lend method for the Illuminate and Yield protocols
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount of underlying tokens to lend |
|
| Yield Space Pool for the principal token |
|
| slippage limit, minimum amount to PTs to buy |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
lend
lend method signature for Swivel
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| array of amounts of underlying tokens lent to each order in the orders array |
|
| Yield Space Pool for the Illuminate PT in this market |
|
| array of Swivel orders being filled |
|
| array of signatures for each order in the orders array |
|
| flag to indicate if returned funds should be swapped in Yield Space Pool |
|
| slippage limit, minimum amount to PTs to buy |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
lend
lend method signature for Element
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount of underlying tokens to lend |
|
| slippage limit, minimum amount to PTs to buy |
|
| deadline is a timestamp by which the swap must be executed |
|
| Element pool that is lent to |
|
| the id of the pool |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
lend
lend method signature for Pendle
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount of underlying tokens to lend |
|
| slippage limit, minimum amount to PTs to buy |
|
| guess parameters for the swap |
|
| contract that corresponds to the market for the PT |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
lend
lend method signature for Tempus and APWine
Parameters
Name | Type | Description |
---|---|---|
|
| value of a specific principal according to the Illuminate Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount of principal tokens to lend |
|
| minimum amount to return when executing the swap (sets a limit to slippage) |
|
| deadline is a timestamp by which the swap must be executed |
|
| Tempus or APWine AMM that executes the swap |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
lend
lend method signature for Sense
this method can be called before maturity to lend to Sense while minting Illuminate tokens
Sense provides a [divider] contract that splits [target] assets (underlying) into PTs and YTs. Each [target] asset has a [series] of contracts, each identifiable by their [maturity].
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount of underlying tokens to lend |
|
| slippage limit, minimum amount to PTs to buy |
|
| periphery contract that is used to conduct the swap |
|
| Sense's maturity for the given market |
|
| Sense's adapter necessary to facilitate the swap |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
lend
lend method signature for Notional
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
|
| amount of underlying tokens to lend |
|
| slippage limit, minimum amount to PTs to buy |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of principal tokens lent out |
scheduleWithdrawal
allows the admin to schedule the withdrawal of tokens
Parameters
Name | Type | Description |
---|---|---|
|
| address of (erc20) token to withdraw |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
blockWithdrawal
emergency function to block unplanned withdrawals
Parameters
Name | Type | Description |
---|---|---|
|
| address of token withdrawal to block |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
scheduleFeeChange
allows the admin to schedule a change to the fee denominators
blockFeeChange
Emergency function to block unplanned changes to fee structure
withdraw
allows the admin to withdraw the given token, provided the holding period has been observed
Parameters
Name | Type | Description |
---|---|---|
|
| Address of token to withdraw |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
withdrawFee
withdraws accumulated lending fees of the underlying token
Parameters
Name | Type | Description |
---|---|---|
|
| address of the underlying token to withdraw |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
pause
pauses a market and prevents execution of all lending for that principal
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| bool representing whether to pause or unpause |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful |
pauseIlluminate
pauses Illuminate's redeem, mint and lend methods from being used
Parameters
Name | Type | Description |
---|---|---|
|
| bool representing whether to pause or unpause Illuminate |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successfully set |
transferFYTs
Tranfers FYTs to Redeemer (used specifically for APWine redemptions)
Parameters
Name | Type | Description |
---|---|---|
|
| FYT contract address |
|
| amount of tokens to send to the redeemer |
transferPremium
Transfers premium from the market to Redeemer (used specifically for Swivel redemptions)
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
batch
Allows batched call to self (this contract).
Parameters
Name | Type | Description |
---|---|---|
|
| An array of inputs for each call. |
yield
swaps underlying premium via a Yield Space Pool
this method is only used by the Yield, Illuminate and Swivel protocols
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| Yield Space Pool for the principal token |
|
| amount of underlying tokens to lend |
|
| the receiving address for PTs |
|
| the principal token in the Yield Space Pool |
|
| the minimum amount to purchase |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 the amount of tokens sent to the Yield Space Pool |
swivelAmount
returns the amount of underlying tokens to be used in a Swivel lend
swivelVerify
reverts if any orders are not for the market
elementSwap
executes a swap for and verifies receipt of Element PTs
apwineTokenPath
returns array token path required for APWine's swap method
Returns
Name | Type | Description |
---|---|---|
|
| array of uint256[] as laid out in APWine's docs |
apwinePairPath
returns array pair path required for APWine's swap method
Returns
Name | Type | Description |
---|---|---|
|
| array of uint256[] as laid out in APWine's docs |
principalToken
retrieves the ERC5095 token for the given market
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| maturity (timestamp) of the market |
Returns
Name | Type | Description |
---|---|---|
|
| address of the ERC5095 token for the market |
convertDecimals
converts principal decimal amount to underlying's decimal amount
Parameters
Name | Type | Description |
---|---|---|
|
| address of an underlying asset |
|
| address of a principal token |
|
| amount denominated in principal token's decimals |
Returns
Name | Type | Description |
---|---|---|
|
| uint256 in underlying decimals |
rateLimit
limits the amount of funds (in USD value) that can flow through a principal in a day
Parameters
Name | Type | Description |
---|---|---|
|
| principal value according to the MarketPlace's Principals Enum |
|
| address of an underlying asset |
|
| amount being minted which is normalized to 18 decimals prior to check |
Returns
Name | Type | Description |
---|---|---|
|
| bool true if successful, reverts otherwise |
Events
Lend
emitted upon lending to a protocol
Mint
emitted upon minting Illuminate principal tokens
ScheduleWithdrawal
emitted upon scheduling a withdrawal
BlockWithdrawal
emitted upon blocking a scheduled withdrawal
SetAdmin
emitted upon changing the admin
SetFee
emitted upon setting the fee rate
ScheduleFeeChange
emitted upon scheduling a fee change
BlockFeeChange
emitted upon blocking a scheduled fee change
PausePrincipal
emitted upon pausing or unpausing of a principal
PauseIlluminate
emitted upon pausing or unpausing minting, lending and redeeming
Last updated