Zerochord
Reference

Packages

The workspace packages, what each exports, and how they depend on one another.

Five libraries and two applications, all private workspace packages under Apache 2.0.

The dependency graph

core
 ├─ venues ─────┐
 │              ├─ quote ──┐
 ├─ oracle ─────┤          │
 │              └──────────┴─ tx ──┬─ apps/cli
 └───────────────────────────────  └─ apps/web
PackageDepends on
@cardano-swap/core@noble/hashes, @scure/base, zod
@cardano-swap/venuescore
@cardano-swap/quotecore, venues
@cardano-swap/oraclecore, @noble/curves
@cardano-swap/txcore, venues, quote, oracle, @lucid-evolution/lucid
apps/clicore, venues, quote, oracle, tx, @lucid-evolution/lucid
apps/webcore, venues, quote, tx, plus React, TanStack and Weld

@cardano-swap/quote deliberately does not depend on @cardano-swap/oracle. The oracle guards are pure functions a caller applies.

@cardano-swap/core

Everything network identity, configuration, chain access and asset identity.

Export groupContents
NetworkNETWORKS, Network, isNetwork, parseNetwork, NETWORK_MAGIC, NETWORK_ID, ADDRESS_HRP, STAKE_ADDRESS_HRP, networkMagic, networkId
ConfigurationThe full Zod schema and its inferred types, loadNetworkConfig, resolveConfigDir, networkFromEnv, requireEnv, requireDeployed, clearConfigCache, ConfigError
AssetsassetFingerprint, assetSubject, AssetRegistry, RegistryAsset, assetKey, AssetRegistryError
PlutusencodePlutusData, decodePlutusData, the plutus* constructors and the expect* readers, bytesToHex, hexToBytes
TaggingCIP20_MESSAGE_LABEL, CIP20_MAX_BYTES_PER_LINE, buildCip20Metadata, splitIntoCip20Lines, buildSwapTagLines, buildSwapTag, utf8ByteLength, Cip20Error
ProvidersChainProvider, ProviderCapabilities, Utxo, Value, OutRef, OutRefRead, Tip, ProtocolParameters, AssetInfo, KoiosProvider, BlockfrostProvider, createProvider, createProviders, ChainProviderError, parseOutRef, outRefToString

@cardano-swap/venues

The venue abstraction and every adapter.

Export groupContents
TypesExecutionClass, CurveType, CurveParameters, PoolState, PoolIdentity, PoolRiskFlags, VenueExecutionCost, SwapQuoteInput, SwapQuoteResult, VenueAdapter, VenueError, InsufficientDepthError
RegistryVenueRegistry, BUILT_IN_VENUE_FACTORIES, VenueAdapterFactory, SkippedVenue
Pool indexLookup helpers over a discovered pool set
Dano FinanceDanogoAdapter, DANOGO_VENUE_ID, its datum codec, calculateConcentratedPoolSwap, concentratedReserves
Minswap V2MinswapV2Adapter, MINSWAP_V2_VENUE_ID, its datum codec and constant product maths
Minswap StableswapMinswapStableAdapter, MINSWAP_STABLE_VENUE_ID, its datum codec, stableswap maths and pool list
SundaeSwapSundaeSwapV3Adapter, SundaeSwapStableAdapter, SUNDAE_V3_VENUE_ID, SUNDAE_STABLE_VENUE_ID, their datum codecs and maths

@cardano-swap/quote

ModuleWhat it exports
typesQuote, QuoteFees, Route, RouteBranch, RouteHop, RouteAtomicity, Baseline, QuoteError, NoRouteError
effectiveEffectivePool, toEffectivePool, composeEffective, effectiveOut, marginalAtZero, inputAtMarginal
splitsolveSplit, waterFill, SplitCandidate, SplitAllocation, SplitResult
pathsenumeratePaths, pathAtomicity, CandidatePath, refUnit
engineQuoteEngine, QuoteRequest, QuoteEngineOptions, RATE_SCALE
crosscheckMINSWAP_AGGREGATOR_URL, AGGREGATOR_PROTOCOLS, AggregatorProtocol

About the cross check

crosscheck compares this engine's arithmetic against the Minswap Aggregator. It is a correctness check on the maths and nothing else: it never replaces a quote, it never feeds the transaction builder, and a failure to reach it is not a failure to quote.

Its whole purpose is that if this number and an independent implementation's number drift apart, that is discovered.

@cardano-swap/oracle

ModuleWhat it exports
typesPythPrice, PythPayload, PythFeedUpdate, PythSignedUpdate, PythParseError, PythSignatureError, PythClientError, PythGuardError
parseparsePythUpdate, verifyPythUpdate, toPythPrice
statePythState, TrustedSigner, PYTH_STATE_ASSET_NAME_HEX, and the state UTxO reader
clientThe Lazer websocket client and PYTH_LAZER_STREAM_URLS
freshnesscheckFreshness, requireFresh, FreshnessOptions, FreshnessResult
deviationcheckDeviation, deviationBps, toCommonScale, checkAdaUsdDeviation, checkStablePairDeviation, ScaledPrice, DeviationResult
redeemerbuildPythWithdrawRedeemer, encodePythWithdrawRedeemer
relayReading a genuine signed update back out of transaction CBOR, and PythRelayError

@cardano-swap/tx

ModuleWhat it exports
lucidcreateLucid and the Lucid Provider implementation over ChainProvider
taggingattachProductTag, readProductTagFromTxCbor, requireProductTag, ProductTagError
windowsubmitWindowMs, SubmitWindowError
danogobuildDanogoSwap, its redeemer builders, DanogoSwapPlan, DanogoSwapLeg, DanogoSwapError, poolStakingScriptHash
minswapbuildMinswapSwapOrder, buildMinswapCancelOrder, the order datum codec, address conversion, order status reading, global setting reading, MINSWAP_MAX_ROUTING_POOLS, MINSWAP_DEFAULT_ORDER_TTL_MS
sundaeSundaeSwap order construction and its datum codec
settlementbuildLockIntoSettlement, buildClaimSettlement, buildRefundSettlement, their plan* counterparts, resolveSettlementUtxos, assertSingleSettlementInput, and the datum and redeemer codec
oracleThe Pyth zero withdrawal builder
simulateSimulation helpers for a built transaction

apps/cli

The cardano-swap binary. See Command line.

Its modules are also importable: wallet, router, audit, footprint, integrity and deploy.

apps/web

The browser interface, on Vite, React 19, TanStack Router and TanStack Query, with wallet access through Weld. Three screens: the swap, the pending orders and a receipt.

onchain

The Aiken project. validators/settlement.ak and lib/budget.ak, compiled to Plutus V3, with the blueprint written to onchain/plutus.json.

On this page