Frax Pools
Contract used for minting and redeeming FRAX, as well as buying back excess collateral.

Deployment

Frax Pool contracts are deployed and permissioned from the governance system, meaning that a new type of collateral may be added at any time after a governance proposal succeeds and is executed. The current pool is USDC, with further collateral types open for future pools.
USDC: 0x3C2982CA260e870eee70c423818010DfeF212659

Description

A Frax Pool is the smart contract that mints FRAX tokens to users for placing collateral or returns collateral by redeeming FRAX sent into the contract. Each Frax Pool has a different type of accepted collateral. Frax Pools can be in any kind of cryptocurrency, but stablecoins are easiest to implement due to their small fluctuations in price. Frax is designed to accept any type of cryptocurrency as collateral, but low volatility pools are preferred at inception since they do not change the collateral ratio erratically. There are promising new projects, such as Reflex Bonds, which dampen the volatility of their underlying crypto assets. Reflex Bonds could make for ideal FRAX collateral in the future. New Frax Pools can be added through FXS governance votes.
Each pool contract has a pool ceiling (the maximum allowable collateral that can be stored to mint FRAX) and a price feed for the asset. The initial Frax Pool at genesis will be USDC (USD Coin) and USDT (Tether) due to their large market capitalization, stability, and availability on Ethereum.
The pools operate through permissioned calls to the FRAXStablecoin (FRAX) and FRAXShare (FXS) contracts to mint and redeem the protocol tokens.

Minting and Redeeming FRAX

The contract has 3 minting functions: mint1t1FRAX(), mintFractionalFRAX(), and mintAlgorithmicFRAX(). The contract also has 3 redemption functions that mirror the minting functions: redeem1t1FRAX(), redeemFractionalFRAX(), redeemAlgorithmicFRAX(). The functions are separated into 1 to 1, fractional, and algorithmic phases to optimize gas usage. The 1 to 1 minting and redemption functions are only available when the collateral ratio is 100%. The fractional minting and redemption functions are only available between a collateral ratio of 99.99% and 0.01%. The algorithmic minting and redemption functions are only available at a ratio of 0%.

Slippage

Each of the minting and redeeming functions also has an AMOUNT_out_min parameter that specifies the minimum units of tokens expected from the transaction. This acts as a limit for slippage tolerance when submitting transactions, as the prices may update from the time a transaction is created to the time it is included in a block.

State Variables

AccessControl (Inherited)

FraxPool-Specific

1
ERC20 private collateral_token
Copied!
Instance for the collateral token in the pool.
1
address private collateral_address
Copied!
Address of the collateral token.
1
address[] private owners
Copied!
List of the pool owners.
1
address private oracle_address
Copied!
Address of the oracle contract.
1
address private frax_contract_address
Copied!
Address of the FRAX contract.
1
address private fxs_contract_address
Copied!
Address of the FXS contract.
1
address private timelock_address
Copied!
Address of the timelock contract.
1
FRAXShares private FXS
Copied!
Instance of the FXS contract.
1
FRAXStablecoin private FRAX
Copied!
Instance of the FRAX contract.
1
UniswapPairOracle private oracle
Copied!
Instance of the oracle contract.
1
mapping (address => uint256) private redeemFXSBalances
Copied!
Keeps track of redemption balances for a given address. A redeemer cannot both request redemption and actually redeem their FRAX in the same block. This is to prevent flash loan exploits that could crash FRAX and/or FXS prices. They have to wait until the next block. This particular variable is for the FXS portion of the redemption.
1
mapping (address => uint256) private redeemCollateralBalances
Copied!
Keeps track of redemption balances for a given address. A redeemer cannot both request redemption and actually redeem their FRAX in the same block. This is to prevent flash loan exploits that could crash FRAX and/or FXS prices. They have to wait until the next block. This particular variable is for the collateral portion of the redemption.
1
uint256 public unclaimedPoolCollateral
Copied!
Sum of the redeemCollateralBalances.
1
uint256 public unclaimedPoolFXS
Copied!
Sum of the redeemFXSBalances.
1
mapping (address => uint256) lastRedeemed
Copied!
Keeps track of the last block a given address redeemed.
1
uint256 private pool_ceiling
Copied!
Maximum amount of collateral the pool can take.
1
bytes32 private constant MINT_PAUSER
Copied!
AccessControl role for the mint pauser.
1
bytes32 private constant REDEEM_PAUSER
Copied!
AccessControl role for the redeem pauser.
1
bytes32 private constant BUYBACK_PAUSER
Copied!
AccessControl role for the buyback pauser.
1
bool mintPaused = false
Copied!
Whether or not minting is paused.
1
bool redeemPaused = false
Copied!
Whether or not redeem is paused.
1
bool buyBackPaused = false
Copied!
Whether or not buyback is paused.

View Functions

