> For the complete documentation index, see [llms.txt](https://docs.boba.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.boba.xyz/agents/boba-agents/core-capabilities/spot-trading/twap-orders.md).

# TWAP Orders

***

### Overview

TWAP (Time-Weighted Average Price) splits a large order into equal-sized chunks executed at regular intervals. Unlike DCA which focuses on long-term accumulation, TWAP is designed for executing large trades efficiently—minimizing price impact and avoiding detection by MEV bots.

**When to use TWAP:**

* You're executing a large order relative to available liquidity
* You want to minimize market impact and slippage
* You need to disguise a large position entry or exit
* You're trading tokens with thin liquidity
* You want predictable execution across a defined time window

**When to use DCA instead:**

* You're accumulating over days/weeks for investment purposes
* You want to average into volatile price swings
* Timing within hours doesn't matter

***

### How TWAP Works

TWAPs split your order into smaller trades executed at regular intervals, minimizing price impact and achieving a better average price. Below is an example of how the order execution flow happens:

#### Execution Flow

```
1. You submit TWAP order → Parameters validated
2. Order split into chunks → Equal USD amounts calculated  
3. First chunk executes → Market buy/sell at current price
4. Wait for interval → Timer with optional randomization
5. Next chunk executes → Liquidity has partially replenished
6. Repeat until complete → All chunks filled
7. Summary generated → Average price across all executions
```

#### Example: $50,000 TWAP Buy over 1 Hour

| Chunk     | Time | Price | Amount      | Tokens Received |
| --------- | ---- | ----- | ----------- | --------------- |
| 1         | 0:00 | $1.02 | $2,500      | 2,451           |
| 2         | 0:03 | $1.03 | $2,500      | 2,427           |
| 3         | 0:06 | $1.01 | $2,500      | 2,475           |
| 4         | 0:09 | $1.02 | $2,500      | 2,451           |
| ...       | ...  | ...   | ...         | ...             |
| 20        | 0:57 | $1.04 | $2,500      | 2,404           |
| **Total** | —    | —     | **$50,000** | **48,780**      |

**TWAP average price: $1.025**

If executed as a single $50K market order, the price impact could have pushed execution to $1.05-1.08, costing an extra $1,200-2,600.

***

### Example Prompts

Here are natural language prompts that trigger TWAP orders:

| Prompt                                                           | Interpretation                        |
| ---------------------------------------------------------------- | ------------------------------------- |
| "TWAP buy $50,000 of SOL on Solana over 4 hours"                 | Split $50K into chunks over 4h window |
| "Execute $20,000 sell of WIF on Solana using TWAP over 1 hour"   | TWAP sell across 1 hour               |
| "Buy $100,000 of JUP on Solana slowly over 12 hours"             | Large TWAP buy over 12h               |
| "TWAP $10,000 into BONK on Solana, 30 minute window"             | Fast TWAP for volatile token          |
| "Sell $25,000 of RAY on Solana with TWAP, minimize impact"       | TWAP sell with default duration       |
| "Split my $15,000 ETH buy on Base into 20 orders over 2 hours"   | Custom chunk count specified          |
| "TWAP out of my POPCAT position on Solana, $30,000 over 6 hours" | Large exit via TWAP                   |

***

### Managing TWAP Orders

#### View Active TWAPs

```
"Show my active TWAP orders"
"Status of my SOL TWAP"
"How many chunks left on my WIF TWAP?"
```

#### Pause/Resume

```
"Pause my BONK TWAP on Solana"
"Resume my JUP TWAP"
```

#### Cancel

```
"Cancel my SOL TWAP on Solana"
"Stop all TWAP orders"
```

#### Speed Up / Slow Down

```
"Speed up my WIF TWAP to finish in 30 minutes"
"Slow down my SOL TWAP, extend to 6 hours"
```

***

### Randomization

#### Why Randomization Matters

Predictable order patterns are exploited by MEV bots:

```
Without randomization:
- Bot detects pattern after 2-3 chunks
- Front-runs remaining chunks
- You pay inflated prices

With randomization:
- Timing varies ±30% around target interval
- Pattern harder to detect
- MEV extraction reduced
```

**Example with randomization:**

* Target interval: 3 minutes
* Actual intervals: 2:05, 3:45, 2:30, 4:10, 2:55...

***

### Tips for Effective TWAP

below are some quick tips to ensure your DCA's are effective:

1. **Size chunks to liquidity** — Each chunk should be <1% of pool liquidity for minimal impact.
2. **Match duration to urgency** — Longer duration = better price, but more exposure to price movement.
3. **Enable randomization** — Always keep this on unless you have a specific reason not to.
4. **Monitor large TWAPs** — Check progress periodically for orders >$50K or >4 hours.
5. **Set pause conditions** — Protect against buying into pumps or selling into dumps.
6. **Don't over-slice** — Too many tiny chunks increase total fees without much benefit.

***


---

# 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://docs.boba.xyz/agents/boba-agents/core-capabilities/spot-trading/twap-orders.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.
