@berachain/berajs 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/dist/BeraError-CfcNTfpH.d.ts +69 -0
  4. package/dist/BexStatusProvider-nS3NcdxI.d.ts +70 -0
  5. package/dist/RequestError-CtJLUaAc.d.ts +57 -0
  6. package/dist/abi/index.d.ts +26765 -0
  7. package/dist/abi/index.mjs +1 -0
  8. package/dist/actions/index.d.ts +1649 -0
  9. package/dist/actions/index.mjs +1 -0
  10. package/dist/aggregatorsRouter-Cny4B_MB.d.ts +593 -0
  11. package/dist/chunk-4IBBLGNS.mjs +1 -0
  12. package/dist/chunk-5GPS724E.mjs +1 -0
  13. package/dist/chunk-5UFI7X4U.mjs +1 -0
  14. package/dist/chunk-AHAZC5K3.mjs +1 -0
  15. package/dist/chunk-JQDPAEK2.mjs +2 -0
  16. package/dist/chunk-K4NZIO2Z.mjs +1 -0
  17. package/dist/chunk-MTBICGRP.mjs +1 -0
  18. package/dist/chunk-RNESAHY2.mjs +3 -0
  19. package/dist/chunk-SMZ3PG6A.mjs +1 -0
  20. package/dist/chunk-XX77QPIR.mjs +1 -0
  21. package/dist/chunk-YKNKCICU.mjs +1 -0
  22. package/dist/contexts/index.d.ts +81 -0
  23. package/dist/contexts/index.mjs +1 -0
  24. package/dist/defaultFlags-V-tJs2K8.d.ts +10 -0
  25. package/dist/dex-BD7Bq3pJ.d.ts +562 -0
  26. package/dist/dex-DreiokgL.d.ts +562 -0
  27. package/dist/enum/index.d.ts +31 -0
  28. package/dist/enum/index.mjs +1 -0
  29. package/dist/errors/index.d.ts +204 -0
  30. package/dist/errors/index.mjs +1 -0
  31. package/dist/getValidatorQueuedOperatorAddress--AXNo9IY.d.ts +440 -0
  32. package/dist/getValidatorQueuedOperatorAddress-DK2Xv19c.d.ts +440 -0
  33. package/dist/hooks/index.d.ts +1703 -0
  34. package/dist/hooks/index.mjs +3 -0
  35. package/dist/polling-BKnyavLI.d.ts +8 -0
  36. package/dist/pythWrapper-CBjsmmsK.d.ts +1958 -0
  37. package/dist/staking-Cggi38So.d.ts +246 -0
  38. package/dist/staking-DYbVFigB.d.ts +246 -0
  39. package/dist/txnEnum-BQKDfaeH.d.ts +81 -0
  40. package/dist/txnEnum-Diichv9Z.d.ts +80 -0
  41. package/dist/types/index.d.ts +56 -0
  42. package/dist/types/index.mjs +1 -0
  43. package/dist/useHoneySwapState-CW49RVci.d.ts +32 -0
  44. package/dist/useHoneySwapState-Ci8_c2bT.d.ts +32 -0
  45. package/dist/utils/index.d.ts +349 -0
  46. package/dist/utils/index.mjs +1 -0
  47. package/package.json +64 -0