unclaimedFXS
1
unclaimedFXS(address _account) public view returns (uint256)
Copied!
Return the total amount of unclaimed FXS.
unclaimedCollateral
1
unclaimedCollateral(address _account) public view returns (uint256)
Copied!
Return the total amount of unclaimed collateral.
collatDollarBalance
1
collatDollarBalance() public view returns (uint256)
Copied!
Return the pool's total balance of the collateral token, in USD.
availableExcessCollatDV
1
availableExcessCollatDV() public view returns (uint256)
Copied!
Return the pool's excess balance of the collateral token (over that required by the collateral ratio), in USD.
getCollateralPrice
1
getCollateralPrice() public view returns (uint256)
Copied!
Return the price of the pool's collateral in USD.

Public Functions

mint1t1FRAX
1
mint1t1FRAX(uint256 collateral_amount_d18) external notMintPaused
Copied!
Mint FRAX from collateral. Valid only when the collateral ratio is 1.
mintFractionalFRAX
1
mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount) external notMintPaused
Copied!
Mint FRAX from collateral and FXS. Valid only when the collateral ratio is between 0 and 1.
mintAlgorithmicFRAX
1
mintAlgorithmicFRAX(uint256 fxs_amount_d18) external notMintPaused
Copied!
Mint FRAX from FXS. Valid only when the collateral ratio is 0.
redeem1t1FRAX
1
redeem1t1FRAX(uint256 FRAX_amount) external notRedeemPaused
Copied!
Redeem collateral from FRAX. Valid only when the collateral ratio is 1. Must call collectionRedemption() later to collect.
redeemFractionalFRAX
1
redeemFractionalFRAX(uint256 FRAX_amount) external notRedeemPaused
Copied!
Redeem collateral and FXS from FRAX. Valid only when the collateral ratio is between 0 and 1. Must call collectionRedemption() later to collect.
redeemAlgorithmicFRAX
1
redeemAlgorithmicFRAX(uint256 FRAX_amount) external notRedeemPaused
Copied!
Redeem FXS from FRAX. Valid only when the collateral ratio is 0. Must call collectionRedemption() later to collect.
collectRedemption
1
collectRedemption() public
Copied!
After a redemption happens, transfer the newly minted FXS and owed collateral from this pool contract to the user. Redemption is split into two functions to prevent flash loans from being able to take out FRAX / collateral from the system, use an AMM to trade the new price, and then mint back into the system.
buyBackFXS
1
buyBackFXS(uint256 FXS_amount) external
Copied!
Function can be called by an FXS holder to have the protocol buy back FXS with excess collateral value from a desired collateral pool. This can also happen if the collateral ratio > 1
recollateralizeAmount
1
recollateralizeAmount() public view returns (uint256 recollateralization_left)
Copied!
When the protocol is recollateralizing, we need to give a discount of FXS to hit the new CR target. Returns value of collateral that must increase to reach recollateralization target (if 0 means no recollateralization)
recollateralizeFrax
1
recollateralizeFrax(uint256 collateral_amount_d18) public
Copied!
Thus, if the target collateral ratio is higher than the actual value of collateral, minters get FXS for adding collateral. This function simply rewards anyone that sends collateral to a pool with the same amount of FXS + .75%. Anyone can call this function to recollateralize the protocol and take the hardcoded .75% arb opportunity

Restricted Functions

toggleMinting
1
toggleMinting() external onlyMintPauser
Copied!
Toggle the ability to mint.
toggleRedeeming
1
toggleRedeeming() external onlyRedeemPauser
Copied!
Toggle the ability to redeem.
toggleBuyBack
1
toggleBuyBack() external onlyBuyBackPauser
Copied!
Toggle the ability to buyback.
setPoolCeiling
1
setPoolCeiling(uint256 new_ceiling) external onlyByOwnerOrGovernance
Copied!
Set the pool_ceiling, which is the total units of collateral that the pool contract can hold.
setOracle
1
setOracle(address new_oracle) external onlyByOwnerOrGovernance
Copied!
Set the oracle_address.
setCollateralAdd
1
setCollateralAdd(address _collateral_address) external onlyByOwnerOrGovernance
Copied!
Set the collateral_address.
addOwner
1
addOwner(address owner_address) external onlyByOwnerOrGovernance
Copied!
Add an address to the array of owners.
removeOwner
1
removeOwner(address owner_address) external onlyByOwnerOrGovernance
Copied!
Remove an owner from the owners array.

Modifiers

onlyByOwnerOrGovernance
1
onlyByOwnerOrGovernance()
Copied!
Restrict actions to the governance contract or the owner(s).
notRedeemPaused
1
notRedeemPaused()
Copied!
Ensure redemption is not paused.
notMintPaused
1
notMintPaused()
Copied!
Ensure minting is not paused.
Last modified 5mo ago