@berachain/berajs 0.2.8-beta.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BeraError-_mQdkanr.d.cts → BeraError-7-A5JYy_.d.ts} +31 -2
- package/dist/{HoneyConfigProvider-DVP_9KZn.d.ts → HoneyConfigProvider-Dkj-_a5x.d.ts} +1 -1
- package/dist/{RequestError-BRIiJgHk.d.ts → RequestError-DBOIV65x.d.ts} +1 -1
- package/dist/abi/exports.mjs +4452 -2
- package/dist/actions/clients/exports.d.ts +78 -0
- package/dist/actions/clients/exports.mjs +21 -0
- package/dist/actions/exports.d.ts +154 -207
- package/dist/actions/exports.mjs +853 -2
- package/dist/actions/governance/exports.d.ts +140 -0
- package/dist/actions/governance/exports.mjs +226 -0
- package/dist/actions/server/exports.d.ts +13 -0
- package/dist/actions/server/exports.mjs +27 -0
- package/dist/chunk-3JJLQ2JX.mjs +211 -0
- package/dist/chunk-7YVNSDXG.mjs +86 -0
- package/dist/chunk-AUOPN6NK.mjs +96 -0
- package/dist/chunk-BGMRHTBQ.mjs +23 -0
- package/dist/chunk-CDK4YV3D.mjs +571 -0
- package/dist/chunk-DKMAIU74.mjs +62 -0
- package/dist/chunk-DQRH5VE3.mjs +25 -0
- package/dist/chunk-E7YFXBBQ.mjs +349 -0
- package/dist/chunk-GUURQAME.mjs +326 -0
- package/dist/chunk-GY6B3PD5.mjs +89 -0
- package/dist/chunk-HQCOU6GY.mjs +243 -0
- package/dist/chunk-HYDP32P6.mjs +135 -0
- package/dist/chunk-IXIBY5FP.mjs +80 -0
- package/dist/chunk-KHXJDYA4.mjs +1776 -0
- package/dist/chunk-NBYLMO2L.mjs +14 -0
- package/dist/chunk-O2NQFKJK.mjs +170 -0
- package/dist/chunk-P5WXXULM.mjs +54 -0
- package/dist/chunk-QBBOWFMH.mjs +4129 -0
- package/dist/chunk-QVHEM4BG.mjs +35 -0
- package/dist/chunk-SGIJVHZO.mjs +12 -0
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/chunk-WNBWX23Q.mjs +426 -0
- package/dist/chunk-Y6THHG77.mjs +126 -0
- package/dist/chunk-ZLTMIFCZ.mjs +165 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +85 -2
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +46 -2
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +4 -3
- package/dist/errors/exports.mjs +48 -2
- package/dist/getApolloClient-BcUTGFUb.d.ts +40 -0
- package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-DphU3qhE.d.ts} +2 -2
- package/dist/{global.d-5w_lvl2J.d.ts → global.d-BuGDKh4k.d.ts} +4 -240
- package/dist/hooks/exports.d.ts +83 -226
- package/dist/hooks/exports.mjs +7463 -4
- package/dist/hooks/governance/exports.d.ts +181 -0
- package/dist/hooks/governance/exports.mjs +888 -0
- package/dist/pol.d-Dw5SQcRX.d.ts +153 -0
- package/dist/{txnEnum-7_o92X3N.d.cts → txnEnum-ByI5dtDi.d.ts} +2 -60
- package/dist/types/exports.d.ts +9 -9
- package/dist/types/exports.mjs +0 -1
- package/dist/types/governance/exports.d.ts +109 -0
- package/dist/types/governance/exports.mjs +0 -0
- package/dist/{useHoneySwapState-B494PQDl.d.ts → useHoneySwapState-vFmuFF0g.d.ts} +1 -1
- package/dist/utils/exports.d.ts +15 -6
- package/dist/utils/exports.mjs +827 -2
- package/package.json +49 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/exports.ts +7 -0
- package/src/actions/clients/fetchBeep.ts +34 -0
- package/src/actions/clients/fetchOpenApi.ts +93 -0
- package/src/actions/clients/fetchOpenApi.unit.test.ts +223 -0
- package/src/actions/clients/fetchRailwayBackend.ts +34 -0
- package/src/actions/clients/getApolloClient.ts +58 -23
- package/src/actions/clients/getEnsoClient.ts +20 -9
- package/src/actions/dex/aggregators/enso/enso.ts +27 -17
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +2 -2
- package/src/actions/dex/aggregators/kyberswap.ts +18 -23
- package/src/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.ts +3 -6
- package/src/actions/enso/getEnsoUserTokensWithBalances.ts +18 -0
- package/src/actions/exports.ts +5 -9
- package/src/actions/governance/exports.ts +9 -0
- package/src/actions/governance/getAllProposals.ts +10 -65
- package/src/actions/governance/getProposalDetails.ts +6 -33
- package/src/actions/governance/getProposalVotes.ts +8 -15
- package/src/actions/honey/getChartData.ts +27 -21
- package/src/actions/honey/getHoney24hVolume.ts +19 -22
- package/src/actions/honey/getPythLatestPrices.ts +7 -0
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +1 -1
- package/src/actions/pol/getAutoclaimedIncentives.ts +41 -0
- package/src/actions/pol/getAutoclaimedIncentivesTxHash.ts +41 -0
- package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +28 -0
- package/src/actions/pol/getEarnedStakedBeraVault.ts +20 -20
- package/src/actions/pol/getGlobalData.ts +1 -0
- package/src/actions/pol/getHeroEarnVaults.ts +62 -0
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +19 -38
- package/src/actions/pol/getRewardVaults.ts +4 -4
- package/src/actions/pol/getSWBeraVaultMetadata.ts +1 -1
- package/src/actions/pol/getStakingDailyAssets.ts +18 -17
- package/src/actions/server/exports.ts +1 -0
- package/src/actions/server/getDailyValidatorBlockStats.ts +33 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +3 -6
- package/src/actions/transactions/beraWriteContract.integration.test.ts +3 -6
- package/src/actions/validators/getDailyValidatorBlockStats.ts +25 -24
- package/src/actions/validators/getValidatorAnalytics.ts +20 -21
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +33 -0
- package/src/actions/validators/utils/getValidatorBoostApy.ts +1 -1
- package/src/enum/contracts.ts +1 -0
- package/src/enum/exports.ts +0 -1
- package/src/enum/governance/exports.ts +1 -0
- package/src/errors/BeraError.ts +47 -7
- package/src/errors/BeraTracing.unit.test.ts +65 -0
- package/src/errors/RequestError.ts +25 -4
- package/src/errors/RequestError.unit.test.ts +55 -0
- package/src/errors/errorMap.ts +8 -0
- package/src/errors/exports.ts +5 -0
- package/src/errors/getRevertReason.integration.test.ts +3 -3
- package/src/errors/spanStatus.ts +78 -0
- package/src/errors/spanStatus.unit.test.ts +62 -0
- package/src/hooks/dex/useCreatePool.ts +1 -88
- package/src/hooks/dex/useOnChainPoolData.ts +27 -2
- package/src/hooks/dex/usePriceImpact.ts +12 -5
- package/src/hooks/enso/useBendDemultiply.ts +9 -1
- package/src/hooks/enso/useBendMultiply.ts +9 -1
- package/src/hooks/enso/useBendZapSupply.ts +26 -7
- package/src/hooks/enso/useEnsoSwapBundle.ts +17 -3
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -2
- package/src/hooks/exports.ts +3 -15
- package/src/hooks/governance/exports.ts +14 -0
- package/src/hooks/pol/useAutoclaimedIncentives.ts +40 -0
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +45 -0
- package/src/hooks/pol/useStakedAPR.ts +2 -2
- package/src/hooks/pol/useStakedSnapshots.ts +5 -9
- package/src/hooks/validators/useValidator.ts +6 -8
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
- package/src/types/bribe-boost.d.ts +19 -0
- package/src/types/exports.ts +0 -1
- package/src/types/governance/exports.ts +1 -0
- package/src/utils/beraFetch.ts +9 -3
- package/src/utils/exports.ts +1 -0
- package/src/utils/getServerSideClient.ts +4 -2
- package/src/utils/polyfillAbortSignalAny.ts +53 -0
- package/src/utils/polyfillAbortSignalAny.unit.test.ts +81 -0
- package/src/utils/sanitizeRpcUrl.ts +22 -0
- package/src/utils/tracedTransport.ts +35 -0
- package/dist/BeraError-_mQdkanr.d.ts +0 -94
- package/dist/BexStatusProvider-DRymVlQf.d.cts +0 -70
- package/dist/HoneyConfigProvider-DfkjmzEf.d.cts +0 -390
- package/dist/RequestError-DSUzJ1Iy.d.cts +0 -144
- package/dist/abi/exports.cjs +0 -2
- package/dist/abi/exports.cjs.map +0 -1
- package/dist/abi/exports.d.cts +0 -6574
- package/dist/abi/exports.mjs.map +0 -1
- package/dist/actions/exports.cjs +0 -2
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1650
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-45HIEVNI.cjs +0 -4
- package/dist/chunk-45HIEVNI.cjs.map +0 -1
- package/dist/chunk-47ILYVHC.mjs +0 -2
- package/dist/chunk-47ILYVHC.mjs.map +0 -1
- package/dist/chunk-575OK77P.mjs +0 -2
- package/dist/chunk-575OK77P.mjs.map +0 -1
- package/dist/chunk-5NVZG5N6.mjs +0 -2
- package/dist/chunk-5NVZG5N6.mjs.map +0 -1
- package/dist/chunk-6DIA6PXV.cjs +0 -2
- package/dist/chunk-6DIA6PXV.cjs.map +0 -1
- package/dist/chunk-6JJIZCVY.cjs +0 -2
- package/dist/chunk-6JJIZCVY.cjs.map +0 -1
- package/dist/chunk-7F72ZH4Q.mjs +0 -2
- package/dist/chunk-7F72ZH4Q.mjs.map +0 -1
- package/dist/chunk-AUA42YIG.mjs +0 -4
- package/dist/chunk-AUA42YIG.mjs.map +0 -1
- package/dist/chunk-BC2WX6O6.cjs +0 -2
- package/dist/chunk-BC2WX6O6.cjs.map +0 -1
- package/dist/chunk-CJOZC5Z2.cjs +0 -2
- package/dist/chunk-CJOZC5Z2.cjs.map +0 -1
- package/dist/chunk-D6L7LTA2.cjs +0 -2
- package/dist/chunk-D6L7LTA2.cjs.map +0 -1
- package/dist/chunk-DDEQFR3M.cjs +0 -2
- package/dist/chunk-DDEQFR3M.cjs.map +0 -1
- package/dist/chunk-GXV2JA36.mjs +0 -2
- package/dist/chunk-GXV2JA36.mjs.map +0 -1
- package/dist/chunk-ISYNEDET.mjs +0 -2
- package/dist/chunk-ISYNEDET.mjs.map +0 -1
- package/dist/chunk-JDDRTHFG.mjs +0 -2
- package/dist/chunk-JDDRTHFG.mjs.map +0 -1
- package/dist/chunk-JDZGYU5T.mjs +0 -2
- package/dist/chunk-JDZGYU5T.mjs.map +0 -1
- package/dist/chunk-LVOXBZMA.cjs +0 -2
- package/dist/chunk-LVOXBZMA.cjs.map +0 -1
- package/dist/chunk-MK5NS5B5.mjs +0 -2
- package/dist/chunk-MK5NS5B5.mjs.map +0 -1
- package/dist/chunk-NAXAZJJY.mjs +0 -2
- package/dist/chunk-NAXAZJJY.mjs.map +0 -1
- package/dist/chunk-NLVWRMGD.mjs +0 -2
- package/dist/chunk-NLVWRMGD.mjs.map +0 -1
- package/dist/chunk-OGBD5YOG.mjs +0 -2
- package/dist/chunk-OGBD5YOG.mjs.map +0 -1
- package/dist/chunk-OGJMSGB2.mjs +0 -2
- package/dist/chunk-OGJMSGB2.mjs.map +0 -1
- package/dist/chunk-OIYXOKTT.cjs +0 -2
- package/dist/chunk-OIYXOKTT.cjs.map +0 -1
- package/dist/chunk-OUD27MU7.cjs +0 -2
- package/dist/chunk-OUD27MU7.cjs.map +0 -1
- package/dist/chunk-PRLVZIKD.mjs +0 -2
- package/dist/chunk-PRLVZIKD.mjs.map +0 -1
- package/dist/chunk-Q2SNRLW3.cjs +0 -2
- package/dist/chunk-Q2SNRLW3.cjs.map +0 -1
- package/dist/chunk-REWME3FY.cjs +0 -2
- package/dist/chunk-REWME3FY.cjs.map +0 -1
- package/dist/chunk-RJN36GBU.mjs +0 -2
- package/dist/chunk-RJN36GBU.mjs.map +0 -1
- package/dist/chunk-RWOICHRW.cjs +0 -2
- package/dist/chunk-RWOICHRW.cjs.map +0 -1
- package/dist/chunk-S4CDSVLK.cjs +0 -2
- package/dist/chunk-S4CDSVLK.cjs.map +0 -1
- package/dist/chunk-SFEULGSX.cjs +0 -2
- package/dist/chunk-SFEULGSX.cjs.map +0 -1
- package/dist/chunk-WBTS6KFG.mjs +0 -2
- package/dist/chunk-WBTS6KFG.mjs.map +0 -1
- package/dist/chunk-WRFDB3QJ.cjs +0 -2
- package/dist/chunk-WRFDB3QJ.cjs.map +0 -1
- package/dist/chunk-XNJLSA6P.cjs +0 -2
- package/dist/chunk-XNJLSA6P.cjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -2
- package/dist/contexts/exports.cjs.map +0 -1
- package/dist/contexts/exports.d.cts +0 -66
- package/dist/contexts/exports.mjs.map +0 -1
- package/dist/defaultFlags-D6KfkTZx.d.cts +0 -10
- package/dist/dex-C_BB0b0O.d.cts +0 -37
- package/dist/enum/exports.cjs +0 -2
- package/dist/enum/exports.cjs.map +0 -1
- package/dist/enum/exports.d.cts +0 -23
- package/dist/enum/exports.mjs.map +0 -1
- package/dist/errors/exports.cjs +0 -2
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -327
- package/dist/errors/exports.mjs.map +0 -1
- package/dist/getValidatorQueuedOperatorAddress-Cql_D50j.d.cts +0 -562
- package/dist/global.d-B7IeayVX.d.cts +0 -474
- package/dist/honey-CYm0RWf4.d.cts +0 -14
- package/dist/hooks/exports.cjs +0 -4
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1734
- package/dist/hooks/exports.mjs.map +0 -1
- package/dist/polling-BKnyavLI.d.cts +0 -8
- package/dist/txnEnum-7_o92X3N.d.ts +0 -164
- package/dist/types/exports.cjs +0 -1
- package/dist/types/exports.cjs.map +0 -1
- package/dist/types/exports.d.cts +0 -90
- package/dist/types/exports.mjs.map +0 -1
- package/dist/useHoneySwapState-D6vpv19r.d.cts +0 -32
- package/dist/utils/exports.cjs +0 -2
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -420
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ChainId } from "@berachain/config";
|
|
2
|
+
|
|
3
|
+
import { beraFetchJson } from "../../utils/beraFetch";
|
|
4
|
+
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
5
|
+
|
|
6
|
+
interface SupplyMonitorBeraStatsResponse {
|
|
7
|
+
/** Total BERA supply, in whole BERA units. */
|
|
8
|
+
totalSupply: number;
|
|
9
|
+
/** Circulating BERA supply, in whole BERA units. */
|
|
10
|
+
circulatingSupply: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type GetBeraTokenTotalSupplyArgs = BeraJS.BaseFunctionArgs;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Fetches the native BERA total supply (in whole BERA units) from the
|
|
17
|
+
* Berachain supply-monitor service.
|
|
18
|
+
*/
|
|
19
|
+
export async function getBeraTokenTotalSupply(
|
|
20
|
+
args: GetBeraTokenTotalSupplyArgs = {},
|
|
21
|
+
): Promise<string> {
|
|
22
|
+
const { config } = parseBaseArgs(args);
|
|
23
|
+
// supply-monitor only exposes BERA stats for mainnet/bepolia; returns 0 on other chains.
|
|
24
|
+
const network = config.chainId === ChainId.MAINNET ? "mainnet" : "bepolia";
|
|
25
|
+
|
|
26
|
+
// `supplyMonitor` is typed as `HttpLink` (string | { uri, name, ... }).
|
|
27
|
+
// Both forms are accepted; pick the URL out of whichever shape was used.
|
|
28
|
+
const supplyMonitor = config.pol.supplyMonitor;
|
|
29
|
+
const baseUrl =
|
|
30
|
+
typeof supplyMonitor === "string" ? supplyMonitor : supplyMonitor.uri;
|
|
31
|
+
|
|
32
|
+
const data = await beraFetchJson<SupplyMonitorBeraStatsResponse>(
|
|
33
|
+
{
|
|
34
|
+
url: `${baseUrl}/api/stats/bera?network=${network}`,
|
|
35
|
+
name:
|
|
36
|
+
typeof supplyMonitor === "string"
|
|
37
|
+
? "supply-monitor-bera"
|
|
38
|
+
: supplyMonitor.name,
|
|
39
|
+
type: "rest",
|
|
40
|
+
},
|
|
41
|
+
{ cache: "no-store" },
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return data.totalSupply.toString();
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PublicClient } from "viem";
|
|
2
|
+
|
|
3
|
+
import { bgtIncentiveDistributorAbi } from "@berachain/abis/pol/rewards/bgtIncentiveDistributor";
|
|
4
|
+
|
|
5
|
+
import { assertPublicClient } from "../../errors/assert";
|
|
6
|
+
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Reads `paused()` on the BGT incentive distributor. Used to gate the
|
|
10
|
+
* autoclaim banner — when `true`, users can no longer self-claim and the
|
|
11
|
+
* bot is responsible for distributing incentives on their behalf.
|
|
12
|
+
*/
|
|
13
|
+
export async function getBgtIncentiveDistributorPaused({
|
|
14
|
+
publicClient,
|
|
15
|
+
...args
|
|
16
|
+
}: {
|
|
17
|
+
publicClient: PublicClient | undefined;
|
|
18
|
+
} & BeraJS.BaseFunctionArgs): Promise<boolean> {
|
|
19
|
+
assertPublicClient(publicClient);
|
|
20
|
+
|
|
21
|
+
const { config } = parseBaseArgs(args);
|
|
22
|
+
|
|
23
|
+
return publicClient.readContract({
|
|
24
|
+
address: config.pol.bgtIncentiveDistributor,
|
|
25
|
+
abi: bgtIncentiveDistributorAbi,
|
|
26
|
+
functionName: "paused",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import { getUriFromLink } from "@berachain/config";
|
|
4
|
-
|
|
5
|
-
import { beraFetchJson } from "../../utils/beraFetch";
|
|
6
3
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
currentDepositRate: string;
|
|
10
|
-
earningsRealized: string;
|
|
11
|
-
earningsTotal: string;
|
|
12
|
-
};
|
|
4
|
+
import { fetchBeep } from "../clients/fetchBeep";
|
|
5
|
+
import { fetchRailwayBackend } from "../clients/fetchRailwayBackend";
|
|
13
6
|
|
|
14
7
|
type GetEarnedStakedBeraVaultArgs = {
|
|
15
8
|
/**
|
|
@@ -25,17 +18,24 @@ export async function getEarnedStakedBeraVault({
|
|
|
25
18
|
address,
|
|
26
19
|
account,
|
|
27
20
|
...args
|
|
28
|
-
}: BeraJS.BaseFunctionArgs &
|
|
29
|
-
GetEarnedStakedBeraVaultArgs): Promise<StakingHistoryData> {
|
|
21
|
+
}: BeraJS.BaseFunctionArgs & GetEarnedStakedBeraVaultArgs) {
|
|
30
22
|
const { config } = parseBaseArgs(args);
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
// beep backend (next-gen), typed against `@berachain/graphql/beep`.
|
|
36
|
+
return fetchBeep(
|
|
37
|
+
"/v0/stake/{vault}/earnings/{owner}",
|
|
38
|
+
{ path: { vault: address, owner: account } },
|
|
39
|
+
args,
|
|
40
|
+
);
|
|
41
41
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ApiVaultFragment,
|
|
3
|
+
GetHeroEarnVaults,
|
|
4
|
+
type GetHeroEarnVaultsQuery,
|
|
5
|
+
type GetHeroEarnVaultsQueryVariables,
|
|
6
|
+
} from "@berachain/graphql/pol/api";
|
|
7
|
+
|
|
8
|
+
import { getApolloClient } from "../clients/getApolloClient";
|
|
9
|
+
|
|
10
|
+
export interface HeroEarnVaults {
|
|
11
|
+
/**
|
|
12
|
+
* Top-APR PoL reward vaults, ordered by APR descending. Callers typically
|
|
13
|
+
* read `[0]` for the "Earn with PoL" hero subtitle. `bestAprExcludedAddresses`
|
|
14
|
+
* lets callers filter out non-incentivized earn actions whose APR figures
|
|
15
|
+
* would otherwise dominate the listing and mislead users.
|
|
16
|
+
*/
|
|
17
|
+
bestApr: ApiVaultFragment[];
|
|
18
|
+
/**
|
|
19
|
+
* Highest-APR PoL reward vault among vaults whose protocol is "bend".
|
|
20
|
+
* Its `stakingToken.address` is a Bend vault share token — match it back
|
|
21
|
+
* against `bendVaults` to combine the PoL reward APR with the underlying
|
|
22
|
+
* Bend native supply APY.
|
|
23
|
+
*/
|
|
24
|
+
bendRewardVault: ApiVaultFragment[];
|
|
25
|
+
/**
|
|
26
|
+
* Minimal Bend native vault data (address + `totalApy`) used to look up the
|
|
27
|
+
* underlying Bend supply APY for whichever Bend vault `bendRewardVault`
|
|
28
|
+
* resolves to.
|
|
29
|
+
*/
|
|
30
|
+
bendVaults: GetHeroEarnVaultsQuery["bendVaults"];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Batched fetch for the hub home page hero cards. Issues a single GraphQL
|
|
35
|
+
* request to the BEX API that returns:
|
|
36
|
+
* - the top-APR PoL reward vaults (for the "Earn with PoL" card)
|
|
37
|
+
* - the highest-APR Bend-protocol PoL reward vault (for the "Lend" card)
|
|
38
|
+
* - minimal Bend native vault data, so callers can add the Bend supply APY
|
|
39
|
+
* on top of the PoL reward APR when displaying the combined Lend APY
|
|
40
|
+
*/
|
|
41
|
+
export async function getHeroEarnVaults({
|
|
42
|
+
bestAprExcludedAddresses = [],
|
|
43
|
+
...args
|
|
44
|
+
}: {
|
|
45
|
+
bestAprExcludedAddresses?: string[];
|
|
46
|
+
} & BeraJS.BaseFunctionArgs = {}): Promise<HeroEarnVaults> {
|
|
47
|
+
const bexApiGraphqlClient = getApolloClient("api", args);
|
|
48
|
+
|
|
49
|
+
const res = await bexApiGraphqlClient.query<
|
|
50
|
+
GetHeroEarnVaultsQuery,
|
|
51
|
+
GetHeroEarnVaultsQueryVariables
|
|
52
|
+
>({
|
|
53
|
+
query: GetHeroEarnVaults,
|
|
54
|
+
variables: { bestAprExcludedAddresses },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
bestApr: res.data.bestApr.vaults,
|
|
59
|
+
bendRewardVault: res.data.bendRewardVault.vaults,
|
|
60
|
+
bendVaults: res.data.bendVaults,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -1,43 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type GetIncentiveFeeClaimStatsQuery,
|
|
4
|
-
type GetIncentiveFeeClaimStatsQueryVariables,
|
|
5
|
-
} from "@berachain/graphql/pol/fees";
|
|
1
|
+
import { BeraError } from "../../errors/BeraError";
|
|
2
|
+
import { beraFetchJson } from "../../utils/beraFetch";
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export type IncentiveFeeClaimStats = {
|
|
5
|
+
sumAllClaims: number;
|
|
6
|
+
sumClaimsInLast24Hours: number;
|
|
7
|
+
};
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
query: GetIncentiveFeeClaimStats,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (data.incentiveFeeClaims.length > 0) {
|
|
22
|
-
const sumAllClaims = data?.incentiveFeeClaims.reduce(
|
|
23
|
-
(acc, curr) => acc + Number(curr.payoutAmount),
|
|
24
|
-
30_000, // this is due to a bug in the subgraph, where the first claim of 50_000 was counted as 20_000, once hunter pushed the fix we can upgrade it.
|
|
25
|
-
);
|
|
26
|
-
const claimsInLast24Hours = data?.incentiveFeeClaims.filter(
|
|
27
|
-
(claim) => Number(claim.timestamp) / 1000 > Date.now() - days(1),
|
|
28
|
-
);
|
|
29
|
-
const sumClaimsInLast24Hours = claimsInLast24Hours.reduce(
|
|
30
|
-
(acc, curr) => acc + Number(curr.payoutAmount),
|
|
31
|
-
0,
|
|
32
|
-
);
|
|
33
|
-
return {
|
|
34
|
-
sumAllClaims,
|
|
35
|
-
sumClaimsInLast24Hours,
|
|
36
|
-
};
|
|
9
|
+
/** Browser-only. Hits `/api/pol/incentive-fee-claims` (server computes totals). */
|
|
10
|
+
export async function getIncentiveFeeClaimStats(): Promise<IncentiveFeeClaimStats> {
|
|
11
|
+
if (typeof window === "undefined") {
|
|
12
|
+
throw new BeraError({
|
|
13
|
+
message:
|
|
14
|
+
"getIncentiveFeeClaimStats is browser-only; call from a Client Component / SWR hook",
|
|
15
|
+
level: "error",
|
|
16
|
+
});
|
|
37
17
|
}
|
|
38
18
|
|
|
39
|
-
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
return beraFetchJson<IncentiveFeeClaimStats>({
|
|
20
|
+
url: "/api/pol/incentive-fee-claims",
|
|
21
|
+
name: "pol-incentive-fee-claims",
|
|
22
|
+
type: "rest",
|
|
23
|
+
});
|
|
43
24
|
}
|
|
@@ -87,13 +87,13 @@ export async function getRewardVaults({
|
|
|
87
87
|
...vault,
|
|
88
88
|
dynamicData: {
|
|
89
89
|
...vault.dynamicData,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
allTimeRewards: vault.dynamicData?.allTimeRewards ?? "0",
|
|
91
|
+
rewardCapturePercentage:
|
|
92
|
+
vault.dynamicData?.rewardCapturePercentage ?? 0,
|
|
93
93
|
activeIncentivesValueUsd: totalIncentiveInUsdc.toString(),
|
|
94
94
|
activeIncentivesRateUsd:
|
|
95
95
|
vault.dynamicData?.activeIncentivesRateUsd ?? "0",
|
|
96
|
-
|
|
96
|
+
rewardCapturePerBlock: vault.dynamicData?.rewardCapturePerBlock ?? 0,
|
|
97
97
|
},
|
|
98
98
|
activeIncentives: incentivesArray,
|
|
99
99
|
} satisfies typeof vault;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import { getUriFromLink } from "@berachain/config";
|
|
4
|
-
|
|
5
|
-
import { beraFetchJson } from "../../utils/beraFetch";
|
|
6
3
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
4
|
+
import { fetchBeep } from "../clients/fetchBeep";
|
|
5
|
+
import { fetchRailwayBackend } from "../clients/fetchRailwayBackend";
|
|
7
6
|
|
|
8
7
|
export async function getStakingDailyAssets({
|
|
9
8
|
address,
|
|
@@ -11,20 +10,22 @@ export async function getStakingDailyAssets({
|
|
|
11
10
|
}: {
|
|
12
11
|
address: Address;
|
|
13
12
|
range: 30 | 60 | 90;
|
|
14
|
-
})
|
|
15
|
-
const now = new Date();
|
|
16
|
-
const startDayDate = new Date(
|
|
17
|
-
now.getTime() - Number(range) * 24 * 60 * 60 * 1000,
|
|
18
|
-
);
|
|
19
|
-
|
|
13
|
+
}) {
|
|
20
14
|
const { config } = parseBaseArgs({});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
// beep backend (next-gen), typed against `@berachain/graphql/beep`.
|
|
27
|
+
return fetchBeep("/v0/stake/{vault}/stats-by-day", {
|
|
28
|
+
path: { vault: address },
|
|
29
|
+
query: { days: `${range}` },
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./getDailyValidatorBlockStats";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
GetValidatorBlockStats,
|
|
5
|
+
type GetValidatorBlockStatsQuery,
|
|
6
|
+
type GetValidatorBlockStatsQueryVariables,
|
|
7
|
+
} from "@berachain/graphql/pol/subgraph";
|
|
8
|
+
|
|
9
|
+
import { getApolloClient } from "../clients/getApolloClient";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Server-only RSC variant. Goes directly to the pol subgraph upstream
|
|
13
|
+
* (no auth required) through the shared Apollo client factory.
|
|
14
|
+
*/
|
|
15
|
+
export async function getDailyValidatorBlockStats({
|
|
16
|
+
pubKey,
|
|
17
|
+
first = 1,
|
|
18
|
+
...args
|
|
19
|
+
}: BeraJS.BaseFunctionArgs & {
|
|
20
|
+
pubKey: Address;
|
|
21
|
+
first?: number;
|
|
22
|
+
}): Promise<GetValidatorBlockStatsQuery | undefined> {
|
|
23
|
+
const client = getApolloClient("pol.subgraph", args);
|
|
24
|
+
|
|
25
|
+
const result = await client.query<
|
|
26
|
+
GetValidatorBlockStatsQuery,
|
|
27
|
+
GetValidatorBlockStatsQueryVariables
|
|
28
|
+
>({
|
|
29
|
+
query: GetValidatorBlockStats,
|
|
30
|
+
variables: { pubKey, first },
|
|
31
|
+
});
|
|
32
|
+
return result.data;
|
|
33
|
+
}
|
|
@@ -2,15 +2,12 @@ import { ethAddress } from "viem";
|
|
|
2
2
|
import { assert, describe, expect, it } from "vitest";
|
|
3
3
|
|
|
4
4
|
import { appConfig } from "@berachain/config/internal";
|
|
5
|
-
import {
|
|
6
|
-
defaultChain,
|
|
7
|
-
externalChains,
|
|
8
|
-
transports,
|
|
9
|
-
} from "@berachain/config/internal/wagmi";
|
|
5
|
+
import { defaultChain, externalChains } from "@berachain/config/internal/wagmi";
|
|
10
6
|
|
|
11
7
|
import { getConfig } from "@berachain/wagmi/config";
|
|
12
8
|
|
|
13
9
|
import { isToken } from "../../utils/tokens";
|
|
10
|
+
import { testTransports } from "../__test/transports";
|
|
14
11
|
import { getTokens } from "./getTokens";
|
|
15
12
|
import { getWalletBalances } from "./getWalletBalances";
|
|
16
13
|
|
|
@@ -22,7 +19,7 @@ import { getWalletBalances } from "./getWalletBalances";
|
|
|
22
19
|
const account = "0x08194D89A52C1410F4bcc46FE11AC2387aC69de8";
|
|
23
20
|
describe("getWalletBalances", async () => {
|
|
24
21
|
const { wagmi: wagmiConfig } = getConfig({
|
|
25
|
-
transports,
|
|
22
|
+
transports: testTransports,
|
|
26
23
|
defaultChain,
|
|
27
24
|
chains: externalChains,
|
|
28
25
|
thirdweb: { clientId: appConfig.apiKeys.public.thirdweb },
|
|
@@ -11,11 +11,7 @@ import { mnemonicToAccount } from "viem/accounts";
|
|
|
11
11
|
import { assert, describe, expect, it } from "vitest";
|
|
12
12
|
|
|
13
13
|
import { appConfig, ChainId, getRpcUrls } from "@berachain/config/internal";
|
|
14
|
-
import {
|
|
15
|
-
defaultChain,
|
|
16
|
-
externalChains,
|
|
17
|
-
transports,
|
|
18
|
-
} from "@berachain/config/internal/wagmi";
|
|
14
|
+
import { defaultChain, externalChains } from "@berachain/config/internal/wagmi";
|
|
19
15
|
|
|
20
16
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
21
17
|
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
@@ -28,6 +24,7 @@ import { getServerSidePublicClient } from "../../utils/getServerSideClient";
|
|
|
28
24
|
import { getTestClient } from "../../utils/getTestClient";
|
|
29
25
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
30
26
|
import { anvilMnemonic } from "../../utils/test-utils";
|
|
27
|
+
import { testTransports } from "../__test/transports";
|
|
31
28
|
import { getUserVaults } from "../pol/getUserVaults";
|
|
32
29
|
import { beraWriteContract } from "./beraWriteContract";
|
|
33
30
|
|
|
@@ -38,7 +35,7 @@ const testFn: IContractWriteFn = async (_args) => {
|
|
|
38
35
|
describe("beraWriteContract", () => {
|
|
39
36
|
const { config } = parseBaseArgs({ chainId: defaultChain.id });
|
|
40
37
|
const beraWagmiConfig = getConfig({
|
|
41
|
-
transports,
|
|
38
|
+
transports: testTransports,
|
|
42
39
|
defaultChain,
|
|
43
40
|
chains: externalChains,
|
|
44
41
|
thirdweb: { clientId: appConfig.apiKeys.public.thirdweb },
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
GetValidatorBlockStats,
|
|
5
|
-
type GetValidatorBlockStatsQuery,
|
|
6
|
-
type GetValidatorBlockStatsQueryVariables,
|
|
7
|
-
} from "@berachain/graphql/pol/subgraph";
|
|
3
|
+
import type { GetValidatorBlockStatsQuery } from "@berachain/graphql/pol/subgraph";
|
|
8
4
|
|
|
9
|
-
import {
|
|
5
|
+
import { BeraError } from "../../errors/BeraError";
|
|
6
|
+
import { beraFetchJson } from "../../utils/beraFetch";
|
|
10
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Browser-only. Hits `/api/pol/validator-block-stats`. Server callers (RSC)
|
|
10
|
+
* should import from `@berachain/berajs/actions/server` instead — that path
|
|
11
|
+
* has the static Apollo + GraphQL imports and does not pass through the
|
|
12
|
+
* browser endpoint.
|
|
13
|
+
*/
|
|
11
14
|
export async function getDailyValidatorBlockStats({
|
|
12
15
|
pubKey,
|
|
13
16
|
first = 1,
|
|
14
|
-
|
|
15
|
-
}: BeraJS.BaseFunctionArgs & {
|
|
17
|
+
}: {
|
|
16
18
|
pubKey: Address;
|
|
17
19
|
first?: number;
|
|
18
20
|
}): Promise<GetValidatorBlockStatsQuery | undefined> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
>({
|
|
25
|
-
query: GetValidatorBlockStats,
|
|
26
|
-
variables: {
|
|
27
|
-
pubKey,
|
|
28
|
-
first,
|
|
29
|
-
},
|
|
21
|
+
if (typeof window === "undefined") {
|
|
22
|
+
throw new BeraError({
|
|
23
|
+
message:
|
|
24
|
+
"getDailyValidatorBlockStats is browser-only; for RSC use @berachain/berajs/actions/server",
|
|
25
|
+
level: "error",
|
|
30
26
|
});
|
|
31
|
-
|
|
32
|
-
return result.data;
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.error("GetValidatorBlockStats:", e);
|
|
35
|
-
throw e;
|
|
36
27
|
}
|
|
28
|
+
|
|
29
|
+
const params = new URLSearchParams({
|
|
30
|
+
pubkey: pubKey,
|
|
31
|
+
first: String(first),
|
|
32
|
+
});
|
|
33
|
+
return beraFetchJson<GetValidatorBlockStatsQuery>({
|
|
34
|
+
url: `/api/pol/validator-block-stats?${params}`,
|
|
35
|
+
name: "pol-validator-block-stats",
|
|
36
|
+
type: "rest",
|
|
37
|
+
});
|
|
37
38
|
}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
GetValidatorAnalytics,
|
|
5
|
-
type GetValidatorAnalyticsQuery,
|
|
6
|
-
type GetValidatorAnalyticsQueryVariables,
|
|
7
|
-
} from "@berachain/graphql/pol/subgraph";
|
|
3
|
+
import type { GetValidatorAnalyticsQuery } from "@berachain/graphql/pol/subgraph";
|
|
8
4
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { BeraError } from "../../errors/BeraError";
|
|
6
|
+
import { beraFetchJson } from "../../utils/beraFetch";
|
|
11
7
|
|
|
8
|
+
/** Browser-only. Hits `/api/pol/validator-analytics`. */
|
|
12
9
|
export async function getValidatorAnalytics({
|
|
13
10
|
pubkey,
|
|
14
11
|
dayRange,
|
|
15
|
-
|
|
16
|
-
}: BeraJS.BaseFunctionArgs & {
|
|
12
|
+
}: {
|
|
17
13
|
pubkey: Address;
|
|
18
14
|
dayRange: number;
|
|
19
15
|
}): Promise<GetValidatorAnalyticsQuery | undefined> {
|
|
20
|
-
|
|
16
|
+
if (typeof window === "undefined") {
|
|
17
|
+
throw new BeraError({
|
|
18
|
+
message:
|
|
19
|
+
"getValidatorAnalytics is browser-only; call from a Client Component / SWR hook",
|
|
20
|
+
level: "error",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
24
|
+
const params = new URLSearchParams({
|
|
25
|
+
pubkey,
|
|
26
|
+
dayRange: String(dayRange),
|
|
27
|
+
});
|
|
28
|
+
return beraFetchJson<GetValidatorAnalyticsQuery>({
|
|
29
|
+
url: `/api/pol/validator-analytics?${params}`,
|
|
30
|
+
name: "pol-validator-analytics",
|
|
31
|
+
type: "rest",
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
-
return result.data;
|
|
34
33
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import type { GetValidatorIncentiveDistributionQuery } from "@berachain/graphql/pol/subgraph";
|
|
4
|
+
|
|
5
|
+
import { BeraError } from "../../errors/BeraError";
|
|
6
|
+
import { beraFetchJson } from "../../utils/beraFetch";
|
|
7
|
+
|
|
8
|
+
/** Browser-only. Hits `/api/pol/validator-incentive-distribution`. */
|
|
9
|
+
export async function getValidatorIncentiveDistribution({
|
|
10
|
+
pubkey,
|
|
11
|
+
dayRange,
|
|
12
|
+
}: {
|
|
13
|
+
pubkey: Address;
|
|
14
|
+
dayRange: number;
|
|
15
|
+
}): Promise<GetValidatorIncentiveDistributionQuery | undefined> {
|
|
16
|
+
if (typeof window === "undefined") {
|
|
17
|
+
throw new BeraError({
|
|
18
|
+
message:
|
|
19
|
+
"getValidatorIncentiveDistribution is browser-only; call from a Client Component / SWR hook",
|
|
20
|
+
level: "error",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
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
|
+
});
|
|
33
|
+
}
|
|
@@ -51,7 +51,7 @@ export function getValidatorBoostApy({
|
|
|
51
51
|
|
|
52
52
|
const boostApy =
|
|
53
53
|
(returnPerBgt *
|
|
54
|
-
Number(validator.dynamicData?.
|
|
54
|
+
Number(validator.dynamicData?.lastDayDistributedRewards ?? 0) *
|
|
55
55
|
365) /
|
|
56
56
|
(validatorActiveBoostAmount * bgtPrice);
|
|
57
57
|
|
package/src/enum/contracts.ts
CHANGED
package/src/enum/exports.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../governance";
|