Loan Token
Overview
Each Tenor market has its own unique Loan Token. A market's Loan Token is created during the market creation process and serves as a unique market identifier. Loan Tokens are ERC4626-compliant tokens that represent claims on the market's loan asset (e.g., USDC) in the Tenor protocol. Loan Tokens earn the reference Morpho market variable rate.
A market's loan token also serves as the redemption asset for Fixed Tokens at maturity. After maturity, any account can call the settle() method on a single Fixed Token to capture the exchange rate between 1 unit of the loan asset (e.g., USDC) and the value of Loan Tokens. The settlement exchange rate is then used to enable Fixed Token holders to redeem their Fixed Tokens for Loan Tokens at that rate.
The Loan Token contract enables Fixed Token holders to redeem their Fixed Tokens for Loan Tokens. During this settlement process, Fixed Tokens are burned and Loan Tokens are minted. Conversely, Fixed Debts can be settled converting the Fixed Debt into matured debts, and simultaneously burning Loan Tokens.
Loan Tokens also allow for setting a recipient for Morpho related incentives. Only the market's owner can set the recipient. Any external address can claim the incentives from the Morpho Universal Rewarder Contract to the benefit of the recipient.
Key Features
Feature | Description |
---|---|
ERC4626 Compliance | Implements standard vault functionalities for deposit/withdrawal of underlying assets |
Morpho Interactions | Deposits & redeems from the Morpho reference market |
Rewards Distribution | Manages setting a recipient for the Morpho URD contract enabling the recipient to receive protocol rewards attributed to the reference Morpho market |
Fixed Token Creation | Creates Fixed Tokens (PTs) of different maturities |
Fixed Tokens & Fixed Debts Settlement | Handles settlement of Fixed Tokens and Fixed Debts after maturity |
Core Functions
Vault Functions
As an ERC4626-compliant vault, Loan Tokens implement standard deposit, mint, withdraw, and redeem functions that handle the conversion between underlying assets (e.g., USDC) and shares (Loan Tokens).
Deposit and Mint
function deposit(uint256 assets, address receiver) external returns (uint256 shares)
function mint(uint256 shares, address receiver) external returns (uint256 assets)
These functions allow users to deposit underlying assets into the vault:
deposit
: User specifies asset amount, receives corresponding sharesmint
: User specifies share amount, deposits required assets- Both functions:
- Transfer underlying assets from user to the Loan Token.
- The Loan Token supplies the underlying assets to the Morpho reference market.
- Mint corresponding Loan Token shares to receiver.
Withdraw and Redeem
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares)
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets)
These functions allow users to withdraw underlying assets from the vault:
withdraw
: User specifies asset amount to receiveredeem
: User specifies share amount (Loan Token amount) to burn- Both functions:
- Burn the required Loan Token shares
- Withdraw the corresponding amount of assets from the Morpho reference market
- Transfer underlying assets to receiver Note that if the withdrawal is in excess of the available liquidity on the Morpho reference market, the method will revert.
Asset Conversion
function convertToShares(uint256 assets) external view returns (uint256 shares)
function convertToAssets(uint256 shares) external view returns (uint256 assets)
Helper functions for calculating conversions:
convertToShares
: Calculate shares for given asset amountconvertToAssets
: Calculate assets for given share amount- Rates based on:
- Total assets supplied to Morpho
- Current virtualMorphoSupplyShares
- Any accumulated bad debt
Preview Functions
function previewDeposit(uint256 assets) external view returns (uint256 shares)
function previewMint(uint256 shares) external view returns (uint256 assets)
function previewWithdraw(uint256 assets) external view returns (uint256 shares)
function previewRedeem(uint256 shares) external view returns (uint256 assets)
Max Functions
function maxDeposit(address) external view returns (uint256 maxAssets)
function maxMint(address) external view returns (uint256 maxShares)
function maxWithdraw(address owner) external view returns (uint256 maxAssets)
function maxRedeem(address owner) external view returns (uint256 maxShares)
maxWithdraw and maxRedeem functions return the maximum possible amounts based on:
- Available liquidity in Morpho
- User's balance
Fixed Token Creation
function createFixedToken(Seconds maturity) external returns (IFixedToken fixedToken)
- Creates a new Fixed Token instance for a specific maturity. Fixed Tokens are Principal Tokens (PTs) that can be converted to Loan Tokens at a certain redemption exchange rate at maturity.
Settlement Functions
Settle Fixed Tokens
function settleFixed(
IFixedToken fixedToken,
uint256 amount
) external returns (uint256 shares)
- Snapshots the settlement exchange rate if not already snapshot
- Converts matured Fixed Tokens into Loan Tokens at the settlement exchange rate
- Fixed Tokens are burned and Loan Tokens are minted
During the settleFixed process the newly created Loan Tokens increase the Share amount.
The increase of Loan Tokens due to the settlement of Fixed Tokens means that if all Loan Token holders were to redeem their Loan Tokens for assets the redemptions would at some point revert due to the amount of Morpho Shares held by the contract being lower than the virtualMorphoSupplyShares variable held by the contract.
In order to increase the likelihood of redemptions occuring, the protocol tracks a sharesBackingExcess variable that is decreased by the number of Loan Token Shares settled. A negative sharesBackingExcess variable means that third party accounts can settle borrowers with matured debts back to Morpho in order increase the Morpho Shares backing of Loan Tokens.
Settle Debt
function settleDebt(
IFixedToken fixedToken,
address user,
uint256 amount
) external returns (
uint256 sharesß,
ExchangeRate settlementExchangeRate
)
- Settles Fixed Debts for Loan Token Debts after maturity at the settlement exchange rate
The settlement of debts decreases the amount of Loan Tokens shares in circulation. This can cause the amount of Loan Tokens (shares) to decrease while the assets (Morpho Shares) are unchanged. This means that the Loan Token contract holds more actual Morpho Shares compared to the supply * exchange rate. The protocol increases the sharesBackingExcess by the amount of Loan Tokens burned during the settlement process. If the sharesBackingExcess of the Loan Token is positive, all Loan Token holders could redeem their Shares for assets (assuming the reference Morpho market is liquid). In a case where the sharesBackingExcess is positive, third party accounts can't settle borrowers with matured debts, because the Loan Token can already facilitate redemptions.
Rewards Management
function setRewardsRecipient(address rewardsRecipient) external;
- The owner of the market can set the reward recipient address that will receive the rewards claimed from the Morpho Universal Reward Distributor contract.
function claimRewards(address token, uint256 amount) external
- Claims rewards from the Morpho Universal Reward Distributor and sends the rewards to the rewards recipient
Bad debt accrual considerations
In order for the Loan Tokens Shares to asset exchange rate to be monotonic, the Loan Token tracks bad debt accrual in the reference Morpho money market. It does so by tracking the lastMorhpoExchangeRate and the highestRecordedExchangeRate. If the exchangeRate decreases the protocol will continue to use the highest recordedExchangeRate thereby using interest rate accrual to cover the bad debt. This means that new depositors will not earn the supply rate until the bad debt is covered.
To protect against an attacker flash minting Loan Token shares just before a bad debt transaction occurs in the reference Morpho market. Effectively pushing a majority of the market's bad debt to the Loan Token, the contract implements a freeze mechanism to pause actions for 60 seconds between the last action taken and the recording of the bad debt accrual. This mitigates the risk of such a flash loan attack.
Burning of Loan Token Shares on the first mint
The Loan Token is created during the market creation process. As part of the market initialization transaction, the initializer is required to pay a small amount of the asset currency to mint an initial amount of Loan Token Shares.
Exchange Rate Behavior
The exchange rate between Loan Token shares and assets is monotonic:
- Increases as yield accumulates in Morpho
- Is does not decrease due to bad debt accumulation on Morpho
- Is not affected due to Fixed Token and Fixed Debt settlement