@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
|
@@ -183,7 +183,13 @@ export function useAggregatorsQuotes(
|
|
|
183
183
|
...args,
|
|
184
184
|
aggregator: bex,
|
|
185
185
|
},
|
|
186
|
-
{
|
|
186
|
+
{
|
|
187
|
+
...swrOptions,
|
|
188
|
+
// Compose with the caller's gate (e.g. same-token suppression from
|
|
189
|
+
// useSwap) instead of overwriting it — otherwise bex fetches whenever
|
|
190
|
+
// it's unpaused, regardless of isEnabled (HUB-9FQ).
|
|
191
|
+
isEnabled: (options?.isEnabled ?? true) && bexProtocol.isPaused === false,
|
|
192
|
+
},
|
|
187
193
|
);
|
|
188
194
|
|
|
189
195
|
const wberaSwapResult = raw_useSingleAggregatorQuote({
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { formatEther, zeroAddress } from "viem";
|
|
4
|
+
|
|
5
|
+
import { usePollBalance } from "../tokens/usePollBalance";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Whether the source-chain native balance fails to cover the tx value.
|
|
9
|
+
*
|
|
10
|
+
* Same-chain zaps never qualify: their tx `value` is the native amount being
|
|
11
|
+
* swapped (e.g. BERA → HONEY), not a bridge fee, so treating it as a fee would
|
|
12
|
+
* always flag the balance short. Extracted (and exported) so the branch is
|
|
13
|
+
* unit-testable without a React renderer.
|
|
14
|
+
*/
|
|
15
|
+
export function isNativeFeeInsufficient({
|
|
16
|
+
isCrossChain,
|
|
17
|
+
value,
|
|
18
|
+
nativeBalance,
|
|
19
|
+
isLoading,
|
|
20
|
+
}: {
|
|
21
|
+
isCrossChain: boolean;
|
|
22
|
+
value: bigint;
|
|
23
|
+
nativeBalance: bigint;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
}): boolean {
|
|
26
|
+
if (!isCrossChain) return false;
|
|
27
|
+
return value > 0n && !isLoading && value > nativeBalance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Cross-chain zaps pay the LayerZero bridge fee out of the source-chain native
|
|
32
|
+
* balance (it's baked into the tx `value`). This polls that native balance and
|
|
33
|
+
* reports whether it covers the fee, so the shared warning/gas-reserve UI stops
|
|
34
|
+
* being copy-pasted per call site. Only polls when a cross-chain route exists —
|
|
35
|
+
* `srcChainId` is passed undefined otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export function useCrossChainNativeFee({
|
|
38
|
+
srcChainId,
|
|
39
|
+
value,
|
|
40
|
+
}: {
|
|
41
|
+
/** Source chain the tx (and bridge fee) lives on. Undefined ⇒ not cross-chain, no poll. */
|
|
42
|
+
srcChainId: number | undefined;
|
|
43
|
+
/** The tx value in wei, including the bridge fee. */
|
|
44
|
+
value: bigint;
|
|
45
|
+
}): {
|
|
46
|
+
nativeFee?: string;
|
|
47
|
+
hasInsufficientNativeBalance: boolean;
|
|
48
|
+
isNativeBalanceLoading: boolean;
|
|
49
|
+
} {
|
|
50
|
+
const isCrossChain = srcChainId !== undefined;
|
|
51
|
+
|
|
52
|
+
const { data: nativeBalanceData, isLoading: isNativeBalanceLoading } =
|
|
53
|
+
usePollBalance(
|
|
54
|
+
{
|
|
55
|
+
address: zeroAddress,
|
|
56
|
+
chainId: isCrossChain ? srcChainId : undefined,
|
|
57
|
+
},
|
|
58
|
+
{ isEnabled: isCrossChain },
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// For a same-chain zap the tx `value` is the native amount being swapped, not
|
|
62
|
+
// a bridge fee — so there's no fee to display or check.
|
|
63
|
+
if (!isCrossChain) {
|
|
64
|
+
return {
|
|
65
|
+
nativeFee: undefined,
|
|
66
|
+
hasInsufficientNativeBalance: false,
|
|
67
|
+
isNativeBalanceLoading: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const nativeBalance = BigInt(nativeBalanceData?.balance.raw ?? 0n);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
nativeFee: value > 0n ? formatEther(value) : undefined,
|
|
75
|
+
hasInsufficientNativeBalance: isNativeFeeInsufficient({
|
|
76
|
+
isCrossChain,
|
|
77
|
+
value,
|
|
78
|
+
nativeBalance,
|
|
79
|
+
isLoading: isNativeBalanceLoading,
|
|
80
|
+
}),
|
|
81
|
+
isNativeBalanceLoading,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { isNativeFeeInsufficient } from "./useCrossChainNativeFee";
|
|
4
|
+
|
|
5
|
+
describe("isNativeFeeInsufficient", () => {
|
|
6
|
+
// Regression (PR #1965 review): a same-chain native-in zap (e.g. BERA → HONEY)
|
|
7
|
+
// has a non-zero tx value that is the swap amount, not a bridge fee. It must
|
|
8
|
+
// never be flagged as insufficient native balance.
|
|
9
|
+
test("same-chain zap is never insufficient, even with a large value", () => {
|
|
10
|
+
expect(
|
|
11
|
+
isNativeFeeInsufficient({
|
|
12
|
+
isCrossChain: false,
|
|
13
|
+
value: 10n ** 18n,
|
|
14
|
+
nativeBalance: 0n,
|
|
15
|
+
isLoading: false,
|
|
16
|
+
}),
|
|
17
|
+
).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("cross-chain: insufficient when value exceeds native balance", () => {
|
|
21
|
+
expect(
|
|
22
|
+
isNativeFeeInsufficient({
|
|
23
|
+
isCrossChain: true,
|
|
24
|
+
value: 2n,
|
|
25
|
+
nativeBalance: 1n,
|
|
26
|
+
isLoading: false,
|
|
27
|
+
}),
|
|
28
|
+
).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("cross-chain: sufficient when balance covers the fee", () => {
|
|
32
|
+
expect(
|
|
33
|
+
isNativeFeeInsufficient({
|
|
34
|
+
isCrossChain: true,
|
|
35
|
+
value: 1n,
|
|
36
|
+
nativeBalance: 5n,
|
|
37
|
+
isLoading: false,
|
|
38
|
+
}),
|
|
39
|
+
).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("cross-chain: not flagged while the balance is still loading", () => {
|
|
43
|
+
expect(
|
|
44
|
+
isNativeFeeInsufficient({
|
|
45
|
+
isCrossChain: true,
|
|
46
|
+
value: 2n,
|
|
47
|
+
nativeBalance: 0n,
|
|
48
|
+
isLoading: true,
|
|
49
|
+
}),
|
|
50
|
+
).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("cross-chain: zero value is never insufficient", () => {
|
|
54
|
+
expect(
|
|
55
|
+
isNativeFeeInsufficient({
|
|
56
|
+
isCrossChain: true,
|
|
57
|
+
value: 0n,
|
|
58
|
+
nativeBalance: 0n,
|
|
59
|
+
isLoading: false,
|
|
60
|
+
}),
|
|
61
|
+
).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -93,17 +93,16 @@ export function useOnChainPoolData(poolId: string) {
|
|
|
93
93
|
return undefined;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
tokens: tokenInformation.map((token, idx) => ({
|
|
96
|
+
const infoByAddress = new Map(
|
|
97
|
+
tokenInformation.map(
|
|
98
|
+
(token) => [token.address.toLowerCase(), token] as const,
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const tokens = poolData.poolTokens[0].map((rawAddress, idx) => {
|
|
103
|
+
const token = infoByAddress.get(rawAddress.toLowerCase());
|
|
104
|
+
if (!token) return null;
|
|
105
|
+
return {
|
|
107
106
|
address: token.address.toLowerCase() as Address,
|
|
108
107
|
name: token.name,
|
|
109
108
|
decimals: token.decimals,
|
|
@@ -115,11 +114,29 @@ export function useOnChainPoolData(poolId: string) {
|
|
|
115
114
|
token.decimals,
|
|
116
115
|
),
|
|
117
116
|
token: {
|
|
118
|
-
__typename: "Token",
|
|
117
|
+
__typename: "Token" as const,
|
|
119
118
|
token,
|
|
120
119
|
latestUSDPrice: tokenPrices?.[token.address],
|
|
121
120
|
},
|
|
122
|
-
}
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// A pool token whose metadata couldn't be resolved leaves the pool incomplete;
|
|
125
|
+
if (tokens.some((token) => token === null)) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const pool: OnChainPoolFragment = {
|
|
130
|
+
address: address.toLowerCase() as Address,
|
|
131
|
+
id: poolId.toLowerCase() as string,
|
|
132
|
+
type: poolData.type,
|
|
133
|
+
factory: poolData.factory,
|
|
134
|
+
totalShares: poolData.totalSupply,
|
|
135
|
+
totalLiquidity: "0", // overwritten below
|
|
136
|
+
swapFee: poolData.swapFee,
|
|
137
|
+
createTime: 0,
|
|
138
|
+
name: poolData.name,
|
|
139
|
+
tokens: tokens as NonNullable<(typeof tokens)[number]>[],
|
|
123
140
|
amplificationParameter: poolData?.amplificationParameter && {
|
|
124
141
|
// For example, if value is 300000n and precision is 1000n, the user-set amplification parameter would be 300000n / 1000n = 300n.
|
|
125
142
|
currentFormattedValue:
|
|
@@ -54,6 +54,7 @@ type IQueryKey = readonly [
|
|
|
54
54
|
Address | undefined, // rewardVault
|
|
55
55
|
MinimalERC20 | null | undefined, // underlyingToken
|
|
56
56
|
TokenWithOrder[] | undefined, // collateralList
|
|
57
|
+
boolean, // proxyAggregatorsThroughVercel
|
|
57
58
|
];
|
|
58
59
|
|
|
59
60
|
export const USE_AGGREGATORS_QUOTES_QUERY_KEY = "useAggregatorsQuotes";
|
|
@@ -70,6 +71,7 @@ function getQueryKey({
|
|
|
70
71
|
feeBps,
|
|
71
72
|
activeAggregators,
|
|
72
73
|
isMAEnabled,
|
|
74
|
+
proxyAggregatorsThroughVercel,
|
|
73
75
|
}: {
|
|
74
76
|
aggregator: BaseAggregator;
|
|
75
77
|
account: Address | undefined;
|
|
@@ -82,17 +84,20 @@ function getQueryKey({
|
|
|
82
84
|
*/
|
|
83
85
|
activeAggregators: string[] | undefined;
|
|
84
86
|
isMAEnabled: boolean;
|
|
87
|
+
proxyAggregatorsThroughVercel: boolean | undefined;
|
|
85
88
|
}): IQueryKey | null {
|
|
86
89
|
if (!Number(args.amount)) {
|
|
87
90
|
return null;
|
|
88
91
|
}
|
|
92
|
+
|
|
89
93
|
if (
|
|
90
|
-
|
|
94
|
+
aggregator.getUnsupportedReason({
|
|
91
95
|
tokenIn: args.tokenIn,
|
|
92
96
|
tokenOut: args.tokenOut,
|
|
93
97
|
underlyingToken: args.underlyingToken,
|
|
94
98
|
honeyNativeState: args.honeyNativeState,
|
|
95
|
-
|
|
99
|
+
rewardVault: args.rewardVault,
|
|
100
|
+
}) !== null
|
|
96
101
|
) {
|
|
97
102
|
return null;
|
|
98
103
|
}
|
|
@@ -156,6 +161,7 @@ function getQueryKey({
|
|
|
156
161
|
aggregator.name === Aggregators.Honey
|
|
157
162
|
? args.honeyNativeState?.collateralList
|
|
158
163
|
: undefined,
|
|
164
|
+
proxyAggregatorsThroughVercel ?? false,
|
|
159
165
|
];
|
|
160
166
|
}
|
|
161
167
|
|
|
@@ -166,11 +172,9 @@ function getQueryKey({
|
|
|
166
172
|
function getQueryFn({
|
|
167
173
|
aggregator,
|
|
168
174
|
publicClient,
|
|
169
|
-
proxyAggregatorsThroughVercel,
|
|
170
175
|
}: {
|
|
171
176
|
aggregator: BaseAggregator;
|
|
172
177
|
publicClient?: PublicClient;
|
|
173
|
-
proxyAggregatorsThroughVercel?: boolean;
|
|
174
178
|
}) {
|
|
175
179
|
return async ([
|
|
176
180
|
,
|
|
@@ -185,6 +189,7 @@ function getQueryFn({
|
|
|
185
189
|
rewardVault,
|
|
186
190
|
underlyingToken,
|
|
187
191
|
honeyCollaterals,
|
|
192
|
+
proxyAggregatorsThroughVercel,
|
|
188
193
|
]: IQueryKey) =>
|
|
189
194
|
aggregator.getQuote({
|
|
190
195
|
tokenIn,
|
|
@@ -240,10 +245,10 @@ export function raw_useSingleAggregatorQuote(
|
|
|
240
245
|
feeBps,
|
|
241
246
|
activeAggregators,
|
|
242
247
|
isMAEnabled,
|
|
248
|
+
proxyAggregatorsThroughVercel,
|
|
243
249
|
}),
|
|
244
250
|
getQueryFn({
|
|
245
251
|
aggregator: args.aggregator,
|
|
246
|
-
proxyAggregatorsThroughVercel,
|
|
247
252
|
publicClient,
|
|
248
253
|
}),
|
|
249
254
|
options,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import type { BaseAggregator } from "../../actions/dex/aggregators/base";
|
|
4
|
+
import { Aggregators } from "../../enum/dex";
|
|
5
|
+
import type { MinimalERC20 } from "../../types/dex";
|
|
6
|
+
import { raw_useSingleAggregatorQuote } from "./useSingleAggregatorQuote";
|
|
7
|
+
|
|
8
|
+
type CapturedFetcher = (key: readonly unknown[]) => Promise<unknown>;
|
|
9
|
+
|
|
10
|
+
const { captured } = vi.hoisted(() => ({
|
|
11
|
+
captured: {
|
|
12
|
+
key: null as readonly unknown[] | null,
|
|
13
|
+
fetcher: null as CapturedFetcher | null,
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock("@berachain/utils/pkg/swr", () => ({
|
|
18
|
+
useSWR: vi.fn(
|
|
19
|
+
(key: readonly unknown[] | null, fetcher: CapturedFetcher | null) => {
|
|
20
|
+
captured.key = key;
|
|
21
|
+
captured.fetcher = fetcher;
|
|
22
|
+
return { data: undefined, refresh: vi.fn() };
|
|
23
|
+
},
|
|
24
|
+
),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const tokenIn = {
|
|
28
|
+
address: "0x6969696969696969696969696969696969696969",
|
|
29
|
+
decimals: 18,
|
|
30
|
+
symbol: "WBERA",
|
|
31
|
+
name: "Wrapped BERA",
|
|
32
|
+
chainId: 80094,
|
|
33
|
+
} as const satisfies MinimalERC20;
|
|
34
|
+
|
|
35
|
+
const tokenOut = {
|
|
36
|
+
address: "0xFCBD14d472B1C3Ff25139Aba7D7aCE0C12fFf4d8",
|
|
37
|
+
decimals: 18,
|
|
38
|
+
symbol: "HONEY",
|
|
39
|
+
name: "Honey",
|
|
40
|
+
chainId: 80094,
|
|
41
|
+
} as const satisfies MinimalERC20;
|
|
42
|
+
|
|
43
|
+
describe("raw_useSingleAggregatorQuote", () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
captured.key = null;
|
|
46
|
+
captured.fetcher = null;
|
|
47
|
+
vi.clearAllMocks();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("reads the proxy transport from the SWR key", async () => {
|
|
51
|
+
const getQuote = vi.fn().mockResolvedValue(undefined);
|
|
52
|
+
const aggregator = {
|
|
53
|
+
name: Aggregators.Oogabooga,
|
|
54
|
+
needsAccountForQuote: false,
|
|
55
|
+
getUnsupportedReason: () => null,
|
|
56
|
+
getQuote,
|
|
57
|
+
} as unknown as BaseAggregator;
|
|
58
|
+
|
|
59
|
+
raw_useSingleAggregatorQuote({
|
|
60
|
+
aggregator,
|
|
61
|
+
tokenIn,
|
|
62
|
+
tokenOut,
|
|
63
|
+
amount: "1",
|
|
64
|
+
slippage: 0.5,
|
|
65
|
+
account: undefined,
|
|
66
|
+
feeBps: 10,
|
|
67
|
+
activeAggregators: undefined,
|
|
68
|
+
isMAEnabled: true,
|
|
69
|
+
publicClient: undefined,
|
|
70
|
+
proxyAggregatorsThroughVercel: false,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(captured.key?.at(-1)).toBe(false);
|
|
74
|
+
expect(captured.fetcher).not.toBeNull();
|
|
75
|
+
|
|
76
|
+
const proxyKey = [...(captured.key ?? [])];
|
|
77
|
+
proxyKey[proxyKey.length - 1] = true;
|
|
78
|
+
await captured.fetcher?.(proxyKey);
|
|
79
|
+
|
|
80
|
+
expect(getQuote).toHaveBeenCalledWith(
|
|
81
|
+
expect.objectContaining({
|
|
82
|
+
proxyAggregatorsThroughVercel: true,
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { type Address,
|
|
4
|
-
|
|
5
|
-
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
3
|
+
import { type Address, parseUnits, zeroAddress } from "viem";
|
|
6
4
|
|
|
7
5
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
8
6
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
@@ -19,9 +17,8 @@ import type { BalanceToken, MinimalERC20 } from "../../types/dex";
|
|
|
19
17
|
import type { DefaultHookOptions } from "../../types/global";
|
|
20
18
|
import { isToken } from "../../utils/tokens";
|
|
21
19
|
import { useGetConvertToAssets } from "../bend/useGetConvertToAssets";
|
|
20
|
+
import { useCrossChainNativeFee } from "../dex/useCrossChainNativeFee";
|
|
22
21
|
import { usePriceImpact } from "../dex/usePriceImpact";
|
|
23
|
-
import { usePollBalance } from "../tokens/usePollBalance";
|
|
24
|
-
import { useTokenPrices } from "../tokens/useTokenPrices";
|
|
25
22
|
|
|
26
23
|
type UseBendZapSupplyArgs = {
|
|
27
24
|
/*
|
|
@@ -69,10 +66,6 @@ export function useBendZapSupply(
|
|
|
69
66
|
}: UseBendZapSupplyArgs,
|
|
70
67
|
options?: DefaultHookOptions,
|
|
71
68
|
) {
|
|
72
|
-
const { getTokenPrice } = useTokenPrices({
|
|
73
|
-
tokens: tokenIn && loanToken ? [tokenIn, loanToken] : undefined,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
69
|
const swrResponse = useBendZapSupplyHelper(
|
|
77
70
|
{
|
|
78
71
|
tokenIn,
|
|
@@ -106,39 +99,17 @@ export function useBendZapSupply(
|
|
|
106
99
|
},
|
|
107
100
|
);
|
|
108
101
|
|
|
109
|
-
const isCrossChain =
|
|
102
|
+
const isCrossChain = swrResponse.data?.isCrossChain;
|
|
110
103
|
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
usePollBalance(
|
|
114
|
-
{
|
|
115
|
-
address: zeroAddress,
|
|
116
|
-
chainId: isCrossChain ? tokenIn?.chainId : undefined,
|
|
117
|
-
},
|
|
118
|
-
{ isEnabled: !!isCrossChain },
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
// for cross-chain zaps, check if transaction value exceeds native token balance
|
|
122
|
-
// (tx.value includes bridge fees that must be paid in native token)
|
|
104
|
+
// for cross-chain zaps, tx.value includes the bridge fee (paid in native
|
|
105
|
+
// token on the source chain); check the source-chain native balance covers it.
|
|
123
106
|
const transactionValue =
|
|
124
107
|
swrResponse.data?.getCalldata?.({ account: zeroAddress })?.value ?? 0n;
|
|
125
108
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
const hasInsufficientNativeBalance =
|
|
132
|
-
isCrossChain &&
|
|
133
|
-
transactionValue > 0n &&
|
|
134
|
-
!isNativeBalanceLoading &&
|
|
135
|
-
transactionValue > BigInt(nativeBalance.raw);
|
|
136
|
-
|
|
137
|
-
// formatted native fee for gas reserve display
|
|
138
|
-
const nativeFee =
|
|
139
|
-
isCrossChain && transactionValue > 0n
|
|
140
|
-
? formatEther(transactionValue)
|
|
141
|
-
: undefined;
|
|
109
|
+
const { hasInsufficientNativeBalance, nativeFee } = useCrossChainNativeFee({
|
|
110
|
+
srcChainId: isCrossChain ? swrResponse.data?.srcChainId : undefined,
|
|
111
|
+
value: transactionValue,
|
|
112
|
+
});
|
|
142
113
|
|
|
143
114
|
return {
|
|
144
115
|
...swrResponse,
|
|
@@ -209,6 +180,7 @@ export function useBendZapSupplyHelper(
|
|
|
209
180
|
rewardVault,
|
|
210
181
|
amount,
|
|
211
182
|
slippage,
|
|
183
|
+
proxyAggregatorsThroughVercel,
|
|
212
184
|
]) => {
|
|
213
185
|
assertPublicClient(publicClientBeraChain);
|
|
214
186
|
assertAddress(fromAddress, "fromAddress");
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import type { BalanceToken, MinimalERC20 } from "../../types/dex";
|
|
4
|
+
import { useBendZapSupplyHelper } from "./useBendZapSupply";
|
|
5
|
+
|
|
6
|
+
type CapturedFetcher = (key: readonly unknown[]) => Promise<unknown>;
|
|
7
|
+
|
|
8
|
+
const { captured, getQuote } = vi.hoisted(() => ({
|
|
9
|
+
captured: {
|
|
10
|
+
key: null as readonly unknown[] | null,
|
|
11
|
+
fetcher: null as CapturedFetcher | null,
|
|
12
|
+
},
|
|
13
|
+
getQuote: vi.fn(),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock("@berachain/wagmi/hooks", () => ({
|
|
17
|
+
useBeraWallet: () => ({
|
|
18
|
+
address: "0x1111111111111111111111111111111111111111",
|
|
19
|
+
}),
|
|
20
|
+
usePublicClient: () => ({}),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
vi.mock("@berachain/utils/pkg/swr", () => ({
|
|
24
|
+
useSWR: vi.fn(
|
|
25
|
+
(key: readonly unknown[] | null, fetcher: CapturedFetcher | null) => {
|
|
26
|
+
captured.key = key;
|
|
27
|
+
captured.fetcher = fetcher;
|
|
28
|
+
return { data: undefined, refresh: vi.fn() };
|
|
29
|
+
},
|
|
30
|
+
),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
vi.mock("../../contexts/BeraFlags/BeraFlags", () => ({
|
|
34
|
+
useBeraFlag: () => false,
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
vi.mock("../../actions/dex/aggregators/enso/ensoErc4626", () => ({
|
|
38
|
+
ensoErc4626: { getQuote },
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const tokenIn = {
|
|
42
|
+
address: "0x6969696969696969696969696969696969696969",
|
|
43
|
+
decimals: 18,
|
|
44
|
+
symbol: "WBERA",
|
|
45
|
+
name: "Wrapped BERA",
|
|
46
|
+
chainId: 80094,
|
|
47
|
+
balance: {
|
|
48
|
+
raw: "1000000000000000000",
|
|
49
|
+
formatted: "1",
|
|
50
|
+
},
|
|
51
|
+
} as const satisfies BalanceToken;
|
|
52
|
+
|
|
53
|
+
const loanToken = {
|
|
54
|
+
address: "0xFCBD14d472B1C3Ff25139Aba7D7aCE0C12fFf4d8",
|
|
55
|
+
decimals: 18,
|
|
56
|
+
symbol: "HONEY",
|
|
57
|
+
name: "Honey",
|
|
58
|
+
chainId: 80094,
|
|
59
|
+
} as const satisfies MinimalERC20;
|
|
60
|
+
|
|
61
|
+
const bendVault = {
|
|
62
|
+
address: "0x2222222222222222222222222222222222222222",
|
|
63
|
+
decimals: 18,
|
|
64
|
+
symbol: "byvHONEY",
|
|
65
|
+
name: "Bend Honey Vault",
|
|
66
|
+
chainId: 80094,
|
|
67
|
+
} as const satisfies MinimalERC20;
|
|
68
|
+
|
|
69
|
+
describe("useBendZapSupplyHelper", () => {
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
captured.key = null;
|
|
72
|
+
captured.fetcher = null;
|
|
73
|
+
getQuote.mockReset();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("reads the proxy transport from the SWR key", async () => {
|
|
77
|
+
useBendZapSupplyHelper({
|
|
78
|
+
tokenIn,
|
|
79
|
+
loanToken,
|
|
80
|
+
bendVault,
|
|
81
|
+
amount: "1000000000000000000",
|
|
82
|
+
slippage: 0.5,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(captured.key?.at(-1)).toBe(false);
|
|
86
|
+
expect(captured.fetcher).not.toBeNull();
|
|
87
|
+
|
|
88
|
+
const proxyKey = [...(captured.key ?? [])];
|
|
89
|
+
proxyKey[proxyKey.length - 1] = true;
|
|
90
|
+
await captured.fetcher?.(proxyKey);
|
|
91
|
+
|
|
92
|
+
expect(getQuote).toHaveBeenCalledWith(
|
|
93
|
+
expect.objectContaining({
|
|
94
|
+
proxyAggregatorsThroughVercel: true,
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ChainId, defaultChainId } from "@berachain/config/internal";
|
|
2
|
+
|
|
1
3
|
import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
2
4
|
import { useSWR } from "@berachain/utils/pkg/swr";
|
|
3
5
|
|
|
@@ -17,10 +19,9 @@ export function useEnsoUserTokensWithBalances(
|
|
|
17
19
|
const proxyAggregatorsThroughVercel = useBeraFlag(
|
|
18
20
|
"proxyAggregatorsThroughVercel",
|
|
19
21
|
);
|
|
20
|
-
const isEnabled = !!fromAddress;
|
|
21
22
|
|
|
22
23
|
const QUERY_KEY =
|
|
23
|
-
|
|
24
|
+
fromAddress && wagmiConfig
|
|
24
25
|
? ([
|
|
25
26
|
"useEnsoUserTokensWithBalances",
|
|
26
27
|
fromAddress,
|
|
@@ -31,7 +32,9 @@ export function useEnsoUserTokensWithBalances(
|
|
|
31
32
|
|
|
32
33
|
return useSWR(
|
|
33
34
|
QUERY_KEY,
|
|
34
|
-
async ([, fromAddress, chainId]): Promise<
|
|
35
|
+
async ([, fromAddress, chainId, proxyAggregatorsThroughVercel]): Promise<
|
|
36
|
+
BalanceToken[]
|
|
37
|
+
> =>
|
|
35
38
|
getEnsoUserTokensWithBalances({
|
|
36
39
|
account: fromAddress,
|
|
37
40
|
wagmiConfig,
|
|
@@ -43,6 +46,13 @@ export function useEnsoUserTokensWithBalances(
|
|
|
43
46
|
{
|
|
44
47
|
refreshInterval: POLLING.NORMAL,
|
|
45
48
|
...options,
|
|
49
|
+
// Enso only supports mainnet — on a Bepolia deployment `getBalances`
|
|
50
|
+
// returns a non-array, which the action reports as a warning (HUB-A1J).
|
|
51
|
+
// Don't query at all when the app isn't on an Enso-supported chain.
|
|
52
|
+
isEnabled:
|
|
53
|
+
chainId !== ChainId.BEPOLIA &&
|
|
54
|
+
defaultChainId !== ChainId.BEPOLIA &&
|
|
55
|
+
(options?.isEnabled ?? true),
|
|
46
56
|
},
|
|
47
57
|
);
|
|
48
58
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { useEnsoUserTokensWithBalances } from "./useEnsoUserTokensWithBalances";
|
|
4
|
+
|
|
5
|
+
type CapturedFetcher = (key: readonly unknown[]) => Promise<unknown>;
|
|
6
|
+
|
|
7
|
+
const { captured, getEnsoClient, getEnsoUserTokensWithBalances } = vi.hoisted(
|
|
8
|
+
() => ({
|
|
9
|
+
captured: {
|
|
10
|
+
key: null as readonly unknown[] | null,
|
|
11
|
+
fetcher: null as CapturedFetcher | null,
|
|
12
|
+
},
|
|
13
|
+
getEnsoClient: vi.fn(() => ({ getBalances: vi.fn() })),
|
|
14
|
+
getEnsoUserTokensWithBalances: vi.fn().mockResolvedValue([]),
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
vi.mock("@berachain/wagmi/hooks", () => ({
|
|
19
|
+
useBeraWallet: () => ({
|
|
20
|
+
address: "0x1111111111111111111111111111111111111111",
|
|
21
|
+
}),
|
|
22
|
+
useConfig: () => ({ chains: [] }),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock("@berachain/utils/pkg/swr", () => ({
|
|
26
|
+
useSWR: vi.fn(
|
|
27
|
+
(key: readonly unknown[] | null, fetcher: CapturedFetcher | null) => {
|
|
28
|
+
captured.key = key;
|
|
29
|
+
captured.fetcher = fetcher;
|
|
30
|
+
return { data: undefined, refresh: vi.fn() };
|
|
31
|
+
},
|
|
32
|
+
),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
vi.mock("../../contexts/BeraFlags/BeraFlags", () => ({
|
|
36
|
+
useBeraFlag: () => false,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
vi.mock("../../actions/clients/getEnsoClient", () => ({
|
|
40
|
+
getEnsoClient,
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
vi.mock("../../actions/enso/getEnsoUserTokensWithBalances", () => ({
|
|
44
|
+
getEnsoUserTokensWithBalances,
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
describe("useEnsoUserTokensWithBalances", () => {
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
captured.key = null;
|
|
50
|
+
captured.fetcher = null;
|
|
51
|
+
getEnsoClient.mockClear();
|
|
52
|
+
getEnsoUserTokensWithBalances.mockClear();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("reads the proxy transport from the SWR key", async () => {
|
|
56
|
+
useEnsoUserTokensWithBalances({ chainId: 80094 });
|
|
57
|
+
|
|
58
|
+
expect(captured.key?.at(-1)).toBe(false);
|
|
59
|
+
expect(captured.fetcher).not.toBeNull();
|
|
60
|
+
|
|
61
|
+
const proxyKey = [...(captured.key ?? [])];
|
|
62
|
+
proxyKey[proxyKey.length - 1] = true;
|
|
63
|
+
await captured.fetcher?.(proxyKey);
|
|
64
|
+
|
|
65
|
+
expect(getEnsoClient).toHaveBeenCalledWith({
|
|
66
|
+
baseURL: "/api/enso",
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|