@berachain/berajs 0.2.8-beta.8 → 0.2.9
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-DBOIV65x.d.ts +144 -0
- package/dist/abi/exports.mjs +3 -4
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.mjs +12 -0
- package/dist/actions/exports.d.ts +108 -187
- package/dist/actions/exports.mjs +97 -158
- 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-VA3BQ34H.mjs → chunk-3EARVV7K.mjs} +20 -9
- package/dist/chunk-4Z4AK6SH.mjs +211 -0
- package/dist/chunk-75M6TF7M.mjs +25 -0
- package/dist/chunk-AFN4CVD3.mjs +326 -0
- package/dist/{chunk-7TFV6UKF.mjs → chunk-BGMRHTBQ.mjs} +0 -1
- package/dist/{chunk-3M47ZRXT.mjs → chunk-CDFWPU2R.mjs} +73 -17
- package/dist/{chunk-GWSTVITN.mjs → chunk-CDK4YV3D.mjs} +0 -1
- package/dist/{chunk-KL6YZ5VR.mjs → chunk-DKMAIU74.mjs} +0 -1
- package/dist/chunk-EXIUPSFN.mjs +86 -0
- package/dist/{chunk-VA5L5FDG.mjs → chunk-FFB5LFDW.mjs} +2 -3
- package/dist/{chunk-ZCEFC2TK.mjs → chunk-HQCOU6GY.mjs} +0 -1
- package/dist/{chunk-SGZP4O6R.mjs → chunk-HSSJKHZ4.mjs} +11 -11
- package/dist/{chunk-7QKRRIHI.mjs → chunk-J5I45WGQ.mjs} +77 -152
- package/dist/chunk-KQUMKB66.mjs +89 -0
- package/dist/{chunk-JA4DHMTG.mjs → chunk-NBYLMO2L.mjs} +0 -1
- package/dist/{chunk-4GFN4LEP.mjs → chunk-NPBQLVL3.mjs} +4 -21
- package/dist/{chunk-I3FTWD6I.mjs → chunk-O2NQFKJK.mjs} +1 -1
- package/dist/{chunk-2R73G2PO.mjs → chunk-QJIXTYTZ.mjs} +121 -765
- package/dist/{chunk-GLWPRM33.mjs → chunk-SGIJVHZO.mjs} +0 -1
- package/dist/chunk-SZ5C44L5.mjs +35 -0
- package/dist/{chunk-5NMATIH4.mjs → chunk-WXXOISTU.mjs} +1 -35
- package/dist/chunk-XIYN6AL6.mjs +160 -0
- package/dist/contexts/exports.d.ts +2 -2
- package/dist/contexts/exports.mjs +11 -9
- package/dist/enum/exports.d.ts +1 -1
- package/dist/enum/exports.mjs +3 -16
- package/dist/enum/governance/exports.d.ts +60 -0
- package/dist/enum/governance/exports.mjs +14 -0
- package/dist/errors/exports.d.ts +5 -90
- package/dist/errors/exports.mjs +19 -10
- package/dist/exports-BcUTGFUb.d.ts +40 -0
- package/dist/{getValidatorQueuedOperatorAddress-BcyxE9uw.d.ts → getValidatorQueuedOperatorAddress-Dw5KN5sh.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 +80 -236
- package/dist/hooks/exports.mjs +609 -1508
- package/dist/hooks/governance/exports.d.ts +181 -0
- package/dist/hooks/governance/exports.mjs +888 -0
- package/dist/pol.d-CqPA9K6m.d.ts +142 -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 +24 -7
- package/dist/utils/exports.mjs +49 -11
- package/package.json +60 -13
- package/src/actions/__test/transports.ts +61 -0
- package/src/actions/clients/BeraApolloClient.ts +9 -0
- package/src/actions/clients/exports.ts +4 -0
- package/src/actions/clients/getApolloClient.ts +70 -25
- package/src/actions/clients/getEnsoClient.ts +20 -9
- package/src/actions/dex/aggregators/base.ts +1 -1
- 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/exports.ts +5 -10
- 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 +27 -0
- package/src/actions/pol/getAutoclaimedIncentives.ts +30 -0
- package/src/actions/pol/getBeraTokenTotalSupply.ts +45 -0
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +35 -0
- package/src/actions/pol/getEarnedStakedBeraVault.ts +15 -9
- 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/getSWBeraVaultMetadata.ts +1 -1
- package/src/actions/pol/getStakingDailyAssets.ts +11 -8
- 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/data/contracts.ts +5 -0
- 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 +15 -2
- 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 -16
- package/src/hooks/governance/exports.ts +14 -0
- package/src/hooks/honey/useHoney24hVolume.ts +16 -0
- package/src/hooks/pol/useAutoclaimedIncentives.ts +49 -0
- package/src/hooks/pol/useStakedAPR.ts +2 -2
- package/src/hooks/pol/useStakedSnapshots.ts +5 -9
- package/src/hooks/validators/useValidator.ts +2 -0
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +39 -0
- package/src/types/bribe-boost.d.ts +8 -0
- package/src/types/exports.ts +0 -1
- package/src/types/governance/exports.ts +1 -0
- package/src/utils/beraFetch.ts +76 -15
- package/src/utils/exports.ts +1 -0
- package/src/utils/getServerSideClient.ts +4 -2
- 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-A8XJ6QR9.d.cts +0 -57
- package/dist/RequestError-Dk97z8rm.d.ts +0 -57
- package/dist/abi/exports.cjs +0 -4453
- 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 -914
- package/dist/actions/exports.cjs.map +0 -1
- package/dist/actions/exports.d.cts +0 -1644
- package/dist/actions/exports.mjs.map +0 -1
- package/dist/chunk-2R73G2PO.mjs.map +0 -1
- package/dist/chunk-3M47ZRXT.mjs.map +0 -1
- package/dist/chunk-4GFN4LEP.mjs.map +0 -1
- package/dist/chunk-5N7QQS55.cjs +0 -130
- package/dist/chunk-5N7QQS55.cjs.map +0 -1
- package/dist/chunk-5NMATIH4.mjs.map +0 -1
- package/dist/chunk-7QKRRIHI.mjs.map +0 -1
- package/dist/chunk-7TFV6UKF.mjs.map +0 -1
- package/dist/chunk-A4FPM7U3.cjs +0 -63
- package/dist/chunk-A4FPM7U3.cjs.map +0 -1
- package/dist/chunk-BDHINMWQ.cjs +0 -417
- package/dist/chunk-BDHINMWQ.cjs.map +0 -1
- package/dist/chunk-BEHP54S3.cjs +0 -24
- package/dist/chunk-BEHP54S3.cjs.map +0 -1
- package/dist/chunk-EGDXV2PT.cjs +0 -36
- package/dist/chunk-EGDXV2PT.cjs.map +0 -1
- package/dist/chunk-EWBKSMPG.cjs +0 -13
- package/dist/chunk-EWBKSMPG.cjs.map +0 -1
- package/dist/chunk-F6ZW7ZDD.cjs +0 -403
- package/dist/chunk-F6ZW7ZDD.cjs.map +0 -1
- package/dist/chunk-FTXTRUYT.cjs +0 -170
- package/dist/chunk-FTXTRUYT.cjs.map +0 -1
- package/dist/chunk-GLWPRM33.mjs.map +0 -1
- package/dist/chunk-GWSTVITN.mjs.map +0 -1
- package/dist/chunk-H3Z37RYU.cjs +0 -15
- package/dist/chunk-H3Z37RYU.cjs.map +0 -1
- package/dist/chunk-I3FTWD6I.mjs.map +0 -1
- package/dist/chunk-JA4DHMTG.mjs.map +0 -1
- package/dist/chunk-KL6YZ5VR.mjs.map +0 -1
- package/dist/chunk-MXWPP6MS.cjs +0 -572
- package/dist/chunk-MXWPP6MS.cjs.map +0 -1
- package/dist/chunk-SGZP4O6R.mjs.map +0 -1
- package/dist/chunk-TDW5SPXR.cjs +0 -244
- package/dist/chunk-TDW5SPXR.cjs.map +0 -1
- package/dist/chunk-TGK3IXDN.cjs +0 -169
- package/dist/chunk-TGK3IXDN.cjs.map +0 -1
- package/dist/chunk-TJEW6YCJ.cjs +0 -97
- package/dist/chunk-TJEW6YCJ.cjs.map +0 -1
- package/dist/chunk-VA3BQ34H.mjs.map +0 -1
- package/dist/chunk-VA5L5FDG.mjs.map +0 -1
- package/dist/chunk-XSGCRLSD.cjs +0 -1844
- package/dist/chunk-XSGCRLSD.cjs.map +0 -1
- package/dist/chunk-XV3GG3HC.cjs +0 -135
- package/dist/chunk-XV3GG3HC.cjs.map +0 -1
- package/dist/chunk-Y5B224UX.cjs +0 -4698
- package/dist/chunk-Y5B224UX.cjs.map +0 -1
- package/dist/chunk-ZBTRKBSI.mjs +0 -169
- package/dist/chunk-ZBTRKBSI.mjs.map +0 -1
- package/dist/chunk-ZCEFC2TK.mjs.map +0 -1
- package/dist/contexts/exports.cjs +0 -83
- 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 -59
- 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 -39
- package/dist/errors/exports.cjs.map +0 -1
- package/dist/errors/exports.d.cts +0 -413
- 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 -8333
- package/dist/hooks/exports.cjs.map +0 -1
- package/dist/hooks/exports.d.cts +0 -1748
- 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 -787
- package/dist/utils/exports.cjs.map +0 -1
- package/dist/utils/exports.d.cts +0 -412
- package/dist/utils/exports.mjs.map +0 -1
- package/src/actions/dex/getIsTokenExploited.ts +0 -63
- package/src/actions/honey/getHoneyGlobalData.ts +0 -21
- package/src/hooks/dex/useExploitedTokens.ts +0 -57
- package/src/hooks/honey/useHoneyGlobalData.ts +0 -23
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { erc20Abi, formatUnits, type PublicClient } from "viem";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
GetExploitedTokens,
|
|
5
|
-
type GetExploitedTokensQuery,
|
|
6
|
-
type GetExploitedTokensQueryVariables,
|
|
7
|
-
} from "@berachain/graphql/dex/subgraph";
|
|
8
|
-
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
9
|
-
|
|
10
|
-
import type { Token } from "../../types/dex";
|
|
11
|
-
import { getApolloClient } from "../clients/getApolloClient";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 0.01% of the total supply
|
|
15
|
-
*/
|
|
16
|
-
const BEX_EXPLOITED_TOKEN_THRESHOLD = 0.0001 as const;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* This function checks if a token was exploited by frontrunning its deployment
|
|
20
|
-
* and creating a large amount of balance in the BEX's vault internal balance.
|
|
21
|
-
*
|
|
22
|
-
* There is a vulnerability on Balancer V2 that might lead an hacker to create a lot of internal balance of a token before it's
|
|
23
|
-
* actually deployed. In this function we're checking if wallet has an internal balance of more than BEX_EXPLOITED_TOKEN_THRESHOLD
|
|
24
|
-
*
|
|
25
|
-
* @see https://forum.balancer.fi/t/balancer-v2-token-frontrun-vulnerability-disclosure/6309
|
|
26
|
-
* @returns true if the token might have been exploited, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
export async function getIsTokenExploited({
|
|
29
|
-
token,
|
|
30
|
-
publicClient,
|
|
31
|
-
...args
|
|
32
|
-
}: BeraJS.BaseFunctionArgs & {
|
|
33
|
-
token: Token;
|
|
34
|
-
publicClient: PublicClient;
|
|
35
|
-
}) {
|
|
36
|
-
const bexSubgraphClient = getApolloClient("bex.subgraph", args);
|
|
37
|
-
|
|
38
|
-
const totalSupply = await publicClient.readContract({
|
|
39
|
-
address: token.address,
|
|
40
|
-
abi: erc20Abi,
|
|
41
|
-
functionName: "totalSupply",
|
|
42
|
-
});
|
|
43
|
-
const balanceThreshold = BigNumber(
|
|
44
|
-
formatUnits(totalSupply, token.decimals),
|
|
45
|
-
).multipliedBy(BEX_EXPLOITED_TOKEN_THRESHOLD);
|
|
46
|
-
|
|
47
|
-
const { data } = await bexSubgraphClient.query<
|
|
48
|
-
GetExploitedTokensQuery,
|
|
49
|
-
GetExploitedTokensQueryVariables
|
|
50
|
-
>({
|
|
51
|
-
query: GetExploitedTokens,
|
|
52
|
-
variables: {
|
|
53
|
-
token: token.address,
|
|
54
|
-
balance: balanceThreshold.toFixed(),
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (data.userInternalBalances.length > 0) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GetGlobalData,
|
|
3
|
-
type GetGlobalDataQuery,
|
|
4
|
-
type GetGlobalDataQueryVariables,
|
|
5
|
-
} from "@berachain/graphql/honey";
|
|
6
|
-
|
|
7
|
-
import { getApolloClient } from "../clients/getApolloClient";
|
|
8
|
-
|
|
9
|
-
export async function getHoneyGlobalData({
|
|
10
|
-
...args
|
|
11
|
-
}: BeraJS.BaseFunctionArgs = {}) {
|
|
12
|
-
const client = getApolloClient("honey.subgraph", args);
|
|
13
|
-
const result = await client.query<
|
|
14
|
-
GetGlobalDataQuery,
|
|
15
|
-
GetGlobalDataQueryVariables
|
|
16
|
-
>({
|
|
17
|
-
query: GetGlobalData,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
return result.data;
|
|
21
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
import type { Address } from "viem";
|
|
3
|
-
|
|
4
|
-
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
|
-
|
|
6
|
-
import { getIsTokenExploited } from "../../actions/dex/getIsTokenExploited";
|
|
7
|
-
import { assertPublicClient } from "../../errors/assert";
|
|
8
|
-
import type { Token } from "../../types/dex";
|
|
9
|
-
|
|
10
|
-
export const useExploitedTokensQueryKey = (tokens: Token[] | undefined) => {
|
|
11
|
-
const filteredTokens = tokens?.filter((token) => token.address);
|
|
12
|
-
if (!filteredTokens || filteredTokens.length === 0) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return ["useExploitedTokens", filteredTokens] as const;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* This hook checks if any of provided tokens might have been exploited by frontrunning its deployment.
|
|
19
|
-
*
|
|
20
|
-
* @see {@link getIsTokenExploited} for more details
|
|
21
|
-
* @returns a record of tokens and whether they might have been exploited
|
|
22
|
-
*/
|
|
23
|
-
export const useExploitedTokens = ({
|
|
24
|
-
tokens,
|
|
25
|
-
}: {
|
|
26
|
-
tokens: Token[] | undefined;
|
|
27
|
-
}) => {
|
|
28
|
-
const QUERY_KEY = useExploitedTokensQueryKey(tokens);
|
|
29
|
-
const publicClient = usePublicClient();
|
|
30
|
-
const swrResponse = useSWR(
|
|
31
|
-
publicClient ? QUERY_KEY : null,
|
|
32
|
-
async ([, tokens]) => {
|
|
33
|
-
assertPublicClient(publicClient);
|
|
34
|
-
|
|
35
|
-
const exploitedTokens = await Promise.all(
|
|
36
|
-
tokens.map((token) =>
|
|
37
|
-
getIsTokenExploited({
|
|
38
|
-
token,
|
|
39
|
-
publicClient,
|
|
40
|
-
}),
|
|
41
|
-
),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return exploitedTokens.reduce<Record<Address, boolean>>(
|
|
45
|
-
(acc, curr, idx) => {
|
|
46
|
-
if (curr !== undefined) {
|
|
47
|
-
acc[tokens[idx].address] = curr;
|
|
48
|
-
}
|
|
49
|
-
return acc;
|
|
50
|
-
},
|
|
51
|
-
{},
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return { ...swrResponse, refresh: () => swrResponse.mutate() };
|
|
57
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import useSWR from "swr";
|
|
2
|
-
|
|
3
|
-
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
4
|
-
|
|
5
|
-
import { getHoneyGlobalData } from "../../actions/honey/getHoneyGlobalData";
|
|
6
|
-
|
|
7
|
-
export function useHoneyGlobalData() {
|
|
8
|
-
const response = useSWR(["useHoneyGlobalData"], () => getHoneyGlobalData());
|
|
9
|
-
|
|
10
|
-
const dailyVolume = response.data?.honeySnapshots.reduce(
|
|
11
|
-
(acc, curr) => new BigNumber(curr.totalVolume).plus(acc),
|
|
12
|
-
new BigNumber(0),
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
...response,
|
|
17
|
-
data: {
|
|
18
|
-
...response.data,
|
|
19
|
-
dailyVolume,
|
|
20
|
-
},
|
|
21
|
-
refresh: () => response.mutate(),
|
|
22
|
-
};
|
|
23
|
-
}
|