# PeggedLinearAuction

The `PeggedLinearAuction` fee module builds upon the same core ideas of [`LinearAuction`](https://docs.ees.xyz/fee-modules/linearauction) but utilizes [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) and [EIP-3198](https://eips.ethereum.org/EIPS/eip-3198) to peg the execution fee to the current base fee. This fee module calculates the total gas cost of the execution, multiplies it with `block.basefee`  and uses a price oracle to convert the amount in ETH to the amount of the user specified execution fee token. During the execution window, `PeggedLinearAuction` performs a reverse dutch auction similarly to `LinearAuction` but over the percentage overhead from the calculated base fee in execution fee tokens. The overhead is represented in basis points (bps), such that 10000 bps corresponds to 100%.

<figure><img src="https://2488988847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FotYFhyxmfp3Clnu5Ko5Q%2Fuploads%2FEtatSFSB0wdkS7gemDAL%2FpeggedLinearAuctionChart.png?alt=media&#x26;token=c8702e1c-8375-4e55-b3ff-d048e69df788" alt="" width="563"><figcaption><p>Abstract chart of execution fee function.</p></figcaption></figure>

The overhead basis points as a function of time within execution mode is calculated as follows:

$$
overhead(t) = \frac{(maxBps  - minBps) }{executionWindow - 1} \cdot (t - executionTime) + minBps
$$

The fee function is then:

$$
fee(t) = \frac{overhead(t)}{10000} \cdot baseFee\_{feeToken}
$$

The input bytes to the `onCreateJob` function should follow the structure:

```solidity
address executionFeeToken;
uint48 minOverheadBps;
uint48 maxOverheadBps;
IPriceOracle priceOracle;
bytes memory oracleData;
```

`priceOracle` is a contract implementing `IPriceOracle` which will provide price data of the token. `oracleData` is arbitrary data which can be used by the price oracle.

{% hint style="info" %}
**Note:** Price oracles have the purpose of finding the price of the execution fee token in terms of ETH.
{% endhint %}

{% hint style="warning" %}
**Warning:** `PeggedLinearAuction`is only deployed on EVM chains supporting EIP-1559 and EIP-3198.
{% endhint %}
