@berachain/berajs 0.2.13 → 0.3.0
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/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.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 +31 -50
- package/dist/actions/exports.mjs.map +1 -1
- package/dist/actions/governance/exports.mjs +3 -3
- 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/pol/getEarnedStakedBeraVault.d.ts +0 -23
- package/dist/actions/pol/getEarnedStakedBeraVault.d.ts.map +1 -1
- package/dist/actions/pol/getLSTStakeConfig.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/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/getValidatorRewardAllocation.d.ts +4 -0
- package/dist/actions/validators/getValidatorRewardAllocation.d.ts.map +1 -1
- package/dist/{chunk-ZWTGVIPJ.mjs → chunk-4576RF2K.mjs} +29 -4
- package/dist/chunk-4576RF2K.mjs.map +1 -0
- package/dist/{chunk-UA3Z47LT.mjs → chunk-5PBYMJRG.mjs} +95 -24
- package/dist/chunk-5PBYMJRG.mjs.map +1 -0
- package/dist/{chunk-AEN6IJFU.mjs → chunk-7KN7TDUC.mjs} +2 -2
- package/dist/chunk-7OESHTBN.mjs +29 -0
- package/dist/chunk-7OESHTBN.mjs.map +1 -0
- package/dist/{chunk-IFNIPVTZ.mjs → chunk-BSLXKPX4.mjs} +4 -48
- package/dist/chunk-BSLXKPX4.mjs.map +1 -0
- package/dist/{chunk-PHYZRH4I.mjs → chunk-BZKA6DBM.mjs} +9 -13
- package/dist/chunk-BZKA6DBM.mjs.map +1 -0
- package/dist/{chunk-LE4CYW7S.mjs → chunk-FWRYUIJK.mjs} +3 -3
- package/dist/{chunk-PJRLHTGC.mjs → chunk-HPRLNT6R.mjs} +3 -3
- package/dist/chunk-J6GM7HWX.mjs +19 -0
- package/dist/chunk-J6GM7HWX.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-DOZJB6IJ.mjs → chunk-SMBAW7AG.mjs} +394 -344
- package/dist/chunk-SMBAW7AG.mjs.map +1 -0
- 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-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/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/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/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/enso/useBendZapSupply.d.ts +2 -2
- package/dist/hooks/enso/useBendZapSupply.d.ts.map +1 -1
- package/dist/hooks/enso/useEnsoUserTokensWithBalances.d.ts.map +1 -1
- package/dist/hooks/exports.d.ts +2 -5
- package/dist/hooks/exports.d.ts.map +1 -1
- package/dist/hooks/exports.mjs +590 -905
- package/dist/hooks/exports.mjs.map +1 -1
- package/dist/hooks/governance/exports.mjs +4 -4
- package/dist/hooks/honey/useHoneyChartData.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 +2 -2
- package/dist/hooks/pol/useStakedData.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/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.map +1 -1
- package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts +3 -4
- 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/utils/crossChainBridge.d.ts +74 -0
- package/dist/utils/crossChainBridge.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 +8 -6
- 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 +4 -1
- package/src/actions/clients/fetchEnso.ts +48 -0
- package/src/actions/clients/fetchLayerzero.ts +34 -0
- package/src/actions/clients/fetchOpenApi.ts +9 -2
- package/src/actions/clients/fetchOpenApi.unit.test.ts +26 -10
- 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/getHoney24hVolume.ts +3 -12
- package/src/actions/honey/getHoneyCollaterals.ts +1 -1
- package/src/actions/pol/getBeraTokenTotalSupply.ts +3 -33
- package/src/actions/pol/getLSTStakeConfig.ts +0 -6
- package/src/actions/pol/getSWBeraVaultMetadata.ts +2 -106
- package/src/actions/pol/getStakedBeraAPY.ts +45 -0
- package/src/actions/pol/getStakedBeraSnapshots.ts +18 -34
- package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +1 -1
- package/src/actions/validators/getUserActiveValidators.ts +116 -54
- 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/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/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 +4 -2
- package/src/hooks/enso/useBendZapSupply.ts +9 -38
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +10 -2
- package/src/hooks/enso/useZapStakeBera.ts +1 -1
- 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 +13 -14
- 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 +3 -4
- 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/clients/fetchOpenApi.unit.test.d.ts +0 -2
- package/dist/actions/clients/fetchOpenApi.unit.test.d.ts.map +0 -1
- package/dist/actions/dex/__tests__/aggregators.unit.test.d.ts +0 -2
- package/dist/actions/dex/__tests__/aggregators.unit.test.d.ts.map +0 -1
- package/dist/actions/dex/__tests__/allPools.integration.test.d.ts +0 -2
- package/dist/actions/dex/__tests__/allPools.integration.test.d.ts.map +0 -1
- package/dist/actions/dex/__tests__/getOnChainPool.unit.test.d.ts +0 -2
- package/dist/actions/dex/__tests__/getOnChainPool.unit.test.d.ts.map +0 -1
- package/dist/actions/dex/aggregators/enso/ensoErc4626.debug.test.d.ts +0 -2
- package/dist/actions/dex/aggregators/enso/ensoErc4626.debug.test.d.ts.map +0 -1
- package/dist/actions/dex/aggregators/haiku.integration.test.d.ts +0 -2
- package/dist/actions/dex/aggregators/haiku.integration.test.d.ts.map +0 -1
- package/dist/actions/dex/b-sdk.d.ts +0 -3
- package/dist/actions/enso/__tests__/getBendDemultiplyBundle.action.unit.test.d.ts +0 -2
- package/dist/actions/enso/__tests__/getBendDemultiplyBundle.action.unit.test.d.ts.map +0 -1
- package/dist/actions/enso/__tests__/getBendDemultiplyBundle.unit.test.d.ts +0 -2
- package/dist/actions/enso/__tests__/getBendDemultiplyBundle.unit.test.d.ts.map +0 -1
- package/dist/actions/enso/__tests__/getBendMultiplyBundle.action.unit.test.d.ts +0 -2
- package/dist/actions/enso/__tests__/getBendMultiplyBundle.action.unit.test.d.ts.map +0 -1
- package/dist/actions/enso/__tests__/getBendMultiplyBundle.unit.test.d.ts +0 -2
- package/dist/actions/enso/__tests__/getBendMultiplyBundle.unit.test.d.ts.map +0 -1
- package/dist/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.d.ts +0 -2
- package/dist/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.d.ts.map +0 -1
- package/dist/actions/enso/__tests__/util.unit.test.d.ts +0 -2
- package/dist/actions/enso/__tests__/util.unit.test.d.ts.map +0 -1
- package/dist/actions/enso/getEnsoSwapBundle.d.ts +0 -3
- package/dist/actions/enso/getEnsoSwapBundle.d.ts.map +0 -1
- package/dist/actions/governance/__tests__/checkProposalField.unit.test.d.ts +0 -2
- package/dist/actions/governance/__tests__/checkProposalField.unit.test.d.ts.map +0 -1
- package/dist/actions/governance/__tests__/getDecodedFunctionData.integration.test.d.ts +0 -2
- package/dist/actions/governance/__tests__/getDecodedFunctionData.integration.test.d.ts.map +0 -1
- package/dist/actions/governance/__tests__/getQuorum.integration.test.d.ts +0 -2
- package/dist/actions/governance/__tests__/getQuorum.integration.test.d.ts.map +0 -1
- package/dist/actions/honey/tests/pyth.integration.test.d.ts +0 -2
- package/dist/actions/honey/tests/pyth.integration.test.d.ts.map +0 -1
- package/dist/actions/pol/__tests__/getAllValidators.integration.test.d.ts +0 -2
- package/dist/actions/pol/__tests__/getAllValidators.integration.test.d.ts.map +0 -1
- package/dist/actions/pol/__tests__/getValidator.integration.test.d.ts +0 -2
- package/dist/actions/pol/__tests__/getValidator.integration.test.d.ts.map +0 -1
- package/dist/actions/pol/__tests__/rewardVaults.integration.test.d.ts +0 -2
- package/dist/actions/pol/__tests__/rewardVaults.integration.test.d.ts.map +0 -1
- package/dist/actions/pol/getBgtAprSimultaion.unit.test.d.ts +0 -2
- package/dist/actions/pol/getBgtAprSimultaion.unit.test.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/getBlockTime.debug.test.d.ts +0 -2
- package/dist/actions/pol/getBlockTime.debug.test.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/getRewardVaultBeaconImplementation.integration.test.d.ts +0 -2
- package/dist/actions/pol/getRewardVaultBeaconImplementation.integration.test.d.ts.map +0 -1
- package/dist/actions/pol/getRewardVaultDurationConstants.integration.test.d.ts +0 -2
- package/dist/actions/pol/getRewardVaultDurationConstants.integration.test.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/prices/__tests__/prices.integration.test.d.ts +0 -2
- package/dist/actions/prices/__tests__/prices.integration.test.d.ts.map +0 -1
- package/dist/actions/tokens/getWalletBalances.integration.test.d.ts +0 -2
- package/dist/actions/tokens/getWalletBalances.integration.test.d.ts.map +0 -1
- package/dist/actions/transactions/beraWriteContract.integration.test.d.ts +0 -2
- package/dist/actions/transactions/beraWriteContract.integration.test.d.ts.map +0 -1
- package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.integration.test.d.ts +0 -2
- package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.integration.test.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/actions/validators/utils/__tests__/validatorUtils.integration.test.d.ts +0 -2
- package/dist/actions/validators/utils/__tests__/validatorUtils.integration.test.d.ts.map +0 -1
- package/dist/actions/validators/utils/aggregateValidatorIncentives.unit.test.d.ts +0 -2
- package/dist/actions/validators/utils/aggregateValidatorIncentives.unit.test.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/errors/BeraError.unit.test.d.ts +0 -2
- package/dist/errors/BeraError.unit.test.d.ts.map +0 -1
- package/dist/errors/BeraTracing.unit.test.d.ts +0 -2
- package/dist/errors/BeraTracing.unit.test.d.ts.map +0 -1
- package/dist/errors/RequestError.unit.test.d.ts +0 -2
- package/dist/errors/RequestError.unit.test.d.ts.map +0 -1
- package/dist/errors/assert.unit.test.d.ts +0 -2
- package/dist/errors/assert.unit.test.d.ts.map +0 -1
- package/dist/errors/getRevertReason.integration.test.d.ts +0 -2
- package/dist/errors/getRevertReason.integration.test.d.ts.map +0 -1
- package/dist/errors/spanStatus.unit.test.d.ts +0 -2
- package/dist/errors/spanStatus.unit.test.d.ts.map +0 -1
- 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/types/bribeBoost.d.ts +0 -69
- package/dist/types/dex.d.ts +0 -225
- package/dist/types/enso.d.ts +0 -76
- package/dist/types/global.d.ts +0 -198
- package/dist/types/governance.d.ts +0 -112
- package/dist/types/honeySwap.d.ts +0 -23
- package/dist/types/pol.d.ts +0 -78
- package/dist/types/staking.d.ts +0 -22
- package/dist/useHoneySwapState-CXVWAThr.d.ts +0 -32
- package/dist/useHoneySwapState-twi7NTaO.d.ts +0 -32
- package/dist/utils/createEmitter.unit.test.d.ts +0 -2
- package/dist/utils/createEmitter.unit.test.d.ts.map +0 -1
- package/dist/utils/formatIncentivesTokenMap.d.ts +0 -3
- package/dist/utils/formatIncentivesTokenMap.d.ts.map +0 -1
- package/dist/utils/formatNumber.unit.test.d.ts +0 -2
- package/dist/utils/formatNumber.unit.test.d.ts.map +0 -1
- package/dist/utils/formatTimestamps.unit.test.d.ts +0 -2
- package/dist/utils/formatTimestamps.unit.test.d.ts.map +0 -1
- package/dist/utils/getContractName.unit.test.d.ts +0 -2
- package/dist/utils/getContractName.unit.test.d.ts.map +0 -1
- package/dist/utils/getHoneySwapMessage.test.d.ts +0 -2
- package/dist/utils/getHoneySwapMessage.test.d.ts.map +0 -1
- package/dist/utils/layerZeroScan.d.ts +0 -39
- package/dist/utils/layerZeroScan.d.ts.map +0 -1
- package/dist/utils/math.unit.test.d.ts +0 -2
- package/dist/utils/math.unit.test.d.ts.map +0 -1
- package/dist/utils/parseBaseArgs.unit.test.d.ts +0 -2
- package/dist/utils/parseBaseArgs.unit.test.d.ts.map +0 -1
- package/dist/utils/polyfillAbortSignalAny.unit.test.d.ts +0 -2
- package/dist/utils/polyfillAbortSignalAny.unit.test.d.ts.map +0 -1
- package/dist/utils/time.unit.test.d.ts +0 -2
- package/dist/utils/time.unit.test.d.ts.map +0 -1
- package/dist/utils/tokens.unit.test.d.ts +0 -2
- package/dist/utils/tokens.unit.test.d.ts.map +0 -1
- package/dist/utils/truncateHash.unit.test.d.ts +0 -2
- package/dist/utils/truncateHash.unit.test.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
|
@@ -3,13 +3,14 @@ import { HttpLink } from "@apollo/client/link/http";
|
|
|
3
3
|
|
|
4
4
|
import type { HttpLink as BeraConfigHttpLink } from "@berachain/config";
|
|
5
5
|
import { getUriFromLink } from "@berachain/config";
|
|
6
|
-
import {
|
|
6
|
+
import { goldskyBaseUrl } from "@berachain/config/internal";
|
|
7
7
|
|
|
8
8
|
import apiResults from "@berachain/graphql/dex/api";
|
|
9
9
|
|
|
10
10
|
import { BeraError } from "../../errors/BeraError";
|
|
11
11
|
import { parseBaseArgs } from "../../utils/parseBaseArgs";
|
|
12
12
|
import { BeraApolloClient } from "./BeraApolloClient";
|
|
13
|
+
import { getClientName } from "./clientName";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* If currentDapp is set, it will add the stellate client name and version to the headers.
|
|
@@ -17,8 +18,6 @@ import { BeraApolloClient } from "./BeraApolloClient";
|
|
|
17
18
|
*/
|
|
18
19
|
function applyStellateClientName(url: BeraConfigHttpLink): BeraConfigHttpLink {
|
|
19
20
|
const headers = typeof url === "string" ? undefined : url.headers;
|
|
20
|
-
const isDapp = !!currentDapp;
|
|
21
|
-
const isTest = process.env.VERCEL_ENV === "test";
|
|
22
21
|
|
|
23
22
|
const uri = getUriFromLink(url);
|
|
24
23
|
const name = typeof url === "string" ? "unknown" : url.name;
|
|
@@ -28,14 +27,7 @@ function applyStellateClientName(url: BeraConfigHttpLink): BeraConfigHttpLink {
|
|
|
28
27
|
name,
|
|
29
28
|
headers: {
|
|
30
29
|
...headers,
|
|
31
|
-
"x-graphql-client-name":
|
|
32
|
-
isDapp
|
|
33
|
-
? "dapps"
|
|
34
|
-
: isTest
|
|
35
|
-
? "test"
|
|
36
|
-
: // this tracks usage of the berajs package in other packages
|
|
37
|
-
"berajs"
|
|
38
|
-
}`,
|
|
30
|
+
"x-graphql-client-name": getClientName(),
|
|
39
31
|
"x-graphql-client-version": `${process.env.VERCEL_TARGET_ENV}.${process.env.VERCEL_GIT_COMMIT_SHA}`,
|
|
40
32
|
},
|
|
41
33
|
};
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, test } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { ChainId } from "@berachain/config/internal";
|
|
3
|
+
import { ChainId, chainConfigs } from "@berachain/config/internal";
|
|
4
4
|
|
|
5
5
|
import { Aggregators } from "../../../enum/dex";
|
|
6
6
|
import { BeraError } from "../../../errors/BeraError";
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
IAggregatorArgs,
|
|
9
|
+
IRawAggregatorQuote,
|
|
10
|
+
MinimalERC20,
|
|
11
|
+
} from "../../../types/dex";
|
|
8
12
|
import { BaseAggregator } from "../aggregators/base";
|
|
13
|
+
import { bex } from "../aggregators/bex";
|
|
14
|
+
import { enso } from "../aggregators/enso/enso";
|
|
15
|
+
import { ensoErc4626 } from "../aggregators/enso/ensoErc4626";
|
|
16
|
+
import { haiku } from "../aggregators/haiku";
|
|
17
|
+
import { wberaSwap } from "../aggregators/wbera";
|
|
9
18
|
|
|
10
19
|
// Test implementation of BaseAggregator to access protected methods
|
|
11
20
|
class TestAggregator extends BaseAggregator {
|
|
@@ -107,3 +116,223 @@ describe("BaseAggregator.getAmountAfterFees", () => {
|
|
|
107
116
|
expect(result).toBe("996");
|
|
108
117
|
});
|
|
109
118
|
});
|
|
119
|
+
|
|
120
|
+
describe("BexAggregator.getUnsupportedReason opt-outs (HUB-A6D, HUB-A5R)", () => {
|
|
121
|
+
function token(
|
|
122
|
+
decimals: number,
|
|
123
|
+
address = "0x0000000000000000000000000000000000000001",
|
|
124
|
+
): MinimalERC20 {
|
|
125
|
+
return {
|
|
126
|
+
address: address as `0x${string}`,
|
|
127
|
+
decimals,
|
|
128
|
+
symbol: "TKN",
|
|
129
|
+
name: "Token",
|
|
130
|
+
chainId: ChainId.MAINNET,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const bgt = token(18, chainConfigs[ChainId.MAINNET].tokens.bgt);
|
|
135
|
+
const tokenA = token(18, "0x0000000000000000000000000000000000000001");
|
|
136
|
+
const tokenB = token(6, "0x0000000000000000000000000000000000000002");
|
|
137
|
+
|
|
138
|
+
test("supports a normal 0–18 decimal pair", () => {
|
|
139
|
+
expect(
|
|
140
|
+
bex.getUnsupportedReason({ tokenIn: tokenA, tokenOut: tokenB }),
|
|
141
|
+
).toBeNull();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// b-sdk's `TokenAmount` scales by `pow10[18 - decimals]`; a token with >18
|
|
145
|
+
// decimals (e.g. 27-decimal ctBeraUSDe) or non-integer decimals throws
|
|
146
|
+
// "Cannot mix BigInt and other types".
|
|
147
|
+
test("rejects a token with >18 decimals", () => {
|
|
148
|
+
const highDecimals = token(
|
|
149
|
+
27,
|
|
150
|
+
"0x0000000000000000000000000000000000000003",
|
|
151
|
+
);
|
|
152
|
+
expect(
|
|
153
|
+
bex.getUnsupportedReason({ tokenIn: highDecimals, tokenOut: tokenB }),
|
|
154
|
+
).not.toBeNull();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("rejects a token with non-integer decimals", () => {
|
|
158
|
+
const nanDecimals = token(
|
|
159
|
+
Number.NaN,
|
|
160
|
+
"0x0000000000000000000000000000000000000004",
|
|
161
|
+
);
|
|
162
|
+
expect(
|
|
163
|
+
bex.getUnsupportedReason({ tokenIn: tokenA, tokenOut: nanDecimals }),
|
|
164
|
+
).not.toBeNull();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// BGT has no Balancer pool (redeemed via the BGT aggregator), so a bex quote
|
|
168
|
+
// always throws NO_SWAP_PATHS — opt out whether it's in or out.
|
|
169
|
+
test("rejects BGT as tokenIn", () => {
|
|
170
|
+
expect(
|
|
171
|
+
bex.getUnsupportedReason({ tokenIn: bgt, tokenOut: token(18) }),
|
|
172
|
+
).not.toBeNull();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("rejects BGT as tokenOut", () => {
|
|
176
|
+
expect(
|
|
177
|
+
bex.getUnsupportedReason({ tokenIn: token(18), tokenOut: bgt }),
|
|
178
|
+
).not.toBeNull();
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe("getUnsupportedReason BERA↔WBERA normalization (HUB-9FQ)", () => {
|
|
183
|
+
function token(address: string): MinimalERC20 {
|
|
184
|
+
return {
|
|
185
|
+
address: address as `0x${string}`,
|
|
186
|
+
decimals: 18,
|
|
187
|
+
symbol: "TKN",
|
|
188
|
+
name: "Token",
|
|
189
|
+
chainId: ChainId.MAINNET,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const bera = token("0x0000000000000000000000000000000000000000");
|
|
194
|
+
const wbera = token(chainConfigs[ChainId.MAINNET].tokens.wbera);
|
|
195
|
+
const honey = token(chainConfigs[ChainId.MAINNET].honey.token);
|
|
196
|
+
|
|
197
|
+
// Aggregators that normalize native BERA → WBERA collapse this pair to
|
|
198
|
+
// WBERA↔WBERA — the router 400s with "tokenIn and tokenOut cannot be the
|
|
199
|
+
// same". supportsBeraWrap is false for these, so the base gate rejects it.
|
|
200
|
+
test("rejects native BERA against WBERA for non-wrap aggregators", () => {
|
|
201
|
+
expect(
|
|
202
|
+
enso.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
|
|
203
|
+
).not.toBeNull();
|
|
204
|
+
expect(
|
|
205
|
+
enso.getUnsupportedReason({ tokenIn: wbera, tokenOut: bera }),
|
|
206
|
+
).not.toBeNull();
|
|
207
|
+
expect(
|
|
208
|
+
bex.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
|
|
209
|
+
).not.toBeNull();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// The wrap/unwrap aggregator sets supportsBeraWrap, so it still accepts it.
|
|
213
|
+
test("keeps supporting BERA↔WBERA for the wrap aggregator", () => {
|
|
214
|
+
expect(
|
|
215
|
+
wberaSwap.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
|
|
216
|
+
).toBeNull();
|
|
217
|
+
expect(
|
|
218
|
+
wberaSwap.getUnsupportedReason({ tokenIn: wbera, tokenOut: bera }),
|
|
219
|
+
).toBeNull();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("still supports a normal distinct pair", () => {
|
|
223
|
+
expect(
|
|
224
|
+
enso.getUnsupportedReason({ tokenIn: wbera, tokenOut: honey }),
|
|
225
|
+
).toBeNull();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// getUnsupportedReason carries the reason; assertChainSupport used to throw a
|
|
229
|
+
// misleading "does not support chain ID" — it now surfaces the real reason.
|
|
230
|
+
test("carries an accurate BERA↔WBERA reason", () => {
|
|
231
|
+
expect(
|
|
232
|
+
enso.getUnsupportedReason({ tokenIn: bera, tokenOut: wbera }),
|
|
233
|
+
).toMatch(/BERA and WBERA/);
|
|
234
|
+
expect(() =>
|
|
235
|
+
enso.assertChainSupport({ tokenIn: bera, tokenOut: wbera }),
|
|
236
|
+
).toThrow(/BERA and WBERA/);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Haiku's zap-haiku proxy key is restricted and 400s on reward-vault staking
|
|
241
|
+
// (HUB-9FN/HUB-9FR). Opt out up-front so the quote hook never fires the request.
|
|
242
|
+
describe("HaikuAggregator.getUnsupportedReason — reward-vault staking", () => {
|
|
243
|
+
function token(address: string): MinimalERC20 {
|
|
244
|
+
return {
|
|
245
|
+
address: address as `0x${string}`,
|
|
246
|
+
decimals: 18,
|
|
247
|
+
symbol: "TKN",
|
|
248
|
+
name: "Token",
|
|
249
|
+
chainId: ChainId.MAINNET,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const tokenA = token("0x0000000000000000000000000000000000000001");
|
|
254
|
+
const tokenB = token("0x0000000000000000000000000000000000000002");
|
|
255
|
+
const rewardVault = "0x0000000000000000000000000000000000000003" as const;
|
|
256
|
+
|
|
257
|
+
test("rejects a reward-vault zap", () => {
|
|
258
|
+
expect(
|
|
259
|
+
haiku.getUnsupportedReason({
|
|
260
|
+
tokenIn: tokenA,
|
|
261
|
+
tokenOut: tokenB,
|
|
262
|
+
rewardVault,
|
|
263
|
+
}),
|
|
264
|
+
).not.toBeNull();
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test("still supports a normal swap (no reward vault)", () => {
|
|
268
|
+
expect(
|
|
269
|
+
haiku.getUnsupportedReason({ tokenIn: tokenA, tokenOut: tokenB }),
|
|
270
|
+
).toBeNull();
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// A cross-chain pair (tokenIn.chainId !== tokenOut.chainId) is rejected up-front
|
|
275
|
+
// unless the aggregator sets supportsBridging, so the swap-page fan-out can be
|
|
276
|
+
// handed multichain pairs safely.
|
|
277
|
+
describe("getUnsupportedReason cross-chain routing", () => {
|
|
278
|
+
// supportedChains: null isolates the bridging gate from the chain-support gate.
|
|
279
|
+
class NonBridgingAggregator extends BaseAggregator {
|
|
280
|
+
name = Aggregators.Fly;
|
|
281
|
+
readonly type = "rest";
|
|
282
|
+
supportedChains = null;
|
|
283
|
+
|
|
284
|
+
async getQuote(_args: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
285
|
+
throw new Error("Not implemented for testing");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const singleChain = new NonBridgingAggregator();
|
|
289
|
+
|
|
290
|
+
function token(chainId: number, address: string): MinimalERC20 {
|
|
291
|
+
return {
|
|
292
|
+
address: address as `0x${string}`,
|
|
293
|
+
decimals: 18,
|
|
294
|
+
symbol: "TKN",
|
|
295
|
+
name: "Token",
|
|
296
|
+
chainId,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const beraToken = token(
|
|
301
|
+
ChainId.MAINNET,
|
|
302
|
+
"0x0000000000000000000000000000000000000001",
|
|
303
|
+
);
|
|
304
|
+
const foreignToken = token(
|
|
305
|
+
ChainId.BEPOLIA,
|
|
306
|
+
"0x0000000000000000000000000000000000000002",
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
test("rejects a cross-chain pair on a non-cross-chain aggregator", () => {
|
|
310
|
+
expect(
|
|
311
|
+
singleChain.getUnsupportedReason({
|
|
312
|
+
tokenIn: foreignToken,
|
|
313
|
+
tokenOut: beraToken,
|
|
314
|
+
}),
|
|
315
|
+
).toMatch(/cannot route across chains/);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test("allows the same cross-chain pair on ensoErc4626", () => {
|
|
319
|
+
expect(
|
|
320
|
+
ensoErc4626.getUnsupportedReason({
|
|
321
|
+
tokenIn: foreignToken,
|
|
322
|
+
tokenOut: beraToken,
|
|
323
|
+
}),
|
|
324
|
+
).toBeNull();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("still allows a same-chain pair on a non-cross-chain aggregator", () => {
|
|
328
|
+
expect(
|
|
329
|
+
singleChain.getUnsupportedReason({
|
|
330
|
+
tokenIn: beraToken,
|
|
331
|
+
tokenOut: token(
|
|
332
|
+
ChainId.MAINNET,
|
|
333
|
+
"0x0000000000000000000000000000000000000003",
|
|
334
|
+
),
|
|
335
|
+
}),
|
|
336
|
+
).toBeNull();
|
|
337
|
+
});
|
|
338
|
+
});
|
|
@@ -30,6 +30,28 @@ export abstract class BaseAggregator {
|
|
|
30
30
|
needsAccountForQuote: boolean = false;
|
|
31
31
|
notFoundMessages: string[] = [];
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Whether this aggregator can handle a BERA↔WBERA pair.
|
|
35
|
+
*
|
|
36
|
+
* Most aggregators normalize native BERA → WBERA before routing (see
|
|
37
|
+
* `parseAddresses`), so a BERA↔WBERA pair collapses to WBERA↔WBERA and the
|
|
38
|
+
* external router rejects it as "same token" (e.g. Enso 400, HUB-9FQ). For
|
|
39
|
+
* those, `getUnsupportedReason` rejects the pair up-front so no request fires.
|
|
40
|
+
* Only the dedicated wrap/unwrap aggregator sets this `true`.
|
|
41
|
+
*/
|
|
42
|
+
supportsBeraWrap: boolean = false;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether this aggregator can bridge — route a pair whose tokens live on
|
|
46
|
+
* different chains (`tokenIn.chainId !== tokenOut.chainId`).
|
|
47
|
+
*
|
|
48
|
+
* Most aggregators only route within a single chain; handed a cross-chain
|
|
49
|
+
* pair they would 400 or, worse, quote garbage against the wrong chain.
|
|
50
|
+
* `getUnsupportedReason` rejects such pairs up-front unless this is `true`.
|
|
51
|
+
* Only bridging aggregators (Enso via LayerZero) set it.
|
|
52
|
+
*/
|
|
53
|
+
supportsBridging: boolean = false;
|
|
54
|
+
|
|
33
55
|
config: BeraConfig;
|
|
34
56
|
|
|
35
57
|
chainId: ChainId;
|
|
@@ -48,9 +70,7 @@ export abstract class BaseAggregator {
|
|
|
48
70
|
|
|
49
71
|
abstract getQuote(
|
|
50
72
|
args: IAggregatorArgs,
|
|
51
|
-
):
|
|
52
|
-
| Promise<IRawAggregatorQuote | undefined>
|
|
53
|
-
| Promise<IRawAggregatorQuote | undefined>;
|
|
73
|
+
): Promise<IRawAggregatorQuote | undefined>;
|
|
54
74
|
|
|
55
75
|
/**
|
|
56
76
|
* return wbera for native tokens to accomodate the aggregator's router logic
|
|
@@ -172,9 +192,12 @@ export abstract class BaseAggregator {
|
|
|
172
192
|
}
|
|
173
193
|
|
|
174
194
|
/**
|
|
175
|
-
*
|
|
195
|
+
* Returns a human-readable reason this aggregator can't route the pair, or
|
|
196
|
+
* `null` if it can. Callers gate on `=== null`; `assertChainSupport` throws
|
|
197
|
+
* the reason so users get an accurate message (not a misleading "does not
|
|
198
|
+
* support chain ID" for what is actually a same-token pair).
|
|
176
199
|
*/
|
|
177
|
-
|
|
200
|
+
getUnsupportedReason({
|
|
178
201
|
tokenIn,
|
|
179
202
|
tokenOut,
|
|
180
203
|
}: {
|
|
@@ -184,31 +207,66 @@ export abstract class BaseAggregator {
|
|
|
184
207
|
honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
|
|
185
208
|
// needed in ERC4626 aggregator
|
|
186
209
|
underlyingToken?: Token | null;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
210
|
+
// needed in haiku aggregator (reward-vault staking opt-out)
|
|
211
|
+
rewardVault?: Address;
|
|
212
|
+
}): string | null {
|
|
213
|
+
if (isToken(tokenIn, tokenOut)) {
|
|
214
|
+
// same token route don't make sense (we're not arbitraging here), so we don't support it
|
|
215
|
+
return `${this.name} cannot route between the same token (${tokenIn.symbol}).`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Reject pairs that collapse to the same token once native BERA is
|
|
219
|
+
// normalized to WBERA (e.g. BERA↔WBERA), unless this aggregator explicitly
|
|
220
|
+
// handles wrapping. Otherwise the router 400s on identical tokens (HUB-9FQ).
|
|
221
|
+
if (!this.supportsBeraWrap) {
|
|
222
|
+
const wbera = this.config.tokens.wbera;
|
|
223
|
+
function normalize(token: Token) {
|
|
224
|
+
return (isToken(token, "BERA") ? wbera : token.address).toLowerCase();
|
|
225
|
+
}
|
|
226
|
+
if (normalize(tokenIn) === normalize(tokenOut)) {
|
|
227
|
+
return `${this.name} cannot route between BERA and WBERA — use wrap/unwrap instead.`;
|
|
228
|
+
}
|
|
190
229
|
}
|
|
191
230
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
)
|
|
231
|
+
// Reject cross-chain pairs unless this aggregator can bridge. Making the
|
|
232
|
+
// rejection explicit (rather than relying on `supportedChains`) lets the
|
|
233
|
+
// swap-page fan-out be handed multichain pairs safely.
|
|
234
|
+
if (tokenIn.chainId !== tokenOut.chainId && !this.supportsBridging) {
|
|
235
|
+
return `${this.name} cannot route across chains (${tokenIn.chainId} → ${tokenOut.chainId}).`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (
|
|
239
|
+
this.supportedChains !== null &&
|
|
240
|
+
(!this.supportedChains.includes(tokenIn.chainId) ||
|
|
241
|
+
!this.supportedChains.includes(tokenOut.chainId))
|
|
242
|
+
) {
|
|
243
|
+
return `${this.name} does not support tokens chain ID: ${tokenIn.chainId} and ${tokenOut.chainId}`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return null;
|
|
196
247
|
}
|
|
197
248
|
|
|
198
249
|
assertChainSupport({
|
|
199
250
|
tokenIn,
|
|
200
251
|
tokenOut,
|
|
201
252
|
underlyingToken,
|
|
253
|
+
honeyNativeState,
|
|
202
254
|
}: {
|
|
203
255
|
tokenIn: Token;
|
|
204
256
|
tokenOut: Token;
|
|
257
|
+
// needed in ERC4626 aggregator
|
|
205
258
|
underlyingToken?: Token | null;
|
|
259
|
+
// needed in honey native aggregator
|
|
260
|
+
honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
|
|
206
261
|
}): void {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
262
|
+
const reason = this.getUnsupportedReason({
|
|
263
|
+
tokenIn,
|
|
264
|
+
tokenOut,
|
|
265
|
+
underlyingToken,
|
|
266
|
+
honeyNativeState,
|
|
267
|
+
});
|
|
268
|
+
if (reason !== null) {
|
|
269
|
+
throw new BeraError({ message: reason, level: "error" });
|
|
212
270
|
}
|
|
213
271
|
}
|
|
214
272
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Address,
|
|
3
|
+
DECIMAL_SCALES,
|
|
3
4
|
Slippage,
|
|
4
5
|
type SorSwapResult,
|
|
5
6
|
Swap,
|
|
@@ -19,7 +20,11 @@ import { assertPublicClient } from "../../../errors/assert";
|
|
|
19
20
|
import { BeraError } from "../../../errors/BeraError";
|
|
20
21
|
import { BeraMonitoring } from "../../../errors/BeraMonitoring";
|
|
21
22
|
import { RequestError } from "../../../errors/RequestError";
|
|
22
|
-
import type {
|
|
23
|
+
import type {
|
|
24
|
+
Token as BeraToken,
|
|
25
|
+
IAggregatorArgs,
|
|
26
|
+
IRawAggregatorQuote,
|
|
27
|
+
} from "../../../types/dex";
|
|
23
28
|
import { isToken } from "../../../utils/tokens";
|
|
24
29
|
import { BalancerApi } from "../bSdk";
|
|
25
30
|
import { BaseAggregator } from "./base";
|
|
@@ -35,6 +40,40 @@ class BexAggregator extends BaseAggregator {
|
|
|
35
40
|
readonly url = getUriFromLink(this.config.api);
|
|
36
41
|
readonly type = "graphql";
|
|
37
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Opt bex out of tokens it structurally can't route (BGT, or decimals
|
|
45
|
+
* outside b-sdk's supported range) so the quote is never requested and other
|
|
46
|
+
* aggregators still handle it — see `supportsToken` for the specifics.
|
|
47
|
+
*/
|
|
48
|
+
getUnsupportedReason(args: {
|
|
49
|
+
tokenIn: BeraToken;
|
|
50
|
+
tokenOut: BeraToken;
|
|
51
|
+
}): string | null {
|
|
52
|
+
const base = super.getUnsupportedReason(args);
|
|
53
|
+
if (base !== null) {
|
|
54
|
+
return base;
|
|
55
|
+
}
|
|
56
|
+
for (const token of [args.tokenIn, args.tokenOut]) {
|
|
57
|
+
if (!this.supportsToken(token)) {
|
|
58
|
+
return `${this.name} can't route ${token.symbol} (BGT or unsupported decimals).`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private supportsToken(token: BeraToken) {
|
|
65
|
+
// BGT has no Balancer pool (it's redeemed via the BGT aggregator, not
|
|
66
|
+
// swapped), so a bex quote for it always throws NO_SWAP_PATHS (HUB-A5R).
|
|
67
|
+
if (isToken(token.address, "BGT", { config: this.config })) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// b-sdk's `TokenAmount` scales via `DECIMAL_SCALES[18 - decimals]`; a token
|
|
71
|
+
// outside that 0–18 table (e.g. 27-decimal ctBeraUSDe) throws "Cannot mix
|
|
72
|
+
// BigInt and other types" (HUB-A6D). Mirror the exact lookup so this tracks
|
|
73
|
+
// b-sdk if the supported range ever changes.
|
|
74
|
+
const scaleKey = 18 - token.decimals;
|
|
75
|
+
return scaleKey in DECIMAL_SCALES;
|
|
76
|
+
}
|
|
38
77
|
/**
|
|
39
78
|
* Helper function to convert zero address to wrapped token address
|
|
40
79
|
*/
|
|
@@ -220,6 +259,7 @@ class BexAggregator extends BaseAggregator {
|
|
|
220
259
|
abi: balancerVaultAbi,
|
|
221
260
|
address: callData.to,
|
|
222
261
|
value: callData.value || BigInt(0),
|
|
262
|
+
extraTags: { aggregator: this.name },
|
|
223
263
|
};
|
|
224
264
|
},
|
|
225
265
|
};
|
|
@@ -15,23 +15,28 @@ class RedeemBgtAggregator extends BaseAggregator {
|
|
|
15
15
|
supportedChains = [ChainId.MAINNET, ChainId.BEPOLIA];
|
|
16
16
|
readonly type = "rpc";
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
getUnsupportedReason({
|
|
19
19
|
tokenIn,
|
|
20
20
|
tokenOut,
|
|
21
21
|
}: {
|
|
22
22
|
tokenIn: MinimalERC20;
|
|
23
23
|
tokenOut: MinimalERC20;
|
|
24
|
-
}):
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
}): string | null {
|
|
25
|
+
const base = super.getUnsupportedReason({ tokenIn, tokenOut });
|
|
26
|
+
if (base !== null) {
|
|
27
|
+
return base;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
if (
|
|
30
31
|
// only supported on same chain
|
|
31
32
|
tokenIn.chainId === tokenOut.chainId &&
|
|
32
33
|
isToken(tokenIn, "BGT", { chainId: tokenIn.chainId }) &&
|
|
33
34
|
isToken(tokenOut, "BERA")
|
|
34
|
-
)
|
|
35
|
+
) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `${this.name} only redeems BGT → BERA on the same chain.`;
|
|
35
40
|
}
|
|
36
41
|
// handles native swaps: wrap and unwrap
|
|
37
42
|
async getQuote({
|
|
@@ -121,6 +121,7 @@ class EnsoAggregator extends BaseAggregator {
|
|
|
121
121
|
},
|
|
122
122
|
],
|
|
123
123
|
functionName: "swap",
|
|
124
|
+
extraTags: { aggregator: this.name },
|
|
124
125
|
abi: aggregatorsRouterAbi,
|
|
125
126
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
126
127
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
@@ -13,6 +13,7 @@ import { BaseAggregator } from "../base";
|
|
|
13
13
|
class EnsoErc4626Aggregator extends BaseAggregator {
|
|
14
14
|
name = Aggregators.EnsoErc4626;
|
|
15
15
|
supportedChains = null;
|
|
16
|
+
supportsBridging = true;
|
|
16
17
|
readonly type = "rest";
|
|
17
18
|
needsAccountForQuote = true;
|
|
18
19
|
|
|
@@ -53,6 +54,11 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
53
54
|
*/
|
|
54
55
|
const zapTokenOut = underlyingToken ?? tokenOut;
|
|
55
56
|
|
|
57
|
+
// Single source of truth for whether this route bridges: the route action
|
|
58
|
+
// gets a `destinationChainId` (LayerZero) exactly when this is true, and it
|
|
59
|
+
// is stamped onto the returned quote so consumers stop re-deriving it.
|
|
60
|
+
const isCrossChain = tokenIn.chainId !== zapTokenOut.chainId;
|
|
61
|
+
|
|
56
62
|
const bundleActions: BundleAction[] = [
|
|
57
63
|
// this is the base route action, which will swap the token in to the zap token out
|
|
58
64
|
// it handles cross-chain swaps and refunds the user if the swap fails
|
|
@@ -63,14 +69,15 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
63
69
|
args: {
|
|
64
70
|
tokenIn: tokenIn.address,
|
|
65
71
|
tokenOut: zapTokenOut.address,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
tokenIn.chainId === zapTokenOut.chainId
|
|
69
|
-
? undefined
|
|
70
|
-
: zapTokenOut.chainId,
|
|
72
|
+
// must be undefined if the token is the same chain
|
|
73
|
+
destinationChainId: isCrossChain ? zapTokenOut.chainId : undefined,
|
|
71
74
|
refundReceiver: account,
|
|
75
|
+
receiver: account,
|
|
72
76
|
amountIn: amount,
|
|
73
77
|
slippage: slippage * 100, // Enso expects slippage in basis points
|
|
78
|
+
// We can't track CCIP delivery status (no poller in crossChainBridge),
|
|
79
|
+
// so keep Enso from routing cross-chain zaps through it.
|
|
80
|
+
ignoreBridges: isCrossChain ? ["ccip"] : undefined,
|
|
74
81
|
},
|
|
75
82
|
},
|
|
76
83
|
];
|
|
@@ -143,14 +150,21 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
143
150
|
bundleActions,
|
|
144
151
|
);
|
|
145
152
|
|
|
153
|
+
// Enso picks the bridge per-route (relay/stargate/ccip); it reports the
|
|
154
|
+
// choice on the route hop whose action is "bridge". The tracker needs this
|
|
155
|
+
// to know which explorer + status API to hit.
|
|
156
|
+
const bridgeProtocol = bundle.route?.find(
|
|
157
|
+
(hop) => hop.action === "bridge",
|
|
158
|
+
)?.protocol;
|
|
159
|
+
|
|
146
160
|
const tokenOutAddress = (rewardVault?.toLowerCase() ??
|
|
147
161
|
tokenOut.address.toLowerCase()) as Address;
|
|
148
162
|
|
|
149
|
-
const amountOut =
|
|
150
|
-
// @ts-expect-error enso has not typed this but is returned sometimes from API.
|
|
163
|
+
const amountOut = String(
|
|
151
164
|
bundle.minAmountsOut?.[tokenOutAddress] ??
|
|
152
|
-
|
|
153
|
-
|
|
165
|
+
bundle.amountsOut?.[tokenOutAddress] ??
|
|
166
|
+
"0",
|
|
167
|
+
);
|
|
154
168
|
|
|
155
169
|
return {
|
|
156
170
|
amountOut,
|
|
@@ -162,6 +176,9 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
162
176
|
}),
|
|
163
177
|
name: this.name,
|
|
164
178
|
swapFeeBps: 0,
|
|
179
|
+
isCrossChain,
|
|
180
|
+
srcChainId: tokenIn.chainId,
|
|
181
|
+
bridgeProtocol,
|
|
165
182
|
priceImpactPercentage: bundle.priceImpact
|
|
166
183
|
? bundle.priceImpact / 100
|
|
167
184
|
: null,
|
|
@@ -169,6 +186,7 @@ class EnsoErc4626Aggregator extends BaseAggregator {
|
|
|
169
186
|
address: bundle.tx.to,
|
|
170
187
|
data: bundle.tx.data as Hex,
|
|
171
188
|
value: BigInt(bundle.tx.value ?? 0),
|
|
189
|
+
extraTags: { aggregator: this.name },
|
|
172
190
|
// not returning gas limit because it's usually underestimated by enso.
|
|
173
191
|
// gasLimit: BigInt(bundle.gas),
|
|
174
192
|
}),
|
|
@@ -30,7 +30,7 @@ class ERC4626Aggregator extends BaseAggregator {
|
|
|
30
30
|
* Returns true when tokenOut is an ERC4626 vault whose underlying asset matches tokenIn,
|
|
31
31
|
* or when depositing native BERA into swBERA.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
getUnsupportedReason({
|
|
34
34
|
tokenIn,
|
|
35
35
|
tokenOut,
|
|
36
36
|
underlyingToken,
|
|
@@ -38,16 +38,28 @@ class ERC4626Aggregator extends BaseAggregator {
|
|
|
38
38
|
tokenIn: Token;
|
|
39
39
|
tokenOut: Token;
|
|
40
40
|
underlyingToken?: Token;
|
|
41
|
-
}):
|
|
42
|
-
const
|
|
43
|
-
|
|
41
|
+
}): string | null {
|
|
42
|
+
const base = super.getUnsupportedReason({
|
|
43
|
+
tokenIn,
|
|
44
|
+
tokenOut,
|
|
45
|
+
underlyingToken,
|
|
46
|
+
});
|
|
47
|
+
if (base !== null) {
|
|
48
|
+
return base;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isVaultDeposit =
|
|
44
52
|
!!underlyingToken &&
|
|
45
53
|
underlyingToken?.chainId === tokenOut.chainId &&
|
|
46
54
|
(isToken(underlyingToken, tokenIn) ||
|
|
47
55
|
// this is a special case for the swbera vault
|
|
48
56
|
(isToken(tokenIn, "BERA") && isToken(tokenOut, "SWBERA")));
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
if (isVaultDeposit) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return `${this.name} only deposits a token into its matching ERC4626 vault.`;
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
/**
|
|
@@ -105,6 +117,7 @@ class ERC4626Aggregator extends BaseAggregator {
|
|
|
105
117
|
functionName: "depositNative",
|
|
106
118
|
params: [BigInt(amount), account],
|
|
107
119
|
value: BigInt(amount),
|
|
120
|
+
extraTags: { aggregator: this.name },
|
|
108
121
|
} satisfies Omit<
|
|
109
122
|
IContractWrite<typeof stakeBeraVaultAbi, "depositNative">,
|
|
110
123
|
"message" | "actionType"
|
|
@@ -116,6 +129,7 @@ class ERC4626Aggregator extends BaseAggregator {
|
|
|
116
129
|
contractName: ContractName.ERC4626,
|
|
117
130
|
params: [BigInt(amount), account],
|
|
118
131
|
value: 0n,
|
|
132
|
+
extraTags: { aggregator: this.name },
|
|
119
133
|
} satisfies Omit<
|
|
120
134
|
IContractWrite<typeof erc4626Abi, "deposit">,
|
|
121
135
|
"message" | "actionType"
|
|
@@ -131,6 +131,7 @@ class FlyAggregator extends BaseAggregator {
|
|
|
131
131
|
},
|
|
132
132
|
],
|
|
133
133
|
functionName: "swap",
|
|
134
|
+
extraTags: { aggregator: this.name },
|
|
134
135
|
abi: aggregatorsRouterAbi,
|
|
135
136
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
136
137
|
value: isToken(tokenIn, "BERA") ? BigInt(amount) : BigInt("0"),
|