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

# Trading

> Route curve and pool trades through the deployment that owns the launch.

Trading depends on the launch, not only the chain. Read the token's `hook_address`, `launch_id`, `denomination_kind`, and lifecycle from `GET /api/token`.

## Route by lifecycle

| State | Route |
| - | - |
| V2 before bond | Token's own hook and bonding curve |
| V2 after bond | Exact V4 `PoolKey` resolved for that hook's ABI family |
| V1 after bond | Legacy Ink V2-style pool/router path |

Do not replace an older token's hook with the active creation hook.

## Native curve buy

```solidity theme={null}
function buy(
    uint256 launchId,
    uint256 minTokensOut,
    CaptchaAuth calldata captcha
) external payable returns (uint256 tokensOut);
```

`msg.value` is the native input. Set `minTokensOut` from a fresh preview and your slippage policy.

## Native curve sell

```solidity theme={null}
function sell(
    uint256 launchId,
    uint128 tokenAmount,
    uint256 minEthOut,
    CaptchaAuth calldata captcha
) external returns (uint256 payout);
```

Approve `tokenAmount` of the launch token to the exact hook before selling. Do not approve the current creation hook when the token belongs to another deployment.

## xStocks curve buy

```solidity theme={null}
function buyWithQuote(
    uint256 launchId,
    uint256 quoteIn,
    uint256 minTokensOut,
    CaptchaAuth calldata captcha
) external returns (uint256 tokensOut);
```

Approve `quoteIn` of the xStocks wrapper to the launch's per-asset hook. The wrapper, not its rebasing underlying, is the canonical quote asset.

## Referrals

Native deployments can expose `buyWithReferral` and `sellWithReferral`. Contract-event referral codes and permanent fee-earning referral bindings are separate systems. Do not assume an emitted string created a cash referral binding.

See [Referral API](/api-reference/inkypump/referral) for the signature-based binding flow.

## Anti-snipe authorization

```solidity theme={null}
struct CaptchaAuth {
    uint256 deadline;
    bytes signature;
}
```

After the launch's anti-snipe window ends, pass `{ deadline: 0, signature: 0x }`. During the window, the signature must bind the wallet, chain, hook context, launch, and deadline.

The current captcha signer endpoint is a first-party service protected by Turnstile and origin policy. Third-party launchpads should set `antiSnipeDuration` to zero unless InkyPump has enabled their origin and captcha flow.

## Fees

Current checked curve deployments charge a 1% protocol fee and a 1% variable fee. The creator receives `creatorFeeSplitBps` of the variable fee.

The rest of the variable fee is deployment-specific:

* Current Ink uses holder fee sharing.
* Older Ink uses buy-and-burn.
* Other deployments must be read from their versioned capability data.

Do not label every deployment's remaining variable fee as a burn.

## Events

```solidity theme={null}
event Trade(
    uint256 indexed launchId,
    address indexed trader,
    TradeType tradeType,
    PriceData priceData,
    TradeData tradeData,
    uint256 refund
);

struct PriceData {
    uint256 price;
    uint128 sold;
    uint40 timestamp;
}

struct TradeData {
    address trader;
    uint256 tokenAmount;
    uint256 ethAmount;
}
```

On an ERC-20-quoted hook, `price` and `ethAmount` use wrapper quote units despite the historical field name.

The canonical `Trade` topic is:

```text theme={null}
0xe2d4c4d950c33268021bcd67d1421807db799277a75376d17d5e2787849180a4
```

## After bonding

Resolve the deployment before reading the pool. Corrected native hooks and current xStocks hooks expose the getter:

```ts theme={null}
const poolKey = await publicClient.readContract({
  address: hook,
  abi: HOOK_READ_ABI,
  functionName: "getLaunchPoolKey",
  args: [launchId],
})
```

The deprecated Ink deployment has `hookAbi: "ink-legacy"` and does not expose that selector. For it, reconstruct the key only from the complete indexed `pool_currency0`, `pool_currency1`, `pool_fee`, `pool_tick_spacing`, `pool_hook`, and `pool_id` values returned by `GET /api/token`.

In both cases, verify the token and launch identity, currency pair, original hook, positive fee, nonzero tick spacing, and the derived pool ID. The derived ID is `keccak256(abi.encode(currency0, currency1, fee, tickSpacing, hooks))` and must equal the 32-byte launch ID. Fail closed when legacy fields are missing. See [Post-Bond Pool](/trading/post-bond-pool) for the full procedure.

For current native Ink launches, the quote currency is native ETH represented by the zero address. A token/WETH key is not the same pool.

## Converted payment assets

Paying with ETH or a stablecoin for a wrapper-quoted launch needs a separate executable conversion route into that wrapper. The reverse applies on sell. A USD mark does not provide route liquidity.

InkyPump's market-route APIs use first-party origin and rate controls. Until a partner route contract is agreed, the safest external integration is:

* Native quote asset for native launches.
* Exact wrapper quote asset for xStocks launches.
* InkyPump trade-page link for optional converted assets.

## Slippage and freshness

* Preview immediately before simulation.
* Compute minimum output with integers.
* Simulate the exact approval and trade path.
* Bind the shown quote to chain, hook, launch ID, input asset, amount, block, and expiry.
* Requote when any bound value changes.
* Treat an RPC or route error as route-specific; keep valid direct quote-asset trading available.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.