# SDK reference

Every name the packages export, each with what it is, generated from the release it ships with: every entry of `maxy-labs` (also published as `@maxy-labs/sdk`, the same package), `@maxy-labs/loans`, and the Python client's methods. It is for integrators looking up a name; [Install and signers](https://maxy.co/docs/install-and-signers) and the guides show how they fit together.

## maxy-labs

The client and every module: swap, auth, orders, the deprecated borrow, signers, errors.

| Export | Kind | What it is |
| --- | --- | --- |
| `AbortedError` | class | The caller's AbortSignal fired. |
| `AccessTokenProvider` | type | Returns the access token of a wallet session, or null when signed out. |
| `AmountInput` | type | A bigint is in the smallest unit (wei, sats, 6-decimal units); a number or a decimal string is in whole coins. |
| `AmountOutOfRangeError` | class | The order is too small, or over the key's order size cap. |
| `AssetInfo` | interface | A coin you can name, with what the SDK needs to show and parse its amounts. |
| `AssetInput` | type | A coin, in any of these forms. |
| `AuthError` | class | Invalid_api_key, key_revoked, scope_denied, origin_not_allowed, invalid_ticket, auth_required, sandbox_key_refused. |
| `bip21Uri` | function | A bitcoin. |
| `bitcoinAddressOfKey` | function | The native SegWit (bc1q…) address of a Bitcoin key (WIF or hex). |
| `BitcoinSigner` | interface | What the SDK needs from a Bitcoin wallet: its network, its payment account and public key, and PSBT signing. |
| `bitcoinSignerFromKey` | function | A mainnet BitcoinSigner over a key (WIF or hex) whose payment account is its native SegWit (bc1q…) address. |
| `BitcoinSignRequest` | interface | A PSBT for a Bitcoin wallet to sign: the PSBT in base64, the inputs it signs and their sighash type. |
| `BRIDGE_CHAINS` | value | EVM chains with no settler of Maxy's that a two-leg route starts or ends on (a swap or bridge leg the user's own wallet sends). |
| `btc` | namespace | Every export of btc, as one object |
| `buildSignInMessage` | function | The exact Sign-In with Ethereum (EIP-4361) text Maxy's wallet sign-in parses. |
| `buyBtcWithEvm` | function | See core/flows.ts. |
| `buyBtcWithSolana` | function | Buy BTC from Solana. |
| `BuyWithSolanaParams` | interface | The input of buyWithSolana: the Solana wallet, the coin and amount to pay, and the Bitcoin address that receives the BTC. |
| `CallOptions` | interface | The last argument of every method. |
| `ChainError` | class | A chain call failed. |
| `ChainInput` | type | A chain id, or its name. |
| `CoinInput` | type | A coin. |
| `ContextOverrides` | interface | Test hooks for a client: a stand-in read client per chain and a stand-in clock. |
| `createAuth` | function | Builds the wallet sign-in module: a nonce, the Sign-In with Ethereum message, and a session from its signature. |
| `createBitcoinKey` | function | A new Bitcoin key (WIF) and its native SegWit address. |
| `createBorrow` | function | Builds the MaxyLock loans module on a context: markets, vaults, quotes, requests, funding, repayment and claims. |
| `createContext` | function | Resolves a client config into the shared context every module runs on: config, HTTP, chain reads and clock. |
| `createEvmKey` | function | A new EVM key and its address. |
| `createMaxyClient` | function | One client for every Maxy call. |
| `createMaxyRest` | function | The client over the HTTP API alone. |
| `CreateOrderParams` | interface | Signers and addresses `createOrder` may need, depending on the route. |
| `createOrders` | function | Builds the order history module: one list of a wallet's swaps and loans from every source. |
| `createReadClients` | function | A cached viem PublicClient per chain. |
| `createSwap` | function | Builds the swap module on a context: routes, prices, quotes, orders, status and refunds. |
| `createSwapMachine` | function | A small state machine that follows an order's states, for showing progress in a UI. |
| `DeclinedError` | class | 403 recipient_declined or jurisdiction_blocked. |
| `Eip1193Provider` | interface | Minimal EIP-1193 provider shape. |
| `ensureEvmChain` | function | Puts the wallet on `chainId` (switching when it can) and returns the signing account. |
| `EVM_CHAINS` | value | Every EVM chain the SDK reads or sends on, by chain id, with its name, native coin and viem chain. |
| `evmChain` | function | The EVM chain info for a chain id; throws for a chain the SDK does not know. |
| `EvmChainInfo` | interface | One EVM chain as the SDK knows it: id, name, native coin symbol, viem chain and the read proxy that serves it. |
| `EvmKeySignerOptions` | interface | Options of evmSignerFromPrivateKey: the starting chain and the RPC URLs to send transactions through. |
| `EvmSigner` | interface | What the SDK needs from an EVM wallet: its address and chain, switching chains, signing typed data and sending transactions. |
| `evmSignerFromEip1193` | function | Wraps an EIP-1193 provider. |
| `evmSignerFromPrivateKey` | function | An EvmSigner over a private key (0x + 64 hex). |
| `evmSignerFromWalletClient` | function | Wraps a viem WalletClient (or anything shaped like one) as an EvmSigner. |
| `EvmTransactionRequest` | interface | A transaction for an EVM wallet to send: chain, recipient, calldata and value. |
| `evmWallet` | function | The wallet a buy needs, from any of the three. |
| `ExecuteParams` | interface | `swap.execute`. |
| `FetchLike` | type | The fetch function the SDK calls, so a server can pass its own (a proxy, a mock in tests). |
| `FlowEvmWallet` | interface | What a buy needs from an EVM wallet. |
| `FlowProgress` | type | The state a flow helper reports to onProgress: the swap state machine's current state. |
| `FlowResult` | interface | How a flow helper ends: the order id, the order as GET /orders/{id} last read it, and the Bitcoin txid. |
| `FlowSolanaWallet` | interface | What a buy needs from a Solana wallet adapter. |
| `formatAmount` | function | An amount in the smallest unit as whole coins, without trailing zeros. |
| `fromSmallest` | function | The smallest unit as whole coins, without trailing zeros. |
| `getDeployment` | export | A MaxyLock deployment by name: its chain, asset and contract addresses. |
| `getNetworkConfig` | export | The app's network settings for a chain id (its contracts and flags), or null when Maxy does not run there. |
| `httpApiBaseOf` | function | The HTTP API's base for an `apiUrl`. |
| `hyperEvm` | value | HyperEVM as a viem chain (chain id 999). |
| `IdempotencyInProgressError` | class | 409 idempotency_in_progress. |
| `isDeploymentReady` | export | Whether a MaxyLock deployment has every contract address it needs to take loans. |
| `isMaxyError` | function | Whether a value is a MaxyError, optionally with a given code. |
| `isPublishableKey` | value | A publishable key. |
| `isSandboxKey` | value | A test key. |
| `isSwapChain` | function | Whether a chain id has a Maxy settler, so BTC swaps run on it directly. |
| `isUserRejection` | function | EIP-1193 4001, viem UserRejectedRequestError, ethers ACTION_REJECTED, and the usual wallet wording. |
| `LIFI_API_URL` | value | LI.FI's API (status of a LI.FI-carried leg, token lists). |
| `ListOrdersInput` | interface | The input of orders.list: the wallet, which sources to read, and paging. |
| `ListOrdersResult` | interface | What orders.list answers: the orders, newest first, and the sources that could not be read. |
| `ListParams` | interface | Filters and paging for GET /orders: limit, cursor, dates, state and wallet. |
| `MAXY_API_URL` | value | The Maxy API at Maxy's own host. |
| `MAXY_FUNCTIONS_HOST` | value | Maxy's host, where every call the SDK makes goes (since 1.1.0). |
| `MAXY_HTTP_API_URL` | value | The HTTP API's base. |
| `MAXY_PUBLIC_KEY` | value | Deprecated. |
| `MaxyAuth` | type | The wallet sign-in module that createAuth returns. |
| `MaxyBorrow` | type | The MaxyLock loans module that createBorrow returns. |
| `MaxyClient` | type | The client createMaxyClient returns: swap, auth, orders, the deprecated borrow, and the HTTP API resources. |
| `MaxyClientConfig` | interface | The options of createMaxyClient: API key, API URL, RPC URLs, your own hosts, fetch and the session source. |
| `MaxyContext` | interface | What every module runs on: the resolved config, the HTTP client, chain reads and the clock. |
| `maxyError` | function | The typed error for a code. |
| `MaxyError` | class | The error every SDK call throws: a stable code, the HTTP status, whether a retry can help, and the request id. |
| `MaxyErrorCode` | type | Every error code the SDK and the API use, as a union of strings. |
| `MaxyErrorOptions` | interface | The optional fields of a MaxyError: HTTP status, request id, docs link, the server's own code and details. |
| `MAXYLOCK_DEPLOYMENTS` | export | Every MaxyLock deployment by name, with its chain, asset and contracts. |
| `MaxyLockDeployment` | type | One MaxyLock deployment: its name, chain, lent asset and contract addresses. |
| `MaxyLockDeploymentName` | type | The names of the MaxyLock deployments. |
| `MaxyOrder` | interface | One order in a wallet's history, swap or loan, in a single shape: id, route, state, amounts, transactions and times. |
| `MaxyOrders` | type | The order history module that createOrders returns. |
| `MaxyRest` | type | The HTTP API client that createMaxyRest returns: one resource per group of routes. |
| `MaxyRestConfig` | interface | The options of createMaxyRest: API key, base URL, fetch, retries and timeouts. |
| `maxyRpcUrl` | function | Maxy's RPC proxy for a chain on Maxy's host, for a client made without a config (a key signer, the CLI). |
| `MaxySession` | interface | A wallet's signed-in session: its access token, refresh token, expiry and wallet. |
| `MaxySwap` | type | The swap module that createSwap returns. |
| `MaxyWebhookEvent` | interface | What a receiver gets, as JSON. |
| `monad` | value | Monad as a viem chain. |
| `NetworkConfig` | type | The app's settings for one network: chain id, name, contracts and flags. |
| `NetworkError` | class | Maxy could not be reached. |
| `NotFoundError` | class | 404 not_found. |
| `OpenSellsLimitError` | class | 409 open_sells_limit. |
| `OrderAmount` | interface | An amount in an order: the asset, the integer amount in its smallest unit, and the chain. |
| `OrderChain` | type | Where an order's amount or transaction is: an EVM chain id, 'bitcoin' or 'solana'. |
| `OrderKind` | type | What an order is: a swap or a loan. |
| `ordersModule` | namespace | Every export of orders, as one object |
| `OrderState` | type | Normalized lifecycle state. |
| `OrderStateError` | class | 409. |
| `OrderTx` | interface | One transaction of an order: what it did, its chain and its hash. |
| `parseAmount` | function | An amount in whole coins ('0.01', 0.01, '1,000.50') or the smallest unit (bigint), in the smallest unit. |
| `parseAsset` | function | A coin in any AssetInput form, as the precise { chain, token } the routes take. |
| `parseChain` | function | The chain a name, an id or a CAIP-2 id (eip155:8453, bip122:…, solana:…) stands for, or null. |
| `PARTNER_KEY_RE` | value | A partner key and 32 letters and digits. |
| `PaymentInstructions` | interface | Where and how much BTC to send for a sale: the address, the exact sats, the deadline and the bitcoin: URI. |
| `preparedPostOf` | function | The exact request a failed call sent, to resend unchanged (its idempotency key keeps it one order). |
| `PricedQuote` | type | A quote as `swap.price` and `swap.quote` give it. |
| `PriceParams` | interface | The input of prices.get and quotes.get: the two coins and one amount. |
| `projectUrlOf` | function | The host the SDK's calls go to for an `apiUrl`. |
| `QuoteExpiredError` | class | 409 quote_expired. |
| `QuoteParams` | interface | The input of borrow.quote: the vault and either the amount to borrow or the BTC to lock. |
| `QuoteRequest` | interface | The input of swap.quote: the coins, the amount, the addresses and the options of the route. |
| `QuoteWords` | interface | A quote in words. |
| `RateLimitError` | class | 429. |
| `readChain` | function | A chain the SDK can read. |
| `ReadClient` | type | The read-only part of a viem PublicClient the SDK uses for chain reads. |
| `readyBorrowDeployments` | function | MaxyLock markets a borrower can use today (Base / USDC, Robinhood / USDG). |
| `redact` | function | What may reach a log. |
| `ResponseMeta` | interface | What every HTTP API answer carries besides its body: request id, status, latency, retries and rate limit. |
| `retryAfterSecondsOf` | function | `rate_limited`. |
| `robinhood` | value | Robinhood Chain as a viem chain (chain id 4663). |
| `rpcUrlsFor` | function | RPC URLs for SDK reads. |
| `SANDBOX_SCENARIOS` | value | Every sandbox scenario with what it does; pass one as scenario on a quote or an order. |
| `SandboxScenario` | type | The name of a sandbox scenario. |
| `SDK_VERSION` | value | This package's version. |
| `sellBtc` | function | Sell BTC to a chain. |
| `SellHandle` | interface | What sellBtc answers before the BTC is sent: the order id, the payment instructions, and a promise of the end. |
| `SellParams` | interface | The input of sellBtc: the wallet that receives and signs, the coin wanted and the BTC to sell. |
| `ServerError` | class | Maxy answered 5xx, or a shape the SDK does not know. |
| `SETTLEMENT_CHAIN_ID` | value | Base (8453). |
| `settlerAddress` | function | The V6 BitcoinIntentSettler on `chainId` (the contract the swap intent is signed for). |
| `SettlerIntent` | interface | The V6 BitcoinIntentSettler Intent struct (20 fields, the EIP-712 primary type). |
| `SIGN_IN_CHAIN_ID` | value | Wallet-auth accepts chain 8453 (Base) only. |
| `SIGN_IN_DEFAULT_DOMAIN` | value | The hosts Maxy's wallet sign-in accepts sign-in messages for; a message naming any other host is refused. |
| `SignInOptions` | interface | Options of auth.signIn: the host and origin named in the message, and a username for a first sign-in. |
| `SignInResult` | interface | What auth.signIn answers: the session, and whether the wallet signed in for the first time. |
| `signWebhook` | function | The Maxy-Signature header for a raw body. |
| `SolanaSigner` | interface | The legacy Solana provider shape (Phantom, Solflare, Backpack, the Wallet Standard adapter). |
| `SuiSigner` | interface | A Sui wallet for the Sui leg of a Sui coin -> BTC swap. |
| `suiSignerFromKey` | function | A SuiSigner over an ed25519 key (suiprivkey1…, 0x + 64 hex, or base64). |
| `SUPPORTED_NETWORKS` | export | The app's settings for every network Maxy runs on, by chain id. |
| `SWAP_CHAIN_IDS` | value | The mainnet EVM chains with a live V6 BitcoinIntentSettler (EVM <-> BTC swaps). |
| `SWAP_FINAL_STATES` | value | The order states that end an order: completed, refunded, cancelled, expired and failed. |
| `SwapAsset` | interface | A coin on a chain: the chain, and the token address, mint, symbol or coin type. |
| `SwapChain` | type | 'bitcoin', 'solana', 'tron' and 'sui' name the non-EVM sides; EVM chains are numeric chain ids. |
| `SwapChainId` | type | The chain ids that have a Maxy settler. |
| `SwapMachine` | interface | The swap state machine: its state, its context, whether it is done, and the moves between states. |
| `SwapMachineState` | type | The states a swap moves through in a UI, from idle and quoting to completed, refunded or failed. |
| `swapModule` | namespace | Every export of swap, as one object |
| `SwapOrder` | interface | A placed swap order: its route, its id to track it with, its chain and the transactions sent for it. |
| `SwapPair` | interface | One way to swap, as `swap.pairs` lists it. |
| `SwapQuote` | interface | A quote from swap.quote: the route, both coins, the amount sent and the executable amount received, fees and expiry. |
| `SwapRequest` | interface | What `swap.quote` and `swap.execute` take. |
| `SwapResult` | interface | What swap.swap answers: the quote, the placed order and its last status. |
| `SwapRoute` | type | Supported swap routes. |
| `SwapState` | type | An order's state: pending, awaiting_deposit, in_progress, completed, refundable, refunded, cancelled, expired or failed. |
| `SwapStatus` | interface | An order's status from swap.getStatus: its state, the service's own status, whether it is complete, and its transactions. |
| `SwapUpdate` | type | What `swap.execute` reports as it goes, for a progress line or a stepper. |
| `TimeoutError` | class | Maxy did not answer in time. |
| `tokenAddress` | function | Token address by symbol on a swap chain ('ETH' / 'BNB' / 'AVAX' are the zero address). |
| `toSmallest` | function | Whole coins as a decimal string to the smallest unit. |
| `TronSigner` | interface | A Tron wallet for the Tron leg of a Tron coin -> BTC swap. |
| `tronSignerFromKey` | function | A TronSigner over a secp256k1 key (64 hex, as Tron wallets export it). |
| `UNFILLABLE_MESSAGE` | value | What every order larger than Maxy can fill right now is refused with (`insufficient_liquidity`). |
| `UnfillableError` | class | Larger than Maxy can fill right now, or not enough in the wallet. |
| `units` | value | Amount helpers: whole coins to the smallest unit and back, and BTC to sats and back, as decimal strings. |
| `unlocksAtOf` | function | `not_refundable`. |
| `UserRejectedError` | class | The wallet declined the signature or the transaction. |
| `ValidationError` | class | 400. |
| `verifyWebhook` | function | Checks a delivery and returns its event. |
| `ViemWalletClientLike` | interface | Minimal viem WalletClient shape (structural, so any viem 2.x WalletClient fits). |
| `WatchOptions` | interface | Options of orders.watch: the order's chain and route, how long to watch, and stream or polling. |
| `WebhookSignatureError` | class | A bad or stale webhook signature. |
| `WithMeta` | type | Every answer is plain JSON with a non-enumerable `meta`. |
| `ZERO_ADDRESS` | value | The zero address, which names a chain's own coin wherever a token address is asked. |
| `ZERO_HASH` | value | The 32-byte zero hash. |