@@ -0,0 +1,440 @@
1
+ import { Address, PublicClient, Hex } from 'viem';
2
+ import { GqlPoolType, GlobalDataQuery, ApiVaultFragment, GetVaultsQueryVariables, GqlChain, GqlVaultSnapshotDataRange, GetSWberaVaultSnapshotsQuery, GetVaultHistoryQueryVariables, GetVaultHistoryQuery, ApiValidatorFragment } from '@berachain/graphql/pol/api';
3
+ import { h as TokenBalance, a as Token, P as PythLatestUpdates } from './dex-DreiokgL.js';
4
+ import { P as ProtocolMetadata } from './staking-Cggi38So.js';
5
+ import { GetPublicClientReturnType } from '@wagmi/core';
6
+
7
+ interface GetConvertToAssetsProps {
8
+ sharesAmount: bigint;
9
+ vaultAddress: Address;
10
+ publicClient: PublicClient;
11
+ }
12
+ declare function getConvertToAssets({ sharesAmount, vaultAddress, publicClient, }: GetConvertToAssetsProps): Promise<{
13
+ raw: bigint;
14
+ formatted: string;
15
+ }>;
16
+
17
+ interface PoolStatus {
18
+ isPoolInRecoveryMode: boolean;
19
+ isPoolPaused: boolean;
20
+ }
21
+ declare function getPoolPausedState({ publicClient, poolAddress, }: {
22
+ publicClient: PublicClient;
23
+ poolAddress: Address;
24
+ }): Promise<PoolStatus>;
25
+
26
+ interface OnChainPool {
27
+ pausedState: PoolStatus;
28
+ address: Address;
29
+ id: Hex;
30
+ name: string;
31
+ poolTokens: [
32
+ /**
33
+ * The addresses of the tokens in the pool
34
+ */
35
+ readonly Address[],
36
+ /**
37
+ * The balances of the tokens in the pool
38
+ */
39
+ string[],
40
+ /**
41
+ * The last change block of the pool
42
+ */
43
+ number
44
+ ];
45
+ totalSupply: string;
46
+ swapFee: string;
47
+ decimals: number;
48
+ weights: readonly string[] | undefined;
49
+ version: any;
50
+ factory: Address;
51
+ type: GqlPoolType;
52
+ /**
53
+ * For example, if value is 300000n and precision is 1000n, the user-set amplification parameter would be 300000n / 1000n = 300n.
54
+ *
55
+ * The first number is the raw value, the second number is a boolean indicating if the amplification parameter is being updated, and the third number is the precision factor.
56
+ * @see https://github.com/balancer/docs-developers/blob/main/references/valuing-balancer-lp-tokens/pools/stablepools.md#getamplificationparameter
57
+ */
58
+ amplificationParameter: readonly [number, boolean, number] | undefined;
59
+ }
60
+ declare function getOnChainPool({ poolId, publicClient, ...args }: {
61
+ poolId: string;
62
+ publicClient: PublicClient;
63
+ } & BeraJS.BaseFunctionArgs): Promise<OnChainPool>;
64
+
65
+ interface GetVaultsBalancesArgs extends BeraJS.BaseFunctionArgs {
66
+ client: PublicClient;
67
+ collateralList: Token[];
68
+ honeyFactoryAddress?: Address;
69
+ }
70
+ interface GetHoneyVaultsBalanceResponse extends TokenBalance {
71
+ vault: Address;
72
+ }
73
+ declare function getHoneyVaultsBalance({ client, collateralList, honeyFactoryAddress, ...args }: GetVaultsBalancesArgs): Promise<GetHoneyVaultsBalanceResponse[]>;
74
+
75
+ interface IsBadCollateralArgs extends BeraJS.BaseFunctionArgs {
76
+ client: PublicClient;
77
+ collateral: Token;
78
+ latestPrices: PythLatestUpdates | undefined;
79
+ isPythWrapperEnabled: boolean;
80
+ }
81
+ interface IsBadCollateralResponse {
82
+ isBlacklisted: boolean;
83
+ isDepegged: boolean;
84
+ }
85
+ /**
86
+ * Checks if a given collateral asset is considered bad, either by being blacklisted or depegged.
87
+ *
88
+ * @param {Object} args - The arguments object.
89
+ * @param {PublicClient} args.client - The client used to interact with the blockchain.
90
+ * @param {Token} args.collateral - The collateral asset to check.
91
+ *
92
+ * @returns {Promise<IsBadCollateralResponse | undefined>} An object indicating if the collateral is blacklisted or depegged.
93
+ */
94
+ declare function isBadCollateralAsset({ client, collateral, latestPrices, isPythWrapperEnabled, ...args }: IsBadCollateralArgs): Promise<IsBadCollateralResponse | undefined>;
95
+
96
+ declare enum RewardVaultDistributionMode {
97
+ Duration = "duration",
98
+ TargetRate = "targetRate",
99
+ TargetApr = "targetApr"
100
+ }
101
+ interface GetRewardVaultRewardsReturn {
102
+ rewardsDuration: number;
103
+ manager: Address;
104
+ /**
105
+ * The amount of BGT that will be distributed per second
106
+ */
107
+ rewardRate: string;
108
+ /**
109
+ * The timestamp when rewards will be depleted
110
+ */
111
+ periodFinish: number;
112
+ /**
113
+ * The amount of BGT that will be distributed from now until the periodFinish timestamp
114
+ */
115
+ availableRewards: string;
116
+ /**
117
+ * The amount of BGT that will be distributed per second.
118
+ *
119
+ * If this is 0, the duration mode is active.
120
+ */
121
+ targetRewardsPerSecond: string;
122
+ /**
123
+ * The minimum reward duration for the target rate
124
+ */
125
+ minRewardDurationForTargetRate: number;
126
+ /**
127
+ * The current mode of the vault
128
+ */
129
+ mode: RewardVaultDistributionMode.Duration | RewardVaultDistributionMode.TargetRate;
130
+ }
131
+ declare function getRewardVaultRewards(address: Address, publicClient: PublicClient): Promise<GetRewardVaultRewardsReturn>;
132
+
133
+ type GetBgtAprSimulationArgs = {
134
+ /**
135
+ * Staked TVL of the vault in USD.
136
+ *
137
+ * Null if not available
138
+ */
139
+ tvl: number | null;
140
+ /**
141
+ * Price of BGT in USD
142
+ */
143
+ bgtPrice: number;
144
+ /**
145
+ * Undistributed BGT rewards
146
+ */
147
+ availableRewards: number;
148
+ /**
149
+ * Finish period of the reward distribution in seconds
150
+ */
151
+ periodFinish: number;
152
+ /**
153
+ * Current duration of the reward distribution in seconds. This will be used if the reward rate is 0.
154
+ *
155
+ */
156
+ currentDuration: number;
157
+ /**
158
+ * Maximum reward duration in seconds
159
+ */
160
+ MAX_REWARD_DURATION: number;
161
+ /**
162
+ * Minimum reward duration in seconds
163
+ */
164
+ MIN_REWARD_DURATION: number;
165
+ } & ({
166
+ /**
167
+ *
168
+ */
169
+ mode: RewardVaultDistributionMode.TargetApr;
170
+ apr: number;
171
+ /**
172
+ * Minimum reward duration for the target rate
173
+ */
174
+ minRewardDurationForTargetRate: number;
175
+ } | {
176
+ /**
177
+ *
178
+ */
179
+ mode: RewardVaultDistributionMode.TargetRate;
180
+ rewardRate: number;
181
+ /**
182
+ * Minimum reward duration for the target rate
183
+ */
184
+ minRewardDurationForTargetRate: number;
185
+ } | {
186
+ /**
187
+ *
188
+ */
189
+ mode: RewardVaultDistributionMode.Duration;
190
+ /**
191
+ * Duration of the reward distribution in seconds
192
+ */
193
+ duration: number;
194
+ rewardRate?: never;
195
+ /**
196
+ * Must be between MIN_REWARD_DURATION and MAX_REWARD_DURATION
197
+ */
198
+ minRewardDurationForTargetRate?: never;
199
+ });
200
+ type GetBgtAprSimulationResult = {
201
+ apr: number | null;
202
+ duration: number;
203
+ rewardRate: number;
204
+ periodFinish: number;
205
+ /**
206
+ * It's the input target rate for the target rate mode.
207
+ *
208
+ * If input was target apr, it will be the calculated reward rate.
209
+ *
210
+ * If input was duration, it will be null.
211
+ */
212
+ targetRate: string | null;
213
+ /**
214
+ * If the mode is changed, this will be the new mode. Null otherwise.
215
+ */
216
+ mode: RewardVaultDistributionMode | null;
217
+ };
218
+ declare function getBgtAprSimulation({ availableRewards, periodFinish, tvl, bgtPrice, MIN_REWARD_DURATION, MAX_REWARD_DURATION, ...args }: GetBgtAprSimulationArgs): GetBgtAprSimulationResult;
219
+
220
+ type ReturnedFromQuery = GlobalDataQuery["polGetGlobalInfo"] & {
221
+ top3EmittingValidators: GlobalDataQuery["top3EmittingValidators"]["validators"];
222
+ allValidatorsCount: number;
223
+ };
224
+ interface GlobalInfo extends Partial<ReturnedFromQuery> {
225
+ }
226
+
227
+ interface GlobalData extends GlobalInfo {
228
+ globalCuttingBoard: ApiVaultFragment[] | undefined;
229
+ bgtTotalSupply: string | undefined;
230
+ bgtTotalBoosts: string | undefined;
231
+ }
232
+ declare function getGlobalData(publicClient: PublicClient): Promise<GlobalData>;
233
+
234
+ interface GetMarkets {
235
+ marketList: ProtocolMetadata[];
236
+ marketDictionary: {
237
+ [key: string]: ProtocolMetadata;
238
+ };
239
+ }
240
+ declare function getMarkets(args?: BeraJS.BaseFunctionArgs): Promise<GetMarkets>;
241
+
242
+ interface RewardVaultIncentive {
243
+ token: Address;
244
+ manager: Address;
245
+ minIncentiveRate: string;
246
+ incentiveRate: string;
247
+ remainingAmount: string;
248
+ symbol?: string;
249
+ /**
250
+ * Amount of tokens that needs approval before they can be added to the incentive.
251
+ *
252
+ * Anyone can just `transfer` ERC20 to the vault, but incentive manager need to send accountIncentives to turn on distribution.
253
+ */
254
+ pendingAmount: string;
255
+ decimals: number;
256
+ }
257
+ declare function getRewardVaultIncentives({ address, stakingToken, publicClient, }: {
258
+ address: Address;
259
+ stakingToken: Address;
260
+ publicClient: PublicClient;
261
+ }): Promise<RewardVaultIncentive[]>;
262
+
263
+ interface GetGaugeData {
264
+ gaugeList: ApiVaultFragment[];
265
+ pagination: {
266
+ currentPage: number;
267
+ totalCount: number;
268
+ };
269
+ }
270
+ declare function getRewardVaults({ filter, publicClient, ...args }?: {
271
+ filter?: GetVaultsQueryVariables;
272
+ publicClient?: GetPublicClientReturnType;
273
+ } & BeraJS.BaseFunctionArgs): Promise<GetGaugeData>;
274
+
275
+ type GetStakedBeraSnapshotsArgs = {
276
+ chain?: GqlChain;
277
+ range?: GqlVaultSnapshotDataRange;
278
+ } & BeraJS.BaseFunctionArgs;
279
+ /**
280
+ *
281
+ * @throws {Error} If the vault is not found
282
+ * @returns
283
+ */
284
+ declare function getStakedBeraSnapshots({ chain, range, ...args }?: GetStakedBeraSnapshotsArgs): Promise<GetSWberaVaultSnapshotsQuery["polGetSWberaVaultSnapshots"]>;
285
+
286
+ /**
287
+ * Interface representing a staked BERA withdrawal request
288
+ */
289
+ interface StakedBeraWithdrawal {
290
+ withdrawalAmount?: bigint;
291
+ timeRemaining?: string;
292
+ withdrawalRequestId?: bigint;
293
+ }
294
+ /**
295
+ * Retrieves staked BERA withdrawal information for a given account
296
+ *
297
+ * This function handles both V1 and V2 versions of the stake vault contract:
298
+ * - V1: Uses a single withdrawal request per account
299
+ * - V2: Uses ERC721 tokens to represent multiple withdrawal requests per account
300
+ *
301
+ * @param contractAddress - The address of the stake vault contract
302
+ * @param accountAddress - The address of the account to check withdrawals for
303
+ * @param publicClient - Viem public client for blockchain interactions
304
+ * @param version - The version of the stake vault contract ("V1" or "V2")
305
+ * @returns Promise resolving to an array of withdrawal request information
306
+ */
307
+ declare function getSWBeraWithdrawal(contractAddress: Address, accountAddress: Address, publicClient: PublicClient, version: "V1" | "V2"): Promise<StakedBeraWithdrawal[]>;
308
+
309
+ interface UserVault {
310
+ unclaimedBgt: string;
311
+ formattedBalance: string;
312
+ stakingTokenPrice: number | null;
313
+ vault: ApiVaultFragment;
314
+ }
315
+ type GetUserVaultsResponse = {
316
+ totalStakedValue: number;
317
+ totalBgtRewards: string;
318
+ vaults: UserVault[];
319
+ };
320
+ declare function getUserVaults({ account, publicClient, ...args }: {
321
+ account: Address;
322
+ publicClient: PublicClient;
323
+ } & BeraJS.BaseFunctionArgs): Promise<GetUserVaultsResponse>;
324
+
325
+ type GetVaultHistoryArgs = {
326
+ vault: Address;
327
+ chain?: GqlChain;
328
+ } & Omit<GetVaultHistoryQueryVariables, "vaultId" | "chain"> & BeraJS.BaseFunctionArgs;
329
+ declare function getVaultHistory({ vault, chain, ...args }: GetVaultHistoryArgs): Promise<GetVaultHistoryQuery["polGetRewardVaultSnapshots"] | undefined>;
330
+
331
+ interface ValidatorRewardAllocationRaw {
332
+ startBlock: bigint;
333
+ weights: readonly {
334
+ receiver: `0x${string}`;
335
+ percentageNumerator: bigint;
336
+ }[];
337
+ }
338
+ interface ValidatorRewardAllocation {
339
+ start: {
340
+ blockNumber: number;
341
+ timestamp: number;
342
+ };
343
+ weights: readonly {
344
+ receiver: `0x${string}`;
345
+ /**
346
+ * Weight percentage as a number between 0 and 1.
347
+ */
348
+ percentage: number;
349
+ }[];
350
+ }
351
+ interface ValidatorRewardAllocationUpdate {
352
+ active: ValidatorRewardAllocation["start"];
353
+ set: ValidatorRewardAllocation["start"];
354
+ }
355
+ interface ValidatorRewardAllocationUpdateWithExpiration extends ValidatorRewardAllocationUpdate {
356
+ expiresAtTs: number;
357
+ }
358
+ declare function formatValidatorRewardAllocation(raw: ValidatorRewardAllocationRaw, startTs: number): ValidatorRewardAllocation;
359
+ declare function isSameRewardAllocation(a: ValidatorRewardAllocation, b: ValidatorRewardAllocation): boolean;
360
+ declare function getValidatorRewardAllocation({ client, pubKey, ...args }: BeraJS.BaseFunctionArgs & {
361
+ client: PublicClient;
362
+ pubKey: Address;
363
+ }): Promise<{
364
+ /**
365
+ * The active reward allocation for the validator.
366
+ */
367
+ activeRewardAllocation: ValidatorRewardAllocation;
368
+ /**
369
+ * The set reward allocation for the validator.
370
+ *
371
+ * It might differ from the active reward allocation if the validator hasn't updated
372
+ * the reward allocation for more than the reward allocation inactivity block span.
373
+ */
374
+ setRewardAllocation: ValidatorRewardAllocation;
375
+ /**
376
+ * Whether the reward allocation is inactive so it falls back to the baseline reward allocation.
377
+ */
378
+ isBaseline: boolean;
379
+ isNeverSet: boolean;
380
+ }>;
381
+
382
+ type UserBoostsOnValidator = {
383
+ pubkey: Address;
384
+ activeBoostAmount: string;
385
+ queuedBoostAmount: string;
386
+ queuedBoostStartBlock: number;
387
+ queuedDropBoostAmount: string;
388
+ queuedDropBoostStartBlock: number;
389
+ hasPendingBoosts: boolean;
390
+ hasActiveBoosts: boolean;
391
+ };
392
+ declare function getUserBoostsOnValidator({ account, pubkey, publicClient, ...args }: {
393
+ account: Address;
394
+ pubkey: Address;
395
+ publicClient: GetPublicClientReturnType;
396
+ } & BeraJS.BaseFunctionArgs): Promise<UserBoostsOnValidator>;
397
+
398
+ type ValidatorWithUserBoost = ApiValidatorFragment & {
399
+ userBoosts: UserBoostsOnValidator;
400
+ };
401
+ declare function getUserActiveValidators({ account, publicClient, chain, ...args }: {
402
+ account: string;
403
+ publicClient?: GetPublicClientReturnType;
404
+ chain?: GqlChain;
405
+ } & BeraJS.BaseFunctionArgs): Promise<ValidatorWithUserBoost[] | undefined>;
406
+
407
+ interface StakingPoolAmount {
408
+ amount: bigint;
409
+ formattedAmount: string;
410
+ }
411
+ interface UserStakingPoolPosition {
412
+ validatorAddress: Address;
413
+ earning: number;
414
+ staked?: StakingPoolAmount;
415
+ rewards?: StakingPoolAmount;
416
+ queueData?: {
417
+ stake?: StakingPoolAmount[];
418
+ unstake?: (StakingPoolAmount & {
419
+ timestamp: number;
420
+ })[];
421
+ };
422
+ }
423
+ declare function getUserStakingPositions(account: Address): Promise<UserStakingPoolPosition[]>;
424
+
425
+ interface ValidatorQueuedCommission {
426
+ blockNumberLast: number;
427
+ commissionRate: number;
428
+ }
429
+ declare function getValidatorQueuedCommission({ client, pubKey, ...args }: BeraJS.BaseFunctionArgs & {
430
+ client: PublicClient;
431
+ pubKey: Address;
432
+ }): Promise<ValidatorQueuedCommission | undefined | null>;
433
+
434
+ type ValidatorQueuedOperatorAddress = [bigint, string];
435
+ declare function getValidatorQueuedOperatorAddress({ client, pubKey, ...args }: {
436
+ client: PublicClient;
437
+ pubKey: Address;
438
+ } & BeraJS.BaseFunctionArgs): Promise<ValidatorQueuedOperatorAddress | undefined>;
439
+
440
+ export { getVaultHistory as A, type ValidatorWithUserBoost as B, getUserActiveValidators as C, type UserBoostsOnValidator as D, getUserBoostsOnValidator as E, type UserStakingPoolPosition as F, type GetConvertToAssetsProps as G, getUserStakingPositions as H, type IsBadCollateralArgs as I, type ValidatorQueuedCommission as J, getValidatorQueuedCommission as K, type ValidatorQueuedOperatorAddress as L, getValidatorQueuedOperatorAddress as M, type ValidatorRewardAllocationRaw as N, type OnChainPool as O, type PoolStatus as P, type ValidatorRewardAllocationUpdate as Q, type RewardVaultIncentive as R, type StakedBeraWithdrawal as S, type ValidatorRewardAllocationUpdateWithExpiration as T, type UserVault as U, type ValidatorRewardAllocation as V, formatValidatorRewardAllocation as W, isSameRewardAllocation as X, getValidatorRewardAllocation as Y, getOnChainPool as a, getPoolPausedState as b, type GetHoneyVaultsBalanceResponse as c, getHoneyVaultsBalance as d, type IsBadCollateralResponse as e, type GetBgtAprSimulationArgs as f, getConvertToAssets as g, type GetBgtAprSimulationResult as h, isBadCollateralAsset as i, getBgtAprSimulation as j, type GlobalData as k, getGlobalData as l, type GetMarkets as m, getMarkets as n, getRewardVaultIncentives as o, RewardVaultDistributionMode as p, type GetRewardVaultRewardsReturn as q, getRewardVaultRewards as r, type GetGaugeData as s, getRewardVaults as t, type GetStakedBeraSnapshotsArgs as u, getStakedBeraSnapshots as v, getSWBeraWithdrawal as w, type GetUserVaultsResponse as x, getUserVaults as y, type GetVaultHistoryArgs as z };