# Sandwich Bot Protection

As was initially created by $INEDIBLE and implemented into inedibleX, Goat has implemented advanced yet elegant sandwich bot protection.

Previously the protection was simply that no more than 2 transactions could happen in a single pool. This worked perfectly to avoid sandwich bots since they were no longer able to sandwich free from risk, but if many transactions were occurring at once, such as one a token first launches, there were many failing purchases.

The advancements we've made with Goat are that the sandwich protection focuses on preventing a "switch" of trading directions rather than denying based on a simple number of trades. For example, if 50 transactions that are all buys occur in a single block, they will all be let through since no sandwich can be occurring. If there's 1 sell then 49 buys after, that will also be allowed since there's only 1 switch of trading direction. However, if there's 1 sell then 1 buy then another sell, that's 2 switches of trading direction and the last transaction will be reverted.

This advancement ensures that failures because of sandwich protection will be much rarer, and many buys occurring during a launch or sells during a period of fear will not result in reverting transactions.


---

# Agent Instructions: 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:

```
GET https://goattrading.gitbook.io/goat/features/for-traders/sandwich-bot-protection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
