@berachain/berajs 0.2.13 → 0.3.1
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/BeraApolloClient.d.ts.map +1 -1
- package/dist/actions/clients/clientName.d.ts +10 -0
- package/dist/actions/clients/clientName.d.ts.map +1 -0
- package/dist/actions/clients/clientName.unit.test.d.ts +2 -0
- package/dist/actions/clients/clientName.unit.test.d.ts.map +1 -0
- package/dist/actions/clients/exports.d.ts +2 -0
- package/dist/actions/clients/exports.d.ts.map +1 -1
- package/dist/actions/clients/exports.mjs +26 -7
- package/dist/actions/clients/exports.mjs.map +1 -1
- package/dist/actions/clients/fetchBeep.d.ts +2 -2
- package/dist/actions/clients/fetchBeep.d.ts.map +1 -1
- package/dist/actions/clients/fetchEnso.d.ts +17 -0
- package/dist/actions/clients/fetchEnso.d.ts.map +1 -0
- package/dist/actions/clients/fetchLayerzero.d.ts +12 -0
- package/dist/actions/clients/fetchLayerzero.d.ts.map +1 -0
- package/dist/actions/clients/fetchOpenApi.d.ts +4 -1
- package/dist/actions/clients/fetchOpenApi.d.ts.map +1 -1
- package/dist/actions/clients/getApolloClient.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/base.d.ts +30 -5
- package/dist/actions/dex/aggregators/base.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/bex.d.ts +11 -1
- package/dist/actions/dex/aggregators/bex.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/bgt.d.ts +2 -2
- package/dist/actions/dex/aggregators/bgt.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/enso/enso.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/enso/ensoErc4626.d.ts +1 -0
- package/dist/actions/dex/aggregators/enso/ensoErc4626.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/erc4626.d.ts +2 -2
- package/dist/actions/dex/aggregators/erc4626.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/fly.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/haiku.d.ts +7 -1
- package/dist/actions/dex/aggregators/haiku.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/honey.d.ts +2 -2
- package/dist/actions/dex/aggregators/honey.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/kyberswap.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/oogabooga.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/openOcean.d.ts.map +1 -1
- package/dist/actions/dex/aggregators/wbera.d.ts +3 -2
- package/dist/actions/dex/aggregators/wbera.d.ts.map +1 -1
- package/dist/actions/dex/getAllPools.d.ts.map +1 -1
- package/dist/actions/dex/getApiPool.d.ts.map +1 -1
- package/dist/actions/enso/getEnsoUserTokensWithBalances.d.ts.map +1 -1
- package/dist/actions/enso/util.d.ts +1 -6
- package/dist/actions/enso/util.d.ts.map +1 -1
- package/dist/actions/exports.d.ts +3 -5
- package/dist/actions/exports.d.ts.map +1 -1
- package/dist/actions/exports.mjs +33 -64
- package/dist/actions/exports.mjs.map +1 -1
- package/dist/actions/governance/exports.mjs +3 -3
- package/dist/actions/honey/getChartData.d.ts +1 -1
- package/dist/actions/honey/getChartData.d.ts.map +1 -1
- package/dist/actions/honey/getHoney24hVolume.d.ts +2 -2
- package/dist/actions/honey/getHoney24hVolume.d.ts.map +1 -1
- package/dist/actions/honey/getHoneyCollaterals.d.ts +1 -1
- package/dist/actions/honey/getHoneyCollaterals.d.ts.map +1 -1
- package/dist/actions/honey/getHoneyTxns.d.ts +1 -1
- package/dist/actions/honey/getHoneyTxns.d.ts.map +1 -1
- package/dist/actions/pol/getBGTGlobalInfo.d.ts +0 -1
- package/dist/actions/pol/getBGTGlobalInfo.d.ts.map +1 -1
- package/dist/actions/pol/getBeraTokenTotalSupply.d.ts.map +1 -1
- package/dist/actions/pol/getEarnedStakedBeraVault.d.ts +4 -27
- package/dist/actions/pol/getEarnedStakedBeraVault.d.ts.map +1 -1
- package/dist/actions/pol/getLSTStakeConfig.d.ts.map +1 -1
- package/dist/actions/pol/getRewardVaults.d.ts.map +1 -1
- package/dist/actions/pol/getSWBeraVaultMetadata.d.ts +1 -14
- package/dist/actions/pol/getSWBeraVaultMetadata.d.ts.map +1 -1
- package/dist/actions/pol/getStakedBeraAPY.d.ts +14 -0
- package/dist/actions/pol/getStakedBeraAPY.d.ts.map +1 -0
- package/dist/actions/pol/getStakedBeraSnapshots.d.ts +14 -4
- package/dist/actions/pol/getStakedBeraSnapshots.d.ts.map +1 -1
- package/dist/actions/pol/getStakingDailyAssets.d.ts +2 -2
- package/dist/actions/pol/getStakingDailyAssets.d.ts.map +1 -1
- package/dist/actions/server/exports.mjs +5 -5
- package/dist/actions/server/exports.mjs.map +1 -1
- package/dist/actions/server/getDailyValidatorBlockStats.d.ts +1 -1
- package/dist/actions/server/getDailyValidatorBlockStats.d.ts.map +1 -1
- package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.d.ts +1 -1
- package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.d.ts.map +1 -1
- package/dist/actions/validators/getUserActiveValidators.d.ts +37 -1
- package/dist/actions/validators/getUserActiveValidators.d.ts.map +1 -1
- package/dist/actions/validators/getValidatorIncentiveDistribution.d.ts +1 -1
- package/dist/actions/validators/getValidatorIncentiveDistribution.d.ts.map +1 -1
- package/dist/actions/validators/getValidatorRewardAllocation.d.ts +4 -0
- package/dist/actions/validators/getValidatorRewardAllocation.d.ts.map +1 -1
- package/dist/chunk-3TRTSTDH.mjs +19 -0
- package/dist/chunk-3TRTSTDH.mjs.map +1 -0
- package/dist/{chunk-ZWTGVIPJ.mjs → chunk-4576RF2K.mjs} +29 -4
- package/dist/chunk-4576RF2K.mjs.map +1 -0
- package/dist/{chunk-PHYZRH4I.mjs → chunk-5MUCX35C.mjs} +9 -13
- package/dist/chunk-5MUCX35C.mjs.map +1 -0
- package/dist/{chunk-UA3Z47LT.mjs → chunk-6D4S3EAC.mjs} +97 -26
- package/dist/chunk-6D4S3EAC.mjs.map +1 -0
- package/dist/{chunk-AEN6IJFU.mjs → chunk-7KN7TDUC.mjs} +2 -2
- package/dist/{chunk-LE4CYW7S.mjs → chunk-FWRYUIJK.mjs} +3 -3
- package/dist/chunk-GDUKRUHE.mjs +29 -0
- package/dist/chunk-GDUKRUHE.mjs.map +1 -0
- package/dist/{chunk-PJRLHTGC.mjs → chunk-HPRLNT6R.mjs} +3 -3
- package/dist/{chunk-DOZJB6IJ.mjs → chunk-KY7JMIIS.mjs} +394 -346
- package/dist/chunk-KY7JMIIS.mjs.map +1 -0
- package/dist/{chunk-P3YZ7F22.mjs → chunk-LL7XR2H5.mjs} +34 -3
- package/dist/chunk-LL7XR2H5.mjs.map +1 -0
- package/dist/{chunk-EJIGERYM.mjs → chunk-M3MIGSH3.mjs} +2 -2
- package/dist/{chunk-NZAH3SGT.mjs → chunk-MVNQY2D4.mjs} +9 -4
- package/dist/chunk-MVNQY2D4.mjs.map +1 -0
- package/dist/{chunk-TGN55GKE.mjs → chunk-SC3BSCTN.mjs} +2 -2
- package/dist/{chunk-QQASX4LJ.mjs → chunk-TXWDUJOY.mjs} +2 -2
- package/dist/{chunk-EGAB6NFQ.mjs → chunk-UWJQ6UKG.mjs} +2 -2
- package/dist/chunk-XO2BFPTB.mjs +50 -0
- package/dist/chunk-XO2BFPTB.mjs.map +1 -0
- package/dist/{chunk-7TFV6UKF.mjs → chunk-XXKPXNQD.mjs} +1 -2
- package/dist/chunk-XXKPXNQD.mjs.map +1 -0
- package/dist/{chunk-IFNIPVTZ.mjs → chunk-Z337NBBW.mjs} +5 -49
- package/dist/chunk-Z337NBBW.mjs.map +1 -0
- package/dist/{chunk-J3LTASDE.mjs → chunk-ZHV3MQ4F.mjs} +4 -4
- package/dist/contexts/BeraFlags/BeraFlags.d.ts +1 -1
- package/dist/contexts/BeraFlags/BeraFlags.d.ts.map +1 -1
- package/dist/contexts/BeraFlags/defaultFlags.d.ts +2 -2
- package/dist/contexts/BeraFlags/defaultFlags.d.ts.map +1 -1
- package/dist/contexts/BexStatusProvider.d.ts +1 -1
- package/dist/contexts/BexStatusProvider.d.ts.map +1 -1
- package/dist/contexts/TokensProvider.d.ts +1 -1
- package/dist/contexts/TokensProvider.d.ts.map +1 -1
- package/dist/contexts/exports.mjs +9 -9
- package/dist/enum/contracts.d.ts +3 -0
- package/dist/enum/contracts.d.ts.map +1 -1
- package/dist/enum/exports.mjs +6 -4
- package/dist/enum/exports.mjs.map +1 -1
- package/dist/enum/txnEnum.d.ts +1 -1
- package/dist/enum/txnEnum.d.ts.map +1 -1
- package/dist/errors/RequestError.d.ts +19 -0
- package/dist/errors/RequestError.d.ts.map +1 -1
- package/dist/errors/errorMap.d.ts +4 -3
- package/dist/errors/errorMap.d.ts.map +1 -1
- package/dist/errors/exports.mjs +5 -5
- package/dist/errors/getErrorMessage.unit.test.d.ts +2 -0
- package/dist/errors/getErrorMessage.unit.test.d.ts.map +1 -0
- package/dist/generated/beep.d.ts +1597 -0
- package/dist/generated/beep.d.ts.map +1 -0
- package/dist/generated/enso.d.ts +4957 -0
- package/dist/generated/enso.d.ts.map +1 -0
- package/dist/generated/layerzero.d.ts +2057 -0
- package/dist/generated/layerzero.d.ts.map +1 -0
- package/dist/hooks/dex/useAggregatorsQuotes.d.ts.map +1 -1
- package/dist/hooks/dex/useAllUserPools.d.ts.map +1 -1
- package/dist/hooks/dex/useCrossChainNativeFee.d.ts +32 -0
- package/dist/hooks/dex/useCrossChainNativeFee.d.ts.map +1 -0
- package/dist/hooks/dex/useCrossChainNativeFee.unit.test.d.ts +2 -0
- package/dist/hooks/dex/useCrossChainNativeFee.unit.test.d.ts.map +1 -0
- package/dist/hooks/dex/useOnChainPoolData.d.ts.map +1 -1
- package/dist/hooks/dex/usePools.d.ts.map +1 -1
- package/dist/hooks/dex/useSingleAggregatorQuote.d.ts.map +1 -1
- package/dist/hooks/dex/useSingleAggregatorQuote.unit.test.d.ts +2 -0
- package/dist/hooks/dex/useSingleAggregatorQuote.unit.test.d.ts.map +1 -0
- package/dist/hooks/enso/useBendZapSupply.d.ts +2 -2
- package/dist/hooks/enso/useBendZapSupply.d.ts.map +1 -1
- package/dist/hooks/enso/useBendZapSupply.unit.test.d.ts +2 -0
- package/dist/hooks/enso/useBendZapSupply.unit.test.d.ts.map +1 -0
- package/dist/hooks/enso/useEnsoUserTokensWithBalances.d.ts.map +1 -1
- package/dist/hooks/enso/useEnsoUserTokensWithBalances.unit.test.d.ts +2 -0
- package/dist/hooks/enso/useEnsoUserTokensWithBalances.unit.test.d.ts.map +1 -0
- package/dist/hooks/enso/useZapStakeBera.d.ts.map +1 -1
- package/dist/hooks/enso/useZapStakeBera.unit.test.d.ts +2 -0
- package/dist/hooks/enso/useZapStakeBera.unit.test.d.ts.map +1 -0
- package/dist/hooks/exports.d.ts +2 -5
- package/dist/hooks/exports.d.ts.map +1 -1
- package/dist/hooks/exports.mjs +615 -911
- package/dist/hooks/exports.mjs.map +1 -1
- package/dist/hooks/governance/exports.mjs +4 -4
- package/dist/hooks/honey/useHoneyChartData.d.ts +4 -4
- package/dist/hooks/honey/useHoneyChartData.d.ts.map +1 -1
- package/dist/hooks/pol/useAutoclaimedIncentives.d.ts.map +1 -1
- package/dist/hooks/pol/useAutoclaimedIncentivesTxHash.d.ts.map +1 -1
- package/dist/hooks/pol/useRewardTokenToBeraRate.d.ts.map +1 -1
- package/dist/hooks/pol/useRewardVaultBalanceFromStakingToken.d.ts.map +1 -1
- package/dist/hooks/pol/useRewardVaults.d.ts.map +1 -1
- package/dist/hooks/pol/useStakedAPY.d.ts +11 -0
- package/dist/hooks/pol/useStakedAPY.d.ts.map +1 -0
- package/dist/hooks/pol/useStakedData.d.ts +4 -2
- package/dist/hooks/pol/useStakedData.d.ts.map +1 -1
- package/dist/hooks/pol/useStakedSnapshots.d.ts +1 -1
- package/dist/hooks/pol/useStakedSnapshots.d.ts.map +1 -1
- package/dist/hooks/pol/useStakingVaultsMetadata.d.ts +0 -1
- package/dist/hooks/pol/useStakingVaultsMetadata.d.ts.map +1 -1
- package/dist/hooks/tokens/useMultipleTokenInformation.d.ts +30 -0
- package/dist/hooks/tokens/useMultipleTokenInformation.d.ts.map +1 -1
- package/dist/hooks/tokens/useMultipleTokenInformation.unit.test.d.ts +2 -0
- package/dist/hooks/tokens/useMultipleTokenInformation.unit.test.d.ts.map +1 -0
- package/dist/hooks/tokens/usePollBalance.d.ts.map +1 -1
- package/dist/hooks/validators/useUserActiveValidators.d.ts +5 -0
- package/dist/hooks/validators/useUserActiveValidators.d.ts.map +1 -1
- package/dist/hooks/validators/useValidator.d.ts +0 -1
- package/dist/hooks/validators/useValidator.d.ts.map +1 -1
- package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts +4 -5
- package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts.map +1 -1
- package/dist/hooks/validators/useValidatorRewardAllocation.d.ts +1 -0
- package/dist/hooks/validators/useValidatorRewardAllocation.d.ts.map +1 -1
- package/dist/types/beep/exports.d.ts +2 -0
- package/dist/types/beep/exports.d.ts.map +1 -0
- package/dist/types/beep/exports.mjs +1 -0
- package/dist/types/beep/exports.mjs.map +1 -0
- package/dist/types/bribeBoost.d.ts +0 -49
- package/dist/types/dex.d.ts +17 -0
- package/dist/types/enso.d.ts +1 -27
- package/dist/types/global.d.ts +7 -0
- package/dist/types/pol.d.ts +3 -48
- package/dist/utils/crossChainBridge.d.ts +74 -0
- package/dist/utils/crossChainBridge.d.ts.map +1 -0
- package/dist/utils/crossChainBridge.unit.test.d.ts +2 -0
- package/dist/utils/crossChainBridge.unit.test.d.ts.map +1 -0
- package/dist/utils/exports.d.ts +1 -1
- package/dist/utils/exports.d.ts.map +1 -1
- package/dist/utils/exports.mjs +142 -72
- package/dist/utils/exports.mjs.map +1 -1
- package/dist/utils/getTestClient.d.ts +5 -3
- package/dist/utils/getTestClient.d.ts.map +1 -1
- package/dist/utils/parseWhiskToken.d.ts.map +1 -1
- package/package.json +14 -10
- package/src/actions/clients/BeraApolloClient.ts +4 -2
- package/src/actions/clients/clientName.ts +17 -0
- package/src/actions/clients/clientName.unit.test.ts +39 -0
- package/src/actions/clients/exports.ts +2 -0
- package/src/actions/clients/fetchBeep.ts +6 -4
- package/src/actions/clients/fetchEnso.ts +47 -0
- package/src/actions/clients/fetchLayerzero.ts +33 -0
- package/src/actions/clients/fetchOpenApi.ts +9 -2
- package/src/actions/clients/fetchOpenApi.unit.test.ts +27 -12
- package/src/actions/clients/getApolloClient.ts +3 -11
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +231 -2
- package/src/actions/dex/aggregators/base.ts +75 -17
- package/src/actions/dex/aggregators/bex.ts +41 -1
- package/src/actions/dex/aggregators/bgt.ts +11 -6
- package/src/actions/dex/aggregators/enso/enso.ts +1 -0
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +27 -9
- package/src/actions/dex/aggregators/erc4626.ts +19 -5
- package/src/actions/dex/aggregators/fly.ts +1 -0
- package/src/actions/dex/aggregators/haiku.ts +33 -2
- package/src/actions/dex/aggregators/honey.ts +17 -6
- package/src/actions/dex/aggregators/kyberswap.ts +1 -0
- package/src/actions/dex/aggregators/oogabooga.ts +1 -0
- package/src/actions/dex/aggregators/openOcean.ts +1 -0
- package/src/actions/dex/aggregators/wbera.ts +17 -11
- package/src/actions/enso/getBendMultiplyBundle.ts +1 -1
- package/src/actions/enso/getEnsoUserTokensWithBalances.ts +4 -8
- package/src/actions/enso/util.ts +0 -59
- package/src/actions/exports.ts +3 -5
- package/src/actions/honey/getChartData.ts +2 -3
- package/src/actions/honey/getHoney24hVolume.ts +4 -13
- package/src/actions/honey/getHoneyCollaterals.ts +1 -1
- package/src/actions/honey/getHoneyTxns.ts +2 -3
- package/src/actions/pol/getBGTGlobalInfo.ts +0 -2
- package/src/actions/pol/getBeraTokenTotalSupply.ts +3 -33
- package/src/actions/pol/getEarnedStakedBeraVault.ts +1 -1
- package/src/actions/pol/getLSTStakeConfig.ts +0 -6
- package/src/actions/pol/getRewardVaults.ts +0 -1
- package/src/actions/pol/getSWBeraVaultMetadata.ts +2 -106
- package/src/actions/pol/getStakedBeraAPY.ts +44 -0
- package/src/actions/pol/getStakedBeraSnapshots.ts +17 -34
- package/src/actions/pol/getStakingDailyAssets.ts +1 -1
- package/src/actions/server/getDailyValidatorBlockStats.ts +1 -2
- package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +1 -1
- package/src/actions/validators/getUserActiveValidators.ts +116 -54
- package/src/actions/validators/getValidatorIncentiveDistribution.ts +1 -2
- package/src/actions/validators/getValidatorRewardAllocation.ts +12 -1
- package/src/contexts/BeraFlags/BeraFlags.tsx +1 -4
- package/src/contexts/BeraFlags/defaultFlags.ts +1 -3
- package/src/contexts/BexStatusProvider.tsx +1 -1
- package/src/contexts/TokensProvider.tsx +1 -4
- package/src/enum/contracts.ts +3 -0
- package/src/enum/txnEnum.ts +1 -1
- package/src/errors/BeraError.unit.test.ts +23 -0
- package/src/errors/RequestError.ts +46 -9
- package/src/errors/RequestError.unit.test.ts +54 -0
- package/src/errors/errorMap.ts +8 -3
- package/src/errors/getErrorMessage.unit.test.ts +32 -0
- package/src/generated/beep.ts +1605 -0
- package/src/generated/enso.ts +4965 -0
- package/src/generated/layerzero.ts +2065 -0
- package/src/hooks/dex/useAggregatorsQuotes.ts +7 -1
- package/src/hooks/dex/useCrossChainNativeFee.ts +83 -0
- package/src/hooks/dex/useCrossChainNativeFee.unit.test.ts +63 -0
- package/src/hooks/dex/useOnChainPoolData.ts +30 -13
- package/src/hooks/dex/useSingleAggregatorQuote.ts +10 -5
- package/src/hooks/dex/useSingleAggregatorQuote.unit.test.ts +86 -0
- package/src/hooks/enso/useBendZapSupply.ts +10 -38
- package/src/hooks/enso/useBendZapSupply.unit.test.ts +98 -0
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +13 -3
- package/src/hooks/enso/useEnsoUserTokensWithBalances.unit.test.ts +69 -0
- package/src/hooks/enso/useZapStakeBera.ts +8 -1
- package/src/hooks/enso/useZapStakeBera.unit.test.ts +97 -0
- package/src/hooks/exports.ts +2 -5
- package/src/hooks/pol/useAutoclaimedIncentives.ts +6 -3
- package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +5 -2
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +5 -4
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +0 -1
- package/src/hooks/pol/{useStakedAPR.ts → useStakedAPY.ts} +11 -9
- package/src/hooks/pol/useStakedData.ts +15 -14
- package/src/hooks/pol/useStakedSnapshots.ts +1 -1
- package/src/hooks/pol/useStakingVaultsMetadata.ts +3 -8
- package/src/hooks/tokens/useMultipleTokenInformation.ts +64 -21
- package/src/hooks/tokens/useMultipleTokenInformation.unit.test.ts +91 -0
- package/src/hooks/tokens/usePollBalance.ts +4 -2
- package/src/hooks/validators/useUserActiveValidators.ts +54 -9
- package/src/hooks/validators/useValidatorIncentiveDistribution.ts +4 -5
- package/src/types/beep/exports.ts +4 -0
- package/src/types/bribeBoost.d.ts +0 -49
- package/src/types/dex.d.ts +17 -0
- package/src/types/enso.d.ts +1 -27
- package/src/types/global.d.ts +7 -0
- package/src/types/pol.d.ts +3 -48
- package/src/utils/crossChainBridge.ts +290 -0
- package/src/utils/crossChainBridge.unit.test.ts +177 -0
- package/src/utils/exports.ts +1 -1
- package/dist/BeraError-7-A5JYy_.d.ts +0 -123
- package/dist/BexStatusProvider-DRymVlQf.d.ts +0 -70
- package/dist/HoneyConfigProvider-COOuDNra.d.ts +0 -390
- package/dist/RequestError-DkUbo3ro.d.ts +0 -145
- package/dist/actions/dex/b-sdk.d.ts +0 -3
- package/dist/actions/enso/getEnsoSwapBundle.d.ts +0 -3
- package/dist/actions/enso/getEnsoSwapBundle.d.ts.map +0 -1
- package/dist/actions/pol/getBgtIncentiveDistributorPaused.d.ts +0 -10
- package/dist/actions/pol/getBgtIncentiveDistributorPaused.d.ts.map +0 -1
- package/dist/actions/pol/getRewardProofsByValidator.d.ts +0 -9
- package/dist/actions/pol/getRewardProofsByValidator.d.ts.map +0 -1
- package/dist/actions/pol/getStakedBeraAPR.d.ts +0 -12
- package/dist/actions/pol/getStakedBeraAPR.d.ts.map +0 -1
- package/dist/actions/pol/getUserClaimableIncentives.d.ts +0 -9
- package/dist/actions/pol/getUserClaimableIncentives.d.ts.map +0 -1
- package/dist/actions/validators/getValidatorAnalytics.d.ts +0 -12
- package/dist/actions/validators/getValidatorAnalytics.d.ts.map +0 -1
- package/dist/chunk-7TFV6UKF.mjs.map +0 -1
- package/dist/chunk-BSOWLS3W.mjs +0 -40
- package/dist/chunk-BSOWLS3W.mjs.map +0 -1
- package/dist/chunk-DOZJB6IJ.mjs.map +0 -1
- package/dist/chunk-IFNIPVTZ.mjs.map +0 -1
- package/dist/chunk-NZAH3SGT.mjs.map +0 -1
- package/dist/chunk-P3YZ7F22.mjs.map +0 -1
- package/dist/chunk-PHYZRH4I.mjs.map +0 -1
- package/dist/chunk-UA3Z47LT.mjs.map +0 -1
- package/dist/chunk-ZWTGVIPJ.mjs.map +0 -1
- package/dist/contexts/block-time-provider.d.ts +0 -10
- package/dist/defaultFlags-D6KfkTZx.d.ts +0 -10
- package/dist/dex-C_BB0b0O.d.ts +0 -37
- package/dist/getApolloClient-MWm_iq4u.d.ts +0 -39
- package/dist/getProposalVotes-DAUrdX2n.d.ts +0 -12
- package/dist/getValidatorQueuedOperatorAddress-N2I7wHd6.d.ts +0 -511
- package/dist/global.d-CR3zicga.d.ts +0 -231
- package/dist/global.d-CiZJ2eHz.d.ts +0 -231
- package/dist/honey-CYm0RWf4.d.ts +0 -14
- package/dist/hooks/enso/useEnsoSwapBundle.d.ts +0 -26
- package/dist/hooks/enso/useEnsoSwapBundle.d.ts.map +0 -1
- package/dist/hooks/pol/useBgtIncentiveDistributorPaused.d.ts +0 -8
- package/dist/hooks/pol/useBgtIncentiveDistributorPaused.d.ts.map +0 -1
- package/dist/hooks/pol/useStakedAPR.d.ts +0 -11
- package/dist/hooks/pol/useStakedAPR.d.ts.map +0 -1
- package/dist/hooks/validators/useUserClaimableIncentives.d.ts +0 -8
- package/dist/hooks/validators/useUserClaimableIncentives.d.ts.map +0 -1
- package/dist/hooks/validators/useValidatorAnalytics.d.ts +0 -11
- package/dist/hooks/validators/useValidatorAnalytics.d.ts.map +0 -1
- package/dist/pol.d-CeRgXBL8.d.ts +0 -167
- package/dist/txnEnum-ByI5dtDi.d.ts +0 -106
- package/dist/types/bribe-boost.d.ts +0 -69
- package/dist/useHoneySwapState-CXVWAThr.d.ts +0 -32
- package/dist/useHoneySwapState-twi7NTaO.d.ts +0 -32
- package/dist/utils/formatIncentivesTokenMap.d.ts +0 -3
- package/dist/utils/formatIncentivesTokenMap.d.ts.map +0 -1
- package/dist/utils/layerZeroScan.d.ts +0 -39
- package/dist/utils/layerZeroScan.d.ts.map +0 -1
- package/src/actions/enso/getEnsoSwapBundle.ts +0 -72
- package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +0 -28
- package/src/actions/pol/getRewardProofsByValidator.ts +0 -49
- package/src/actions/pol/getStakedBeraAPR.ts +0 -56
- package/src/actions/pol/getUserClaimableIncentives.ts +0 -40
- package/src/actions/validators/getValidatorAnalytics.ts +0 -37
- package/src/hooks/enso/useEnsoSwapBundle.ts +0 -121
- package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +0 -34
- package/src/hooks/validators/useUserClaimableIncentives.ts +0 -148
- package/src/hooks/validators/useValidatorAnalytics.ts +0 -37
- package/src/utils/formatIncentivesTokenMap.ts +0 -19
- package/src/utils/layerZeroScan.ts +0 -124
- /package/dist/{chunk-AEN6IJFU.mjs.map → chunk-7KN7TDUC.mjs.map} +0 -0
- /package/dist/{chunk-LE4CYW7S.mjs.map → chunk-FWRYUIJK.mjs.map} +0 -0
- /package/dist/{chunk-PJRLHTGC.mjs.map → chunk-HPRLNT6R.mjs.map} +0 -0
- /package/dist/{chunk-EJIGERYM.mjs.map → chunk-M3MIGSH3.mjs.map} +0 -0
- /package/dist/{chunk-TGN55GKE.mjs.map → chunk-SC3BSCTN.mjs.map} +0 -0
- /package/dist/{chunk-QQASX4LJ.mjs.map → chunk-TXWDUJOY.mjs.map} +0 -0
- /package/dist/{chunk-EGAB6NFQ.mjs.map → chunk-UWJQ6UKG.mjs.map} +0 -0
- /package/dist/{chunk-J3LTASDE.mjs.map → chunk-ZHV3MQ4F.mjs.map} +0 -0
|
@@ -8,6 +8,7 @@ import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
|
8
8
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
9
9
|
|
|
10
10
|
import { ensoErc4626 } from "../../actions/dex/aggregators/enso/ensoErc4626";
|
|
11
|
+
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
11
12
|
import { POLLING } from "../../enum/polling";
|
|
12
13
|
import type { MinimalERC20 } from "../../types/dex";
|
|
13
14
|
import type { DefaultHookOptions } from "../../types/global";
|
|
@@ -37,6 +38,9 @@ export function useZapStakeBera(
|
|
|
37
38
|
options?: DefaultHookOptions,
|
|
38
39
|
) {
|
|
39
40
|
const { address: account } = useBeraWallet();
|
|
41
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
42
|
+
"proxyAggregatorsThroughVercel",
|
|
43
|
+
);
|
|
40
44
|
// enso route simulation needs a real EOA-like address; zeroAddress can fail simulation.
|
|
41
45
|
// use the connected wallet when available, otherwise fallback to our configured aggregator executor.
|
|
42
46
|
const quoteAccount =
|
|
@@ -59,6 +63,7 @@ export function useZapStakeBera(
|
|
|
59
63
|
slippage,
|
|
60
64
|
underlyingToken,
|
|
61
65
|
tokenOut,
|
|
66
|
+
proxyAggregatorsThroughVercel ?? false,
|
|
62
67
|
] as const)
|
|
63
68
|
: null;
|
|
64
69
|
|
|
@@ -72,6 +77,7 @@ export function useZapStakeBera(
|
|
|
72
77
|
slippage,
|
|
73
78
|
underlyingToken,
|
|
74
79
|
tokenOut,
|
|
80
|
+
proxyAggregatorsThroughVercel,
|
|
75
81
|
]) => {
|
|
76
82
|
const rawAmount = parseUnits(amount, inputToken.decimals).toString();
|
|
77
83
|
|
|
@@ -82,6 +88,7 @@ export function useZapStakeBera(
|
|
|
82
88
|
underlyingToken: underlyingToken,
|
|
83
89
|
tokenOut: tokenOut,
|
|
84
90
|
slippage,
|
|
91
|
+
proxyAggregatorsThroughVercel,
|
|
85
92
|
});
|
|
86
93
|
},
|
|
87
94
|
{
|
|
@@ -104,7 +111,7 @@ export function useZapStakeBera(
|
|
|
104
111
|
data: {
|
|
105
112
|
...swrResponse.data,
|
|
106
113
|
priceImpactPercentage,
|
|
107
|
-
isCrossChain:
|
|
114
|
+
isCrossChain: swrResponse.data?.isCrossChain,
|
|
108
115
|
},
|
|
109
116
|
};
|
|
110
117
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import type { MinimalERC20 } from "../../types/dex";
|
|
4
|
+
import { useZapStakeBera } from "./useZapStakeBera";
|
|
5
|
+
|
|
6
|
+
type CapturedFetcher = (key: readonly unknown[]) => Promise<unknown>;
|
|
7
|
+
|
|
8
|
+
const { captured, getQuote } = vi.hoisted(() => ({
|
|
9
|
+
captured: {
|
|
10
|
+
key: null as readonly unknown[] | null,
|
|
11
|
+
fetcher: null as CapturedFetcher | null,
|
|
12
|
+
},
|
|
13
|
+
getQuote: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock("@berachain/wagmi/hooks", () => ({
|
|
17
|
+
useBeraWallet: () => ({
|
|
18
|
+
address: "0x1111111111111111111111111111111111111111",
|
|
19
|
+
}),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock("@berachain/utils/pkg/swr", () => ({
|
|
23
|
+
useSWR: vi.fn(
|
|
24
|
+
(key: readonly unknown[] | null, fetcher: CapturedFetcher | null) => {
|
|
25
|
+
captured.key = key;
|
|
26
|
+
captured.fetcher = fetcher;
|
|
27
|
+
return { data: undefined, refresh: vi.fn() };
|
|
28
|
+
},
|
|
29
|
+
),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
vi.mock("../../contexts/BeraFlags/BeraFlags", () => ({
|
|
33
|
+
useBeraFlag: () => false,
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
vi.mock("../../actions/dex/aggregators/enso/ensoErc4626", () => ({
|
|
37
|
+
ensoErc4626: { getQuote },
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
vi.mock("../dex/usePriceImpact", () => ({
|
|
41
|
+
usePriceImpact: () => ({ data: null }),
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const inputToken = {
|
|
45
|
+
address: "0xFCBD14d472B1C3Ff25139Aba7D7aCE0C12fFf4d8",
|
|
46
|
+
decimals: 18,
|
|
47
|
+
symbol: "HONEY",
|
|
48
|
+
name: "Honey",
|
|
49
|
+
chainId: 80094,
|
|
50
|
+
} as const satisfies MinimalERC20;
|
|
51
|
+
|
|
52
|
+
const underlyingToken = {
|
|
53
|
+
address: "0x6969696969696969696969696969696969696969",
|
|
54
|
+
decimals: 18,
|
|
55
|
+
symbol: "WBERA",
|
|
56
|
+
name: "Wrapped BERA",
|
|
57
|
+
chainId: 80094,
|
|
58
|
+
} as const satisfies MinimalERC20;
|
|
59
|
+
|
|
60
|
+
const tokenOut = {
|
|
61
|
+
address: "0x118D2cEeE9785eaf70C15Cd74CD84c9f8c3EeC9a",
|
|
62
|
+
decimals: 18,
|
|
63
|
+
symbol: "sWBERA",
|
|
64
|
+
name: "Staked WBERA",
|
|
65
|
+
chainId: 80094,
|
|
66
|
+
} as const satisfies MinimalERC20;
|
|
67
|
+
|
|
68
|
+
describe("useZapStakeBera", () => {
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
captured.key = null;
|
|
71
|
+
captured.fetcher = null;
|
|
72
|
+
getQuote.mockReset();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("reads the proxy transport from the SWR key", async () => {
|
|
76
|
+
useZapStakeBera({
|
|
77
|
+
inputToken,
|
|
78
|
+
amount: "1",
|
|
79
|
+
underlyingToken,
|
|
80
|
+
slippage: 0.5,
|
|
81
|
+
tokenOut,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(captured.key?.at(-1)).toBe(false);
|
|
85
|
+
expect(captured.fetcher).not.toBeNull();
|
|
86
|
+
|
|
87
|
+
const proxyKey = [...(captured.key ?? [])];
|
|
88
|
+
proxyKey[proxyKey.length - 1] = true;
|
|
89
|
+
await captured.fetcher?.(proxyKey);
|
|
90
|
+
|
|
91
|
+
expect(getQuote).toHaveBeenCalledWith(
|
|
92
|
+
expect.objectContaining({
|
|
93
|
+
proxyAggregatorsThroughVercel: true,
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
});
|
package/src/hooks/exports.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./dex/useAllUserPools";
|
|
|
13
13
|
export * from "./dex/useApiPool";
|
|
14
14
|
export * from "./dex/useBexStatus";
|
|
15
15
|
export * from "./dex/useCreatePool";
|
|
16
|
+
export * from "./dex/useCrossChainNativeFee";
|
|
16
17
|
export { useGlobalLiquidityAndSwapVolume } from "./dex/useGlobalLiquidityAndSwapVolume";
|
|
17
18
|
export * from "./dex/useLiquidityMismatch";
|
|
18
19
|
export * from "./dex/useLpPosition";
|
|
@@ -32,7 +33,6 @@ export {
|
|
|
32
33
|
export * from "./enso/useBendDemultiply";
|
|
33
34
|
export * from "./enso/useBendMultiply";
|
|
34
35
|
export * from "./enso/useBendZapSupply";
|
|
35
|
-
export * from "./enso/useEnsoSwapBundle";
|
|
36
36
|
export * from "./enso/useEnsoUserTokensWithBalances";
|
|
37
37
|
export * from "./enso/useZapStakeBera";
|
|
38
38
|
export * from "./honey/useCappedGlobally";
|
|
@@ -51,7 +51,6 @@ export * from "./perps/usePythUpdateFee";
|
|
|
51
51
|
export { useAutoclaimedIncentives } from "./pol/useAutoclaimedIncentives";
|
|
52
52
|
export { useAutoclaimedIncentivesTxHash } from "./pol/useAutoclaimedIncentivesTxHash";
|
|
53
53
|
export * from "./pol/useBgtAprSimulation";
|
|
54
|
-
export { useBgtIncentiveDistributorPaused } from "./pol/useBgtIncentiveDistributorPaused";
|
|
55
54
|
export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
|
|
56
55
|
export { useClaimableFees } from "./pol/useClaimableFees";
|
|
57
56
|
export * from "./pol/useHighestVaultsAPR";
|
|
@@ -66,7 +65,7 @@ export * from "./pol/useRewardVaultIncentives";
|
|
|
66
65
|
export { useRewardVaultRewards } from "./pol/useRewardVaultRewards";
|
|
67
66
|
export * from "./pol/useRewardVaults";
|
|
68
67
|
export { useRewardVaults } from "./pol/useRewardVaults";
|
|
69
|
-
export * from "./pol/
|
|
68
|
+
export * from "./pol/useStakedAPY";
|
|
70
69
|
export * from "./pol/useStakedData";
|
|
71
70
|
export * from "./pol/useStakedSnapshots";
|
|
72
71
|
export * from "./pol/useStakingVaultsMetadata";
|
|
@@ -104,10 +103,8 @@ export {
|
|
|
104
103
|
export * from "./validators/useStakingPoolBatch";
|
|
105
104
|
export { useUserActiveValidators } from "./validators/useUserActiveValidators";
|
|
106
105
|
export { useUserBoostsOnValidator } from "./validators/useUserBoostsOnValidator";
|
|
107
|
-
export { useUserClaimableIncentives } from "./validators/useUserClaimableIncentives";
|
|
108
106
|
export * from "./validators/useUserStakingPositions";
|
|
109
107
|
export * from "./validators/useValidator";
|
|
110
|
-
export { useValidatorAnalytics } from "./validators/useValidatorAnalytics";
|
|
111
108
|
export { useValidatorCommission } from "./validators/useValidatorCommission";
|
|
112
109
|
export { useValidatorEstimatedBgtPerYear } from "./validators/useValidatorEstimatedBgtPerYear";
|
|
113
110
|
export { useValidatorIncentiveDistribution } from "./validators/useValidatorIncentiveDistribution";
|
|
@@ -4,11 +4,12 @@ import { useSWR } from "@berachain/utils/pkg/swr";
|
|
|
4
4
|
import { getAutoclaimedIncentives } from "../../actions/pol/getAutoclaimedIncentives";
|
|
5
5
|
import type { AutoclaimedIncentivesResponse } from "../../types/bribeBoost";
|
|
6
6
|
import type { DefaultHookReturnType } from "../../types/global";
|
|
7
|
+
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
7
8
|
|
|
8
9
|
interface UseAutoclaimedIncentivesArgs {
|
|
9
10
|
// Hard gate: when false the SWR key is null, so the API is never called.
|
|
10
|
-
// The banner consumer flips this to true only after
|
|
11
|
-
//
|
|
11
|
+
// The banner consumer flips this to true only after
|
|
12
|
+
// `bgtIncentiveDistributor.paused() === true` has been verified.
|
|
12
13
|
enabled: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,9 +17,11 @@ export function useAutoclaimedIncentives({
|
|
|
16
17
|
enabled,
|
|
17
18
|
}: UseAutoclaimedIncentivesArgs): DefaultHookReturnType<AutoclaimedIncentivesResponse | null> {
|
|
18
19
|
const { address: account } = useBeraWallet();
|
|
20
|
+
const { config } = parseBaseArgs({});
|
|
19
21
|
|
|
20
22
|
const QUERY_KEY =
|
|
21
|
-
|
|
23
|
+
// `bribeBoostApi` is null on chains where the endpoint is shut down.
|
|
24
|
+
enabled && account && config.pol.bribeBoostApi
|
|
22
25
|
? (["useAutoclaimedIncentives", account] as const)
|
|
23
26
|
: null;
|
|
24
27
|
|
|
@@ -5,10 +5,11 @@ import { getAutoclaimedIncentivesTxHash } from "../../actions/pol/getAutoclaimed
|
|
|
5
5
|
import { POLLING } from "../../enum/polling";
|
|
6
6
|
import type { AutoclaimedIncentivesTxHashResponse } from "../../types/bribeBoost";
|
|
7
7
|
import type { DefaultHookReturnType } from "../../types/global";
|
|
8
|
+
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
8
9
|
|
|
9
10
|
interface UseAutoclaimedIncentivesTxHashArgs {
|
|
10
11
|
// Hard gate, identical to `useAutoclaimedIncentives` — only flip true once
|
|
11
|
-
//
|
|
12
|
+
// `bgtIncentiveDistributor.paused()` holds.
|
|
12
13
|
enabled: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,9 +17,11 @@ export function useAutoclaimedIncentivesTxHash({
|
|
|
16
17
|
enabled,
|
|
17
18
|
}: UseAutoclaimedIncentivesTxHashArgs): DefaultHookReturnType<AutoclaimedIncentivesTxHashResponse | null> {
|
|
18
19
|
const { address: account } = useBeraWallet();
|
|
20
|
+
const { config } = parseBaseArgs({});
|
|
19
21
|
|
|
20
22
|
const QUERY_KEY =
|
|
21
|
-
|
|
23
|
+
// `bribeBoostApi` is null on chains where the endpoint is shut down.
|
|
24
|
+
enabled && account && config.pol.bribeBoostApi
|
|
22
25
|
? (["useAutoclaimedIncentivesTxHash", account] as const)
|
|
23
26
|
: null;
|
|
24
27
|
|
|
@@ -17,10 +17,11 @@ export function useRewardTokenToBeraRate(
|
|
|
17
17
|
},
|
|
18
18
|
opt?: DefaultHookOptions,
|
|
19
19
|
) {
|
|
20
|
-
const QUERY_KEY = address
|
|
21
|
-
? (["useRewardTokenToBeraRate", address] as const)
|
|
22
|
-
: null;
|
|
23
20
|
const publicClient = usePublicClient({ chainId: defaultChainId });
|
|
21
|
+
const QUERY_KEY =
|
|
22
|
+
address && publicClient
|
|
23
|
+
? (["useRewardTokenToBeraRate", address] as const)
|
|
24
|
+
: null;
|
|
24
25
|
|
|
25
26
|
return useSWR(
|
|
26
27
|
QUERY_KEY,
|
|
@@ -29,7 +30,7 @@ export function useRewardTokenToBeraRate(
|
|
|
29
30
|
assertPublicClient(publicClient);
|
|
30
31
|
|
|
31
32
|
return getRewardTokenToBeraRate({
|
|
32
|
-
address
|
|
33
|
+
address,
|
|
33
34
|
publicClient,
|
|
34
35
|
});
|
|
35
36
|
},
|
|
@@ -26,7 +26,6 @@ export function useRewardVaultBalanceFromStakingToken(
|
|
|
26
26
|
const isEnabled = options?.isEnabled ?? true;
|
|
27
27
|
const {
|
|
28
28
|
data: rewardVaultAddress = _rewardVaultAddress,
|
|
29
|
-
error,
|
|
30
29
|
refresh: mutateRewardVaultAddress,
|
|
31
30
|
isLoading: isLoadingRewardVaultAddress,
|
|
32
31
|
} = useRewardVaultFromToken(
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import type { GqlVaultSnapshotDataRange } from "@berachain/graphql/dex/api";
|
|
2
1
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getStakedBeraSnapshots,
|
|
5
|
+
type StakeSnapshotRange,
|
|
6
|
+
} from "../../actions/pol/getStakedBeraSnapshots";
|
|
5
7
|
import type { DefaultHookReturnType } from "../../types/global";
|
|
6
8
|
import { dailyResolution } from "../../utils/filter";
|
|
7
9
|
|
|
8
|
-
type
|
|
10
|
+
type UseStakedAPY = {
|
|
9
11
|
timestamp: number;
|
|
10
|
-
|
|
12
|
+
apy: number | null;
|
|
11
13
|
}[];
|
|
12
|
-
export function
|
|
14
|
+
export function useStakedAPY({
|
|
13
15
|
range,
|
|
14
16
|
}: {
|
|
15
|
-
range:
|
|
16
|
-
}): DefaultHookReturnType<
|
|
17
|
-
const QUERY_KEY = range ? (["
|
|
17
|
+
range: StakeSnapshotRange;
|
|
18
|
+
}): DefaultHookReturnType<UseStakedAPY> {
|
|
19
|
+
const QUERY_KEY = range ? (["useStakedAPY", range] as const) : null;
|
|
18
20
|
return useSWR(QUERY_KEY, async ([, range]) => {
|
|
19
21
|
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
20
22
|
range,
|
|
@@ -26,7 +28,7 @@ export function useStakedAPR({
|
|
|
26
28
|
|
|
27
29
|
return sortedStakedBeraSnapshots.map((item) => ({
|
|
28
30
|
timestamp: item.timestamp,
|
|
29
|
-
|
|
31
|
+
apy: item.apy,
|
|
30
32
|
}));
|
|
31
33
|
});
|
|
32
34
|
}
|
|
@@ -2,11 +2,11 @@ import { useMemo } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
4
4
|
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
5
|
-
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
|
+
import { useSWR, useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
6
6
|
|
|
7
7
|
import { getEarnedStakedBeraVault } from "../../actions/pol/getEarnedStakedBeraVault";
|
|
8
8
|
import { getRewardTokenToBeraRate } from "../../actions/pol/getRewardTokenToBeraRate";
|
|
9
|
-
import {
|
|
9
|
+
import { getStakedBeraAPY } from "../../actions/pol/getStakedBeraAPY";
|
|
10
10
|
import { useBeraFlag } from "../../contexts/BeraFlags/BeraFlags";
|
|
11
11
|
import { POLLING } from "../../enum/polling";
|
|
12
12
|
import { assertPublicClient } from "../../errors/assert";
|
|
@@ -18,7 +18,7 @@ import { useTokenPrices } from "../tokens/useTokenPrices";
|
|
|
18
18
|
/**
|
|
19
19
|
* Fetches staked asset data in two phases for progressive loading:
|
|
20
20
|
*
|
|
21
|
-
* 1.
|
|
21
|
+
* 1. APY — independent fetch, resolves quickly, shared by both phases.
|
|
22
22
|
* 2. Balances (fast path) — wallet balances (via usePollWalletBalances),
|
|
23
23
|
* token prices (via useTokenPrices), and exchange rates.
|
|
24
24
|
* Provides staked amounts and USD values immediately (earnings are 0).
|
|
@@ -42,12 +42,11 @@ export function useStakedData(stakingConfigs: StakingConfig[]) {
|
|
|
42
42
|
[stakingConfigs],
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
//
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{ refreshInterval: POLLING.NORMAL },
|
|
45
|
+
// APY — only updates every ~12 hours on BE
|
|
46
|
+
const apyKey = window ? (["useStakedData:apy", window] as const) : null;
|
|
47
|
+
|
|
48
|
+
const { data: apy } = useSWRImmutable(apyKey, async ([, window]) =>
|
|
49
|
+
getStakedBeraAPY({ window }),
|
|
51
50
|
);
|
|
52
51
|
|
|
53
52
|
const {
|
|
@@ -152,7 +151,7 @@ export function useStakedData(stakingConfigs: StakingConfig[]) {
|
|
|
152
151
|
|
|
153
152
|
return {
|
|
154
153
|
token: inputToken,
|
|
155
|
-
|
|
154
|
+
apy,
|
|
156
155
|
stakedAmount: stakedAmount.toNumber(),
|
|
157
156
|
stakedAmountUsd,
|
|
158
157
|
earnedAmount: 0,
|
|
@@ -164,7 +163,7 @@ export function useStakedData(stakingConfigs: StakingConfig[]) {
|
|
|
164
163
|
walletBalances,
|
|
165
164
|
exchangeRates,
|
|
166
165
|
stakingConfigs,
|
|
167
|
-
|
|
166
|
+
apy,
|
|
168
167
|
getTokenPrice,
|
|
169
168
|
earningsSettled,
|
|
170
169
|
]);
|
|
@@ -205,16 +204,18 @@ export function useStakedData(stakingConfigs: StakingConfig[]) {
|
|
|
205
204
|
|
|
206
205
|
return {
|
|
207
206
|
token: inputToken,
|
|
208
|
-
|
|
207
|
+
apy,
|
|
209
208
|
stakedAmount: stakedAmount.toNumber(),
|
|
210
209
|
earnedAmount: earnedAmount.toNumber(),
|
|
211
210
|
stakedAmountUsd,
|
|
212
211
|
earnedAmountUsd,
|
|
213
212
|
};
|
|
214
213
|
});
|
|
215
|
-
}, [positionsRaw, walletBalances, stakingConfigs,
|
|
214
|
+
}, [positionsRaw, walletBalances, stakingConfigs, apy, getTokenPrice]);
|
|
216
215
|
|
|
217
216
|
return {
|
|
217
|
+
/** Overall staked-BERA APY. Wallet-independent. */
|
|
218
|
+
apy,
|
|
218
219
|
/** Fast path: staked amounts + USD values (no earnings) */
|
|
219
220
|
balances,
|
|
220
221
|
/** Slow path: full enriched positions with earnings */
|
|
@@ -227,7 +228,7 @@ export function useStakedData(stakingConfigs: StakingConfig[]) {
|
|
|
227
228
|
/**
|
|
228
229
|
* Hard error: the RPC fast-path could not produce staked balances (wallet
|
|
229
230
|
* balances or exchange-rate reads failed). Price and earnings backend
|
|
230
|
-
* failures are intentionally excluded — those degrade gracefully (USD/
|
|
231
|
+
* failures are intentionally excluded — those degrade gracefully (USD/APY
|
|
231
232
|
* render as "—", earnings stop loading) so RPC-derived amounts still show.
|
|
232
233
|
*/
|
|
233
234
|
error: walletBalancesError ?? exchangeRatesError,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
|
-
import type { StakeStatsByDayResponse } from "@berachain/graphql/beep";
|
|
4
3
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
4
|
|
|
6
5
|
import { getStakingDailyAssets } from "../../actions/pol/getStakingDailyAssets";
|
|
6
|
+
import type { StakeStatsByDayResponse } from "../../generated/beep";
|
|
7
7
|
import type { DefaultHookReturnType } from "../../types/global";
|
|
8
8
|
import { dailyResolution } from "../../utils/filter";
|
|
9
9
|
|
|
@@ -4,33 +4,28 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
4
4
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
5
5
|
|
|
6
6
|
import { getSWBeraVaultMetadata } from "../../actions/pol/getSWBeraVaultMetadata";
|
|
7
|
-
import { useBlockTime } from "../../contexts/BlockTimeProvider";
|
|
8
7
|
import { POLLING } from "../../enum/polling";
|
|
9
8
|
import { assertPublicClient } from "../../errors/assert";
|
|
10
9
|
|
|
11
10
|
export type StakingVaultEntry = {
|
|
12
11
|
address: Address;
|
|
13
|
-
underlyingAsset: Address;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export function useStakingVaultsMetadata(vaults: StakingVaultEntry[] = []) {
|
|
17
15
|
const publicClient = usePublicClient();
|
|
18
|
-
const blockTime = useBlockTime();
|
|
19
16
|
const QUERY_KEY =
|
|
20
|
-
vaults.length > 0 && publicClient
|
|
21
|
-
? (["useStakingVaultMetadata", vaults
|
|
17
|
+
vaults.length > 0 && publicClient
|
|
18
|
+
? (["useStakingVaultMetadata", vaults] as const)
|
|
22
19
|
: null;
|
|
23
20
|
return useSWR(
|
|
24
21
|
QUERY_KEY,
|
|
25
|
-
async ([, vaults
|
|
22
|
+
async ([, vaults]) => {
|
|
26
23
|
assertPublicClient(publicClient);
|
|
27
24
|
return Promise.all(
|
|
28
25
|
vaults.map((vault) =>
|
|
29
26
|
getSWBeraVaultMetadata({
|
|
30
27
|
address: vault.address,
|
|
31
|
-
underlyingAsset: vault.underlyingAsset,
|
|
32
28
|
publicClient,
|
|
33
|
-
blockTime,
|
|
34
29
|
}),
|
|
35
30
|
),
|
|
36
31
|
);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PublicClient } from "viem";
|
|
2
2
|
|
|
3
|
+
import type { ChainId } from "@berachain/config";
|
|
3
4
|
import { defaultChainId } from "@berachain/config/internal";
|
|
4
5
|
|
|
5
6
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
7
|
import { useSWRImmutable } from "@berachain/utils/pkg/swr";
|
|
7
8
|
|
|
8
9
|
import { getTokenInformation } from "../../actions/tokens/getTokenInformation";
|
|
9
|
-
import { assertPublicClient } from "../../errors/assert";
|
|
10
|
+
import { assertAddress, assertPublicClient } from "../../errors/assert";
|
|
10
11
|
import type { Token } from "../../types/dex";
|
|
11
12
|
import type {
|
|
12
13
|
DefaultHookOptions,
|
|
@@ -17,10 +18,66 @@ export type UseMultipleTokenInformationResponse = DefaultHookReturnType<
|
|
|
17
18
|
Token[]
|
|
18
19
|
>;
|
|
19
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Resolve ERC20 metadata for a batch of addresses, best-effort. An address whose
|
|
23
|
+
* metadata can't be read — a non-ERC20 / codeless contract (e.g. a single-asset
|
|
24
|
+
* staking vault whose `decimals()` reverts), an invalid address, or a missing
|
|
25
|
+
* token — is simply omitted from the result rather than failing the whole batch.
|
|
26
|
+
* Consumers key results by address and treat a missing entry as absent.
|
|
27
|
+
*/
|
|
28
|
+
export async function fetchMultipleTokenInformation({
|
|
29
|
+
addresses,
|
|
30
|
+
publicClient,
|
|
31
|
+
chainId,
|
|
32
|
+
}: {
|
|
33
|
+
addresses: readonly string[];
|
|
34
|
+
publicClient: PublicClient;
|
|
35
|
+
chainId: ChainId;
|
|
36
|
+
}): Promise<Token[]> {
|
|
37
|
+
const settled = await Promise.allSettled(
|
|
38
|
+
addresses.map(async (address) => {
|
|
39
|
+
assertAddress(address, "address");
|
|
40
|
+
|
|
41
|
+
const tk = await getTokenInformation({
|
|
42
|
+
address,
|
|
43
|
+
publicClient,
|
|
44
|
+
chainId,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!tk) {
|
|
48
|
+
throw new Error(`Token ${address} not found`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return tk;
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return settled
|
|
56
|
+
.filter((r): r is PromiseFulfilledResult<Token> => r.status === "fulfilled")
|
|
57
|
+
.map((r) => r.value);
|
|
58
|
+
}
|
|
59
|
+
|
|
20
60
|
export type useMultipleTokenInformationArgs = {
|
|
61
|
+
/** Addresses to resolve metadata for. `undefined` disables the query. */
|
|
21
62
|
addresses: string[] | readonly string[] | undefined;
|
|
63
|
+
/** Chain to read from. Defaults to the app's `defaultChainId`. */
|
|
22
64
|
chainId?: number;
|
|
23
65
|
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Batch-resolves ERC20 metadata for `addresses`, best-effort.
|
|
69
|
+
*
|
|
70
|
+
* Metadata resolution is best-effort:
|
|
71
|
+
* any address that can't be resolved — a non-ERC20 / codeless contract (e.g. a
|
|
72
|
+
* single-asset staking vault whose `decimals()` reverts), an invalid address, or
|
|
73
|
+
* a missing token — is OMITTED rather than failing the whole batch. So the result
|
|
74
|
+
* length and order do not necessarily match the input `addresses`.
|
|
75
|
+
*
|
|
76
|
+
* ⚠️ The returned array is NOT positional.
|
|
77
|
+
* Do NOT index the result positionally (`data[i]` for `addresses[i]`). Always
|
|
78
|
+
* look tokens up by address, e.g. `data?.find(t => t.address === addr)` or build
|
|
79
|
+
* an address-keyed map.
|
|
80
|
+
*/
|
|
24
81
|
export function useMultipleTokenInformation(
|
|
25
82
|
args: useMultipleTokenInformationArgs,
|
|
26
83
|
options?: DefaultHookOptions,
|
|
@@ -44,25 +101,11 @@ export function useMultipleTokenInformation(
|
|
|
44
101
|
// but we need this for correct type inference
|
|
45
102
|
assertPublicClient(publicClient);
|
|
46
103
|
|
|
47
|
-
return
|
|
48
|
-
addresses
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const tk = await getTokenInformation({
|
|
54
|
-
address: address,
|
|
55
|
-
publicClient,
|
|
56
|
-
chainId,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (!tk) {
|
|
60
|
-
throw new Error(`Token ${address} not found`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return tk;
|
|
64
|
-
}),
|
|
65
|
-
);
|
|
104
|
+
return fetchMultipleTokenInformation({
|
|
105
|
+
addresses,
|
|
106
|
+
publicClient,
|
|
107
|
+
chainId,
|
|
108
|
+
});
|
|
66
109
|
},
|
|
67
110
|
{ ...options },
|
|
68
111
|
);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Address, PublicClient } from "viem";
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { ChainId } from "@berachain/config/internal";
|
|
5
|
+
|
|
6
|
+
import { getTokenInformation } from "../../actions/tokens/getTokenInformation";
|
|
7
|
+
import type { Token } from "../../types/dex";
|
|
8
|
+
import { fetchMultipleTokenInformation } from "./useMultipleTokenInformation";
|
|
9
|
+
|
|
10
|
+
vi.mock("../../actions/tokens/getTokenInformation", () => ({
|
|
11
|
+
getTokenInformation: vi.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const mockGetTokenInformation = vi.mocked(getTokenInformation);
|
|
15
|
+
|
|
16
|
+
// publicClient is only forwarded to (the mocked) getTokenInformation, so a stub
|
|
17
|
+
// is enough here.
|
|
18
|
+
const publicClient = {} as unknown as PublicClient;
|
|
19
|
+
const chainId = ChainId.MAINNET;
|
|
20
|
+
|
|
21
|
+
const ADDR_A = "0xac03caba51e17c86c921e1f6cbfbdc91f8bb2e6b" as Address;
|
|
22
|
+
const ADDR_B = "0xbaadcc2962417c01af99fb2b7c75706b9bd6babe" as Address;
|
|
23
|
+
const STAKING_CONTRACT =
|
|
24
|
+
"0x75f3be06b02e235f6d0e7ef2d462b29739168301" as Address;
|
|
25
|
+
|
|
26
|
+
function makeToken(address: Address, symbol: string): Token {
|
|
27
|
+
return {
|
|
28
|
+
address,
|
|
29
|
+
decimals: 18,
|
|
30
|
+
symbol,
|
|
31
|
+
name: symbol,
|
|
32
|
+
chainId,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
vi.clearAllMocks();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("fetchMultipleTokenInformation", () => {
|
|
41
|
+
it("omits an address whose metadata read reverts instead of rejecting the batch", async () => {
|
|
42
|
+
// Simulates a non-ERC20 single-asset staking contract: `decimals()` reverts,
|
|
43
|
+
// so getTokenInformation rethrows.
|
|
44
|
+
mockGetTokenInformation.mockImplementation(async ({ address }) => {
|
|
45
|
+
if (address === STAKING_CONTRACT) {
|
|
46
|
+
throw new Error('The contract function "decimals" reverted.');
|
|
47
|
+
}
|
|
48
|
+
return makeToken(address, address === ADDR_A ? "iBGT" : "LBGT");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const result = await fetchMultipleTokenInformation({
|
|
52
|
+
addresses: [ADDR_A, STAKING_CONTRACT, ADDR_B],
|
|
53
|
+
publicClient,
|
|
54
|
+
chainId,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(result).toHaveLength(2);
|
|
58
|
+
expect(result.map((t) => t.address)).toEqual([ADDR_A, ADDR_B]);
|
|
59
|
+
expect(result.some((t) => t.address === STAKING_CONTRACT)).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("drops invalid addresses without reading them", async () => {
|
|
63
|
+
mockGetTokenInformation.mockImplementation(async ({ address }) =>
|
|
64
|
+
makeToken(address, "iBGT"),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const result = await fetchMultipleTokenInformation({
|
|
68
|
+
addresses: ["not-an-address", ADDR_A],
|
|
69
|
+
publicClient,
|
|
70
|
+
chainId,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(result.map((t) => t.address)).toEqual([ADDR_A]);
|
|
74
|
+
// The invalid address never reaches getTokenInformation.
|
|
75
|
+
expect(mockGetTokenInformation).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("returns all tokens for an all-valid batch, preserving order", async () => {
|
|
79
|
+
mockGetTokenInformation.mockImplementation(async ({ address }) =>
|
|
80
|
+
makeToken(address, address === ADDR_A ? "iBGT" : "LBGT"),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const result = await fetchMultipleTokenInformation({
|
|
84
|
+
addresses: [ADDR_A, ADDR_B],
|
|
85
|
+
publicClient,
|
|
86
|
+
chainId,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(result.map((t) => t.address)).toEqual([ADDR_A, ADDR_B]);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -110,8 +110,10 @@ export function usePollBalance(
|
|
|
110
110
|
|
|
111
111
|
return {
|
|
112
112
|
...rest,
|
|
113
|
-
isLoading:
|
|
114
|
-
|
|
113
|
+
isLoading: isNativeToken
|
|
114
|
+
? isLoading
|
|
115
|
+
: isLoading || isLoadingTokenInformation,
|
|
116
|
+
error,
|
|
115
117
|
data: tokenBalance,
|
|
116
118
|
};
|
|
117
119
|
}
|