@berachain/berajs 0.2.2 → 0.2.4

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 (205) hide show
  1. package/.claude/skills/berajs/SKILL.md +222 -0
  2. package/.claude/skills/berajs/references/dex.md +235 -0
  3. package/.claude/skills/berajs/references/pol.md +194 -0
  4. package/.claude/skills/berajs/references/staking.md +198 -0
  5. package/.claude/skills/berajs/references/tokens.md +170 -0
  6. package/dist/{BexStatusProvider-nS3NcdxI.d.cts → BexStatusProvider-DRymVlQf.d.cts} +1 -1
  7. package/dist/{BexStatusProvider-nS3NcdxI.d.ts → BexStatusProvider-DRymVlQf.d.ts} +1 -1
  8. package/dist/{HoneyConfigProvider-CK6mOKFH.d.ts → HoneyConfigProvider-DVP_9KZn.d.ts} +1 -1
  9. package/dist/{HoneyConfigProvider-Ca3ouozs.d.cts → HoneyConfigProvider-DfkjmzEf.d.cts} +1 -1
  10. package/dist/abi/exports.cjs +1 -1
  11. package/dist/abi/exports.cjs.map +1 -1
  12. package/dist/abi/exports.d.cts +1893 -25347
  13. package/dist/abi/exports.d.ts +1893 -25347
  14. package/dist/abi/exports.mjs +1 -1
  15. package/dist/abi/exports.mjs.map +1 -1
  16. package/dist/actions/exports.cjs +1 -1
  17. package/dist/actions/exports.cjs.map +1 -1
  18. package/dist/actions/exports.d.cts +10 -9
  19. package/dist/actions/exports.d.ts +10 -9
  20. package/dist/actions/exports.mjs +1 -1
  21. package/dist/actions/exports.mjs.map +1 -1
  22. package/dist/chunk-4GU2O2OW.cjs +4 -0
  23. package/dist/chunk-4GU2O2OW.cjs.map +1 -0
  24. package/dist/chunk-5XWELBWR.mjs +2 -0
  25. package/dist/chunk-5XWELBWR.mjs.map +1 -0
  26. package/dist/chunk-BS6K7HGH.cjs +2 -0
  27. package/dist/chunk-BS6K7HGH.cjs.map +1 -0
  28. package/dist/chunk-NLVWRMGD.mjs +2 -0
  29. package/dist/chunk-NLVWRMGD.mjs.map +1 -0
  30. package/dist/chunk-OUD27MU7.cjs +2 -0
  31. package/dist/chunk-OUD27MU7.cjs.map +1 -0
  32. package/dist/chunk-RW3JFPED.mjs +4 -0
  33. package/dist/chunk-RW3JFPED.mjs.map +1 -0
  34. package/dist/chunk-S3EAKCVM.cjs +2 -0
  35. package/dist/{chunk-PKXAW6MO.cjs.map → chunk-S3EAKCVM.cjs.map} +1 -1
  36. package/dist/chunk-YNO7BCCM.mjs +2 -0
  37. package/dist/{chunk-3YXSUBA5.mjs.map → chunk-YNO7BCCM.mjs.map} +1 -1
  38. package/dist/contexts/exports.d.cts +3 -3
  39. package/dist/contexts/exports.d.ts +3 -3
  40. package/dist/enum/exports.d.cts +1 -1
  41. package/dist/enum/exports.d.ts +1 -1
  42. package/dist/errors/exports.d.cts +1 -1
  43. package/dist/errors/exports.d.ts +1 -1
  44. package/dist/{getValidatorQueuedOperatorAddress-RW4OMcD1.d.ts → getValidatorQueuedOperatorAddress-CqR6cyqC.d.ts} +3 -3
  45. package/dist/{getValidatorQueuedOperatorAddress-Dstyaomr.d.cts → getValidatorQueuedOperatorAddress-DZgrPmZ2.d.cts} +3 -3
  46. package/dist/{global.d-wYu8G8IQ.d.ts → global.d-BeYWDreg.d.ts} +5 -4
  47. package/dist/{global.d-CN6l2b9E.d.cts → global.d-DghRxpHd.d.cts} +5 -4
  48. package/dist/hooks/exports.cjs +3 -3
  49. package/dist/hooks/exports.cjs.map +1 -1
  50. package/dist/hooks/exports.d.cts +63 -39
  51. package/dist/hooks/exports.d.ts +63 -39
  52. package/dist/hooks/exports.mjs +3 -3
  53. package/dist/hooks/exports.mjs.map +1 -1
  54. package/dist/{txnEnum-BlBYhNRl.d.cts → txnEnum-DxPRHSJt.d.cts} +1 -1
  55. package/dist/{txnEnum-BlBYhNRl.d.ts → txnEnum-DxPRHSJt.d.ts} +1 -1
  56. package/dist/types/exports.d.cts +3 -3
  57. package/dist/types/exports.d.ts +3 -3
  58. package/dist/{useHoneySwapState-D1DKG_Of.d.ts → useHoneySwapState-B494PQDl.d.ts} +1 -1
  59. package/dist/{useHoneySwapState-B-vmIP1b.d.cts → useHoneySwapState-D6vpv19r.d.cts} +1 -1
  60. package/dist/utils/exports.cjs +1 -1
  61. package/dist/utils/exports.cjs.map +1 -1
  62. package/dist/utils/exports.d.cts +2 -2
  63. package/dist/utils/exports.d.ts +2 -2
  64. package/dist/utils/exports.mjs +1 -1
  65. package/dist/utils/exports.mjs.map +1 -1
  66. package/package.json +9 -10
  67. package/src/abi/exports.ts +0 -27
  68. package/src/actions/bend/getConvertToAssets.ts +1 -1
  69. package/src/actions/bend/getMaxDeposit.ts +1 -1
  70. package/src/actions/dex/aggregators/bex.ts +2 -1
  71. package/src/actions/dex/aggregators/enso/enso.ts +3 -2
  72. package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +2 -3
  73. package/src/actions/dex/aggregators/erc4626.ts +2 -1
  74. package/src/actions/dex/aggregators/fly.ts +2 -1
  75. package/src/actions/dex/aggregators/haiku.ts +2 -1
  76. package/src/actions/dex/aggregators/kyberswap.ts +2 -2
  77. package/src/actions/dex/aggregators/oogabooga.ts +2 -1
  78. package/src/actions/dex/aggregators/openOcean.ts +2 -1
  79. package/src/actions/dex/aggregators/wbera.ts +2 -1
  80. package/src/actions/dex/getVaultPausedState.ts +2 -1
  81. package/src/actions/enso/getEnsoUserTokensWithBalances.debug.test.ts +1 -1
  82. package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +2 -1
  83. package/src/actions/governance/__tests__/getDecodedFunctionData.integration.test.ts +66 -78
  84. package/src/actions/governance/__tests__/getQuorum.integration.test.ts +6 -7
  85. package/src/actions/governance/getDecodedFunctionData.ts +2 -2
  86. package/src/actions/governance/getProposalFromTx.ts +2 -1
  87. package/src/actions/governance/getProposalParams.ts +3 -2
  88. package/src/actions/governance/getQuorum.ts +2 -1
  89. package/src/actions/honey/getCollateralWeights.ts +2 -1
  90. package/src/actions/honey/getGlobalCapLimit.ts +2 -1
  91. package/src/actions/honey/getHoneyCollaterals.ts +2 -1
  92. package/src/actions/honey/getHoneyFees.ts +2 -1
  93. package/src/actions/honey/getHoneyPausedState.ts +2 -1
  94. package/src/actions/honey/getHoneyPreview.ts +2 -1
  95. package/src/actions/honey/getHoneyPythPriceOracle.ts +1 -1
  96. package/src/actions/honey/getHoneyRootPriceOracle.ts +2 -1
  97. package/src/actions/honey/getHoneyVaultsBalance.ts +3 -2
  98. package/src/actions/honey/getRelativeCapLimit.ts +2 -1
  99. package/src/actions/honey/getSharesWithoutFees.ts +3 -2
  100. package/src/actions/honey/getSwapPayload.ts +3 -2
  101. package/src/actions/honey/isBadCollateralAsset.ts +3 -2
  102. package/src/actions/honey/isBasketModeEnabled.ts +3 -2
  103. package/src/actions/pol/getBgtTokenTotalBoosts.ts +2 -1
  104. package/src/actions/pol/getLSTStakeConfig.ts +2 -1
  105. package/src/actions/pol/getRewardTokenToBeraRate.ts +2 -1
  106. package/src/actions/pol/getRewardVaultBeaconImplementation.ts +2 -1
  107. package/src/actions/pol/getRewardVaultDurationConstants.ts +2 -1
  108. package/src/actions/pol/getRewardVaultFromToken.ts +2 -1
  109. package/src/actions/pol/getRewardVaultIncentives.ts +2 -1
  110. package/src/actions/pol/getRewardVaultRewards.ts +2 -1
  111. package/src/actions/pol/getRewardVaultStakingToken.ts +1 -1
  112. package/src/actions/pol/getRewardVaults.ts +2 -1
  113. package/src/actions/pol/getSWBeraVaultMetadata.ts +2 -1
  114. package/src/actions/pol/getSWBeraWithdrawal.ts +2 -1
  115. package/src/actions/pol/getStakeWithdrawalCooldown.ts +1 -1
  116. package/src/actions/pol/getTotalStakedAmount.ts +2 -1
  117. package/src/actions/pol/getUserVaults.ts +2 -1
  118. package/src/actions/pol/getUserVaultsBalance.ts +2 -1
  119. package/src/actions/pol/getUserVaultsReward.ts +1 -1
  120. package/src/actions/pol/getVaultsSupply.ts +1 -1
  121. package/src/actions/pyth/getHoneyPythFeeds.ts +2 -1
  122. package/src/actions/transactions/beraWriteContract.integration.test.ts +48 -51
  123. package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +3 -2
  124. package/src/actions/validators/getBaselineRewardAllocation.ts +2 -1
  125. package/src/actions/validators/getDefaultRewardAllocation.ts +2 -1
  126. package/src/actions/validators/getUserBoostsOnValidator.ts +2 -1
  127. package/src/actions/validators/getValidatorCommission.ts +2 -1
  128. package/src/actions/validators/getValidatorOperatorAddress.ts +2 -1
  129. package/src/actions/validators/getValidatorQueuedCommission.ts +2 -1
  130. package/src/actions/validators/getValidatorQueuedOperatorAddress.ts +2 -1
  131. package/src/actions/validators/getValidatorQueuedRewardAllocation.ts +2 -1
  132. package/src/actions/validators/getValidatorRewardAllocation.ts +2 -1
  133. package/src/actions/validators/getValidatorRewardAllocatorAddress.ts +2 -1
  134. package/src/actions/validators/utils/__tests__/validatorUtils.integration.test.ts +10 -11
  135. package/src/errors/getRevertReason.integration.test.ts +115 -107
  136. package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +2 -1
  137. package/src/hooks/dex/useCreatePool.ts +2 -1
  138. package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +2 -1
  139. package/src/hooks/governance/useGetPastVotes.ts +2 -1
  140. package/src/hooks/governance/useHasVoted.ts +2 -1
  141. package/src/hooks/governance/useIsCanceller.ts +2 -1
  142. package/src/hooks/governance/usePollProposalThreshold.ts +2 -1
  143. package/src/hooks/governance/usePollUserDelegates.ts +2 -1
  144. package/src/hooks/governance/useProposalSnapshot.ts +2 -1
  145. package/src/hooks/governance/useProposalState.ts +2 -1
  146. package/src/hooks/governance/useProposalTimelockState.ts +5 -4
  147. package/src/hooks/pol/useBgtUnstakedBalance.ts +2 -1
  148. package/src/hooks/pol/useOnChainRewardVault.ts +2 -1
  149. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +2 -1
  150. package/src/hooks/pol/useRewardVaultFromToken.ts +2 -1
  151. package/src/hooks/pol/useStakedData.ts +169 -92
  152. package/src/hooks/validators/useOnChainValidator.ts +4 -3
  153. package/src/types/pol.d.ts +1 -0
  154. package/dist/chunk-3YXSUBA5.mjs +0 -2
  155. package/dist/chunk-A4UDYSB6.mjs +0 -4
  156. package/dist/chunk-A4UDYSB6.mjs.map +0 -1
  157. package/dist/chunk-CYKCYPFR.cjs +0 -2
  158. package/dist/chunk-CYKCYPFR.cjs.map +0 -1
  159. package/dist/chunk-ECRMUMTA.mjs +0 -2
  160. package/dist/chunk-ECRMUMTA.mjs.map +0 -1
  161. package/dist/chunk-F4BKSBEM.mjs +0 -2
  162. package/dist/chunk-F4BKSBEM.mjs.map +0 -1
  163. package/dist/chunk-FL2N3XHK.cjs +0 -2
  164. package/dist/chunk-FL2N3XHK.cjs.map +0 -1
  165. package/dist/chunk-MUCEYO3E.cjs +0 -4
  166. package/dist/chunk-MUCEYO3E.cjs.map +0 -1
  167. package/dist/chunk-P2Q7CMUD.cjs +0 -2
  168. package/dist/chunk-P2Q7CMUD.cjs.map +0 -1
  169. package/dist/chunk-PKXAW6MO.cjs +0 -2
  170. package/dist/chunk-Q3SCM6WL.mjs +0 -2
  171. package/dist/chunk-Q3SCM6WL.mjs.map +0 -1
  172. package/dist/chunk-TEBJWAVU.mjs +0 -2
  173. package/dist/chunk-TEBJWAVU.mjs.map +0 -1
  174. package/dist/chunk-VP7XUOSI.cjs +0 -2
  175. package/dist/chunk-VP7XUOSI.cjs.map +0 -1
  176. package/dist/pythWrapper-CBjsmmsK.d.cts +0 -1958
  177. package/dist/pythWrapper-CBjsmmsK.d.ts +0 -1958
  178. package/src/abi/bend/metaMorpho.ts +0 -2584
  179. package/src/abi/bend/morpho.ts +0 -444
  180. package/src/abi/bex/aggregatorsRouter.ts +0 -492
  181. package/src/abi/bex/balancerComposableStablePoolFactoryV6.ts +0 -283
  182. package/src/abi/bex/balancerPoolCreationHelper.ts +0 -267
  183. package/src/abi/bex/balancerVault.ts +0 -757
  184. package/src/abi/governance/governance.ts +0 -1016
  185. package/src/abi/governance/governanceTimelock.ts +0 -589
  186. package/src/abi/honey/collateralVault.ts +0 -1144
  187. package/src/abi/honey/honey.ts +0 -563
  188. package/src/abi/honey/honeyFactory.ts +0 -1270
  189. package/src/abi/honey/honeyFactoryReader.ts +0 -894
  190. package/src/abi/honey/honeyRootOracle.ts +0 -492
  191. package/src/abi/honey/pythPriceOracle.ts +0 -619
  192. package/src/abi/honey/pythWrapper.ts +0 -446
  193. package/src/abi/pol/LSTStakerVault.ts +0 -2032
  194. package/src/abi/pol/beaconDeposit.ts +0 -595
  195. package/src/abi/pol/beraChef.ts +0 -1019
  196. package/src/abi/pol/bgt.ts +0 -1008
  197. package/src/abi/pol/bgtIncentiveDistributor.ts +0 -640
  198. package/src/abi/pol/bgtStaker.ts +0 -1034
  199. package/src/abi/pol/rewardAllocationFactory.ts +0 -408
  200. package/src/abi/pol/rewardVault.ts +0 -1928
  201. package/src/abi/pol/rewardVaultFactory.ts +0 -586
  202. package/src/abi/pol/rewardVaultHelper.ts +0 -882
  203. package/src/abi/pol/stakeBeraVault.ts +0 -1116
  204. package/src/abi/pol/stakeBeraVaultWithdrawalRequest.ts +0 -618
  205. package/src/abi/pol/wbera.ts +0 -366
