Frax V1 池 ABI & 地址
用于铸造和赎回 FRAX 的合约,以及回购多余抵押品。
⚠️ 此池已被弃用,取而代之的是 FRAX V2 及更高版本的机制 ⚠️
部署
Frax Pool 合约由治理系统部署和管理,这意味着在治理提案成功并执行后,可以随时添加新的抵押类型。当前池为 USDC,未来池将开放更多的抵押类型。
USDC: 0x3C2982CA260e870eee70c423818010DfeF212659
描述
Frax Pool 是一个智能合约,通过抵押品向用户铸造 FRAX 代币,或通过赎回发送到合约中的 FRAX 代币来返回抵押品。每个 Frax Pool 接受不同类型的抵押品。Frax Pools 可以采用任何类型的加密货币,但由于其价格波动较小,稳定币的实现最为简单。Frax 旨在接受任何类型的加密货币作为抵押品,但在初始阶段优先选择低波动性的池,因为它们不会导致抵押比率剧烈变化。有一些有前景的新项目,如 Reflex Bonds,能够抑制其基础加密资产的波动性。未来,Reflex Bonds 可能成为理想的 FRAX 抵押品。新的 Frax Pools 可以通过 FXS 治理投票添加。
每个池合约都有一个池上限(可存储以铸造 FRAX 的最大抵押品)和资产的价格馈送。创世时的初始 Frax Pool 将是 USDC(美元硬币)和 USDT(泰达币),因为它们具有较大的市值、稳定性,并且在以太坊上可用。
这些池通过对 FRAX 稳定币(FRAX)和 FRAX 股份(FXS)合约的授权调用来铸造和赎回协议代币。
铸造和赎回 FRAX
该合约有 3 个铸造功能:mint1t1FRAX()
、mintFractionalFRAX()
和 mintAlgorithmicFRAX()
。合约还具有与铸造功能对应的 3 个赎回功能:redeem1t1FRAX()
、redeemFractionalFRAX()
和 redeemAlgorithmicFRAX()
。
这些功能被分为 1 对 1、分数和算法三个阶段,以优化 Gas 使用。1 对 1 的铸造和赎回功能仅在抵押比率为 100% 时可用。分数铸造和赎回功能仅在抵押比率为 99.99% 到 0.01% 之间可用。算法铸造和赎回功能仅在抵押比率为 0% 时可用。
滑点
每个铸造和赎回功能都有一个 AMOUNT_out_min
参数,用于指定期望从交易中获得的最低代币单位。这在提交交易时作为滑点容忍度的限制,因为价格可能会在创建交易和被包含在区块中的时间之间更新。
状态变量
接入控制 (Inherited)
https://docs.openzeppelin.com/contracts/3.x/api/access#AccessControl
FraxPool-Specific
ERC20 private collateral_token
池中抵押代币的实例。
address private collateral_address
抵押代币的地址。
address[] private owners
池子的所有者列表。
address private oracle_address
预言机合约的地址。
address private frax_contract_address
FRAX 合约的地址。
address private fxs_contract_address
FXS 合约的地址。
address private timelock_address
时间锁合约的地址。
FRAXShares private FXS
FXS 合约的实例。
FRAXStablecoin private FRAX
FRAX 合约的实例。
UniswapPairOracle private oracle
预言机合约的实例。
mapping (address => uint256) private redeemFXSBalances
记录给定地址的赎回余额。赎回者不能在同一个区块中同时请求赎回和实际赎回他们的 FRAX。这是为了防止闪电贷攻击,可能导致 FRAX 和/或 FXS 价格崩溃。赎回者必须等到下一个区块。这一特定变量用于赎回的 FXS 部分。
mapping (address => uint256) private redeemCollateralBalances
记录给定地址的赎回余额。赎回者不能在同一个区块中同时请求赎回和实际赎回他们的 FRAX。这是为了防止闪电贷攻击,可能导致 FRAX 和/或 FXS 价格崩溃。赎回者必须等到下一个区块。这一特定变量用于赎回的抵押品部分。
uint256 public unclaimedPoolCollateral
redeemCollateralBalances
的总和。
uint256 public unclaimedPoolFXS
redeemFXSBalances
的总和
mapping (address => uint256) lastRedeemed
记录给定地址最后一次赎回的区块。
uint256 private pool_ceiling
池子可以接受的最大抵押品金额。
bytes32 private constant MINT_PAUSER
铸造暂停的 AccessControl
角色。
bytes32 private constant REDEEM_PAUSER
AccessControl
role for the redeem pauser.
bytes32 private constant BUYBACK_PAUSER
赎回暂停的 AccessControl
角色。
bool mintPaused = false
铸造是否已暂停。
bool redeemPaused = false
赎回是否已暂停。
bool buyBackPaused = false
回购是否已暂停。
查看函数
unclaimedFXS
unclaimedFXS(address _account) public view returns (uint256)
返回未领取的 FXS 总金额。
unclaimedCollateral
unclaimedCollateral(address _account) public view returns (uint256)
返回未领取的抵押品总金额。
collatDollarBalance
collatDollarBalance() public view returns (uint256)
返回池中抵押代币的总余额(以美元计)。
availableExcessCollatDV
availableExcessCollatDV() public view returns (uint256)
返回池中抵押代币的多余余额(超过抵押比率所需的部分,以美元计)。
getCollateralPrice
getCollateralPrice() public view returns (uint256)
返回池中抵押品的价格(以美元计)。
Public Functions
mint1t1FRAX
mint1t1FRAX(uint256 collateral_amount_d18) external notMintPaused
从抵押品中铸造 FRAX。仅在抵押比率为 1 时有效。
mintFractionalFRAX
mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount) external notMintPaused
从抵押品和 FXS 中铸造 FRAX。仅在抵押比率介于 0 和 1 之间时有效。
mintAlgorithmicFRAX
mintAlgorithmicFRAX(uint256 fxs_amount_d18) external notMintPaused
从 FXS 中铸造 FRAX。仅在抵押比率为 0 时有效。
redeem1t1FRAX
redeem1t1FRAX(uint256 FRAX_amount) external notRedeemPaused
从 FRAX 赎回抵押品。仅在抵押比率为 1 时有效。必须在之后调用 collectionRedemption()
以进行收集。
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
Restricted Functions
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.
Modifiers
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.
Last updated
Was this helpful?