用于铸造和赎回FRAX,以及回购多余抵押品的合约
Frax池合约是由治理系统部署和批准的,这意味着在治理提案成功执行后,可以随时添加新的抵押品类型。目前的池是USDC,未来池将开放更多的抵押品类型。
USDC: 0x3C2982CA260e870eee70c423818010DfeF212659
Frax池是一种智能合约,为用户存入抵押品来铸造Frax代币,或通过赎回发送到合约中的Frax来取回抵押品。每个Frax池都有不同类型的可接受抵押品。Frax 池可以支持任何类型的加密货币,但稳定币由于其价格的小波动,是最容易实现的。Frax的设计初衷是接受任何类型的加密货币作为抵押品,但低波动性池在一开始是首选,因为它们不会不规则地改变抵押品比率。有一些很有前途的新项目,比如Reflex Bonds,它们抑制了基础加密资产的波动性。Reflex Bonds可能成为未来理想的FRAX抵押品。新的Frax池可以通过FXS治理投票添加。
每个池合约都有一个池上限(可存储用于铸造FRAX的最大允许抵押品)和资产的价格信息流。最初的Frax池将是USDC (USD Coin)和USDT (Tether),因为它们在以太坊上拥有巨大市值、稳定性和可用性。
这些池通过对FRAXStablecoin (FRAX)和FRAXShare (FXS)合约的授权调用来创建和赎回协议代币。
合约有3个铸造函数:mint1t1FRAX(), mintFractionalFRAX()和mintAlgorithmicFRAX()。该合约还有3个赎回函数,它们与铸造函数对应:redeem1t1FRAX(), redeemFractionalFRAX(), redeemAlgorithmicFRAX()。
这些函数被分成1比1阶段、部分抵押阶段和纯算法阶段,以优化Gas费。1比1的铸币和赎回功能只有在抵押率为100%时才可用。部分抵押铸造和赎回函数仅在担保比率为99.99%和0.01%之间可用。纯算法铸造和赎回函数只能在0%的比例可用。
每个铸造和赎回函数都有一个AMOUNT_out_min
参数,该参数指定交易者预期的最小代币单元。这作为提交交易时滑点范围的限制,因为从交易创建时到区块打包期间价格可能会发生变化。
https://docs.openzeppelin.com/contracts/3.x/api/access#AccessControl
Instance for the collateral token in the pool.
Address of the collateral token.
List of the pool owners.
Address of the oracle contract.
Address of the FRAX contract.
Address of the FXS contract.
Address of the timelock contract.
Instance of the FXS contract.
Instance of the FRAX contract.
Instance of the oracle contract.
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.
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.
Sum of the redeemCollateralBalances
.
Sum of the redeemFXSBalances
.
Keeps track of the last block a given address redeemed.
Maximum amount of collateral the pool can take.
AccessControl
role for the mint pauser.
AccessControl
role for the redeem pauser.
AccessControl
role for the buyback pauser.
Whether or not minting is paused.
Whether or not redeem is paused.
Whether or not buyback is paused.
unclaimedFXS
Return the total amount of unclaimed FXS.
unclaimedCollateral
Return the total amount of unclaimed collateral.
collatDollarBalance
Return the pool's total balance of the collateral token, in USD.
availableExcessCollatDV
Return the pool's excess balance of the collateral token (over that required by the collateral ratio), in USD.
getCollateralPrice
Return the price of the pool's collateral in USD.
mint1t1FRAX
Mint FRAX from collateral. Valid only when the collateral ratio is 1.
mintFractionalFRAX
Mint FRAX from collateral and FXS. Valid only when the collateral ratio is between 0 and 1.
mintAlgorithmicFRAX
Mint FRAX from FXS. Valid only when the collateral ratio is 0.
redeem1t1FRAX
Redeem collateral from FRAX. Valid only when the collateral ratio is 1. Must call collectionRedemption()
later to collect.
redeemFractionalFRAX
Redeem collateral and FXS from FRAX. Valid only when the collateral ratio is between 0 and 1. Must call collectionRedemption()
later to collect.
redeemAlgorithmicFRAX
Redeem FXS from FRAX. Valid only when the collateral ratio is 0. Must call collectionRedemption()
later to collect.
collectRedemption
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
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
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
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
toggleMinting
Toggle the ability to mint.
toggleRedeeming
Toggle the ability to redeem.
toggleBuyBack
Toggle the ability to buyback.
setPoolCeiling
Set the pool_ceiling
, which is the total units of collateral that the pool contract can hold.
setOracle
Set the oracle_address
.
setCollateralAdd
Set the collateral_address
.
addOwner
Add an address to the array of owners.
removeOwner
Remove an owner from the owners array.
onlyByOwnerOrGovernance
Restrict actions to the governance contract or the owner(s).
notRedeemPaused
Ensure redemption is not paused.
notMintPaused
Ensure minting is not paused.