Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion clients/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ FyndClientBuilder::new(fynd_url)
FyndClientBuilder::new(fynd_url).build_quote_only()?
```

Against the hosted gateway (`fynd-api.propellerheads.xyz`), add auth and per-chain routing:

```rust
FyndClientBuilder::new("https://fynd-api.propellerheads.xyz")
.with_api_key(tycho_api_key) // sent as the raw `Authorization` header value (no `Bearer` prefix)
.with_chain("base") // routes to /v1/base/quote instead of /v1/quote
.build_quote_only()?
```

Both are opt-in; omitting them keeps the unauthenticated, unprefixed paths that self-hosted
Fynd serves. `with_chain` accepts `ethereum`, `base`, `arbitrum`, `bsc`, `polygon`, `unichain`
and rejects anything else at build time. It also determines the `chain_id` used for signing
when building via `build_quote_only` (no RPC node to ask); `build` cross-checks the slug
against the chain the RPC node reports and errors on a mismatch.

**`FyndClient`**
- `quote(params: QuoteParams) -> Result<Quote, FyndError>` — request a swap quote
- `batch_quote(params: BatchQuoteParams) -> Result<Vec<Quote>, FyndError>` — request multiple quotes in one call
Expand Down Expand Up @@ -81,7 +96,14 @@ For full details, see [`.claude/knowledge/typescript.md`](../.claude/knowledge/t
pnpm workspace at `clients/typescript/` with two packages: `client` and `examples/tutorial`.

- **`@kayibal/fynd-client`** (`client/`) — Typed HTTP client: `FyndClient`, signing, Permit2, error types.
Contains `autogen.ts` and `schema.d.ts` (generated from `openapi-typescript`; do not edit manually).
Contains `schema.d.ts` (generated by `scripts/update-openapi.sh`; do not edit manually) and
`autogen.ts` (a hand-maintained wrapper over `openapi-fetch`).

Hosted-gateway equivalents of the Rust builder options are `FyndClientOptions.apiKey` and
`.chain`, plus `.headers` for arbitrary headers. Chain routing is implemented as an
`openapi-fetch` middleware that rewrites `/v1/…` to `/v1/{chain}/…`, so call sites stay typed
against the generated schema literals. `createFyndClient` and the `Middleware` type are
re-exported from the package root for callers that want to add their own middleware.

### Build & Test

Expand Down
Loading
Loading