@berachain/berajs 0.2.10 → 0.2.11

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 (144) hide show
  1. package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
  2. package/dist/actions/clients/exports.mjs +1 -1
  3. package/dist/actions/exports.d.ts +67 -17
  4. package/dist/actions/exports.mjs +60 -19
  5. package/dist/actions/governance/exports.d.ts +3 -11
  6. package/dist/{chunk-P5WXXULM.mjs → chunk-MRQGHXAN.mjs} +1 -1
  7. package/dist/{chunk-WNBWX23Q.mjs → chunk-SXUNCX5E.mjs} +5 -4
  8. package/dist/chunk-UD5IUNCW.mjs +34 -0
  9. package/dist/{chunk-QBBOWFMH.mjs → chunk-VAA2FVPP.mjs} +58 -12
  10. package/dist/contexts/exports.d.ts +2 -2
  11. package/dist/contexts/exports.mjs +4 -2
  12. package/dist/enum/exports.d.ts +8 -2
  13. package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
  14. package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.d.ts → getValidatorQueuedOperatorAddress-Cxt-DlL_.d.ts} +2 -2
  15. package/dist/{global.d-BuGDKh4k.d.ts → global.d-q_LQWQqs.d.ts} +2 -4
  16. package/dist/hooks/exports.d.ts +100 -149
  17. package/dist/hooks/exports.mjs +468 -484
  18. package/dist/hooks/governance/exports.d.ts +20 -15
  19. package/dist/hooks/governance/exports.mjs +39 -37
  20. package/dist/{pol.d-Dw5SQcRX.d.ts → pol.d-CeRgXBL8.d.ts} +18 -4
  21. package/dist/types/exports.d.ts +5 -5
  22. package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
  23. package/dist/utils/exports.d.ts +2 -2
  24. package/dist/utils/exports.mjs +4 -0
  25. package/package.json +8 -7
  26. package/src/actions/bend/getMaxDeposit.ts +28 -2
  27. package/src/actions/clients/fetchOpenApi.ts +6 -2
  28. package/src/actions/clients/fetchOpenApi.unit.test.ts +24 -2
  29. package/src/actions/exports.ts +1 -0
  30. package/src/actions/honey/getChartData.ts +53 -12
  31. package/src/actions/honey/getHoney24hVolume.ts +34 -6
  32. package/src/actions/honey/getHoneyTxns.ts +93 -0
  33. package/src/actions/validators/getValidatorIncentiveDistribution.ts +64 -12
  34. package/src/contexts/SwrFallback.tsx +2 -1
  35. package/src/data/contracts.ts +4 -0
  36. package/src/errors/getRevertReason.integration.test.ts +5 -1
  37. package/src/hooks/bend/useGetConvertToAssets.ts +2 -3
  38. package/src/hooks/dex/useAggregatorsQuotes.ts +10 -10
  39. package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +1 -1
  40. package/src/hooks/dex/useAllUserPools.ts +7 -5
  41. package/src/hooks/dex/useApiPool.ts +1 -1
  42. package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -1
  43. package/src/hooks/dex/useOnChainPoolData.ts +1 -1
  44. package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +2 -2
  45. package/src/hooks/dex/usePoolEvents.ts +1 -2
  46. package/src/hooks/dex/usePoolHistoricalData.ts +2 -3
  47. package/src/hooks/dex/usePools.ts +4 -2
  48. package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
  49. package/src/hooks/enso/useBendDemultiply.ts +3 -4
  50. package/src/hooks/enso/useBendMultiply.ts +3 -4
  51. package/src/hooks/enso/useBendZapSupply.ts +3 -4
  52. package/src/hooks/enso/useEnsoSwapBundle.ts +1 -1
  53. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +3 -5
  54. package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
  55. package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
  56. package/src/hooks/enso/useZapStakeBera.ts +2 -2
  57. package/src/hooks/exports.ts +1 -0
  58. package/src/hooks/governance/useGetPastVotes.ts +1 -1
  59. package/src/hooks/governance/useHasVoted.ts +1 -1
  60. package/src/hooks/governance/useIsCanceller.ts +1 -1
  61. package/src/hooks/governance/usePollAllProposals.ts +13 -12
  62. package/src/hooks/governance/usePollProposal.ts +3 -3
  63. package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
  64. package/src/hooks/governance/usePollProposalVotes.ts +23 -5
  65. package/src/hooks/governance/usePollUserDelegates.ts +3 -3
  66. package/src/hooks/governance/useProposalFromTx.ts +2 -1
  67. package/src/hooks/governance/useProposalSnapshot.ts +2 -3
  68. package/src/hooks/governance/useProposalState.ts +2 -2
  69. package/src/hooks/governance/useProposalTimelockState.ts +2 -1
  70. package/src/hooks/governance/useQuorum.ts +1 -2
  71. package/src/hooks/honey/useCappedGlobally.ts +3 -6
  72. package/src/hooks/honey/useCappedRelatively.ts +2 -2
  73. package/src/hooks/honey/useCollateralWeights.ts +3 -3
  74. package/src/hooks/honey/useHoney24hVolume.ts +1 -1
  75. package/src/hooks/honey/useHoneyBalances.ts +1 -1
  76. package/src/hooks/honey/useHoneyChartData.ts +1 -1
  77. package/src/hooks/honey/useHoneyVaultsBalance.ts +2 -3
  78. package/src/hooks/honey/useIsBadCollateralAsset.ts +4 -7
  79. package/src/hooks/honey/useIsBasketModeEnabled.ts +4 -7
  80. package/src/hooks/honey/usePythLatestPrices.ts +13 -9
  81. package/src/hooks/perps/usePythUpdateFee.ts +13 -11
  82. package/src/hooks/pol/useAutoclaimedIncentives.ts +1 -2
  83. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +1 -2
  84. package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +39 -0
  85. package/src/hooks/pol/useBgtUnstakedBalance.ts +2 -2
  86. package/src/hooks/pol/useClaimableFees.ts +1 -1
  87. package/src/hooks/pol/useHighestVaultsAPR.ts +4 -6
  88. package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
  89. package/src/hooks/pol/usePollGlobalData.ts +2 -3
  90. package/src/hooks/pol/usePollMarkets.ts +2 -2
  91. package/src/hooks/pol/useQueuedBeraUnlock.ts +2 -2
  92. package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
  93. package/src/hooks/pol/useRewardVault.ts +7 -6
  94. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +4 -4
  95. package/src/hooks/pol/useRewardVaultFromToken.ts +1 -1
  96. package/src/hooks/pol/useRewardVaultIncentives.ts +1 -1
  97. package/src/hooks/pol/useRewardVaultRewards.ts +2 -2
  98. package/src/hooks/pol/useRewardVaults.ts +3 -6
  99. package/src/hooks/pol/useStakedAPR.ts +1 -2
  100. package/src/hooks/pol/useStakedData.ts +90 -41
  101. package/src/hooks/pol/useStakedSnapshots.ts +1 -1
  102. package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
  103. package/src/hooks/pol/useTotalStakedAmount.ts +1 -2
  104. package/src/hooks/pol/useUserVaultInfo.ts +2 -2
  105. package/src/hooks/pol/useUserVaults.ts +2 -3
  106. package/src/hooks/pol/useVaultAddress.ts +1 -1
  107. package/src/hooks/pol/useVaultHistory.ts +1 -2
  108. package/src/hooks/pol/useVaultValidators.ts +2 -2
  109. package/src/hooks/tokens/useMultipleTokenInformation.ts +2 -2
  110. package/src/hooks/tokens/usePollAllowances.ts +3 -4
  111. package/src/hooks/tokens/usePollBalance.ts +2 -2
  112. package/src/hooks/tokens/usePollWalletBalances.ts +2 -2
  113. package/src/hooks/tokens/useStakingTokenInformation.ts +2 -2
  114. package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
  115. package/src/hooks/tokens/useTokenInformation.ts +2 -2
  116. package/src/hooks/tokens/useTokenPrice.ts +2 -1
  117. package/src/hooks/tokens/useTokenPrices.ts +3 -4
  118. package/src/hooks/tokens/useTotalSupply.ts +1 -1
  119. package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
  120. package/src/hooks/useBlockToTimestamp.ts +1 -2
  121. package/src/hooks/useGetVerifiedAbi.ts +2 -1
  122. package/src/hooks/validators/useAllValidators.ts +2 -3
  123. package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
  124. package/src/hooks/validators/useApiValidator.ts +3 -6
  125. package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
  126. package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
  127. package/src/hooks/validators/useDefaultRewardAllocation.ts +2 -3
  128. package/src/hooks/validators/useManagedValidatorRole.ts +2 -2
  129. package/src/hooks/validators/useOnChainValidator.ts +3 -3
  130. package/src/hooks/validators/useStakingPoolBatch.ts +3 -4
  131. package/src/hooks/validators/useUserActiveValidators.ts +2 -3
  132. package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
  133. package/src/hooks/validators/useUserClaimableIncentives.ts +1 -1
  134. package/src/hooks/validators/useUserStakingPositions.ts +2 -1
  135. package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
  136. package/src/hooks/validators/useValidatorCommission.ts +2 -2
  137. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +3 -3
  138. package/src/hooks/validators/useValidatorQueuedCommission.ts +2 -2
  139. package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +2 -2
  140. package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +2 -2
  141. package/src/hooks/validators/useValidatorRewardAllocation.ts +2 -2
  142. package/src/types/global.d.ts +3 -4
  143. package/src/types/pol.d.ts +17 -3
  144. package/dist/polling-BKnyavLI.d.ts +0 -8
