A FXB is a basic ERC20 token that can be created by the Frax AMO Timelock. Each FXB contains a unique maturity which always expires on a Wednesday, UTC 00:00.
After a FXB is created, anyone is able to mint the FXB by depositing FRAX. For every unit of FRAX deposited, the depositor receives the equivalent amount of FXB. After the current time has passed the maturity timestamp, any FXB holder of that specific maturity is able to redeem the equivalent FRAX by returning the FXB.
FXBFactory (etherscan)
Factory contract permissioned to Frax Timelock to create a FXB.
A SlippageAuction operates similarly to a Uniswap V2 Pair with different mathematics and additional functionality. A caller can utilize the swap() method similarly and plug the SlippageAuction into a router.
There is an owner of the SlippageAuction who has permissions to:
- Start an auction
- The buy/sell token must be
token0,token1respectively - Have any auction configuration meeting basic requirements
- The buy/sell token must be
- Stop an auction
- Returns all token0, token1 held by the auction contract to the owner
- Can be done at any time
- Transfer auction ownership
Every SlippageAuction runs one auction at a time using a continuous Gradual Dutch Auction, as described by Paradigm. The mechanics work like so:
- Owner starts an auction with:
- Amount of tokens to sell
- Starting Price
- Minimum Allowed Price
- Price Decay
- Slippage
- Expiration
- As time passes, the price to purchase the tokens decreases linearly due to the set Price Decay.
- If someone buys the tokens, the amount they swap has slippage due to the set Slippage.
- After a swap, the price of tokens increases by twice the Slippage.
- Swappers can only ever swap token0 (buyToken) for token1 (sellToken).
- Price can never go below the MinimumAllowedPrice, before Slippage.
SlippageAuctionFactory (etherscan)
Permission-less factory contract to create a SlippageAuction.
See the formal documentation.
See current FXB auctions.
AuctionFactory deploy commit: 384f562
FXBFactory deploy commit: 5879a32
swapTokensForExactTokens()- Intended to be used with
getAmountIn()andgetAmountInMax() - Using
getAmountOut()prior may revert due to precision rounding down
- Intended to be used with
swapExactTokensForTokens()- Intended to be used with
getAmountOut() - Using
getAmountIn()prior may revert due to precision rounding down
- Intended to be used with
getAmountInMax()- May revert when swapping when
amountInMax < 1e5due to precision rounding down
- May revert when swapping when
- Output from chain-calling
getAmountIn()andgetAmountOut()may round down due to precision startAuction()- Assume that
params.amountListed > 1e8to prevent rounding issues. See minimums set in the fuzz tests for generally acceptable ranges.
- Assume that
npm install
forge build
forge doc
forge test
- Ensure your solc version matches the version of the deployed scripts
cp .env.example .envand update variables- Update
FXB_TIMELOCKandFRAX_ERC20inscripts/constants/mainnet.tsto pass into theFXBFactoryconstructor npm run generate:constantssource .envforge script src/script/DeployFxbFactory.s.sol --rpc-url mainnet --broadcast --verify -vvvv --slowforge script src/script/DeploySlippageAuctionFactory.s.sol --rpc-url mainnet --broadcast --verify -vvvv --slow
This repo uses the following tools:
- frax-standard-solidity for testing and scripting helpers
- forge fmt & prettier for code formatting
- lint-staged & husky for pre-commit formatting checks
- solhint for code quality and style hints
- foundry for compiling, testing, and deploying