@agg-build/hooks 4.0.0 → 4.4.0
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.
- package/README.md +38 -15
- package/dist/{chunk-AZYAQIZB.mjs → chunk-IHMZHA2W.mjs} +1 -1
- package/dist/{chunk-SC6X5TL4.mjs → chunk-LVOL27OZ.mjs} +338 -49
- package/dist/{chunk-BR6NZSXN.mjs → chunk-O4RM4KKO.mjs} +1 -1
- package/dist/deposit.js +54 -5
- package/dist/deposit.mjs +2 -2
- package/dist/index.d.mts +472 -4
- package/dist/index.d.ts +472 -4
- package/dist/index.js +1013 -80
- package/dist/index.mjs +654 -21
- package/dist/withdraw.js +54 -5
- package/dist/withdraw.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ npm install @agg-build/sdk @agg-build/hooks
|
|
|
31
31
|
## Quick start
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
|
-
import { AggProvider } from "@agg-build/hooks";
|
|
34
|
+
import { AggProvider, QueryClient, QueryClientProvider } from "@agg-build/hooks";
|
|
35
35
|
import { createAggClient } from "@agg-build/sdk";
|
|
36
36
|
|
|
37
37
|
const client = createAggClient({
|
|
@@ -39,18 +39,21 @@ const client = createAggClient({
|
|
|
39
39
|
appId: "your-app-id",
|
|
40
40
|
wsUrl: "wss://ws.agg.market",
|
|
41
41
|
});
|
|
42
|
+
const queryClient = new QueryClient();
|
|
42
43
|
|
|
43
44
|
export function App() {
|
|
44
45
|
return (
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
<QueryClientProvider client={queryClient}>
|
|
47
|
+
<AggProvider
|
|
48
|
+
client={client}
|
|
49
|
+
config={{
|
|
50
|
+
general: { locale: "en-US", theme: "dark" },
|
|
51
|
+
features: { enableAnimations: true, enableLiveUpdates: true },
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<YourApp />
|
|
55
|
+
</AggProvider>
|
|
56
|
+
</QueryClientProvider>
|
|
54
57
|
);
|
|
55
58
|
}
|
|
56
59
|
```
|
|
@@ -59,9 +62,9 @@ export function App() {
|
|
|
59
62
|
prefer to compose them yourself, the individual providers (`AggSdkProvider`, `AggUiProvider`,
|
|
60
63
|
`AggBalanceProvider`) are exported too.
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
`AggProvider` uses TanStack Query for shared request and live-data caches, so a
|
|
66
|
+
`QueryClientProvider` ancestor is required. The package re-exports `QueryClient` and
|
|
67
|
+
`QueryClientProvider` for hooks-only consumers.
|
|
65
68
|
|
|
66
69
|
### Signing in with a wallet
|
|
67
70
|
|
|
@@ -278,8 +281,7 @@ function LinkPartnerAccount({
|
|
|
278
281
|
|
|
279
282
|
| Hook | Description |
|
|
280
283
|
| ------------------------------- | -------------------------------------------------------------- |
|
|
281
|
-
| `
|
|
282
|
-
| `useExecuteManaged(options?)` | Execute a previously quoted managed trade |
|
|
284
|
+
| `useExecuteManaged(options?)` | Fill a quote from `useSmartRoute` — see note below |
|
|
283
285
|
| `useValidateManaged(options?)` | Pre-validate balances/bridge without quoting |
|
|
284
286
|
| `useWithdrawManaged(options?)` | Withdraw from managed wallets |
|
|
285
287
|
| `useSyncBalances(options?)` | Trigger on-chain balance sync |
|
|
@@ -287,6 +289,27 @@ function LinkPartnerAccount({
|
|
|
287
289
|
| `useRedeem()` | Claim winnings from resolved markets |
|
|
288
290
|
| `useRedeemEligibleCount()` | Count of positions eligible to redeem |
|
|
289
291
|
|
|
292
|
+
To quote and fill, take the quote from `useSmartRoute` and pass its `quoteId` to
|
|
293
|
+
`useExecuteManaged`.
|
|
294
|
+
|
|
295
|
+
```tsx
|
|
296
|
+
const buyRoute = useSmartRoute({
|
|
297
|
+
venueMarketOutcomeId,
|
|
298
|
+
tradeSide: "buy",
|
|
299
|
+
maxSpend: 50,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const sellRoute = useSmartRoute({
|
|
303
|
+
venueMarketOutcomeId,
|
|
304
|
+
tradeSide: "sell",
|
|
305
|
+
sellShares: 10,
|
|
306
|
+
});
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
> **Removed in v4.** `useQuoteManaged` was deleted — it wrapped
|
|
310
|
+
> `client.quoteManaged()`, whose endpoint (`POST /execution/quote`) does not
|
|
311
|
+
> exist on the API, so the call only ever returned 404.
|
|
312
|
+
|
|
290
313
|
### Deposits (subpath)
|
|
291
314
|
|
|
292
315
|
Import from `@agg-build/hooks/deposit` to keep wallet-heavy hooks out of your main bundle:
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useOnWithdrawalLifecycle,
|
|
12
12
|
useSyncBalances,
|
|
13
13
|
useWithdrawManaged
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LVOL27OZ.mjs";
|
|
15
15
|
|
|
16
16
|
// src/withdraw/use-withdraw-flow.ts
|
|
17
17
|
import { useCallback, useEffect, useMemo, useState } from "react";
|