@berachain/berajs 0.2.10 → 0.2.12

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 (166) hide show
  1. package/dist/{HoneyConfigProvider-Dkj-_a5x.d.ts → HoneyConfigProvider-COOuDNra.d.ts} +1 -1
  2. package/dist/actions/clients/exports.d.ts +5 -21
  3. package/dist/actions/clients/exports.mjs +5 -7
  4. package/dist/actions/exports.d.ts +117 -31
  5. package/dist/actions/exports.mjs +36 -25
  6. package/dist/actions/governance/exports.d.ts +3 -11
  7. package/dist/actions/server/exports.mjs +2 -2
  8. package/dist/chunk-4ML4Y6UN.mjs +46 -0
  9. package/dist/{chunk-7YVNSDXG.mjs → chunk-FGION6F6.mjs} +1 -1
  10. package/dist/{chunk-3JJLQ2JX.mjs → chunk-MKSFQIKC.mjs} +1 -4
  11. package/dist/{chunk-ZLTMIFCZ.mjs → chunk-RFJGL4MF.mjs} +3 -3
  12. package/dist/{chunk-Y6THHG77.mjs → chunk-T43JPYQS.mjs} +1 -1
  13. package/dist/{chunk-WNBWX23Q.mjs → chunk-W2VODV76.mjs} +7 -10
  14. package/dist/{chunk-QBBOWFMH.mjs → chunk-XDG26EG6.mjs} +115 -162
  15. package/dist/{chunk-P5WXXULM.mjs → chunk-YLTWPFCJ.mjs} +3 -18
  16. package/dist/contexts/exports.d.ts +2 -2
  17. package/dist/contexts/exports.mjs +6 -4
  18. package/dist/enum/exports.d.ts +8 -2
  19. package/dist/errors/exports.mjs +2 -2
  20. package/dist/{getApolloClient-BcUTGFUb.d.ts → getApolloClient-MWm_iq4u.d.ts} +4 -5
  21. package/dist/getProposalVotes-DAUrdX2n.d.ts +12 -0
  22. package/dist/{getValidatorQueuedOperatorAddress-DphU3qhE.d.ts → getValidatorQueuedOperatorAddress-Cc05dlO3.d.ts} +8 -59
  23. package/dist/{global.d-BuGDKh4k.d.ts → global.d-CR3zicga.d.ts} +3 -10
  24. package/dist/hooks/exports.d.ts +145 -403
  25. package/dist/hooks/exports.mjs +496 -755
  26. package/dist/hooks/governance/exports.d.ts +24 -19
  27. package/dist/hooks/governance/exports.mjs +43 -53
  28. package/dist/{pol.d-Dw5SQcRX.d.ts → pol.d-CeRgXBL8.d.ts} +18 -4
  29. package/dist/types/exports.d.ts +5 -5
  30. package/dist/{useHoneySwapState-vFmuFF0g.d.ts → useHoneySwapState-twi7NTaO.d.ts} +1 -1
  31. package/dist/utils/exports.d.ts +2 -2
  32. package/dist/utils/exports.mjs +6 -2
  33. package/package.json +8 -7
  34. package/src/actions/bend/getMaxDeposit.ts +28 -2
  35. package/src/actions/clients/exports.ts +0 -1
  36. package/src/actions/clients/fetchBeep.ts +0 -7
  37. package/src/actions/clients/fetchOpenApi.ts +10 -6
  38. package/src/actions/clients/fetchOpenApi.unit.test.ts +20 -14
  39. package/src/actions/clients/getApolloClient.ts +4 -9
  40. package/src/actions/exports.ts +1 -1
  41. package/src/actions/honey/getChartData.ts +14 -14
  42. package/src/actions/honey/getHoney24hVolume.ts +17 -8
  43. package/src/actions/honey/getHoneyTxns.ts +45 -0
  44. package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +3 -3
  45. package/src/actions/pol/getEarnedStakedBeraVault.ts +0 -15
  46. package/src/actions/pol/getGlobalData.ts +10 -29
  47. package/src/actions/pol/getRewardVaults.ts +4 -4
  48. package/src/actions/pol/getSWBeraVaultMetadata.ts +0 -7
  49. package/src/actions/pol/getStakingDailyAssets.ts +0 -14
  50. package/src/actions/validators/getApiEnrichedAllocation.ts +1 -1
  51. package/src/actions/validators/getValidatorIncentiveDistribution.ts +43 -13
  52. package/src/contexts/SwrFallback.tsx +2 -1
  53. package/src/data/contracts.ts +4 -0
  54. package/src/errors/RequestError.ts +3 -3
  55. package/src/errors/getRevertReason.integration.test.ts +5 -1
  56. package/src/hooks/bend/useGetConvertToAssets.ts +3 -11
  57. package/src/hooks/dex/useAggregatorsQuotes.ts +13 -11
  58. package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +2 -7
  59. package/src/hooks/dex/useAllUserPools.ts +8 -13
  60. package/src/hooks/dex/useApiPool.ts +2 -9
  61. package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +1 -2
  62. package/src/hooks/dex/useOnChainPoolData.ts +3 -4
  63. package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +3 -9
  64. package/src/hooks/dex/usePoolEvents.ts +1 -2
  65. package/src/hooks/dex/usePoolHistoricalData.ts +3 -9
  66. package/src/hooks/dex/usePools.ts +6 -4
  67. package/src/hooks/dex/useSingleAggregatorQuote.ts +6 -18
  68. package/src/hooks/enso/useBendDemultiply.ts +3 -4
  69. package/src/hooks/enso/useBendMultiply.ts +3 -4
  70. package/src/hooks/enso/useBendZapSupply.ts +4 -5
  71. package/src/hooks/enso/useEnsoSwapBundle.ts +2 -2
  72. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +4 -10
  73. package/src/hooks/enso/useEnsoWalletV2Address.ts +1 -1
  74. package/src/hooks/enso/useIsBendAuthorized.ts +1 -1
  75. package/src/hooks/enso/useZapStakeBera.ts +2 -5
  76. package/src/hooks/exports.ts +1 -0
  77. package/src/hooks/governance/useGetPastVotes.ts +1 -1
  78. package/src/hooks/governance/useHasVoted.ts +1 -1
  79. package/src/hooks/governance/useIsCanceller.ts +1 -1
  80. package/src/hooks/governance/usePollAllProposals.ts +13 -12
  81. package/src/hooks/governance/usePollProposal.ts +7 -10
  82. package/src/hooks/governance/usePollProposalThreshold.ts +2 -7
  83. package/src/hooks/governance/usePollProposalVotes.ts +23 -5
  84. package/src/hooks/governance/usePollUserDelegates.ts +4 -9
  85. package/src/hooks/governance/useProposalFromTx.ts +4 -5
  86. package/src/hooks/governance/useProposalSnapshot.ts +3 -4
  87. package/src/hooks/governance/useProposalState.ts +3 -3
  88. package/src/hooks/governance/useProposalTimelockState.ts +3 -2
  89. package/src/hooks/governance/useQuorum.ts +1 -2
  90. package/src/hooks/honey/useCappedGlobally.ts +4 -12
  91. package/src/hooks/honey/useCappedRelatively.ts +3 -8
  92. package/src/hooks/honey/useCollateralWeights.ts +4 -9
  93. package/src/hooks/honey/useHoney24hVolume.ts +2 -6
  94. package/src/hooks/honey/useHoneyBalances.ts +2 -7
  95. package/src/hooks/honey/useHoneyChartData.ts +4 -12
  96. package/src/hooks/honey/useHoneyVaultsBalance.ts +3 -9
  97. package/src/hooks/honey/useIsBadCollateralAsset.ts +5 -13
  98. package/src/hooks/honey/useIsBasketModeEnabled.ts +5 -13
  99. package/src/hooks/honey/usePythLatestPrices.ts +15 -13
  100. package/src/hooks/perps/usePythUpdateFee.ts +13 -11
  101. package/src/hooks/pol/useAutoclaimedIncentives.ts +2 -8
  102. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +2 -8
  103. package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +34 -0
  104. package/src/hooks/pol/useBgtUnstakedBalance.ts +3 -8
  105. package/src/hooks/pol/useClaimableFees.ts +2 -6
  106. package/src/hooks/pol/useHighestVaultsAPR.ts +6 -11
  107. package/src/hooks/pol/useOnChainRewardVault.ts +77 -72
  108. package/src/hooks/pol/usePollGlobalData.ts +3 -9
  109. package/src/hooks/pol/usePollMarkets.ts +3 -8
  110. package/src/hooks/pol/useQueuedBeraUnlock.ts +3 -12
  111. package/src/hooks/pol/useRewardTokenToBeraRate.ts +2 -2
  112. package/src/hooks/pol/useRewardVault.ts +9 -8
  113. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +6 -6
  114. package/src/hooks/pol/useRewardVaultFromToken.ts +24 -30
  115. package/src/hooks/pol/useRewardVaultIncentives.ts +2 -7
  116. package/src/hooks/pol/useRewardVaultRewards.ts +3 -8
  117. package/src/hooks/pol/useRewardVaults.ts +4 -12
  118. package/src/hooks/pol/useStakedAPR.ts +2 -8
  119. package/src/hooks/pol/useStakedData.ts +90 -41
  120. package/src/hooks/pol/useStakedSnapshots.ts +4 -9
  121. package/src/hooks/pol/useStakingVaultsMetadata.ts +1 -1
  122. package/src/hooks/pol/useTotalStakedAmount.ts +2 -8
  123. package/src/hooks/pol/useUserVaultInfo.ts +3 -8
  124. package/src/hooks/pol/useUserVaults.ts +3 -8
  125. package/src/hooks/pol/useVaultAddress.ts +1 -1
  126. package/src/hooks/pol/useVaultHistory.ts +2 -8
  127. package/src/hooks/pol/useVaultValidators.ts +3 -8
  128. package/src/hooks/tokens/useMultipleTokenInformation.ts +3 -8
  129. package/src/hooks/tokens/usePollAllowances.ts +4 -11
  130. package/src/hooks/tokens/usePollBalance.ts +2 -5
  131. package/src/hooks/tokens/usePollWalletBalances.ts +3 -3
  132. package/src/hooks/tokens/useStakingTokenInformation.ts +3 -12
  133. package/src/hooks/tokens/useTokenCurrentPrices.ts +11 -13
  134. package/src/hooks/tokens/useTokenInformation.ts +3 -8
  135. package/src/hooks/tokens/useTokenPrice.ts +2 -1
  136. package/src/hooks/tokens/useTokenPrices.ts +3 -4
  137. package/src/hooks/tokens/useTotalSupply.ts +1 -1
  138. package/src/hooks/tokens/useUnderlyingAsset.ts +1 -2
  139. package/src/hooks/useBlockToTimestamp.ts +1 -2
  140. package/src/hooks/useGetVerifiedAbi.ts +2 -1
  141. package/src/hooks/validators/useAllValidators.ts +3 -9
  142. package/src/hooks/validators/useApiEnrichedAllocation.ts +1 -1
  143. package/src/hooks/validators/useApiValidator.ts +4 -12
  144. package/src/hooks/validators/useBaselineRewardAllocation.ts +1 -2
  145. package/src/hooks/validators/useDailyValidatorBlockStats.ts +2 -4
  146. package/src/hooks/validators/useDefaultRewardAllocation.ts +3 -9
  147. package/src/hooks/validators/useManagedValidatorRole.ts +2 -3
  148. package/src/hooks/validators/useOnChainValidator.ts +4 -11
  149. package/src/hooks/validators/useStakingPoolBatch.ts +4 -10
  150. package/src/hooks/validators/useUserActiveValidators.ts +3 -9
  151. package/src/hooks/validators/useUserBoostsOnValidator.ts +2 -4
  152. package/src/hooks/validators/useUserClaimableIncentives.ts +3 -3
  153. package/src/hooks/validators/useUserStakingPositions.ts +3 -9
  154. package/src/hooks/validators/useValidatorAnalytics.ts +2 -4
  155. package/src/hooks/validators/useValidatorCommission.ts +3 -8
  156. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +4 -6
  157. package/src/hooks/validators/useValidatorQueuedCommission.ts +3 -8
  158. package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +3 -8
  159. package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +3 -8
  160. package/src/hooks/validators/useValidatorRewardAllocation.ts +3 -8
  161. package/src/types/global.d.ts +7 -10
  162. package/src/types/pol.d.ts +17 -3
  163. package/dist/polling-BKnyavLI.d.ts +0 -8
  164. package/src/actions/clients/fetchRailwayBackend.ts +0 -34
  165. package/src/actions/pol/getGlobalCuttingBoard.ts +0 -25
  166. package/src/actions/pol/getIncentiveFeeClaimStats.ts +0 -24
