# $FEE Token
## What is FEE or BASEFEE token?
$FEE token is an idea to have a token pegged to ethereum BASEFEE that is stable in terms of ethereum compute.
Lets look at the [idea](https://twitter.com/jeffcancode/status/1421772593938509826) described by twitter user @jeffcancode and break it down.
```
-1/5
Working on a new DAI-like stable coin design that's not pegged to USD but to ETH basefee
The great part:
(i) Doesn't rely on oracles
(ii) Independent unit of account unrelated to the currency/economy of any nation
(iii) GasToken-esque but doesn't rely on gas refunds
-2/5
Context:
(1) Ethereum is introducing a BASEFEE parameter in EIP 1559 w London hardfork
(2) BASEFEE is unpredictable, users cannot plan ahead
(3) EIP3529 reduces gas refunds
Most importantly: 1 BASEFEE = 1 BASEFEE (stable amount of ETH compute can always be purchased using $FEE)
```
The design of the fee token will be DAI-like where $FEE tokens pegged to `BASEFEE` can be minted backed by $ETH collaterals with collateral ratio of C.
- Doesn't rely on oracles
BASEFEE value of the block can be accessed using `BASEFEE opcode`
- Independent unit of account
As [described by Maker for DAI](https://makerdao.com/en/whitepaper/#dai-as-a-unit-of-account), it means to have a standardized measurement of value to price goods and services which in this case is Eth computer.
- GasToken-esque but doesn't rely on gas refunds
[GasTokens (GAS1, GAS2)](https://gastoken.io/) based on refund promotes exploitative behaviour on storage. Also refund mechanism is [subject to change(EIP-3529)](https://eips.ethereum.org/EIPS/eip-3529). Have a gas fee token is a lucrative idea and $FEE token makes it possible without depending on refund mechanism.
In 2/5, user assumes that the `BASEFEE` is unpredictable which could not be the case and can be manipulation at the cost of Eth. More on this later in the doc.
```
-4/5
Design:
(i) Users lock X ETH in a contract and mint Y BaseFeeTokens where
X / Y >= C * BASEFEE, C is the collateralization ratio
(ii) Liquidation, redemption like Maker
(iii) BASEFEE can double/halve in 6 blocks, C needs to be large enough to cover liquidation window of N blocks
```
The design is very simple and straight forward maths. Here X, Y and C can be thought of as constants considering no collateral withdraw or deposit were made, and the only value fluctuating is `BASEFEE`. `BASEFEE` going down creates a safer position and that going up can approach/cause liquidation. [Liquidation mechanism](https://) is assumed similar to MakerDAO.
Now lets discuss the 3rd point in detail. After [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) the least no of block that can cause the BASEFEE to double is 6 considering all the block gas was almost fully consumed thus increasing the BASEFEE by 12.5% every block.
Now, if at best it can go `2x`(eg. 100gwei) in 6 blocks from a refrence basefee(50gwei), then it can also go `4x`(200gwei) for next 6 blocks and `8x`(400gwei) for the another next 6 from the same basefee refrence(50gwei).
It is not necessary that BASEFEE only double every 6 blocks but can also happen at variable no.(>6) of blocks. Infact if we look at the activity of `BASEFEE` on 7 Sept 2021 [here](https://etherscan.io/chart/gasprice); it was min at 48gwei, average at 213gwei and for block([13179381](https://etherscan.io/block/13179381)) it was around 780gwei.
The BASEFEE fluctuation what we saw above is very vibrant; even in normal condition if we look at empirical data of BASEFEE, it changes by good 10's of percentage. Now think of the same price fluctuation happening for $ETH in Maker, we would surely need a good high enough `C` as correctly pointed by @jeffcancode but how high? and whether it is optimal? would be the next question to ask.
Also few question I would add is,
- How similar or different is the $FEE design compared to MakerDAO and TerraMirror?
- What would it cost to manipulate BASEFEE to 2x, 4x or even 8x in worst case scenerios?
Lets start with the first question.
## $FEE Vs MakerDAO Vs TerraMirror
||MakerDAO|TerraMirror(mAAPL)|$FEE|
|-|-|-|-|
|Minted|DAI|mAAPL|FEE|
|Peg|USD|AAPL|BASEFEE|
|Minted Type|Stablecoin|Volatile|Volatile(in terms of gwei)|
|Collateral|ETH|UST|ETH|
|Col. Type|Volatile|Stable|Stable(in terms of gwei)|
|Oracle price (tracking of)|ETH/USD (Colat)|AAPL/USD (Minted)|Gwei\[/gas](Minted)|
Here we can see that $FEE is surely not completely similar to Maker and resemble some what like a TerraMirror. Also case of $FEE is more dynamic, as the $ETH in USD fluctuates can cause behaviour of a user change and also BASEFEE is changing in terms of gwei. Lets only focus on what is being tracked as it affects the rules of the protocol as we saw above that X, Y and C are constant and BASEFEE is what matters.
For a thought experiment if we assume that there is no such thing like USD or ETH/USD pair then everything will be considered in terms of wei or gwei. Supplying 1ETH would be like supplying a stable value of 10^9 gwei and BASEFEE would be something that changes in terms of gwei. Comparing with TerraMirror, it is like supplying stable value in UST(~USD) and mAAPL changing in terms of UST(or USD)
## BASEFEE manipulation
In the systems like Maker or FEE that we are discussing there is a huge TVL and with this huge stakes involved would attract a lots of bad actors. In public chains like Eth there is no doubt that some individual or group of bad actors can cause the BASEFEE to increase by creating bundle of genuine looking transactions and coordinating with block producer.
Lets try to evaluate what could be this cost. We will first tabulate the cost that will cause BASFEE to double if we start with a BASEFEE=50gwei at current block(101).
$Formule for Eth Consumed = \frac {(BASEFEE*30000000)}{1000000000}$ ETH
|Block No|BASEFEE (+12.5%)|Eth Consumed this block|$\sum$Eth|BASEFEE Next|
|-|-|-|-|-|
|101|50|1.5|1.5|56.25|
|102|56.25|1.688|3.188|63.28|
|103|63.28|1.898|5.086|71.19|
|104|71.19|2.136|7.222|80.09|
|105|80.09|2.4|9.624|90.1|
|106|90.1|2.7|**12.327**|**101.36**|
If we consider `12 sec` of block time then it will take `72 sec` or `1.2 min` to `~2x` the basefee. Note, if this activity is further extended to the next 6 block it would surely cost more Eth but interestingly would take the same time.
Now lets plot this formula with different start basefee scenerios for `20gwei`, `30gwei`, `40gwei` and `50gwei`. The following complete chart can be found [here](https://www.desmos.com/calculator/0ufyyrx97o).

- We can see that the cost reduces as we lower the BASEFEE at which we start.
- For every next block the cost compounds.
- The time for every 6 block remains the same i.e every double take same time but more cost.
This was a worst case scenerio cost where the attacker is bearing all cost. This cost can be further reduced by following three techniques.
- Accumulate FEE at lower costs thus discounting the attack cost.
- Bundle a few transactions from the pool that will surely consume most gas.
- This one is just an idea, cannot say how practicle it is. Create nearly empty or less than half filled block at the time when the BASEFEE is already low thus reducing it further in the next blocks and then start the BASEFEE increase attack.