@@ -1,18 +1,26 @@
1
+ import type { HoneySnapshotResponse } from "@berachain/graphql/beep";
1
2
  import type { GetSnapshotsQuery } from "@berachain/graphql/honey";
2
3
 
3
4
  import { BeraError } from "../../errors/BeraError";
4
5
  import { beraFetchJson } from "../../utils/beraFetch";
6
+ import { parseBaseArgs } from "../../utils/parseBaseArgs";
7
+ import { fetchBeep } from "../clients/fetchBeep";
5
8
 
6
9
  /**
7
- * Browser-only. Hits the typed `/api/honey/snapshots` endpoint.
8
- * Server callers must compose the upstream query directly (this action is
9
- * not server-safe — `fetch` against a relative URL has no origin off-browser).
10
+ * Browser-only. Returns daily honey snapshots in the `beep` response shape
11
+ * (`HoneySnapshotResponse`) the chart consumes.
12
+ *
13
+ * Reads from the `beep` backend (`fetchBeep`) when configured, falling back to
14
+ * the legacy honey subgraph proxied through `/api/honey/snapshots` (whose
15
+ * GraphQL result is adapted into the beep shape) otherwise. Server callers must
16
+ * compose the upstream query directly (this action is not server-safe — `fetch`
17
+ * against a relative URL has no origin off-browser).
10
18
  */