@@ -5,9 +5,9 @@ import { beraFetchJson } from "../../utils/beraFetch";
5
5
 
6
6
  /**
7
7
  * A minimal, fully-typed GET helper for our `openapi-typescript`-generated
8
- * backends. Both backends serve only GETs, so rather than a full OpenAPI client
9
- * we type a single `fetchOpenApi` against a schema's `paths` and wrap it per
10
- * backend (`fetchBeep`, `fetchRailwayBackend`).
8
+ * `beep` backend. beep serves only GETs, so rather than a full OpenAPI client
9
+ * we type a single `fetchOpenApi` against a schema's `paths` and wrap it
10
+ * (`fetchBeep`).
11
11
  *
12
12
  * The `path`, its path/query params and the response body are all type-checked
13
13
  * against the schema, so route shapes can never drift out of sync with the
@@ -56,7 +56,7 @@ export type DefinedParams<Paths extends AnyPaths, P extends GetPath<Paths>> = {
56
56
  * @param params Path and query params, typed from the schema for `path`.
57
57
  * @param fallbackName Monitoring name to use when `link` is a bare string.
58
58
  */
59
- // biome-ignore lint/complexity/useMaxParams: internal helper; the wrappers (fetchBeep / fetchRailwayBackend) are the public surface.
59
+ // biome-ignore lint/complexity/useMaxParams: internal helper; the wrapper (fetchBeep) is the public surface.
60
60
  export function fetchOpenApi<Paths extends AnyPaths, P extends GetPath<Paths>>(
61
61
  link: HttpLink,
62
62
  path: P,
@@ -65,7 +65,7 @@ export function fetchOpenApi<Paths extends AnyPaths, P extends GetPath<Paths>>(
65
65
  ): Promise<GetResponse<Paths, P>> {
66
66
  const { path: pathParams, query } = params as {
67
67
  path?: Record<string, string | number>;
68
- query?: Record<string, string | number>;
68
+ query?: Record<string, string | number | undefined>;
69
69
  };
70
70
 
71
71
  // Substitute `{param}` placeholders from the typed path params.
@@ -80,9 +80,13 @@ export function fetchOpenApi<Paths extends AnyPaths, P extends GetPath<Paths>>(
80
80
  return encodeURIComponent(String(value));
81
81
  });
82
82
 
83
+ // Omit params whose value is `undefined` rather than serializing them as the
84
+ // literal string "undefined" (e.g. optional filters left unset by callers).
83
85
  const search = query
84
86
  ? new URLSearchParams(
85
- Object.entries(query).map(([k, v]) => [k, String(v)]),
87
+ Object.entries(query)
88
+ .filter(([, v]) => v !== undefined)
89
+ .map(([k, v]) => [k, String(v)]),
86
90
  ).toString()
87
91
  : "";
88
92
 
@@ -10,7 +10,6 @@ import {
10
10
 
11
11
  import type { HttpLink } from "@berachain/config";
12
12
  import { bepolia } from "@berachain/config/bepolia";
13
- import { mainnet } from "@berachain/config/mainnet";
14
13
 
15
14
  import type {
16
15
  paths as beepPaths,
@@ -72,6 +71,23 @@ describe("fetchOpenApi", () => {
72
71
  });
73
72
  });
74
73
 
74
+ it("omits query params whose value is undefined", async () => {
75
+ await fetchOpenApi<beepPaths, "/v0/honey/transactions/latest">(
76
+ NAMED_LINK,
77
+ "/v0/honey/transactions/latest",
78
+ // `perPage` is set; `page` is left undefined and must not be serialized
79
+ // as the literal string "undefined".
80
+ { query: { page: undefined, perPage: "10" } },
81
+ "beep",
82
+ );
83
+
84
+ expect(beraFetchJson).toHaveBeenCalledWith(
85
+ expect.objectContaining({
86
+ url: `${BASE}/v0/honey/transactions/latest?perPage=10`,
87
+ }),
88
+ );
89
+ });
90
+
75
91
  it("url-encodes path param values", async () => {
76
92
  // `pubkey` is a free-form string segment; reserved chars must be encoded.
77
93
  await fetchOpenApi<beepPaths, "/v0/validators/{pubkey}/incentives">(
@@ -152,21 +168,11 @@ describe("fetchBeep", () => {
152
168
  }),
153
169
  );
154
170
  });
155
-
156
- it("throws when config.beep is not set (e.g. mainnet)", () => {
157
- expect(() =>
158
- fetchBeep(
159
- "/v0/stake/{vault}/earnings/{owner}",
160
- { path: { vault: VAULT, owner: OWNER } },
161
- { config: mainnet },
162
- ),
163
- ).toThrow(/`beep` backend is not configured/);
164
- });
165
171
  });