## maxy-labs/core

The client over the HTTP API alone (fetch only), flow helpers and error classes.

| Export | Kind | What it is |
| --- | --- | --- |
| `AbortedError` | class | The caller's AbortSignal fired. |
| `AddressCheck` | type | What GET /addresses/validate answers: whether the address is valid for the chain, its type and network, and whether an order would pay it. |
| `AmountOutOfRangeError` | class | The order is too small, or over the key's order size cap. |
| `ApiOperations` | interface | The HTTP API's operations as TypeScript types, generated from the OpenAPI document. |
| `ApiPaths` | interface | This file was auto-generated by openapi-typescript. |
| `ApiSchemas` | interface | The HTTP API's schemas as TypeScript types, generated from the OpenAPI document. |
| `AuthError` | class | Invalid_api_key, key_revoked, scope_denied, origin_not_allowed, invalid_ticket, auth_required, sandbox_key_refused. |
| `bip21Uri` | function | A bitcoin. |
| `buyBtcWithEvm` | function | Buy BTC from an EVM chain. |
| `buyBtcWithSolana` | function | Buy BTC from Solana. |
| `BuyWithEvmParams` | interface | The input of buyWithEvm: the EVM wallet, the coin and amount to pay (or the BTC wanted) and the Bitcoin address. |
| `BuyWithSolanaParams` | interface | The input of buyWithSolana: the Solana wallet, the coin and amount to pay, and the Bitcoin address that receives the BTC. |
| `CallOptions` | interface | The last argument of every method. |
| `ChainError` | class | A chain call failed. |
| `CoinInput` | type | A coin. |
| `createMaxyClient` | function | The client over the HTTP API alone. |
| `createMaxyRest` | function | The client over the HTTP API alone. |
| `createResources` | function | Builds the HTTP API resources (prices, pairs, quotes, orders, status, webhooks and more) on a transport. |
| `createRest` | function | Builds the HTTP API transport: the key, the base URL, and the call with retries, timeouts and rate-limit handling. |
| `createSwapMachine` | function | A small state machine that follows an order's states, for showing progress in a UI. |
| `DeclinedError` | class | 403 recipient_declined or jurisdiction_blocked. |
| `errorFromAnswer` | function | The typed error for a failed answer. |
| `ERRORS_DOC` | value | Where every code is explained. |
| `FetchLike` | type | The fetch function the SDK calls, so a server can pass its own (a proxy, a mock in tests). |
| `FlowCommon` | interface | What every flow helper takes: the client, a progress callback, an abort signal and an order placed earlier. |
| `FlowEvmWallet` | interface | What a buy needs from an EVM wallet. |
| `FlowProgress` | type | The state a flow helper reports to onProgress: the swap state machine's current state. |
| `FlowResult` | interface | How a flow helper ends: the order id, the order as GET /orders/{id} last read it, and the Bitcoin txid. |
| `FlowSolanaWallet` | interface | What a buy needs from a Solana wallet adapter. |
| `fromSmallest` | function | The smallest unit as whole coins, without trailing zeros. |
| `Health` | type | What GET /health answers: the solver, Bitcoin and each chain's verifier, with a degraded flag. |
| `IdempotencyInProgressError` | class | 409 idempotency_in_progress. |
| `isMaxyError` | function | Whether a value is a MaxyError, optionally with a given code. |
| `isPublishableKey` | value | A publishable key. |
| `isSandboxKey` | value | A test key. |
| `isUserRejection` | function | EIP-1193 4001, viem UserRejectedRequestError, ethers ACTION_REJECTED, and the usual wallet wording. |
| `KeyInfo` | type | What GET /key answers: your key's class, network and limits. |
| `Limits` | type | What GET /limits answers: your order size cap, the routes' smallest orders and your rate limits. |
| `ListParams` | interface | Filters and paging for GET /orders: limit, cursor, dates, state and wallet. |
| `MAXY_API_URL` | value | The Maxy API at Maxy's own host. |
| `MAXY_HTTP_API_URL` | value | The HTTP API's base. |
| `maxyError` | function | The typed error for a code. |
| `MaxyError` | class | The error every SDK call throws: a stable code, the HTTP status, whether a retry can help, and the request id. |
| `MaxyErrorCode` | type | Every error code the SDK and the API use, as a union of strings. |
| `MaxyErrorOptions` | interface | The optional fields of a MaxyError: HTTP status, request id, docs link, the server's own code and details. |
| `MaxyLogger` | interface | A logger the SDK writes to: debug, info, warn and error, each optional. |
| `MaxyResources` | type | The HTTP API client's resources, one per group of routes. |
| `MaxyRest` | type | The HTTP API client that createMaxyRest returns: one resource per group of routes. |
| `MaxyRestConfig` | interface | The options of createMaxyRest: API key, base URL, fetch, retries and timeouts. |
| `NetworkError` | class | Maxy could not be reached. |
| `NotFoundError` | class | 404 not_found. |
| `OpenSellsLimitError` | class | 409 open_sells_limit. |
| `OrderEvent` | type | One recorded change of an order: its state, the state before, the service's status, the Bitcoin txid and the time. |
| `OrderRef` | interface | What identifies an order's chain and route on the order routes, beside its id. |
| `OrderRow` | type | One order in GET /orders: id, route, chain, state, Bitcoin txid and times. |
| `OrderState` | type | An order's state on the HTTP API, the same nine states as SwapState. |
| `OrderStateError` | class | 409. |
| `Pair` | type | One pair from GET /pairs: the two coins, the route, the settler, the order size and the confirmations. |
| `PARTNER_KEY_RE` | value | A partner key and 32 letters and digits. |
| `PaymentInstructions` | interface | Where and how much BTC to send for a sale: the address, the exact sats, the deadline and the bitcoin: URI. |
| `Price` | type | Generated from the published OpenAPI document (scripts/gen-api-types.mjs). |
| `PriceParams` | interface | The input of prices.get and quotes.get: the two coins and one amount. |
| `Quote` | type | What GET /quote answers: the price fields, the order to send back, the steps and any issues. |
| `QuoteExpiredError` | class | 409 quote_expired. |
| `QuoteParams` | interface | The input of borrow.quote: the vault and either the amount to borrow or the BTC to lock. |
| `RateLimitError` | class | 429. |
| `redact` | function | What may reach a log. |
| `RequestInfo` | interface | What the SDK's hooks receive about a request: method, path and request id. |
| `ResponseInfo` | interface | What the SDK's hooks receive about an answer: the request, its status and its latency. |
| `ResponseMeta` | interface | What every HTTP API answer carries besides its body: request id, status, latency, retries and rate limit. |
| `RestTransport` | type | The HTTP API transport that createRest returns. |
| `RetryInfo` | interface | What the SDK's onRetry hook receives: the request, the attempt, the delay and the status that caused it. |
| `SDK_VERSION` | value | This package's version. |
| `sellBtc` | function | Sell BTC to a chain. |
| `SellHandle` | interface | What sellBtc answers before the BTC is sent: the order id, the payment instructions, and a promise of the end. |
| `SellParams` | interface | The input of sellBtc: the wallet that receives and signs, the coin wanted and the BTC to sell. |
| `ServerError` | class | Maxy answered 5xx, or a shape the SDK does not know. |
| `SseEvent` | interface | One server-sent event from a stream: its name and its JSON data. |
| `Status` | type | What GET /status and GET /orders/{id} answer: the order's state, substatus, receiving transaction and Bitcoin payment. |
| `SWAP_FINAL_STATES` | value | The order states that end an order: completed, refunded, cancelled, expired and failed. |
| `SwapMachine` | interface | The swap state machine: its state, its context, whether it is done, and the moves between states. |
| `SwapMachineState` | type | The states a swap moves through in a UI, from idle and quoting to completed, refunded or failed. |
| `TimeoutError` | class | Maxy did not answer in time. |
| `toSmallest` | function | Whole coins as a decimal string to the smallest unit. |
| `UnfillableError` | class | Larger than Maxy can fill right now, or not enough in the wallet. |
| `units` | value | Amount helpers: whole coins to the smallest unit and back, and BTC to sats and back, as decimal strings. |
| `UserRejectedError` | class | The wallet declined the signature or the transaction. |
| `ValidationError` | class | 400. |
| `WatchOptions` | interface | Options of orders.watch: the order's chain and route, how long to watch, and stream or polling. |
| `WebhookSignatureError` | class | A bad or stale webhook signature. |
| `WithMeta` | type | Every answer is plain JSON with a non-enumerable `meta`. |

