> For the complete documentation index, see [llms.txt](https://turbos.gitbook.io/turbos/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://turbos.gitbook.io/turbos/developer-docs/via-sdk/clmm/preswap.md).

# preSwap

### Preswap by simulation transaction <a href="#preswap-by-simulation-transaction" id="preswap-by-simulation-transaction"></a>

### Signature

`computeSwapResultV2(options: ComputeSwapResultOptionsV2): Promise<Transaction>`

### Params

```typescript
interface ComputeSwapResultOptionsV2 {
  pools: Array<{
    // Pool object ID
    pool: string;
    // swap from coinA to coinB
    a2b: boolean;
    amountSpecified: string | number 
  }>;
  // Operator's wallet address
  address: string;
  amountSpecifiedIsInput: boolean;
  tickStep?: number;
}
```

* `pools` : Multiple pools can be passed for prediction, which is particularly useful when there are multiple fee pools with the same token.
* `address` : Transaction sender
* `a2b` : Swap Direction: A value of `true` indicates a swap from CoinA to CoinB
* `amountSpecifiedIsInput` : `true` means fixed the amount of input, `false` means fixed the amount of output
* tickStep: Represented this pre swap can move up to how many tickSpacing

### Examples

```typescript
const turbosSdk = new TurbosSdk(Network.testnet, {
  url: 'https://fullnode.testnet.sui.io',
});
const signer = turbosSdk.account.getKeypairFromMnemonics("your mnemonic");
const poolId = '0xb32fb8ec0b447a833066496bd7251d3a2ee57a0a97c54bf4cc945a986235582a';
const preSwapResult = await turbosSdk.trade.computeSwapResultV2({
  pools: [
    {
      pool: poolId,
      a2b: true,
      amountSpecified: 1000000,
    },
  ],
  amountSpecifiedIsInput: true,
  tickStep: 100,
  address: signer.toSuiAddress(),
});
console.log(preSwapResult);
```

Response

```json
[
  {
    a_to_b: true,
    amount_a: '1000000',
    amount_b: '297',
    fee_amount: '10000',
    is_exact_in: true,
    liquidity: '15182876622',
    pool: '0xb32fb8ec0b447a833066496bd7251d3a2ee57a0a97c54bf4cc945a986235582a',
    protocol_fee: '0',
    recipient: '0x9563578937da5bd33657306871057dbe50c18900d300ecd97c93c3cbda2262ed',
    sqrt_price: '319730214661613148',
    tick_current_index: { bits: 4294886188 },
    tick_pre_index: { bits: 4294886188 }
  }
]
```


---

# 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://turbos.gitbook.io/turbos/developer-docs/via-sdk/clmm/preswap.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.
