FRAX池
用于铸造和赎回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
参数,该参数指定交易者预期的最小代币单元。这作为提交交易时滑点范围的限制,因为从交易创建时到区块打包期间价格可能会发生变化。ERC20 private collateral_token
Instance for the collateral token in the pool.
address private collateral_address
Address of the collateral token.
address[] private owners
List of the pool owners.
address private oracle_address
Address of the oracle contract.
address private frax_contract_address
Address of the FRAX contract.
address private fxs_contract_address
Address of the FXS contract.
address private timelock_address
Address of the timelock contract.
FRAXShares private FXS
Instance of the FXS contract.
FRAXStablecoin private FRAX
Instance of the FRAX contract.
UniswapPairOracle private oracle
Instance of the oracle contract.
mapping (address => uint256) private redeemFXSBalances
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.
mapping (address => uint256) private redeemCollateralBalances
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.
uint256 public unclaimedPoolCollateral
Sum of the
redeemCollateralBalances
.uint256 public unclaimedPoolFXS
Sum of the
redeemFXSBalances
.mapping (address => uint256) lastRedeemed
Keeps track of the last block a given address redeemed.
uint256 private pool_ceiling
Maximum amount of collateral the pool can take.
bytes32 private constant MINT_PAUSER
AccessControl
role for the mint pauser.bytes32 private constant REDEEM_PAUSER
AccessControl
role for the redeem pauser.bytes32 private constant BUYBACK_PAUSER
AccessControl
role for the buyback pauser.bool mintPaused = false
Whether or not minting is paused.
bool redeemPaused = false
Whether or not redeem is paused.
bool buyBackPaused = false
Whether or not buyback is paused.
unclaimedFXS
unclaimedFXS(address _account) public view returns (uint256)
Return the total amount of unclaimed FXS.
unclaimedCollateral
unclaimedCollateral(address _account) public view returns (uint256)
Return the total amount of unclaimed collateral.
collatDollarBalance
collatDollarBalance() public view returns (uint256)
Return the pool's total balance of the collateral token, in USD.
availableExcessCollatDV
availableExcessCollatDV() public view returns (uint256)
Return the pool's excess balance of the collateral token (over that required by the collateral ratio), in USD.
getCollateralPrice
getCollateralPrice() public view returns (uint256)
Return the price of the pool's collateral in USD.
mint1t1FRAX
mint1t1FRAX(uint256 collateral_amount_d18) external notMintPaused
Mint FRAX from collateral. Valid only when the collateral ratio is 1.
mintFractionalFRAX
mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount) external notMintPaused
Mint FRAX from collateral and FXS. Valid only when the collateral ratio is between 0 and 1.
mintAlgorithmicFRAX
mintAlgorithmicFRAX(uint256 fxs_amount_d18) external notMintPaused
Mint FRAX from FXS. Valid only when the collateral ratio is 0.
redeem1t1FRAX
redeem1t1FRAX(uint256 FRAX_amount) external notRedeemPaused
Redeem collateral from FRAX. Valid only when the collateral ratio is 1. Must call
collectionRedemption()
later to collect.redeemFractionalFRAX
redeemFractionalFRAX(uint256 FRAX_amount) external notRedeemPaused
Redeem collateral and FXS from FRAX. Valid only when the collateral ratio is between 0 and 1. Must call
collectionRedemption()
later to collect.redeemAlgorithmicFRAX
redeemAlgorithmicFRAX(uint256 FRAX_amount) external notRedeemPaused
Redeem FXS from FRAX. Valid only when the collateral ratio is 0. Must call
collectionRedemption()
later to collect.collectRedemption
collectRedemption() public
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
buyBackFXS(uint256 FXS_amount) external
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
recollateralizeAmount() public view returns (uint256 recollateralization_left)
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
recollateralizeFrax(uint256 collateral_amount_d18) public
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
toggleMinting() external onlyMintPauser
Toggle the ability to mint.
toggleRedeeming
toggleRedeeming() external onlyRedeemPauser
Toggle the ability to redeem.
toggleBuyBack
toggleBuyBack() external onlyBuyBackPauser
Toggle the ability to buyback.
setPoolCeiling
setPoolCeiling(uint256 new_ceiling) external onlyByOwnerOrGovernance
Set the
pool_ceiling
, which is the total units of collateral that the pool contract can hold.setOracle
setOracle(address new_oracle) external onlyByOwnerOrGovernance
Set the
oracle_address
.setCollateralAdd
setCollateralAdd(address _collateral_address) external onlyByOwnerOrGovernance
Set the
collateral_address
.addOwner
addOwner(address owner_address) external onlyByOwnerOrGovernance
Add an address to the array of owners.
removeOwner
removeOwner(address owner_address) external onlyByOwnerOrGovernance
Remove an owner from the owners array.
onlyByOwnerOrGovernance
onlyByOwnerOrGovernance()
Restrict actions to the governance contract or the owner(s).
notRedeemPaused
notRedeemPaused()
Ensure redemption is not paused.
notMintPaused
notMintPaused()
Ensure minting is not paused.
最近更新 1yr ago