Minting Process Flow
This document describes the process of minting leveraged and pegged tokens in Harbor Protocol.
Overview
Users can mint two types of tokens:
- Leveraged Tokens: Provide leveraged exposure to the underlying asset
- Pegged Tokens: Provide 1:1 exposure to the underlying asset
Minting Leveraged Tokens
Step-by-Step Process
-
User Initiates Mint
- User calls
mintLeveragedToken(amount)on the Minter contract - Provides collateral (e.g., wstETH)
- User calls
-
Price Oracle Query
- Minter queries the price oracle for current collateral and asset prices
- Calculates exchange rate based on current prices
-
Fee Calculation
- Protocol fees are calculated based on the mint amount
- Fees are sent to the fee receiver contract
-
Reserve Pool Update
- A portion of collateral is allocated to the reserve pool
- Reserve pool balance is updated
-
Token Minting
- Leveraged tokens are minted to the user
- Amount minted = (collateral amount - fees - reserve) × leverage ratio / asset price
-
Event Emission
LeveragedTokenMintedevent is emitted with details
Example Flow
User deposits 10 wstETH
↓
Price Oracle: 1 wstETH = $3000, 1 ETH = $3000
↓
Fees: 0.5% = 0.05 wstETH → Fee Receiver
Reserve: 1% = 0.1 wstETH → Reserve Pool
Net: 9.85 wstETH
↓
Leverage: 3x
Minted: (9.85 × 3) / 1 = 29.55 leveraged tokens
Minting Pegged Tokens
Step-by-Step Process
-
User Initiates Mint
- User calls
mintPeggedToken(amount)on the Minter contract - Provides collateral (e.g., wstETH)
- User calls
-
Price Oracle Query
- Minter queries price oracle for current prices
- Calculates 1:1 exchange rate
-
Fee Calculation
- Protocol fees are calculated
- Fees sent to fee receiver
-
Reserve Pool Update
- Reserve allocation is made
-
Token Minting
- Pegged tokens are minted 1:1 with collateral value
- Amount minted = (collateral amount - fees - reserve) / asset price
-
Event Emission
PeggedTokenMintedevent is emitted
Example Flow
User deposits 10 wstETH
↓
Price Oracle: 1 wstETH = $3000, 1 ETH = $3000
↓
Fees: 0.5% = 0.05 wstETH → Fee Receiver
Reserve: 1% = 0.1 wstETH → Reserve Pool
Net: 9.85 wstETH
↓
Minted: 9.85 pegged tokens (1:1 ratio)
Requirements
Pre-Minting Checks
- Sufficient collateral balance
- Protocol is not paused
- Price oracle is not stale
- Minimum mint amount requirements met
- Maximum leverage limits not exceeded
Post-Minting State
- User receives minted tokens
- Fees distributed to fee receiver
- Reserve pool updated
- Protocol state updated
Burning Tokens
The reverse process (burning) follows similar steps:
- User calls
burnLeveragedToken(amount)orburnPeggedToken(amount) - Tokens are burned
- Collateral is calculated based on current prices
- Fees are deducted
- Remaining collateral is returned to user
Gas Considerations
- Minting operations require multiple contract calls
- Price oracle updates may be needed
- Multiple token transfers occur
- Gas costs vary based on network conditions