@@ -0,0 +1,198 @@
1
+ # BeraJS — Liquid Staking (swBERA) Reference
2
+
3
+ swBERA is Berachain's native liquid staking token. Users stake BERA (or WBERA) to receive swBERA, which accrues staking yield. LST (Liquid Staking Token) vaults follow the same pattern but for third-party protocols.
4
+
5
+ ## APR
6
+
7
+ ### `getStakedBeraAPR`
8
+
9
+ Server-side action. Returns the current APR as a plain `number` (e.g. `0.12` = 12%).
10
+
11
+ ```ts
12
+ import { getStakedBeraAPR } from "@berachain/berajs/actions";
13
+
14
+ const apr = await getStakedBeraAPR({ window: "DAY" });
15
+ // or window: "WEEK" for 7-day annualised APR
16
+ ```
17
+
18
+ This is typically cached server-side and passed down as a prop, since APR only updates every ~12 hours on the backend.
19
+
20
+ ## Vault Metadata
21
+
22
+ ### `useSWBeraVaultMetadata` / `getSWBeraVaultMetadata`
23
+
24
+ On-chain vault stats for a given receipt token address (e.g. swBERA contract address).
25
+
26
+ ```tsx
27
+ import { useSWBeraVaultMetadata } from "@berachain/berajs/hooks";
28
+ import { config } from "@berachain/config/internal";
29
+
30
+ const { data } = useSWBeraVaultMetadata(config.tokens.swbera);
31
+
32
+ // data: VaultMetadata | undefined
33
+ // {
34
+ // current: {
35
+ // exchangeRate: string, // how much BERA 1 swBERA redeems for (in wei, as string)
36
+ // totalSupply: string, // total swBERA supply (formatted, not wei)
37
+ // totalAssets: string, // total BERA staked (formatted)
38
+ // tvl: string, // total WBERA in vault (formatted)
39
+ // },
40
+ // previous: { ... }, // same shape, from ~26 hours ago
41
+ // totalWBeraIssued: string,
42
+ // lockPeriod?: number, // unstake cooldown in seconds (undefined if no lock)
43
+ // totalBuyBacks: number,
44
+ // totalBuyBacksInLast24Hours: number,
45
+ // }
46
+ ```
47
+
48
+ > Note: `useSWBeraVaultMetadata` requires `BlockTimeProvider` in the tree (provided by `BeraFlagsProvider`).
49
+
50
+ ## Staking Configs
51
+
52
+ ### `getLSTStakeConfig`
53
+
54
+ Server-side action. Resolves a list of LST vault addresses into `StakingConfig[]` by reading each vault's `asset()` on-chain.
55
+
56
+ ```ts
57
+ import { getLSTStakeConfig } from "@berachain/berajs/actions";
58
+ import { getServerSidePublicClient } from "@berachain/berajs/utils";
59
+
60
+ const publicClient = await getServerSidePublicClient();
61
+
62
+ // lstStakingVaults: Address[] from your config/edge config
63
+ const lstConfigs = await getLSTStakeConfig({
64
+ tokenList, // TokenWithMetadata[] — full token list to resolve symbols/metadata
65
+ publicClient,
66
+ lstStakingVaults, // vault contract addresses to resolve
67
+ });
68
+
69
+ // lstConfigs: StakingConfig[]
70
+ ```
71
+
72
+ **`StakingConfig` type:**
73
+ ```ts
74
+ type StakingConfig = {
75
+ id: string; // vault address
76
+ receiptToken: TokenWithMetadata; // e.g. swBERA token
77
+ inputTokens: TokenWithMetadata[]; // e.g. [BERA, WBERA]
78
+ };
79
+ ```
80
+
81
+ The native swBERA config is built manually (not via `getLSTStakeConfig`):
82
+
83
+ ```ts
84
+ const nativeStakingConfig: StakingConfig = {
85
+ id: swberaToken.address,
86
+ receiptToken: swberaToken,
87
+ inputTokens: [beraToken, wBeraToken],
88
+ };
89
+
90
+ const allConfigs = [nativeStakingConfig, ...lstConfigs];
91
+ ```
92
+
93
+ ## User Staked Positions & Earnings
94
+
95
+ ### `useStakedData`
96
+
97
+ The primary hook for user staking data. Loads in two phases for progressive rendering:
98
+
99
+ - **`balances`** (fast): staked amounts and USD values, earnings are `0`
100
+ - **`data`** (slow): full picture including earnings from the vault
101
+
102
+ ```tsx
103
+ import { useStakedData } from "@berachain/berajs/hooks";
104
+
105
+ const {
106
+ balances, // StakedBeraAsset[] | undefined — fast path, no earnings
107
+ data, // StakedBeraAsset[] | undefined — slow path, full earnings
108
+ isLoadingBalances, // true while fast path is pending
109
+ isLoadingPositions, // true while slow path is pending
110
+ } = useStakedData(stakingConfigs); // StakingConfig[]
111
+
112
+ // Show balances immediately, swap in data when available
113
+ const positions = data ?? balances ?? [];
114
+ const activePositions = positions.filter((p) => p.stakedAmount > 0);
115
+ ```
116
+
117
+ **`StakedBeraAsset` type:**
118
+ ```ts
119
+ type StakedBeraAsset = {
120
+ token: TokenWithMetadata; // the input token (e.g. BERA)
121
+ apr: number; // current APR as decimal (e.g. 0.12 = 12%)
122
+ stakedAmount: number; // staked amount in token units
123
+ stakedAmountUsd: number; // USD value of staked amount
124
+ earnedAmount: number; // unrealised earnings in token units (0 on fast path)
125
+ earnedAmountUsd: number; // USD value of earnings (0 on fast path)
126
+ isLoadingEarnings?: boolean; // true on fast path while earnings are still loading
127
+ };
128
+ ```
129
+
130
+ ## Queued Withdrawals
131
+
132
+ ### `useQueuedBeraUnlock`
133
+
134
+ Fetches pending (queued but not yet claimable) withdrawals for a user.
135
+
136
+ ```tsx
137
+ import { useQueuedBeraUnlock } from "@berachain/berajs/hooks";
138
+
139
+ const { data: queuedWithdrawals } = useQueuedBeraUnlock({
140
+ receiptTokenAddresses: stakingConfigs.map((c) => c.receiptToken.address),
141
+ account,
142
+ version: "V2", // always "V2" for new deployments
143
+ });
144
+
145
+ const totalQueued = queuedWithdrawals?.reduce(
146
+ (sum, q) => sum + Number(q.withdrawalAmount),
147
+ 0,
148
+ ) ?? 0;
149
+ const hasQueuedWithdrawal = totalQueued > 0;
150
+ ```
151
+
152
+ ## Key Types
153
+
154
+ ```ts
155
+ import type { StakingConfig, StakedBeraAsset } from "@berachain/berajs/types";
156
+ import type { VaultMetadata } from "@berachain/berajs/actions";
157
+ ```
158
+
159
+ ## Complete Example: Staked Balance Display
160
+
161
+ ```tsx
162
+ "use client";
163
+ import { useStakedData } from "@berachain/berajs/hooks";
164
+ import type { StakingConfig } from "@berachain/berajs/types";
165
+
166
+ export function StakedBalance({ configs }: { configs: StakingConfig[] }) {
167
+ const { balances, data: positions, isLoadingBalances } = useStakedData(configs);
168
+
169
+ // Use full positions when available, otherwise show balances immediately
170
+ const source = positions ?? balances ?? [];
171
+ const active = source.filter((p) => p.stakedAmount > 0);
172
+
173
+ const totalStaked = active.reduce((sum, p) => sum + p.stakedAmountUsd, 0);
174
+ const totalEarned = active.reduce((sum, p) => sum + p.earnedAmountUsd, 0);
175
+ const hasPositions = !!positions;
176
+
177
+ if (!isLoadingBalances && active.length === 0) {
178
+ return <p>No staked assets.</p>;
179
+ }
180
+
181
+ return (
182
+ <div>
183
+ <p>Total Staked: ${totalStaked.toFixed(2)}</p>
184
+ <p>Total Earnings: {hasPositions ? `$${totalEarned.toFixed(2)}` : "..."}</p>
185
+ {active.map((asset) => (
186
+ <div key={asset.token.address}>
187
+ <span>{asset.token.symbol}</span>
188
+ <span>{asset.stakedAmount.toFixed(4)} staked</span>
189
+ <span>
190
+ {asset.isLoadingEarnings ? "..." : `${asset.earnedAmount.toFixed(4)} earned`}
191
+ </span>
192
+ <span>APR: {(asset.apr * 100).toFixed(2)}%</span>
193
+ </div>
194
+ ))}
195
+ </div>
196
+ );
197
+ }
198
+ ```
@@ -0,0 +1,170 @@
1
+ # BeraJS — Tokens Reference
2
+
3
+ ## Wallet Balances
4
+
5
+ ### `usePollWalletBalances` / `getWalletBalances`
6
+
7
+ Fetch all ERC-20 token balances for a wallet address.
8
+
9
+ ```tsx
10
+ import { usePollWalletBalances } from "@berachain/berajs/hooks";
11
+
12
+ const { data: balances, isLoading } = usePollWalletBalances({
13
+ account: "0x...",
14
+ });
15
+
16
+ // balances: BalanceToken[]
17
+ balances?.map((token) => (
18
+ <div key={token.address}>
19
+ {token.symbol}: {token.balance.formatted} (${token.usdValue?.toFixed(2)})
20
+ </div>
21
+ ));
22
+ ```
23
+
24
+ ```ts
25
+ // Server-side:
26
+ import { getWalletBalances } from "@berachain/berajs/actions";
27
+ const balances = await getWalletBalances({ account: "0x..." });
28
+ ```
29
+
30
+ **`BalanceToken` type:**
31
+ ```ts
32
+ type BalanceToken = Token & {
33
+ balance: {
34
+ raw: string; // wei as string — safe to pass to BigInt()
35
+ formatted: string; // human-readable e.g. "1.5"
36
+ };
37
+ price?: number; // USD price per token
38
+ usdValue?: number; // balance * price
39
+ };
40
+ ```
41
+
42
+ ## Allowances
43
+
44
+ ### `usePollAllowances` / `getAllowances`
45
+
46
+ Check ERC-20 spending approvals. Returns whether each token needs approval before a transaction.
47
+
48
+ ```tsx
49
+ import { usePollAllowances } from "@berachain/berajs/hooks";
50
+ import type { AllowanceQueryItem } from "@berachain/berajs/types";
51
+
52
+ const items: AllowanceQueryItem[] = [{
53
+ token: {
54
+ address: "0xHONEY",
55
+ decimals: 18,
56
+ symbol: "HONEY",
57
+ name: "Honey",
58
+ chainId: 80094,
59
+ },
60
+ amount: { raw: "1000000000000000000", formatted: "1.0" },
61
+ spender: "0xVaultAddress",
62
+ }];
63
+
64
+ const { data: allowances } = usePollAllowances({
65
+ account: "0x...",
66
+ allowanceQueryList: items,
67
+ });
68
+
69
+ // allowances[0].needsApproval → true if approval required before tx
70
+ // allowances[0].allowance.formatted → current approved amount
71
+ ```
72
+
73
+ ## Token Metadata
74
+
75
+ ### `useTokenInformation` / `getTokenInformation`
76
+
77
+ Resolve a token address to its metadata.
78
+
79
+ ```ts
80
+ import { useTokenInformation } from "@berachain/berajs/hooks";
81
+
82
+ const { data: token } = useTokenInformation({ address: "0x..." });
83
+ // token: TokenWithMetadata | undefined
84
+ // { address, decimals, symbol, name, chainId, logoURI?, tags? }
85
+ ```
86
+
87
+ ## Prices
88
+
89
+ ### `useTokenCurrentPrices` / `getTokenCurrentPrices`
90
+
91
+ USD prices for multiple tokens at once.
92
+
93
+ ```tsx
94
+ import { useTokenCurrentPrices } from "@berachain/berajs/hooks";
95
+
96
+ const { data: priceMap } = useTokenCurrentPrices({
97
+ tokenAddresses: ["0xHONEY", "0xWBERA"],
98
+ });
99
+
100
+ // priceMap: TokenCurrentPriceMap
101
+ // priceMap["0xhoney"]?.price → 1.0
102
+ // Keys are lowercased addresses
103
+ ```
104
+
105
+ ## Key Types
106
+
107
+ ```ts
108
+ // Base for all tokens
109
+ type MinimalERC20 = {
110
+ address: Address;
111
+ decimals: number;
112
+ symbol: string;
113
+ name: string;
114
+ chainId: number;
115
+ };
116
+
117
+ // Full token with optional display metadata
118
+ type Token = MinimalERC20 & {
119
+ tags?: string[];
120
+ logoURI?: string;
121
+ totalSupply?: string;
122
+ weight?: number | string | null;
123
+ };
124
+
125
+ // For allowance checking
126
+ type AllowanceQueryItem = {
127
+ token: MinimalERC20;
128
+ amount: { raw: string; formatted: string };
129
+ spender: Address;
130
+ };
131
+
132
+ type AllowanceToken = AllowanceQueryItem & {
133
+ allowance: { raw: string; formatted: string };
134
+ needsApproval: boolean;
135
+ };
136
+ ```
137
+
138
+ ## Complete Example: Token Balance List
139
+
140
+ ```tsx
141
+ "use client";
142
+ import { usePollWalletBalances } from "@berachain/berajs/hooks";
143
+ import { useAccount } from "wagmi";
144
+
145
+ export function TokenBalanceList() {
146
+ const { address } = useAccount();
147
+ const { data: balances, isLoading } = usePollWalletBalances(
148
+ { account: address },
149
+ { opts: { isEnabled: !!address } }
150
+ );
151
+
152
+ if (!address) return <div>Connect wallet</div>;
153
+ if (isLoading) return <div>Loading...</div>;
154
+ if (!balances?.length) return <div>No tokens found</div>;
155
+
156
+ return (
157
+ <ul>
158
+ {balances.map((token) => (
159
+ <li key={token.address}>
160
+ <span>{token.symbol}</span>
161
+ <span>{token.balance.formatted}</span>
162
+ {token.usdValue !== undefined && (
163
+ <span>${token.usdValue.toFixed(2)}</span>
164
+ )}
165
+ </li>
166
+ ))}
167
+ </ul>
168
+ );
169
+ }
170
+ ```
@@ -67,4 +67,4 @@ declare function useBexStatus(): {
67
67
  };
