@agg-build/sdk 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +53 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -252,8 +252,7 @@ Call `client.destroy()` when you no longer need the client to release internal r
252
252
  | Method | Description |
253
253
  | ----------------------------- | ---------------------------------------------------- |
254
254
  | `validateManaged(params)` | Check balances and bridge requirements |
255
- | `quoteManaged(params)` | Request a 2-min TTL quote with execution steps |
256
- | `executeManaged(params)` | Execute a previously quoted trade |
255
+ | `executeManaged(params)` | Fill a quote from `getSmartRoute()` see note below |
257
256
  | `withdrawManaged(params)` | Withdraw from managed wallets to an external address |
258
257
  | `withdrawPreview(params)` | Preview withdrawal receive amount and route fees |
259
258
  | `getWithdrawalQuote(params)` | Quote the maximum deliverable withdrawal amount |
@@ -263,6 +262,18 @@ Call `client.destroy()` when you no longer need the client to release internal r
263
262
  | `getManagedBalances()` | Get managed wallet balances per-chain + per-venue |
264
263
  | `getDepositAddresses()` | Get managed wallet deposit addresses (EVM + Solana) |
265
264
 
265
+ To quote and fill a managed trade, take the quote from `getSmartRoute()` and pass
266
+ its `quoteId` to `executeManaged()`:
267
+
268
+ ```ts
269
+ const route = await client.getSmartRoute({ venueMarketOutcomeId, side, amount });
270
+ await client.executeManaged({ quoteId: route.quoteId });
271
+ ```
272
+
273
+ > **Removed in v4.** `quoteManaged()` was deleted — its endpoint,
274
+ > `POST /execution/quote`, does not exist on the API, so the call only ever
275
+ > returned 404. Use the two-step flow above.
276
+
266
277
  #### Orders & positions
267
278
 
268
279
  | Method | Description |
@@ -296,6 +307,33 @@ Call `client.destroy()` when you no longer need the client to release internal r
296
307
  | `mergeCandles` | Merge live + historical candles, live-wins on collision |
297
308
  | `mergeClosedCandles` | Variant that merges only fully closed candles |
298
309
  | `TurnstileChallengeError` | Thrown when an auth endpoint requires a Turnstile challenge |
310
+ | `AggApiError` | Thrown for every non-2xx API response — see below |
311
+ | `isAggApiError` | Type guard for `AggApiError` |
312
+
313
+ ### Error handling
314
+
315
+ Every non-2xx response is thrown as an `AggApiError` carrying `status`, and —
316
+ when the API supplies them — `code`, `retryable` and per-field `errors`. Branch
317
+ on `status`/`code` rather than matching message text; messages are human-facing
318
+ and may be reworded.
319
+
320
+ ```ts
321
+ import { isAggApiError } from "@agg-build/sdk";
322
+
323
+ try {
324
+ await client.getPositions();
325
+ } catch (err) {
326
+ if (isAggApiError(err)) {
327
+ if (err.status === 401) return promptReconnect(); // session lapsed
328
+ if (err.code === "unregistered_domain") {
329
+ // The signed SIWE `domain` is not in the app's allowedOrigins.
330
+ // Note this is NOT the Origin header — sign-in works with no Origin
331
+ // at all, which is what makes Node and React Native work.
332
+ }
333
+ }
334
+ throw err;
335
+ }
336
+ ```
299
337
 
300
338
  ### `@agg-build/sdk/server`
301
339
 
@@ -350,8 +388,19 @@ Key behaviors:
350
388
 
351
389
  ## Peer dependencies
352
390
 
353
- None. `@agg-build/sdk` is dependency-light and bundles its own clients for `viem`, `ethers@5`,
354
- `@polymarket/clob-client`, and `@polymarket/builder-signing-sdk`.
391
+ None and as of v4, no runtime dependencies either. The only module the bundle
392
+ imports is `node:crypto` (used by `@agg-build/sdk/server`), so a fresh install is
393
+ under 1 MB with nothing transitive.
394
+
395
+ Bring your own wallet library. The SDK builds SIWE/SIWS message strings and never
396
+ signs anything itself, so `viem`, `ethers`, or any other signer works — you pass
397
+ in a `signMessage` function.
398
+
399
+ > **Changed in v4.** Earlier versions declared `viem`, `ethers@5`,
400
+ > `@polymarket/clob-client` and `@polymarket/builder-signing-sdk` as runtime
401
+ > dependencies. No code path ever imported them, but installers still paid for
402
+ > them — roughly 100 MB of `node_modules` across their transitive trees. They
403
+ > were removed in v4; nothing in the SDK's behaviour changed.
355
404
 
356
405
  ## Links
357
406
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agg-build/sdk",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Vanilla TypeScript client for the AGG prediction market aggregator (auth, markets, orderbooks, charts, trading, managed execution, WebSockets). Works in browsers, Node.js, and React Native.",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",