fraxnet
Contracts
Fraxnet Deposit

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

NameTypeDescription
frxUSDIERC20frxUSD token address (immutable)
USDCIERC20USDC token address (immutable)
oftaddressLayerZero OFT address for frxUSD

State Variables

NameTypeDescription
wasInitializedboolWhether this contract has been initialized
factoryFraxNetDepositFactoryThe factory contract that deployed this instance
targetEiduint32Destination LayerZero endpoint ID
targetAddressbytes32Target address in bytes32 format on destination chain

Events

NameDescription
ProcessedDepoistEmitted after successful USDC deposit and frxUSD send
ProcessedRedemptionEmitted after successful frxUSD redemption to USDC

Custom Errors

ErrorDescription
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 for USDC using:

    • USDC custodian (if amount < rwaRedemptionThreshold and sufficient liquidity exists)
    • RWA redeemer otherwise
  • 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 and 1e18 decimal representations.

Dependencies

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