> For the complete documentation index, see [llms.txt](https://cron-finance.gitbook.io/twamm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cron-finance.gitbook.io/twamm/fundamentals/dynamic-fees.md).

# Dynamic Fees

*This is an ongoing case study on TWAMMs where fees can be adjusted based on future orders that are queued to be executed. Below is a problem and related parameters we're researching.*

### Problem Statement

> What is the optimal swap fee discount for dedicated arbitrageurs (toxic, atomic swaps, short term) to maximize price updates for traders (non-toxic, non-atomic swaps, long term) and MEV kickback to LPs?

<figure><img src="/files/KeKimNtNs6UNSYbQ4oyQ" alt=""><figcaption></figcaption></figure>

### Optimization

* LPs: maximize swap fees & MEV remittance to compensate for IL and toxic flow from arbitrageurs
* Traders: maximize price updates of assets to keep parity with external venues and get a smoother order fill
* Arbitrageurs: maximize MEV opportunity and minimize swap fee for a profitable arbitrage opportunity

### Assumptions

* Pool parameters:
  * ETH/USDC
  * Partner Fee: Dedicated Arbitrageur (0.025%)
  * Short Term Fee: Mempool Users (0.05%)
  * Long Term Fee: Traders (0.15%)
* Gas (transaction) fees can vary on number of virtual orders that need to be executed
  * For the purpose of this problem, assume a fixed amount
* Trades last multiple blocks and can be cancelled at any time
* Mempool arbitrageurs will always exploit opportunity if dedicated arbitrage don’t act in time
* Dedicated arbitrageurs get a fee discount to get a first right arbitrage opportunity

### Background

* TWAMMs have two swap interfaces: non-atomic swap (traders), atomic swap (arbitrageurs)
* TWAMM pools are 2 asset, 50/50 Uni V2 style pools that follow `X*Y=K` invariant
* Dedicated arbitrageur fees can be changed in-flight and are customizable per pool
* Long term trades create back running opportunities as prices move on the bonding curve
  * Traders are primarily uninformed flow (non-toxic), benefit from arbitrageurs keeping prices fresh
* Dedicated arbitrageurs remit share of MEV extracted to LPs for the swap fee discount
  * Arbitrageurs are informed flow (toxic), profit from correcting prices and pay gas to write traders virtual orders on-chain
* LPs get swap fees from long term traders, and MEV + discounted short term swap fees from arbitrageurs
* MEV remitted to pools are automatically invested and distributed pro-rata to LPs similar to swap fees, but on a weekly basis

### Existing Solutions

* Private relays: ineffective because `first right advantage` is negated after the first block
* Rook auctions: group of arbitrageurs bid on the arbitrage opportunity, 90% of bid is remitted back to LPs. Note `bid != potential MEV opportunity`
* SLAs: require off-chain agreements and trust with 3rd parties to behave ethically

### Related Research

{% embed url="<https://a16zcrypto.com/content/article/lvr-quantifying-the-cost-of-providing-liquidity-to-automated-market-makers/>" %}

{% embed url="<https://research.paradigm.xyz/uniswaps-alchemy>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cron-finance.gitbook.io/twamm/fundamentals/dynamic-fees.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
