svm/venues.
Generated from the type declarations shipped in
@eco-incorp/sauce 0.99.4. Each entry shows the package authors’ JSDoc and declaration for this SDK version. For runtime compatibility and deployed addresses, see architecture and deployments.ceilDiv
Function · sdk/dist/svm/venues/math.d.ts
Ceiling division: smallest q with q * b >= a. Non-negative dividends only.
readUintLE
Function · sdk/dist/svm/venues/math.d.ts
Little-endian unsigned field read - the TS mirror of the compiler’s
accountUint(ref, offset, width). All seven venues are pure-LE; BE never
occurs. width is in bytes, 1..=32 (SPL token amount = readUintLE(data, 64, 8)).
assertOracleExponent
Function · sdk/dist/svm/venues/oracle-exponent.d.ts
Deterministic range gate: same bytes in, same throw out, before any BigInt
power is constructed. Rejects the whole out-of-range i32 domain, extremes
included. Note what Math.abs does NOT do here: Math.abs(i32::MIN) is
2147483648 - a perfectly ordinary, safe JS integer that sails into BigInt
intact. Taking an absolute value bounds the SIGN, never the MAGNITUDE, so the
gate has to reject on the value itself.
- @param provider which account format the exponent was decoded from
- @param expo the decoded, sign-corrected
i32 - @param context caller-supplied identity (venue, pool, account) for the error
OracleExponentProvider
Type · sdk/dist/svm/venues/oracle-exponent.d.ts
The oracle account FORMATS these adapters decode an exponent out of. The
issuer is Pyth in both cases; the formats differ in how the bound reaches
them, which is why they are separate rows rather than one global constant.
PYTH_MAX_NUM_DECIMALS
Variable · sdk/dist/svm/venues/oracle-exponent.d.ts
MAX_NUM_DECIMALS as the Pythnet oracle program itself defines it:
pyth-network/pyth-client, program/rust/src/c_oracle_header.rs -
/// Bound on the range of the exponent in price accounts. This number is set
/// such that the PD-based EMA computation does not lose too much precision.
pub const MAX_NUM_DECIMALS: i32 = 12;
enforced by utils::check_exponent_range, which asserts
(-MAX_NUM_DECIMALS..=MAX_NUM_DECIMALS).contains(&expo). That check runs in
processor::add_price and processor::init_price - the only two instructions
in the program that ever write price_data.exponent - so no Pyth price
account can carry an exponent outside [-12, 12].
OracleExponentRange
Interface · sdk/dist/svm/venues/oracle-exponent.d.ts
ORACLE_EXPONENT_RANGES
Variable · sdk/dist/svm/venues/oracle-exponent.d.ts
configurePdaMemo
Function · sdk/dist/svm/venues/pda-memo.d.ts
Tune the process-wide PDA-derivation memo. Call once at startup - the memo is
a single process-lifetime cache shared across every CLMM/DLMM venue family,
so this is global configuration, not per-call.
A consumer whose pool universe is large enough to approach the default 100 000
ceiling (each entry is one small (program, pool, window)-shaped key) can
raise maxEntries to keep more derivations warm. Raising it is cheap - the
memo only grows as far as real derivations demand. LOWERING it below the
current population evicts the oldest entries eagerly to honor the new bound
immediately (correct addresses always re-derive on the next miss).
- @throws if
maxEntriesis not a positive integer.
getPdaMemoMaxEntries
Function · sdk/dist/svm/venues/pda-memo.d.ts
The memo’s current maximum-entry cap (default DEFAULT_PDA_MEMO_MAX_ENTRIES).
DEFAULT_PDA_MEMO_MAX_ENTRIES
Variable · sdk/dist/svm/venues/pda-memo.d.ts
Default belt-and-suspenders cap on the memo’s size - the real steady-state
population is a small, bounded set of distinct (program, pool, window)
tick-array/bin-array keys plus one oracle/bitmap/tick-array-map key per
pool (tens of entries per actively-traded pool, across all eleven
families), so this ceiling is never expected to bind in practice. A
consumer running an unusually large pool universe can raise it via
configurePdaMemo.
PdaMemoConfig
Interface · sdk/dist/svm/venues/pda-memo.d.ts
Options for configurePdaMemo.
listVenues
Function · sdk/dist/svm/venues/registry.d.ts
Known venue slugs, in table order.
venueAdapter
Function · sdk/dist/svm/venues/registry.d.ts
Looks up a venue adapter by slug; throws listing the known slugs.
RegisteredVenueSlug
Type · sdk/dist/svm/venues/registry.d.ts
The registered venue slugs, as a literal union - what svm/accessors.ts builds its tree from.
SCALE_COMMON_TOKEN_PROGRAM
Variable · sdk/dist/svm/venues/scale-common.d.ts
TOKEN_2022_PROGRAM
Variable · sdk/dist/svm/venues/scale-common.d.ts
ASSOCIATED_TOKEN_PROGRAM
Variable · sdk/dist/svm/venues/scale-common.d.ts
SYSTEM_PROGRAM
Variable · sdk/dist/svm/venues/scale-common.d.ts
SCALE_AMM_PROGRAM_ID
Variable · sdk/dist/svm/venues/scale-common.d.ts
SCALE_VMM_PROGRAM_ID
Variable · sdk/dist/svm/venues/scale-common.d.ts
BUY_DISCRIMINATOR
Variable · sdk/dist/svm/venues/scale-common.d.ts
Anchor global instruction discriminators (sha256(“global:<name>”)[0..8]).
SELL_DISCRIMINATOR
Variable · sdk/dist/svm/venues/scale-common.d.ts
FEE_BENEFICIARY_SLOTS
Variable · sdk/dist/svm/venues/scale-common.d.ts
CONFIG_SEED
Variable · sdk/dist/svm/venues/scale-common.d.ts
The literal ASCII seed both programs’ PlatformConfig PDA uses (seeds=[“config”]).
POOL_SEED
Variable · sdk/dist/svm/venues/scale-common.d.ts
The literal ASCII seed scale_amm’s own (non-VMM-migrated) Pool PDA uses (seeds=[“pool”, owner, mint_a, mint_b]).
CURVE_CONSTANT_PRODUCT
Variable · sdk/dist/svm/venues/scale-common.d.ts
CurveType::ConstantProduct - the only variant this adapter supports (see module doc).
SCALE_CURVE_HELPER_NAME
Variable · sdk/dist/svm/venues/scale-common.d.ts
The shared quote-curve helper, deduped BY NAME across both scale-amm and scale-vmm
(byte-identical source - the
two programs’ math is identical, only account layouts differ). dir is 0 for
aToB (buy: fee on input) and nonzero for bToA (sell: fee on gross output).
SCALE_CURVE_HELPER_SOURCE
Variable · sdk/dist/svm/venues/scale-common.d.ts
scaleCommonReadUintLE
Function · sdk/dist/svm/venues/scale-common.d.ts
pubkeyAt
Function · sdk/dist/svm/venues/scale-common.d.ts
readFeeBeneficiaries
Function · sdk/dist/svm/venues/scale-common.d.ts
Reads all FEE_BENEFICIARY_SLOTS entries unconditionally (inactive slots are zero-inited).
ata
Function · sdk/dist/svm/venues/scale-common.d.ts
Associated Token Account address: PDA([owner, tokenProgram, mint], ASSOCIATED_TOKEN_PROGRAM).
detectTokenProgram
Function · sdk/dist/svm/venues/scale-common.d.ts
Which token program serves this mint, from its account data alone - the SAME
detection + gate the SDK’s pumpswap adapter uses (a classic layout is exactly 82
bytes; an extensionless token-2022 mint is indistinguishable from it, but neither Scale
program is known to interact with such a mint in practice, so this stays conservative
like pumpswap’s own copy). A TransferFeeConfig extension makes real wire amounts
diverge from the quote (a portion of every transfer is withheld by the mint itself), so
such mints are rejected rather than mis-quoted.
computeScaleQuote
Function · sdk/dist/svm/venues/scale-common.d.ts
TS mirror of the qScaleCurve SauceScript helper - see module doc for the derivation.
scaleDepthReserves
Function · sdk/dist/svm/venues/scale-common.d.ts
Effective (reserveIn, reserveOut) for the relative-depth filter - the VIRTUAL reserves the curve above actually prices against.
scaleContinuousFees
Function · sdk/dist/svm/venues/scale-common.d.ts
Continuous-oracle fee model (measurement only).
pda
Function · sdk/dist/svm/venues/scale-common.d.ts
FeeBeneficiary
Interface · sdk/dist/svm/venues/scale-common.d.ts
ScaleDirection
Type · sdk/dist/svm/venues/scale-common.d.ts
ScaleCurveState
Interface · sdk/dist/svm/venues/scale-common.d.ts
mulDivDown
Function · sdk/dist/svm/venues/stabble-common.d.ts
floor(a*n/d) - the engine’s DIV rule (a zero divisor yields 0, never throws), matched here for parity with the on-chain fragment.
mulDivUp
Function · sdk/dist/svm/venues/stabble-common.d.ts
ceil(a*n/d), 0 on a zero divisor (engine DIV-rule parity).
divUpRaw
Function · sdk/dist/svm/venues/stabble-common.d.ts
ceil(a/d), 0 on a zero divisor (engine DIV-rule parity).
mulDown
Function · sdk/dist/svm/venues/stabble-common.d.ts
mulUp
Function · sdk/dist/svm/venues/stabble-common.d.ts
divDown
Function · sdk/dist/svm/venues/stabble-common.d.ts
divUp
Function · sdk/dist/svm/venues/stabble-common.d.ts
complement
Function · sdk/dist/svm/venues/stabble-common.d.ts
calcWrappedAmount
Function · sdk/dist/svm/venues/stabble-common.d.ts
calcUnwrappedAmount
Function · sdk/dist/svm/venues/stabble-common.d.ts
calcRoundedAmount
Function · sdk/dist/svm/venues/stabble-common.d.ts
decodeStabbleVault
Function · sdk/dist/svm/venues/stabble-common.d.ts
decodeStabblePoolCommon
Function · sdk/dist/svm/venues/stabble-common.d.ts
createProgramAddress
Function · sdk/dist/svm/venues/stabble-common.d.ts
sha256(seeds… || programId || “ProgramDerivedAddress”) - the raw
create_program_address with a KNOWN bump (never find_program_address:
would be wrong if the stored bump isn’t the canonical one, and here it’s
always read straight off the Vault account, never searched).
deriveStabbleVaultAuthority
Function · sdk/dist/svm/venues/stabble-common.d.ts
vault_authority = create_program_address([“vault_authority”, vault, [bump]], VAULT_PROGRAM_ID) - verified against live mainnet vaults.
findStabbleAta
Function · sdk/dist/svm/venues/stabble-common.d.ts
Canonical ATA(owner, mint) under the classic SPL Token program - a real find_program_address (off-curve search), needed once per pool at fetch time.
stableCalcInvariantN
Function · sdk/dist/svm/venues/stabble-common.d.ts
calc_invariant - Newton-Raphson D, <=64 rounds, converged when |D - Dprev| <= 100 (NOT 1 - Stabble’s own default threshold, distinct from the 2-coin curve’s threshold of 1).
stableGetBalanceGivenInvariant
Function · sdk/dist/svm/venues/stabble-common.d.ts
get_token_balance_given_invariant_n_all_other_balances - cold start (the venue’s own initial guess), see stableSolveY for the shared Newton loop.
stableGetBalanceGivenInvariantWarm
Function · sdk/dist/svm/venues/stabble-common.d.ts
Ladder warm-start variant: same Newton recursion, starting from a caller-supplied y0 (the previous rung’s converged y) instead of the cold initial guess. Passing y0 = invariant reproduces the cold start exactly.
stableCalcOutGivenIn
Function · sdk/dist/svm/venues/stabble-common.d.ts
calc_out_given_in - the exact-in quote (wrapped units, no fee applied yet). Returns 0 (not throw) on a degenerate/dust input the venue’s own checked_sub would fail on, matching the engine’s div-by-zero-yields-0 convention used throughout this codebase for quote fragments.
stableGetAmplification
Function · sdk/dist/svm/venues/stabble-common.d.ts
get_amplification: linear ramp interpolation, clamped at the ramp window’s ends (60s-quantized elapsed, matching the on-chain checked_div(60)?.checked_mul(60)?).
stableDHelperSource
Function · sdk/dist/svm/venues/stabble-common.d.ts
SauceScript SOURCE for the N-token D-Newton ALONE (calc_invariant) - the
ladder’s warm-start split of stableQuoteHelperSource: an N-token pool’s
D depends only on the reserves, so it is computed ONCE per trade (in
emitSetup), not once per rung. Same <=64 rounds / converge |Δ|<=100 as
the combined helper; see that function’s doc for the ceiling-division and
zero-divisor conventions (identical here).
stableYWarmHelperSource
Function · sdk/dist/svm/venues/stabble-common.d.ts
SauceScript SOURCE for the excluded-balance Y-Newton ALONE, WARM-STARTABLE
from a caller-supplied y0 (the ladder’s warm-start split of
stableQuoteHelperSource): identical math to
stableGetBalanceGivenInvariant EXCEPT the cold initial-guess formula is
replaced by the caller’s y0 - passing y0 = d (the venue’s own cold
start) reproduces the venue-exact final quote; a ladder thread the
PREVIOUS rung’s converged y instead, cutting iterations to ~1-2 (a larger
cumulative input means a smaller y, so the previous rung’s y still
approaches the fixed point from above - exactly stableYW’s justification
for the 2-coin case, unchanged by generalizing to N tokens). Same
ceiling-division / zero-divisor conventions as stableQuoteHelperSource.
stableQuoteHelperSource
Function · sdk/dist/svm/venues/stabble-common.d.ts
isqrtFloor
Function · sdk/dist/svm/venues/stabble-common.d.ts
Integer floor(sqrt(n)), Newton’s method. Exported (like every other helper
in this module) so its byte-identity and iteration count are directly
testable - see stabble-isqrt.test.ts.
The seed 1n << ceil(bits/2) (bits = n’s bit length) is picked so the
FIRST iterate already sits >= floor(sqrt(n)) for every n >= 2: n < 2^bits
implies sqrt(n) < 2^(bits/2) <= 2^ceil(bits/2), so the seed’s square,
2^(2*ceil(bits/2)), is >= 2^bits > n. Newton’s iteration for floor-sqrt is
monotonically non-increasing once started at or above the true root and
converges to exactly floor(sqrt(n)) regardless of the starting point (the
classical property this loop has always relied on - only the seed changed
here) - so the RESULT for every n is unchanged; only the number of
iterations needed drops, from ~bits/2 with the old x = n seed (each
early iteration barely halves x) to ~5-8 total once seeded this close to
the root. This matters here specifically because weightedPowUp’s
fractional-exponent path feeds sqrtInternalCeil an ISCALE(1e18)-inflated
operand - routinely ~110-130 bits - so the old seed cost ~55-70 slow
halving iterations per sqrt call, repeated up to POW_FRAC_BITS(64) times
per weightedPowUp invocation.
weightedPowUp
Function · sdk/dist/svm/venues/stabble-common.d.ts
OVER-estimate of base^exponent (base in (0, ONE], exponent >= 0, both ONE(1e9)-scaled).
weightedCalcOutGivenIn
Function · sdk/dist/svm/venues/stabble-common.d.ts
calc_out_given_in (wrapped units) - null (not throw) once amountIn exceeds MAX_IN_RATIO, the venue’s real hard capacity cap (None on-chain, would panic the instruction; the ladder must clamp to this, never quote past it).
weightedPowUpSource
Function · sdk/dist/svm/venues/stabble-common.d.ts
SauceScript SOURCE mirror of weightedPowUp - since weightIn/weightOut
are pool constants (immutable in practice; treated as such here, matching
this codebase’s convention of baking genuinely-immutable curve constants),
the exponent - and therefore the ENTIRE bit-decomposition schedule (how
many squarings for the integer part, how many sqrt iterations for the
fraction, and which of them land a “multiply into result” - is fully
determined at COMPILE TIME. So unlike the runtime loop weightedPowUp
runs in TS, the emitted fragment needs NO loop and NO data-dependent
branch at all: this function TRACES the same schedule off-chain and
emits a flat, unrolled sequence of ceiling-sqrt/ceiling-multiply lines - cheaper AND simpler than a generic runtime loop, and naturally short for
“nice” ratios (50/50, 80/20, …) since the fractional remainder can hit
exactly 0 after only 1-2 iterations. baseVar must already be bound to
the ONE(1e9)-scaled runtime base (divUp(balanceIn, balanceIn+amountIn));
out becomes a const holding the ONE-scaled, ceiling-biased power.
The three exact-integer special cases (ONE/TWO/THREE/FOUR) reproduce the
real program’s own fast path bit-for-bit (mulUp composition, no
approximation); everything else uses the conservative sqrt ladder (see
weightedPowUp’s doc for the accuracy/conservatism proof).
weightedCoreQuoteLines
Function · sdk/dist/svm/venues/stabble-common.d.ts
Full weighted-swap core quote (wrapped-space, NO fee applied yet - the
caller applies swap_fee, matching the real program’s own function
boundary): ${outVar} becomes the wrapped gross output for a wrapped
gross-input expression wrappedXExpr (0 when the expression is 0, never
negative, never throws on a zero/degenerate denominator - matches the
engine’s DIV rule). tag must be unique per call site (rung index or
“final”) so nested locals across multiple emissions in one fragment don’t
collide.
STABLE_SWAP_PROGRAM_ID
Variable · sdk/dist/svm/venues/stabble-common.d.ts
WEIGHTED_SWAP_PROGRAM_ID
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABBLE_VAULT_PROGRAM_ID
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABBLE_TOKEN_PROGRAM_ID
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABBLE_TOKEN_2022_PROGRAM_ID
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABBLE_ATA_PROGRAM_ID
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABBLE_POOL_DISCRIMINATOR
Variable · sdk/dist/svm/venues/stabble-common.d.ts
sha256(“account:Pool”)[..8] - shared by BOTH variants (Anchor discriminators are name-, not program-, keyed; verified against live pool accounts of both programs).
STABBLE_VAULT_DISCRIMINATOR
Variable · sdk/dist/svm/venues/stabble-common.d.ts
sha256(“account:Vault”)[..8].
STABBLE_SWAP_DISCRIMINATOR
Variable · sdk/dist/svm/venues/stabble-common.d.ts
sha256(“global:swap”)[..8] - the v1 swap(amount_in: Option<u64>, minimum_amount_out: u64) entry point.
STABBLE_ONE
Variable · sdk/dist/svm/venues/stabble-common.d.ts
StabbleTokenScale
Interface · sdk/dist/svm/venues/stabble-common.d.ts
StabblePoolTokenBase
Interface · sdk/dist/svm/venues/stabble-common.d.ts
StabbleVaultInfo
Interface · sdk/dist/svm/venues/stabble-common.d.ts
assertStabbleU64AmountIn
Function · sdk/dist/svm/venues/stabble-common.d.ts
STABBLE_U64_MAX
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABLE_AMP_PRECISION
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABLE_MIN_TOKENS
Variable · sdk/dist/svm/venues/stabble-common.d.ts
STABLE_MAX_TOKENS
Variable · sdk/dist/svm/venues/stabble-common.d.ts
WEIGHTED_MAX_IN_RATIO
Variable · sdk/dist/svm/venues/stabble-common.d.ts
WEIGHTED_MIN_TOKENS
Variable · sdk/dist/svm/venues/stabble-common.d.ts
WEIGHTED_MAX_TOKENS
Variable · sdk/dist/svm/venues/stabble-common.d.ts
stabbleStableSwapCalcRoundedAmount
Function · sdk/dist/svm/venues/stabble-common.d.ts
SvmHelperFn
Interface · sdk/dist/svm/venues/stable-helpers.d.ts
The declared-helper shape an SvmRoute venue contributes to codegen (the
generator dedupes helpers by name).
The shared stable-curve Newton helper SOURCES that used to live here
(STABLE_D_HELPER/STABLE_YW_HELPER and their TS mirrors
stableComputeD/stableComputeYWarm) were merge-decomposition ladder
internals - only ladder rung walks consumed them - and moved out with the
ladders themselves to the consuming recipes package. This interface stays
because it is the generic contract, not the math.
AccountLoader
Type · sdk/dist/svm/venues/types.d.ts
RPC-or-fixture account source: address in, raw account data out (null when
the account does not exist). fetchPoolConfig takes one of these so LiteSVM
fixture tests run without any RPC.
OwnedAccountLoader
Type · sdk/dist/svm/venues/types.d.ts
The same source, WITH the owning program.
Owner-based classification is the only correct way to tell a legacy SPL mint from a Token-2022
one - an extensionless T22 mint is byte-identical to a classic 82-byte mint, so no amount of data
inspection can separate them. AccountLoader drops the owner at this boundary, which made that
classification structurally impossible for an adapter; this hands it through.
Additive on purpose: the data-only loader stays the argument every adapter takes, so adapters
move over one at a time rather than in one 64-file sweep.
AccountBytesMap
Type · sdk/dist/svm/venues/types.d.ts
Point-in-time account state keyed by base58 address - what referenceQuote
reads instead of the chain.
PoolConfig
Interface · sdk/dist/svm/venues/types.d.ts
Base shape of a decoded pool configuration. Each adapter extends it with
the venue-specific fields its quote emitter and swap builder need (vault
addresses, fee parameters, curve constants, …) - everything is resolved
once, off-chain, by fetchPoolConfig.
VenueAccount
Interface · sdk/dist/svm/venues/types.d.ts
One account attached to the generated program. ref is the symbolic
account-plan ref used in generated SauceScript; address is present when
the adapter resolved it from PoolConfig and absent for caller-resolved refs
(the user’s token accounts / owner from SwapUser).
SwapUser
Interface · sdk/dist/svm/venues/types.d.ts
User-side refs for buildSwap. Refs, not addresses: the caller resolves them
(resolveAccounts) when sending.
VenueSwap
Interface · sdk/dist/svm/venues/types.d.ts
A ready-to-CPI venue swap: raw instruction data plus its ordered accounts.
Venue-level min_out is always 1 - the recipe’s post-swap outAta delta check
enforces the real bound.
SvmVenueAdapter
Interface · sdk/dist/svm/venues/types.d.ts
