@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
package/dist/hooks/exports.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
BalancerApi,
|
|
6
6
|
BaseAggregator,
|
|
7
7
|
beraWriteContract,
|
|
8
|
+
ensoErc4626,
|
|
8
9
|
formatValidatorRewardAllocation,
|
|
9
10
|
getAllPools,
|
|
10
11
|
getAllValidators,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
getAutoclaimedIncentives,
|
|
16
17
|
getAutoclaimedIncentivesTxHash,
|
|
17
18
|
getBgtAprSimulation,
|
|
18
|
-
getBgtIncentiveDistributorPaused,
|
|
19
19
|
getBlockTimestamp,
|
|
20
20
|
getChartData,
|
|
21
21
|
getCollateralWeights,
|
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
getPythLatestPrices,
|
|
35
35
|
getPythUpdateFee,
|
|
36
36
|
getRelativeCapLimit,
|
|
37
|
-
getRewardProofsByValidator,
|
|
38
37
|
getRewardTokenToBeraRate,
|
|
39
38
|
getRewardVault,
|
|
40
39
|
getRewardVaultEarnedRewards,
|
|
@@ -44,20 +43,19 @@ import {
|
|
|
44
43
|
getRewardVaults,
|
|
45
44
|
getSWBeraVaultMetadata,
|
|
46
45
|
getSWBeraWithdrawal,
|
|
47
|
-
|
|
46
|
+
getStakedBeraAPY,
|
|
48
47
|
getStakedBeraSnapshots,
|
|
49
48
|
getStakingPoolBatch,
|
|
50
49
|
getSwapPayload,
|
|
51
50
|
getTokenCurrentPrices,
|
|
52
51
|
getTokenInformation,
|
|
53
52
|
getTotalStakedAmount,
|
|
54
|
-
|
|
53
|
+
getUserActiveValidatorsApi,
|
|
54
|
+
getUserActiveValidatorsOnChain,
|
|
55
55
|
getUserBoostsOnValidator,
|
|
56
|
-
getUserClaimableIncentives,
|
|
57
56
|
getUserStakingPositions,
|
|
58
57
|
getUserVaultInfo,
|
|
59
58
|
getUserVaults,
|
|
60
|
-
getValidatorAnalytics,
|
|
61
59
|
getValidatorCommission,
|
|
62
60
|
getValidatorEstimatedBgtPerYear,
|
|
63
61
|
getValidatorOperatorAddress,
|
|
@@ -68,12 +66,13 @@ import {
|
|
|
68
66
|
getVaultHistory,
|
|
69
67
|
getVaultValidators,
|
|
70
68
|
isBadCollateralAsset,
|
|
71
|
-
isBasketModeEnabled
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
isBasketModeEnabled,
|
|
70
|
+
mergeUserActiveValidators
|
|
71
|
+
} from "../chunk-KY7JMIIS.mjs";
|
|
72
|
+
import "../chunk-5MUCX35C.mjs";
|
|
74
73
|
import {
|
|
75
74
|
fetchBeep
|
|
76
|
-
} from "../chunk-
|
|
75
|
+
} from "../chunk-GDUKRUHE.mjs";
|
|
77
76
|
import "../chunk-GWSTVITN.mjs";
|
|
78
77
|
import {
|
|
79
78
|
TokenContext,
|
|
@@ -82,7 +81,7 @@ import {
|
|
|
82
81
|
useBlockTime,
|
|
83
82
|
useEnsoUserTokensWithBalances,
|
|
84
83
|
useHoneyConfig
|
|
85
|
-
} from "../chunk-
|
|
84
|
+
} from "../chunk-6D4S3EAC.mjs";
|
|
86
85
|
import {
|
|
87
86
|
swr_default,
|
|
88
87
|
useSWR,
|
|
@@ -91,28 +90,28 @@ import {
|
|
|
91
90
|
import {
|
|
92
91
|
getEnsoClient,
|
|
93
92
|
getWalletBalances
|
|
94
|
-
} from "../chunk-
|
|
93
|
+
} from "../chunk-ZHV3MQ4F.mjs";
|
|
95
94
|
import "../chunk-ZCEFC2TK.mjs";
|
|
96
|
-
import "../chunk-
|
|
95
|
+
import "../chunk-Z337NBBW.mjs";
|
|
96
|
+
import "../chunk-XO2BFPTB.mjs";
|
|
97
97
|
import "../chunk-GLWPRM33.mjs";
|
|
98
98
|
import {
|
|
99
99
|
TransactionFailedError
|
|
100
|
-
} from "../chunk-
|
|
100
|
+
} from "../chunk-M3MIGSH3.mjs";
|
|
101
101
|
import {
|
|
102
102
|
BeraMonitoring,
|
|
103
103
|
initBeraError
|
|
104
|
-
} from "../chunk-
|
|
104
|
+
} from "../chunk-FWRYUIJK.mjs";
|
|
105
105
|
import {
|
|
106
106
|
assertAddress,
|
|
107
|
-
assertAmount,
|
|
108
107
|
assertDefined,
|
|
109
108
|
assertPositive,
|
|
110
109
|
assertPublicClient
|
|
111
|
-
} from "../chunk-
|
|
110
|
+
} from "../chunk-TXWDUJOY.mjs";
|
|
112
111
|
import {
|
|
113
112
|
computePriceImpact,
|
|
114
113
|
wrapNativeTokens
|
|
115
|
-
} from "../chunk-
|
|
114
|
+
} from "../chunk-7KN7TDUC.mjs";
|
|
116
115
|
import {
|
|
117
116
|
DEFAULT_METAMASK_GAS_LIMIT,
|
|
118
117
|
bignumber_js_default,
|
|
@@ -123,24 +122,24 @@ import {
|
|
|
123
122
|
} from "../chunk-35RACQD4.mjs";
|
|
124
123
|
import {
|
|
125
124
|
beraFetchJson
|
|
126
|
-
} from "../chunk-
|
|
127
|
-
import "../chunk-
|
|
125
|
+
} from "../chunk-4576RF2K.mjs";
|
|
126
|
+
import "../chunk-XXKPXNQD.mjs";
|
|
128
127
|
import {
|
|
129
128
|
beraToken,
|
|
130
129
|
getHoneyToken,
|
|
131
130
|
isToken
|
|
132
|
-
} from "../chunk-
|
|
131
|
+
} from "../chunk-HPRLNT6R.mjs";
|
|
133
132
|
import {
|
|
134
133
|
parseBaseArgs
|
|
135
|
-
} from "../chunk-
|
|
134
|
+
} from "../chunk-SC3BSCTN.mjs";
|
|
136
135
|
import "../chunk-BMNEN4OK.mjs";
|
|
137
136
|
import {
|
|
138
137
|
RequestError
|
|
139
|
-
} from "../chunk-
|
|
138
|
+
} from "../chunk-LL7XR2H5.mjs";
|
|
140
139
|
import {
|
|
141
140
|
BeraError,
|
|
142
141
|
InvalidArgumentError
|
|
143
|
-
} from "../chunk-
|
|
142
|
+
} from "../chunk-MVNQY2D4.mjs";
|
|
144
143
|
|
|
145
144
|
// src/hooks/bend/useGetConvertToAssets.ts
|
|
146
145
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
@@ -174,6 +173,7 @@ import { useBeraWallet as useBeraWallet2, usePublicClient as usePublicClient4 }
|
|
|
174
173
|
|
|
175
174
|
// src/actions/dex/aggregators/bex.ts
|
|
176
175
|
import {
|
|
176
|
+
DECIMAL_SCALES,
|
|
177
177
|
Slippage,
|
|
178
178
|
Swap,
|
|
179
179
|
SwapKind,
|
|
@@ -192,6 +192,30 @@ var BexAggregator = class extends BaseAggregator {
|
|
|
192
192
|
supportedChains = [ChainId.MAINNET, ChainId.BEPOLIA];
|
|
193
193
|
url = getUriFromLink(this.config.api);
|
|
194
194
|
type = "graphql";
|
|
195
|
+
/**
|
|
196
|
+
* Opt bex out of tokens it structurally can't route (BGT, or decimals
|
|
197
|
+
* outside b-sdk's supported range) so the quote is never requested and other
|
|
198
|
+
* aggregators still handle it — see `supportsToken` for the specifics.
|
|
199
|
+
*/
|
|
200
|
+
getUnsupportedReason(args) {
|
|
201
|
+
const base = super.getUnsupportedReason(args);
|
|
202
|
+
if (base !== null) {
|
|
203
|
+
return base;
|
|
204
|
+
}
|
|
205
|
+
for (const token of [args.tokenIn, args.tokenOut]) {
|
|
206
|
+
if (!this.supportsToken(token)) {
|
|
207
|
+
return `${this.name} can't route ${token.symbol} (BGT or unsupported decimals).`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
supportsToken(token) {
|
|
213
|
+
if (isToken(token.address, "BGT", { config: this.config })) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
const scaleKey = 18 - token.decimals;
|
|
217
|
+
return scaleKey in DECIMAL_SCALES;
|
|
218
|
+
}
|
|
195
219
|
/**
|
|
196
220
|
* Helper function to convert zero address to wrapped token address
|
|
197
221
|
*/
|
|
@@ -341,7 +365,8 @@ var BexAggregator = class extends BaseAggregator {
|
|
|
341
365
|
functionName,
|
|
342
366
|
abi: balancerVaultAbi,
|
|
343
367
|
address: callData.to,
|
|
344
|
-
value: callData.value || BigInt(0)
|
|
368
|
+
value: callData.value || BigInt(0),
|
|
369
|
+
extraTags: { aggregator: this.name }
|
|
345
370
|
};
|
|
346
371
|
}
|
|
347
372
|
};
|
|
@@ -355,17 +380,21 @@ var RedeemBgtAggregator = class extends BaseAggregator {
|
|
|
355
380
|
name = "RedeemBgt" /* RedeemBgt */;
|
|
356
381
|
supportedChains = [ChainId2.MAINNET, ChainId2.BEPOLIA];
|
|
357
382
|
type = "rpc";
|
|
358
|
-
|
|
383
|
+
getUnsupportedReason({
|
|
359
384
|
tokenIn,
|
|
360
385
|
tokenOut
|
|
361
386
|
}) {
|
|
362
|
-
|
|
363
|
-
|
|
387
|
+
const base = super.getUnsupportedReason({ tokenIn, tokenOut });
|
|
388
|
+
if (base !== null) {
|
|
389
|
+
return base;
|
|
364
390
|
}
|
|
365
|
-
|
|
391
|
+
if (
|
|
366
392
|
// only supported on same chain
|
|
367
393
|
tokenIn.chainId === tokenOut.chainId && isToken(tokenIn, "BGT", { chainId: tokenIn.chainId }) && isToken(tokenOut, "BERA")
|
|
368
|
-
)
|
|
394
|
+
) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
return `${this.name} only redeems BGT \u2192 BERA on the same chain.`;
|
|
369
398
|
}
|
|
370
399
|
// handles native swaps: wrap and unwrap
|
|
371
400
|
async getQuote({
|
|
@@ -487,6 +516,7 @@ var EnsoAggregator = class extends BaseAggregator {
|
|
|
487
516
|
}
|
|
488
517
|
],
|
|
489
518
|
functionName: "swap",
|
|
519
|
+
extraTags: { aggregator: this.name },
|
|
490
520
|
abi: aggregatorsRouterAbi,
|
|
491
521
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
492
522
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
@@ -508,14 +538,25 @@ var ERC4626Aggregator = class extends BaseAggregator {
|
|
|
508
538
|
* Returns true when tokenOut is an ERC4626 vault whose underlying asset matches tokenIn,
|
|
509
539
|
* or when depositing native BERA into swBERA.
|
|
510
540
|
*/
|
|
511
|
-
|
|
541
|
+
getUnsupportedReason({
|
|
512
542
|
tokenIn,
|
|
513
543
|
tokenOut,
|
|
514
544
|
underlyingToken
|
|
515
545
|
}) {
|
|
516
|
-
const
|
|
546
|
+
const base = super.getUnsupportedReason({
|
|
547
|
+
tokenIn,
|
|
548
|
+
tokenOut,
|
|
549
|
+
underlyingToken
|
|
550
|
+
});
|
|
551
|
+
if (base !== null) {
|
|
552
|
+
return base;
|
|
553
|
+
}
|
|
554
|
+
const isVaultDeposit = !!underlyingToken && underlyingToken?.chainId === tokenOut.chainId && (isToken(underlyingToken, tokenIn) || // this is a special case for the swbera vault
|
|
517
555
|
isToken(tokenIn, "BERA") && isToken(tokenOut, "SWBERA"));
|
|
518
|
-
|
|
556
|
+
if (isVaultDeposit) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
return `${this.name} only deposits a token into its matching ERC4626 vault.`;
|
|
519
560
|
}
|
|
520
561
|
/**
|
|
521
562
|
* Fetches a deposit quote by calling `convertToShares` on the vault.
|
|
@@ -559,14 +600,16 @@ var ERC4626Aggregator = class extends BaseAggregator {
|
|
|
559
600
|
address: tokenOut.address,
|
|
560
601
|
functionName: "depositNative",
|
|
561
602
|
params: [BigInt(amount), account],
|
|
562
|
-
value: BigInt(amount)
|
|
603
|
+
value: BigInt(amount),
|
|
604
|
+
extraTags: { aggregator: this.name }
|
|
563
605
|
} : {
|
|
564
606
|
abi: erc4626Abi,
|
|
565
607
|
address: tokenOut.address,
|
|
566
608
|
functionName: "deposit",
|
|
567
609
|
contractName: "others.erc4626" /* ERC4626 */,
|
|
568
610
|
params: [BigInt(amount), account],
|
|
569
|
-
value: 0n
|
|
611
|
+
value: 0n,
|
|
612
|
+
extraTags: { aggregator: this.name }
|
|
570
613
|
}
|
|
571
614
|
};
|
|
572
615
|
}
|
|
@@ -672,6 +715,7 @@ var FlyAggregator = class extends BaseAggregator {
|
|
|
672
715
|
}
|
|
673
716
|
],
|
|
674
717
|
functionName: "swap",
|
|
718
|
+
extraTags: { aggregator: this.name },
|
|
675
719
|
abi: aggregatorsRouterAbi2,
|
|
676
720
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
677
721
|
value: isToken(tokenIn, "BERA") ? BigInt(amount) : BigInt("0"),
|
|
@@ -697,6 +741,20 @@ var HaikuAggregator = class extends BaseAggregator {
|
|
|
697
741
|
"No route found for the given input or the liquidity is not enough",
|
|
698
742
|
"Invalid input amount. Please ensure the total amount of input is greater than 0.001 USD"
|
|
699
743
|
];
|
|
744
|
+
getUnsupportedReason({
|
|
745
|
+
tokenIn,
|
|
746
|
+
tokenOut,
|
|
747
|
+
rewardVault
|
|
748
|
+
}) {
|
|
749
|
+
const base = super.getUnsupportedReason({ tokenIn, tokenOut });
|
|
750
|
+
if (base !== null) {
|
|
751
|
+
return base;
|
|
752
|
+
}
|
|
753
|
+
if (rewardVault) {
|
|
754
|
+
return `${this.name} does not support reward-vault staking.`;
|
|
755
|
+
}
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
700
758
|
async getQuote({
|
|
701
759
|
tokenIn,
|
|
702
760
|
tokenOut,
|
|
@@ -815,6 +873,7 @@ var HaikuAggregator = class extends BaseAggregator {
|
|
|
815
873
|
}
|
|
816
874
|
],
|
|
817
875
|
functionName: "swap",
|
|
876
|
+
extraTags: { aggregator: this.name },
|
|
818
877
|
abi: aggregatorsRouterAbi3,
|
|
819
878
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
820
879
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
@@ -855,16 +914,23 @@ var HoneyNativeAggregator = class extends BaseAggregator {
|
|
|
855
914
|
(coll) => isToken(coll.address, isMint ? tokenIn : tokenOut)
|
|
856
915
|
);
|
|
857
916
|
}
|
|
858
|
-
|
|
917
|
+
getUnsupportedReason({
|
|
859
918
|
tokenIn,
|
|
860
919
|
tokenOut,
|
|
861
920
|
honeyNativeState
|
|
862
921
|
}) {
|
|
863
|
-
|
|
922
|
+
const base = super.getUnsupportedReason({ tokenIn, tokenOut });
|
|
923
|
+
if (base !== null) {
|
|
924
|
+
return base;
|
|
925
|
+
}
|
|
926
|
+
if (tokenIn.chainId === tokenOut.chainId && this.isHoneyNativeSwap({
|
|
864
927
|
tokenIn: tokenIn.address,
|
|
865
928
|
tokenOut: tokenOut.address,
|
|
866
929
|
honeyNativeState
|
|
867
|
-
})
|
|
930
|
+
})) {
|
|
931
|
+
return null;
|
|
932
|
+
}
|
|
933
|
+
return `${this.name} only mints/redeems HONEY against a listed collateral.`;
|
|
868
934
|
}
|
|
869
935
|
async getQuote({
|
|
870
936
|
tokenIn,
|
|
@@ -884,7 +950,7 @@ var HoneyNativeAggregator = class extends BaseAggregator {
|
|
|
884
950
|
});
|
|
885
951
|
}
|
|
886
952
|
assertPublicClient(publicClient);
|
|
887
|
-
this.assertChainSupport({ tokenIn, tokenOut });
|
|
953
|
+
this.assertChainSupport({ tokenIn, tokenOut, honeyNativeState });
|
|
888
954
|
const isMint = isToken(tokenOut, this.honeyToken);
|
|
889
955
|
const hubOrderedCollaterals = collaterals;
|
|
890
956
|
const collateral = collaterals.find(
|
|
@@ -1094,6 +1160,7 @@ var KyberSwapAggregator = class extends BaseAggregator {
|
|
|
1094
1160
|
}
|
|
1095
1161
|
],
|
|
1096
1162
|
functionName: "swap",
|
|
1163
|
+
extraTags: { aggregator: this.name },
|
|
1097
1164
|
abi: aggregatorsRouterAbi4,
|
|
1098
1165
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
1099
1166
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
@@ -1188,6 +1255,7 @@ var OogaboogaAggregator = class extends BaseAggregator {
|
|
|
1188
1255
|
}
|
|
1189
1256
|
],
|
|
1190
1257
|
functionName: "swap",
|
|
1258
|
+
extraTags: { aggregator: this.name },
|
|
1191
1259
|
abi: aggregatorsRouterAbi5,
|
|
1192
1260
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
1193
1261
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
@@ -1309,6 +1377,7 @@ var OpenOceanAggregator = class extends BaseAggregator {
|
|
|
1309
1377
|
}
|
|
1310
1378
|
],
|
|
1311
1379
|
functionName: "swap",
|
|
1380
|
+
extraTags: { aggregator: this.name },
|
|
1312
1381
|
abi: aggregatorsRouterAbi6,
|
|
1313
1382
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
1314
1383
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
@@ -1327,18 +1396,21 @@ var WBeraAggregator = class extends BaseAggregator {
|
|
|
1327
1396
|
name = "Wrap" /* Wrap */;
|
|
1328
1397
|
supportedChains = [ChainId10.MAINNET, ChainId10.BEPOLIA];
|
|
1329
1398
|
type = "rpc";
|
|
1330
|
-
|
|
1399
|
+
// This aggregator's entire job is BERA↔WBERA, so keep the base same-token
|
|
1400
|
+
// (native-normalized) guard from rejecting it.
|
|
1401
|
+
supportsBeraWrap = true;
|
|
1402
|
+
getUnsupportedReason({
|
|
1331
1403
|
tokenIn,
|
|
1332
1404
|
tokenOut
|
|
1333
1405
|
}) {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
!super.checkChainSupport({ tokenIn, tokenOut })
|
|
1338
|
-
) {
|
|
1339
|
-
return false;
|
|
1406
|
+
const base = super.getUnsupportedReason({ tokenIn, tokenOut });
|
|
1407
|
+
if (base !== null) {
|
|
1408
|
+
return base;
|
|
1340
1409
|
}
|
|
1341
|
-
|
|
1410
|
+
if (tokenIn.chainId === tokenOut.chainId && (isToken(tokenIn, "BERA") && isToken(tokenOut, "WBERA") || isToken(tokenIn, "WBERA") && isToken(tokenOut, "BERA"))) {
|
|
1411
|
+
return null;
|
|
1412
|
+
}
|
|
1413
|
+
return `${this.name} only wraps/unwraps between BERA and WBERA on the same chain.`;
|
|
1342
1414
|
}
|
|
1343
1415
|
// handles native swaps: wrap and unwrap
|
|
1344
1416
|
async getQuote({
|
|
@@ -1361,13 +1433,15 @@ var WBeraAggregator = class extends BaseAggregator {
|
|
|
1361
1433
|
address: this.config.tokens.wbera,
|
|
1362
1434
|
functionName: "deposit",
|
|
1363
1435
|
params: [],
|
|
1364
|
-
value: BigInt(amount)
|
|
1436
|
+
value: BigInt(amount),
|
|
1437
|
+
extraTags: { aggregator: this.name }
|
|
1365
1438
|
} : {
|
|
1366
1439
|
abi: wberaAbi,
|
|
1367
1440
|
address: this.config.tokens.wbera,
|
|
1368
1441
|
functionName: "withdraw",
|
|
1369
1442
|
params: [BigInt(amount)],
|
|
1370
|
-
value: BigInt(0)
|
|
1443
|
+
value: BigInt(0),
|
|
1444
|
+
extraTags: { aggregator: this.name }
|
|
1371
1445
|
};
|
|
1372
1446
|
}
|
|
1373
1447
|
};
|
|
@@ -1453,17 +1527,19 @@ function getQueryKey({
|
|
|
1453
1527
|
args,
|
|
1454
1528
|
feeBps,
|
|
1455
1529
|
activeAggregators,
|
|
1456
|
-
isMAEnabled
|
|
1530
|
+
isMAEnabled,
|
|
1531
|
+
proxyAggregatorsThroughVercel
|
|
1457
1532
|
}) {
|
|
1458
1533
|
if (!Number(args.amount)) {
|
|
1459
1534
|
return null;
|
|
1460
1535
|
}
|
|
1461
|
-
if (
|
|
1536
|
+
if (aggregator.getUnsupportedReason({
|
|
1462
1537
|
tokenIn: args.tokenIn,
|
|
1463
1538
|
tokenOut: args.tokenOut,
|
|
1464
1539
|
underlyingToken: args.underlyingToken,
|
|
1465
|
-
honeyNativeState: args.honeyNativeState
|
|
1466
|
-
|
|
1540
|
+
honeyNativeState: args.honeyNativeState,
|
|
1541
|
+
rewardVault: args.rewardVault
|
|
1542
|
+
}) !== null) {
|
|
1467
1543
|
return null;
|
|
1468
1544
|
}
|
|
1469
1545
|
const name = aggregator.name;
|
|
@@ -1505,13 +1581,13 @@ function getQueryKey({
|
|
|
1505
1581
|
referrer,
|
|
1506
1582
|
rewardVault,
|
|
1507
1583
|
needsUnderlyingToken ? args.underlyingToken : void 0,
|
|
1508
|
-
aggregator.name === "Honey" /* Honey */ ? args.honeyNativeState?.collateralList : void 0
|
|
1584
|
+
aggregator.name === "Honey" /* Honey */ ? args.honeyNativeState?.collateralList : void 0,
|
|
1585
|
+
proxyAggregatorsThroughVercel ?? false
|
|
1509
1586
|
];
|
|
1510
1587
|
}
|
|
1511
1588
|
function getQueryFn({
|
|
1512
1589
|
aggregator,
|
|
1513
|
-
publicClient
|
|
1514
|
-
proxyAggregatorsThroughVercel
|
|
1590
|
+
publicClient
|
|
1515
1591
|
}) {
|
|
1516
1592
|
return async ([
|
|
1517
1593
|
,
|
|
@@ -1525,7 +1601,8 @@ function getQueryFn({
|
|
|
1525
1601
|
referrer,
|
|
1526
1602
|
rewardVault,
|
|
1527
1603
|
underlyingToken,
|
|
1528
|
-
honeyCollaterals
|
|
1604
|
+
honeyCollaterals,
|
|
1605
|
+
proxyAggregatorsThroughVercel
|
|
1529
1606
|
]) => aggregator.getQuote({
|
|
1530
1607
|
tokenIn,
|
|
1531
1608
|
tokenOut,
|
|
@@ -1559,11 +1636,11 @@ function raw_useSingleAggregatorQuote({
|
|
|
1559
1636
|
args,
|
|
1560
1637
|
feeBps,
|
|
1561
1638
|
activeAggregators,
|
|
1562
|
-
isMAEnabled
|
|
1639
|
+
isMAEnabled,
|
|
1640
|
+
proxyAggregatorsThroughVercel
|
|
1563
1641
|
}),
|
|
1564
1642
|
getQueryFn({
|
|
1565
1643
|
aggregator: args.aggregator,
|
|
1566
|
-
proxyAggregatorsThroughVercel,
|
|
1567
1644
|
publicClient
|
|
1568
1645
|
}),
|
|
1569
1646
|
options
|
|
@@ -1731,7 +1808,13 @@ function useAggregatorsQuotes(args, options) {
|
|
|
1731
1808
|
...args,
|
|
1732
1809
|
aggregator: bex
|
|
1733
1810
|
},
|
|
1734
|
-
{
|
|
1811
|
+
{
|
|
1812
|
+
...swrOptions,
|
|
1813
|
+
// Compose with the caller's gate (e.g. same-token suppression from
|
|
1814
|
+
// useSwap) instead of overwriting it — otherwise bex fetches whenever
|
|
1815
|
+
// it's unpaused, regardless of isEnabled (HUB-9FQ).
|
|
1816
|
+
isEnabled: (options?.isEnabled ?? true) && bexProtocol.isPaused === false
|
|
1817
|
+
}
|
|
1735
1818
|
);
|
|
1736
1819
|
const wberaSwapResult = raw_useSingleAggregatorQuote({
|
|
1737
1820
|
...sharedArgs,
|
|
@@ -2123,6 +2206,151 @@ function useCreatePool({
|
|
|
2123
2206
|
};
|
|
2124
2207
|
}
|
|
2125
2208
|
|
|
2209
|
+
// src/hooks/dex/useCrossChainNativeFee.ts
|
|
2210
|
+
import { formatEther as formatEther3, zeroAddress as zeroAddress13 } from "viem";
|
|
2211
|
+
|
|
2212
|
+
// src/hooks/tokens/usePollBalance.ts
|
|
2213
|
+
import {
|
|
2214
|
+
erc20Abi,
|
|
2215
|
+
formatEther as formatEther2,
|
|
2216
|
+
formatUnits as formatUnits5,
|
|
2217
|
+
isAddress as isAddress3,
|
|
2218
|
+
zeroAddress as zeroAddress12
|
|
2219
|
+
} from "viem";
|
|
2220
|
+
import { defaultChainId as defaultChainId3 } from "@berachain/config/internal";
|
|
2221
|
+
import { useBeraWallet as useBeraWallet3, usePublicClient as usePublicClient6 } from "@berachain/wagmi/hooks";
|
|
2222
|
+
|
|
2223
|
+
// src/hooks/tokens/useTokenInformation.ts
|
|
2224
|
+
import { isAddress as isAddress2, zeroAddress as zeroAddress11 } from "viem";
|
|
2225
|
+
import { defaultChainId as defaultChainId2 } from "@berachain/config/internal";
|
|
2226
|
+
import { usePublicClient as usePublicClient5 } from "@berachain/wagmi/hooks";
|
|
2227
|
+
function useTokenInformation(args, options) {
|
|
2228
|
+
const publicClient = usePublicClient5({
|
|
2229
|
+
chainId: args.chainId
|
|
2230
|
+
});
|
|
2231
|
+
const QUERY_KEY = args?.address && publicClient && isAddress2(args.address) ? ["useTokenInformation", args.address, args.chainId] : null;
|
|
2232
|
+
return useSWRImmutable(
|
|
2233
|
+
QUERY_KEY,
|
|
2234
|
+
async ([_, address, chainId2 = defaultChainId2]) => {
|
|
2235
|
+
if (isToken(address, "BERA")) {
|
|
2236
|
+
return {
|
|
2237
|
+
address: zeroAddress11,
|
|
2238
|
+
decimals: beraToken.decimals,
|
|
2239
|
+
name: beraToken.name,
|
|
2240
|
+
symbol: beraToken.symbol,
|
|
2241
|
+
chainId: chainId2
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
assertPublicClient(publicClient);
|
|
2245
|
+
return await getTokenInformation({
|
|
2246
|
+
address,
|
|
2247
|
+
publicClient,
|
|
2248
|
+
chainId: chainId2
|
|
2249
|
+
});
|
|
2250
|
+
},
|
|
2251
|
+
{ ...options }
|
|
2252
|
+
);
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
// src/hooks/tokens/usePollBalance.ts
|
|
2256
|
+
function usePollBalance({
|
|
2257
|
+
address: addressString,
|
|
2258
|
+
owner,
|
|
2259
|
+
chainId: chainId2 = defaultChainId3
|
|
2260
|
+
}, options) {
|
|
2261
|
+
let address = addressString;
|
|
2262
|
+
if (isToken(address, "ETH")) {
|
|
2263
|
+
address = zeroAddress12;
|
|
2264
|
+
}
|
|
2265
|
+
const publicClient = usePublicClient6({ chainId: chainId2 });
|
|
2266
|
+
const { address: account } = useBeraWallet3();
|
|
2267
|
+
const assetOwner = owner ?? account;
|
|
2268
|
+
const QUERY_KEY = publicClient && assetOwner && isAddress3(assetOwner) && address && isAddress3(address) ? ["usePollBalance", assetOwner, address, chainId2] : null;
|
|
2269
|
+
const { data: tokenInformation, isLoading: isLoadingTokenInformation } = useTokenInformation({ address, chainId: chainId2 });
|
|
2270
|
+
const isNativeToken = isToken(address, "BERA");
|
|
2271
|
+
const { isLoading, data, error, ...rest } = useSWR(
|
|
2272
|
+
QUERY_KEY,
|
|
2273
|
+
async ([, assetOwner2, address2]) => {
|
|
2274
|
+
assertPublicClient(publicClient);
|
|
2275
|
+
if (!isToken(address2, "BERA")) {
|
|
2276
|
+
return await publicClient.readContract({
|
|
2277
|
+
address: address2,
|
|
2278
|
+
abi: erc20Abi,
|
|
2279
|
+
functionName: "balanceOf",
|
|
2280
|
+
args: [assetOwner2]
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
return await publicClient.getBalance({
|
|
2284
|
+
address: assetOwner2
|
|
2285
|
+
});
|
|
2286
|
+
},
|
|
2287
|
+
{
|
|
2288
|
+
refreshInterval: 1e4 /* FAST */,
|
|
2289
|
+
...options
|
|
2290
|
+
}
|
|
2291
|
+
);
|
|
2292
|
+
const formattedBalance = !error && data ? isToken(address, "BERA") ? formatEther2(data) : tokenInformation && !isLoadingTokenInformation ? formatUnits5(data, tokenInformation.decimals) : void 0 : void 0;
|
|
2293
|
+
const tokenBalance = {
|
|
2294
|
+
chainId: chainId2,
|
|
2295
|
+
balance: data ? {
|
|
2296
|
+
raw: data.toString(),
|
|
2297
|
+
formatted: formattedBalance ?? "0"
|
|
2298
|
+
} : { raw: "0", formatted: "0" },
|
|
2299
|
+
address,
|
|
2300
|
+
decimals: isNativeToken ? beraToken.decimals : tokenInformation?.decimals ?? 0,
|
|
2301
|
+
symbol: isNativeToken ? beraToken.symbol : tokenInformation?.symbol ?? "",
|
|
2302
|
+
name: isNativeToken ? beraToken.name : tokenInformation?.name ?? ""
|
|
2303
|
+
};
|
|
2304
|
+
return {
|
|
2305
|
+
...rest,
|
|
2306
|
+
isLoading: isNativeToken ? isLoading : isLoading || isLoadingTokenInformation,
|
|
2307
|
+
error,
|
|
2308
|
+
data: tokenBalance
|
|
2309
|
+
};
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// src/hooks/dex/useCrossChainNativeFee.ts
|
|
2313
|
+
function isNativeFeeInsufficient({
|
|
2314
|
+
isCrossChain,
|
|
2315
|
+
value,
|
|
2316
|
+
nativeBalance,
|
|
2317
|
+
isLoading
|
|
2318
|
+
}) {
|
|
2319
|
+
if (!isCrossChain) return false;
|
|
2320
|
+
return value > 0n && !isLoading && value > nativeBalance;
|
|
2321
|
+
}
|
|
2322
|
+
function useCrossChainNativeFee({
|
|
2323
|
+
srcChainId,
|
|
2324
|
+
value
|
|
2325
|
+
}) {
|
|
2326
|
+
const isCrossChain = srcChainId !== void 0;
|
|
2327
|
+
const { data: nativeBalanceData, isLoading: isNativeBalanceLoading } = usePollBalance(
|
|
2328
|
+
{
|
|
2329
|
+
address: zeroAddress13,
|
|
2330
|
+
chainId: isCrossChain ? srcChainId : void 0
|
|
2331
|
+
},
|
|
2332
|
+
{ isEnabled: isCrossChain }
|
|
2333
|
+
);
|
|
2334
|
+
if (!isCrossChain) {
|
|
2335
|
+
return {
|
|
2336
|
+
nativeFee: void 0,
|
|
2337
|
+
hasInsufficientNativeBalance: false,
|
|
2338
|
+
isNativeBalanceLoading: false
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
const nativeBalance = BigInt(nativeBalanceData?.balance.raw ?? 0n);
|
|
2342
|
+
return {
|
|
2343
|
+
nativeFee: value > 0n ? formatEther3(value) : void 0,
|
|
2344
|
+
hasInsufficientNativeBalance: isNativeFeeInsufficient({
|
|
2345
|
+
isCrossChain,
|
|
2346
|
+
value,
|
|
2347
|
+
nativeBalance,
|
|
2348
|
+
isLoading: isNativeBalanceLoading
|
|
2349
|
+
}),
|
|
2350
|
+
isNativeBalanceLoading
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2126
2354
|
// src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts
|
|
2127
2355
|
function useGlobalLiquidityAndSwapVolume() {
|
|
2128
2356
|
const response = useSWR(
|
|
@@ -2249,24 +2477,24 @@ function useLiquidityMismatch({
|
|
|
2249
2477
|
}
|
|
2250
2478
|
|
|
2251
2479
|
// src/hooks/dex/useLpPosition.ts
|
|
2252
|
-
import { formatEther as
|
|
2480
|
+
import { formatEther as formatEther4, isAddressEqual } from "viem";
|
|
2253
2481
|
|
|
2254
2482
|
// src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts
|
|
2255
|
-
import { isAddress as
|
|
2483
|
+
import { isAddress as isAddress5, zeroAddress as zeroAddress15 } from "viem";
|
|
2256
2484
|
import { rewardVaultAbi } from "@berachain/abis/pol/rewards/rewardVault";
|
|
2257
|
-
import { useBeraWallet as
|
|
2485
|
+
import { useBeraWallet as useBeraWallet4, usePublicClient as usePublicClient8 } from "@berachain/wagmi/hooks";
|
|
2258
2486
|
|
|
2259
2487
|
// src/hooks/pol/useRewardVaultFromToken.ts
|
|
2260
|
-
import { isAddress as
|
|
2488
|
+
import { isAddress as isAddress4, zeroAddress as zeroAddress14 } from "viem";
|
|
2261
2489
|
import { rewardVaultFactoryAbi } from "@berachain/abis/pol/rewards/rewardVaultFactory";
|
|
2262
|
-
import { usePublicClient as
|
|
2490
|
+
import { usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
|
|
2263
2491
|
function useRewardVaultFromToken({
|
|
2264
2492
|
tokenAddress
|
|
2265
2493
|
}, {
|
|
2266
2494
|
isEnabled = true
|
|
2267
2495
|
} = {}) {
|
|
2268
|
-
const publicClient =
|
|
2269
|
-
const QUERY_KEY = publicClient && tokenAddress &&
|
|
2496
|
+
const publicClient = usePublicClient7();
|
|
2497
|
+
const QUERY_KEY = publicClient && tokenAddress && isAddress4(tokenAddress) && isEnabled ? ["useRewardVaultFromToken", tokenAddress] : null;
|
|
2270
2498
|
return useSWRImmutable(
|
|
2271
2499
|
QUERY_KEY,
|
|
2272
2500
|
async ([, tokenAddress2]) => {
|
|
@@ -2283,7 +2511,7 @@ function useRewardVaultFromToken({
|
|
|
2283
2511
|
functionName: "getVault",
|
|
2284
2512
|
args: [tokenAddress2]
|
|
2285
2513
|
});
|
|
2286
|
-
return res ===
|
|
2514
|
+
return res === zeroAddress14 ? void 0 : res;
|
|
2287
2515
|
}
|
|
2288
2516
|
);
|
|
2289
2517
|
}
|
|
@@ -2293,12 +2521,11 @@ function useRewardVaultBalanceFromStakingToken({
|
|
|
2293
2521
|
stakingToken,
|
|
2294
2522
|
rewardVaultAddress: _rewardVaultAddress
|
|
2295
2523
|
}, options) {
|
|
2296
|
-
const { address: account } =
|
|
2297
|
-
const publicClient =
|
|
2524
|
+
const { address: account } = useBeraWallet4();
|
|
2525
|
+
const publicClient = usePublicClient8();
|
|
2298
2526
|
const isEnabled = options?.isEnabled ?? true;
|
|
2299
2527
|
const {
|
|
2300
2528
|
data: rewardVaultAddress = _rewardVaultAddress,
|
|
2301
|
-
error,
|
|
2302
2529
|
refresh: mutateRewardVaultAddress,
|
|
2303
2530
|
isLoading: isLoadingRewardVaultAddress
|
|
2304
2531
|
} = useRewardVaultFromToken(
|
|
@@ -2310,10 +2537,10 @@ function useRewardVaultBalanceFromStakingToken({
|
|
|
2310
2537
|
}
|
|
2311
2538
|
);
|
|
2312
2539
|
const swrResponse = useSWR(
|
|
2313
|
-
rewardVaultAddress && account && publicClient &&
|
|
2540
|
+
rewardVaultAddress && account && publicClient && isAddress5(rewardVaultAddress) && isAddress5(account) ? ["useVaultBalanceFromStakingToken", rewardVaultAddress, account] : null,
|
|
2314
2541
|
async ([, rewardVaultAddress2, account2]) => {
|
|
2315
2542
|
assertPublicClient(publicClient);
|
|
2316
|
-
if (rewardVaultAddress2 ===
|
|
2543
|
+
if (rewardVaultAddress2 === zeroAddress15) {
|
|
2317
2544
|
return {
|
|
2318
2545
|
address: rewardVaultAddress2,
|
|
2319
2546
|
balance: 0n
|
|
@@ -2342,106 +2569,6 @@ function useRewardVaultBalanceFromStakingToken({
|
|
|
2342
2569
|
};
|
|
2343
2570
|
}
|
|
2344
2571
|
|
|
2345
|
-
// src/hooks/tokens/usePollBalance.ts
|
|
2346
|
-
import {
|
|
2347
|
-
erc20Abi,
|
|
2348
|
-
formatEther as formatEther2,
|
|
2349
|
-
formatUnits as formatUnits5,
|
|
2350
|
-
isAddress as isAddress5,
|
|
2351
|
-
zeroAddress as zeroAddress14
|
|
2352
|
-
} from "viem";
|
|
2353
|
-
import { defaultChainId as defaultChainId3 } from "@berachain/config/internal";
|
|
2354
|
-
import { useBeraWallet as useBeraWallet4, usePublicClient as usePublicClient8 } from "@berachain/wagmi/hooks";
|
|
2355
|
-
|
|
2356
|
-
// src/hooks/tokens/useTokenInformation.ts
|
|
2357
|
-
import { isAddress as isAddress4, zeroAddress as zeroAddress13 } from "viem";
|
|
2358
|
-
import { defaultChainId as defaultChainId2 } from "@berachain/config/internal";
|
|
2359
|
-
import { usePublicClient as usePublicClient7 } from "@berachain/wagmi/hooks";
|
|
2360
|
-
function useTokenInformation(args, options) {
|
|
2361
|
-
const publicClient = usePublicClient7({
|
|
2362
|
-
chainId: args.chainId
|
|
2363
|
-
});
|
|
2364
|
-
const QUERY_KEY = args?.address && publicClient && isAddress4(args.address) ? ["useTokenInformation", args.address, args.chainId] : null;
|
|
2365
|
-
return useSWRImmutable(
|
|
2366
|
-
QUERY_KEY,
|
|
2367
|
-
async ([_, address, chainId2 = defaultChainId2]) => {
|
|
2368
|
-
if (isToken(address, "BERA")) {
|
|
2369
|
-
return {
|
|
2370
|
-
address: zeroAddress13,
|
|
2371
|
-
decimals: beraToken.decimals,
|
|
2372
|
-
name: beraToken.name,
|
|
2373
|
-
symbol: beraToken.symbol,
|
|
2374
|
-
chainId: chainId2
|
|
2375
|
-
};
|
|
2376
|
-
}
|
|
2377
|
-
assertPublicClient(publicClient);
|
|
2378
|
-
return await getTokenInformation({
|
|
2379
|
-
address,
|
|
2380
|
-
publicClient,
|
|
2381
|
-
chainId: chainId2
|
|
2382
|
-
});
|
|
2383
|
-
},
|
|
2384
|
-
{ ...options }
|
|
2385
|
-
);
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
|
-
// src/hooks/tokens/usePollBalance.ts
|
|
2389
|
-
function usePollBalance({
|
|
2390
|
-
address: addressString,
|
|
2391
|
-
owner,
|
|
2392
|
-
chainId: chainId2 = defaultChainId3
|
|
2393
|
-
}, options) {
|
|
2394
|
-
let address = addressString;
|
|
2395
|
-
if (isToken(address, "ETH")) {
|
|
2396
|
-
address = zeroAddress14;
|
|
2397
|
-
}
|
|
2398
|
-
const publicClient = usePublicClient8({ chainId: chainId2 });
|
|
2399
|
-
const { address: account } = useBeraWallet4();
|
|
2400
|
-
const assetOwner = owner ?? account;
|
|
2401
|
-
const QUERY_KEY = publicClient && assetOwner && isAddress5(assetOwner) && address && isAddress5(address) ? ["usePollBalance", assetOwner, address, chainId2] : null;
|
|
2402
|
-
const { data: tokenInformation, isLoading: isLoadingTokenInformation } = useTokenInformation({ address, chainId: chainId2 });
|
|
2403
|
-
const isNativeToken = isToken(address, "BERA");
|
|
2404
|
-
const { isLoading, data, error, ...rest } = useSWR(
|
|
2405
|
-
QUERY_KEY,
|
|
2406
|
-
async ([, assetOwner2, address2]) => {
|
|
2407
|
-
assertPublicClient(publicClient);
|
|
2408
|
-
if (!isToken(address2, "BERA")) {
|
|
2409
|
-
return await publicClient.readContract({
|
|
2410
|
-
address: address2,
|
|
2411
|
-
abi: erc20Abi,
|
|
2412
|
-
functionName: "balanceOf",
|
|
2413
|
-
args: [assetOwner2]
|
|
2414
|
-
});
|
|
2415
|
-
}
|
|
2416
|
-
return await publicClient.getBalance({
|
|
2417
|
-
address: assetOwner2
|
|
2418
|
-
});
|
|
2419
|
-
},
|
|
2420
|
-
{
|
|
2421
|
-
refreshInterval: 1e4 /* FAST */,
|
|
2422
|
-
...options
|
|
2423
|
-
}
|
|
2424
|
-
);
|
|
2425
|
-
const formattedBalance = !error && data ? isToken(address, "BERA") ? formatEther2(data) : tokenInformation && !isLoadingTokenInformation ? formatUnits5(data, tokenInformation.decimals) : void 0 : void 0;
|
|
2426
|
-
const tokenBalance = {
|
|
2427
|
-
chainId: chainId2,
|
|
2428
|
-
balance: data ? {
|
|
2429
|
-
raw: data.toString(),
|
|
2430
|
-
formatted: formattedBalance ?? "0"
|
|
2431
|
-
} : { raw: "0", formatted: "0" },
|
|
2432
|
-
address,
|
|
2433
|
-
decimals: isNativeToken ? beraToken.decimals : tokenInformation?.decimals ?? 0,
|
|
2434
|
-
symbol: isNativeToken ? beraToken.symbol : tokenInformation?.symbol ?? "",
|
|
2435
|
-
name: isNativeToken ? beraToken.name : tokenInformation?.name ?? ""
|
|
2436
|
-
};
|
|
2437
|
-
return {
|
|
2438
|
-
...rest,
|
|
2439
|
-
isLoading: isLoading || isNativeToken ? isLoadingTokenInformation : false,
|
|
2440
|
-
error: error || !isNativeToken ? error : void 0,
|
|
2441
|
-
data: tokenBalance
|
|
2442
|
-
};
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
2572
|
// src/hooks/dex/useLpPosition.ts
|
|
2446
2573
|
function useLpPosition({ pool, vaultAddress }, options) {
|
|
2447
2574
|
const { data: userPosition, ...rest } = usePollBalance({
|
|
@@ -2491,9 +2618,9 @@ function useLpPosition({ pool, vaultAddress }, options) {
|
|
|
2491
2618
|
balance: {
|
|
2492
2619
|
raw: userVaultTokenBalance.balance.toString(),
|
|
2493
2620
|
// Pools always use the 18 decimals
|
|
2494
|
-
formatted:
|
|
2621
|
+
formatted: formatEther4(userVaultTokenBalance.balance)
|
|
2495
2622
|
},
|
|
2496
|
-
usdValue: Number(
|
|
2623
|
+
usdValue: Number(formatEther4(userVaultTokenBalance.balance)) * lpTokenPrice
|
|
2497
2624
|
} : void 0
|
|
2498
2625
|
},
|
|
2499
2626
|
...rest,
|
|
@@ -2506,7 +2633,7 @@ function useLpPosition({ pool, vaultAddress }, options) {
|
|
|
2506
2633
|
|
|
2507
2634
|
// src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts
|
|
2508
2635
|
import { useMemo as useMemo3 } from "react";
|
|
2509
|
-
import { parseUnits as parseUnits4, zeroAddress as
|
|
2636
|
+
import { parseUnits as parseUnits4, zeroAddress as zeroAddress16 } from "viem";
|
|
2510
2637
|
|
|
2511
2638
|
// src/hooks/tokens/usePollAllowances.ts
|
|
2512
2639
|
import { useBeraWallet as useBeraWallet5, useConfig as useConfig2 } from "@berachain/wagmi/hooks";
|
|
@@ -2542,7 +2669,7 @@ function calculateMaxAmountIn({
|
|
|
2542
2669
|
function useMultipleTokenApprovalsWithSlippage(tokenInput, options) {
|
|
2543
2670
|
const { slippage } = options ?? {};
|
|
2544
2671
|
const items = useMemo3(
|
|
2545
|
-
() => tokenInput.filter((token) => token.token.address !==
|
|
2672
|
+
() => tokenInput.filter((token) => token.token.address !== zeroAddress16).filter((token) => bignumber_js_default(token.amount.formatted).gt(0)),
|
|
2546
2673
|
[tokenInput]
|
|
2547
2674
|
);
|
|
2548
2675
|
const {
|
|
@@ -2595,13 +2722,33 @@ function useMultipleTokenApprovalsWithSlippage(tokenInput, options) {
|
|
|
2595
2722
|
|
|
2596
2723
|
// src/hooks/dex/useOnChainPoolData.ts
|
|
2597
2724
|
import { useMemo as useMemo5 } from "react";
|
|
2598
|
-
import { formatUnits as formatUnits6, isAddress as
|
|
2725
|
+
import { formatUnits as formatUnits6, isAddress as isAddress7 } from "viem";
|
|
2599
2726
|
import { usePublicClient as usePublicClient10 } from "@berachain/wagmi/hooks";
|
|
2600
2727
|
|
|
2601
2728
|
// src/hooks/tokens/useMultipleTokenInformation.ts
|
|
2602
|
-
import { isAddress as isAddress6 } from "viem";
|
|
2603
2729
|
import { defaultChainId as defaultChainId4 } from "@berachain/config/internal";
|
|
2604
2730
|
import { usePublicClient as usePublicClient9 } from "@berachain/wagmi/hooks";
|
|
2731
|
+
async function fetchMultipleTokenInformation({
|
|
2732
|
+
addresses,
|
|
2733
|
+
publicClient,
|
|
2734
|
+
chainId: chainId2
|
|
2735
|
+
}) {
|
|
2736
|
+
const settled = await Promise.allSettled(
|
|
2737
|
+
addresses.map(async (address) => {
|
|
2738
|
+
assertAddress(address, "address");
|
|
2739
|
+
const tk = await getTokenInformation({
|
|
2740
|
+
address,
|
|
2741
|
+
publicClient,
|
|
2742
|
+
chainId: chainId2
|
|
2743
|
+
});
|
|
2744
|
+
if (!tk) {
|
|
2745
|
+
throw new Error(`Token ${address} not found`);
|
|
2746
|
+
}
|
|
2747
|
+
return tk;
|
|
2748
|
+
})
|
|
2749
|
+
);
|
|
2750
|
+
return settled.filter((r) => r.status === "fulfilled").map((r) => r.value);
|
|
2751
|
+
}
|
|
2605
2752
|
function useMultipleTokenInformation(args, options) {
|
|
2606
2753
|
const publicClient = usePublicClient9();
|
|
2607
2754
|
const QUERY_KEY = publicClient && args.addresses ? [
|
|
@@ -2613,22 +2760,11 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2613
2760
|
QUERY_KEY,
|
|
2614
2761
|
async ([, addresses, chainId2]) => {
|
|
2615
2762
|
assertPublicClient(publicClient);
|
|
2616
|
-
return
|
|
2617
|
-
addresses
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
const tk = await getTokenInformation({
|
|
2622
|
-
address,
|
|
2623
|
-
publicClient,
|
|
2624
|
-
chainId: chainId2
|
|
2625
|
-
});
|
|
2626
|
-
if (!tk) {
|
|
2627
|
-
throw new Error(`Token ${address} not found`);
|
|
2628
|
-
}
|
|
2629
|
-
return tk;
|
|
2630
|
-
})
|
|
2631
|
-
);
|
|
2763
|
+
return fetchMultipleTokenInformation({
|
|
2764
|
+
addresses,
|
|
2765
|
+
publicClient,
|
|
2766
|
+
chainId: chainId2
|
|
2767
|
+
});
|
|
2632
2768
|
},
|
|
2633
2769
|
{ ...options }
|
|
2634
2770
|
);
|
|
@@ -2636,7 +2772,7 @@ function useMultipleTokenInformation(args, options) {
|
|
|
2636
2772
|
|
|
2637
2773
|
// src/hooks/tokens/useTokenCurrentPrices.ts
|
|
2638
2774
|
import { useMemo as useMemo4 } from "react";
|
|
2639
|
-
import { isAddress as
|
|
2775
|
+
import { isAddress as isAddress6, zeroAddress as zeroAddress17 } from "viem";
|
|
2640
2776
|
import { defaultChainId as defaultChainId5 } from "@berachain/config/internal";
|
|
2641
2777
|
|
|
2642
2778
|
// src/hooks/tokens/useTokens.ts
|
|
@@ -2674,7 +2810,7 @@ function useTokenCurrentPrices({
|
|
|
2674
2810
|
const addresses2 = [];
|
|
2675
2811
|
if (addressIn) {
|
|
2676
2812
|
addresses2.push(
|
|
2677
|
-
...addressIn.filter((a) =>
|
|
2813
|
+
...addressIn.filter((a) => isAddress6(a))
|
|
2678
2814
|
);
|
|
2679
2815
|
}
|
|
2680
2816
|
return addresses2.map((a) => a.toLowerCase());
|
|
@@ -2684,7 +2820,7 @@ function useTokenCurrentPrices({
|
|
|
2684
2820
|
tokenList?.map((token) => token.address.toLowerCase())
|
|
2685
2821
|
);
|
|
2686
2822
|
if (tokenList.some((token) => isToken(token, "WBERA"))) {
|
|
2687
|
-
tokenSet.add(
|
|
2823
|
+
tokenSet.add(zeroAddress17);
|
|
2688
2824
|
}
|
|
2689
2825
|
return beraAddresses?.some((a) => !tokenSet.has(a));
|
|
2690
2826
|
}, [beraAddresses, tokenList]);
|
|
@@ -2746,7 +2882,7 @@ function useTokenCurrentPrices({
|
|
|
2746
2882
|
// src/hooks/dex/useOnChainPoolData.ts
|
|
2747
2883
|
function useOnChainPoolDataQueryKey(args) {
|
|
2748
2884
|
const address = "poolId" in args ? args.poolId?.slice(0, 42) : args.address;
|
|
2749
|
-
const isAddressValid =
|
|
2885
|
+
const isAddressValid = isAddress7(address);
|
|
2750
2886
|
const isValid = isAddressValid;
|
|
2751
2887
|
return isValid && address ? ["useOnChainPoolData", address] : null;
|
|
2752
2888
|
}
|
|
@@ -2780,18 +2916,15 @@ function useOnChainPoolData(poolId) {
|
|
|
2780
2916
|
if (!poolData || !tokenInformation) {
|
|
2781
2917
|
return void 0;
|
|
2782
2918
|
}
|
|
2783
|
-
const
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
createTime: 0,
|
|
2793
|
-
name: poolData.name,
|
|
2794
|
-
tokens: tokenInformation.map((token, idx) => ({
|
|
2919
|
+
const infoByAddress = new Map(
|
|
2920
|
+
tokenInformation.map(
|
|
2921
|
+
(token) => [token.address.toLowerCase(), token]
|
|
2922
|
+
)
|
|
2923
|
+
);
|
|
2924
|
+
const tokens = poolData.poolTokens[0].map((rawAddress, idx) => {
|
|
2925
|
+
const token = infoByAddress.get(rawAddress.toLowerCase());
|
|
2926
|
+
if (!token) return null;
|
|
2927
|
+
return {
|
|
2795
2928
|
address: token.address.toLowerCase(),
|
|
2796
2929
|
name: token.name,
|
|
2797
2930
|
decimals: token.decimals,
|
|
@@ -2807,7 +2940,23 @@ function useOnChainPoolData(poolId) {
|
|
|
2807
2940
|
token,
|
|
2808
2941
|
latestUSDPrice: tokenPrices?.[token.address]
|
|
2809
2942
|
}
|
|
2810
|
-
}
|
|
2943
|
+
};
|
|
2944
|
+
});
|
|
2945
|
+
if (tokens.some((token) => token === null)) {
|
|
2946
|
+
return void 0;
|
|
2947
|
+
}
|
|
2948
|
+
const pool2 = {
|
|
2949
|
+
address: address.toLowerCase(),
|
|
2950
|
+
id: poolId.toLowerCase(),
|
|
2951
|
+
type: poolData.type,
|
|
2952
|
+
factory: poolData.factory,
|
|
2953
|
+
totalShares: poolData.totalSupply,
|
|
2954
|
+
totalLiquidity: "0",
|
|
2955
|
+
// overwritten below
|
|
2956
|
+
swapFee: poolData.swapFee,
|
|
2957
|
+
createTime: 0,
|
|
2958
|
+
name: poolData.name,
|
|
2959
|
+
tokens,
|
|
2811
2960
|
amplificationParameter: poolData?.amplificationParameter && {
|
|
2812
2961
|
// For example, if value is 300000n and precision is 1000n, the user-set amplification parameter would be 300000n / 1000n = 300n.
|
|
2813
2962
|
currentFormattedValue: Number(poolData.amplificationParameter[0]) / Number(poolData.amplificationParameter[2])
|
|
@@ -3122,10 +3271,10 @@ import {
|
|
|
3122
3271
|
ethAddress,
|
|
3123
3272
|
formatUnits as formatUnits7,
|
|
3124
3273
|
getAddress,
|
|
3125
|
-
zeroAddress as
|
|
3274
|
+
zeroAddress as zeroAddress18
|
|
3126
3275
|
} from "viem";
|
|
3127
3276
|
function toEnsoAddress(address) {
|
|
3128
|
-
return address ===
|
|
3277
|
+
return address === zeroAddress18 ? ethAddress : address;
|
|
3129
3278
|
}
|
|
3130
3279
|
function toBigIntOrUndefined(value) {
|
|
3131
3280
|
if (value === null || value === void 0) {
|
|
@@ -3133,52 +3282,6 @@ function toBigIntOrUndefined(value) {
|
|
|
3133
3282
|
}
|
|
3134
3283
|
return typeof value === "bigint" ? value : BigInt(value);
|
|
3135
3284
|
}
|
|
3136
|
-
async function getTransactionsFromBundle({
|
|
3137
|
-
fromAddress,
|
|
3138
|
-
amountIn,
|
|
3139
|
-
tokenIn,
|
|
3140
|
-
chainId: chainId2,
|
|
3141
|
-
ensoClient,
|
|
3142
|
-
bundle,
|
|
3143
|
-
publicClient
|
|
3144
|
-
}) {
|
|
3145
|
-
const transactions = [];
|
|
3146
|
-
if (tokenIn !== ethAddress) {
|
|
3147
|
-
const approvalRequest = await ensoClient.getApprovalData({
|
|
3148
|
-
fromAddress,
|
|
3149
|
-
tokenAddress: tokenIn,
|
|
3150
|
-
chainId: chainId2,
|
|
3151
|
-
amount: amountIn
|
|
3152
|
-
});
|
|
3153
|
-
let requiresApproval = true;
|
|
3154
|
-
if (publicClient) {
|
|
3155
|
-
const currentAllowance = await publicClient.readContract({
|
|
3156
|
-
address: tokenIn,
|
|
3157
|
-
abi: erc20Abi2,
|
|
3158
|
-
functionName: "allowance",
|
|
3159
|
-
args: [fromAddress, approvalRequest.spender]
|
|
3160
|
-
});
|
|
3161
|
-
requiresApproval = currentAllowance < BigInt(amountIn);
|
|
3162
|
-
}
|
|
3163
|
-
if (requiresApproval) {
|
|
3164
|
-
const approvalValue = toBigIntOrUndefined(approvalRequest.tx.value) ?? 0n;
|
|
3165
|
-
transactions.push({
|
|
3166
|
-
to: approvalRequest.tx.to,
|
|
3167
|
-
data: approvalRequest.tx.data,
|
|
3168
|
-
value: approvalValue,
|
|
3169
|
-
gasLimit: BigInt(approvalRequest.gas)
|
|
3170
|
-
});
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
|
-
const bundleValue = toBigIntOrUndefined(bundle.tx.value) ?? 0n;
|
|
3174
|
-
transactions.push({
|
|
3175
|
-
to: bundle.tx.to,
|
|
3176
|
-
data: bundle.tx.data,
|
|
3177
|
-
value: bundleValue,
|
|
3178
|
-
gasLimit: BigInt(bundle.gas)
|
|
3179
|
-
});
|
|
3180
|
-
return transactions;
|
|
3181
|
-
}
|
|
3182
3285
|
async function getEnsoWalletTransactionsWithApproval({
|
|
3183
3286
|
fromAddress,
|
|
3184
3287
|
amountIn,
|
|
@@ -3813,7 +3916,6 @@ async function getBendMultiplyBundle({
|
|
|
3813
3916
|
leverageMultiplier,
|
|
3814
3917
|
slippage
|
|
3815
3918
|
});
|
|
3816
|
-
const CALLBACK_IDX_ROUTE_LOAN_TO_COLLATERAL = 0;
|
|
3817
3919
|
const CALLBACK_IDX_BALANCE_COLLATERAL = 1;
|
|
3818
3920
|
const depositOnlyActions = [
|
|
3819
3921
|
{
|
|
@@ -4039,152 +4141,8 @@ function useBendMultiply({
|
|
|
4039
4141
|
}
|
|
4040
4142
|
|
|
4041
4143
|
// src/hooks/enso/useBendZapSupply.ts
|
|
4042
|
-
import {
|
|
4043
|
-
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
4144
|
+
import { parseUnits as parseUnits7, zeroAddress as zeroAddress19 } from "viem";
|
|
4044
4145
|
import { useBeraWallet as useBeraWallet12, usePublicClient as usePublicClient16 } from "@berachain/wagmi/hooks";
|
|
4045
|
-
|
|
4046
|
-
// src/actions/dex/aggregators/enso/ensoErc4626.ts
|
|
4047
|
-
import { ethAddress as ethAddress2, zeroAddress as zeroAddress18 } from "viem";
|
|
4048
|
-
var EnsoErc4626Aggregator = class extends BaseAggregator {
|
|
4049
|
-
name = "Enso (Mint)" /* EnsoErc4626 */;
|
|
4050
|
-
supportedChains = null;
|
|
4051
|
-
type = "rest";
|
|
4052
|
-
needsAccountForQuote = true;
|
|
4053
|
-
notFoundMessages = [
|
|
4054
|
-
"Could not build shortcuts for route",
|
|
4055
|
-
"Could not quote shortcuts for route",
|
|
4056
|
-
"Swap not found for a required underlying of defi route,",
|
|
4057
|
-
"No route found from"
|
|
4058
|
-
];
|
|
4059
|
-
async getQuote({
|
|
4060
|
-
tokenIn,
|
|
4061
|
-
tokenOut,
|
|
4062
|
-
amount,
|
|
4063
|
-
slippage,
|
|
4064
|
-
account = zeroAddress18,
|
|
4065
|
-
aggregatorsFeeBps,
|
|
4066
|
-
proxyAggregatorsThroughVercel = false,
|
|
4067
|
-
rewardVault,
|
|
4068
|
-
underlyingToken
|
|
4069
|
-
}) {
|
|
4070
|
-
this.assertChainSupport({ tokenIn, tokenOut });
|
|
4071
|
-
assertAddress(account, "account");
|
|
4072
|
-
const ensoClient = getEnsoClient({
|
|
4073
|
-
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : void 0
|
|
4074
|
-
});
|
|
4075
|
-
if (tokenIn.address === zeroAddress18) tokenIn.address = ethAddress2;
|
|
4076
|
-
if (tokenOut.address === zeroAddress18) tokenOut.address = ethAddress2;
|
|
4077
|
-
const zapTokenOut = underlyingToken ?? tokenOut;
|
|
4078
|
-
const bundleActions = [
|
|
4079
|
-
// this is the base route action, which will swap the token in to the zap token out
|
|
4080
|
-
// it handles cross-chain swaps and refunds the user if the swap fails
|
|
4081
|
-
// this might even be the only action if no underlying token or reward vault is provided
|
|
4082
|
-
{
|
|
4083
|
-
protocol: "enso",
|
|
4084
|
-
action: "route",
|
|
4085
|
-
args: {
|
|
4086
|
-
tokenIn: tokenIn.address,
|
|
4087
|
-
tokenOut: zapTokenOut.address,
|
|
4088
|
-
destinationChainId: (
|
|
4089
|
-
// must be undefined if the token is the same chain
|
|
4090
|
-
tokenIn.chainId === zapTokenOut.chainId ? void 0 : zapTokenOut.chainId
|
|
4091
|
-
),
|
|
4092
|
-
refundReceiver: account,
|
|
4093
|
-
amountIn: amount,
|
|
4094
|
-
slippage: slippage * 100
|
|
4095
|
-
// Enso expects slippage in basis points
|
|
4096
|
-
}
|
|
4097
|
-
}
|
|
4098
|
-
];
|
|
4099
|
-
if (underlyingToken) {
|
|
4100
|
-
bundleActions.push({
|
|
4101
|
-
protocol: "erc4626",
|
|
4102
|
-
action: "deposit",
|
|
4103
|
-
args: {
|
|
4104
|
-
amountIn: { useOutputOfCallAt: 0 },
|
|
4105
|
-
tokenIn: underlyingToken.address,
|
|
4106
|
-
primaryAddress: tokenOut.address,
|
|
4107
|
-
tokenOut: tokenOut.address
|
|
4108
|
-
}
|
|
4109
|
-
});
|
|
4110
|
-
}
|
|
4111
|
-
if (rewardVault) {
|
|
4112
|
-
const offset = bundleActions.length;
|
|
4113
|
-
bundleActions.push(
|
|
4114
|
-
{
|
|
4115
|
-
protocol: "enso",
|
|
4116
|
-
action: "balance",
|
|
4117
|
-
args: {
|
|
4118
|
-
token: tokenOut.address
|
|
4119
|
-
}
|
|
4120
|
-
},
|
|
4121
|
-
{
|
|
4122
|
-
protocol: "erc20",
|
|
4123
|
-
action: "approve",
|
|
4124
|
-
args: {
|
|
4125
|
-
amount: { useOutputOfCallAt: offset },
|
|
4126
|
-
spender: rewardVault,
|
|
4127
|
-
token: tokenOut.address
|
|
4128
|
-
}
|
|
4129
|
-
},
|
|
4130
|
-
{
|
|
4131
|
-
protocol: "enso",
|
|
4132
|
-
action: "call",
|
|
4133
|
-
args: {
|
|
4134
|
-
address: rewardVault,
|
|
4135
|
-
args: [account, { useOutputOfCallAt: offset }],
|
|
4136
|
-
method: "stakeOnBehalf",
|
|
4137
|
-
abi: "function stakeOnBehalf(address account, uint256 amount) external"
|
|
4138
|
-
}
|
|
4139
|
-
},
|
|
4140
|
-
{
|
|
4141
|
-
protocol: "enso",
|
|
4142
|
-
action: "balance",
|
|
4143
|
-
args: {
|
|
4144
|
-
token: rewardVault
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
|
-
);
|
|
4148
|
-
}
|
|
4149
|
-
const bundle = await ensoClient.getBundleData(
|
|
4150
|
-
{
|
|
4151
|
-
fromAddress: account,
|
|
4152
|
-
receiver: account,
|
|
4153
|
-
spender: account,
|
|
4154
|
-
chainId: tokenIn.chainId,
|
|
4155
|
-
routingStrategy: "router"
|
|
4156
|
-
},
|
|
4157
|
-
bundleActions
|
|
4158
|
-
);
|
|
4159
|
-
const tokenOutAddress = rewardVault?.toLowerCase() ?? tokenOut.address.toLowerCase();
|
|
4160
|
-
const amountOut = (
|
|
4161
|
-
// @ts-expect-error enso has not typed this but is returned sometimes from API.
|
|
4162
|
-
bundle.minAmountsOut?.[tokenOutAddress] ?? bundle.amountsOut[tokenOutAddress] ?? "0"
|
|
4163
|
-
);
|
|
4164
|
-
return {
|
|
4165
|
-
amountOut,
|
|
4166
|
-
amountIn: amount,
|
|
4167
|
-
allowanceRequirements: this.parseAllowanceRequirements({
|
|
4168
|
-
tokenIn,
|
|
4169
|
-
rawAmount: amount,
|
|
4170
|
-
spender: bundle.tx.to
|
|
4171
|
-
}),
|
|
4172
|
-
name: this.name,
|
|
4173
|
-
swapFeeBps: 0,
|
|
4174
|
-
priceImpactPercentage: bundle.priceImpact ? bundle.priceImpact / 100 : null,
|
|
4175
|
-
getCalldata: () => ({
|
|
4176
|
-
address: bundle.tx.to,
|
|
4177
|
-
data: bundle.tx.data,
|
|
4178
|
-
value: BigInt(bundle.tx.value ?? 0)
|
|
4179
|
-
// not returning gas limit because it's usually underestimated by enso.
|
|
4180
|
-
// gasLimit: BigInt(bundle.gas),
|
|
4181
|
-
})
|
|
4182
|
-
};
|
|
4183
|
-
}
|
|
4184
|
-
};
|
|
4185
|
-
var ensoErc4626 = new EnsoErc4626Aggregator();
|
|
4186
|
-
|
|
4187
|
-
// src/hooks/enso/useBendZapSupply.ts
|
|
4188
4146
|
function useBendZapSupply({
|
|
4189
4147
|
tokenIn,
|
|
4190
4148
|
loanToken,
|
|
@@ -4193,9 +4151,6 @@ function useBendZapSupply({
|
|
|
4193
4151
|
amount,
|
|
4194
4152
|
slippage
|
|
4195
4153
|
}, options) {
|
|
4196
|
-
const { getTokenPrice } = useTokenPrices({
|
|
4197
|
-
tokens: tokenIn && loanToken ? [tokenIn, loanToken] : void 0
|
|
4198
|
-
});
|
|
4199
4154
|
const swrResponse = useBendZapSupplyHelper(
|
|
4200
4155
|
{
|
|
4201
4156
|
tokenIn,
|
|
@@ -4224,21 +4179,12 @@ function useBendZapSupply({
|
|
|
4224
4179
|
formattedAmountOut: zapSupplyAmount?.formatted ?? "0"
|
|
4225
4180
|
}
|
|
4226
4181
|
);
|
|
4227
|
-
const isCrossChain =
|
|
4228
|
-
const { data: nativeBalanceData, isLoading: isNativeBalanceLoading } = usePollBalance(
|
|
4229
|
-
{
|
|
4230
|
-
address: zeroAddress19,
|
|
4231
|
-
chainId: isCrossChain ? tokenIn?.chainId : void 0
|
|
4232
|
-
},
|
|
4233
|
-
{ isEnabled: !!isCrossChain }
|
|
4234
|
-
);
|
|
4182
|
+
const isCrossChain = swrResponse.data?.isCrossChain;
|
|
4235
4183
|
const transactionValue = swrResponse.data?.getCalldata?.({ account: zeroAddress19 })?.value ?? 0n;
|
|
4236
|
-
const
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
};
|
|
4240
|
-
const hasInsufficientNativeBalance = isCrossChain && transactionValue > 0n && !isNativeBalanceLoading && transactionValue > BigInt(nativeBalance.raw);
|
|
4241
|
-
const nativeFee = isCrossChain && transactionValue > 0n ? formatEther4(transactionValue) : void 0;
|
|
4184
|
+
const { hasInsufficientNativeBalance, nativeFee } = useCrossChainNativeFee({
|
|
4185
|
+
srcChainId: isCrossChain ? swrResponse.data?.srcChainId : void 0,
|
|
4186
|
+
value: transactionValue
|
|
4187
|
+
});
|
|
4242
4188
|
return {
|
|
4243
4189
|
...swrResponse,
|
|
4244
4190
|
zapSupplyAmount,
|
|
@@ -4289,7 +4235,8 @@ function useBendZapSupplyHelper({
|
|
|
4289
4235
|
bendVault2,
|
|
4290
4236
|
rewardVault2,
|
|
4291
4237
|
amount2,
|
|
4292
|
-
slippage2
|
|
4238
|
+
slippage2,
|
|
4239
|
+
proxyAggregatorsThroughVercel2
|
|
4293
4240
|
]) => {
|
|
4294
4241
|
assertPublicClient(publicClientBeraChain);
|
|
4295
4242
|
assertAddress(fromAddress2, "fromAddress");
|
|
@@ -4303,7 +4250,7 @@ function useBendZapSupplyHelper({
|
|
|
4303
4250
|
slippage: slippage2,
|
|
4304
4251
|
account: fromAddress2,
|
|
4305
4252
|
rewardVault: rewardVault2,
|
|
4306
|
-
proxyAggregatorsThroughVercel
|
|
4253
|
+
proxyAggregatorsThroughVercel: proxyAggregatorsThroughVercel2
|
|
4307
4254
|
});
|
|
4308
4255
|
},
|
|
4309
4256
|
{
|
|
@@ -4313,187 +4260,10 @@ function useBendZapSupplyHelper({
|
|
|
4313
4260
|
);
|
|
4314
4261
|
}
|
|
4315
4262
|
|
|
4316
|
-
// src/hooks/enso/useEnsoSwapBundle.ts
|
|
4317
|
-
import { getPublicClient as getPublicClient2 } from "@wagmi/core";
|
|
4318
|
-
import { parseUnits as parseUnits8 } from "viem";
|
|
4319
|
-
import { defaultChainId as berachainChainId2 } from "@berachain/config/internal";
|
|
4320
|
-
import { useBeraWallet as useBeraWallet14, useConfig as useConfig4 } from "@berachain/wagmi/hooks";
|
|
4321
|
-
|
|
4322
|
-
// src/actions/enso/getEnsoSwapBundle.ts
|
|
4323
|
-
import { ethAddress as ethAddress3, zeroAddress as zeroAddress20 } from "viem";
|
|
4324
|
-
async function getEnsoSwapBundle({
|
|
4325
|
-
fromAddress,
|
|
4326
|
-
amountIn,
|
|
4327
|
-
tokenIn,
|
|
4328
|
-
tokenOut,
|
|
4329
|
-
chainId: chainId2,
|
|
4330
|
-
ensoClient,
|
|
4331
|
-
destinationChainId,
|
|
4332
|
-
slippage,
|
|
4333
|
-
publicClient
|
|
4334
|
-
}) {
|
|
4335
|
-
assertAddress(fromAddress, "fromAddress");
|
|
4336
|
-
if (tokenOut === zeroAddress20) tokenOut = ethAddress3;
|
|
4337
|
-
const bundleAction = {
|
|
4338
|
-
protocol: "enso",
|
|
4339
|
-
action: "route",
|
|
4340
|
-
args: {
|
|
4341
|
-
tokenIn,
|
|
4342
|
-
tokenOut,
|
|
4343
|
-
amountIn,
|
|
4344
|
-
slippage: slippage * 100
|
|
4345
|
-
// Enso expects slippage in basis points
|
|
4346
|
-
}
|
|
4347
|
-
};
|
|
4348
|
-
if (destinationChainId && destinationChainId !== chainId2) {
|
|
4349
|
-
bundleAction.args = {
|
|
4350
|
-
...bundleAction.args,
|
|
4351
|
-
destinationChainId,
|
|
4352
|
-
refundReceiver: fromAddress
|
|
4353
|
-
};
|
|
4354
|
-
}
|
|
4355
|
-
const bundle = await ensoClient.getBundleData(
|
|
4356
|
-
{
|
|
4357
|
-
fromAddress,
|
|
4358
|
-
receiver: fromAddress,
|
|
4359
|
-
spender: fromAddress,
|
|
4360
|
-
chainId: chainId2,
|
|
4361
|
-
routingStrategy: "router"
|
|
4362
|
-
},
|
|
4363
|
-
[bundleAction]
|
|
4364
|
-
);
|
|
4365
|
-
const transactions = await getTransactionsFromBundle({
|
|
4366
|
-
fromAddress,
|
|
4367
|
-
amountIn,
|
|
4368
|
-
tokenIn,
|
|
4369
|
-
chainId: chainId2,
|
|
4370
|
-
ensoClient,
|
|
4371
|
-
bundle,
|
|
4372
|
-
publicClient
|
|
4373
|
-
});
|
|
4374
|
-
return {
|
|
4375
|
-
bundle,
|
|
4376
|
-
transactions
|
|
4377
|
-
};
|
|
4378
|
-
}
|
|
4379
|
-
|
|
4380
|
-
// src/hooks/tokens/usePollWalletBalances.ts
|
|
4381
|
-
import { useMemo as useMemo9 } from "react";
|
|
4382
|
-
import {
|
|
4383
|
-
useBeraWallet as useBeraWallet13,
|
|
4384
|
-
useConfig as useConfig3,
|
|
4385
|
-
usePublicClient as usePublicClient17
|
|
4386
|
-
} from "@berachain/wagmi/hooks";
|
|
4387
|
-
function usePollWalletBalances(args, options) {
|
|
4388
|
-
const publicClient = usePublicClient17();
|
|
4389
|
-
const wagmiConfig = useConfig3();
|
|
4390
|
-
const { address: connectedAccount } = useBeraWallet13();
|
|
4391
|
-
const { tokenList, refresh } = useTokens();
|
|
4392
|
-
const wallet = args?.walletAddress ?? connectedAccount;
|
|
4393
|
-
const tokens = useMemo9(() => {
|
|
4394
|
-
return new Map(
|
|
4395
|
-
(args?.tokens ?? tokenList)?.map((t) => [t.address.toLowerCase(), t]) ?? []
|
|
4396
|
-
);
|
|
4397
|
-
}, [tokenList, args?.tokens]);
|
|
4398
|
-
const QUERY_KEY = publicClient && tokenList !== void 0 && wallet ? [
|
|
4399
|
-
"usePollWalletBalances",
|
|
4400
|
-
wallet,
|
|
4401
|
-
// TODO: adding the whole list to the query is very inefficient, we should only add the tokens addresses
|
|
4402
|
-
Array.from(tokens.values())
|
|
4403
|
-
] : null;
|
|
4404
|
-
const swrResponse = useSWR(
|
|
4405
|
-
QUERY_KEY,
|
|
4406
|
-
async ([, wallet2, tokenList2]) => {
|
|
4407
|
-
return getWalletBalances({
|
|
4408
|
-
account: wallet2,
|
|
4409
|
-
tokenList: tokenList2,
|
|
4410
|
-
wagmiConfig
|
|
4411
|
-
});
|
|
4412
|
-
},
|
|
4413
|
-
{
|
|
4414
|
-
refreshInterval: 1e5 /* NORMAL */,
|
|
4415
|
-
...options
|
|
4416
|
-
}
|
|
4417
|
-
);
|
|
4418
|
-
return {
|
|
4419
|
-
...swrResponse,
|
|
4420
|
-
refresh: () => {
|
|
4421
|
-
swrResponse?.refresh();
|
|
4422
|
-
refresh();
|
|
4423
|
-
}
|
|
4424
|
-
};
|
|
4425
|
-
}
|
|
4426
|
-
|
|
4427
|
-
// src/hooks/enso/useEnsoSwapBundle.ts
|
|
4428
|
-
function useEnsoSwapBundle({
|
|
4429
|
-
tokenIn,
|
|
4430
|
-
tokenOut,
|
|
4431
|
-
amount,
|
|
4432
|
-
slippage
|
|
4433
|
-
}) {
|
|
4434
|
-
const { address: fromAddress } = useBeraWallet14();
|
|
4435
|
-
const wagmiConfig = useConfig4();
|
|
4436
|
-
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4437
|
-
"proxyAggregatorsThroughVercel"
|
|
4438
|
-
);
|
|
4439
|
-
const ensoClient = getEnsoClient({
|
|
4440
|
-
baseURL: proxyAggregatorsThroughVercel ? "/api/enso" : void 0
|
|
4441
|
-
});
|
|
4442
|
-
const { refresh: refreshBalances } = usePollWalletBalances();
|
|
4443
|
-
const isEnabled = !!tokenIn && !!tokenOut && !!amount && Number(amount) > 0 && !!slippage && !!fromAddress && !!tokenIn.chainId;
|
|
4444
|
-
const QUERY_KEY = isEnabled ? [
|
|
4445
|
-
"useEnsoSwapBundle",
|
|
4446
|
-
fromAddress,
|
|
4447
|
-
tokenIn,
|
|
4448
|
-
tokenOut,
|
|
4449
|
-
amount,
|
|
4450
|
-
slippage,
|
|
4451
|
-
proxyAggregatorsThroughVercel ?? false
|
|
4452
|
-
] : null;
|
|
4453
|
-
const swrResponse = useSWR(
|
|
4454
|
-
QUERY_KEY,
|
|
4455
|
-
async ([, fromAddress2, tokenIn2, tokenOut2, amount2, slippage2]) => {
|
|
4456
|
-
assertAddress(fromAddress2, "fromAddress");
|
|
4457
|
-
assertAddress(tokenIn2?.address, "tokenInAddress");
|
|
4458
|
-
assertDefined(tokenIn2?.chainId, "tokenInChainId");
|
|
4459
|
-
assertAddress(tokenOut2?.address, "tokenOutAddress");
|
|
4460
|
-
assertAmount(amount2, "amount");
|
|
4461
|
-
assertAmount(slippage2, "slippage");
|
|
4462
|
-
const publicClient = getPublicClient2(wagmiConfig, {
|
|
4463
|
-
chainId: tokenIn2.chainId
|
|
4464
|
-
});
|
|
4465
|
-
assertPublicClient(publicClient);
|
|
4466
|
-
const rawAmount = parseUnits8(amount2, tokenIn2.decimals).toString();
|
|
4467
|
-
return getEnsoSwapBundle({
|
|
4468
|
-
fromAddress: fromAddress2,
|
|
4469
|
-
amountIn: rawAmount,
|
|
4470
|
-
tokenIn: tokenIn2.address,
|
|
4471
|
-
tokenOut: tokenOut2.address,
|
|
4472
|
-
chainId: tokenIn2.chainId,
|
|
4473
|
-
ensoClient,
|
|
4474
|
-
destinationChainId: berachainChainId2,
|
|
4475
|
-
slippage: slippage2,
|
|
4476
|
-
publicClient
|
|
4477
|
-
});
|
|
4478
|
-
},
|
|
4479
|
-
{
|
|
4480
|
-
refreshInterval: 1e5 /* NORMAL */,
|
|
4481
|
-
isEnabled
|
|
4482
|
-
}
|
|
4483
|
-
);
|
|
4484
|
-
return {
|
|
4485
|
-
...swrResponse,
|
|
4486
|
-
refresh: () => {
|
|
4487
|
-
swrResponse.refresh();
|
|
4488
|
-
refreshBalances();
|
|
4489
|
-
}
|
|
4490
|
-
};
|
|
4491
|
-
}
|
|
4492
|
-
|
|
4493
4263
|
// src/hooks/enso/useZapStakeBera.ts
|
|
4494
|
-
import { formatUnits as formatUnits9, parseUnits as
|
|
4264
|
+
import { formatUnits as formatUnits9, parseUnits as parseUnits8 } from "viem";
|
|
4495
4265
|
import { chainConfigs, defaultChainId as defaultChainId9 } from "@berachain/config/internal";
|
|
4496
|
-
import { useBeraWallet as
|
|
4266
|
+
import { useBeraWallet as useBeraWallet13 } from "@berachain/wagmi/hooks";
|
|
4497
4267
|
function useZapStakeBera({
|
|
4498
4268
|
inputToken,
|
|
4499
4269
|
amount,
|
|
@@ -4501,7 +4271,10 @@ function useZapStakeBera({
|
|
|
4501
4271
|
slippage,
|
|
4502
4272
|
tokenOut
|
|
4503
4273
|
}, options) {
|
|
4504
|
-
const { address: account } =
|
|
4274
|
+
const { address: account } = useBeraWallet13();
|
|
4275
|
+
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
4276
|
+
"proxyAggregatorsThroughVercel"
|
|
4277
|
+
);
|
|
4505
4278
|
const quoteAccount = account ?? chainConfigs[defaultChainId9].bex.aggregatorsRouterExecutor;
|
|
4506
4279
|
const isEnabled = !!inputToken && !!amount && Number(amount) > 0 && !!inputToken.chainId && !!underlyingToken && !!slippage;
|
|
4507
4280
|
const QUERY_KEY = isEnabled ? [
|
|
@@ -4511,7 +4284,8 @@ function useZapStakeBera({
|
|
|
4511
4284
|
quoteAccount,
|
|
4512
4285
|
slippage,
|
|
4513
4286
|
underlyingToken,
|
|
4514
|
-
tokenOut
|
|
4287
|
+
tokenOut,
|
|
4288
|
+
proxyAggregatorsThroughVercel ?? false
|
|
4515
4289
|
] : null;
|
|
4516
4290
|
const swrResponse = useSWR(
|
|
4517
4291
|
QUERY_KEY,
|
|
@@ -4522,16 +4296,18 @@ function useZapStakeBera({
|
|
|
4522
4296
|
quoteAccount2,
|
|
4523
4297
|
slippage2,
|
|
4524
4298
|
underlyingToken2,
|
|
4525
|
-
tokenOut2
|
|
4299
|
+
tokenOut2,
|
|
4300
|
+
proxyAggregatorsThroughVercel2
|
|
4526
4301
|
]) => {
|
|
4527
|
-
const rawAmount =
|
|
4302
|
+
const rawAmount = parseUnits8(amount2, inputToken2.decimals).toString();
|
|
4528
4303
|
return ensoErc4626.getQuote({
|
|
4529
4304
|
account: quoteAccount2,
|
|
4530
4305
|
amount: rawAmount,
|
|
4531
4306
|
tokenIn: inputToken2,
|
|
4532
4307
|
underlyingToken: underlyingToken2,
|
|
4533
4308
|
tokenOut: tokenOut2,
|
|
4534
|
-
slippage: slippage2
|
|
4309
|
+
slippage: slippage2,
|
|
4310
|
+
proxyAggregatorsThroughVercel: proxyAggregatorsThroughVercel2
|
|
4535
4311
|
});
|
|
4536
4312
|
},
|
|
4537
4313
|
{
|
|
@@ -4553,13 +4329,13 @@ function useZapStakeBera({
|
|
|
4553
4329
|
data: {
|
|
4554
4330
|
...swrResponse.data,
|
|
4555
4331
|
priceImpactPercentage,
|
|
4556
|
-
isCrossChain:
|
|
4332
|
+
isCrossChain: swrResponse.data?.isCrossChain
|
|
4557
4333
|
}
|
|
4558
4334
|
};
|
|
4559
4335
|
}
|
|
4560
4336
|
|
|
4561
4337
|
// src/hooks/honey/useCappedGlobally.ts
|
|
4562
|
-
import { usePublicClient as
|
|
4338
|
+
import { usePublicClient as usePublicClient17 } from "@berachain/wagmi/hooks";
|
|
4563
4339
|
|
|
4564
4340
|
// src/hooks/honey/usePythLatestPrices.ts
|
|
4565
4341
|
function usePythLatestPrices({
|
|
@@ -4584,7 +4360,7 @@ function useCappedGlobally({
|
|
|
4584
4360
|
isMint,
|
|
4585
4361
|
isBasketModeEnabled: isBasketModeEnabled2
|
|
4586
4362
|
}, options) {
|
|
4587
|
-
const publicClient =
|
|
4363
|
+
const publicClient = usePublicClient17();
|
|
4588
4364
|
const { priceFeedMap, flags } = useHoneyConfig();
|
|
4589
4365
|
const { data: latestPrices } = usePythLatestPrices(
|
|
4590
4366
|
{
|
|
@@ -4633,14 +4409,14 @@ function useCappedGlobally({
|
|
|
4633
4409
|
}
|
|
4634
4410
|
|
|
4635
4411
|
// src/hooks/honey/useCappedRelatively.ts
|
|
4636
|
-
import { usePublicClient as
|
|
4412
|
+
import { usePublicClient as usePublicClient18 } from "@berachain/wagmi/hooks";
|
|
4637
4413
|
function useCappedRelatively({
|
|
4638
4414
|
asset,
|
|
4639
4415
|
amount,
|
|
4640
4416
|
isMint,
|
|
4641
4417
|
isBasketModeEnabled: isBasketModeEnabled2
|
|
4642
4418
|
}, options) {
|
|
4643
|
-
const publicClient =
|
|
4419
|
+
const publicClient = usePublicClient18();
|
|
4644
4420
|
const { collateralList, referenceCollateral } = useHoneyConfig();
|
|
4645
4421
|
const QUERY_KEY = asset && amount ? [
|
|
4646
4422
|
"useCappedRelatively",
|
|
@@ -4690,11 +4466,11 @@ function useCappedRelatively({
|
|
|
4690
4466
|
}
|
|
4691
4467
|
|
|
4692
4468
|
// src/hooks/honey/useCollateralWeights.ts
|
|
4693
|
-
import { usePublicClient as
|
|
4469
|
+
import { usePublicClient as usePublicClient19 } from "@berachain/wagmi/hooks";
|
|
4694
4470
|
function useCollateralWeights({
|
|
4695
4471
|
collateralList
|
|
4696
4472
|
}, options) {
|
|
4697
|
-
const publicClient =
|
|
4473
|
+
const publicClient = usePublicClient19();
|
|
4698
4474
|
const QUERY_KEY = publicClient && collateralList ? ["useCollateralWeights", collateralList] : void 0;
|
|
4699
4475
|
return useSWR(
|
|
4700
4476
|
QUERY_KEY,
|
|
@@ -4721,19 +4497,19 @@ function useHoney24hVolume() {
|
|
|
4721
4497
|
}
|
|
4722
4498
|
|
|
4723
4499
|
// src/hooks/honey/useHoneyAlerts.ts
|
|
4724
|
-
import { useMemo as
|
|
4500
|
+
import { useMemo as useMemo9 } from "react";
|
|
4725
4501
|
|
|
4726
4502
|
// src/hooks/honey/useHoneyBalances.ts
|
|
4727
4503
|
import {
|
|
4728
|
-
useBeraWallet as
|
|
4729
|
-
useConfig as
|
|
4730
|
-
usePublicClient as
|
|
4504
|
+
useBeraWallet as useBeraWallet14,
|
|
4505
|
+
useConfig as useConfig3,
|
|
4506
|
+
usePublicClient as usePublicClient20
|
|
4731
4507
|
} from "@berachain/wagmi/hooks";
|
|
4732
4508
|
function useHoneyBalances() {
|
|
4733
|
-
const publicClient =
|
|
4734
|
-
const { address: account } =
|
|
4509
|
+
const publicClient = usePublicClient20();
|
|
4510
|
+
const { address: account } = useBeraWallet14();
|
|
4735
4511
|
const { collateralList } = useHoneyConfig();
|
|
4736
|
-
const wagmiConfig =
|
|
4512
|
+
const wagmiConfig = useConfig3();
|
|
4737
4513
|
const QUERY_KEY = account && collateralList && publicClient ? ["useHoneyBalances", account, collateralList] : null;
|
|
4738
4514
|
return useSWR(
|
|
4739
4515
|
QUERY_KEY,
|
|
@@ -4761,9 +4537,9 @@ function useHoneyBalances() {
|
|
|
4761
4537
|
}
|
|
4762
4538
|
|
|
4763
4539
|
// src/hooks/honey/useHoneyVaultsBalance.ts
|
|
4764
|
-
import { usePublicClient as
|
|
4540
|
+
import { usePublicClient as usePublicClient21 } from "@berachain/wagmi/hooks";
|
|
4765
4541
|
function useHoneyVaultsBalance(options) {
|
|
4766
|
-
const publicClient =
|
|
4542
|
+
const publicClient = usePublicClient21();
|
|
4767
4543
|
const { collateralList } = useHoneyConfig();
|
|
4768
4544
|
const QUERY_KEY = collateralList && publicClient ? ["useHoneyVaultsBalance", collateralList] : null;
|
|
4769
4545
|
return useSWR(
|
|
@@ -4780,9 +4556,9 @@ function useHoneyVaultsBalance(options) {
|
|
|
4780
4556
|
}
|
|
4781
4557
|
|
|
4782
4558
|
// src/hooks/honey/useIsBadCollateralAsset.ts
|
|
4783
|
-
import { usePublicClient as
|
|
4559
|
+
import { usePublicClient as usePublicClient22 } from "@berachain/wagmi/hooks";
|
|
4784
4560
|
function useIsBadCollateralAsset({ collateral }, options) {
|
|
4785
|
-
const publicClient =
|
|
4561
|
+
const publicClient = usePublicClient22();
|
|
4786
4562
|
const { priceFeedMap, flags } = useHoneyConfig();
|
|
4787
4563
|
const { data: latestPrices } = usePythLatestPrices(
|
|
4788
4564
|
{
|
|
@@ -4947,7 +4723,7 @@ function useHoneyAlerts({
|
|
|
4947
4723
|
const redeemedVaultBalance = vaultsBalances?.find(
|
|
4948
4724
|
(vault) => vault.address.toLowerCase() === redeemedCollateral.toLowerCase()
|
|
4949
4725
|
);
|
|
4950
|
-
const [isLiquidityDepleted, isLowLiquidity] =
|
|
4726
|
+
const [isLiquidityDepleted, isLowLiquidity] = useMemo9(() => {
|
|
4951
4727
|
const isDepleted = getIsLiquidityLowerThan({
|
|
4952
4728
|
lowerThan: 1,
|
|
4953
4729
|
vaultsBalances,
|
|
@@ -4965,7 +4741,7 @@ function useHoneyAlerts({
|
|
|
4965
4741
|
const {
|
|
4966
4742
|
isMore: isRedeemMoreThanLiquidity,
|
|
4967
4743
|
isRedeemMoreThanLiquidityCollaterals
|
|
4968
|
-
} =
|
|
4744
|
+
} = useMemo9(() => {
|
|
4969
4745
|
return getRedeemMoreThanLiquidity({
|
|
4970
4746
|
vaultsBalances,
|
|
4971
4747
|
redeemedVaultBalance,
|
|
@@ -4973,7 +4749,7 @@ function useHoneyAlerts({
|
|
|
4973
4749
|
collateralList
|
|
4974
4750
|
});
|
|
4975
4751
|
}, [vaultsBalances, redeemedVaultBalance, state, collateralList]);
|
|
4976
|
-
const isExceedingBalance =
|
|
4752
|
+
const isExceedingBalance = useMemo9(
|
|
4977
4753
|
() => getExceedingBalance({
|
|
4978
4754
|
state,
|
|
4979
4755
|
honeyBalances
|
|
@@ -5008,9 +4784,9 @@ import { formatUnits as formatUnits10 } from "viem";
|
|
|
5008
4784
|
import { defaultChainId as defaultChainId10 } from "@berachain/config/internal";
|
|
5009
4785
|
|
|
5010
4786
|
// src/hooks/honey/useIsBasketModeEnabled.ts
|
|
5011
|
-
import { usePublicClient as
|
|
4787
|
+
import { usePublicClient as usePublicClient23 } from "@berachain/wagmi/hooks";
|
|
5012
4788
|
function useIsBasketModeEnabled({ state }, options) {
|
|
5013
|
-
const publicClient =
|
|
4789
|
+
const publicClient = usePublicClient23();
|
|
5014
4790
|
const { priceFeedMap, flags, collateralList } = useHoneyConfig();
|
|
5015
4791
|
const { data: latestPrices } = usePythLatestPrices(
|
|
5016
4792
|
{
|
|
@@ -5184,12 +4960,12 @@ function useHoneySwapState() {
|
|
|
5184
4960
|
}
|
|
5185
4961
|
|
|
5186
4962
|
// src/hooks/perps/usePythUpdateFee.ts
|
|
5187
|
-
import { usePublicClient as
|
|
4963
|
+
import { usePublicClient as usePublicClient24 } from "@berachain/wagmi/hooks";
|
|
5188
4964
|
function usePythUpdateFee({
|
|
5189
4965
|
pythPriceFeedCalldata,
|
|
5190
4966
|
tokenListLength
|
|
5191
4967
|
}, options) {
|
|
5192
|
-
const publicClient =
|
|
4968
|
+
const publicClient = usePublicClient24();
|
|
5193
4969
|
const QUERY_KEY = pythPriceFeedCalldata && pythPriceFeedCalldata.length > 0 ? ["usePythUpdateFee", pythPriceFeedCalldata] : null;
|
|
5194
4970
|
const { data = getPythDefaultUpdateFee(tokenListLength), isLoading } = useSWRImmutable(
|
|
5195
4971
|
QUERY_KEY,
|
|
@@ -5210,12 +4986,16 @@ function usePythUpdateFee({
|
|
|
5210
4986
|
}
|
|
5211
4987
|
|
|
5212
4988
|
// src/hooks/pol/useAutoclaimedIncentives.ts
|
|
5213
|
-
import { useBeraWallet as
|
|
4989
|
+
import { useBeraWallet as useBeraWallet15 } from "@berachain/wagmi/hooks";
|
|
5214
4990
|
function useAutoclaimedIncentives({
|
|
5215
4991
|
enabled
|
|
5216
4992
|
}) {
|
|
5217
|
-
const { address: account } =
|
|
5218
|
-
const
|
|
4993
|
+
const { address: account } = useBeraWallet15();
|
|
4994
|
+
const { config } = parseBaseArgs({});
|
|
4995
|
+
const QUERY_KEY = (
|
|
4996
|
+
// `bribeBoostApi` is null on chains where the endpoint is shut down.
|
|
4997
|
+
enabled && account && config.pol.bribeBoostApi ? ["useAutoclaimedIncentives", account] : null
|
|
4998
|
+
);
|
|
5219
4999
|
return useSWR(
|
|
5220
5000
|
QUERY_KEY,
|
|
5221
5001
|
async ([, account2]) => getAutoclaimedIncentives({ account: account2 }),
|
|
@@ -5228,12 +5008,16 @@ function useAutoclaimedIncentives({
|
|
|
5228
5008
|
}
|
|
5229
5009
|
|
|
5230
5010
|
// src/hooks/pol/useAutoclaimedIncentivesTxHash.ts
|
|
5231
|
-
import { useBeraWallet as
|
|
5011
|
+
import { useBeraWallet as useBeraWallet16 } from "@berachain/wagmi/hooks";
|
|
5232
5012
|
function useAutoclaimedIncentivesTxHash({
|
|
5233
5013
|
enabled
|
|
5234
5014
|
}) {
|
|
5235
|
-
const { address: account } =
|
|
5236
|
-
const
|
|
5015
|
+
const { address: account } = useBeraWallet16();
|
|
5016
|
+
const { config } = parseBaseArgs({});
|
|
5017
|
+
const QUERY_KEY = (
|
|
5018
|
+
// `bribeBoostApi` is null on chains where the endpoint is shut down.
|
|
5019
|
+
enabled && account && config.pol.bribeBoostApi ? ["useAutoclaimedIncentivesTxHash", account] : null
|
|
5020
|
+
);
|
|
5237
5021
|
return useSWR(
|
|
5238
5022
|
QUERY_KEY,
|
|
5239
5023
|
async ([, account2]) => getAutoclaimedIncentivesTxHash({ account: account2 }),
|
|
@@ -5251,9 +5035,9 @@ function useAutoclaimedIncentivesTxHash({
|
|
|
5251
5035
|
}
|
|
5252
5036
|
|
|
5253
5037
|
// src/hooks/pol/useBgtAprSimulation.ts
|
|
5254
|
-
import { useMemo as
|
|
5038
|
+
import { useMemo as useMemo10 } from "react";
|
|
5255
5039
|
function useBgtAprSimulation(args) {
|
|
5256
|
-
return
|
|
5040
|
+
return useMemo10(() => {
|
|
5257
5041
|
if (!args) {
|
|
5258
5042
|
return void 0;
|
|
5259
5043
|
}
|
|
@@ -5261,29 +5045,13 @@ function useBgtAprSimulation(args) {
|
|
|
5261
5045
|
}, [args]);
|
|
5262
5046
|
}
|
|
5263
5047
|
|
|
5264
|
-
// src/hooks/pol/useBgtIncentiveDistributorPaused.ts
|
|
5265
|
-
import { usePublicClient as usePublicClient26 } from "@berachain/wagmi/hooks";
|
|
5266
|
-
function useBgtIncentiveDistributorPaused(options) {
|
|
5267
|
-
const publicClient = usePublicClient26();
|
|
5268
|
-
const QUERY_KEY = publicClient ? ["useBgtIncentiveDistributorPaused", publicClient.chain?.id] : null;
|
|
5269
|
-
return swr_default(
|
|
5270
|
-
QUERY_KEY,
|
|
5271
|
-
async () => getBgtIncentiveDistributorPaused({ publicClient }).catch(() => false),
|
|
5272
|
-
{
|
|
5273
|
-
revalidateOnFocus: false,
|
|
5274
|
-
revalidateOnReconnect: false,
|
|
5275
|
-
...options
|
|
5276
|
-
}
|
|
5277
|
-
);
|
|
5278
|
-
}
|
|
5279
|
-
|
|
5280
5048
|
// src/hooks/pol/useBgtUnstakedBalance.ts
|
|
5281
5049
|
import { formatEther as formatEther5 } from "viem";
|
|
5282
5050
|
import { bgtAbi } from "@berachain/abis/pol/bgt";
|
|
5283
|
-
import { useBeraWallet as
|
|
5051
|
+
import { useBeraWallet as useBeraWallet17, usePublicClient as usePublicClient25 } from "@berachain/wagmi/hooks";
|
|
5284
5052
|
function useBgtUnstakedBalance(options) {
|
|
5285
|
-
const { address: account } =
|
|
5286
|
-
const publicClient =
|
|
5053
|
+
const { address: account } = useBeraWallet17();
|
|
5054
|
+
const publicClient = usePublicClient25();
|
|
5287
5055
|
const QUERY_KEY = account && publicClient ? ["useBgtUnstakedBalance", account] : null;
|
|
5288
5056
|
return useSWR(
|
|
5289
5057
|
QUERY_KEY,
|
|
@@ -5309,10 +5077,10 @@ function useBgtUnstakedBalance(options) {
|
|
|
5309
5077
|
|
|
5310
5078
|
// src/hooks/pol/useClaimableFees.ts
|
|
5311
5079
|
import { formatUnits as formatUnits11 } from "viem";
|
|
5312
|
-
import { useBeraWallet as
|
|
5080
|
+
import { useBeraWallet as useBeraWallet18, usePublicClient as usePublicClient26 } from "@berachain/wagmi/hooks";
|
|
5313
5081
|
function useClaimableFees() {
|
|
5314
|
-
const { address: account } =
|
|
5315
|
-
const publicClient =
|
|
5082
|
+
const { address: account } = useBeraWallet18();
|
|
5083
|
+
const publicClient = usePublicClient26();
|
|
5316
5084
|
const QUERY_KEY = account && publicClient ? ["useClaimableFees", account] : null;
|
|
5317
5085
|
return useSWR(
|
|
5318
5086
|
QUERY_KEY,
|
|
@@ -5341,7 +5109,7 @@ import {
|
|
|
5341
5109
|
} from "@berachain/graphql/pol/api";
|
|
5342
5110
|
|
|
5343
5111
|
// src/hooks/pol/useRewardVaults.ts
|
|
5344
|
-
import { usePublicClient as
|
|
5112
|
+
import { usePublicClient as usePublicClient27 } from "@berachain/wagmi/hooks";
|
|
5345
5113
|
function useRewardVaultsQueryKey(filter, onChainIncentives = false) {
|
|
5346
5114
|
return ["useRewardVaults", filter, onChainIncentives];
|
|
5347
5115
|
}
|
|
@@ -5350,7 +5118,7 @@ function useRewardVaults(args, options) {
|
|
|
5350
5118
|
args.filter,
|
|
5351
5119
|
args.onChainIncentives
|
|
5352
5120
|
);
|
|
5353
|
-
const publicClient =
|
|
5121
|
+
const publicClient = usePublicClient27();
|
|
5354
5122
|
return useSWR(
|
|
5355
5123
|
QUERY_KEY,
|
|
5356
5124
|
async ([, filter, onChainIncentives]) => {
|
|
@@ -5388,9 +5156,9 @@ function useHighestVaultsAPR(where = {}, { isEnabled = true } = {}) {
|
|
|
5388
5156
|
}
|
|
5389
5157
|
|
|
5390
5158
|
// src/hooks/pol/usePollGlobalData.ts
|
|
5391
|
-
import { usePublicClient as
|
|
5159
|
+
import { usePublicClient as usePublicClient28 } from "@berachain/wagmi/hooks";
|
|
5392
5160
|
function usePollGlobalData(options) {
|
|
5393
|
-
const publicClient =
|
|
5161
|
+
const publicClient = usePublicClient28();
|
|
5394
5162
|
return useSWR(
|
|
5395
5163
|
publicClient ? "usePollGlobalData" : null,
|
|
5396
5164
|
async () => {
|
|
@@ -5423,15 +5191,15 @@ function usePollMarkets(options) {
|
|
|
5423
5191
|
}
|
|
5424
5192
|
|
|
5425
5193
|
// src/hooks/pol/useQueuedBeraUnlock.ts
|
|
5426
|
-
import { isAddress as
|
|
5427
|
-
import { usePublicClient as
|
|
5194
|
+
import { isAddress as isAddress8 } from "viem";
|
|
5195
|
+
import { usePublicClient as usePublicClient29 } from "@berachain/wagmi/hooks";
|
|
5428
5196
|
function useQueuedBeraUnlock({
|
|
5429
5197
|
receiptTokenAddresses,
|
|
5430
5198
|
account,
|
|
5431
5199
|
version
|
|
5432
5200
|
}, options) {
|
|
5433
|
-
const publicClient =
|
|
5434
|
-
const QUERY_KEY = receiptTokenAddresses && account && publicClient &&
|
|
5201
|
+
const publicClient = usePublicClient29();
|
|
5202
|
+
const QUERY_KEY = receiptTokenAddresses && account && publicClient && isAddress8(account) && version ? [
|
|
5435
5203
|
"useQueuedBeraUnlock",
|
|
5436
5204
|
receiptTokenAddresses,
|
|
5437
5205
|
account,
|
|
@@ -5461,12 +5229,12 @@ function useQueuedBeraUnlock({
|
|
|
5461
5229
|
|
|
5462
5230
|
// src/hooks/pol/useRewardTokenToBeraRate.ts
|
|
5463
5231
|
import { defaultChainId as defaultChainId11 } from "@berachain/config/internal";
|
|
5464
|
-
import { usePublicClient as
|
|
5232
|
+
import { usePublicClient as usePublicClient30 } from "@berachain/wagmi/hooks";
|
|
5465
5233
|
function useRewardTokenToBeraRate({
|
|
5466
5234
|
address
|
|
5467
5235
|
}, opt) {
|
|
5468
|
-
const
|
|
5469
|
-
const
|
|
5236
|
+
const publicClient = usePublicClient30({ chainId: defaultChainId11 });
|
|
5237
|
+
const QUERY_KEY = address && publicClient ? ["useRewardTokenToBeraRate", address] : null;
|
|
5470
5238
|
return useSWR(
|
|
5471
5239
|
QUERY_KEY,
|
|
5472
5240
|
async ([_, address2]) => {
|
|
@@ -5484,9 +5252,9 @@ function useRewardTokenToBeraRate({
|
|
|
5484
5252
|
}
|
|
5485
5253
|
|
|
5486
5254
|
// src/hooks/pol/useOnChainRewardVault.ts
|
|
5487
|
-
import { erc20Abi as erc20Abi4, formatUnits as formatUnits13, isAddress as
|
|
5255
|
+
import { erc20Abi as erc20Abi4, formatUnits as formatUnits13, isAddress as isAddress9 } from "viem";
|
|
5488
5256
|
import { beraChefAbi } from "@berachain/abis/pol/rewards/beraChef";
|
|
5489
|
-
import { usePublicClient as
|
|
5257
|
+
import { usePublicClient as usePublicClient31 } from "@berachain/wagmi/hooks";
|
|
5490
5258
|
|
|
5491
5259
|
// src/actions/pol/getStakingTokenInformation.ts
|
|
5492
5260
|
import { erc20Abi as erc20Abi3, formatUnits as formatUnits12 } from "viem";
|
|
@@ -5532,12 +5300,12 @@ async function getStakingTokenInformation({
|
|
|
5532
5300
|
|
|
5533
5301
|
// src/hooks/pol/useOnChainRewardVault.ts
|
|
5534
5302
|
function useOnChainRewardVaultQueryKey(address) {
|
|
5535
|
-
return address &&
|
|
5303
|
+
return address && isAddress9(address) ? ["onChainRewardVault", address.toLowerCase()] : null;
|
|
5536
5304
|
}
|
|
5537
5305
|
function useOnChainRewardVault({
|
|
5538
5306
|
address
|
|
5539
5307
|
}, opt) {
|
|
5540
|
-
const publicClient =
|
|
5308
|
+
const publicClient = usePublicClient31();
|
|
5541
5309
|
const QUERY_KEY = useOnChainRewardVaultQueryKey(address);
|
|
5542
5310
|
return useSWR(
|
|
5543
5311
|
publicClient ? QUERY_KEY : null,
|
|
@@ -5649,12 +5417,12 @@ function useRewardVault(id, options) {
|
|
|
5649
5417
|
}
|
|
5650
5418
|
|
|
5651
5419
|
// src/hooks/pol/useRewardVaultIncentives.ts
|
|
5652
|
-
import { usePublicClient as
|
|
5420
|
+
import { usePublicClient as usePublicClient32 } from "@berachain/wagmi/hooks";
|
|
5653
5421
|
function useRewardVaultIncentives({
|
|
5654
5422
|
address,
|
|
5655
5423
|
stakingToken
|
|
5656
5424
|
}) {
|
|
5657
|
-
const publicClient =
|
|
5425
|
+
const publicClient = usePublicClient32();
|
|
5658
5426
|
const QUERY_KEY = publicClient && address && stakingToken ? ["useRewardVaultIncentives", address, stakingToken] : null;
|
|
5659
5427
|
return useSWR(QUERY_KEY, async ([, address2, stakingToken2]) => {
|
|
5660
5428
|
assertPublicClient(publicClient);
|
|
@@ -5667,9 +5435,9 @@ function useRewardVaultIncentives({
|
|
|
5667
5435
|
}
|
|
5668
5436
|
|
|
5669
5437
|
// src/hooks/pol/useRewardVaultRewards.ts
|
|
5670
|
-
import { usePublicClient as
|
|
5438
|
+
import { usePublicClient as usePublicClient33 } from "@berachain/wagmi/hooks";
|
|
5671
5439
|
function useRewardVaultRewards(address, options) {
|
|
5672
|
-
const publicClient =
|
|
5440
|
+
const publicClient = usePublicClient33();
|
|
5673
5441
|
const QUERY_KEY = publicClient && address ? ["useRewardVaultRewards", address] : null;
|
|
5674
5442
|
return useSWR(
|
|
5675
5443
|
QUERY_KEY,
|
|
@@ -5705,11 +5473,11 @@ function dailyResolution(data) {
|
|
|
5705
5473
|
return dailyData;
|
|
5706
5474
|
}
|
|
5707
5475
|
|
|
5708
|
-
// src/hooks/pol/
|
|
5709
|
-
function
|
|
5476
|
+
// src/hooks/pol/useStakedAPY.ts
|
|
5477
|
+
function useStakedAPY({
|
|
5710
5478
|
range
|
|
5711
5479
|
}) {
|
|
5712
|
-
const QUERY_KEY = range ? ["
|
|
5480
|
+
const QUERY_KEY = range ? ["useStakedAPY", range] : null;
|
|
5713
5481
|
return useSWR(QUERY_KEY, async ([, range2]) => {
|
|
5714
5482
|
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
5715
5483
|
range: range2
|
|
@@ -5719,18 +5487,67 @@ function useStakedAPR({
|
|
|
5719
5487
|
);
|
|
5720
5488
|
return sortedStakedBeraSnapshots.map((item) => ({
|
|
5721
5489
|
timestamp: item.timestamp,
|
|
5722
|
-
|
|
5490
|
+
apy: item.apy
|
|
5723
5491
|
}));
|
|
5724
5492
|
});
|
|
5725
5493
|
}
|
|
5726
5494
|
|
|
5727
5495
|
// src/hooks/pol/useStakedData.ts
|
|
5728
5496
|
import { useMemo as useMemo12 } from "react";
|
|
5729
|
-
import { useBeraWallet as
|
|
5497
|
+
import { useBeraWallet as useBeraWallet20, usePublicClient as usePublicClient35 } from "@berachain/wagmi/hooks";
|
|
5498
|
+
|
|
5499
|
+
// src/hooks/tokens/usePollWalletBalances.ts
|
|
5500
|
+
import { useMemo as useMemo11 } from "react";
|
|
5501
|
+
import {
|
|
5502
|
+
useBeraWallet as useBeraWallet19,
|
|
5503
|
+
useConfig as useConfig4,
|
|
5504
|
+
usePublicClient as usePublicClient34
|
|
5505
|
+
} from "@berachain/wagmi/hooks";
|
|
5506
|
+
function usePollWalletBalances(args, options) {
|
|
5507
|
+
const publicClient = usePublicClient34();
|
|
5508
|
+
const wagmiConfig = useConfig4();
|
|
5509
|
+
const { address: connectedAccount } = useBeraWallet19();
|
|
5510
|
+
const { tokenList, refresh } = useTokens();
|
|
5511
|
+
const wallet = args?.walletAddress ?? connectedAccount;
|
|
5512
|
+
const tokens = useMemo11(() => {
|
|
5513
|
+
return new Map(
|
|
5514
|
+
(args?.tokens ?? tokenList)?.map((t) => [t.address.toLowerCase(), t]) ?? []
|
|
5515
|
+
);
|
|
5516
|
+
}, [tokenList, args?.tokens]);
|
|
5517
|
+
const QUERY_KEY = publicClient && tokenList !== void 0 && wallet ? [
|
|
5518
|
+
"usePollWalletBalances",
|
|
5519
|
+
wallet,
|
|
5520
|
+
// TODO: adding the whole list to the query is very inefficient, we should only add the tokens addresses
|
|
5521
|
+
Array.from(tokens.values())
|
|
5522
|
+
] : null;
|
|
5523
|
+
const swrResponse = useSWR(
|
|
5524
|
+
QUERY_KEY,
|
|
5525
|
+
async ([, wallet2, tokenList2]) => {
|
|
5526
|
+
return getWalletBalances({
|
|
5527
|
+
account: wallet2,
|
|
5528
|
+
tokenList: tokenList2,
|
|
5529
|
+
wagmiConfig
|
|
5530
|
+
});
|
|
5531
|
+
},
|
|
5532
|
+
{
|
|
5533
|
+
refreshInterval: 1e5 /* NORMAL */,
|
|
5534
|
+
...options
|
|
5535
|
+
}
|
|
5536
|
+
);
|
|
5537
|
+
return {
|
|
5538
|
+
...swrResponse,
|
|
5539
|
+
refresh: () => {
|
|
5540
|
+
swrResponse?.refresh();
|
|
5541
|
+
refresh();
|
|
5542
|
+
}
|
|
5543
|
+
};
|
|
5544
|
+
}
|
|
5545
|
+
|
|
5546
|
+
// src/hooks/pol/useStakedData.ts
|
|
5730
5547
|
function useStakedData(stakingConfigs) {
|
|
5731
5548
|
const window2 = useBeraFlag("swberaAprWindow");
|
|
5732
|
-
const publicClient =
|
|
5733
|
-
const { address: account } =
|
|
5549
|
+
const publicClient = usePublicClient35();
|
|
5550
|
+
const { address: account } = useBeraWallet20();
|
|
5734
5551
|
const receiptTokens = useMemo12(
|
|
5735
5552
|
() => stakingConfigs.map((config) => config.receiptToken),
|
|
5736
5553
|
[stakingConfigs]
|
|
@@ -5739,11 +5556,10 @@ function useStakedData(stakingConfigs) {
|
|
|
5739
5556
|
() => stakingConfigs.map((config) => config.inputTokens[0]),
|
|
5740
5557
|
[stakingConfigs]
|
|
5741
5558
|
);
|
|
5742
|
-
const
|
|
5743
|
-
const { data:
|
|
5744
|
-
|
|
5745
|
-
async ([, window3]) =>
|
|
5746
|
-
{ refreshInterval: 1e5 /* NORMAL */ }
|
|
5559
|
+
const apyKey = window2 ? ["useStakedData:apy", window2] : null;
|
|
5560
|
+
const { data: apy } = useSWRImmutable(
|
|
5561
|
+
apyKey,
|
|
5562
|
+
async ([, window3]) => getStakedBeraAPY({ window: window3 })
|
|
5747
5563
|
);
|
|
5748
5564
|
const {
|
|
5749
5565
|
data: walletBalances,
|
|
@@ -5811,7 +5627,7 @@ function useStakedData(stakingConfigs) {
|
|
|
5811
5627
|
const stakedAmountUsd = inputTokenPrice === void 0 ? void 0 : stakedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
5812
5628
|
return {
|
|
5813
5629
|
token: inputToken,
|
|
5814
|
-
|
|
5630
|
+
apy,
|
|
5815
5631
|
stakedAmount: stakedAmount.toNumber(),
|
|
5816
5632
|
stakedAmountUsd,
|
|
5817
5633
|
earnedAmount: 0,
|
|
@@ -5823,7 +5639,7 @@ function useStakedData(stakingConfigs) {
|
|
|
5823
5639
|
walletBalances,
|
|
5824
5640
|
exchangeRates,
|
|
5825
5641
|
stakingConfigs,
|
|
5826
|
-
|
|
5642
|
+
apy,
|
|
5827
5643
|
getTokenPrice,
|
|
5828
5644
|
earningsSettled
|
|
5829
5645
|
]);
|
|
@@ -5847,15 +5663,17 @@ function useStakedData(stakingConfigs) {
|
|
|
5847
5663
|
const earnedAmountUsd = inputTokenPrice === void 0 ? void 0 : earnedAmount.multipliedBy(inputTokenPrice).toNumber();
|
|
5848
5664
|
return {
|
|
5849
5665
|
token: inputToken,
|
|
5850
|
-
|
|
5666
|
+
apy,
|
|
5851
5667
|
stakedAmount: stakedAmount.toNumber(),
|
|
5852
5668
|
earnedAmount: earnedAmount.toNumber(),
|
|
5853
5669
|
stakedAmountUsd,
|
|
5854
5670
|
earnedAmountUsd
|
|
5855
5671
|
};
|
|
5856
5672
|
});
|
|
5857
|
-
}, [positionsRaw, walletBalances, stakingConfigs,
|
|
5673
|
+
}, [positionsRaw, walletBalances, stakingConfigs, apy, getTokenPrice]);
|
|
5858
5674
|
return {
|
|
5675
|
+
/** Overall staked-BERA APY. Wallet-independent. */
|
|
5676
|
+
apy,
|
|
5859
5677
|
/** Fast path: staked amounts + USD values (no earnings) */
|
|
5860
5678
|
balances,
|
|
5861
5679
|
/** Slow path: full enriched positions with earnings */
|
|
@@ -5868,7 +5686,7 @@ function useStakedData(stakingConfigs) {
|
|
|
5868
5686
|
/**
|
|
5869
5687
|
* Hard error: the RPC fast-path could not produce staked balances (wallet
|
|
5870
5688
|
* balances or exchange-rate reads failed). Price and earnings backend
|
|
5871
|
-
* failures are intentionally excluded — those degrade gracefully (USD/
|
|
5689
|
+
* failures are intentionally excluded — those degrade gracefully (USD/APY
|
|
5872
5690
|
* render as "—", earnings stop loading) so RPC-derived amounts still show.
|
|
5873
5691
|
*/
|
|
5874
5692
|
error: walletBalancesError ?? exchangeRatesError,
|
|
@@ -5923,22 +5741,19 @@ function useStakedSnapshots({
|
|
|
5923
5741
|
}
|
|
5924
5742
|
|
|
5925
5743
|
// src/hooks/pol/useStakingVaultsMetadata.ts
|
|
5926
|
-
import { usePublicClient as
|
|
5744
|
+
import { usePublicClient as usePublicClient36 } from "@berachain/wagmi/hooks";
|
|
5927
5745
|
function useStakingVaultsMetadata(vaults = []) {
|
|
5928
|
-
const publicClient =
|
|
5929
|
-
const
|
|
5930
|
-
const QUERY_KEY = vaults.length > 0 && publicClient && blockTime ? ["useStakingVaultMetadata", vaults, publicClient, blockTime] : null;
|
|
5746
|
+
const publicClient = usePublicClient36();
|
|
5747
|
+
const QUERY_KEY = vaults.length > 0 && publicClient ? ["useStakingVaultMetadata", vaults] : null;
|
|
5931
5748
|
return useSWR(
|
|
5932
5749
|
QUERY_KEY,
|
|
5933
|
-
async ([, vaults2
|
|
5934
|
-
assertPublicClient(
|
|
5750
|
+
async ([, vaults2]) => {
|
|
5751
|
+
assertPublicClient(publicClient);
|
|
5935
5752
|
return Promise.all(
|
|
5936
5753
|
vaults2.map(
|
|
5937
5754
|
(vault) => getSWBeraVaultMetadata({
|
|
5938
5755
|
address: vault.address,
|
|
5939
|
-
|
|
5940
|
-
publicClient: publicClient2,
|
|
5941
|
-
blockTime: blockTime2
|
|
5756
|
+
publicClient
|
|
5942
5757
|
})
|
|
5943
5758
|
)
|
|
5944
5759
|
);
|
|
@@ -5948,11 +5763,11 @@ function useStakingVaultsMetadata(vaults = []) {
|
|
|
5948
5763
|
}
|
|
5949
5764
|
|
|
5950
5765
|
// src/hooks/pol/useTotalStakedAmount.ts
|
|
5951
|
-
import { usePublicClient as
|
|
5766
|
+
import { usePublicClient as usePublicClient37 } from "@berachain/wagmi/hooks";
|
|
5952
5767
|
function useTotalStakedAmount({
|
|
5953
5768
|
vaultAddresses
|
|
5954
5769
|
}) {
|
|
5955
|
-
const publicClient =
|
|
5770
|
+
const publicClient = usePublicClient37();
|
|
5956
5771
|
return useSWR(
|
|
5957
5772
|
vaultAddresses && publicClient ? ["useTotalStakedAmount", vaultAddresses] : null,
|
|
5958
5773
|
([, vaultAddresses2]) => {
|
|
@@ -5962,10 +5777,10 @@ function useTotalStakedAmount({
|
|
|
5962
5777
|
}
|
|
5963
5778
|
|
|
5964
5779
|
// src/hooks/pol/useUserVaultInfo.ts
|
|
5965
|
-
import { useBeraWallet as
|
|
5780
|
+
import { useBeraWallet as useBeraWallet21, usePublicClient as usePublicClient38 } from "@berachain/wagmi/hooks";
|
|
5966
5781
|
function useUserVaultInfo(args, options) {
|
|
5967
|
-
const { address: account } =
|
|
5968
|
-
const publicClient =
|
|
5782
|
+
const { address: account } = useBeraWallet21();
|
|
5783
|
+
const publicClient = usePublicClient38();
|
|
5969
5784
|
const QUERY_KEY = account && publicClient && args.vaultAddress ? ["useUserVaultInfo", account, args.vaultAddress] : null;
|
|
5970
5785
|
return useSWR(
|
|
5971
5786
|
QUERY_KEY,
|
|
@@ -5985,10 +5800,10 @@ function useUserVaultInfo(args, options) {
|
|
|
5985
5800
|
}
|
|
5986
5801
|
|
|
5987
5802
|
// src/hooks/pol/useUserVaults.ts
|
|
5988
|
-
import { useBeraWallet as
|
|
5803
|
+
import { useBeraWallet as useBeraWallet22, usePublicClient as usePublicClient39 } from "@berachain/wagmi/hooks";
|
|
5989
5804
|
function useUserVaults(options) {
|
|
5990
|
-
const { address: account } =
|
|
5991
|
-
const publicClient =
|
|
5805
|
+
const { address: account } = useBeraWallet22();
|
|
5806
|
+
const publicClient = usePublicClient39();
|
|
5992
5807
|
const QUERY_KEY = account && publicClient ? ["useUserVaults", account] : null;
|
|
5993
5808
|
return useSWR(
|
|
5994
5809
|
QUERY_KEY,
|
|
@@ -6008,9 +5823,9 @@ function useUserVaults(options) {
|
|
|
6008
5823
|
}
|
|
6009
5824
|
|
|
6010
5825
|
// src/hooks/pol/useVaultAddress.ts
|
|
6011
|
-
import { usePublicClient as
|
|
5826
|
+
import { usePublicClient as usePublicClient40 } from "@berachain/wagmi/hooks";
|
|
6012
5827
|
function useVaultAddress(vaultAddress) {
|
|
6013
|
-
const publicClient =
|
|
5828
|
+
const publicClient = usePublicClient40();
|
|
6014
5829
|
const QUERY_KEY = vaultAddress && publicClient ? ["useVaultAddress", vaultAddress] : null;
|
|
6015
5830
|
return useSWR(QUERY_KEY, async ([, vaultAddress2]) => {
|
|
6016
5831
|
assertPublicClient(publicClient);
|
|
@@ -6078,17 +5893,17 @@ function useBeraCurrentPrice(opts) {
|
|
|
6078
5893
|
}
|
|
6079
5894
|
|
|
6080
5895
|
// src/hooks/tokens/useStakingTokenInformation.ts
|
|
6081
|
-
import { isAddress as
|
|
6082
|
-
import { usePublicClient as
|
|
5896
|
+
import { isAddress as isAddress10, zeroAddress as zeroAddress20 } from "viem";
|
|
5897
|
+
import { usePublicClient as usePublicClient41 } from "@berachain/wagmi/hooks";
|
|
6083
5898
|
function useStakingTokenInformation(args, options) {
|
|
6084
|
-
const publicClient =
|
|
6085
|
-
const QUERY_KEY = args?.address && publicClient &&
|
|
5899
|
+
const publicClient = usePublicClient41();
|
|
5900
|
+
const QUERY_KEY = args?.address && publicClient && isAddress10(args.address) ? ["useStakingTokenInformation", args.address] : null;
|
|
6086
5901
|
return useSWRImmutable(
|
|
6087
5902
|
QUERY_KEY,
|
|
6088
5903
|
async ([_, address]) => {
|
|
6089
5904
|
if (isToken(address, "BERA")) {
|
|
6090
5905
|
return {
|
|
6091
|
-
address:
|
|
5906
|
+
address: zeroAddress20,
|
|
6092
5907
|
decimals: beraToken.decimals,
|
|
6093
5908
|
name: beraToken.name,
|
|
6094
5909
|
symbol: beraToken.symbol
|
|
@@ -6105,9 +5920,9 @@ function useStakingTokenInformation(args, options) {
|
|
|
6105
5920
|
|
|
6106
5921
|
// src/hooks/tokens/useTotalSupply.ts
|
|
6107
5922
|
import { erc20Abi as erc20Abi5 } from "viem";
|
|
6108
|
-
import { usePublicClient as
|
|
5923
|
+
import { usePublicClient as usePublicClient42 } from "@berachain/wagmi/hooks";
|
|
6109
5924
|
function useTotalSupply({ address }) {
|
|
6110
|
-
const publicClient =
|
|
5925
|
+
const publicClient = usePublicClient42();
|
|
6111
5926
|
return useSWR(
|
|
6112
5927
|
address && publicClient ? ["useTotalSupply", address] : null,
|
|
6113
5928
|
([, address2]) => {
|
|
@@ -6123,9 +5938,9 @@ function useTotalSupply({ address }) {
|
|
|
6123
5938
|
}
|
|
6124
5939
|
|
|
6125
5940
|
// src/hooks/useBlockToTimestamp.ts
|
|
6126
|
-
import { useBlockNumber, usePublicClient as
|
|
5941
|
+
import { useBlockNumber, usePublicClient as usePublicClient43 } from "@berachain/wagmi/hooks";
|
|
6127
5942
|
function useBlockToTimestamp(inputBlock) {
|
|
6128
|
-
const publicClient =
|
|
5943
|
+
const publicClient = usePublicClient43();
|
|
6129
5944
|
const { config } = parseBaseArgs({ chainId: publicClient?.chain.id });
|
|
6130
5945
|
const { data: currentBlock, isLoading } = useBlockNumber({
|
|
6131
5946
|
cacheTime: seconds(config.averageBlockTime)
|
|
@@ -6154,7 +5969,7 @@ function useBlockToTimestamp(inputBlock) {
|
|
|
6154
5969
|
|
|
6155
5970
|
// src/hooks/useContractWrite/useBeraContractWrite.ts
|
|
6156
5971
|
import { useCallback as useCallback2, useReducer as useReducer2 } from "react";
|
|
6157
|
-
import { useBeraWagmi as useBeraWagmi3, useConfig as
|
|
5972
|
+
import { useBeraWagmi as useBeraWagmi3, useConfig as useConfig5 } from "@berachain/wagmi/hooks";
|
|
6158
5973
|
|
|
6159
5974
|
// src/hooks/useContractWrite/stateReducer.ts
|
|
6160
5975
|
var initialState = {
|
|
@@ -6205,7 +6020,7 @@ function useBeraContractWrite({
|
|
|
6205
6020
|
} = {}) {
|
|
6206
6021
|
const [state, dispatch] = useReducer2(reducer2, initialState);
|
|
6207
6022
|
const { account, onSmartAccountRejection } = useBeraWagmi3();
|
|
6208
|
-
const wagmiConfig =
|
|
6023
|
+
const wagmiConfig = useConfig5();
|
|
6209
6024
|
const txConfirmationTimeout = account?.wallet?.isContract ? 6e4 * 10 : 12e4;
|
|
6210
6025
|
const reset = useCallback2(() => {
|
|
6211
6026
|
dispatch({ type: "confirm_reset" /* RESET */ });
|
|
@@ -6280,7 +6095,7 @@ function useBeraContractWrite({
|
|
|
6280
6095
|
}
|
|
6281
6096
|
|
|
6282
6097
|
// src/hooks/useGetVerifiedAbi.ts
|
|
6283
|
-
import { isAddress as
|
|
6098
|
+
import { isAddress as isAddress11, zeroAddress as zeroAddress21 } from "viem";
|
|
6284
6099
|
import { chainId } from "@berachain/config/internal";
|
|
6285
6100
|
async function fetchVerifiedAbi(address) {
|
|
6286
6101
|
const data = await beraFetchJson({
|
|
@@ -6295,8 +6110,8 @@ async function fetchVerifiedAbi(address) {
|
|
|
6295
6110
|
}
|
|
6296
6111
|
function useGetVerifiedAbi(address) {
|
|
6297
6112
|
return useSWRImmutable(
|
|
6298
|
-
address &&
|
|
6299
|
-
address !==
|
|
6113
|
+
address && isAddress11(address) && // Address zero can't be a contract for sure
|
|
6114
|
+
address !== zeroAddress21 ? ["useGetVerifiedAbi", address] : null,
|
|
6300
6115
|
() => address ? fetchVerifiedAbi(address) : Promise.resolve(""),
|
|
6301
6116
|
{}
|
|
6302
6117
|
);
|
|
@@ -6405,7 +6220,7 @@ function useApiValidator(id, options) {
|
|
|
6405
6220
|
}
|
|
6406
6221
|
|
|
6407
6222
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
6408
|
-
import { usePublicClient as
|
|
6223
|
+
import { usePublicClient as usePublicClient44 } from "@berachain/wagmi/hooks";
|
|
6409
6224
|
|
|
6410
6225
|
// src/actions/validators/getBaselineRewardAllocation.ts
|
|
6411
6226
|
import { rewardAllocatorFactoryAbi as rewardAllocationFactoryAbi } from "@berachain/abis/pol/rewards/rewardAllocatorFactory";
|
|
@@ -6427,7 +6242,7 @@ async function getBaselineRewardAllocation({
|
|
|
6427
6242
|
|
|
6428
6243
|
// src/hooks/validators/useBaselineRewardAllocation.ts
|
|
6429
6244
|
function useBaselineRewardAllocation() {
|
|
6430
|
-
const publicClient =
|
|
6245
|
+
const publicClient = usePublicClient44();
|
|
6431
6246
|
return useSWR(publicClient ? ["baselineRewardAllocation"] : null, () => {
|
|
6432
6247
|
assertPublicClient(publicClient);
|
|
6433
6248
|
return getBaselineRewardAllocation({
|
|
@@ -6438,10 +6253,10 @@ function useBaselineRewardAllocation() {
|
|
|
6438
6253
|
|
|
6439
6254
|
// src/hooks/validators/useManagedValidatorRole.ts
|
|
6440
6255
|
import { useMemo as useMemo13 } from "react";
|
|
6441
|
-
import { useBeraWallet as
|
|
6256
|
+
import { useBeraWallet as useBeraWallet23, usePublicClient as usePublicClient45 } from "@berachain/wagmi/hooks";
|
|
6442
6257
|
|
|
6443
6258
|
// src/actions/validators/getValidatorRewardAllocatorAddress.ts
|
|
6444
|
-
import { zeroAddress as
|
|
6259
|
+
import { zeroAddress as zeroAddress22 } from "viem";
|
|
6445
6260
|
import { beraChefAbi as beraChefAbi2 } from "@berachain/abis/pol/rewards/beraChef";
|
|
6446
6261
|
async function getValidatorRewardAllocatorAddress({
|
|
6447
6262
|
client,
|
|
@@ -6456,7 +6271,7 @@ async function getValidatorRewardAllocatorAddress({
|
|
|
6456
6271
|
functionName: "valRewardAllocator",
|
|
6457
6272
|
args: [pubKey]
|
|
6458
6273
|
});
|
|
6459
|
-
if (result ===
|
|
6274
|
+
if (result === zeroAddress22) {
|
|
6460
6275
|
return null;
|
|
6461
6276
|
}
|
|
6462
6277
|
return result;
|
|
@@ -6485,13 +6300,13 @@ function useManagedValidatorRole({
|
|
|
6485
6300
|
pubKey,
|
|
6486
6301
|
account: accountAddress
|
|
6487
6302
|
}, options) {
|
|
6488
|
-
const publicClient =
|
|
6303
|
+
const publicClient = usePublicClient45();
|
|
6489
6304
|
const mockValidatorOperator = useBeraFlag("mockValidatorOperator");
|
|
6490
6305
|
const mockValidatorRewardAllocator = useBeraFlag(
|
|
6491
6306
|
"mockValidatorRewardAllocator"
|
|
6492
6307
|
);
|
|
6493
6308
|
const QUERY_KEY = publicClient && pubKey ? ["useManagedValidatorRole", pubKey] : null;
|
|
6494
|
-
const { address: connectedAccount } =
|
|
6309
|
+
const { address: connectedAccount } = useBeraWallet23();
|
|
6495
6310
|
const account = accountAddress ?? connectedAccount;
|
|
6496
6311
|
const swrResponse = useSWR(
|
|
6497
6312
|
QUERY_KEY,
|
|
@@ -6533,12 +6348,12 @@ function useManagedValidatorRole({
|
|
|
6533
6348
|
}
|
|
6534
6349
|
|
|
6535
6350
|
// src/hooks/validators/useStakingPoolBatch.ts
|
|
6536
|
-
import { usePublicClient as
|
|
6351
|
+
import { usePublicClient as usePublicClient46 } from "@berachain/wagmi/hooks";
|
|
6537
6352
|
function useStakingPoolBatch({
|
|
6538
6353
|
valPubKey,
|
|
6539
6354
|
options
|
|
6540
6355
|
}) {
|
|
6541
|
-
const publicClient =
|
|
6356
|
+
const publicClient = usePublicClient46();
|
|
6542
6357
|
const QUERY_KEY = publicClient && valPubKey ? ["useStakingPoolBatch", valPubKey] : null;
|
|
6543
6358
|
return useSWR(
|
|
6544
6359
|
QUERY_KEY,
|
|
@@ -6557,16 +6372,29 @@ function useStakingPoolBatch({
|
|
|
6557
6372
|
}
|
|
6558
6373
|
|
|
6559
6374
|
// src/hooks/validators/useUserActiveValidators.ts
|
|
6560
|
-
import {
|
|
6375
|
+
import { useMemo as useMemo14 } from "react";
|
|
6376
|
+
import { useBeraWallet as useBeraWallet24, usePublicClient as usePublicClient47 } from "@berachain/wagmi/hooks";
|
|
6561
6377
|
function useUserActiveValidators(options) {
|
|
6562
|
-
const { address: account } =
|
|
6563
|
-
const publicClient =
|
|
6564
|
-
const
|
|
6565
|
-
|
|
6566
|
-
QUERY_KEY,
|
|
6378
|
+
const { address: account } = useBeraWallet24();
|
|
6379
|
+
const publicClient = usePublicClient47();
|
|
6380
|
+
const apiSwr = useSWR(
|
|
6381
|
+
account ? ["useUserActiveValidatorsApi", account] : null,
|
|
6567
6382
|
async ([, account2]) => {
|
|
6568
|
-
return await
|
|
6383
|
+
return await getUserActiveValidatorsApi({ account: account2 });
|
|
6384
|
+
},
|
|
6385
|
+
{
|
|
6386
|
+
...options,
|
|
6387
|
+
refreshInterval: options?.refreshInterval ?? 18e4 /* SLOW */,
|
|
6388
|
+
keepPreviousData: true
|
|
6389
|
+
}
|
|
6390
|
+
);
|
|
6391
|
+
const validators = apiSwr.data;
|
|
6392
|
+
const onChainSwr = useSWR(
|
|
6393
|
+
publicClient && account && validators ? ["useUserActiveValidatorsOnChain", account, validators] : null,
|
|
6394
|
+
async ([, account2, validators2]) => {
|
|
6395
|
+
return await getUserActiveValidatorsOnChain({
|
|
6569
6396
|
account: account2,
|
|
6397
|
+
validators: validators2,
|
|
6570
6398
|
publicClient
|
|
6571
6399
|
});
|
|
6572
6400
|
},
|
|
@@ -6576,16 +6404,35 @@ function useUserActiveValidators(options) {
|
|
|
6576
6404
|
keepPreviousData: true
|
|
6577
6405
|
}
|
|
6578
6406
|
);
|
|
6407
|
+
const onChainBoosts = onChainSwr.data;
|
|
6408
|
+
const data = useMemo14(() => {
|
|
6409
|
+
if (!validators || !onChainBoosts) return void 0;
|
|
6410
|
+
return mergeUserActiveValidators({ validators, onChainBoosts });
|
|
6411
|
+
}, [validators, onChainBoosts]);
|
|
6412
|
+
return {
|
|
6413
|
+
...apiSwr,
|
|
6414
|
+
data,
|
|
6415
|
+
isLoading: apiSwr.isLoading || onChainSwr.isLoading,
|
|
6416
|
+
isValidating: apiSwr.isValidating || onChainSwr.isValidating,
|
|
6417
|
+
error: apiSwr.error ?? onChainSwr.error,
|
|
6418
|
+
refresh: () => {
|
|
6419
|
+
apiSwr.refresh();
|
|
6420
|
+
onChainSwr.refresh();
|
|
6421
|
+
},
|
|
6422
|
+
refreshOnChain: () => {
|
|
6423
|
+
onChainSwr.refresh();
|
|
6424
|
+
}
|
|
6425
|
+
};
|
|
6579
6426
|
}
|
|
6580
6427
|
|
|
6581
6428
|
// src/hooks/validators/useUserBoostsOnValidator.ts
|
|
6582
|
-
import { useBeraWallet as
|
|
6429
|
+
import { useBeraWallet as useBeraWallet25, usePublicClient as usePublicClient48 } from "@berachain/wagmi/hooks";
|
|
6583
6430
|
function useUserBoostsOnValidator({
|
|
6584
6431
|
pubkey,
|
|
6585
6432
|
...args
|
|
6586
6433
|
}) {
|
|
6587
|
-
const { address: connectedAccount } =
|
|
6588
|
-
const publicClient =
|
|
6434
|
+
const { address: connectedAccount } = useBeraWallet25();
|
|
6435
|
+
const publicClient = usePublicClient48();
|
|
6589
6436
|
const account = args.account ?? connectedAccount;
|
|
6590
6437
|
const QUERY_KEY = account && pubkey ? ["useUserBoostsOnValidator", pubkey, account] : null;
|
|
6591
6438
|
return useSWR(
|
|
@@ -6603,128 +6450,6 @@ function useUserBoostsOnValidator({
|
|
|
6603
6450
|
);
|
|
6604
6451
|
}
|
|
6605
6452
|
|
|
6606
|
-
// src/hooks/validators/useUserClaimableIncentives.ts
|
|
6607
|
-
import { useCallback as useCallback4, useMemo as useMemo14 } from "react";
|
|
6608
|
-
import { useBeraWallet as useBeraWallet27 } from "@berachain/wagmi/hooks";
|
|
6609
|
-
|
|
6610
|
-
// src/utils/formatIncentivesTokenMap.ts
|
|
6611
|
-
function formatIncentivesTokenMap(allRewards) {
|
|
6612
|
-
const tokenMap = /* @__PURE__ */ new Set();
|
|
6613
|
-
for (const item of allRewards) {
|
|
6614
|
-
if (Array.isArray(item.rewards)) {
|
|
6615
|
-
for (const reward of item.rewards) {
|
|
6616
|
-
if (reward.token) {
|
|
6617
|
-
tokenMap.add(reward.token);
|
|
6618
|
-
}
|
|
6619
|
-
}
|
|
6620
|
-
}
|
|
6621
|
-
}
|
|
6622
|
-
return tokenMap;
|
|
6623
|
-
}
|
|
6624
|
-
|
|
6625
|
-
// src/hooks/validators/useUserClaimableIncentives.ts
|
|
6626
|
-
function useUserClaimableIncentives() {
|
|
6627
|
-
const { address: account } = useBeraWallet27();
|
|
6628
|
-
const REWARDS_QUERY_KEY = account ? ["useUserClaimableIncentives", account] : null;
|
|
6629
|
-
const allRewardsResponse = useSWR(
|
|
6630
|
-
REWARDS_QUERY_KEY,
|
|
6631
|
-
async ([, account2]) => {
|
|
6632
|
-
if (!account2) {
|
|
6633
|
-
throw new BeraError({
|
|
6634
|
-
message: "useUserClaimableIncentives needs a logged in account",
|
|
6635
|
-
level: "error"
|
|
6636
|
-
});
|
|
6637
|
-
}
|
|
6638
|
-
return await getUserClaimableIncentives({
|
|
6639
|
-
account: account2
|
|
6640
|
-
});
|
|
6641
|
-
},
|
|
6642
|
-
{
|
|
6643
|
-
revalidateOnFocus: false,
|
|
6644
|
-
revalidateOnReconnect: false,
|
|
6645
|
-
revalidateIfStale: false,
|
|
6646
|
-
refreshInterval: 18e4 /* SLOW */
|
|
6647
|
-
}
|
|
6648
|
-
);
|
|
6649
|
-
const allRewards = allRewardsResponse?.data;
|
|
6650
|
-
const tokenMap = useMemo14(() => {
|
|
6651
|
-
if (!allRewards) {
|
|
6652
|
-
return void 0;
|
|
6653
|
-
}
|
|
6654
|
-
if (!Array.isArray(allRewards)) {
|
|
6655
|
-
BeraMonitoring.captureException(
|
|
6656
|
-
new BeraError({
|
|
6657
|
-
message: "Incorrect aggregated incentives data receieved.",
|
|
6658
|
-
level: "error",
|
|
6659
|
-
extra: {
|
|
6660
|
-
allRewards,
|
|
6661
|
-
account
|
|
6662
|
-
}
|
|
6663
|
-
})
|
|
6664
|
-
);
|
|
6665
|
-
return void 0;
|
|
6666
|
-
}
|
|
6667
|
-
return formatIncentivesTokenMap(allRewards);
|
|
6668
|
-
}, [allRewards, account]);
|
|
6669
|
-
const QUERY_KEY = account && allRewards ? ["useUserClaimableIncentives", account, allRewards] : null;
|
|
6670
|
-
const swrResponse = useSWR(
|
|
6671
|
-
QUERY_KEY,
|
|
6672
|
-
async ([, account2, allRewards2]) => {
|
|
6673
|
-
if (!account2) {
|
|
6674
|
-
throw new InvalidArgumentError({
|
|
6675
|
-
property: "account",
|
|
6676
|
-
value: account2,
|
|
6677
|
-
expected: "Address"
|
|
6678
|
-
});
|
|
6679
|
-
}
|
|
6680
|
-
if (!allRewards2) {
|
|
6681
|
-
return [];
|
|
6682
|
-
}
|
|
6683
|
-
if (!Array.isArray(allRewards2)) {
|
|
6684
|
-
throw new InvalidArgumentError({
|
|
6685
|
-
message: "Incorrect aggregated incentives data receieved to calculate proofs.",
|
|
6686
|
-
property: "allRewards",
|
|
6687
|
-
value: allRewards2,
|
|
6688
|
-
expected: "Array",
|
|
6689
|
-
level: "error"
|
|
6690
|
-
});
|
|
6691
|
-
}
|
|
6692
|
-
const validatorsSet = new Set(allRewards2.map((item) => item.validator));
|
|
6693
|
-
const validatorAddresses = Array.from(validatorsSet);
|
|
6694
|
-
return await Promise.all(
|
|
6695
|
-
validatorAddresses.map(async (validator) => {
|
|
6696
|
-
const proofsData = await getRewardProofsByValidator({
|
|
6697
|
-
account: account2,
|
|
6698
|
-
validator,
|
|
6699
|
-
page: 1,
|
|
6700
|
-
perPage: 1e4
|
|
6701
|
-
});
|
|
6702
|
-
return {
|
|
6703
|
-
...proofsData,
|
|
6704
|
-
validator
|
|
6705
|
-
};
|
|
6706
|
-
})
|
|
6707
|
-
);
|
|
6708
|
-
},
|
|
6709
|
-
{
|
|
6710
|
-
revalidateOnFocus: false,
|
|
6711
|
-
revalidateOnReconnect: false,
|
|
6712
|
-
revalidateIfStale: false,
|
|
6713
|
-
refreshInterval: 18e4 /* SLOW */
|
|
6714
|
-
}
|
|
6715
|
-
);
|
|
6716
|
-
const refresh = useCallback4(() => {
|
|
6717
|
-
allRewardsResponse?.refresh();
|
|
6718
|
-
swrResponse?.refresh();
|
|
6719
|
-
}, [allRewardsResponse, swrResponse]);
|
|
6720
|
-
return {
|
|
6721
|
-
...swrResponse,
|
|
6722
|
-
isLoading: allRewardsResponse?.isLoading || swrResponse?.isLoading,
|
|
6723
|
-
tokenMap,
|
|
6724
|
-
refresh
|
|
6725
|
-
};
|
|
6726
|
-
}
|
|
6727
|
-
|
|
6728
6453
|
// src/hooks/validators/useUserStakingPositions.ts
|
|
6729
6454
|
function useUserStakingPositions({
|
|
6730
6455
|
account,
|
|
@@ -6753,9 +6478,9 @@ import { keccak256 as keccak2562 } from "viem";
|
|
|
6753
6478
|
import { beaconDepositAbi } from "@berachain/abis/pol/beaconDeposit";
|
|
6754
6479
|
import { bgtAbi as bgtAbi2 } from "@berachain/abis/pol/bgt";
|
|
6755
6480
|
import { beraChefAbi as beraChefAbi3 } from "@berachain/abis/pol/rewards/beraChef";
|
|
6756
|
-
import { usePublicClient as
|
|
6481
|
+
import { usePublicClient as usePublicClient49 } from "@berachain/wagmi/hooks";
|
|
6757
6482
|
function useOnChainValidator({ pubkey }, options) {
|
|
6758
|
-
const publicClient =
|
|
6483
|
+
const publicClient = usePublicClient49();
|
|
6759
6484
|
const QUERY_KEY = pubkey ? ["useOnChainValidator", pubkey] : null;
|
|
6760
6485
|
return useSWR(
|
|
6761
6486
|
publicClient ? QUERY_KEY : null,
|
|
@@ -6838,30 +6563,10 @@ function useValidator({ pubkey }, options) {
|
|
|
6838
6563
|
};
|
|
6839
6564
|
}
|
|
6840
6565
|
|
|
6841
|
-
// src/hooks/validators/useValidatorAnalytics.ts
|
|
6842
|
-
function useValidatorAnalytics({
|
|
6843
|
-
pubkey,
|
|
6844
|
-
dayRange
|
|
6845
|
-
}) {
|
|
6846
|
-
const QUERY_KEY = pubkey && dayRange ? ["useValidatorAnalytics", pubkey, dayRange] : null;
|
|
6847
|
-
return useSWR(
|
|
6848
|
-
QUERY_KEY,
|
|
6849
|
-
async ([, pubkey2, dayRange2]) => {
|
|
6850
|
-
return await getValidatorAnalytics({
|
|
6851
|
-
pubkey: pubkey2,
|
|
6852
|
-
dayRange: dayRange2
|
|
6853
|
-
});
|
|
6854
|
-
},
|
|
6855
|
-
{
|
|
6856
|
-
refreshInterval: 18e4 /* SLOW */
|
|
6857
|
-
}
|
|
6858
|
-
);
|
|
6859
|
-
}
|
|
6860
|
-
|
|
6861
6566
|
// src/hooks/validators/useValidatorCommission.ts
|
|
6862
|
-
import { usePublicClient as
|
|
6567
|
+
import { usePublicClient as usePublicClient50 } from "@berachain/wagmi/hooks";
|
|
6863
6568
|
function useValidatorCommission(pubKey, options) {
|
|
6864
|
-
const publicClient =
|
|
6569
|
+
const publicClient = usePublicClient50();
|
|
6865
6570
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorCommission", pubKey] : null;
|
|
6866
6571
|
return swr_default(
|
|
6867
6572
|
QUERY_KEY,
|
|
@@ -6946,9 +6651,9 @@ function useValidatorIncentiveDistribution({
|
|
|
6946
6651
|
}
|
|
6947
6652
|
|
|
6948
6653
|
// src/hooks/validators/useValidatorQueuedCommission.ts
|
|
6949
|
-
import { usePublicClient as
|
|
6654
|
+
import { usePublicClient as usePublicClient51 } from "@berachain/wagmi/hooks";
|
|
6950
6655
|
function useValidatorQueuedCommission(pubKey, options) {
|
|
6951
|
-
const publicClient =
|
|
6656
|
+
const publicClient = usePublicClient51();
|
|
6952
6657
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedCommission", pubKey] : null;
|
|
6953
6658
|
return useSWR(
|
|
6954
6659
|
QUERY_KEY,
|
|
@@ -6966,9 +6671,9 @@ function useValidatorQueuedCommission(pubKey, options) {
|
|
|
6966
6671
|
}
|
|
6967
6672
|
|
|
6968
6673
|
// src/hooks/validators/useValidatorQueuedOperatorAddress.ts
|
|
6969
|
-
import { usePublicClient as
|
|
6674
|
+
import { usePublicClient as usePublicClient52 } from "@berachain/wagmi/hooks";
|
|
6970
6675
|
function useValidatorQueuedOperatorAddress(pubKey, options) {
|
|
6971
|
-
const publicClient =
|
|
6676
|
+
const publicClient = usePublicClient52();
|
|
6972
6677
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedOperatorAddress", pubKey] : null;
|
|
6973
6678
|
return useSWR(
|
|
6974
6679
|
QUERY_KEY,
|
|
@@ -6985,9 +6690,9 @@ function useValidatorQueuedOperatorAddress(pubKey, options) {
|
|
|
6985
6690
|
}
|
|
6986
6691
|
|
|
6987
6692
|
// src/hooks/validators/useValidatorQueuedRewardAllocation.ts
|
|
6988
|
-
import { usePublicClient as
|
|
6693
|
+
import { usePublicClient as usePublicClient53 } from "@berachain/wagmi/hooks";
|
|
6989
6694
|
function useValidatorQueuedRewardAllocation(pubKey, options) {
|
|
6990
|
-
const publicClient =
|
|
6695
|
+
const publicClient = usePublicClient53();
|
|
6991
6696
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorQueuedRewardAllocation", pubKey] : null;
|
|
6992
6697
|
return useSWR(
|
|
6993
6698
|
QUERY_KEY,
|
|
@@ -7004,9 +6709,9 @@ function useValidatorQueuedRewardAllocation(pubKey, options) {
|
|
|
7004
6709
|
}
|
|
7005
6710
|
|
|
7006
6711
|
// src/hooks/validators/useValidatorRewardAllocation.ts
|
|
7007
|
-
import { usePublicClient as
|
|
6712
|
+
import { usePublicClient as usePublicClient54 } from "@berachain/wagmi/hooks";
|
|
7008
6713
|
function useValidatorRewardAllocation(pubKey, options) {
|
|
7009
|
-
const publicClient =
|
|
6714
|
+
const publicClient = usePublicClient54();
|
|
7010
6715
|
const QUERY_KEY = publicClient && pubKey ? ["useValidatorRewardAllocation", pubKey] : null;
|
|
7011
6716
|
return useSWR(
|
|
7012
6717
|
QUERY_KEY,
|
|
@@ -7024,6 +6729,8 @@ function useValidatorRewardAllocation(pubKey, options) {
|
|
|
7024
6729
|
export {
|
|
7025
6730
|
OracleMode,
|
|
7026
6731
|
USE_AGGREGATORS_QUOTES_QUERY_KEY,
|
|
6732
|
+
fetchMultipleTokenInformation,
|
|
6733
|
+
isNativeFeeInsufficient,
|
|
7027
6734
|
reducer,
|
|
7028
6735
|
useAggregatorsQuotes,
|
|
7029
6736
|
useAggregatorsRouterFeeBps,
|
|
@@ -7047,7 +6754,6 @@ export {
|
|
|
7047
6754
|
useBeraCurrentPrice,
|
|
7048
6755
|
useBexStatus,
|
|
7049
6756
|
useBgtAprSimulation,
|
|
7050
|
-
useBgtIncentiveDistributorPaused,
|
|
7051
6757
|
useBgtUnstakedBalance,
|
|
7052
6758
|
useBlockToTimestamp,
|
|
7053
6759
|
useCappedGlobally,
|
|
@@ -7055,7 +6761,7 @@ export {
|
|
|
7055
6761
|
useClaimableFees,
|
|
7056
6762
|
useCollateralWeights,
|
|
7057
6763
|
useCreatePool,
|
|
7058
|
-
|
|
6764
|
+
useCrossChainNativeFee,
|
|
7059
6765
|
useEnsoUserTokensWithBalances,
|
|
7060
6766
|
useGetConvertToAssets,
|
|
7061
6767
|
useGetVerifiedAbi,
|
|
@@ -7104,7 +6810,7 @@ export {
|
|
|
7104
6810
|
useRewardVaults,
|
|
7105
6811
|
useRewardVaultsQueryKey,
|
|
7106
6812
|
useSingleAggregatorQuote,
|
|
7107
|
-
|
|
6813
|
+
useStakedAPY,
|
|
7108
6814
|
useStakedData,
|
|
7109
6815
|
useStakedSnapshots,
|
|
7110
6816
|
useStakingPoolBatch,
|
|
@@ -7119,12 +6825,10 @@ export {
|
|
|
7119
6825
|
useTotalSupply,
|
|
7120
6826
|
useUserActiveValidators,
|
|
7121
6827
|
useUserBoostsOnValidator,
|
|
7122
|
-
useUserClaimableIncentives,
|
|
7123
6828
|
useUserStakingPositions,
|
|
7124
6829
|
useUserVaultInfo,
|
|
7125
6830
|
useUserVaults,
|
|
7126
6831
|
useValidator,
|
|
7127
|
-
useValidatorAnalytics,
|
|
7128
6832
|
useValidatorCommission,
|
|
7129
6833
|
useValidatorEstimatedBgtPerYear,
|
|
7130
6834
|
useValidatorIncentiveDistribution,
|