> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokenlayer.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Anti-Sniping Protection

> Understand how Token Layer protects new token launches from snipers

## Overview

Token Layer implements anti-sniping protection to ensure fair token launches and prevent malicious actors from exploiting new tokens in the first moments of trading.

## How It Works

### Time-Based Fee Structure

When a new token is launched, the first **6 seconds** of trading (calculated in blocks for each chain) has increased fees:

<Steps>
  <Step title="Initial Fee: 80%">
    At the moment of launch (block 0), the trading fee starts at 80%
  </Step>

  <Step title="Linear Decrease">
    The fee decreases linearly over each block for 6 seconds worth of blocks
  </Step>

  <Step title="Final Fee: 1%">
    At the 6-second mark, the fee reaches 1%
  </Step>

  <Step title="Normal Trading">
    After 6 seconds, normal protocol fees apply
  </Step>
</Steps>

### Fee Calculation Example

Here's how the fees decrease over time for a typical chain:

| Time | Blocks | Fee Percentage |
| ---- | ------ | -------------- |
| 0s   | 0      | 80%            |
| 1s   | \~0.5  | \~66%          |
| 2s   | \~1    | \~53%          |
| 3s   | \~1.5  | \~40%          |
| 4s   | \~2    | \~26%          |
| 5s   | \~2.5  | \~13%          |
| 6s   | 3      | 1%             |
| 6s+  | 3+     | Normal fees    |

<Info>
  Block times vary by chain. The 6-second window is converted to the equivalent number of blocks for each specific blockchain.
</Info>

## Who This Affects

### All Initial Buyers

The anti-sniping fees apply to **everyone** buying in the first 6 seconds:

* **First buyer**: Pays high fees if buying immediately
* **Early buyers**: Pay progressively lower fees as time passes
* **Bots and snipers**: Discouraged from instant exploitation
* **Regular traders**: Can wait 6 seconds for normal fees

### Not Affected By

The anti-sniping protection does NOT affect:

* **Token creators**: No fees on token creation
* **Sellers**: Only affects buy transactions
* **Later buyers**: After 6 seconds, normal fees apply
* **Graduated tokens**: After DEX migration, uses standard DEX fees

## Why This Matters

<CardGroup cols={2}>
  <Card title="Fair Launch" icon="scale-balanced">
    Ensures everyone has an equal opportunity to participate without bots dominating
  </Card>

  <Card title="Prevents Exploitation" icon="shield-halved">
    Discourages snipers from extracting value immediately after launch
  </Card>

  <Card title="Protects Creators" icon="user-shield">
    Gives token creators time for their community to discover the token
  </Card>

  <Card title="Better Price Discovery" icon="chart-line">
    Allows organic price formation without immediate manipulation
  </Card>
</CardGroup>

## Trading Strategy

### Best Practices

<Tip>
  **Wait 6 Seconds**: For the best value, wait at least 6 seconds after launch to buy at normal fees.
</Tip>

<Warning>
  **Avoid Immediate Buys**: Buying in the first few seconds means paying significantly higher fees with limited benefit.
</Warning>

### When to Buy Early

Despite high fees, some traders buy immediately because:

* Strong conviction in the token's potential
* Willing to pay premium for earliest position
* Expecting significant price appreciation
* Supporting a specific creator or project

### When to Wait

Most traders benefit from waiting because:

* 6 seconds is minimal delay for massive fee savings
* Price won't move significantly in 6 seconds on bonding curve
* Lower entry price improves potential returns
* Reduces risk of paying excessive fees

## API Integration

The anti-sniping fees are automatically included in all API responses:

### Price Quotes

When you get a price quote, the returned amounts already include anti-sniping fees if applicable:

<Card title="Token Price API" icon="dollar-sign" href="/api-reference/tokens/get-token-price-quote">
  Get quotes with fees automatically included
</Card>

### Trading Transactions

All trading endpoints factor in anti-sniping fees:

<Card title="Trade Tokens" icon="arrows-rotate" href="/api-reference/transactions/trade-tokens-buy-or-sell">
  Buy/sell with automatic fee calculation
</Card>

### Pool Data

Check token status and timing information:

<Card title="Get Pool Data" icon="water" href="/api-reference/tokens/get-liquidity-pool-data">
  View token pool information and launch details
</Card>

## Technical Details

### Block-Based Calculation

The system uses blocks (not wall-clock time) to ensure consistency:

1. **Launch Block**: Token creation block is recorded
2. **Current Block**: Each transaction checks the current block number
3. **Block Difference**: Calculates blocks elapsed since launch
4. **Fee Lookup**: Maps block difference to fee percentage
5. **Linear Interpolation**: Smooth fee decrease between blocks

### Chain-Specific Implementation

Different chains have different block times:

| Chain     | Avg Block Time | Blocks in 6s |
| --------- | -------------- | ------------ |
| Ethereum  | \~12s          | \~0.5        |
| Base      | \~2s           | \~3          |
| BNB Chain | \~3s           | \~2          |
| Arbitrum  | \~0.25s        | \~24         |
| Solana    | \~0.4s         | \~15         |

The smart contract automatically adjusts for each chain's block time.

### Quoter Integration

The Token Layer Quoter contract:

* Reads current block number
* Calculates blocks since token launch
* Applies appropriate anti-sniping fee if within window
* Returns accurate quote including all fees
* No surprises at execution time

## Comparison with Normal Fees

### Normal Trading Fees (After 6 Seconds)

When anti-sniping period ends, normal fees apply:

* **Protocol Fee**: \~0.3% to 1% depending on liquidity
* **Creator Fee**: Set by token creator (typically 0.2% - 2%)
* **Gas Fees**: Standard network costs

### During Anti-Sniping Window

The increased fees replace normal fees temporarily:

* **Anti-Sniping Fee**: 80% to 1% (decreasing)
* **Creator Fee**: Still applies on top
* **Gas Fees**: Standard network costs

<Info>
  After the 6-second window, the anti-sniping fee drops to 0% and normal protocol fees resume.
</Info>

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Can I avoid anti-sniping fees?">
    Yes! Simply wait 6 seconds after token launch before buying. The fees automatically drop to normal levels.
  </Accordion>

  <Accordion title="Do sellers pay anti-sniping fees?">
    No, anti-sniping fees only apply to buy transactions during the first 6 seconds.
  </Accordion>

  <Accordion title="What if I buy at exactly 6 seconds?">
    The fee will be approximately 1%, which is the minimum of the anti-sniping period before transitioning to normal fees.
  </Accordion>

  <Accordion title="Do fees apply to graduated tokens?">
    No, once a token graduates to external DEXes (Uniswap, PancakeSwap, etc.), it uses standard DEX fees instead.
  </Accordion>

  <Accordion title="How do I know if anti-sniping fees apply?">
    Check the token's launch time. If it launched less than 6 seconds ago, anti-sniping fees are active.
  </Accordion>

  <Accordion title="Can bots get around this?">
    No, the fees are enforced at the smart contract level and apply to all transactions equally, including bots.
  </Accordion>
</AccordionGroup>

## Related Documentation

<CardGroup cols={3}>
  <Card title="How to Launch Tokens" icon="rocket" href="/onboarding/launch-tokens">
    Create your own token
  </Card>

  <Card title="How to Trade" icon="chart-line" href="/onboarding/trade">
    Buy and sell tokens
  </Card>

  <Card title="Launchpad Overview" icon="layer-group" href="/launchpad">
    Learn about the launchpad
  </Card>
</CardGroup>

## Need Help?

Click the chat icon in the bottom right corner for support with anti-sniping protection or trading questions.