166
172
 
167
- // Type-only assertions. The bodies are never executed at runtime (they would
168
- // hit the `beep` not-configured throw); they exist so `tsc` validates inference
169
- // and the `@ts-expect-error` lines. `expectTypeOf` is purely compile-time.
173
+ // Type-only assertions. The bodies are never executed at runtime; they exist so
174
+ // `tsc` validates inference and the `@ts-expect-error` lines. `expectTypeOf` is
175
+ // purely compile-time.
170
176
  describe("fetchBeep types", () => {
171
177
  it("infers the response type per path", () => {
172
178
  const _assert = () => {
@@ -82,15 +82,13 @@ function getClient(
82
82
 
83
83
  /**
84
84
  * Browser-reachable Apollo client factory for `api` and Bend's `whisk`
85
- * endpoints. Subgraph clients (honey/pol) are server-only; browser data
86
- * access goes through the typed `/api/honey/*` and `/api/pol/*` REST
87
- * endpoints. Same auth shape as bend.whiskApi — non-public env values only
88
- * resolve server-side.
85
+ * endpoints. The pol subgraph client is server-only; browser data access goes
86
+ * through the typed `/api/pol/*` REST endpoints. Same auth shape as
87
+ * bend.whiskApi — non-public env values only resolve server-side.
89
88
  */
90
- type GraphqlClient = "api" | "bend.whisk" | "honey.subgraph" | "pol.subgraph";
89
+ type GraphqlClient = "api" | "bend.whisk" | "pol.subgraph";
91
90
 
92
91
  const SUBGRAPH_CLIENTS = [
93
- "honey.subgraph",
94
92
  "pol.subgraph",
95
93
  ] as const satisfies readonly GraphqlClient[];
96
94
 
@@ -152,9 +150,6 @@ export function getApolloClient(
152
150
  }
153
151
  return store(cacheKey, getClient(config.bend.whiskApi));
154
152
 
155
- case "honey.subgraph":
156
- return store(cacheKey, getClient(config.honey.subgraph));
157
-
158
153
  case "pol.subgraph":
159
154
  return store(cacheKey, getClient(config.pol.subgraph));
160
155
  }
@@ -35,6 +35,7 @@ export * from "./honey/getHoneyPausedState";
35
35
  export * from "./honey/getHoneyPreview";
36
36
  export * from "./honey/getHoneyPythPriceOracle";
37
37
  export * from "./honey/getHoneyRootPriceOracle";
38
+ export * from "./honey/getHoneyTxns";
38
39
  export * from "./honey/getHoneyVaultsBalance";
39
40
  export * from "./honey/getPythLatestPrices";
40
41
  export * from "./honey/getRelativeCapLimit";
@@ -51,7 +52,6 @@ export * from "./pol/getBlockTime";
51
52
  export * from "./pol/getEarnedStakedBeraVault";
52
53
  export * from "./pol/getGlobalData";
53
54
  export * from "./pol/getHeroEarnVaults";
54
- export * from "./pol/getIncentiveFeeClaimStats";
55
55
  export * from "./pol/getLSTStakeConfig";
56
56
  export * from "./pol/getMarkets";
57
57
  export * from "./pol/getRewardProofsByValidator";
@@ -1,18 +1,21 @@
1
- import type { GetSnapshotsQuery } from "@berachain/graphql/honey";
1
+ import type { HoneySnapshotResponse } from "@berachain/graphql/beep";
2
2
 
3
3
  import { BeraError } from "../../errors/BeraError";
4
- import { beraFetchJson } from "../../utils/beraFetch";
4
+ import { fetchBeep } from "../clients/fetchBeep";
5
5
 
6
6
  /**
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).
7
+ * Browser-only. Returns daily honey snapshots in the `beep` response shape
8
+ * (`HoneySnapshotResponse`) the chart consumes.
9
+ *
10
+ * Reads from the `beep` backend (`fetchBeep`). Server callers must compose the
11
+ * upstream query directly (this action is not server-safe — `fetch` against a
12
+ * relative URL has no origin off-browser).
10
13
  */
11
14
  export async function getChartData({
12
15
  days,
13
16
  }: {
14
17
  days: number;
15
- }): Promise<GetSnapshotsQuery> {
18
+ }): Promise<HoneySnapshotResponse> {
16
19
  if (typeof window === "undefined") {
17
20
  throw new BeraError({
18
21
  message:
@@ -21,13 +24,10 @@ export async function getChartData({
21
24
  });
22
25
  }
23
26
 
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",
27
+ // beep backend (next-gen), typed against `@berachain/graphql/beep`. Queried
28
+ // directly from the browser — no Vercel proxy.
29
+ return fetchBeep("/v0/honey/snapshots/{interval}", {
30
+ path: { interval: "day" },
31
+ query: { perPage: String(days) },
31
32
  });
32
- return { honeySnapshots };
33
33
  }
@@ -1,10 +1,14 @@
1
- import type { GetSnapshotsQuery } from "@berachain/graphql/honey";
2
1
  import BigNumber from "@berachain/utils/pkg/bignumber.js";
3
2
 
4
3
  import { BeraError } from "../../errors/BeraError";
5
- import { beraFetchJson } from "../../utils/beraFetch";
4
+ import { fetchBeep } from "../clients/fetchBeep";
6
5
 
7
- /** Browser-only. Hits `/api/honey/snapshots?interval=hour&first=24` and reduces. */
6
+ /**
7
+ * Browser-only. Sums the last 24 hourly honey snapshots into a 24h volume.
8
+ *
9
+ * Reads from the `beep` backend (`fetchBeep`), which exposes `totalVolume` per
10
+ * snapshot.
11
+ */
8
12
  export async function getHoney24hVolume(): Promise<BigNumber | undefined> {
9
13
  if (typeof window === "undefined") {
10
14
  throw new BeraError({
@@ -14,12 +18,17 @@ export async function getHoney24hVolume(): Promise<BigNumber | undefined> {
14
18
  });
15
19
  }
16
20
 
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",
21
+ // beep backend (next-gen), typed against `@berachain/graphql/beep`. Queried
22
+ // directly from the browser — no Vercel proxy.
23
+ const snapshots = await fetchBeep("/v0/honey/snapshots/{interval}", {
24
+ path: { interval: "hour" },
25
+ query: { perPage: "24" },
22
26
  });
27
+
28
+ return sumTotalVolume(snapshots);
29
+ }
30
+
31
+ function sumTotalVolume(snapshots: { totalVolume: string }[]): BigNumber {
23
32
  return snapshots.reduce(
24
33
  (acc, curr) => new BigNumber(curr.totalVolume).plus(acc),
25
34
  new BigNumber(0),
@@ -0,0 +1,45 @@
1
+ import type { HoneyTransactionsLatestResponse } from "@berachain/graphql/beep";
2
+
3
+ import { BeraError } from "../../errors/BeraError";
4
+ import { fetchBeep } from "../clients/fetchBeep";
5
+
6
+ type HoneyTxn = HoneyTransactionsLatestResponse[number];
7
+ /** beep's transaction type discriminator (`"MINT" | "REDEEM"`). */
8
+ type HoneyTxnType = HoneyTxn["type"];
9
+
10
+ interface GetHoneyTxnsArgs {
11
+ /** Zero-based page index (the page size is applied internally). */
12
+ index: number;
13
+ /** Page size. */
14
+ limit: number;
15
+ /** Optional MINT/REDEEM filter; omit for all transactions. */
16
+ txnType?: HoneyTxnType;
17
+ }
18
+
19
+ /**
20
+ * Browser-only. Returns a page of honey transactions in the `beep` response
21
+ * shape (`HoneyTransactionsLatestResponse`) the transactions table consumes.
22
+ *
23
+ * Reads from the `beep` backend (`fetchBeep`).
24
+ */
25
+ export async function getHoneyTxns({
26
+ index,
27
+ limit,
28
+ txnType,
29
+ }: GetHoneyTxnsArgs): Promise<HoneyTransactionsLatestResponse> {
30
+ if (typeof window === "undefined") {
31
+ throw new BeraError({
32
+ message:
33
+ "getHoneyTxns is browser-only; call from a Client Component / SWR hook",
34
+ level: "error",
35
+ });
36
+ }
37
+
38
+ // beep backend (next-gen), typed against `@berachain/graphql/beep`. Queried
39
+ // directly from the browser — no Vercel proxy. beep's `page` is 1-indexed and
40
+ // filters server-side by `type`; `fetchOpenApi` omits `type` when `txnType`
41
+ // is undefined (the "all" tab), so each tab paginates its own filtered feed.
42
+ return fetchBeep("/v0/honey/transactions/latest", {
43
+ query: { page: String(index + 1), perPage: String(limit), type: txnType },
44
+ });
45
+ }
@@ -16,14 +16,14 @@ describe("rewardVaults", async () => {
16
16
  throw new Error("Failed to fetch vaults");
17
17
  }
18
18
 
19
- const { gaugeList } = result;
19
+ const { rewardVaultList } = result;
20
20
 
21
21
  it("should return vaults", () => {
22
- expect(gaugeList.length).toBeGreaterThan(0);
22
+ expect(rewardVaultList.length).toBeGreaterThan(0);
23
23
  });
24
24
 
25
25
  it("should have consistent data", () => {
26
- const totalBgtCatpure = gaugeList.reduce(
26
+ const totalBgtCatpure = rewardVaultList.reduce(
27
27
  (acc, vault) =>
28
28
  acc + Number(vault.dynamicData?.rewardCapturePercentage ?? 0),
29
29
  0,
@@ -1,8 +1,6 @@
1
1
  import type { Address } from "viem";
2
2
 
3
- import { parseBaseArgs } from "../../utils/parseBaseArgs";
4
3
  import { fetchBeep } from "../clients/fetchBeep";
5
- import { fetchRailwayBackend } from "../clients/fetchRailwayBackend";
6
4
 
7
5
  type GetEarnedStakedBeraVaultArgs = {
8
6
  /**
@@ -19,19 +17,6 @@ export async function getEarnedStakedBeraVault({
19
17
  account,
20
18
  ...args
21
19
  }: BeraJS.BaseFunctionArgs & GetEarnedStakedBeraVaultArgs) {
22
- const { config } = parseBaseArgs(args);
23
-
24
- // TODO(beep): remove this entire block once `beep` is deployed on every
25
- // chain. It is the only legacy-Railway-specific code left here; deleting it
26
- // leaves the `beep` path below as the sole implementation.
27
- if (!config.beep) {
28
- return fetchRailwayBackend(
29
- "/vaults/{vault}/earnings/{owner}",
30
- { path: { vault: address, owner: account } },
31
- args,
32
- );
33
- }
34
-
35
20
  // beep backend (next-gen), typed against `@berachain/graphql/beep`.
36
21
  return fetchBeep(
37
22
  "/v0/stake/{vault}/earnings/{owner}",
@@ -1,16 +1,12 @@
1
1
  import type { PublicClient } from "viem";
2
2
 
3
- import type { ApiVaultFragment } from "@berachain/graphql/pol/api";
4
-
5
3
  import { BeraMonitoring } from "../../errors/BeraMonitoring";
6
4
  import { initBeraError } from "../../errors/initBeraError";
7
5
  import { type GlobalInfo, getBGTGlobalInfo } from "./getBGTGlobalInfo";
8
6
  import { getBgtTokenTotalBoosts } from "./getBgtTokenTotalBoosts";
9
7
  import { getBgtTokenTotalSupply } from "./getBgtTokenTotalSupply";
10
- import { getGlobalCuttingBoard } from "./getGlobalCuttingBoard";
11
8
 
12
9
  export interface GlobalData extends GlobalInfo {
13
- globalCuttingBoard: ApiVaultFragment[] | undefined;
14
10
  bgtTotalSupply: string | undefined;
15
11
  bgtTotalBoosts: string | undefined;
16
12
  }
@@ -18,21 +14,16 @@ export interface GlobalData extends GlobalInfo {
18
14
  export async function getGlobalData(
19
15
  publicClient: PublicClient,
20
16
  ): Promise<GlobalData> {
21
- const [
22
- globalDataRes,
23
- globalCuttingBoardRes,
24
- bgtTotalSupplyRes,
25
- bgtTotalBoostsRes,
26
- ] = await Promise.allSettled([
27
- getBGTGlobalInfo(),
28
- getGlobalCuttingBoard(300),
29
- getBgtTokenTotalSupply({
30
- publicClient,
31
- }),
32
- getBgtTokenTotalBoosts({
33
- publicClient,
34
- }),
35
- ]);
17
+ const [globalDataRes, bgtTotalSupplyRes, bgtTotalBoostsRes] =
18
+ await Promise.allSettled([
19
+ getBGTGlobalInfo(),
20
+ getBgtTokenTotalSupply({
21
+ publicClient,
22
+ }),
23
+ getBgtTokenTotalBoosts({
24
+ publicClient,
25
+ }),
26
+ ]);
36
27
 
37
28
  if (globalDataRes.status === "rejected") {
38
29
  BeraMonitoring.captureException(
@@ -40,12 +31,6 @@ export async function getGlobalData(
40
31
  );
41
32
  }
42
33
 
43
- if (globalCuttingBoardRes.status === "rejected") {
44
- BeraMonitoring.captureException(
45
- initBeraError({ cause: globalCuttingBoardRes.reason, level: "warning" }),
46
- );
47
- }
48
-
49
34
  if (bgtTotalSupplyRes.status === "rejected") {
50
35
  BeraMonitoring.captureException(
51
36
  initBeraError({ cause: bgtTotalSupplyRes.reason, level: "warning" }),
@@ -63,10 +48,6 @@ export async function getGlobalData(
63
48
  bgtTotalSupplyRes.status === "fulfilled"
64
49
  ? bgtTotalSupplyRes.value
65
50
  : undefined,
66
- globalCuttingBoard:
67
- globalCuttingBoardRes.status === "fulfilled"
68
- ? globalCuttingBoardRes.value
69
- : [],
70
51
  bgtTotalBoosts:
71
52
  bgtTotalBoostsRes.status === "fulfilled"
72
53
  ? bgtTotalBoostsRes.value
@@ -11,8 +11,8 @@ import {
11
11
 
12
12
  import { getApolloClient } from "../clients/getApolloClient";
13
13
 
14
- export interface GetGaugeData {
15
- gaugeList: ApiVaultFragment[];
14
+ export interface GetRewardVaultData {
15
+ rewardVaultList: ApiVaultFragment[];
16
16
  pagination: {
17
17
  currentPage: number;
18
18
  totalCount: number;
@@ -26,7 +26,7 @@ export async function getRewardVaults({
26
26
  }: {
27
27
  filter?: GetVaultsQueryVariables;
28
28
  publicClient?: PublicClient | undefined;
29
- } & BeraJS.BaseFunctionArgs = {}): Promise<GetGaugeData> {
29
+ } & BeraJS.BaseFunctionArgs = {}): Promise<GetRewardVaultData> {
30
30
  const bexApiGraphqlClient = getApolloClient("api", args);
31
31
 
32
32
  const res = await bexApiGraphqlClient.query<
@@ -101,6 +101,6 @@ export async function getRewardVaults({
101
101
 
102
102
  return {
103
103
  pagination: res.data.polGetRewardVaults.pagination,
104
- gaugeList: vaults!,
104
+ rewardVaultList: vaults!,
105
105
  };
106
106
  }
@@ -3,7 +3,6 @@ import { type Address, erc20Abi, erc4626Abi, type PublicClient } from "viem";
3
3
  import BigNumber from "@berachain/utils/pkg/bignumber.js";
4
4
 
5
5
  import { assertPublicClient } from "../../errors/assert";
6
- import { getIncentiveFeeClaimStats } from "./getIncentiveFeeClaimStats";
7
6
  import { getStakeWithdrawalCooldown } from "./getStakeWithdrawalCooldown";
8
7
 
9
8
  export interface VaultMetadata {
@@ -21,8 +20,6 @@ export interface VaultMetadata {
21
20
  };
22
21
  totalWBeraIssued: string;
23
22
  lockPeriod?: number;
24
- totalBuyBacks: number;
25
- totalBuyBacksInLast24Hours: number;
26
23
  address: Address;
27
24
  }
28
25
  /**
@@ -63,7 +60,6 @@ export async function getSWBeraVaultMetadata({
63
60
  tvl24HoursAgo,
64
61
  underlyingTotalSupply,
65
62
  lockPeriod,
66
- incentiveFeeClaimStats,
67
63
  ] = await Promise.all([
68
64
  publicClient.readContract({
69
65
  address,
@@ -123,7 +119,6 @@ export async function getSWBeraVaultMetadata({
123
119
  publicClient,
124
120
  address,
125
121
  }),
126
- getIncentiveFeeClaimStats(),
127
122
  ]);
128
123
  const exchangeRateWindowAgo = new BigNumber(
129
124
  oneShareWorthWindowAgo.toString(),
@@ -157,8 +152,6 @@ export async function getSWBeraVaultMetadata({
157
152
  .dividedBy(1e18)
158
153
  .toString(),
159
154
  lockPeriod,
160
- totalBuyBacks: incentiveFeeClaimStats.sumAllClaims,
161
- totalBuyBacksInLast24Hours: incentiveFeeClaimStats.sumClaimsInLast24Hours,
162
155
  };
163
156
  } catch (error) {
164
157
  console.error("Failed to get SW Bera Vault Metadata", error);
@@ -1,8 +1,6 @@
1
1
  import type { Address } from "viem";
2
2
 
3
- import { parseBaseArgs } from "../../utils/parseBaseArgs";
4
3
  import { fetchBeep } from "../clients/fetchBeep";
5
- import { fetchRailwayBackend } from "../clients/fetchRailwayBackend";
6
4
 
7
5
  export async function getStakingDailyAssets({
8
6
  address,
@@ -11,18 +9,6 @@ export async function getStakingDailyAssets({
11
9
  address: Address;
12
10
  range: 30 | 60 | 90;
13
11
  }) {
14
- const { config } = parseBaseArgs({});
15
-
16
- // TODO(beep): remove this entire block once `beep` is deployed on every
17
- // chain. It is the only legacy-Railway-specific code left here; deleting it
18
- // leaves the `beep` path below as the sole implementation.
19
- if (!config.beep) {
20
- return fetchRailwayBackend("/vaults/{vault}/stats-by-day", {
21
- path: { vault: address },
22
- query: { days: `${range}` },
23
- });
24
- }
25
-
26
12
  // beep backend (next-gen), typed against `@berachain/graphql/beep`.
27
13
  return fetchBeep("/v0/stake/{vault}/stats-by-day", {
28
14
  path: { vault: address },
@@ -24,7 +24,7 @@ export async function getApiEnrichedAllocation({
24
24
  percentage: allocation.percentage,
25
25
  receiver: allocation.receiver,
26
26
  startBlock,
27
- receivingVault: vaults?.gaugeList.find((vault) =>
27
+ receivingVault: vaults?.rewardVaultList.find((vault) =>
28
28
  isAddressEqual(vault.address, allocation.receiver),
29
29
  ),
30
30
  };
@@ -1,18 +1,19 @@
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
- import { beraFetchJson } from "../../utils/beraFetch";
6
+ import { calculateTimestampFromDays } from "../../utils/formatTimestamps";
7
+ import { fetchBeep } from "../clients/fetchBeep";
7
8
 
8
- /** Browser-only. Hits `/api/pol/validator-incentive-distribution`. */
9
+ /** Browser-only. Reads validator incentive distribution from beep. */
9
10
  export async function getValidatorIncentiveDistribution({
10
11
  pubkey,
11
12
  dayRange,
12
13
  }: {
13
14
  pubkey: Address;
14
15
  dayRange: number;
15
- }): Promise<GetValidatorIncentiveDistributionQuery | undefined> {
16
+ }): Promise<ValidatorIncentivesResponse | undefined> {
16
17
  if (typeof window === "undefined") {
17
18
  throw new BeraError({
18
19
  message:
@@ -21,13 +22,42 @@ export async function getValidatorIncentiveDistribution({
21
22
  });
22
23
  }
23
24
 
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
- });
25
+ // beep backend (next-gen). It is a public (`NEXT_PUBLIC_*`) URL, so it can be
26
+ // called directly from the browser — no Vercel proxy.
27
+ //
28
+ // beep's `after` cursor is in seconds; `calculateTimestampFromDays` returns
29
+ // microseconds, matching the subgraph's `timestamp_gte`. Pin it to the start
30
+ // of the target day (UTC) so the cursor is stable within a day instead of
31
+ // sliding every second — beep buckets by `interval: "day"` anyway, and a
32
+ // stable value keeps requests cacheable.
33
+ const SECONDS_PER_DAY = 86_400;
34
+ const after = String(
35
+ Math.floor(
36
+ calculateTimestampFromDays(dayRange) / 1_000_000 / SECONDS_PER_DAY,
37
+ ) * SECONDS_PER_DAY,
38
+ );
39
+
40
+ // beep defaults to 100 rows/page, so page until a short page to gather the
41
+ // full range (matches the subgraph's `first: 1000`). In practice this is a
42
+ // single request — a busy validator is ~325 rows over the UI's max 90-day
43
+ // window, well under one page.
44
+ const PER_PAGE = 1000;
45
+ const rows: ValidatorIncentivesResponse = [];
46
+ let page = 1;
47
+ while (true) {
48
+ const pageRows = await fetchBeep("/v0/validators/{pubkey}/incentives", {
49
+ path: { pubkey },
50
+ query: {
51
+ interval: "day",
52
+ after,
53
+ page: String(page),
54
+ perPage: String(PER_PAGE),
55
+ },
56
+ });
57
+ rows.push(...pageRows);
58
+ if (pageRows.length < PER_PAGE) break;
59
+ page++;
60
+ }
61
+
62
+ return rows;
33
63
  }
@@ -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",
@@ -40,9 +40,9 @@ export class RequestError extends BeraError {
40
40
  "https://open-api.openocean.finance/v4/bera/swap",
41
41
  // vercel internal proxy
42
42
  "/api/aggregators?aggregator",
43
- // bonder endpoints have date-based query params (e.g. ?start=2025-11-28)
44
- mainnet.backend,
45
- // beep (next-gen backend) on testnet — same date-based bonder query params
43
+ // beep (next-gen backend) bonder endpoints have date-based query params
44
+ // (e.g. ?start=2025-11-28) on both networks
45
+ mainnet.beep,
46
46
  bepolia.beep,
47
47
  ];
48
48
 
@@ -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
  },