# Packages (/developers/reference/packages)



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

## The dependency graph [#the-dependency-graph]

```text
core
 ├─ venues ─────┐
 │              ├─ quote ──┐
 ├─ oracle ─────┤          │
 │              └──────────┴─ tx ──┬─ apps/cli
 └───────────────────────────────  └─ apps/web
```

| Package                | Depends on                                                          |
| ---------------------- | ------------------------------------------------------------------- |
| `@cardano-swap/core`   | `@noble/hashes`, `@scure/base`, `zod`                               |
| `@cardano-swap/venues` | `core`                                                              |
| `@cardano-swap/quote`  | `core`, `venues`                                                    |
| `@cardano-swap/oracle` | `core`, `@noble/curves`                                             |
| `@cardano-swap/tx`     | `core`, `venues`, `quote`, `oracle`, `@lucid-evolution/lucid`       |
| `apps/cli`             | `core`, `venues`, `quote`, `oracle`, `tx`, `@lucid-evolution/lucid` |
| `apps/web`             | `core`, `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` [#cardano-swapcore]

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

| Export group  | Contents                                                                                                                                                                                                                                                      |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Network       | `NETWORKS`, `Network`, `isNetwork`, `parseNetwork`, `NETWORK_MAGIC`, `NETWORK_ID`, `ADDRESS_HRP`, `STAKE_ADDRESS_HRP`, `networkMagic`, `networkId`                                                                                                            |
| Configuration | The full Zod schema and its inferred types, `loadNetworkConfig`, `resolveConfigDir`, `networkFromEnv`, `requireEnv`, `requireDeployed`, `clearConfigCache`, `ConfigError`                                                                                     |
| Assets        | `assetFingerprint`, `assetSubject`, `AssetRegistry`, `RegistryAsset`, `assetKey`, `AssetRegistryError`                                                                                                                                                        |
| Plutus        | `encodePlutusData`, `decodePlutusData`, the `plutus*` constructors and the `expect*` readers, `bytesToHex`, `hexToBytes`                                                                                                                                      |
| Tagging       | `CIP20_MESSAGE_LABEL`, `CIP20_MAX_BYTES_PER_LINE`, `buildCip20Metadata`, `splitIntoCip20Lines`, `buildSwapTagLines`, `buildSwapTag`, `utf8ByteLength`, `Cip20Error`                                                                                           |
| Providers     | `ChainProvider`, `ProviderCapabilities`, `Utxo`, `Value`, `OutRef`, `OutRefRead`, `Tip`, `ProtocolParameters`, `AssetInfo`, `KoiosProvider`, `BlockfrostProvider`, `createProvider`, `createProviders`, `ChainProviderError`, `parseOutRef`, `outRefToString` |

## `@cardano-swap/venues` [#cardano-swapvenues]

The venue abstraction and every adapter.

| Export group       | Contents                                                                                                                                                                                                          |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Types              | `ExecutionClass`, `CurveType`, `CurveParameters`, `PoolState`, `PoolIdentity`, `PoolRiskFlags`, `VenueExecutionCost`, `SwapQuoteInput`, `SwapQuoteResult`, `VenueAdapter`, `VenueError`, `InsufficientDepthError` |
| Registry           | `VenueRegistry`, `BUILT_IN_VENUE_FACTORIES`, `VenueAdapterFactory`, `SkippedVenue`                                                                                                                                |
| Pool index         | Lookup helpers over a discovered pool set                                                                                                                                                                         |
| Dano Finance       | `DanogoAdapter`, `DANOGO_VENUE_ID`, its datum codec, `calculateConcentratedPoolSwap`, `concentratedReserves`                                                                                                      |
| Minswap V2         | `MinswapV2Adapter`, `MINSWAP_V2_VENUE_ID`, its datum codec and constant product maths                                                                                                                             |
| Minswap Stableswap | `MinswapStableAdapter`, `MINSWAP_STABLE_VENUE_ID`, its datum codec, stableswap maths and pool list                                                                                                                |
| SundaeSwap         | `SundaeSwapV3Adapter`, `SundaeSwapStableAdapter`, `SUNDAE_V3_VENUE_ID`, `SUNDAE_STABLE_VENUE_ID`, their datum codecs and maths                                                                                    |

## `@cardano-swap/quote` [#cardano-swapquote]

| Module       | What it exports                                                                                                      |
| ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `types`      | `Quote`, `QuoteFees`, `Route`, `RouteBranch`, `RouteHop`, `RouteAtomicity`, `Baseline`, `QuoteError`, `NoRouteError` |
| `effective`  | `EffectivePool`, `toEffectivePool`, `composeEffective`, `effectiveOut`, `marginalAtZero`, `inputAtMarginal`          |
| `split`      | `solveSplit`, `waterFill`, `SplitCandidate`, `SplitAllocation`, `SplitResult`                                        |
| `paths`      | `enumeratePaths`, `pathAtomicity`, `CandidatePath`, `refUnit`                                                        |
| `engine`     | `QuoteEngine`, `QuoteRequest`, `QuoteEngineOptions`, `RATE_SCALE`                                                    |
| `crosscheck` | `MINSWAP_AGGREGATOR_URL`, `AGGREGATOR_PROTOCOLS`, `AggregatorProtocol`                                               |

### About the cross check [#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` [#cardano-swaporacle]

| Module      | What it exports                                                                                                                               |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `types`     | `PythPrice`, `PythPayload`, `PythFeedUpdate`, `PythSignedUpdate`, `PythParseError`, `PythSignatureError`, `PythClientError`, `PythGuardError` |
| `parse`     | `parsePythUpdate`, `verifyPythUpdate`, `toPythPrice`                                                                                          |
| `state`     | `PythState`, `TrustedSigner`, `PYTH_STATE_ASSET_NAME_HEX`, and the state UTxO reader                                                          |
| `client`    | The Lazer websocket client and `PYTH_LAZER_STREAM_URLS`                                                                                       |
| `freshness` | `checkFreshness`, `requireFresh`, `FreshnessOptions`, `FreshnessResult`                                                                       |
| `deviation` | `checkDeviation`, `deviationBps`, `toCommonScale`, `checkAdaUsdDeviation`, `checkStablePairDeviation`, `ScaledPrice`, `DeviationResult`       |
| `redeemer`  | `buildPythWithdrawRedeemer`, `encodePythWithdrawRedeemer`                                                                                     |
| `relay`     | Reading a genuine signed update back out of transaction CBOR, and `PythRelayError`                                                            |

## `@cardano-swap/tx` [#cardano-swaptx]

| Module       | What it exports                                                                                                                                                                                          |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lucid`      | `createLucid` and the Lucid `Provider` implementation over `ChainProvider`                                                                                                                               |
| `tagging`    | `attachProductTag`, `readProductTagFromTxCbor`, `requireProductTag`, `ProductTagError`                                                                                                                   |
| `window`     | `submitWindowMs`, `SubmitWindowError`                                                                                                                                                                    |
| `danogo`     | `buildDanogoSwap`, its redeemer builders, `DanogoSwapPlan`, `DanogoSwapLeg`, `DanogoSwapError`, `poolStakingScriptHash`                                                                                  |
| `minswap`    | `buildMinswapSwapOrder`, `buildMinswapCancelOrder`, the order datum codec, address conversion, order status reading, global setting reading, `MINSWAP_MAX_ROUTING_POOLS`, `MINSWAP_DEFAULT_ORDER_TTL_MS` |
| `sundae`     | SundaeSwap order construction and its datum codec                                                                                                                                                        |
| `settlement` | `buildLockIntoSettlement`, `buildClaimSettlement`, `buildRefundSettlement`, their `plan*` counterparts, `resolveSettlementUtxos`, `assertSingleSettlementInput`, and the datum and redeemer codec        |
| `oracle`     | The Pyth zero withdrawal builder                                                                                                                                                                         |
| `simulate`   | Simulation helpers for a built transaction                                                                                                                                                               |

## `apps/cli` [#appscli]

The `cardano-swap` binary. See [Command line](/developers/reference/command-line).

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

## `apps/web` [#appsweb]

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` [#onchain]

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

## Related [#related]

<Cards>
  <Card title="Architecture" href="/developers" />

  <Card title="Local development" href="/developers/local-development" />
</Cards>
