@eco-incorp/sauce/svm: per venue, its program ids, pool account decoding and the accounts a swap takes. listVenues() returns the venues registered for the Solana.<Venue> accessors; every other adapter is imported by name.
@eco-incorp/sauce.
dlmmPow
Function · @eco-incorp/sauce/svm
base (a Q64.64 value) raised to the integer power exp, as a Q64.64 value; null where it cannot be represented.
dlmmAmountOut
Function · @eco-incorp/sauce/svm
The amount received for amountIn paid into a bin at price.
dlmmAmountIn
Function · @eco-incorp/sauce/svm
The amount that must be paid into a bin at price to receive amountOutValue.
SCALE_COMMON_TOKEN_PROGRAM
Variable · @eco-incorp/sauce/svm
TOKEN_2022_PROGRAM
Variable · @eco-incorp/sauce/svm
ASSOCIATED_TOKEN_PROGRAM
Variable · @eco-incorp/sauce/svm
SYSTEM_PROGRAM
Variable · @eco-incorp/sauce/svm
SCALE_AMM_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
SCALE_VMM_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
BUY_DISCRIMINATOR
Variable · @eco-incorp/sauce/svm
Anchor global instruction discriminators (sha256(“global:<name>”)[0..8]).
SELL_DISCRIMINATOR
Variable · @eco-incorp/sauce/svm
FEE_BENEFICIARY_SLOTS
Variable · @eco-incorp/sauce/svm
CONFIG_SEED
Variable · @eco-incorp/sauce/svm
The literal ASCII seed both programs’ PlatformConfig PDA uses (seeds=[“config”]).
POOL_SEED
Variable · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
CurveType::ConstantProduct - the only variant this adapter supports (see module doc).
SCALE_CURVE_HELPER_NAME
Variable · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
scaleCommonReadUintLE
Function · @eco-incorp/sauce/svm
pubkeyAt
Function · @eco-incorp/sauce/svm
readFeeBeneficiaries
Function · @eco-incorp/sauce/svm
Reads all FEE_BENEFICIARY_SLOTS entries unconditionally (inactive slots are zero-inited).
ata
Function · @eco-incorp/sauce/svm
Associated Token Account address: PDA([owner, tokenProgram, mint], ASSOCIATED_TOKEN_PROGRAM).
detectTokenProgram
Function · @eco-incorp/sauce/svm
Which token program serves this mint - the SAME detection + gate the SDK’s pumpswap adapter
uses. The OWNER decides the program: an extensionless Token-2022 mint is 82 bytes, exactly a
classic mint’s layout, so only the owner tells them apart. Without an owner, an 82-byte mint is
taken as legacy. A Token-2022 mint’s extensions are then checked either way: 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 · @eco-incorp/sauce/svm
TS mirror of the qScaleCurve SauceScript helper - see module doc for the derivation.
scaleDepthReserves
Function · @eco-incorp/sauce/svm
Effective (reserveIn, reserveOut) for the relative-depth filter - the VIRTUAL reserves the curve above actually prices against.
scaleContinuousFees
Function · @eco-incorp/sauce/svm
Continuous-oracle fee model (measurement only).
pda
Function · @eco-incorp/sauce/svm
FeeBeneficiary
Interface · @eco-incorp/sauce/svm
ScaleDirection
Type · @eco-incorp/sauce/svm
ScaleCurveState
Interface · @eco-incorp/sauce/svm
configurePdaMemo
Function · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
The memo’s current maximum-entry cap (default DEFAULT_PDA_MEMO_MAX_ENTRIES).
DEFAULT_PDA_MEMO_MAX_ENTRIES
Variable · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
Options for configurePdaMemo.
AccountLoader
Type · @eco-incorp/sauce/svm
Data-only account source: address in, raw account data out (null when the account does not
exist). What the readers that need no owner take; accountDataLoader projects one out of an
OwnedAccountLoader.
OwnedAccountLoader
Type · @eco-incorp/sauce/svm
RPC-or-fixture account source WITH the owning program: address in, the account’s data and owner
out (null when the account does not exist). fetchPoolConfig takes one of these, so LiteSVM
fixture tests run without any RPC.
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. Every adapter’s mint gate passes the owner to
classifyMintProgram.
AccountBytesMap
Type · @eco-incorp/sauce/svm
Point-in-time account state keyed by base58 address - what referenceQuote
reads instead of the chain.
PoolConfig
Interface · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
User-side refs for buildSwap. Refs, not addresses: the caller resolves them
(resolveAccounts) when sending.
VenueSwap
Interface · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
ceilDiv
Function · @eco-incorp/sauce/svm
Ceiling division: smallest q with q * b >= a. Non-negative dividends only.
readUintLE
Function · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
ORACLE_EXPONENT_RANGES
Variable · @eco-incorp/sauce/svm
listVenues
Function · @eco-incorp/sauce/svm
Known venue slugs, in table order.
venueAdapter
Function · @eco-incorp/sauce/svm
Looks up a venue adapter by slug; throws listing the known slugs.
RegisteredVenueSlug
Type · @eco-incorp/sauce/svm
The registered venue slugs, as a literal union - what svm/accessors.ts builds its tree from.
SvmHelperFn
Interface · @eco-incorp/sauce/svm
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.
mulDivDown
Function · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
ceil(a*n/d), 0 on a zero divisor (engine DIV-rule parity).
divUpRaw
Function · @eco-incorp/sauce/svm
ceil(a/d), 0 on a zero divisor (engine DIV-rule parity).
mulDown
Function · @eco-incorp/sauce/svm
mulUp
Function · @eco-incorp/sauce/svm
divDown
Function · @eco-incorp/sauce/svm
divUp
Function · @eco-incorp/sauce/svm
complement
Function · @eco-incorp/sauce/svm
calcWrappedAmount
Function · @eco-incorp/sauce/svm
calcUnwrappedAmount
Function · @eco-incorp/sauce/svm
calcRoundedAmount
Function · @eco-incorp/sauce/svm
decodeStabbleVault
Function · @eco-incorp/sauce/svm
decodeStabblePoolCommon
Function · @eco-incorp/sauce/svm
deriveStabbleVaultAuthority
Function · @eco-incorp/sauce/svm
vault_authority = create_program_address([“vault_authority”, vault, [bump]], VAULT_PROGRAM_ID) - verified against live mainnet vaults. A KNOWN bump, read straight off the Vault account (never
find_program_address: that would be wrong if the stored bump isn’t the canonical one).
findStabbleAta
Function · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
isqrtFloor
Function · @eco-incorp/sauce/svm
Integer floor(sqrt(n)), Newton’s method.
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 · @eco-incorp/sauce/svm
OVER-estimate of base^exponent (base in (0, ONE], exponent >= 0, both ONE(1e9)-scaled).
weightedCalcOutGivenIn
Function · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
WEIGHTED_SWAP_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
STABBLE_VAULT_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
STABBLE_TOKEN_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
STABBLE_TOKEN_2022_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
STABBLE_ATA_PROGRAM_ID
Variable · @eco-incorp/sauce/svm
STABBLE_POOL_DISCRIMINATOR
Variable · @eco-incorp/sauce/svm
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 · @eco-incorp/sauce/svm
sha256(“account:Vault”)[..8].
STABBLE_SWAP_DISCRIMINATOR
Variable · @eco-incorp/sauce/svm
sha256(“global:swap”)[..8] - the v1 swap(amount_in: Option<u64>, minimum_amount_out: u64) entry point.
STABBLE_ONE
Variable · @eco-incorp/sauce/svm
StabbleTokenScale
Interface · @eco-incorp/sauce/svm
StabblePoolTokenBase
Interface · @eco-incorp/sauce/svm
StabbleVaultInfo
Interface · @eco-incorp/sauce/svm
assertStabbleU64AmountIn
Function · @eco-incorp/sauce/svm
STABBLE_U64_MAX
Variable · @eco-incorp/sauce/svm
STABLE_AMP_PRECISION
Variable · @eco-incorp/sauce/svm
STABLE_MIN_TOKENS
Variable · @eco-incorp/sauce/svm
STABLE_MAX_TOKENS
Variable · @eco-incorp/sauce/svm
WEIGHTED_MAX_IN_RATIO
Variable · @eco-incorp/sauce/svm
WEIGHTED_MIN_TOKENS
Variable · @eco-incorp/sauce/svm
WEIGHTED_MAX_TOKENS
Variable · @eco-incorp/sauce/svm