68
68
  declare function BexStatusProvider({ children, isVaultPaused, labels, factories, }: PropsWithChildren<BexStatusProviderProps>): react_jsx_runtime.JSX.Element;
69
69
 
70
- export { type BexStatusProviderProps as B, BexStateContext as a, BexStatusProvider as b, useBexStatus as u };
70
+ export { BexStateContext as B, BexStatusProvider as a, type BexStatusProviderProps as b, useBexStatus as u };
@@ -67,4 +67,4 @@ declare function useBexStatus(): {
67
67
  };
68
68
  declare function BexStatusProvider({ children, isVaultPaused, labels, factories, }: PropsWithChildren<BexStatusProviderProps>): react_jsx_runtime.JSX.Element;
69
69
 
70
- export { type BexStatusProviderProps as B, BexStateContext as a, BexStatusProvider as b, useBexStatus as u };
70
+ export { BexStateContext as B, BexStatusProvider as a, type BexStatusProviderProps as b, useBexStatus as u };
@@ -387,4 +387,4 @@ interface HoneyConfigProviderProps extends HoneyConfigContextReturn {
387
387
  declare function HoneyConfigProvider({ children, ...props }: HoneyConfigProviderProps): react_jsx_runtime.JSX.Element;
388
388
  declare function useHoneyConfig(): HoneyConfigContextReturn;
389
389
 
390
- export { type AllowanceQueryItem as A, type BalanceToken as B, type CollateralRates as C, type IAggregatorQuote as D, type HoneySwapActions as H, type IAggregatorArgs as I, type MinimalERC20 as M, type PythLatestUpdates as P, type SwapRequest as S, type TokenWithOrder as T, type TokenWithMetadata as a, type Token as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, type HoneyConfigProviderProps as e, HoneyConfigProvider as f, type IRawAggregatorQuote as g, type PythPriceFeedMap as h, type TokenCurrentPriceMap as i, type AllowanceToken as j, type HoneyFeeMap as k, type CollateralRatesArgs as l, getHoneyFees as m, HoneyPreviewMethod as n, type HoneyPreviewArgs as o, type HoneyPreviewResult as p, type HoneyPreviewReadResult as q, getHoneyPreview as r, getPythLatestPrices as s, type TokenWithAmount as t, useHoneyConfig as u, type IUserPosition as v, type Calldata as w, type TokenPriceInfo as x, type TokenWithPrice as y, type BexStatus as z };
390
+ export { type AllowanceQueryItem as A, type BalanceToken as B, type CollateralRates as C, type TokenWithPrice as D, type HoneySwapActions as H, type IAggregatorArgs as I, type MinimalERC20 as M, type PythLatestUpdates as P, type SwapRequest as S, type TokenWithOrder as T, type TokenWithMetadata as a, type Token as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, HoneyConfigProvider as e, type HoneyConfigProviderProps as f, type IRawAggregatorQuote as g, type PythPriceFeedMap as h, type TokenCurrentPriceMap as i, type AllowanceToken as j, type CollateralRatesArgs as k, type HoneyFeeMap as l, type HoneyPreviewArgs as m, HoneyPreviewMethod as n, type HoneyPreviewReadResult as o, type HoneyPreviewResult as p, getHoneyFees as q, getHoneyPreview as r, getPythLatestPrices as s, type TokenWithAmount as t, useHoneyConfig as u, type IUserPosition as v, type Calldata as w, type TokenPriceInfo as x, type BexStatus as y, type IAggregatorQuote as z };
@@ -387,4 +387,4 @@ interface HoneyConfigProviderProps extends HoneyConfigContextReturn {
387
387
  declare function HoneyConfigProvider({ children, ...props }: HoneyConfigProviderProps): react_jsx_runtime.JSX.Element;
388
388
  declare function useHoneyConfig(): HoneyConfigContextReturn;
389
389
 
390
- export { type AllowanceQueryItem as A, type BalanceToken as B, type CollateralRates as C, type IAggregatorQuote as D, type HoneySwapActions as H, type IAggregatorArgs as I, type MinimalERC20 as M, type PythLatestUpdates as P, type SwapRequest as S, type TokenWithOrder as T, type TokenWithMetadata as a, type Token as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, type HoneyConfigProviderProps as e, HoneyConfigProvider as f, type IRawAggregatorQuote as g, type PythPriceFeedMap as h, type TokenCurrentPriceMap as i, type AllowanceToken as j, type HoneyFeeMap as k, type CollateralRatesArgs as l, getHoneyFees as m, HoneyPreviewMethod as n, type HoneyPreviewArgs as o, type HoneyPreviewResult as p, type HoneyPreviewReadResult as q, getHoneyPreview as r, getPythLatestPrices as s, type TokenWithAmount as t, useHoneyConfig as u, type IUserPosition as v, type Calldata as w, type TokenPriceInfo as x, type TokenWithPrice as y, type BexStatus as z };
390
+ export { type AllowanceQueryItem as A, type BalanceToken as B, type CollateralRates as C, type TokenWithPrice as D, type HoneySwapActions as H, type IAggregatorArgs as I, type MinimalERC20 as M, type PythLatestUpdates as P, type SwapRequest as S, type TokenWithOrder as T, type TokenWithMetadata as a, type Token as b, HoneyConfigContext as c, type HoneyConfigContextReturn as d, HoneyConfigProvider as e, type HoneyConfigProviderProps as f, type IRawAggregatorQuote as g, type PythPriceFeedMap as h, type TokenCurrentPriceMap as i, type AllowanceToken as j, type CollateralRatesArgs as k, type HoneyFeeMap as l, type HoneyPreviewArgs as m, HoneyPreviewMethod as n, type HoneyPreviewReadResult as o, type HoneyPreviewResult as p, getHoneyFees as q, getHoneyPreview as r, getPythLatestPrices as s, type TokenWithAmount as t, useHoneyConfig as u, type IUserPosition as v, type Calldata as w, type TokenPriceInfo as x, type BexStatus as y, type IAggregatorQuote as z };