FraxNetDeposit
Overview
FraxNetDeposit
is a cross-chain deposit and redemption contract used in the Fraxnet ecosystem. It enables the minting of frxUSD
from USDC
, and its transfer to another chain using LayerZero’s OFT mechanism. It also supports redemption of frxUSD
to USDC
using either a custodian or RWA-based redemption path.
This contract serves as the implementation for EIP-1967 (opens in a new tab) Beacon Proxies deployed from the FraxNetDeposit
Factory contract
Key Features
- Deposits USDC to mint frxUSD
- Sends frxUSD cross-chain via LayerZero
- Redeems frxUSD back to USDC conditionally
- Integrates with Circle’s CCTP
Initialization
constructor(address _factory)
function initialize(uint32 _targetEid, bytes32 _targetAddress)
- Called once by the factory upon deployment.
- Sets target LayerZero endpoint and target recipient address.
Constants
Name | Type | Description |
---|---|---|
frxUSD | IERC20 | frxUSD token address (immutable) |
USDC | IERC20 | USDC token address (immutable) |
oft | address | LayerZero OFT address for frxUSD |
State Variables
Name | Type | Description |
---|---|---|
wasInitialized | bool | Whether this contract has been initialized |
factory | FraxNetDepositFactory | The factory contract that deployed this instance |
targetEid | uint32 | Destination LayerZero endpoint ID |
targetAddress | bytes32 | Target address in bytes32 format on destination chain |
Events
Name | Description |
---|---|
ProcessedDepoist | Emitted after successful USDC deposit and frxUSD send |
ProcessedRedemption | Emitted after successful frxUSD redemption to USDC |
Custom Errors
Error | Description |
---|---|
Forbidden() | Caller is not authorized |
InsufficientBalance() | Not enough tokens to complete the operation |
TransferFailed() | Native token transfer failed |
CCTPNotConfiguredForThisChain() | No CCTP domain configured for target chain |
AlreadyInitialized() | Initialization was already performed |
Functions
Deposit Flow
function processDeposit(uint256 amount) external payable
-
User must have previously sent USDC, or other stablecoin, to their
FraxNetDeposit
contract. -
Caller must be an operator.
-
Transfers USDC from sender, mints
frxUSD
using custodian. -
Sends frxUSD to
targetAddress
via:- Direct transfer (if Ethereum)
- LayerZero OFT (if other chains)
Redemption Flow
function processRedemption(uint256 amount) external
-
User must have previously sent frxUSD to their
FraxNetDeposit
contract. -
Caller must be an operator.
-
Redeems
frxUSD
forUSDC
using:- USDC custodian (if amount <
rwaRedemptionThreshold
and sufficient liquidity exists) - RWA redeemer otherwise
- USDC custodian (if amount <
-
Sends USDC to target:
- Direct transfer (if Ethereum)
- Circle CCTP (if other chains)
Quoting
function quote(uint256 amount) external view returns (IRemoteHop.MessagingFee memory)
- Uses RemoteHop to return a LayerZero quote for a given USDC amount.
Admin
function recoverERC20(address tokenAddress, uint256 tokenAmount, address recipient) external
- Allows factory owner to recover ERC20 tokens.
Utility Functions
function scaleUpTo1e18(uint256 amount1e6) public pure returns (uint256)
function scaleDownTo1e6(uint256 amount1e18) public pure returns (uint256)
- Helper conversions between
1e6
and1e18
decimal representations.
Dependencies
FraxNetDepositFactory
IRemoteHop
,IFrxUSDCustodian
,IRWAUSDCRedeemer
,ITokenMessenger
Notes
- Factory is used for access control (e.g. setting operators, recovering tokens)
- Deposit vs redemption paths are optimized for cost and RWA handling
- Emits events for every successful cross-chain or redemption operation
Author: Frax Finance License: AGPL-3.0-only