Frax (FRAX)

Modified ERC-20 Contract representing the FRAX stablecoin.


State Variables

ERC-20 (Inherited)

AccessControl (Inherited) NOTE: FRAX & FXS contracts have no pause or blacklist controls in any way (including system contracts).


enum PriceChoice { FRAX, FXS }

An enum declaring FRAX and FXS. Used with oracles.

ChainlinkETHUSDPriceConsumer eth_usd_pricer

Instance for the Chainlink ETH / USD trading. Combined with FRAX / WETH, FXS / WETH, collateral / FRAX, and collateral / FXS trading pairs, can be used to calculate FRAX/FXS/Collateral prices in USD.

uint8 eth_usd_pricer_decimals

Decimals for the Chainlink ETH / USD trading pair price.

UniswapPairOracle fraxEthOracle

Instance for the FRAX / WETH Uniswap pair price oracle.

UniswapPairOracle fxsEthOracle

Instance for the FXS / WETH Uniswap pair price oracle.

address[] public owners

Array of owner address, who have privileged actions.

address governance_address

Address of the governance contract.

address public creator_address

Address of the contract creator.

address public timelock_address

Address of the timelock contract.

address public fxs_address

Address of the FXS contract

address public frax_eth_oracle_address

Address for the fraxEthOracle .

address public fxs_eth_oracle_address

Address for the fxsEthOracle .

address public weth_address

Address for the canonical wrapped-Ethereum (WETH) contract. Should be 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 for the mainnet.

address public eth_usd_consumer_address

Address for the ChainlinkETHUSDPriceConsumer .

uint256 public genesis_supply

Genesis supply of FRAX. Should be a small nonzero amount. Most of the FRAX supply will come from minting, but a small amount is needed initially to prevent divide-by-zero errors in various functions.

address[] frax_pools_array

Array of all the FraxPool contract addresses.

mapping(address => bool) public frax_pools

Essentially the same as frax_pools_array , but in mapping form. Useful for gas savings in various functions like globalCollateralValue() .

uint256 public global_collateral_ratio

The current ratio of FRAX to collateral, over all FraxPool s.

uint256 public redemption_fee

The fee for redeeming FRAX for FXS and/or collateral. Also the fee for buying back excess collateral with FXS. See the FraxPool contract for usage.

uint256 public minting_fee

The fee for minting FRAX from FXS and/or collateral. See the FraxPool contract for usage.


Set in the constructor. Used in AccessControl .

bytes32 public constant COLLATERAL_RATIO_PAUSER

A constant used in the pausing of the collateral ratio.

bool public collateral_ratio_paused

Whether or not the collateral ratio is paused.

View Functions


oracle_price(PriceChoice choice) internal view returns (uint256)

Get the FRAX or FXS price, in USD.


frax_price() public view returns (uint256)

Returns the price for FRAX from the FRAX-ETH Chainlink price oracle.


fxs_price() public view returns (uint256)

Returns the price for FXS from the FXS-ETH Chainlink price oracle.


frax_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256)

Returns some commonly-used state variables and computed values. This is needed to avoid costly repeat calls to different getter functions. It is cheaper gas-wise to just dump everything and only use some of the info.


globalCollateralValue() public view returns (uint256)

Iterate through all FRAX pools and calculate all value of collateral in all pools globally. This uses the oracle price of each collateral.

Public Functions


refreshCollateralRatio() public

This function checks the price of FRAX and refreshes the collateral ratio if the price is not $1. If the price is above $1, then the ratio is lowered by .5%. If the price is below $1, then the ratio is increased by .5%. Anyone can poke this function to change the ratio. This function can only be called once every hour.

Restricted Functions


mint(uint256 amount) public virtual onlyByOwnerOrGovernance

Public implementation of internal _mint().


pool_burn_from(address b_address, uint256 b_amount) public onlyPools

Used by pools when user redeems.


pool_mint(address m_address, uint256 m_amount) public onlyPools

This function is what other frax pools will call to mint new FRAX.


addPool(address pool_address) public onlyByOwnerOrGovernance

Adds collateral addresses supported, such as tether and busd, must be ERC20.


removePool(address pool_address) public onlyByOwnerOrGovernance

Remove a pool.


setOwner(address owner_address) public onlyByOwnerOrGovernance

Sets the admin of the contract


setFraxStep(uint256 _new_step) public onlyByOwnerOrGovernance

Sets the amount that the collateral ratio will change by upon an execution of refreshCollateralRatio(),


setPriceTarget(uint256 _new_price_target) public onlyByOwnerOrGovernance

Set the price target to be used for refreshCollateralRatio() (does not affect minting/redeeming).


setRefreshCooldown(uint256 _new_cooldown) public onlyByOwnerOrGovernance

Set refresh cooldown for refreshCollateralRatio().


setRedemptionFee(uint256 red_fee) public onlyByOwnerOrGovernance

Set the redemption fee.


setMintingFee(uint256 min_fee) public onlyByOwnerOrGovernance

Set the minting fee.


setFXSAddress(address _fxs_address) public onlyByOwnerOrGovernance

Set the FXS address.


setETHUSDOracle(address _eth_usd_consumer_address) public onlyByOwnerOrGovernance

Set the ETH / USD oracle address.


setFRAXEthOracle(address _frax_addr, address _weth_address) public onlyByOwnerOrGovernance

Sets the FRAX / ETH Uniswap oracle address


setFXSEthOracle(address _fxs_addr, address _weth_address) public onlyByOwnerOrGovernance

Sets the FXS / ETH Uniswap oracle address


toggleCollateralRatio() public onlyCollateralRatioPauser 

Toggle pausing / unpausing the collateral ratio.



FRAXBurned(address indexed from, address indexed to, uint256 amount)

Emitted when FRAX is burned, usually from a redemption by the pool.




Restrict actions to the designated collateral ratio pauser.



Restrict actions to pool contracts, e.g. minting new FRAX.



Restrict actions to the governance contract, e.g. setting the minting and redemption fees, as well as the oracle and pool addresses.



Restrict actions to the governance contract or owner account(s), e.g. setting the minting and redemption fees, as well as the oracle and pool addresses.

Last updated