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

# svm: Compute stops

> Compute stops: the declaration and description of each of the 26 exports of @eco-incorp/sauce/svm.

`@eco-incorp/sauce/svm` is the Solana side: the client (`createSauceSvmClient`), clusters, PDAs, account resolution against the compiler's account manifest, Kitchen and engine instructions, transactions and sending, token accounts, and compute planning for `@sauce/router`'s Solana venues. `@eco-incorp/sauce/svm/engine` exports the engine's wire format and instruction builders, `@eco-incorp/sauce/svm/verify` verifies settle programs and engine CPI data, and `@eco-incorp/sauce/svm/engine-artifacts` (Node only) returns file paths to the packaged engine and Kitchen binaries.

```typescript theme={null}
import { createSauceSvmClient, SOLANA_CLUSTERS } from "@eco-incorp/sauce/svm";
```

Generated from the type declarations of `@eco-incorp/sauce`.

### `svmTickArray`

*Function* · `@eco-incorp/sauce/svm`

One tick array of `layout`, read: its start, span and initialized ticks; undefined for none.

```typescript theme={null}
export declare function svmTickArray(layout: SvmStopLayout, data: Uint8Array | undefined, spacing: number): SvmTickArray | undefined;
```

### `svmTickAtSqrtPrice`

*Function* · `@eco-incorp/sauce/svm`

The tick whose sqrt price is the greatest at or below `sqrt`.

```typescript theme={null}
export declare function svmTickAtSqrtPrice(sqrt: bigint): number;
```

### `svmOwnLimit`

*Function* · `@eco-incorp/sauce/svm`

The router's own limit for `priceLimit` at a pool of `fee`: its sqrt price (`clmmOrder`).

```typescript theme={null}
export declare function svmOwnLimit(priceLimit: bigint, fee: bigint, paysA: boolean): bigint;
```

### `svmPoolWalk`

*Function* · `@eco-incorp/sauce/svm`

How far `pool`'s swap walks, held by nothing but its limit and its window, its cost and output: on
Raydium's code and Crema, on into the furthest tick array its slot gives where its limit takes it
past the window (`SvmWalk.deep`), as its Stopped form walks with the deep tick its stop carries.

```typescript theme={null}
export declare function svmPoolWalk(pool: SvmStopPool): SvmWalk;
```

### `svmStopLimit`

*Function* · `@eco-incorp/sauce/svm`

The `priceLimit` that holds `pool`'s swap a tick inside `tick`, the first initialized tick it is
not to cross: the loosest whose own limit, by the router's arithmetic (`svmOwnLimit`), keeps the
price short of it, found by halving, since the own limit moves with `priceLimit` one way only.
Undefined where none does, a tick past what the router's arithmetic reaches.

```typescript theme={null}
export declare function svmStopLimit(tick: number, fee: bigint, paysA: boolean): bigint | undefined;
```

### `svmSkipStop`

*Function* · `@eco-incorp/sauce/svm`

The stop that skips a pool, whatever its price: a start bound past every tick the walk's way (the
least an i32 tick reads as paying the lower-key token, as the price falls, the greatest the other
way), which every pool's price has moved past, and no limit.

```typescript theme={null}
export declare function svmSkipStop(paysA: boolean): bigint;
```

### `svmComputeStops`

*Function* · `@eco-incorp/sauce/svm`

Each pool's stop for a cook whose venues' programs may spend `budget` units between them. The pool
whose walk buys the most per unit of compute goes first, each walking as far as its limit takes
it within what is left; a pool the rest no longer covers is held a tick inside the first
initialized tick it cannot pay to cross, and one that cannot pay for the swap itself is skipped.
Every pool that trades is charged `SVM_HEADROOM_TICKS` crossings past its walk. A walk that goes
on into the furthest tick array its slot gives (`SvmWalk.deep`) carries its deep tick, held or
not, wherever it trades past its window.

```typescript theme={null}
export declare function svmComputeStops(pools: readonly SvmStopPool[], budget: number): SvmComputeStop[];
```

### `svmProgramStops`

*Function* · `@eco-incorp/sauce/svm`

