FraxNet
Stablecoins as a Service (SaaS)
Branded Custodian

BrandedCustodian

Overview

BrandedCustodian is an ERC-4626-style vault that custodies the frxUSD backing a branded stablecoin instance. It acts as the primary PSM (Peg Stability Module) for the branded stablecoin, ensuring it is always redeemable 1:1 for frxUSD on a given chain.

Key Features

  • ERC-4626 compatible deposit/mint/withdraw/redeem interface
  • 1:1 backing of branded tokens with frxUSD
  • Configurable mint and redeem fees
  • Mint cap enforcement
  • Optional isolated backing mode for siloed collateral configurations
  • Reentrancy protected

Initialization

function initialize(
  address _brandedCoin,
  address _localFrxUSD,
  address _owner,
  uint256 _mintCap,
  uint256 _mintFee,
  uint256 _redeemFee
) public
  • Called once by the BrandedFactory upon deployment.
  • Sets the branded stablecoin (shares), frxUSD (asset), owner, mint cap, and fees.

State Variables

NameTypeDescription
brandedStablecoinIGDollarThe branded stablecoin token (shares)
custodianTknIERC20The underlying asset (frxUSD)
brandedTknDecimalsuint8Decimals of the branded stablecoin
custodianTknDecimalsuint8Decimals of frxUSD
mintFeeuint256Fee applied on minting (18 decimals)
redeemFeeuint256Fee applied on redemption (18 decimals)
mintCapuint256Maximum branded tokens that can be minted
brandedCoinMinteduint256Running total of branded tokens minted
isolatedBackingEnabledboolWhether isolated backing mode is active
routeraddressCrossChainRouter address (if isolated backing)
individualCustodianaddressSiloed custodian address (if isolated backing)

Functions

Deposit Flow

function deposit(uint256 _assetsIn, address _receiver) public returns (uint256 _sharesOut)
  • Deposits frxUSD and mints branded stablecoin tokens to _receiver.
  • Caller must approve the custodian to spend frxUSD first.
  • Reverts if _assetsIn exceeds maxDeposit(_receiver).
function mint(uint256 _sharesOut, address _receiver) public returns (uint256 _assetsIn)
  • Mints an exact amount of branded tokens by pulling the required frxUSD from the caller.
  • Reverts if _sharesOut exceeds maxMint(_receiver).

Redemption Flow

function redeem(uint256 _sharesIn, address _receiver, address _owner) public returns (uint256 _assetsOut)
  • Burns branded tokens and returns frxUSD to _receiver.
  • _owner must be msg.sender.
  • Reverts if _sharesIn exceeds maxRedeem(_owner).
function withdraw(uint256 _assetsOut, address _receiver, address _owner) public returns (uint256 _sharesIn)
  • Withdraws an exact amount of frxUSD by burning the required branded tokens.
  • _owner must be msg.sender.
  • Reverts if _assetsOut exceeds maxWithdraw(_owner).

Preview Functions

function previewDeposit(uint256 _assetsIn) public view returns (uint256 _sharesOut)
function previewMint(uint256 _sharesOut) public view returns (uint256 _assetsIn)
function previewRedeem(uint256 _sharesIn) public view returns (uint256 _assetsOut)
function previewWithdraw(uint256 _assetsOut) public view returns (uint256 _sharesIn)
  • Simulate the effects of deposit, mint, redeem, and withdraw operations at the current block.
  • All preview functions account for mint/redeem fees.

View Functions

function totalAssets() public view returns (uint256)
function totalSupply() public view returns (uint256)
function pricePerShare() external view returns (uint256)
function maxDeposit(address) public view returns (uint256)
function maxMint(address) public view returns (uint256)
function maxRedeem(address owner) public view returns (uint256)
function maxWithdraw(address owner) public view returns (uint256)

Admin Functions

function setMintRedeemFee(uint256 _mintFee, uint256 _redeemFee) public onlyOwner
function setMintCap(uint256 _mintCap) public onlyOwner
function recoverERC20(address _tokenAddress, uint256 _tokenAmount) external onlyOwner

Events

NameDescription
DepositEmitted after a successful deposit or mint
WithdrawEmitted after a successful withdrawal or redemption
MintCapSetEmitted when the mint cap is updated
RecoveredERC20Emitted when ERC20 tokens are recovered by the owner

Custom Errors

ErrorDescription
ERC4626ExceededMaxDepositAttempted to deposit more than the max
ERC4626ExceededMaxMintAttempted to mint more than the cap allows
MintCapExceededMint cap exceeded during deposit
ERC4626ExceededMaxWithdrawAttempted to withdraw more than max
ERC4626ExceededMaxRedeemAttempted to redeem more than max
InitializeFailedContract already initialized
TokenOwnerShouldBeSender_owner param must be msg.sender
NotIsolatedBackingCaller not authorized under isolated backing mode

Author: Frax Finance License: MIT