11
19
  export async function getChartData({
12
20
  days,
13
21
  }: {
14
22
  days: number;
15
- }): Promise<GetSnapshotsQuery> {
23
+ }): Promise<HoneySnapshotResponse> {
16
24
  if (typeof window === "undefined") {
17
25
  throw new BeraError({
18
26
  message:
@@ -21,13 +29,46 @@ export async function getChartData({
21
29
  });
22
30
  }
23
31
 
24
- const params = new URLSearchParams({ interval: "day", first: String(days) });
25
- const honeySnapshots = await beraFetchJson<
26
- GetSnapshotsQuery["honeySnapshots"]
27
- >({
28
- url: `/api/honey/snapshots?${params}`,
29
- name: "honey-snapshots",
30
- type: "rest",
32
+ const { config } = parseBaseArgs({});
33
+
34
+ // TODO(beep): remove this entire block once `beep` is deployed on every
35
+ // chain. It is the only legacy honey-subgraph code left here; deleting it
36
+ // leaves the `beep` path below as the sole implementation.
37
+ if (!config.beep) {
38
+ const params = new URLSearchParams({
39
+ interval: "day",
40
+ first: String(days),
41
+ });
42
+ const snapshots = await beraFetchJson<GetSnapshotsQuery["honeySnapshots"]>({
43
+ url: `/api/honey/snapshots?${params}`,
44
+ name: "honey-snapshots",
45
+ type: "rest",
46
+ });
47
+ return snapshots.map(fromHoneySnapshot);
48
+ }
49
+
50
+ // beep backend (next-gen), typed against `@berachain/graphql/beep`. Queried
51
+ // directly from the browser — no Vercel proxy.
52
+ return fetchBeep("/v0/honey/snapshots/{interval}", {
53
+ path: { interval: "day" },
54
+ query: { perPage: String(days) },
31
55
  });
32
- return { honeySnapshots };
56
+ }
57
+
58
+ /**
59
+ * Adapt a legacy subgraph snapshot into the beep `HoneySnapshotResponse` shape.
60
+ *
61
+ * The subgraph reports `timestamp` in microseconds; beep (and every consumer)
62
+ * expects seconds, so scale microseconds → seconds.
63
+ */
64
+ function fromHoneySnapshot(
65
+ snapshot: GetSnapshotsQuery["honeySnapshots"][number],
66
+ ): HoneySnapshotResponse[number] {
67
+ return {
68
+ timestamp: Math.floor(Number(snapshot.timestamp) / 1_000_000),
69
+ mintVolume: snapshot.mintVolume,
70
+ redeemVolume: snapshot.redeemVolume,
71
+ totalVolume: snapshot.totalVolume,
72
+ totalSupply: snapshot.totalSupply,
73
+ };
33
74
  }
@@ -3,8 +3,16 @@ import BigNumber from "@berachain/utils/pkg/bignumber.js";
3
3
 
4
4
  import { BeraError } from "../../errors/BeraError";
5
5
  import { beraFetchJson } from "../../utils/beraFetch";
6
+ import { parseBaseArgs } from "../../utils/parseBaseArgs";
7
+ import { fetchBeep } from "../clients/fetchBeep";
6
8
 
7
- /** Browser-only. Hits `/api/honey/snapshots?interval=hour&first=24` and reduces. */
9
+ /**
10
+ * Browser-only. Sums the last 24 hourly honey snapshots into a 24h volume.
11
+ *
12
+ * Reads from the `beep` backend (`fetchBeep`) when configured, falling back to
13
+ * the legacy honey subgraph proxied through `/api/honey/snapshots` otherwise.
14
+ * Both backends expose `totalVolume` per snapshot, so the sum is shape-agnostic.
15
+ */
8
16
  export async function getHoney24hVolume(): Promise<BigNumber | undefined> {
9
17
  if (typeof window === "undefined") {
10
18
  throw new BeraError({
@@ -14,12 +22,32 @@ export async function getHoney24hVolume(): Promise<BigNumber | undefined> {
14
22
  });
15
23
  }
16
24
 
17
- const params = new URLSearchParams({ interval: "hour", first: "24" });
18
- const snapshots = await beraFetchJson<GetSnapshotsQuery["honeySnapshots"]>({
19
- url: `/api/honey/snapshots?${params}`,
20
- name: "honey-snapshots",
21
- type: "rest",
25
+ const { config } = parseBaseArgs({});
26
+
27
+ // TODO(beep): remove this entire block once `beep` is deployed on every
28
+ // chain. It is the only legacy honey-subgraph code left here; deleting it
29
+ // leaves the `beep` path below as the sole implementation.
30
+ if (!config.beep) {
31
+ const params = new URLSearchParams({ interval: "hour", first: "24" });
32
+ const snapshots = await beraFetchJson<GetSnapshotsQuery["honeySnapshots"]>({
33
+ url: `/api/honey/snapshots?${params}`,
34
+ name: "honey-snapshots",
35
+ type: "rest",
36
+ });
37
+ return sumTotalVolume(snapshots);
38
+ }
39
+
40
+ // beep backend (next-gen), typed against `@berachain/graphql/beep`. Queried
41
+ // directly from the browser — no Vercel proxy.
42
+ const snapshots = await fetchBeep("/v0/honey/snapshots/{interval}", {
43
+ path: { interval: "hour" },
44
+ query: { perPage: "24" },
22
45
  });
46
+
47
+ return sumTotalVolume(snapshots);
48
+ }
49
+
50
+ function sumTotalVolume(snapshots: { totalVolume: string }[]): BigNumber {
23
51
  return snapshots.reduce(
24
52
  (acc, curr) => new BigNumber(curr.totalVolume).plus(acc),
25
53
  new BigNumber(0),
@@ -0,0 +1,93 @@
1
+ import type { HoneyTransactionsLatestResponse } from "@berachain/graphql/beep";
2
+ import type { GetHoneyTxnQuery } from "@berachain/graphql/honey";
3
+
4
+ import { BeraError } from "../../errors/BeraError";
5
+ import { beraFetchJson } from "../../utils/beraFetch";
6
+ import { parseBaseArgs } from "../../utils/parseBaseArgs";
7
+ import { fetchBeep } from "../clients/fetchBeep";
8
+
9
+ type HoneyTxn = HoneyTransactionsLatestResponse[number];
10
+ /** beep's transaction type discriminator (`"MINT" | "REDEEM"`). */
11
+ type HoneyTxnType = HoneyTxn["type"];
12
+
13
+ interface GetHoneyTxnsArgs {
14
+ /** Zero-based page index (the page size is applied internally). */
15
+ index: number;
16
+ /** Page size. */
17
+ limit: number;
18
+ /** Optional MINT/REDEEM filter; omit for all transactions. */
19
+ txnType?: HoneyTxnType;
20
+ }
21
+
22
+ /**
23
+ * Browser-only. Returns a page of honey transactions in the `beep` response
24
+ * shape (`HoneyTransactionsLatestResponse`) the transactions table consumes.
25
+ *
26
+ * Reads from the `beep` backend (`fetchBeep`) when configured, falling back to
27
+ * the legacy honey subgraph proxied through `/api/honey/txns` (whose GraphQL
28
+ * result is adapted into the beep shape) otherwise.
29
+ */
30
+ export async function getHoneyTxns({
31
+ index,
32
+ limit,
33
+ txnType,
34
+ }: GetHoneyTxnsArgs): Promise<HoneyTransactionsLatestResponse> {
35
+ if (typeof window === "undefined") {
36
+ throw new BeraError({
37
+ message:
38
+ "getHoneyTxns is browser-only; call from a Client Component / SWR hook",
39
+ level: "error",
40
+ });
41
+ }
42
+
43
+ const { config } = parseBaseArgs({});
44
+
45
+ // TODO(beep): remove this entire block once `beep` is deployed on every
46
+ // chain. It is the only legacy honey-subgraph code left here; deleting it
47
+ // leaves the `beep` path below as the sole implementation.
48
+ if (!config.beep) {
49
+ const params = new URLSearchParams({
50
+ skip: String(index * limit),
51
+ limit: String(limit),
52
+ });
53
+ if (txnType) params.set("type", txnType);
54
+
55
+ const txns = await beraFetchJson<GetHoneyTxnQuery["honeyTxns"]>({
56
+ url: `/api/honey/txns?${params}`,
57
+ name: "honey-txns",
58
+ type: "rest",
59
+ });
60
+ return txns.map(fromHoneyTxn);
61
+ }
62
+
63
+ // beep backend (next-gen), typed against `@berachain/graphql/beep`. Queried
64
+ // directly from the browser — no Vercel proxy. beep's `page` is 1-indexed and
65
+ // filters server-side by `type`; `fetchOpenApi` omits `type` when `txnType`
66
+ // is undefined (the "all" tab), so each tab paginates its own filtered feed.
67
+ return fetchBeep("/v0/honey/transactions/latest", {
68
+ query: { page: String(index + 1), perPage: String(limit), type: txnType },
69
+ });
70
+ }
71
+
72
+ /**
73
+ * Adapt a legacy subgraph transaction into the beep `HoneyTransactionsLatest`
74
+ * shape: nested `chainTransaction.txHash` → flat `txHash`, `collateral` →
75
+ * `collaterals` (`collateral`/`collateralAmount` → `address`/`amount`).
76
+ *
77
+ * The subgraph reports `timestamp` in seconds (matching beep), so it passes
78
+ * through as a number. A subgraph txn always carries a `type` in practice.
79
+ */
80
+ function fromHoneyTxn(txn: GetHoneyTxnQuery["honeyTxns"][number]): HoneyTxn {
81
+ return {
82
+ txHash: txn.chainTransaction.txHash,
83
+ type: (txn.type ?? "MINT") as HoneyTxnType,
84
+ collaterals: txn.collateral.map((collateral) => ({
85
+ address: collateral.collateral,
86
+ amount: collateral.collateralAmount,
87
+ })),
88
+ to: txn.to,
89
+ from: txn.from,
90
+ honeyAmount: txn.honeyAmount,
91
+ timestamp: Number(txn.timestamp),
92
+ };
93
+ }
@@ -1,18 +1,21 @@
1
1
  import type { Address } from "viem";
2
2
 
3
- import type { GetValidatorIncentiveDistributionQuery } from "@berachain/graphql/pol/subgraph";
3
+ import type { ValidatorIncentivesResponse } from "@berachain/graphql/beep";
4
4
 
5
5
  import { BeraError } from "../../errors/BeraError";
6
6
  import { beraFetchJson } from "../../utils/beraFetch";
7
+ import { calculateTimestampFromDays } from "../../utils/formatTimestamps";
8
+ import { parseBaseArgs } from "../../utils/parseBaseArgs";
9
+ import { fetchBeep } from "../clients/fetchBeep";
7
10
 
8
- /** Browser-only. Hits `/api/pol/validator-incentive-distribution`. */
11
+ /** Browser-only. Reads from beep when configured, else the subgraph proxy. */
9
12
  export async function getValidatorIncentiveDistribution({
10
13
  pubkey,
11
14
  dayRange,
12
15
  }: {
13
16
  pubkey: Address;
14
17
  dayRange: number;
15
- }): Promise<GetValidatorIncentiveDistributionQuery | undefined> {
18
+ }): Promise<ValidatorIncentivesResponse | undefined> {
16
19
  if (typeof window === "undefined") {
17
20
  throw new BeraError({
18
21
  message:
@@ -21,13 +24,62 @@ export async function getValidatorIncentiveDistribution({
21
24
  });
22
25
  }
23
26
 
24
- const params = new URLSearchParams({
25
- pubkey,
26
- dayRange: String(dayRange),
27
- });
28
- return beraFetchJson<GetValidatorIncentiveDistributionQuery>({
29
- url: `/api/pol/validator-incentive-distribution?${params}`,
30
- name: "pol-validator-incentive-distribution",
31
- type: "rest",
32
- });
27
+ const { config } = parseBaseArgs({});
28
+
29
+ // TODO(beep): remove this entire block (and the subgraph proxy route at
30
+ // `/api/pol/validator-incentive-distribution`) once `beep` is deployed on
31
+ // every chain. beep then becomes the sole implementation. The route already
32
+ // maps the subgraph response into beep's `ValidatorIncentivesResponse` shape,
33
+ // so the client consumes a single (beep) type regardless of source.
34
+ if (!config.beep) {
35
+ const params = new URLSearchParams({
36
+ pubkey,
37
+ dayRange: String(dayRange),
38
+ });
39
+ return beraFetchJson<ValidatorIncentivesResponse>({
40
+ url: `/api/pol/validator-incentive-distribution?${params}`,
41
+ name: "pol-validator-incentive-distribution",
42
+ type: "rest",
43
+ });
44
+ }
45
+
46
+ // beep backend (next-gen). It is a public (`NEXT_PUBLIC_*`) URL, so it can be
47
+ // called directly from the browser; the subgraph above stays behind the proxy
48
+ // because it needs server-side auth headers.
49
+ //
50
+ // beep's `after` cursor is in seconds; `calculateTimestampFromDays` returns
51
+ // microseconds, matching the subgraph's `timestamp_gte`. Pin it to the start
52
+ // of the target day (UTC) so the cursor is stable within a day instead of
53
+ // sliding every second — beep buckets by `interval: "day"` anyway, and a
54
+ // stable value keeps requests cacheable.
55
+ const SECONDS_PER_DAY = 86_400;
56
+ const after = String(
57
+ Math.floor(
58
+ calculateTimestampFromDays(dayRange) / 1_000_000 / SECONDS_PER_DAY,
59
+ ) * SECONDS_PER_DAY,
60
+ );
61
+
62
+ // beep defaults to 100 rows/page, so page until a short page to gather the
63
+ // full range (matches the subgraph's `first: 1000`). In practice this is a
64
+ // single request — a busy validator is ~325 rows over the UI's max 90-day
65
+ // window, well under one page.
66
+ const PER_PAGE = 1000;
67
+ const rows: ValidatorIncentivesResponse = [];
68
+ let page = 1;
69
+ while (true) {
70
+ const pageRows = await fetchBeep("/v0/validators/{pubkey}/incentives", {
71
+ path: { pubkey },
72
+ query: {
73
+ interval: "day",
74
+ after,
75
+ page: String(page),
76
+ perPage: String(PER_PAGE),
77
+ },
78
+ });
79
+ rows.push(...pageRows);
80
+ if (pageRows.length < PER_PAGE) break;
81
+ page++;
82
+ }
83
+
84
+ return rows;
33
85
  }
@@ -1,6 +1,7 @@
1
1
  import type React from "react";
2
2
  import { useEffect } from "react";
3
- import { SWRConfig } from "swr";
3
+
4
+ import { SWRConfig } from "@berachain/utils/pkg/swr";
4
5
 
5
6
  import { BeraError } from "../errors/BeraError";
6
7
  import { BeraMonitoring } from "../errors/BeraMonitoring";
@@ -377,6 +377,10 @@ export const contracts = [
377
377
  "80094": "0x2880aB155794e7179c9eE2e38200202908C17B43",
378
378
  name: "external.pyth",
379
379
  },
380
+ {
381
+ "80094": "0xB5f473c4b7F402d8f7bED42b6D516f5ff3306B01",
382
+ name: "bend.production.supportedVaults.1",
383
+ },
380
384
  {
381
385
  "80069": null,
382
386
  "80094": "0xC5FabF3a7E98a2ed89f5d5057Ab010634Ca7e71f",
@@ -78,8 +78,12 @@ const expectedRevertReasons = [
78
78
  },
79
79
  {
80
80
  functionName: "revertNoReasonAssembly",
81
+ // A revert with no data has nothing to decode. The two replay paths surface it
82
+ // differently: simulateContract (getRevertReason) yields the RPC "execution
83
+ // reverted", while sendCalls/simulateCalls (eip5972) yields viem's zero-data
84
+ // error chain whose innermost name is "AbiDecodingZeroDataError".
81
85
  onChainReason: "execution reverted",
82
- revertReason: "execution failed",
86
+ revertReason: "AbiDecodingZeroDataError",
83
87
  txHashWith5972:
84
88
  "0xcd9af1bca5ac53d1fd6bd33796a087f15895943047ae0d20f51331d78945a7a8",
85
89
  },
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import { usePublicClient } from "@berachain/wagmi/hooks";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import type { GetConvertToAssetsProps } from "../../actions/bend/getConvertToAssets";
6
5
  import { getConvertToAssets } from "../../actions/bend/getConvertToAssets";
@@ -30,7 +29,7 @@ export const useGetConvertToAssets = (
30
29
  });
31
30
  },
32
31
  {
33
- ...options?.opts,
32
+ ...options,
34
33
  },
35
34
  );
36
35
 
@@ -118,7 +118,7 @@ export function useAggregatorsQuotes(
118
118
  ...args,
119
119
  aggregator: oogabooga,
120
120
  },
121
- { opts: swrOptions },
121
+ swrOptions,
122
122
  );
123
123
 
124
124
  const flyResult = raw_useSingleAggregatorQuote(
@@ -127,7 +127,7 @@ export function useAggregatorsQuotes(
127
127
  ...args,
128
128
  aggregator: fly,
129
129
  },
130
- { opts: swrOptions },
130
+ swrOptions,
131
131
  );
132
132
 
133
133
  const erc4626Result = raw_useSingleAggregatorQuote(
@@ -136,7 +136,7 @@ export function useAggregatorsQuotes(
136
136
  ...args,
137
137
  aggregator: erc4626Deposit,
138
138
  },
139
- { opts: swrOptions },
139
+ swrOptions,
140
140
  );
141
141
 
142
142
  const kyberswapResult = raw_useSingleAggregatorQuote(
@@ -145,7 +145,7 @@ export function useAggregatorsQuotes(
145
145
  ...args,
146
146
  aggregator: kyberswap,
147
147
  },
148
- { opts: swrOptions },
148
+ swrOptions,
149
149
  );
150
150
 
151
151
  const openOceanResult = raw_useSingleAggregatorQuote(
@@ -154,7 +154,7 @@ export function useAggregatorsQuotes(
154
154
  ...args,
155
155
  aggregator: openOcean,
156
156
  },
157
- { opts: swrOptions },
157
+ swrOptions,
158
158
  );
159
159
 
160
160
  const haikuResult = raw_useSingleAggregatorQuote(
@@ -163,7 +163,7 @@ export function useAggregatorsQuotes(
163
163
  ...args,
164
164
  aggregator: haiku,
165
165
  },
166
- { opts: swrOptions },
166
+ swrOptions,
167
167
  );
168
168
 
169
169
  const ensoResult = raw_useSingleAggregatorQuote(
@@ -172,7 +172,7 @@ export function useAggregatorsQuotes(
172
172
  ...args,
173
173
  aggregator: enso,
174
174
  },
175
- { opts: swrOptions },
175
+ swrOptions,
176
176
  );
177
177
 
178
178
  const { protocol: bexProtocol } = useBexStatus();
@@ -183,7 +183,7 @@ export function useAggregatorsQuotes(
183
183
  ...args,
184
184
  aggregator: bex,
185
185
  },
186
- { opts: { ...swrOptions, isEnabled: bexProtocol.isPaused === false } },
186
+ { ...swrOptions, isEnabled: bexProtocol.isPaused === false },
187
187
  );
188
188
 
189
189
  const wberaSwapResult = raw_useSingleAggregatorQuote({
@@ -198,7 +198,7 @@ export function useAggregatorsQuotes(
198
198
  ...args,
199
199
  aggregator: bgtRedeem,
200
200
  },
201
- { opts: swrOptions },
201
+ swrOptions,
202
202
  );
203
203
 
204
204
  const honeyResult = raw_useSingleAggregatorQuote(
@@ -207,7 +207,7 @@ export function useAggregatorsQuotes(
207
207
  ...args,
208
208
  aggregator: honeyNative,
209
209
  },
210
- { opts: swrOptions },
210
+ swrOptions,
211
211
  );
212
212
 
213
213
  const results = isWrapOrUnwrap
@@ -1,9 +1,9 @@
1
- import useSWRImmutable from "swr/immutable";
2
1
  import { type PublicClient, zeroAddress } from "viem";
3
2
 
4
3
  import aggregatorsRouterAbi from "@berachain/abis/meta-aggregator/metaAggregatorV2";
5
4
 
6
5
  import { usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { parseBaseArgs } from "../../utils/parseBaseArgs";
9
9
 
@@ -1,6 +1,5 @@
1
- import useSWR from "swr";
2
-
3
1
  import type { GetPoolsQueryVariables } from "@berachain/graphql/dex/api";
2
+ import { useSWR } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getAllPools } from "../../actions/dex/getAllPools";
6
5
  import { POLLING } from "../../enum/polling";
@@ -20,12 +19,15 @@ export const useAllUserPools = (
20
19
  ) => {
21
20
  const swrResponse = useSWR(
22
21
  useAllUserPoolsQueryKey({ query }),
23
- async ([_, params]: [string, GetPoolsQueryVariables]) => {
24
- return getAllPools({ ...params, fetchPolicy: "no-cache" });
22
+ async ([_, params]) => {
23
+ return getAllPools({
24
+ ...(params as GetPoolsQueryVariables),
25
+ fetchPolicy: "no-cache",
26
+ });
25
27
  },
26
28
  {
27
29
  refreshInterval: POLLING.SLOW,
28
- ...options?.opts,
30
+ ...options,
29
31
  },
30
32
  );
31
33
 
@@ -1,7 +1,7 @@
1
- import useSWR from "swr";
2
1
  import { type Address, type Hex, isAddress } from "viem";
3
2
 
4
3
  import type { MinimalPoolFragment } from "@berachain/graphql/dex/api";
4
+ import { useSWR } from "@berachain/utils/pkg/swr";
5
5
 
6
6
  import { getApiPool } from "../../actions/dex/getApiPool";
7
7
  import { POLLING } from "../../enum/polling";
@@ -1,4 +1,4 @@
1
- import useSWR from "swr";
1
+ import { useSWR } from "@berachain/utils/pkg/swr";
2
2
 
3
3
  import { getGlobalLiquidityAndSwapVolume } from "../../actions/dex/getGlobalLiquidityAndSwapVolume";
4
4
 
@@ -1,8 +1,8 @@
1
1
  import { useMemo } from "react";
2
- import useSWRImmutable from "swr/immutable";
3
2
  import { type Address, formatUnits, isAddress } from "viem";
4
3
 
5
4
  import { usePublicClient } from "@berachain/wagmi/hooks";
5
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
6
6
 
7
7
  import { getOnChainPool } from "../../actions/dex/getOnChainPool";
8
8
  import type { TokenPriceInfo } from "../../types/dex";
@@ -1,9 +1,9 @@
1
- import useSWR from "swr";
2
1
  import type { Address } from "viem";
3
2
 
4
3
  import { vaultAbi as balancerVaultAbi } from "@berachain/abis/bex/vault";
5
4
 
6
5
  import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
6
+ import { useSWR } from "@berachain/utils/pkg/swr";
7
7
 
8
8
  import { assertPublicClient } from "../../errors/assert";
9
9
  import type { DefaultHookOptions } from "../../types/global";
@@ -44,7 +44,7 @@ export const usePollPoolCreationRelayerApproval = (
44
44
 
45
45
  return approved;
46
46
  },
47
- { ...options?.opts },
47
+ { ...options },
48
48
  );
49
49
 
50
50
  const refreshPoolCreationApproval = () => {
@@ -1,6 +1,5 @@
1
- import useSWRImmutable from "swr/immutable";
2
-
3
1
  import type { GqlPoolEventType } from "@berachain/graphql/dex/api";
2
+ import { useSWRImmutable } from "@berachain/utils/pkg/swr";
4
3
 
5
4
  import { getPoolEvents } from "../../actions/dex/getPoolEvents";
6
5
  import { POLLING } from "../../enum/polling";
@@ -1,9 +1,8 @@
1
- import useSWR from "swr";
2
-
3
1
  import type {
4
2
  GqlChain,
5
3
  PoolHistoricalDataFragment,
6
4
  } from "@berachain/graphql/dex/api";
5
+ import { useSWR } from "@berachain/utils/pkg/swr";
7
6
 
8
7
  import { getPoolHistoricalData } from "../../actions/dex/getPoolHistoricalData";
9
8
  import type {
@@ -37,7 +36,7 @@ export const usePoolHistoricalData = (
37
36
  chain: config.bex.chainName as GqlChain,
38
37
  });
39
38
  },
40
- options?.opts,
39
+ options,
41
40
  );
42
41
 
43
42
  return {
@@ -1,8 +1,8 @@
1
1
  import { useMemo } from "react";
2
- import useSWR from "swr";
3
2
 
4
3
  import type { GetPoolsQueryVariables } from "@berachain/graphql/dex/api";
5
4
  import { useBeraWallet } from "@berachain/wagmi/hooks";
5
+ import { useSWR } from "@berachain/utils/pkg/swr";
6
6
 
7
7
  import { getAllPools } from "../../actions/dex/getAllPools";
8
8
  import { POLLING } from "../../enum/polling";
@@ -38,6 +38,7 @@ export const usePools = (
38
38
  data: pools,
39
39
  isLoading: isPoolsLoading,
40
40
  mutate: mutatePools,
41
+ error: poolsError,
41
42
  } = useSWR(
42
43
  usePoolsQueryKey({ query }),
43
44
  async ([_, query]) => {
@@ -45,7 +46,7 @@ export const usePools = (
45
46
  },
46
47
  {
47
48
  refreshInterval: POLLING.SLOW,
48
- ...options?.opts,
49
+ ...options,
49
50
  },
50
51
  );
51
52
 
@@ -74,6 +75,7 @@ export const usePools = (
74
75
  pools: mergedPools ?? [],
75
76
  walletPools: pools?.pools ?? [],
76
77
  isLoading: isPoolsLoading || isUserPoolsLoading,
78
+ error: poolsError,
77
79
  refresh: () => {
78
80
  mutatePools();
79
81
  mutateUserPools();