> For the complete documentation index, see [llms.txt](https://basedapp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://basedapp.gitbook.io/docs/trading/twap.md).

# TWAP

## What is TWAP?

TWAP (Time-Weighted Average Price) is an order execution strategy that breaks a large order into smaller trades, executed at regular intervals over a set duration.

Instead of placing one large order that may impact price, TWAP helps smooth execution, reducing slippage and market impact.

<figure><img src="/files/9K1SJvW5MQGQTdSADOK5" alt="" width="375"><figcaption></figcaption></figure>

***

## How TWAP Works

{% stepper %}
{% step %}
**Order Size**

The user specifies the total amount to buy/sell.
{% endstep %}

{% step %}
**Duration**

The time over which the order will be executed.
{% endstep %}

{% step %}
**Intervals**

The order is split into smaller chunks, executed evenly at each interval.
{% endstep %}

{% step %}
**Execution**

Orders are placed automatically until the total size is filled.
{% endstep %}
{% endstepper %}

For example: Buying 100 ETH over 1 hour with 12 intervals means the system executes \~8.33 ETH every 5 minutes.

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

{% hint style="info" %}
Each TWAP suborder has a maximum slippage of 3%. If a suborder cannot fill within this limit, it will be skipped and the algorithm will attempt to catch up in subsequent intervals (up to 3x the standard suborder size).
{% endhint %}

***

## Minimum Requirements

TWAP orders have a minimum duration of 5 minutes and a minimum order size that varies by asset. The system will reject orders that don't meet these thresholds.

***

## Reduce-Only Mode

When Reduce-Only is enabled:

* The TWAP will only reduce your current position.
* It prevents the strategy from flipping your position (e.g., closing a long and accidentally opening a short).
* If no position exists, no orders are executed.

This ensures TWAP is used strictly for scaling out, not scaling in.

***

## Randomize Mode

When Randomize is enabled:

* The system slightly varies the size and/or timing of each order.
* This makes execution less predictable and harder to track.
* Helps mitigate predatory algorithms or bots attempting to anticipate TWAP orders.

Example: Instead of executing exactly 10 ETH every 5 minutes, the bot may execute 8.5 ETH, then 11.2 ETH, with timing offsets of a few seconds.

***

## Privacy TWAP

Normal TWAPs are executed fully on-chain, which makes them visible to everyone. Large players (whales) dislike this because:

* Their execution path can be tracked.
* They are vulnerable to frontrunning and other predatory trading behavior.

Privacy TWAP executes trades client-side, directly inside the user's browser:

* Local Execution -- Orders are created and sent from your browser only.
* No Visibility -- Neither the trading terminal nor external observers can see or frontrun your order path.
* True Privacy -- Even we, as the trading platform, cannot track or manipulate your order flow.

{% hint style="warning" %}
Since orders run locally, if you refresh or close the terminal, the TWAP pauses. Execution resumes only while the terminal/browser is active.
{% endhint %}

This design ensures maximum privacy and security for users executing large trades.
