@berachain/berajs 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/clients/exports.d.ts +5 -21
- package/dist/actions/clients/exports.mjs +5 -7
- package/dist/actions/exports.d.ts +65 -29
- package/dist/actions/exports.mjs +6 -36
- package/dist/actions/server/exports.mjs +2 -2
- package/dist/{chunk-UD5IUNCW.mjs → chunk-4ML4Y6UN.mjs} +14 -2
- package/dist/{chunk-7YVNSDXG.mjs → chunk-FGION6F6.mjs} +1 -1
- package/dist/{chunk-3JJLQ2JX.mjs → chunk-MKSFQIKC.mjs} +1 -4
- package/dist/{chunk-ZLTMIFCZ.mjs → chunk-RFJGL4MF.mjs} +3 -3
- package/dist/{chunk-Y6THHG77.mjs → chunk-T43JPYQS.mjs} +1 -1
- package/dist/{chunk-SXUNCX5E.mjs → chunk-W2VODV76.mjs} +3 -7
- package/dist/{chunk-VAA2FVPP.mjs → chunk-XDG26EG6.mjs} +90 -183
- package/dist/{chunk-MRQGHXAN.mjs → chunk-YLTWPFCJ.mjs} +2 -17
- package/dist/contexts/exports.mjs +4 -4
- package/dist/errors/exports.mjs +2 -2
- package/dist/{getApolloClient-BcUTGFUb.d.ts → getApolloClient-MWm_iq4u.d.ts} +4 -5
- package/dist/{getValidatorQueuedOperatorAddress-Cxt-DlL_.d.ts → getValidatorQueuedOperatorAddress-Cc05dlO3.d.ts} +6 -57
- package/dist/{global.d-q_LQWQqs.d.ts → global.d-CR3zicga.d.ts} +2 -7
- package/dist/hooks/exports.d.ts +109 -318
- package/dist/hooks/exports.mjs +102 -345
- package/dist/hooks/governance/exports.d.ts +10 -10
- package/dist/hooks/governance/exports.mjs +8 -20
- package/dist/types/exports.d.ts +1 -1
- package/dist/utils/exports.mjs +2 -2
- package/package.json +3 -3
- package/src/actions/clients/exports.ts +0 -1
- package/src/actions/clients/fetchBeep.ts +0 -7
- package/src/actions/clients/fetchOpenApi.ts +4 -4
- package/src/actions/clients/fetchOpenApi.unit.test.ts +3 -19
- package/src/actions/clients/getApolloClient.ts +4 -9
- package/src/actions/exports.ts +0 -1
- package/src/actions/honey/getChartData.ts +3 -44
- package/src/actions/honey/getHoney24hVolume.ts +2 -21
- package/src/actions/honey/getHoneyTxns.ts +1 -49
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +3 -3
- package/src/actions/pol/getEarnedStakedBeraVault.ts +0 -15
- package/src/actions/pol/getGlobalData.ts +10 -29
- package/src/actions/pol/getRewardVaults.ts +4 -4
- package/src/actions/pol/getSWBeraVaultMetadata.ts +0 -7
- package/src/actions/pol/getStakingDailyAssets.ts +0 -14
- package/src/actions/validators/getApiEnrichedAllocation.ts +1 -1
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +2 -24
- package/src/errors/RequestError.ts +3 -3
- package/src/hooks/bend/useGetConvertToAssets.ts +1 -8
- package/src/hooks/dex/useAggregatorsQuotes.ts +3 -1
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +1 -6
- package/src/hooks/dex/useAllUserPools.ts +1 -8
- package/src/hooks/dex/useApiPool.ts +1 -8
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +0 -1
- package/src/hooks/dex/useOnChainPoolData.ts +2 -3
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -7
- package/src/hooks/dex/usePoolHistoricalData.ts +1 -6
- package/src/hooks/dex/usePools.ts +2 -2
- package/src/hooks/enso/useBendZapSupply.ts +1 -1
- package/src/hooks/enso/useEnsoSwapBundle.ts +1 -1
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +1 -5
- package/src/hooks/enso/useZapStakeBera.ts +0 -3
- package/src/hooks/governance/usePollProposal.ts +4 -7
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -6
- package/src/hooks/governance/usePollUserDelegates.ts +1 -6
- package/src/hooks/governance/useProposalFromTx.ts +3 -5
- package/src/hooks/governance/useProposalSnapshot.ts +2 -2
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/governance/useProposalTimelockState.ts +2 -2
- package/src/hooks/honey/useCappedGlobally.ts +1 -6
- package/src/hooks/honey/useCappedRelatively.ts +1 -6
- package/src/hooks/honey/useCollateralWeights.ts +1 -6
- package/src/hooks/honey/useHoney24hVolume.ts +1 -5
- package/src/hooks/honey/useHoneyBalances.ts +1 -6
- package/src/hooks/honey/useHoneyChartData.ts +3 -11
- package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -6
- package/src/hooks/honey/useIsBadCollateralAsset.ts +1 -6
- package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -6
- package/src/hooks/honey/usePythLatestPrices.ts +4 -6
- package/src/hooks/pol/useAutoclaimedIncentives.ts +1 -6
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +1 -6
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +1 -6
- package/src/hooks/pol/useBgtUnstakedBalance.ts +1 -6
- package/src/hooks/pol/useClaimableFees.ts +1 -5
- package/src/hooks/pol/useHighestVaultsAPR.ts +2 -5
- package/src/hooks/pol/usePollGlobalData.ts +1 -6
- package/src/hooks/pol/usePollMarkets.ts +1 -6
- package/src/hooks/pol/useQueuedBeraUnlock.ts +1 -10
- package/src/hooks/pol/useRewardVault.ts +2 -2
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +2 -2
- package/src/hooks/pol/useRewardVaultFromToken.ts +23 -29
- package/src/hooks/pol/useRewardVaultIncentives.ts +1 -6
- package/src/hooks/pol/useRewardVaultRewards.ts +1 -6
- package/src/hooks/pol/useRewardVaults.ts +1 -6
- package/src/hooks/pol/useStakedAPR.ts +1 -6
- package/src/hooks/pol/useStakedSnapshots.ts +3 -8
- package/src/hooks/pol/useTotalStakedAmount.ts +1 -6
- package/src/hooks/pol/useUserVaultInfo.ts +1 -6
- package/src/hooks/pol/useUserVaults.ts +1 -5
- package/src/hooks/pol/useVaultHistory.ts +1 -6
- package/src/hooks/pol/useVaultValidators.ts +1 -6
- package/src/hooks/tokens/useMultipleTokenInformation.ts +1 -6
- package/src/hooks/tokens/usePollAllowances.ts +1 -7
- package/src/hooks/tokens/usePollBalance.ts +0 -3
- package/src/hooks/tokens/usePollWalletBalances.ts +1 -1
- package/src/hooks/tokens/useStakingTokenInformation.ts +1 -10
- package/src/hooks/tokens/useTokenInformation.ts +1 -6
- package/src/hooks/validators/useAllValidators.ts +1 -6
- package/src/hooks/validators/useApiValidator.ts +1 -6
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -3
- package/src/hooks/validators/useDefaultRewardAllocation.ts +1 -6
- package/src/hooks/validators/useManagedValidatorRole.ts +0 -1
- package/src/hooks/validators/useOnChainValidator.ts +1 -8
- package/src/hooks/validators/useStakingPoolBatch.ts +1 -6
- package/src/hooks/validators/useUserActiveValidators.ts +1 -6
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -3
- package/src/hooks/validators/useUserClaimableIncentives.ts +2 -2
- package/src/hooks/validators/useUserStakingPositions.ts +1 -8
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -3
- package/src/hooks/validators/useValidatorCommission.ts +1 -6
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +1 -3
- package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -6
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -6
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -6
- package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -6
- package/src/types/global.d.ts +5 -7
- package/src/actions/clients/fetchRailwayBackend.ts +0 -34
- package/src/actions/pol/getGlobalCuttingBoard.ts +0 -25
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +0 -24
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { getApolloClient } from "../clients/getApolloClient";
|
|
13
13
|
|
|
14
|
-
export interface
|
|
15
|
-
|
|
14
|
+
export interface GetRewardVaultData {
|
|
15
|
+
rewardVaultList: ApiVaultFragment[];
|
|
16
16
|
pagination: {
|
|
17
17
|
currentPage: number;
|
|
18
18
|
totalCount: number;
|
|
@@ -26,7 +26,7 @@ export async function getRewardVaults({
|
|
|
26
26
|
}: {
|
|
27
27
|
filter?: GetVaultsQueryVariables;
|
|
28
28
|
publicClient?: PublicClient | undefined;
|
|
29
|
-
} & BeraJS.BaseFunctionArgs = {}): Promise<
|
|
29
|
+
} & BeraJS.BaseFunctionArgs = {}): Promise<GetRewardVaultData> {
|
|
30
30
|
const bexApiGraphqlClient = getApolloClient("api", args);
|
|
31
31
|
|
|
32
32
|
const res = await bexApiGraphqlClient.query<
|
|
@@ -101,6 +101,6 @@ export async function getRewardVaults({
|
|
|
101
101
|
|
|
102
102
|
return {
|
|
103
103
|
pagination: res.data.polGetRewardVaults.pagination,
|
|
104
|
-
|
|
104
|
+
rewardVaultList: vaults!,
|
|
105
105
|
};
|
|
106
106
|
}
|
|
@@ -3,7 +3,6 @@ import { type Address, erc20Abi, erc4626Abi, type PublicClient } from "viem";
|
|
|
3
3
|
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
4
4
|
|
|
5
5
|
import { assertPublicClient } from "../../errors/assert";
|
|
6
|
-
import { getIncentiveFeeClaimStats } from "./getIncentiveFeeClaimStats";
|
|
7
6
|
import { getStakeWithdrawalCooldown } from "./getStakeWithdrawalCooldown";
|
|
8
7
|
|
|
9
8
|
export interface VaultMetadata {
|
|
@@ -21,8 +20,6 @@ export interface VaultMetadata {
|
|
|
21
20
|
};
|
|
22
21
|
totalWBeraIssued: string;
|
|
23
22
|
lockPeriod?: number;
|
|
24
|
-
totalBuyBacks: number;
|
|
25
|
-
totalBuyBacksInLast24Hours: number;
|
|
26
23
|
address: Address;
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
@@ -63,7 +60,6 @@ export async function getSWBeraVaultMetadata({
|
|
|
63
60
|
tvl24HoursAgo,
|
|
64
61
|
underlyingTotalSupply,
|
|
65
62
|
lockPeriod,
|
|
66
|
-
incentiveFeeClaimStats,
|
|
67
63
|
] = await Promise.all([
|
|
68
64
|
publicClient.readContract({
|
|
69
65
|
address,
|
|
@@ -123,7 +119,6 @@ export async function getSWBeraVaultMetadata({
|
|
|
123
119
|
publicClient,
|
|
124
120
|
address,
|
|
125
121
|
}),
|
|
126
|
-
getIncentiveFeeClaimStats(),
|
|
127
122
|
]);
|
|
128
123
|
const exchangeRateWindowAgo = new BigNumber(
|
|
129
124
|
oneShareWorthWindowAgo.toString(),
|
|
@@ -157,8 +152,6 @@ export async function getSWBeraVaultMetadata({
|
|
|
157
152
|
.dividedBy(1e18)
|
|
158
153
|
.toString(),
|
|
159
154
|
lockPeriod,
|
|
160
|
-
totalBuyBacks: incentiveFeeClaimStats.sumAllClaims,
|
|
161
|
-
totalBuyBacksInLast24Hours: incentiveFeeClaimStats.sumClaimsInLast24Hours,
|
|
162
155
|
};
|
|
163
156
|
} catch (error) {
|
|
164
157
|
console.error("Failed to get SW Bera Vault Metadata", error);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
4
3
|
import { fetchBeep } from "../clients/fetchBeep";
|
|
5
|
-
import { fetchRailwayBackend } from "../clients/fetchRailwayBackend";
|
|
6
4
|
|
|
7
5
|
export async function getStakingDailyAssets({
|
|
8
6
|
address,
|
|
@@ -11,18 +9,6 @@ export async function getStakingDailyAssets({
|
|
|
11
9
|
address: Address;
|
|
12
10
|
range: 30 | 60 | 90;
|
|
13
11
|
}) {
|
|
14
|
-
const { config } = parseBaseArgs({});
|
|
15
|
-
|
|
16
|
-
// TODO(beep): remove this entire block once `beep` is deployed on every
|
|
17
|
-
// chain. It is the only legacy-Railway-specific code left here; deleting it
|
|
18
|
-
// leaves the `beep` path below as the sole implementation.
|
|
19
|
-
if (!config.beep) {
|
|
20
|
-
return fetchRailwayBackend("/vaults/{vault}/stats-by-day", {
|
|
21
|
-
path: { vault: address },
|
|
22
|
-
query: { days: `${range}` },
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
12
|
// beep backend (next-gen), typed against `@berachain/graphql/beep`.
|
|
27
13
|
return fetchBeep("/v0/stake/{vault}/stats-by-day", {
|
|
28
14
|
path: { vault: address },
|
|
@@ -24,7 +24,7 @@ export async function getApiEnrichedAllocation({
|
|
|
24
24
|
percentage: allocation.percentage,
|
|
25
25
|
receiver: allocation.receiver,
|
|
26
26
|
startBlock,
|
|
27
|
-
receivingVault: vaults?.
|
|
27
|
+
receivingVault: vaults?.rewardVaultList.find((vault) =>
|
|
28
28
|
isAddressEqual(vault.address, allocation.receiver),
|
|
29
29
|
),
|
|
30
30
|
};
|
|
@@ -3,12 +3,10 @@ import type { Address } from "viem";
|
|
|
3
3
|
import type { ValidatorIncentivesResponse } from "@berachain/graphql/beep";
|
|
4
4
|
|
|
5
5
|
import { BeraError } from "../../errors/BeraError";
|
|
6
|
-
import { beraFetchJson } from "../../utils/beraFetch";
|
|
7
6
|
import { calculateTimestampFromDays } from "../../utils/formatTimestamps";
|
|
8
|
-
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
9
7
|
import { fetchBeep } from "../clients/fetchBeep";
|
|
10
8
|
|
|
11
|
-
/** Browser-only. Reads
|
|
9
|
+
/** Browser-only. Reads validator incentive distribution from beep. */
|
|
12
10
|
export async function getValidatorIncentiveDistribution({
|
|
13
11
|
pubkey,
|
|
14
12
|
dayRange,
|
|
@@ -24,28 +22,8 @@ export async function getValidatorIncentiveDistribution({
|
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
const { config } = parseBaseArgs({});
|
|
28
|
-
|
|
29
|
-
// TODO(beep): remove this entire block (and the subgraph proxy route at
|
|
30
|
-
// `/api/pol/validator-incentive-distribution`) once `beep` is deployed on
|
|
31
|
-
// every chain. beep then becomes the sole implementation. The route already
|
|
32
|
-
// maps the subgraph response into beep's `ValidatorIncentivesResponse` shape,
|
|
33
|
-
// so the client consumes a single (beep) type regardless of source.
|
|
34
|
-
if (!config.beep) {
|
|
35
|
-
const params = new URLSearchParams({
|
|
36
|
-
pubkey,
|
|
37
|
-
dayRange: String(dayRange),
|
|
38
|
-
});
|
|
39
|
-
return beraFetchJson<ValidatorIncentivesResponse>({
|
|
40
|
-
url: `/api/pol/validator-incentive-distribution?${params}`,
|
|
41
|
-
name: "pol-validator-incentive-distribution",
|
|
42
|
-
type: "rest",
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
25
|
// beep backend (next-gen). It is a public (`NEXT_PUBLIC_*`) URL, so it can be
|
|
47
|
-
// called directly from the browser
|
|
48
|
-
// because it needs server-side auth headers.
|
|
26
|
+
// called directly from the browser — no Vercel proxy.
|
|
49
27
|
//
|
|
50
28
|
// beep's `after` cursor is in seconds; `calculateTimestampFromDays` returns
|
|
51
29
|
// microseconds, matching the subgraph's `timestamp_gte`. Pin it to the start
|
|
@@ -40,9 +40,9 @@ export class RequestError extends BeraError {
|
|
|
40
40
|
"https://open-api.openocean.finance/v4/bera/swap",
|
|
41
41
|
// vercel internal proxy
|
|
42
42
|
"/api/aggregators?aggregator",
|
|
43
|
-
// bonder endpoints have date-based query params
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
// beep (next-gen backend) bonder endpoints have date-based query params
|
|
44
|
+
// (e.g. ?start=2025-11-28) on both networks
|
|
45
|
+
mainnet.beep,
|
|
46
46
|
bepolia.beep,
|
|
47
47
|
];
|
|
48
48
|
|
|
@@ -15,7 +15,7 @@ export const useGetConvertToAssets = (
|
|
|
15
15
|
options?: DefaultHookOptions,
|
|
16
16
|
) => {
|
|
17
17
|
const publicClient = usePublicClient({ chainId: vaultChainId });
|
|
18
|
-
|
|
18
|
+
return useSWR(
|
|
19
19
|
publicClient && sharesAmount && vaultAddress
|
|
20
20
|
? ["useGetConvertToAssets", sharesAmount, vaultAddress, vaultChainId]
|
|
21
21
|
: null,
|
|
@@ -32,11 +32,4 @@ export const useGetConvertToAssets = (
|
|
|
32
32
|
...options,
|
|
33
33
|
},
|
|
34
34
|
);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
...swrResponse,
|
|
38
|
-
refresh: () => {
|
|
39
|
-
swrResponse.mutate();
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
35
|
};
|
|
@@ -12,7 +12,7 @@ export const useAggregatorsRouterFeeBps = () => {
|
|
|
12
12
|
const { config } = parseBaseArgs({
|
|
13
13
|
chainId: publicClient.chain?.id,
|
|
14
14
|
});
|
|
15
|
-
|
|
15
|
+
return useSWRImmutable(
|
|
16
16
|
publicClient &&
|
|
17
17
|
config.bex.aggregatorsRouter &&
|
|
18
18
|
config.bex.aggregatorsRouter !== zeroAddress
|
|
@@ -27,9 +27,4 @@ export const useAggregatorsRouterFeeBps = () => {
|
|
|
27
27
|
return Number(fee);
|
|
28
28
|
},
|
|
29
29
|
);
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...swrResponse,
|
|
33
|
-
refresh: swrResponse.mutate,
|
|
34
|
-
};
|
|
35
30
|
};
|
|
@@ -17,7 +17,7 @@ export const useAllUserPools = (
|
|
|
17
17
|
query: GetPoolsQueryVariables,
|
|
18
18
|
options?: DefaultHookOptions,
|
|
19
19
|
) => {
|
|
20
|
-
|
|
20
|
+
return useSWR(
|
|
21
21
|
useAllUserPoolsQueryKey({ query }),
|
|
22
22
|
async ([_, params]) => {
|
|
23
23
|
return getAllPools({
|
|
@@ -30,11 +30,4 @@ export const useAllUserPools = (
|
|
|
30
30
|
...options,
|
|
31
31
|
},
|
|
32
32
|
);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...swrResponse,
|
|
36
|
-
refresh: () => {
|
|
37
|
-
swrResponse.mutate();
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
33
|
};
|
|
@@ -24,7 +24,7 @@ export function useApiPool({
|
|
|
24
24
|
poolId: Hex;
|
|
25
25
|
account?: Address;
|
|
26
26
|
}) {
|
|
27
|
-
|
|
27
|
+
return useSWR(
|
|
28
28
|
useApiPoolQueryKey({ poolId, account }),
|
|
29
29
|
async ([, poolId, account]): Promise<MinimalPoolFragment> => {
|
|
30
30
|
if (account && !isAddress(account)) {
|
|
@@ -43,11 +43,4 @@ export function useApiPool({
|
|
|
43
43
|
refreshInterval: POLLING.NORMAL,
|
|
44
44
|
},
|
|
45
45
|
);
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
...res,
|
|
49
|
-
refresh: () => {
|
|
50
|
-
res.mutate();
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
46
|
}
|
|
@@ -65,7 +65,7 @@ export function useOnChainPoolData(poolId: string) {
|
|
|
65
65
|
data: poolData,
|
|
66
66
|
error,
|
|
67
67
|
isLoading,
|
|
68
|
-
mutate,
|
|
68
|
+
refresh: mutate,
|
|
69
69
|
} = useSWRImmutable(
|
|
70
70
|
// FIXME: why are we using useSWRImmutable when we fetch tokenSupply and swapFee?
|
|
71
71
|
publicClient ? QUERY_KEY : null,
|
|
@@ -145,7 +145,6 @@ export function useOnChainPoolData(poolId: string) {
|
|
|
145
145
|
data: pool,
|
|
146
146
|
error,
|
|
147
147
|
isLoading: isLoading || isTokenInformationLoading || isTokenPricesLoading,
|
|
148
|
-
mutate,
|
|
149
|
-
refresh: () => mutate(),
|
|
148
|
+
refresh: mutate,
|
|
150
149
|
};
|
|
151
150
|
}
|
|
@@ -29,7 +29,7 @@ export const usePollPoolCreationRelayerApproval = (
|
|
|
29
29
|
] as const)
|
|
30
30
|
: null;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return useSWR<boolean>(
|
|
33
33
|
QUERY_KEY,
|
|
34
34
|
async ([, account]) => {
|
|
35
35
|
assertPublicClient(publicClient);
|
|
@@ -46,10 +46,4 @@ export const usePollPoolCreationRelayerApproval = (
|
|
|
46
46
|
},
|
|
47
47
|
{ ...options },
|
|
48
48
|
);
|
|
49
|
-
|
|
50
|
-
const refreshPoolCreationApproval = () => {
|
|
51
|
-
swrResponse.mutate();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return { ...swrResponse, refreshPoolCreationApproval };
|
|
55
49
|
};
|
|
@@ -24,7 +24,7 @@ export const usePoolHistoricalData = (
|
|
|
24
24
|
? (["usePoolHistoricalData", poolId] as const)
|
|
25
25
|
: null;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
return useSWR<
|
|
28
28
|
PoolHistoricalDataFragment[] | undefined,
|
|
29
29
|
any,
|
|
30
30
|
typeof QUERY_KEY
|
|
@@ -38,9 +38,4 @@ export const usePoolHistoricalData = (
|
|
|
38
38
|
},
|
|
39
39
|
options,
|
|
40
40
|
);
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
...swrResponse,
|
|
44
|
-
refresh: () => void swrResponse.mutate(),
|
|
45
|
-
};
|
|
46
41
|
};
|
|
@@ -28,7 +28,7 @@ export const usePools = (
|
|
|
28
28
|
const {
|
|
29
29
|
data: userPools,
|
|
30
30
|
isLoading: isUserPoolsLoading,
|
|
31
|
-
|
|
31
|
+
refresh: mutateUserPools,
|
|
32
32
|
} = useAllUserPools({
|
|
33
33
|
userAddress: account,
|
|
34
34
|
chain: query.chain,
|
|
@@ -37,7 +37,7 @@ export const usePools = (
|
|
|
37
37
|
const {
|
|
38
38
|
data: pools,
|
|
39
39
|
isLoading: isPoolsLoading,
|
|
40
|
-
|
|
40
|
+
refresh: mutatePools,
|
|
41
41
|
error: poolsError,
|
|
42
42
|
} = useSWR(
|
|
43
43
|
usePoolsQueryKey({ query }),
|
|
@@ -29,7 +29,7 @@ export function useEnsoUserTokensWithBalances(
|
|
|
29
29
|
] as const)
|
|
30
30
|
: null;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return useSWR(
|
|
33
33
|
QUERY_KEY,
|
|
34
34
|
async ([, fromAddress, chainId]): Promise<BalanceToken[]> =>
|
|
35
35
|
getEnsoUserTokensWithBalances({
|
|
@@ -45,8 +45,4 @@ export function useEnsoUserTokensWithBalances(
|
|
|
45
45
|
...options,
|
|
46
46
|
},
|
|
47
47
|
);
|
|
48
|
-
return {
|
|
49
|
-
...swrResponse,
|
|
50
|
-
refresh: () => swrResponse.mutate(),
|
|
51
|
-
};
|
|
52
48
|
}
|
|
@@ -75,25 +75,22 @@ export const usePollProposal = (
|
|
|
75
75
|
switch (swrResponse.data.status) {
|
|
76
76
|
case ProposalStatus.Pending:
|
|
77
77
|
if (timestamp >= Number(swrResponse.data.voteStartAt)) {
|
|
78
|
-
swrResponse.
|
|
78
|
+
swrResponse.refresh();
|
|
79
79
|
}
|
|
80
80
|
break;
|
|
81
81
|
case ProposalStatus.Active:
|
|
82
82
|
if (timestamp >= Number(swrResponse.data.voteEndAt)) {
|
|
83
|
-
swrResponse.
|
|
83
|
+
swrResponse.refresh();
|
|
84
84
|
}
|
|
85
85
|
break;
|
|
86
86
|
case ProposalStatus.InQueue:
|
|
87
87
|
if (Date.now() / 1000 + 1 >= Number(swrResponse.data.queueEnd)) {
|
|
88
|
-
swrResponse.
|
|
88
|
+
swrResponse.refresh();
|
|
89
89
|
}
|
|
90
90
|
break;
|
|
91
91
|
}
|
|
92
92
|
}, [swrResponse.data?.status, timestamp]);
|
|
93
93
|
|
|
94
94
|
// const votes = swrResponse.data?.votes.nodes ?? [];
|
|
95
|
-
return
|
|
96
|
-
...swrResponse,
|
|
97
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
98
|
-
};
|
|
95
|
+
return swrResponse;
|
|
99
96
|
};
|
|
@@ -18,7 +18,7 @@ export const usePollProposalThreshold = (
|
|
|
18
18
|
? (["usePollProposalThreshold", governorAddress] as const)
|
|
19
19
|
: null;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
return useSWR<{ votesThreshold: string }, any, typeof QUERY_KEY>(
|
|
22
22
|
QUERY_KEY,
|
|
23
23
|
async ([, governorAddress]) => {
|
|
24
24
|
assertPublicClient(publicClient);
|
|
@@ -34,9 +34,4 @@ export const usePollProposalThreshold = (
|
|
|
34
34
|
refreshInterval: POLLING.SLOW,
|
|
35
35
|
},
|
|
36
36
|
);
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
...swrResponse,
|
|
40
|
-
refresh: swrResponse.mutate,
|
|
41
|
-
};
|
|
42
37
|
};
|
|
@@ -25,7 +25,7 @@ export const usePollUserDelegates = (
|
|
|
25
25
|
? (["usePollUserDelegates", account] as const)
|
|
26
26
|
: null;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
return useSWR<
|
|
29
29
|
{ delegate: Address; currentVotes: string | undefined },
|
|
30
30
|
any,
|
|
31
31
|
typeof QUERY_KEY
|
|
@@ -66,9 +66,4 @@ export const usePollUserDelegates = (
|
|
|
66
66
|
refreshInterval: options?.refreshInterval ?? POLLING.SLOW,
|
|
67
67
|
},
|
|
68
68
|
);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...swrResponse,
|
|
72
|
-
refresh: () => swrResponse?.mutate?.(),
|
|
73
|
-
};
|
|
74
69
|
};
|
|
@@ -2,14 +2,14 @@ import type { Address } from "viem";
|
|
|
2
2
|
|
|
3
3
|
import type { ProposalWithVotesFragment } from "@berachain/graphql/governance";
|
|
4
4
|
import { usePublicClient, useTransactionReceipt } from "@berachain/wagmi/hooks";
|
|
5
|
-
import type {
|
|
5
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
6
6
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
7
7
|
|
|
8
8
|
import { getProposalFromTx } from "../../actions/governance/getProposalFromTx";
|
|
9
9
|
|
|
10
10
|
export const useProposalFromTx = (
|
|
11
11
|
txHash?: Address,
|
|
12
|
-
):
|
|
12
|
+
): BeraSwrResponse<ProposalWithVotesFragment | null> => {
|
|
13
13
|
const { data: tx } = useTransactionReceipt({
|
|
14
14
|
hash: txHash,
|
|
15
15
|
});
|
|
@@ -19,7 +19,7 @@ export const useProposalFromTx = (
|
|
|
19
19
|
const QUERY_KEY =
|
|
20
20
|
tx && publicClient ? (["useProposalFromTx", txHash] as const) : null;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
return useSWR(QUERY_KEY, async ([, txHash]) => {
|
|
23
23
|
if (!tx) {
|
|
24
24
|
throw new Error("Transaction not found");
|
|
25
25
|
}
|
|
@@ -33,6 +33,4 @@ export const useProposalFromTx = (
|
|
|
33
33
|
|
|
34
34
|
return getProposalFromTx({ tx, publicClient });
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
return swrResponse;
|
|
38
36
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
2
2
|
|
|
3
3
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
|
-
import type {
|
|
4
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
5
5
|
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
6
6
|
|
|
7
7
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -18,7 +18,7 @@ export const useProposalSnapshot = ({
|
|
|
18
18
|
proposalId,
|
|
19
19
|
}: {
|
|
20
20
|
proposalId: number | bigint | string | undefined;
|
|
21
|
-
}):
|
|
21
|
+
}): BeraSwrResponse<string> => {
|
|
22
22
|
const publicClient = usePublicClient();
|
|
23
23
|
|
|
24
24
|
const QUERY_KEY =
|
|
@@ -3,7 +3,7 @@ import type { Address } from "viem";
|
|
|
3
3
|
import { berachainGovernanceAbi as governanceAbi } from "@berachain/abis/gov/berachainGovernance";
|
|
4
4
|
|
|
5
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
-
import type {
|
|
6
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
7
7
|
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
8
8
|
|
|
9
9
|
import { ProposalState } from "../../enum/governance";
|
|
@@ -26,7 +26,7 @@ export const useProposalState = ({
|
|
|
26
26
|
}: {
|
|
27
27
|
proposalId: number | bigint | string | undefined;
|
|
28
28
|
governorAddress: Address;
|
|
29
|
-
}):
|
|
29
|
+
}): BeraSwrResponse<string> => {
|
|
30
30
|
const publicClient = usePublicClient();
|
|
31
31
|
|
|
32
32
|
const QUERY_KEY =
|
|
@@ -3,7 +3,7 @@ import type { Address } from "viem";
|
|
|
3
3
|
import { timeLockAbi as governanceTimelockAbi } from "@berachain/abis/gov/timeLock";
|
|
4
4
|
|
|
5
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
-
import type {
|
|
6
|
+
import type { BeraSwrResponse } from "@berachain/utils/pkg/swr";
|
|
7
7
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
8
8
|
|
|
9
9
|
import { POLLING } from "../../enum/polling";
|
|
@@ -26,7 +26,7 @@ export function useProposalTimelockState({
|
|
|
26
26
|
}: {
|
|
27
27
|
proposalTimelockId: Address | undefined;
|
|
28
28
|
timelockAddress: Address;
|
|
29
|
-
}):
|
|
29
|
+
}): BeraSwrResponse<
|
|
30
30
|
(typeof TimelockOperationState)[keyof typeof TimelockOperationState]
|
|
31
31
|
> {
|
|
32
32
|
const publicClient = usePublicClient();
|
|
@@ -56,7 +56,7 @@ export const useCappedGlobally = (
|
|
|
56
56
|
] as const)
|
|
57
57
|
: null;
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
return useSWR(
|
|
60
60
|
QUERY_KEY,
|
|
61
61
|
async ([
|
|
62
62
|
_,
|
|
@@ -85,9 +85,4 @@ export const useCappedGlobally = (
|
|
|
85
85
|
refreshInterval: 0,
|
|
86
86
|
},
|
|
87
87
|
);
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
...swrResponse,
|
|
91
|
-
refresh: () => void swrResponse.mutate(),
|
|
92
|
-
};
|
|
93
88
|
};
|
|
@@ -41,7 +41,7 @@ export const useCappedRelatively = (
|
|
|
41
41
|
] as const)
|
|
42
42
|
: null;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
return useSWR(
|
|
45
45
|
QUERY_KEY,
|
|
46
46
|
async ([_, asset, amount, collaterals, referenceCollateral]) => {
|
|
47
47
|
if (isBasketModeEnabled) {
|
|
@@ -83,9 +83,4 @@ export const useCappedRelatively = (
|
|
|
83
83
|
...options,
|
|
84
84
|
},
|
|
85
85
|
);
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
...swrResponse,
|
|
89
|
-
refresh: () => void swrResponse.mutate(),
|
|
90
|
-
};
|
|
91
86
|
};
|
|
@@ -29,7 +29,7 @@ export const useCollateralWeights = (
|
|
|
29
29
|
? (["useCollateralWeights", collateralList] as const)
|
|
30
30
|
: undefined;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return useSWR(
|
|
33
33
|
QUERY_KEY,
|
|
34
34
|
async ([_, collateralList]) => {
|
|
35
35
|
assertPublicClient(publicClient);
|
|
@@ -44,9 +44,4 @@ export const useCollateralWeights = (
|
|
|
44
44
|
refreshInterval: options?.refreshInterval ?? POLLING.NORMAL,
|
|
45
45
|
},
|
|
46
46
|
);
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
...swrResponse,
|
|
50
|
-
refresh: () => void swrResponse.mutate(),
|
|
51
|
-
};
|
|
52
47
|
};
|
|
@@ -48,7 +48,7 @@ export const useHoneyBalances = (): DefaultHookReturnType<
|
|
|
48
48
|
? (["useHoneyBalances", account, collateralList] as const)
|
|
49
49
|
: null;
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
return useSWR(
|
|
52
52
|
QUERY_KEY,
|
|
53
53
|
async ([_, account, collateralList]) => {
|
|
54
54
|
assertPublicClient(publicClient);
|
|
@@ -75,9 +75,4 @@ export const useHoneyBalances = (): DefaultHookReturnType<
|
|
|
75
75
|
refreshInterval: POLLING.FAST,
|
|
76
76
|
},
|
|
77
77
|
);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
...swrResponse,
|
|
81
|
-
refresh: () => swrResponse.mutate(),
|
|
82
|
-
};
|
|
83
78
|
};
|
|
@@ -3,15 +3,7 @@ import { useSWR } from "@berachain/utils/pkg/swr";
|
|
|
3
3
|
import { getChartData } from "../../actions/honey/getChartData";
|
|
4
4
|
|
|
5
5
|
export function useHoneyChartData({ days }: { days: number }) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return await getChartData({ days });
|
|
10
|
-
},
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
...swrResponse,
|
|
15
|
-
refresh: () => swrResponse.mutate(),
|
|
16
|
-
};
|
|
6
|
+
return useSWR(["useHoneyChartData", days] as const, async ([_, days]) => {
|
|
7
|
+
return await getChartData({ days });
|
|
8
|
+
});
|
|
17
9
|
}
|