The stops of `program`'s swaps at a price, read through `load` from the accounts the cook resolved
(`accounts`, by `main`'s parameter), with main's `Uint256` arguments by name (`integers`), for a
limit a swap takes from one. `fixed` is the cook's own units where a simulation measured them;
`scale` shrinks what the venues are given, for a cook that ran out of units anyway. A swap in a
loop is charged for each time the loop runs it (`stoppableRuns`); where a loop does not write its
count out, or writes one that swap's runs alone cannot pay for, none is held (`unbounded`).
Undefined for a program with no stops.

```typescript theme={null}
export declare function svmProgramStops(program: Pick<CompiledSauceProgram, "stoppable" | "stoppableRuns" | "derivedAccounts">, chain: CanonicalChain, accounts: Readonly<Record<string, string>>, integers: Readonly<Record<string, bigint>>, load: OwnedAccountLoader, fixed?: number, scale?: number): Promise<SvmProgramStops | undefined>;
```

### `svmStopValues`

*Function* · `@eco-incorp/sauce/svm`

The values a program compiled with `stops.binding` takes after its own arguments, one for each of
its `derivedValues`: each held swap's stop.

```typescript theme={null}
export declare function svmStopValues(stops: SvmProgramStops | undefined, program: Pick<CompiledSauceProgram, "derivedValues">): bigint[];
```

### `SvmStopLayout`

*Type* · `@eco-incorp/sauce/svm`

The concentrated-liquidity layouts a stop is worked out for.

```typescript theme={null}
export type SvmStopLayout = "raydium" | "whirlpool" | "defituna" | "crema";
```

### `SvmSwapCost`

*Interface* · `@eco-incorp/sauce/svm`

What a venue's program charges one swap at a price, in compute units: `base` for the swap itself
and `tick` for each initialized tick it crosses (a tick it walks past uninitialized costs next to
nothing). Both are the venue program's own units as the engine calls it, under CPI, as its log
line reports them (`Program <id> consumed N`): the invoke itself and the accounts it serializes are
the caller's, in `SVM_SWAP_FIXED`, so a caller pricing the venue under its own CPI adds its own.
`base` is at or above every walk of none measured and `tick` at or above the steepest step between
two measured walks, on the venues' own programs as mainnet runs them; the router suite holds both
to those programs, so a
program upgrade that moves them fails it. A whirlpool with an adaptive fee, which pays per step of
its volatility too, is not priced here: the router skips it at a price.

```typescript theme={null}
export interface SvmSwapCost {
    readonly base: number;
    readonly tick: number;
}
```

### `SVM_SWAP_COSTS`

*Variable* · `@eco-incorp/sauce/svm`

```typescript theme={null}
SVM_SWAP_COSTS: Readonly<Record<string, SvmSwapCost>>
```

### `svmSwapCost`

*Variable* · `@eco-incorp/sauce/svm`

What `program`'s swap costs: its row of `SVM_SWAP_COSTS`, else the table's dearest.

```typescript theme={null}
svmSwapCost: (program: string) => SvmSwapCost
```

### `SVM_COOK_UNITS`

*Variable* · `@eco-incorp/sauce/svm`

The units a Solana cook may spend: the compute-unit limit its transaction asks for.

```typescript theme={null}
SVM_COOK_UNITS = 1400000
```

### `SVM_COOK_FIXED`

*Variable* · `@eco-incorp/sauce/svm`

What the cook spends besides the venues' programs, as `sauce tx` estimates it with no simulation:
the Kitchen, the engine and the program's own work, `SVM_COOK_FIXED`; each swap at a price that
trades, the router reading its pool and arrays, the balances around it and the venue's invoke,
`SVM_SWAP_FIXED`; each whose pool it reads and leaves (past its limit, an adaptive fee),
`SVM_SWAP_IDLE`; and each with no pool at its key, `SVM_SWAP_SKIPPED`. Measured on the distributed
swap's program, a little above; `sauce simulate` and `sauce run` measure each cook's own.

```typescript theme={null}
SVM_COOK_FIXED = 200000
```

### `SVM_SWAP_FIXED`

*Variable* · `@eco-incorp/sauce/svm`

```typescript theme={null}
SVM_SWAP_FIXED = 255000
```

### `SVM_SWAP_IDLE`

*Variable* · `@eco-incorp/sauce/svm`

```typescript theme={null}
SVM_SWAP_IDLE = 120000
```

### `SVM_SWAP_SKIPPED`

*Variable* · `@eco-incorp/sauce/svm`

```typescript theme={null}
SVM_SWAP_SKIPPED = 20000
```

### `SVM_HEADROOM_TICKS`

*Variable* · `@eco-incorp/sauce/svm`

The initialized ticks each pool that trades is charged past its walk, for a price that moves
between the cook's building and its landing: tick-spacing positions, each holding at most one
initialized tick. A held pool's Stopped form skips the pool where its price has moved further than
that from where its walk was priced, so a held pool crosses at most this many more initialized
ticks than were priced, while the ticks in its way stay as they were read: a position opened inside
the walk in the meantime adds a crossing nothing charged.

```typescript theme={null}
SVM_HEADROOM_TICKS = 3
```

### `SvmStopPool`

*Interface* · `@eco-incorp/sauce/svm`

A pool a swap at a price walks, as the cook's builder reads it.

```typescript theme={null}
export interface SvmStopPool {
    readonly name: string;
    readonly program: Address;
    readonly layout: SvmStopLayout;
    readonly pool: Uint8Array;
    readonly fee: bigint;
    readonly arrays: readonly (Uint8Array | undefined)[];
    readonly paysA: boolean;
    readonly priceLimit?: bigint;
    readonly runs?: number;
}
```

### `SvmWalk`

*Interface* · `@eco-incorp/sauce/svm`

How far a pool's swap would walk, unheld, and what that costs and buys.

```typescript theme={null}
export interface SvmWalk {
    readonly liquidity: bigint;
    readonly tick: number;
    readonly spacing: number;
    readonly window: number;
    readonly deep?: number;
    readonly limitTick: number;
    readonly crossed: readonly number[];
    readonly units: number;
    readonly output: bigint;
    readonly none?: true;
}
```

### `SvmComputeStop`

*Interface* · `@eco-incorp/sauce/svm`

A pool's stop, as the cook's builder worked it out.

```typescript theme={null}
export interface SvmComputeStop {
    readonly name: string;
    readonly stop: bigint;
    readonly deepTick?: number;
    readonly skipped?: boolean;
    readonly limit?: bigint;
    readonly from?: number;
    readonly stopTick?: number;
    readonly ticksToLimit: number;
    readonly estimatedUnits: number;
    readonly share: number;
    readonly rank: number;
}
```

### `SvmTick`

*Interface* · `@eco-incorp/sauce/svm`

An initialized tick, and the liquidity crossing it adds walking up.

```typescript theme={null}
export interface SvmTick {
    readonly tick: number;
    readonly net: bigint;
}
```

### `SvmTickArray`

*Interface* · `@eco-incorp/sauce/svm`

An array's first tick, its span in ticks, and its initialized ticks.

```typescript theme={null}
export interface SvmTickArray {
    readonly start: number;
    readonly span: number;
    readonly ticks: readonly SvmTick[];
}
```

### `SvmPoolStop`

*Interface* · `@eco-incorp/sauce/svm`

A pool's stop, with what a person reads of it.

```typescript theme={null}
export interface SvmPoolStop extends SvmComputeStop {
    readonly pool: Address;
    readonly label: string;
    readonly venue: string;
    readonly pay: string;
    readonly buy: string;
    readonly stopPrice?: string;
}
```

### `SvmProgramStops`

*Interface* · `@eco-incorp/sauce/svm`

The stops of a cook: each swap's, by its stop's derivation (`name`), in the program's order.

```typescript theme={null}
export interface SvmProgramStops {
    readonly stops: readonly SvmPoolStop[];
    readonly binding: readonly string[];
    readonly budget: number;
    readonly fixed: {
        readonly units: number;
        readonly measured: boolean;
    };
    readonly headroom: number;
    readonly unbounded?: {
        readonly label: string;
        readonly runs: number | null;
    };
}
```


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