## maxy-labs/swap

Every swap route: quotes, orders, status, refunds, the Tron, Sui and Solana-swap legs.

| Export | Kind | What it is |
| --- | --- | --- |
| `AmountInput` | type | A bigint is in the smallest unit (wei, sats, 6-decimal units); a number or a decimal string is in whole coins. |
| `AssetInfo` | interface | A coin you can name, with what the SDK needs to show and parse its amounts. |
| `AssetInput` | type | A coin, in any of these forms. |
| `BRIDGED_BUY_CHAINS` | value | Chains a two-leg buy starts on. |
| `bridgedLegStatus` | function | Where leg 1 stands. |
| `bridgedSellPlan` | export | For a sale paid out on a chain with no settler: the settler payout to take first and the bridge leg after it, or null. |
| `BridgedSellPlan` | type | A two-leg sale's plan: where the settler pays out first, and the coin and chain the bridge leg then delivers. |
| `BridgeStatusHandle` | type | What a bridge leg's status is read with: the carrier, both chains, the recipient, the token and the minimum out. |
| `btcPayoutScript` | function | The receive script for a BTC payout. |
| `BtcToEvmOrder` | interface | A BTC sale to an EVM coin: the order, the Bitcoin address that must pay, and the escrow the payout is locked in. |
| `BtcToSolState` | interface | A BTC to Solana order's state: the filled offer with its payment plan, the payment, and the amounts. |
| `buildBuyIntent` | function | Builds the settler intent a buy signs: maker, asset, Bitcoin address, sats, prices, bond, confirmations and deadline. |
| `buildSellProof` | function | Finds the user's payment into this escrow (exact sats to the committed script, mined after the commit) on Esplora and builds the BitcoinProof the settler checks. |
| `BUY_CONFIRMATION_HEADROOM` | value | The share by which a buy's size is raised before its confirmations are set, so a price move cannot drop a tier. |
| `BUY_CONFIRMATION_TIERS` | value | Bitcoin confirmations a buy's intent asks for, by the order's value. |
| `BUY_MIN_SATS` | value | The smallest BTC buy (Bitcoin's dust limit). |
| `buyConfirmationsFor` | function | The confirmations a buy of `satAmount` asks for at `btcUsd`; the most (3) when the price is unknown. |
| `ChainInfo` | interface | One chain Maxy swaps on: id or name, type, native coin and its settler. |
| `ChainInput` | type | A chain id, or its name. |
| `checkCrossEvmQuote` | function | The SDK's own check of the bytes about to be signed. |
| `checkJupiterSwap` | function | Refuses a Solana swap that does more than this leg. |
| `checkLifiLeg` | function | Every check a leg must pass before the sending wallet is asked to sign it (throws verification_failed). |
| `checkPartnerFeeInput` | function | Checks what was asked, before any quote. |
| `ClaimResult` | interface | What claiming a sale's payout answers: the function called, the transaction, the Bitcoin txid and the amount settled. |
| `CreateBridgedBuyInput` | interface | The input of a two-leg buy: the EVM wallet, the Bitcoin address, the bond, the confirmations and a progress callback. |
| `createBridgedBuyOrder` | function | Evm-btc-bridge from a wallet the SDK holds. |
| `CreateBtcToEvmInput` | interface | The input of a BTC sale to an EVM coin: the sats to sell, the payout chain and token, and the signers. |
| `CreateBtcToSolInput` | interface | The input of a BTC to Solana order: the Solana and Bitcoin signers, the coin, the sats and the quoted amount. |
| `CreateDirectInput` | interface | The input of a buy that escrows the chain's coin or a token directly, with the prices and the approval mode. |
| `CreateEvmToBtcInput` | interface | The input of a buy: the chain, the Bitcoin address, the sats to receive, the EVM signer and the prices. |
| `CreateGaslessInput` | interface | The input of a gasless USDC buy: the order, the prices and the token. |
| `CreateNonEvmBuyInput` | interface | The input of a buy paid from Tron or Sui: the EVM wallet between the legs, the Tron or Sui signer and the Bitcoin address. |
| `createNonEvmBuyOrder` | function | A Tron or Sui coin -> BTC from wallets the SDK holds. |
| `CreateOrderParams` | interface | Signers and addresses `createOrder` may need, depending on the route. |
| `CreateSolToBtcInput` | interface | The input of a SOL to BTC order: the Solana signer, the coin, the amount and the Bitcoin address. |
| `createSwap` | function | Builds the swap module on a context: routes, prices, quotes, orders, status and refunds. |
| `CrossEvmCheck` | type | The verdict of a transaction that passed the SDK's own check. |
| `CrossEvmQuoteInput` | interface | The input of a coin-to-coin quote between EVM chains: both chains and tokens, the amount and the sender. |
| `CrossEvmStatusInput` | interface | The input of a coin-to-coin status read: the source transaction, both chains and the carrier. |
| `describeAsset` | function | Symbol, decimals and chain name of a coin (read on-chain once for tokens Maxy does not list). |
| `EscrowState` | interface | A buy's escrow as the settler holds it: open or not, the maker, the commit and the fill. |
| `EvmToBtcPrices` | interface | The prices a buy is signed at: BTC and the paid coin in dollars, and the solver's cost to fill. |
| `ExecuteParams` | interface | `swap.execute`. |
| `fillCostUsd` | function | USD the solver spends to fill one buy. |
| `findFreeNonce` | function | The lowest unused settler nonce for `maker`. |
| `formatAmount` | function | An amount in the smallest unit as whole coins, without trailing zeros. |
| `formatQuote` | function | Readable figures for a quote. |
| `FoundToken` | interface | A token found by swap.searchTokens: chain, symbol, name, address and decimals read on chain. |
| `getEscrowState` | function | Reads a buy's escrow from its settler: whether it is open, committed or filled. |
| `getSellTemplate` | function | Sell_capacity with settler:{maker}. |
| `INTENT_TTL_SEC` | value | The intent stays valid this long (same as the app). |
| `intentDeposit` | function | The deposit the settler takes for a LIMIT intent at the top of its signed slippage band (PricingLib.buyDepositAmount). |
| `intentJson` | function | The intent as JSON for the solver (it int()s every field). |
| `intentTypedData` | function | The EIP-712 typed data of a settler intent, for a wallet to sign. |
| `isBridgedBuySource` | function | True when (chain, token) buys BTC in two legs. |
| `isNonEvmChain` | value | Whether a chain name is Tron or Sui. |
| `JupiterQuote` | interface | A quote for the Solana swap leg: the two mints, the amounts in and out, the minimum and the slippage. |
| `jupiterSwapTransaction` | function | The Solana swap transaction for this wallet (base64), built from a quote (the app's getJupiterSwapTransaction). |
| `keyCapUsd` | function | This client's key cap, read once from GET /key (null. |
| `LifiLeg` | interface | A LI.FI leg from or to Tron or Sui: both chains and tokens, the amount, the sender and the recipient. |
| `lifiLegStatus` | function | Where a LI.FI leg stands, from LI.FI's own status (by the source transaction). |
| `LifiQuote` | interface | A bridge leg as the solver's route picker handed it out. |
| `lifiState` | function | A bridge leg's state from its status, whichever carrier took it. |
| `LifiStatus` | interface | Where a bridge leg stands. |
| `limitPriceFor` | function | Market price per sat in token base units scaled 1e18, from USD prices (the app's pricing.marketPricePerSat). |
| `listChains` | function | Every chain Maxy swaps on, with its type, native coin and settler. |
| `listPairs` | function | Every pair Maxy swaps, in plain words. |
| `listTokens` | function | The tokens on one chain (a name or id), or on every chain. |
| `ListTokensOptions` | interface | Options of swap.listTokens: also list the tokens in no pair. |
| `LivePricing` | interface | The solver's live prices: BTC, ETH and USDC in dollars, wei per sat and the margin every buy price carries. |
| `localIntentHash` | function | The EIP-712 hash of a settler intent, computed locally. |
| `MAX_FILL_COST_FRACTION` | value | The fill cost is always folded into the signed price, so the escrow carries what the quote charged (the market maker's get_quote already deducts it from the sats). |
| `MaxySwap` | type | The swap module that createSwap returns. |
| `merkleRoot` | function | Folds a merkle branch (internal byte order) for leaf `txidInternal` at `pos`. |
| `MM_SAFE` | export | The market maker's Safe, the same address on every EVM chain. |
| `NON_EVM_CHAINS` | value | Tron and Sui as the SDK knows them: LI.FI's chain id, name, native coin and listed coins. |
| `NonEvmChain` | type | A chain with no EVM address: 'tron' or 'sui'. |
| `NonEvmChainInfo` | interface | Tron or Sui as the SDK knows it: LI.FI's chain id, name, native coin and the coins listed there. |
| `nonEvmChainOfId` | function | Tron or Sui for LI.FI's chain id, or null for any other chain. |
| `orderCapIssue` | function | Over the key's cap. |
| `OrderCapIssue` | interface | An order over your key's size cap: the cap, the order's size in dollars and the message to show. |
| `orderCapMessage` | value | The refusal, word for word as Maxy's servers give it. |
| `orderSats` | function | The BTC side of an order in sats. |
| `orderUsd` | function | An order's size in dollars. |
| `parseAmount` | function | An amount in whole coins ('0.01', 0.01, '1,000.50') or the smallest unit (bigint), in the smallest unit. |
| `parseAsset` | function | A coin in any AssetInput form, as the precise { chain, token } the routes take. |
| `parseChain` | function | The chain a name, an id or a CAIP-2 id (eip155:8453, bip122:…, solana:…) stands for, or null. |
| `PARTNER_FEE_MAX_BPS` | value | The largest partner fee, in basis points of the trade (1%). |
| `PARTNER_FEE_ROUTES` | value | The routes a partner fee runs on. |
| `PARTNER_FEE_ROUTES_TEXT` | value | PARTNER_FEE_ROUTES in words, for every message and the spec (a btc-evm sale takes a fee only with two legs). |
| `PartnerFee` | interface | The fee on a quote. |
| `partnerFeeFor` | function | The partner fee on a quote, or null for none. |
| `partnerFeeFromJson` | function | A fee back from its JSON form (an order the API handed out), every field checked. |
| `PartnerFeeInput` | interface | What a partner asks for, on a price, a quote or an order. |
| `partnerFeeJson` | function | The fee as the HTTP API and an order carry it. |
| `partnerFeeTransaction` | function | The transaction the user's wallet sends to pay the fee. |
| `planReclaim` | function | Which settler call returns the deposit, following the live V6 rules (fork-tested by the app, services/dexService.ts). |
| `prepareBridgedBuy` | function | The order a two-leg quote describes, for `maker`. |
| `PREPARED_TTL_SEC` | value | A prepared order stays usable this long; after that createOrder prepares again. |
| `PreparedBridgedBuy` | interface | A two-leg buy ready to sign: the escrow order on the settler chain and the checked leg before it. |
| `PreparedEscrowOrder` | interface | Everything an evm-btc-escrow order reads before the wallet prompts, done ahead of the user's confirmation. |
| `PreparedNonEvmBuy` | interface | A buy from Tron or Sui ready to sign: the escrow on Base, the checked LI.FI leg and what it delivers. |
| `prepareNonEvmBuy` | function | The order a Tron or Sui quote describes. |
| `PricedQuote` | type | A quote as `swap.price` and `swap.quote` give it. |
| `quoteBridgedBuy` | function | Quotes a two-leg buy. |
| `quoteJupiter` | function | The Solana swap router's quote for swapping `lamports` of SOL (or that raw amount of `inMint`) into `outMint` (the app's getJupiterQuote). |
| `quoteLifiLeg` | function | A LI.FI leg to or from Tron or Sui, asked as the app asks it. |
| `quoteNonEvmBuy` | function | Quotes a Tron or Sui coin -> BTC. |
| `quoteNonEvmPayoutLeg` | function | Leg 2 of BTC -> a Tron or Sui coin, priced (and, with the EVM wallet, built). |
| `QuoteRequest` | interface | The input of swap.quote: the coins, the amount, the addresses and the options of the route. |
| `quoteSwap` | function | Quotes a swap. |
| `QuoteWords` | interface | A quote in words. |
| `readSettlerEscrow` | function | Reads the escrow of a settler sell on-chain. |
| `ReclaimFunction` | type | The settler function that takes an escrow back: cancel, slash or refund after expiry. |
| `ReclaimPlan` | interface | How to take an escrow back: the function, the settler, the calldata and the escrow's state. |
| `resolveRoute` | function | The route the SDK uses for a pair of assets (the same choice the app makes), or throws unsupported_route. |
| `SEARCH_CHAINS` | value | The chains a token can be searched on. |
| `searchTokens` | function | Tokens on `chainId` matching `query` (a symbol, a name, or an address), the closest first. |
| `SELL_SETTLER_CHAINS` | value | Settler payout chains (every coin each settler pays is in SETTLER_SELL_CHAINS). |
| `SellPayment` | interface | A sale's Bitcoin payment: its txid, output, block height and the proof that it was paid. |
| `SellTemplate` | interface | The solver's offer for a sale: its executable payout and the sell intent to sign. |
| `sendJupiterLeg` | function | Sends the Solana swap leg of a BTC to Solana-coin order from the user's wallet, after checking it. |
| `sendSuiLeg` | function | Sends a checked Sui leg from `sui` (LI.FI's TransactionData, signed as it is) and answers its digest. |
| `sendTronLeg` | function | Sends a checked Tron leg from `tron`. |
| `settleChainFor` | function | The chain whose settler takes a two-leg buy from `chainId`. |
| `SETTLER_SELL_CHAINS` | export | The chains where the settler pays out a sale, with the coins it pays. |
| `SettlerAsset` | type | A coin the Solana settler pays: symbol, mint, decimals and token program. |
| `SettlerEscrow` | interface | A sale's escrow on the settler: chain, settler, intent hash, commitment and the Bitcoin script to pay. |
| `SettlerIntent` | interface | The V6 BitcoinIntentSettler Intent struct (20 fields, the EIP-712 primary type). |
| `settlerSellAsset` | export | The settler's payout coin for a chain and token, or null when the settler does not pay it. |
| `SettlerSellTemplate` | type | The sell intent the solver offers for a sale: chain, settler, filler, intent and script. |
| `SOL_SWAP_RESERVE_LAMPORTS` | value | SOL the wallet keeps from the settler's payout for the swap's own fees and accounts (the app's SOL_SWAP_RESERVE_LAMPORTS). |
| `solanaState` | function | Solana V2 offer phases, for the user. |
| `solverState` | function | Maps a solver status (EVM <-> BTC routes) to a SwapState. |
| `StatusTarget` | interface | What swap.getStatus reads: the route, the order id, the chain and, for coin to coin, the destination. |
| `stripWitness` | function | The transaction without its witness (sha256d of it is the txid the verifier checks). |
| `SWAP_ROUTES` | value | Every swap route name. |
| `SwapAsset` | interface | A coin on a chain: the chain, and the token address, mint, symbol or coin type. |
| `SwapChain` | type | 'bitcoin', 'solana', 'tron' and 'sui' name the non-EVM sides; EVM chains are numeric chain ids. |
| `SwapOrder` | interface | A placed swap order: its route, its id to track it with, its chain and the transactions sent for it. |
| `SwapPair` | interface | One way to swap, as `swap.pairs` lists it. |
| `SwapQuote` | interface | A quote from swap.quote: the route, both coins, the amount sent and the executable amount received, fees and expiry. |
| `SwapRequest` | interface | What `swap.quote` and `swap.execute` take. |
| `SwapResult` | interface | What swap.swap answers: the quote, the placed order and its last status. |
| `SwapRoute` | type | Supported swap routes. |
| `SwapState` | type | An order's state: pending, awaiting_deposit, in_progress, completed, refundable, refunded, cancelled, expired or failed. |
| `SwapStatus` | interface | An order's status from swap.getStatus: its state, the service's own status, whether it is complete, and its transactions. |
| `SwapUpdate` | type | What `swap.execute` reports as it goes, for a progress line or a stepper. |
| `TokenInfo` | interface | One token Maxy lists: chain, symbol, address and decimals. |
| `toQuoteRequest` | function | The precise QuoteRequest for a plain-words request (reads decimals only when the amount is in whole coins). |
| `verifyIntentHash` | function | Refuses unless the settler's own hashIntent equals the local EIP-712 hash (both must bind the same 20 fields). |
| `withFillCost` | function | The price a buy signs. |

## maxy-labs/evm

Buying BTC from an EVM wallet.

| Export | Kind | What it is |
| --- | --- | --- |
| `btcPayoutScript` | function | The receive script for a BTC payout. |
| `buildBuyIntent` | function | Builds the settler intent a buy signs: maker, asset, Bitcoin address, sats, prices, bond, confirmations and deadline. |
| `buyBtcWithEvm` | function | See core/flows.ts. |
| `BuyWithEvmParams` | interface | The input of buyWithEvm: the EVM wallet, the coin and amount to pay (or the BTC wanted) and the Bitcoin address. |
| `ensureEvmChain` | function | Puts the wallet on `chainId` (switching when it can) and returns the signing account. |
| `EVM_CHAINS` | value | Every EVM chain the SDK reads or sends on, by chain id, with its name, native coin and viem chain. |
| `evmSignerFromEip1193` | function | Wraps an EIP-1193 provider. |
| `evmSignerFromWalletClient` | function | Wraps a viem WalletClient (or anything shaped like one) as an EvmSigner. |
| `evmWallet` | function | The wallet a buy needs, from any of the three. |
| `EvmWalletInput` | type | A viem WalletClient, an EIP-1193 provider, or your own signer. |
| `findFreeNonce` | function | The lowest unused settler nonce for `maker`. |
| `FlowEvmWallet` | interface | What a buy needs from an EVM wallet. |
| `FlowProgress` | type | The state a flow helper reports to onProgress: the swap state machine's current state. |
| `FlowResult` | interface | How a flow helper ends: the order id, the order as GET /orders/{id} last read it, and the Bitcoin txid. |
| `intentDeposit` | function | The deposit the settler takes for a LIMIT intent at the top of its signed slippage band (PricingLib.buyDepositAmount). |
| `intentTypedData` | function | The EIP-712 typed data of a settler intent, for a wallet to sign. |
| `localIntentHash` | function | The EIP-712 hash of a settler intent, computed locally. |
| `SETTLER_ABI` | value | The settler contract's ABI, the functions and events the SDK uses. |
| `settlerAddress` | function | The V6 BitcoinIntentSettler on `chainId` (the contract the swap intent is signed for). |
| `SWAP_CHAIN_IDS` | value | The mainnet EVM chains with a live V6 BitcoinIntentSettler (EVM <-> BTC swaps). |
| `verifyIntentHash` | function | Refuses unless the settler's own hashIntent equals the local EIP-712 hash (both must bind the same 20 fields). |

## maxy-labs/solana

Buying BTC from a Solana wallet adapter.

| Export | Kind | What it is |
| --- | --- | --- |
| `buyBtcWithSolana` | function | Buy BTC from Solana. |
| `BuyWithSolanaParams` | interface | The input of buyWithSolana: the Solana wallet, the coin and amount to pay, and the Bitcoin address that receives the BTC. |
| `FlowProgress` | type | The state a flow helper reports to onProgress: the swap state machine's current state. |
| `FlowResult` | interface | How a flow helper ends: the order id, the order as GET /orders/{id} last read it, and the Bitcoin txid. |
| `FlowSolanaWallet` | interface | What a buy needs from a Solana wallet adapter. |
| `SOLANA_PROGRAMS` | value | Maxy's Solana V2 settler on mainnet, as its gateway's /config names it (btc_intents 97CyZ9qd…, btc_spv AVna5sHd…). |

## maxy-labs/bitcoin

Selling BTC, and Bitcoin address checks.

| Export | Kind | What it is |
| --- | --- | --- |
| `AddressCheck` | interface | What GET /addresses/validate answers: whether the address is valid for the chain, its type and network, and whether an order would pay it. |
| `addressToScriptPubKey` | function | The output script of a Bitcoin address. |
| `addressUtxos` | function | A Bitcoin address's unspent outputs, read from Esplora. |
| `bip21Uri` | function | A bitcoin. |
| `BorrowerBtcIdentity` | interface | A borrower's Bitcoin identity: network, address, type, public key, key hash and script. |
| `borrowerIdentityFromWallet` | function | Builds a borrower's Bitcoin identity from a wallet's address and public key. |
| `BroadcastOutcome` | type | How a Bitcoin broadcast went: sent with the nodes that accepted it, or ambiguous with the reason. |
| `broadcastTx` | function | Broadcasts a raw transaction to every Esplora host. |
| `BTC_NETWORKS` | value | The Bitcoin networks' parameters: address prefixes, key versions and BIP-32 versions. |
| `BtcAddressError` | class | Thrown for a Bitcoin address that is not valid or not on the expected network. |
| `btcDepositAllowlist` | function | The Bitcoin deposit addresses the SDK accepts for a sale besides an attested escrow script. |
| `BtcNetworkName` | type | A Bitcoin network name: mainnet, signet or regtest. |
| `BtcNetworkParams` | interface | One Bitcoin network's parameters: bech32 prefix, address versions, key format and BIP-32 versions. |
| `BtcScriptError` | class | Thrown for a Bitcoin script that does not match what a MaxyLock loan expects, with the field at fault. |
| `btcToSats` | function | "0.015" -> 1_500_000n. |
| `BtcTxError` | class | Thrown when a Bitcoin transaction cannot be built or finalized, with a code saying why. |
| `buildCollateralWitnessScript` | function | Builds the witness script that locks a loan's BTC collateral. |
| `buildFundingPsbt` | function | Builds the PSBT that funds a loan's Bitcoin outputs from a wallet's coins at a fee rate. |
| `buildInterestWitnessScript` | function | Builds the witness script that locks a loan's interest output. |
| `buildPayment` | function | Builds (does not sign) a payment from the signer's wallet with `outputs` first, in order, and change last. |
| `buildPaymentPsbt` | function | A plain payment from the connected wallet with the outputs in exactly the given order and change (if any) last, for a receiver that reads the deposit as output 0 (a wallet's own send may put change first). |
| `BuiltPayment` | interface | A Bitcoin payment ready to sign: the payer's identity and the funding plan. |
| `checkBtcDepositAddress` | function | Decides whether a server-supplied BTC deposit address may be paid. |
| `DecodedHtlc` | type | A MaxyLock Bitcoin script decoded: collateral or interest, with its hashlock, keys and timelock. |
| `decodeHtlcScript` | function | Decodes a MaxyLock witness script into its hashlock, keys and timelock. |
| `DepositVerdict` | type | Whether a sale's deposit address is accepted, and why. |
| `DUST_SATS` | value | The smallest Bitcoin output a node relays: 546 sats. |
| `encodeSegwitAddress` | function | Encodes a SegWit address from its witness version and program. |
| `esploraBasesFor` | function | The Esplora API bases the SDK reads for a Bitcoin network. |
| `EsploraError` | class | Thrown when every Esplora base failed for a read, with each attempt. |
| `esploraFetchJson` | function | Reads JSON from Esplora, trying each base in turn. |
| `EsploraFetchOptions` | interface | Options of the Esplora reads: abort signal, timeout, bases, network and fetch. |
| `esploraOptions` | function | The Esplora options for a client: the bases through Maxy's host and its fetch. |
| `EsploraTx` | interface | A Bitcoin transaction as Esplora answers it: id, inputs, outputs and status. |
| `EsploraTxStatus` | interface | A Bitcoin transaction's confirmation status: confirmed or not, and its block. |
| `EsploraUtxo` | interface | One unspent output of an address: txid, output, value and confirmation. |
| `FeeTarget` | type | How fast a Bitcoin payment should confirm: fast, medium or slow. |
| `fetchConfirmedUtxos` | function | The wallet's confirmed UTXOs with their previous transactions (needed to sign legacy-safe SegWit inputs). |
| `fetchFeeRate` | function | Sat/vB from Esplora fee-estimates (fast = next block). |
| `finalizeFundingPsbt` | function | Finalizes a signed funding PSBT into the raw transaction, its txid, size and fee. |
| `fromSmallest` | function | The smallest unit as whole coins, without trailing zeros. |
| `FundingOutputSpec` | interface | One output of a loan's funding transaction: its tranche, script hash and sats. |
| `FundingPlan` | interface | A loan's funding transaction before signing: the PSBT, the expected txid, inputs, outputs and fee. |
| `generateSecret` | function | A random 32-byte secret for a loan's hashlock. |
| `getOutspend` | function | Whether an output is spent, and by which transaction, read from Esplora. |
| `getTipHeight` | function | The current Bitcoin block height, read from Esplora. |
| `getTx` | function | A Bitcoin transaction read from Esplora. |
| `getTxHex` | function | A Bitcoin transaction's raw hex, read from Esplora. |
| `getTxStatus` | function | A Bitcoin transaction's confirmation status, read from Esplora. |
| `hashlockOf` | function | The SHA-256 hashlock of a loan secret. |
| `INTEREST_RECOVERY_DELAY_SEC` | value | How long after a loan's end the borrower may take back an unclaimed interest output: 7 days. |
| `INTEREST_SWEEP_DELAY_SEC` | value | How long after the interest output confirms the lender may sweep it: 10 minutes. |
| `isBtcNetworkName` | function | Whether a value is a Bitcoin network name. |
| `isStandardScriptPubKey` | function | Whether an output script is a standard type, and which. |
| `MIN_WALLET_UTXO_SATS` | value | The smallest wallet coin used to fund a payment: 1,000 sats. |
| `miniscriptDescriptor` | function | The miniscript descriptor of a decoded MaxyLock script, for a wallet that reads descriptors. |
| `p2wshAddress` | function | The P2WSH address of a script hash on a network. |
| `p2wshScriptPubKey` | function | The P2WSH output script of a script hash. |
| `payerIdentity` | function | The signer's account as a MaxyLock payer identity (P2WPKH or P2SH-P2WPKH only). |
| `PaymentInstructions` | interface | Where and how much BTC to send for a sale: the address, the exact sats, the deadline and the bitcoin: URI. |
| `PaymentOutput` | interface | One output of a Bitcoin payment: an address or a raw script, and the sats. |
| `payToAddress` | function | Pays exactly `sats` to `address` as output 0 (change last) and broadcasts it. |
| `pkhFromPubkey` | function | The HASH160 of a public key. |
| `SATS_PER_BTC` | value | Sats in one BTC: 100,000,000. |
| `satsToBtc` | function | 1_500_000n -> "0.015". |
| `scriptHashToP2wshAddress` | function | The P2WSH address of a script hash. |
| `scriptHashToP2wshScriptPubKey` | function | The P2WSH output script of a script hash. |
| `scriptPubKeyToAddress` | function | The Bitcoin address of an output script. |
| `secretMatchesHashlock` | function | Whether a secret hashes to a hashlock. |
| `sellBtc` | function | Sell BTC to a chain. |
| `SellHandle` | interface | What sellBtc answers before the BTC is sent: the order id, the payment instructions, and a promise of the end. |
| `SellParams` | interface | The input of sellBtc: the wallet that receives and signs, the coin wanted and the BTC to sell. |
| `SentPayment` | interface | A Bitcoin payment sent: its txid, raw transaction, fee and how the broadcast went. |
| `SIGHASH_ALL` | value | The SIGHASH_ALL flag (0x01). |
| `SIGHASH_SINGLE_ANYONECANPAY` | value | The SIGHASH_SINGLE \| ANYONECANPAY flag (0x83), used for the bundled collateral returns. |
| `signAndBroadcast` | function | Signs a built payment with the wallet, checks the signed tx is unchanged, and broadcasts it. |
| `StandardScriptType` | type | A standard Bitcoin output type: p2wpkh, p2wsh, p2tr, p2pkh or p2sh. |
| `TEMPLATE_VERSION` | value | The version of the MaxyLock Bitcoin script template the SDK builds and checks. |
| `toSmallest` | function | Whole coins as a decimal string to the smallest unit. |
| `units` | value | Amount helpers: whole coins to the smallest unit and back, and BTC to sats and back, as decimal strings. |
| `validateAddress` | function | The check for one address on one chain (a chain from parseChain). |
| `verifyFundingPsbt` | function | Checks that a signed funding PSBT is the plan it came from; throws otherwise. |
| `WalletUtxo` | interface | One coin of the borrower's wallet: txid, output, value, confirmation and its previous transaction. |
| `witnessScriptHash` | function | The SHA-256 of a witness script, as a P2WSH output commits to it. |

## maxy-labs/server

Backend helpers: webhooks, checkout links, statements.

| Export | Kind | What it is |
| --- | --- | --- |
| `CHECKOUT_URL` | value | Maxy's hosted checkout. |
| `CheckoutParams` | interface | The input of checkoutUrl: your publishable key, the starting amount and coin, and the destination. |
| `constructEvent` | function | The same check as verifyWebhook, from a framework's request. |
| `downloadStatement` | function | A month's statement. |
| `exportOrders` | function | A month of a key's orders as CSV, the ledger a finance team reconciles. |
| `handleOnce` | function | Your own idempotent handler around an event. |
| `MaxyWebhookEvent` | type | A webhook event: its id, type, time, a sandbox mark and the order data. |
| `revokeKey` | function | Revokes one of your keys by its prefix; calls with it are refused from then on. |
| `rotateKey` | function | Rotates a secret key. |
| `signCheckoutUrl` | function | A hosted checkout URL, signed on your server with your secret key. |
| `signWebhook` | export | Signs a webhook body as Maxy does, for testing your receiver. |
| `statements` | value | Monthly statements from your server: download a month in JSON, CSV or PDF. |
| `verifyWebhook` | export | Checks a webhook delivery's signature and age and returns its event; throws on a bad one. |

## maxy-labs/testing

A mock API, fixtures and a state simulator.

| Export | Kind | What it is |
| --- | --- | --- |
| `CatalogueRow` | type | One error code in the catalogue: the code, its HTTP status and what it means. |
| `createMockFetch` | function | A fetch that answers as the API does, for `createMaxyRest({ fetch })`. |
| `ERROR_CATALOGUE` | export | Every error code the API sends, with its HTTP status and meaning. |
| `ERROR_FIXTURES` | value | Every code the API can answer, with its fixture. |
| `errorFixture` | function | The envelope the API answers `code` with. |
| `MaxyErrorCode` | type | Every error code the SDK and the API use, as a union of strings. |
| `MockApiOptions` | interface | Options of the mock API: a simulator for order walks and your own answers tried first. |
| `mswHandlers` | function | Handlers for Mock Service Worker, if your tests use it. |
| `SandboxSimulator` | class | Orders that move when you say, in memory. |
| `SimulatedOrder` | interface | An order in the simulator: its id, route and the states it walks, one per read. |

## maxy-labs/orders

One list of a wallet's swaps and loans.

| Export | Kind | What it is |
| --- | --- | --- |
| `createOrders` | function | Builds the order history module: one list of a wallet's swaps and loans from every source. |
| `intentRowToOrder` | function | A cross_chain_intents row (submit-intent's order record) as a MaxyOrder. |
| `ledgerRowToOrder` | function | A row of the app's `orders` ledger as a MaxyOrder. |
| `ListOrdersInput` | interface | The input of orders.list: the wallet, which sources to read, and paging. |
| `ListOrdersResult` | interface | What orders.list answers: the orders, newest first, and the sources that could not be read. |
| `MaxyOrder` | interface | One order in a wallet's history, swap or loan, in a single shape: id, route, state, amounts, transactions and times. |
| `MaxyOrders` | type | The order history module that createOrders returns. |
| `OrderAmount` | interface | An amount in an order: the asset, the integer amount in its smallest unit, and the chain. |
| `OrderChain` | type | Where an order's amount or transaction is: an EVM chain id, 'bitcoin' or 'solana'. |
| `OrderKind` | type | What an order is: a swap or a loan. |
| `OrderSources` | interface | Extra sources for orders.list, such as the signed-in wallet's loans. |
| `OrderState` | type | Normalized lifecycle state. |
| `OrderTx` | interface | One transaction of an order: what it did, its chain and its hash. |
| `swapOrderToOrder` | function | A SwapOrder this SDK created, with its live status, as a MaxyOrder. |

## maxy-labs/btc

Bitcoin transactions, PSBTs and proofs.

| Export | Kind | What it is |
| --- | --- | --- |
| `addressToScriptPubKey` | function | The output script of a Bitcoin address. |
| `addressUtxos` | function | A Bitcoin address's unspent outputs, read from Esplora. |
| `BorrowerBtcIdentity` | interface | A borrower's Bitcoin identity: network, address, type, public key, key hash and script. |
| `borrowerIdentityFromWallet` | function | Builds a borrower's Bitcoin identity from a wallet's address and public key. |
| `BroadcastOutcome` | type | How a Bitcoin broadcast went: sent with the nodes that accepted it, or ambiguous with the reason. |
| `broadcastTx` | function | Broadcasts a raw transaction to every Esplora host. |
| `BTC_NETWORKS` | value | The Bitcoin networks' parameters: address prefixes, key versions and BIP-32 versions. |
| `BtcAddressError` | class | Thrown for a Bitcoin address that is not valid or not on the expected network. |
| `btcDepositAllowlist` | function | The Bitcoin deposit addresses the SDK accepts for a sale besides an attested escrow script. |
| `BtcNetworkName` | type | A Bitcoin network name: mainnet, signet or regtest. |
| `BtcNetworkParams` | interface | One Bitcoin network's parameters: bech32 prefix, address versions, key format and BIP-32 versions. |
| `BtcScriptError` | class | Thrown for a Bitcoin script that does not match what a MaxyLock loan expects, with the field at fault. |
| `btcToSats` | function | "0.015" -> 1_500_000n. |
| `BtcTxError` | class | Thrown when a Bitcoin transaction cannot be built or finalized, with a code saying why. |
| `buildCollateralWitnessScript` | function | Builds the witness script that locks a loan's BTC collateral. |
| `buildFundingPsbt` | function | Builds the PSBT that funds a loan's Bitcoin outputs from a wallet's coins at a fee rate. |
| `buildInterestWitnessScript` | function | Builds the witness script that locks a loan's interest output. |
| `buildPayment` | function | Builds (does not sign) a payment from the signer's wallet with `outputs` first, in order, and change last. |
| `buildPaymentPsbt` | function | A plain payment from the connected wallet with the outputs in exactly the given order and change (if any) last, for a receiver that reads the deposit as output 0 (a wallet's own send may put change first). |
| `BuiltPayment` | interface | A Bitcoin payment ready to sign: the payer's identity and the funding plan. |
| `checkBtcDepositAddress` | function | Decides whether a server-supplied BTC deposit address may be paid. |
| `DecodedHtlc` | type | A MaxyLock Bitcoin script decoded: collateral or interest, with its hashlock, keys and timelock. |
| `decodeHtlcScript` | function | Decodes a MaxyLock witness script into its hashlock, keys and timelock. |
| `DepositVerdict` | type | Whether a sale's deposit address is accepted, and why. |
| `DUST_SATS` | value | The smallest Bitcoin output a node relays: 546 sats. |
| `encodeSegwitAddress` | function | Encodes a SegWit address from its witness version and program. |
| `esploraBasesFor` | function | The Esplora API bases the SDK reads for a Bitcoin network. |
| `EsploraError` | class | Thrown when every Esplora base failed for a read, with each attempt. |
| `esploraFetchJson` | function | Reads JSON from Esplora, trying each base in turn. |
| `EsploraFetchOptions` | interface | Options of the Esplora reads: abort signal, timeout, bases, network and fetch. |
| `esploraOptions` | function | The Esplora options for a client: the bases through Maxy's host and its fetch. |
| `EsploraTx` | interface | A Bitcoin transaction as Esplora answers it: id, inputs, outputs and status. |
| `EsploraTxStatus` | interface | A Bitcoin transaction's confirmation status: confirmed or not, and its block. |
| `EsploraUtxo` | interface | One unspent output of an address: txid, output, value and confirmation. |
| `FeeTarget` | type | How fast a Bitcoin payment should confirm: fast, medium or slow. |
| `fetchConfirmedUtxos` | function | The wallet's confirmed UTXOs with their previous transactions (needed to sign legacy-safe SegWit inputs). |
| `fetchFeeRate` | function | Sat/vB from Esplora fee-estimates (fast = next block). |
| `finalizeFundingPsbt` | function | Finalizes a signed funding PSBT into the raw transaction, its txid, size and fee. |
| `FundingOutputSpec` | interface | One output of a loan's funding transaction: its tranche, script hash and sats. |
| `FundingPlan` | interface | A loan's funding transaction before signing: the PSBT, the expected txid, inputs, outputs and fee. |
| `generateSecret` | function | A random 32-byte secret for a loan's hashlock. |
| `getOutspend` | function | Whether an output is spent, and by which transaction, read from Esplora. |
| `getTipHeight` | function | The current Bitcoin block height, read from Esplora. |
| `getTx` | function | A Bitcoin transaction read from Esplora. |
| `getTxHex` | function | A Bitcoin transaction's raw hex, read from Esplora. |
| `getTxStatus` | function | A Bitcoin transaction's confirmation status, read from Esplora. |
| `hashlockOf` | function | The SHA-256 hashlock of a loan secret. |
| `INTEREST_RECOVERY_DELAY_SEC` | value | How long after a loan's end the borrower may take back an unclaimed interest output: 7 days. |
| `INTEREST_SWEEP_DELAY_SEC` | value | How long after the interest output confirms the lender may sweep it: 10 minutes. |
| `isBtcNetworkName` | function | Whether a value is a Bitcoin network name. |
| `isStandardScriptPubKey` | function | Whether an output script is a standard type, and which. |
| `MIN_WALLET_UTXO_SATS` | value | The smallest wallet coin used to fund a payment: 1,000 sats. |
| `miniscriptDescriptor` | function | The miniscript descriptor of a decoded MaxyLock script, for a wallet that reads descriptors. |
| `p2wshAddress` | function | The P2WSH address of a script hash on a network. |
| `p2wshScriptPubKey` | function | The P2WSH output script of a script hash. |
| `payerIdentity` | function | The signer's account as a MaxyLock payer identity (P2WPKH or P2SH-P2WPKH only). |
| `PaymentOutput` | interface | One output of a Bitcoin payment: an address or a raw script, and the sats. |
| `payToAddress` | function | Pays exactly `sats` to `address` as output 0 (change last) and broadcasts it. |
| `pkhFromPubkey` | function | The HASH160 of a public key. |
| `SATS_PER_BTC` | value | Sats in one BTC: 100,000,000. |
| `satsToBtc` | function | 1_500_000n -> "0.015". |
| `scriptHashToP2wshAddress` | function | The P2WSH address of a script hash. |
| `scriptHashToP2wshScriptPubKey` | function | The P2WSH output script of a script hash. |
| `scriptPubKeyToAddress` | function | The Bitcoin address of an output script. |
| `secretMatchesHashlock` | function | Whether a secret hashes to a hashlock. |
| `SentPayment` | interface | A Bitcoin payment sent: its txid, raw transaction, fee and how the broadcast went. |
| `SIGHASH_ALL` | value | The SIGHASH_ALL flag (0x01). |
| `SIGHASH_SINGLE_ANYONECANPAY` | value | The SIGHASH_SINGLE \| ANYONECANPAY flag (0x83), used for the bundled collateral returns. |
| `signAndBroadcast` | function | Signs a built payment with the wallet, checks the signed tx is unchanged, and broadcasts it. |
| `StandardScriptType` | type | A standard Bitcoin output type: p2wpkh, p2wsh, p2tr, p2pkh or p2sh. |
| `TEMPLATE_VERSION` | value | The version of the MaxyLock Bitcoin script template the SDK builds and checks. |
| `verifyFundingPsbt` | function | Checks that a signed funding PSBT is the plan it came from; throws otherwise. |
| `WalletUtxo` | interface | One coin of the borrower's wallet: txid, output, value, confirmation and its previous transaction. |
| `witnessScriptHash` | function | The SHA-256 of a witness script, as a P2WSH output commits to it. |

## maxy-labs/borrow

Deprecated: MaxyLock through the swap SDK, working until 2.0. Use `@maxy-labs/loans`.

| Export | Kind | What it is |
| --- | --- | --- |
| `BORROW_MARKETS` | export | Every MaxyLock market the SDK lends in. |
| `BorrowerBtcIdentity` | type | A borrower's Bitcoin identity: network, address, type, public key, key hash and script. |
| `BorrowerLoan` | interface | One of the borrower's loans: its market, its request, the loan on chain and the same as a MaxyOrder. |
| `BorrowMarket` | type | A MaxyLock market name: base-mainnet, robinhood-mainnet, or the deprecated mainnet. |
| `BorrowMarketInfo` | type | One MaxyLock market: chain, lent asset, its decimals and contracts, and whether it takes loans. |
| `BorrowQuote` | interface | A loan quote with the market it is for. |
| `BroadcastOutcome` | type | How a Bitcoin broadcast went: sent with the nodes that accepted it, or ambiguous with the reason. |
| `BtcSpendResult` | interface | One Bitcoin spend of a loan's tranche: its index, txid and how the broadcast went. |
| `BtcWalletIdentity` | interface | The Bitcoin wallet a borrower locks collateral from: network, address and public key. |
| `canonicalMarket` | export | The canonical name of a market ('mainnet' becomes 'base-mainnet'); undefined is the default. |
| `createBorrow` | function | Builds the MaxyLock loans module on a context: markets, vaults, quotes, requests, funding, repayment and claims. |
| `DEFAULT_BORROW_MARKET` | export | The market used when none is named: base-mainnet (USDC on Base). |
| `deploymentFor` | export | The MaxyLock deployment behind a market. |
| `fromCodecError` | function | Turns a MaxyLockApiError (thrown by the shared codec) into a MaxyError. |
| `FundingPlan` | type | A loan's funding transaction before signing: the PSBT, the expected txid, inputs, outputs and fee. |
| `FundingPreparation` | interface | Returned only by prepareFunding. |
| `FundingResult` | interface | A loan's collateral funding sent: the market, loan, request, txid, raw transaction and fee. |
| `FundingTarget` | type | What borrow.fund takes: the market, the Bitcoin signer, the fee rate and the coins to spend. |
| `isBorrowMarket` | export | Whether a value is a MaxyLock market name. |
| `KeeperHeartbeat` | type | The loan keeper's last run: when it finished, the block it reached and whether it was healthy. |
| `Loan` | type | A loan as the MaxyLock contract's getLoan answers it. |
| `LoanMirrorRow` | type | A loan as Maxy's index mirrors it from the chain: id, vault, request, borrower, state and phase. |
| `loanOrderState` | export | The order state of a loan, from its request and its phase on chain. |
| `LoanRequestRow` | type | A loan request as Maxy holds it: id, vault, status, reason, error and the loan once committed. |
| `LoanStatus` | type | A loan's display status: a key, a label, a tone and any missed or overdue tranches. |
| `LoanView` | interface | A loan as the borrower sees it: the loan on chain, its display status and what can be done next. |
| `marketInfo` | export | A market's details: chain, lent asset, contracts and readiness. |
| `MarketParam` | interface | The market a borrow call runs in; default base-mainnet. |
| `MaxyBorrow` | type | The MaxyLock loans module that createBorrow returns. |
| `MAXYLOCK_CODE_MAP` | value | MaxyLock server / codec code -> SDK code. |
| `MaxyLockQuote` | type | A loan quote: vault, principal, collateral, tranches, rates and the signed payload. |
| `MaxyLockVault` | type | A lending vault: id, name, status, loan contract and lent asset. |
| `MaxyLockVaultStats` | type | A vault's figures: available to lend, lent out, exposure and active loans. |
| `PreimageSource` | type | Where a loan's secret came from: revealed on chain, disclosed for an unfunded loan, or a missed reveal. |
| `QuoteParams` | type | The input of borrow.quote: the vault and either the amount to borrow or the BTC to lock. |
| `RepayResult` | interface | A repayment sent: the approval, each tranche's repayment transaction and the total. |
| `RequestStatus` | type | A loan request's status, from requested to committed, cancelled or failed. |
| `ReturnAuthorization` | type | The borrower's signed returns of the collateral: one bundled PSBT or one per tranche. |
| `SendOptions` | type | Options of a loan transaction: whether to wait for the receipt, and how long and how often. |
| `sessionWalletOfToken` | function | The wallet a Maxy session token belongs to (email `<wallet>@wallet.local` confirmed by app_metadata), or null if unreadable. |
| `SignedTerms` | interface | Loan terms signed by the borrower: the request, the signature and the request's status after it. |
| `TermsPlanV1` | type | The plan a loan request's terms are built from: deployment, vault, anchor time and timings. |
| `toMaxyOrder` | export | A loan request as a MaxyOrder, for one list with swaps. |
| `ToMaxyOrderOptions` | type | Options of toMaxyOrder: the market the row came from and the loan's mirror row. |
| `TrancheMirrorRow` | type | One Bitcoin tranche of a loan as indexed: kind, state, script hash, sats and timelock. |
| `VaultCapacity` | interface | A vault and whether it lends now: its figures and the keeper's health. |
| `VerifiedCommittedLoan` | type | A committed loan checked against the borrower's identity: its funding outputs and tranches. |
| `VerifiedLoanRequest` | interface | Returned only by createRequest after verifyPlanForBorrower passed. |
| `VerifiedPlan` | type | A loan plan checked locally: the plan, the borrower's identity, the terms and their hash. |
| `VerifyPlanCode` | type | Why a loan plan failed its local check, as a code. |
| `WalletUtxo` | type | One coin of the borrower's wallet: txid, output, value, confirmation and its previous transaction. |

## @maxy-labs/loans

MaxyLock: borrowing USDC or USDG against BTC. `createMaxyLoans()` gives `borrow` and `auth`.

| Export | Kind | What it is |
| --- | --- | --- |
| `BitcoinSigner` | interface | What the SDK needs from a Bitcoin wallet: its network, its payment account and public key, and PSBT signing. |
| `bitcoinSignerFromKey` | function | A mainnet BitcoinSigner over a key (WIF or hex) whose payment account is its native SegWit (bc1q…) address. |
| `BORROW_MARKETS` | export | Every MaxyLock market the SDK lends in. |
| `BorrowerBtcIdentity` | type | A borrower's Bitcoin identity: network, address, type, public key, key hash and script. |
| `BorrowerLoan` | interface | One of the borrower's loans: its market, its request, the loan on chain and the same as a MaxyOrder. |
| `BorrowMarket` | type | A MaxyLock market name: base-mainnet, robinhood-mainnet, or the deprecated mainnet. |
| `BorrowMarketInfo` | type | One MaxyLock market: chain, lent asset, its decimals and contracts, and whether it takes loans. |
| `BorrowQuote` | interface | A loan quote with the market it is for. |
| `BroadcastOutcome` | type | How a Bitcoin broadcast went: sent with the nodes that accepted it, or ambiguous with the reason. |
| `BtcSpendResult` | interface | One Bitcoin spend of a loan's tranche: its index, txid and how the broadcast went. |
| `BtcWalletIdentity` | interface | The Bitcoin wallet a borrower locks collateral from: network, address and public key. |
| `canonicalMarket` | export | The canonical name of a market ('mainnet' becomes 'base-mainnet'); undefined is the default. |
| `createBorrow` | function | Builds the MaxyLock loans module on a context: markets, vaults, quotes, requests, funding, repayment and claims. |
| `createMaxyLoans` | function | A loans client. |
| `DEFAULT_BORROW_MARKET` | export | The market used when none is named: base-mainnet (USDC on Base). |
| `deploymentFor` | export | The MaxyLock deployment behind a market. |
| `EvmSigner` | interface | What the SDK needs from an EVM wallet: its address and chain, switching chains, signing typed data and sending transactions. |
| `evmSignerFromEip1193` | function | Wraps an EIP-1193 provider. |
| `evmSignerFromPrivateKey` | function | An EvmSigner over a private key (0x + 64 hex). |
| `evmSignerFromWalletClient` | function | Wraps a viem WalletClient (or anything shaped like one) as an EvmSigner. |
| `fromCodecError` | function | Turns a MaxyLockApiError (thrown by the shared codec) into a MaxyError. |
| `FundingPlan` | type | A loan's funding transaction before signing: the PSBT, the expected txid, inputs, outputs and fee. |
| `FundingPreparation` | interface | Returned only by prepareFunding. |
| `FundingResult` | interface | A loan's collateral funding sent: the market, loan, request, txid, raw transaction and fee. |
| `FundingTarget` | type | What borrow.fund takes: the market, the Bitcoin signer, the fee rate and the coins to spend. |
| `isBorrowMarket` | export | Whether a value is a MaxyLock market name. |
| `isMaxyError` | function | Whether a value is a MaxyError, optionally with a given code. |
| `KeeperHeartbeat` | type | The loan keeper's last run: when it finished, the block it reached and whether it was healthy. |
| `Loan` | type | A loan as the MaxyLock contract's getLoan answers it. |
| `LoanMirrorRow` | type | A loan as Maxy's index mirrors it from the chain: id, vault, request, borrower, state and phase. |
| `loanOrderState` | export | The order state of a loan, from its request and its phase on chain. |
| `LoanRequestRow` | type | A loan request as Maxy holds it: id, vault, status, reason, error and the loan once committed. |
| `LoanStatus` | type | A loan's display status: a key, a label, a tone and any missed or overdue tranches. |
| `LoanView` | interface | A loan as the borrower sees it: the loan on chain, its display status and what can be done next. |
| `marketInfo` | export | A market's details: chain, lent asset, contracts and readiness. |
| `MarketParam` | interface | The market a borrow call runs in; default base-mainnet. |
| `MaxyBorrow` | type | The MaxyLock loans module that createBorrow returns. |
| `MaxyClientConfig` | interface | The options of createMaxyClient: API key, API URL, RPC URLs, your own hosts, fetch and the session source. |
| `MaxyError` | class | The error every SDK call throws: a stable code, the HTTP status, whether a retry can help, and the request id. |
| `MaxyLoans` | type | The client createMaxyLoans returns: borrow and auth. |
| `MAXYLOCK_CODE_MAP` | value | MaxyLock server / codec code -> SDK code. |
| `MaxyLockQuote` | type | A loan quote: vault, principal, collateral, tranches, rates and the signed payload. |
| `MaxyLockVault` | type | A lending vault: id, name, status, loan contract and lent asset. |
| `MaxyLockVaultStats` | type | A vault's figures: available to lend, lent out, exposure and active loans. |
| `PreimageSource` | type | Where a loan's secret came from: revealed on chain, disclosed for an unfunded loan, or a missed reveal. |
| `QuoteParams` | type | The input of borrow.quote: the vault and either the amount to borrow or the BTC to lock. |
| `RepayResult` | interface | A repayment sent: the approval, each tranche's repayment transaction and the total. |
| `RequestStatus` | type | A loan request's status, from requested to committed, cancelled or failed. |
| `ReturnAuthorization` | type | The borrower's signed returns of the collateral: one bundled PSBT or one per tranche. |
| `SendOptions` | type | Options of a loan transaction: whether to wait for the receipt, and how long and how often. |
| `sessionWalletOfToken` | function | The wallet a Maxy session token belongs to (email `<wallet>@wallet.local` confirmed by app_metadata), or null if unreadable. |
| `SignedTerms` | interface | Loan terms signed by the borrower: the request, the signature and the request's status after it. |
| `TermsPlanV1` | type | The plan a loan request's terms are built from: deployment, vault, anchor time and timings. |
| `toMaxyOrder` | export | A loan request as a MaxyOrder, for one list with swaps. |
| `ToMaxyOrderOptions` | type | Options of toMaxyOrder: the market the row came from and the loan's mirror row. |
| `TrancheMirrorRow` | type | One Bitcoin tranche of a loan as indexed: kind, state, script hash, sats and timelock. |
| `VaultCapacity` | interface | A vault and whether it lends now: its figures and the keeper's health. |
| `VerifiedCommittedLoan` | type | A committed loan checked against the borrower's identity: its funding outputs and tranches. |
| `VerifiedLoanRequest` | interface | Returned only by createRequest after verifyPlanForBorrower passed. |
| `VerifiedPlan` | type | A loan plan checked locally: the plan, the borrower's identity, the terms and their hash. |
| `VerifyPlanCode` | type | Why a loan plan failed its local check, as a code. |
| `WalletUtxo` | type | One coin of the borrower's wallet: txid, output, value, confirmation and its previous transaction. |

## Python

`pip install maxy-labs`, then `from maxy import Maxy, AsyncMaxy`. Every method answers the API's JSON as a dict; `AsyncMaxy` has the same methods, awaited.

| Method | Parameters |
| --- | --- |
| `maxy.sse_parser.line()` | line |
| `maxy.sandbox` | none: a property, not a method |
| `maxy.issue_test_keys()` | *, name=None, origins=None |
| `maxy.close()` | none |
| `amaxy.sandbox` | none: a property, not a method |
| `amaxy.issue_test_keys()` | *, name=None, origins=None |
| `amaxy.aclose()` | none |
| `maxy.prices.get()` | from_, to, amount=None, **rest: Any |
| `maxy.prices.stream()` | from_, to, amount=None, *, interval_seconds=None, **rest: Any |
| `maxy.chains.list()` | none |
| `maxy.pairs.list()` | none |
| `maxy.pairs.get()` | from_, to |
| `maxy.pairs.search_tokens()` | chain, search, *, limit=None |
| `maxy.quotes.get()` | from_, to, amount=None, *, from_address=None, to_address=None, **rest: Any |
| `maxy.quotes.batch()` | requests |
| `maxy.quotes.seconds_until_expiry()` | quote |
| `maxy.orders.create()` | order, *, signatures=None, signature=None, external_id=None, external_customer_id=None, scenario=None, partner_fee_bps=None, partner_fee_recipient=None, partner_fee_token=None, idempotency_key=None |
| `maxy.orders.submit_signature()` | order_id, order, *, signature=None, signatures=None |
| `maxy.orders.submit()` | order, signatures, tx_hash=None, *, bridge_tx_hash=None |
| `maxy.orders.get()` | order_id, *, chain_id=None, route=None |
| `maxy.orders.list()` | *, limit=None, cursor=None, from_=None, to=None, state=None, wallet=None, external_id=None, external_customer_id=None |
| `maxy.orders.export_csv()` | *, from_=None, to=None, limit=None |
| `maxy.orders.cancel()` | order_id, *, chain_id, from_=None |
| `maxy.orders.events()` | order_id |
| `maxy.orders.refund()` | order_id, *, chain_id, from_=None |
| `maxy.orders.deposit()` | order_id, *, chain_id |
| `maxy.orders.claim()` | order_id, *, chain_id, txid=None |
| `maxy.orders.bridge()` | order_id, *, path=None, **query: Any |
| `maxy.orders.steps()` | order_id, body=None, *, route=None |
| `maxy.orders.stream()` | order_id, *, chain_id=None, route=None |
| `maxy.orders.follow()` | order_id, *, route=None, chain_id=None, external_id=None, external_customer_id=None |
| `maxy.orders.iterate()` | **params: Any |
| `maxy.orders.watch()` | order_id, *, chain_id=None, route=None, max_seconds=1800.0, sleep=time.sleep |
| `maxy.orders.resume()` | order_id, **options: Any |
| `amaxy.orders.iterate()` | **params: Any |
| `amaxy.orders.watch()` | order_id, *, chain_id=None, route=None, max_seconds=1800.0 |
| `amaxy.orders.resume()` | order_id, **options: Any |
| `maxy.status.by_tx_hash()` | tx_hash |
| `maxy.status.by_intent_hash()` | order_id, *, chain_id=None, route=None |
| `maxy.status.by_bitcoin_txid()` | txid |
| `maxy.addresses.validate()` | chain, address |
| `maxy.limits.get()` | none (`GET /limits`) |
| `maxy.health.get()` | none (`GET /health`) |
| `maxy.key.get()` | none (`GET /key`) |
| `maxy.config.get()` | none (`GET /config`) |
| `maxy.ping.get()` | none (`GET /ping`) |
| `maxy.openapi.get()` | none (`GET /openapi.json`) |
| `maxy.webhooks.create()` | url |
| `maxy.webhooks.list()` | none |
| `maxy.webhooks.remove()` | webhook_id |
| `maxy.webhooks.test()` | webhook_id |
| `maxy.webhooks.events()` | webhook_id, *, signed=False |
| `maxy.webhooks.replay()` | webhook_id, event_id |
| `maxy.webhooks.verify()` | raw_body, signature_header, secret, *, tolerance_seconds=TOLERANCE_SECONDS, now=None |
| `maxy.sandbox_controls.advance()` | order_id, *, to=None |
| `maxy.sandbox_controls.scenarios()` | none |
| `maxy.sandbox_controls.rates()` | none |
| `maxy.account.get()` | none |
| `maxy.account.usage()` | *, days=None |
| `maxy.keys.create()` | *, kind="publishable", origins=None, note=None |
| `maxy.keys.rotate()` | none |
| `maxy.keys.revoke()` | prefix, *, confirm_self=False |
| `maxy.keys.set_origins()` | prefix, origins |
| `maxy.limit_requests.create()` | *, wanted_usd=None, note=None |
| `maxy.limit_requests.list()` | none |
| `maxy.statements.get()` | month=None |
| `maxy.statements.download()` | month, format="csv" |
| `maxy.explorer.lookup()` | query |
| `maxy.system.status()` | none |
| `maxy.system.history()` | *, days=None |
| `maxy.system.incidents()` | none |
| `maxy.system.maintenance()` | none |
| `maxy.system.verified()` | none |
| `maxy.system.subscribe()` | kind, target |
| `maxy.system.confirm()` | token |
| `maxy.system.unsubscribe()` | token |
| `maxy.checkout.verify()` | query |
| `maxy.feedback.send()` | page, *, helpful=None, comment=None, kind=None |
| `maxy.security_reports.send()` | summary, *, details=None, reply_to=None |

Generated from the 1.1.13 build.

---
Source: https://maxy.co/docs/sdk-reference (Maxy Docs › SDK › Using the SDK)
