@berachain/berajs 0.1.1 → 0.1.2
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/{dex-BaNHEuck.d.cts → HoneyConfigProvider-6PXZJMSU.d.cts} +171 -171
- package/dist/{dex-D6IK-4D9.d.ts → HoneyConfigProvider-CwDFrt02.d.ts} +171 -171
- package/dist/abi/index.cjs +1 -1
- package/dist/abi/index.cjs.map +1 -1
- package/dist/abi/index.mjs +1 -1
- package/dist/actions/index.cjs +1 -1
- package/dist/actions/index.d.cts +7 -7
- package/dist/actions/index.d.ts +7 -7
- package/dist/actions/index.mjs +1 -1
- package/dist/chunk-22MQVFHP.cjs +2 -0
- package/dist/chunk-22MQVFHP.cjs.map +1 -0
- package/dist/chunk-3TKSVFZ3.mjs +2 -0
- package/dist/chunk-3TKSVFZ3.mjs.map +1 -0
- package/dist/{chunk-GZ5YA2AZ.cjs → chunk-6VF3RF53.cjs} +3 -3
- package/dist/{chunk-GZ5YA2AZ.cjs.map → chunk-6VF3RF53.cjs.map} +1 -1
- package/dist/{chunk-3WCYP277.mjs → chunk-AMRJ4B36.mjs} +2 -2
- package/dist/chunk-EU4WFADK.cjs +2 -0
- package/dist/chunk-EU4WFADK.cjs.map +1 -0
- package/dist/{chunk-ZLCBHOSV.mjs → chunk-KMKUXP2S.mjs} +3 -3
- package/dist/chunk-OJXJ6CZ4.mjs +4 -0
- package/dist/{chunk-M5GUTM7K.mjs.map → chunk-OJXJ6CZ4.mjs.map} +1 -1
- package/dist/{chunk-V3PCHP2D.cjs → chunk-REDXXUK7.cjs} +2 -2
- package/dist/{chunk-V3PCHP2D.cjs.map → chunk-REDXXUK7.cjs.map} +1 -1
- package/dist/chunk-VYWYJR63.mjs +2 -0
- package/dist/chunk-VYWYJR63.mjs.map +1 -0
- package/dist/{chunk-GWBENQEV.cjs → chunk-XFPTQMAK.cjs} +3 -3
- package/dist/{chunk-GWBENQEV.cjs.map → chunk-XFPTQMAK.cjs.map} +1 -1
- package/dist/contexts/index.cjs +1 -1
- package/dist/contexts/index.d.cts +3 -3
- package/dist/contexts/index.d.ts +3 -3
- package/dist/contexts/index.mjs +1 -1
- package/dist/{getValidatorQueuedOperatorAddress-BhPVMCTj.d.ts → getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts} +2 -2
- package/dist/{getValidatorQueuedOperatorAddress-Cmd7rgYK.d.cts → getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts} +2 -2
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +6 -6
- package/dist/hooks/index.d.ts +6 -6
- package/dist/hooks/index.mjs +2 -2
- package/dist/{staking-Bcb8DhoZ.d.cts → staking-F9Nx9TKD.d.ts} +1 -1
- package/dist/{staking-DvJOnMJG.d.ts → staking-f4BpYH7l.d.cts} +1 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/{useHoneySwapState-DfmXCavx.d.cts → useHoneySwapState-C-9BV4VB.d.cts} +1 -1
- package/dist/{useHoneySwapState-AKDZI2MT.d.ts → useHoneySwapState-CUY5Sm1b.d.ts} +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +4 -4
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.mjs +1 -1
- package/package.json +3 -2
- package/src/abi/bend/bundler.ts +60 -0
- package/src/abi/bend/generalAdapter.ts +362 -0
- package/src/abi/bend/metaMorpho.ts +2584 -0
- package/src/abi/bend/morpho.ts +444 -0
- package/src/abi/bend/morphoVault.ts +1456 -0
- package/src/abi/bend/publicAllocator.ts +355 -0
- package/src/abi/bex/aggregatorsRouter.ts +492 -0
- package/src/abi/bex/balancerComposableStablePoolFactoryV6.ts +283 -0
- package/src/abi/bex/balancerPoolCreationHelper.ts +267 -0
- package/src/abi/bex/balancerVault.ts +757 -0
- package/src/abi/enso/ensoRouterAbi.ts +140 -0
- package/src/abi/governance/governance.ts +1016 -0
- package/src/abi/governance/governanceTimelock.ts +589 -0
- package/src/abi/honey/collateralVault.ts +1144 -0
- package/src/abi/honey/honey.ts +563 -0
- package/src/abi/honey/honeyFactory.ts +1270 -0
- package/src/abi/honey/honeyFactoryReader.ts +894 -0
- package/src/abi/honey/honeyRootOracle.ts +492 -0
- package/src/abi/honey/pythPriceOracle.ts +619 -0
- package/src/abi/honey/pythWrapper.ts +446 -0
- package/src/abi/index.ts +35 -0
- package/src/abi/pol/beaconDeposit.ts +595 -0
- package/src/abi/pol/beraChef.ts +1019 -0
- package/src/abi/pol/bgt.ts +1008 -0
- package/src/abi/pol/bgtIncentiveDistributor.ts +640 -0
- package/src/abi/pol/bgtStaker.ts +1034 -0
- package/src/abi/pol/rewardAllocationFactory.ts +408 -0
- package/src/abi/pol/rewardVault.ts +1928 -0
- package/src/abi/pol/rewardVaultFactory.ts +586 -0
- package/src/abi/pol/rewardVaultHelper.ts +882 -0
- package/src/abi/pol/stakeBeraVault.ts +1116 -0
- package/src/abi/pol/stakeBeraVaultWithdrawalRequest.ts +618 -0
- package/src/abi/pol/wbera.ts +366 -0
- package/src/abi/pyth/pyth.ts +566 -0
- package/src/abi/pyth/pythErrors.ts +72 -0
- package/src/abi/utils/EIP7702StatelessDelegator.ts +523 -0
- package/src/abi/utils/bundler3errors.ts +6 -0
- package/src/abi/utils/commonAbiErrors.ts +9 -0
- package/src/abi/utils/erc20errors.ts +74 -0
- package/src/abi/utils/merkleDistributor.ts +838 -0
- package/src/abi/utils/multicall3.ts +242 -0
- package/src/abi/utils/openChainErrors.ts +139 -0
- package/src/abi/utils/upgradableBeacon.ts +86 -0
- package/src/actions/bend/getConvertToAssets.ts +23 -0
- package/src/actions/bend/getMaxDeposit.ts +21 -0
- package/src/actions/clients/BeraApolloClient.ts +125 -0
- package/src/actions/clients/getApolloClient.ts +109 -0
- package/src/actions/clients/getEnsoClient.ts +24 -0
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +112 -0
- package/src/actions/dex/__tests__/allPools.integration.test.ts +13 -0
- package/src/actions/dex/__tests__/getOnChainPool.unit.test.ts +15 -0
- package/src/actions/dex/__tests__/haiku.integration.test.ts +40 -0
- package/src/actions/dex/aggregators/base.ts +174 -0
- package/src/actions/dex/aggregators/bex.ts +255 -0
- package/src/actions/dex/aggregators/bgt.ts +50 -0
- package/src/actions/dex/aggregators/enso.ts +113 -0
- package/src/actions/dex/aggregators/fly.ts +136 -0
- package/src/actions/dex/aggregators/haiku.ts +171 -0
- package/src/actions/dex/aggregators/honey.ts +245 -0
- package/src/actions/dex/aggregators/kyberswap.ts +142 -0
- package/src/actions/dex/aggregators/oogabooga.ts +110 -0
- package/src/actions/dex/aggregators/openOcean.ts +142 -0
- package/src/actions/dex/aggregators/wbera.ts +72 -0
- package/src/actions/dex/b-sdk.ts +48 -0
- package/src/actions/dex/getAllPools.ts +60 -0
- package/src/actions/dex/getApiPool.ts +47 -0
- package/src/actions/dex/getGlobalLiquidityAndSwapVolume.ts +29 -0
- package/src/actions/dex/getIsTokenExploited.ts +63 -0
- package/src/actions/dex/getOnChainPool.ts +216 -0
- package/src/actions/dex/getPoolEvents.ts +35 -0
- package/src/actions/dex/getPoolHistoricalData.ts +51 -0
- package/src/actions/dex/getPoolPausedState.ts +40 -0
- package/src/actions/dex/getPoolWithState.ts +24 -0
- package/src/actions/dex/getSubgraphPool.ts +30 -0
- package/src/actions/dex/getTransactionCount.ts +29 -0
- package/src/actions/dex/getVaultPausedState.ts +21 -0
- package/src/actions/enso/bend.ts +143 -0
- package/src/actions/enso/getEnsoUserToken.debug.test.ts +57 -0
- package/src/actions/enso/getEnsoUserToken.ts +133 -0
- package/src/actions/enso/util.ts +60 -0
- package/src/actions/enso/zap.ts +78 -0
- package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +108 -0
- package/src/actions/governance/__tests__/getDecodedFunctionData.integration.test.ts +127 -0
- package/src/actions/governance/__tests__/getQuorum.integration.test.ts +39 -0
- package/src/actions/governance/checkProposalField.ts +211 -0
- package/src/actions/governance/computeActualStatus.ts +154 -0
- package/src/actions/governance/constants.ts +7 -0
- package/src/actions/governance/getAllProposals.ts +75 -0
- package/src/actions/governance/getBodyErrors.ts +28 -0
- package/src/actions/governance/getDecodedFunctionData.ts +170 -0
- package/src/actions/governance/getProposalDetails.ts +40 -0
- package/src/actions/governance/getProposalFromTx.ts +101 -0
- package/src/actions/governance/getProposalParams.ts +247 -0
- package/src/actions/governance/getProposalVotes.ts +20 -0
- package/src/actions/governance/getQuorum.ts +38 -0
- package/src/actions/governance/parseProposalBody.ts +73 -0
- package/src/actions/honey/getChartData.ts +27 -0
- package/src/actions/honey/getCollateralWeights.ts +50 -0
- package/src/actions/honey/getGlobalCapLimit.ts +148 -0
- package/src/actions/honey/getHoneyCollaterals.ts +139 -0
- package/src/actions/honey/getHoneyFees.ts +100 -0
- package/src/actions/honey/getHoneyGlobalData.ts +21 -0
- package/src/actions/honey/getHoneyPausedState.ts +25 -0
- package/src/actions/honey/getHoneyPreview.ts +152 -0
- package/src/actions/honey/getHoneyPythPriceOracle.ts +21 -0
- package/src/actions/honey/getHoneyRootPriceOracle.ts +23 -0
- package/src/actions/honey/getHoneyVaultsBalance.ts +86 -0
- package/src/actions/honey/getPythLatestPrices.ts +54 -0
- package/src/actions/honey/getRelativeCapLimit.ts +83 -0
- package/src/actions/honey/getSharesWithoutFees.ts +65 -0
- package/src/actions/honey/getSwapPayload.ts +128 -0
- package/src/actions/honey/isBadCollateralAsset.ts +77 -0
- package/src/actions/honey/isBasketModeEnabled.ts +47 -0
- package/src/actions/honey/tests/pyth.integration.test.ts +63 -0
- package/src/actions/index.ts +105 -0
- package/src/actions/misc/getBlockTimestamp.ts +41 -0
- package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +55 -0
- package/src/actions/pol/__tests__/getValidator.integration.test.ts +32 -0
- package/src/actions/pol/__tests__/rewardVaults.integration.test.ts +34 -0
- package/src/actions/pol/getBGTGlobalInfo.ts +43 -0
- package/src/actions/pol/getBgtAprSimulation.ts +207 -0
- package/src/actions/pol/getBgtAprSimultaion.unit.test.ts +297 -0
- package/src/actions/pol/getBgtTokenTotalBoosts.ts +30 -0
- package/src/actions/pol/getBgtTokenTotalSupply.ts +29 -0
- package/src/actions/pol/getBlockTime.ts +43 -0
- package/src/actions/pol/getGlobalCuttingBoard.ts +25 -0
- package/src/actions/pol/getGlobalData.ts +74 -0
- package/src/actions/pol/getIncentiveFeeClaimStats.ts +43 -0
- package/src/actions/pol/getMarkets.ts +36 -0
- package/src/actions/pol/getRewardProofsByValidator.ts +49 -0
- package/src/actions/pol/getRewardTokenToBeraRate.ts +30 -0
- package/src/actions/pol/getRewardVault.ts +54 -0
- package/src/actions/pol/getRewardVaultBeaconImplementation.integration.test.ts +18 -0
- package/src/actions/pol/getRewardVaultBeaconImplementation.ts +35 -0
- package/src/actions/pol/getRewardVaultDurationConstants.integration.test.ts +24 -0
- package/src/actions/pol/getRewardVaultDurationConstants.ts +45 -0
- package/src/actions/pol/getRewardVaultFromToken.ts +30 -0
- package/src/actions/pol/getRewardVaultIncentives.ts +122 -0
- package/src/actions/pol/getRewardVaultRewards.ts +109 -0
- package/src/actions/pol/getRewardVaultStakingToken.ts +19 -0
- package/src/actions/pol/getRewardVaults.ts +106 -0
- package/src/actions/pol/getSWBeraVaultMetadata.ts +166 -0
- package/src/actions/pol/getSWBeraWithdrawal.ts +165 -0
- package/src/actions/pol/getStakeWithdrawalCooldown.ts +21 -0
- package/src/actions/pol/getStakedBeraAPR.ts +56 -0
- package/src/actions/pol/getStakedBeraSnapshots.ts +48 -0
- package/src/actions/pol/getStakingTokenInformation.ts +60 -0
- package/src/actions/pol/getUserClaimableIncentives.ts +40 -0
- package/src/actions/pol/getUserVaultInfo.ts +52 -0
- package/src/actions/pol/getUserVaults.ts +185 -0
- package/src/actions/pol/getUserVaultsBalance.ts +54 -0
- package/src/actions/pol/getUserVaultsReward.ts +32 -0
- package/src/actions/pol/getVaultHistory.ts +43 -0
- package/src/actions/pol/getVaultValidators.ts +31 -0
- package/src/actions/pol/getVaultsSupply.ts +28 -0
- package/src/actions/prices/__tests__/prices.integration.test.ts +29 -0
- package/src/actions/prices/getTokenCurrentPrices.ts +79 -0
- package/src/actions/pyth/getHoneyPythFeeds.ts +46 -0
- package/src/actions/pyth/getUpdateFee.ts +27 -0
- package/src/actions/tokens/getAllowances.ts +59 -0
- package/src/actions/tokens/getTokenInformation.ts +57 -0
- package/src/actions/tokens/getTokens.ts +19 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +40 -0
- package/src/actions/tokens/getWalletBalances.ts +123 -0
- package/src/actions/transactions/beraWriteContract.integration.test.ts +251 -0
- package/src/actions/transactions/beraWriteContract.ts +722 -0
- package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.integration.test.ts +40 -0
- package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +109 -0
- package/src/actions/validators/getAllValidators.ts +33 -0
- package/src/actions/validators/getApiEnrichedAllocation.ts +33 -0
- package/src/actions/validators/getApiValidator.ts +38 -0
- package/src/actions/validators/getBaselineRewardAllocation.ts +26 -0
- package/src/actions/validators/getDailyValidatorBlockStats.ts +37 -0
- package/src/actions/validators/getDefaultRewardAllocation.ts +39 -0
- package/src/actions/validators/getManagedValidatorByAccount.ts +32 -0
- package/src/actions/validators/getStakingPoolBatch.ts +20 -0
- package/src/actions/validators/getUserActiveValidators.ts +101 -0
- package/src/actions/validators/getUserBoosts.ts +28 -0
- package/src/actions/validators/getUserBoostsOnValidator.ts +70 -0
- package/src/actions/validators/getUserStakingPositions.ts +225 -0
- package/src/actions/validators/getValidatorAnalytics.ts +34 -0
- package/src/actions/validators/getValidatorCommission.ts +24 -0
- package/src/actions/validators/getValidatorEstimatedBgtPerYear.ts +25 -0
- package/src/actions/validators/getValidatorOperatorAddress.ts +27 -0
- package/src/actions/validators/getValidatorQueuedCommission.ts +30 -0
- package/src/actions/validators/getValidatorQueuedOperatorAddress.ts +32 -0
- package/src/actions/validators/getValidatorQueuedRewardAllocation.ts +31 -0
- package/src/actions/validators/getValidatorRewardAllocation.ts +158 -0
- package/src/actions/validators/getValidatorRewardAllocatorAddress.ts +38 -0
- package/src/actions/validators/utils/__tests__/validatorUtils.integration.test.ts +36 -0
- package/src/actions/validators/utils/getValidatorBoostApy.ts +59 -0
- package/src/contexts/BeraFlags/BeraFlags.tsx +69 -0
- package/src/contexts/BeraFlags/defaultFlags.ts +42 -0
- package/src/contexts/BexStatusProvider.tsx +125 -0
- package/src/contexts/HoneyConfigProvider.tsx +73 -0
- package/src/contexts/SwrFallback.tsx +34 -0
- package/src/contexts/TokensProvider.tsx +66 -0
- package/src/contexts/berajsProvider/context.tsx +49 -0
- package/src/contexts/berajsProvider/index.ts +2 -0
- package/src/contexts/berajsProvider/useBeraJs.ts +18 -0
- package/src/contexts/block-time-provider.tsx +34 -0
- package/src/contexts/index.ts +14 -0
- package/src/data/contracts.ts +398 -0
- package/src/enum/dex.ts +10 -0
- package/src/enum/index.ts +4 -0
- package/src/enum/polling.ts +8 -0
- package/src/enum/slippage.ts +19 -0
- package/src/enum/txnEnum.ts +101 -0
- package/src/errors/BeraError.ts +202 -0
- package/src/errors/InvalidArgumentError.ts +81 -0
- package/src/errors/NotFoundError.ts +34 -0
- package/src/errors/RequestError.ts +207 -0
- package/src/errors/TransactionFailedError.ts +93 -0
- package/src/errors/assert.ts +144 -0
- package/src/errors/assert.unit.test.ts +110 -0
- package/src/errors/errorMap.ts +1157 -0
- package/src/errors/getErrorMessage.ts +40 -0
- package/src/errors/getRevertReason.integration.test.ts +449 -0
- package/src/errors/getRevertReason.ts +179 -0
- package/src/errors/index.ts +8 -0
- package/src/errors/initBeraError.ts +46 -0
- package/src/errors/parseViemError.ts +239 -0
- package/src/hooks/bend/useGetConvertToAssets.ts +42 -0
- package/src/hooks/dex/useAggregatorsQuotes.ts +502 -0
- package/src/hooks/dex/useAggregatorsRouterFeeBps.ts +34 -0
- package/src/hooks/dex/useAllUserPools.ts +38 -0
- package/src/hooks/dex/useApiPool.ts +53 -0
- package/src/hooks/dex/useBexStatus.ts +1 -0
- package/src/hooks/dex/useCreatePool.ts +437 -0
- package/src/hooks/dex/useExploitedTokens.ts +57 -0
- package/src/hooks/dex/useGlobalLiquidityAndSwapVolume.ts +22 -0
- package/src/hooks/dex/useLiquidityMismatch.ts +195 -0
- package/src/hooks/dex/useLpPosition.ts +115 -0
- package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +92 -0
- package/src/hooks/dex/useOnChainPoolData.ts +126 -0
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +54 -0
- package/src/hooks/dex/usePollVaultIsPaused.ts +30 -0
- package/src/hooks/dex/usePool.ts +59 -0
- package/src/hooks/dex/usePoolEvents.ts +22 -0
- package/src/hooks/dex/usePoolHistoricalData.ts +44 -0
- package/src/hooks/dex/usePools.ts +83 -0
- package/src/hooks/enso/useBendTransactionRequests.ts +247 -0
- package/src/hooks/enso/useEnsoZap.ts +166 -0
- package/src/hooks/enso/useZapTransactionRequests.ts +81 -0
- package/src/hooks/governance/useCreateProposal.ts +88 -0
- package/src/hooks/governance/useGetPastVotes.ts +63 -0
- package/src/hooks/governance/useHasVoted.ts +38 -0
- package/src/hooks/governance/useIsCanceller.ts +43 -0
- package/src/hooks/governance/usePollAllProposals.ts +232 -0
- package/src/hooks/governance/usePollProposal.ts +96 -0
- package/src/hooks/governance/usePollProposalThreshold.ts +41 -0
- package/src/hooks/governance/usePollProposalVotes.ts +64 -0
- package/src/hooks/governance/usePollUserDelegates.ts +70 -0
- package/src/hooks/governance/useProposalFromTx.ts +37 -0
- package/src/hooks/governance/useProposalSnapshot.ts +44 -0
- package/src/hooks/governance/useProposalState.ts +48 -0
- package/src/hooks/governance/useProposalTimelockState.ts +61 -0
- package/src/hooks/governance/useQuorum.ts +42 -0
- package/src/hooks/honey/useCappedGlobally.ts +92 -0
- package/src/hooks/honey/useCappedRelatively.ts +88 -0
- package/src/hooks/honey/useCollateralWeights.ts +48 -0
- package/src/hooks/honey/useHoneyAlerts.ts +314 -0
- package/src/hooks/honey/useHoneyBalances.ts +79 -0
- package/src/hooks/honey/useHoneyChartData.ts +17 -0
- package/src/hooks/honey/useHoneyGlobalData.ts +22 -0
- package/src/hooks/honey/useHoneySwapState.ts +202 -0
- package/src/hooks/honey/useHoneyVaultsBalance.ts +41 -0
- package/src/hooks/honey/useIsBadCollateralAsset.ts +73 -0
- package/src/hooks/honey/useIsBasketModeEnabled.ts +70 -0
- package/src/hooks/honey/usePythLatestPrices.ts +41 -0
- package/src/hooks/index.ts +124 -0
- package/src/hooks/perps/usePythUpdateFee.ts +43 -0
- package/src/hooks/pol/useBgtAprSimulation.ts +22 -0
- package/src/hooks/pol/useBgtUnstakedBalance.ts +50 -0
- package/src/hooks/pol/useClaimableFees.ts +38 -0
- package/src/hooks/pol/useEarnedStakedBeraVault.ts +59 -0
- package/src/hooks/pol/useHighestVaultsAPR.ts +57 -0
- package/src/hooks/pol/useOnChainRewardVault.ts +114 -0
- package/src/hooks/pol/usePollGlobalData.ts +31 -0
- package/src/hooks/pol/usePollMarkets.ts +32 -0
- package/src/hooks/pol/useQueuedBeraUnlock.ts +70 -0
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +45 -0
- package/src/hooks/pol/useRewardVault.ts +51 -0
- package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +82 -0
- package/src/hooks/pol/useRewardVaultFromToken.ts +58 -0
- package/src/hooks/pol/useRewardVaultIncentives.ts +37 -0
- package/src/hooks/pol/useRewardVaultRewards.ts +37 -0
- package/src/hooks/pol/useRewardVaults.ts +45 -0
- package/src/hooks/pol/useStakedBeraSnapshots.ts +27 -0
- package/src/hooks/pol/useUserVaultInfo.ts +46 -0
- package/src/hooks/pol/useUserVaults.ts +40 -0
- package/src/hooks/pol/useVaultAddress.ts +31 -0
- package/src/hooks/pol/useVaultHistory.ts +29 -0
- package/src/hooks/pol/useVaultValidators.ts +33 -0
- package/src/hooks/tokens/useBeraCurrentPrice.ts +12 -0
- package/src/hooks/tokens/useMultipleTokenInformation.ts +62 -0
- package/src/hooks/tokens/usePollAllowances.ts +60 -0
- package/src/hooks/tokens/usePollBalance.ts +113 -0
- package/src/hooks/tokens/usePollWalletBalances.ts +75 -0
- package/src/hooks/tokens/useStakingTokenInformation.ts +54 -0
- package/src/hooks/tokens/useTokenCurrentPrice.ts +19 -0
- package/src/hooks/tokens/useTokenCurrentPrices.ts +57 -0
- package/src/hooks/tokens/useTokenInformation.ts +59 -0
- package/src/hooks/tokens/useTokens.ts +26 -0
- package/src/hooks/tokens/useTotalSupply.ts +22 -0
- package/src/hooks/transactions/TransactionStoreContext.tsx +59 -0
- package/src/hooks/transactions/transactionStore.ts +275 -0
- package/src/hooks/transactions/transactionStore.unit.test.ts +508 -0
- package/src/hooks/transactions/useAddRecentTransaction.ts +29 -0
- package/src/hooks/transactions/useRecentTransactions.ts +27 -0
- package/src/hooks/useBlockToTimestamp.ts +51 -0
- package/src/hooks/useContractWrite/index.ts +2 -0
- package/src/hooks/useContractWrite/stateReducer.ts +60 -0
- package/src/hooks/useContractWrite/types.ts +88 -0
- package/src/hooks/useContractWrite/useBeraContractWrite.ts +137 -0
- package/src/hooks/useGetVerifiedAbi.ts +47 -0
- package/src/hooks/useHistoryState.ts +64 -0
- package/src/hooks/usePrevious.ts +13 -0
- package/src/hooks/validators/useAllValidators.ts +48 -0
- package/src/hooks/validators/useApiEnrichedAllocation.ts +17 -0
- package/src/hooks/validators/useApiValidator.ts +37 -0
- package/src/hooks/validators/useBaselineRewardAllocation.ts +16 -0
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +35 -0
- package/src/hooks/validators/useDefaultRewardAllocation.ts +32 -0
- package/src/hooks/validators/useManagedValidatorByAccount.ts +40 -0
- package/src/hooks/validators/useManagedValidatorRole.ts +119 -0
- package/src/hooks/validators/useOnChainValidator.ts +66 -0
- package/src/hooks/validators/useStakingPoolBatch.ts +45 -0
- package/src/hooks/validators/useSubgraphUserValidators.ts +36 -0
- package/src/hooks/validators/useUserActiveValidators.ts +44 -0
- package/src/hooks/validators/useUserBoostsOnValidator.ts +45 -0
- package/src/hooks/validators/useUserClaimableIncentives.ts +149 -0
- package/src/hooks/validators/useUserStakingPositions.ts +62 -0
- package/src/hooks/validators/useValidator.ts +83 -0
- package/src/hooks/validators/useValidatorAnalytics.ts +36 -0
- package/src/hooks/validators/useValidatorCommission.ts +36 -0
- package/src/hooks/validators/useValidatorEstimatedBgtPerYear.ts +24 -0
- package/src/hooks/validators/useValidatorQueuedCommission.ts +41 -0
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +39 -0
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +37 -0
- package/src/hooks/validators/useValidatorRewardAllocation.ts +36 -0
- package/src/hooks/validators/validatorRoleManager.ts +0 -0
- package/src/types/bribe-boost.ts +50 -0
- package/src/types/dex.ts +196 -0
- package/src/types/enso.ts +42 -0
- package/src/types/global.ts +230 -0
- package/src/types/governance.ts +174 -0
- package/src/types/honeySwap.ts +35 -0
- package/src/types/index.ts +8 -0
- package/src/types/pol.ts +52 -0
- package/src/types/staking.ts +7 -0
- package/src/utils/beraFetch.ts +55 -0
- package/src/utils/constants.ts +35 -0
- package/src/utils/formatAggregatorsQuotes.ts +57 -0
- package/src/utils/formatAggregatorsQuotes.unit.test.ts +191 -0
- package/src/utils/formatIncentivesTokenMap.ts +19 -0
- package/src/utils/formatInputTokenValue.ts +12 -0
- package/src/utils/formatNumber.ts +225 -0
- package/src/utils/formatNumber.unit.test.ts +245 -0
- package/src/utils/formatTimestamps.ts +155 -0
- package/src/utils/formatTimestamps.unit.test.ts +395 -0
- package/src/utils/formatTokenList.ts +61 -0
- package/src/utils/formatUsd.ts +46 -0
- package/src/utils/getContractName.ts +27 -0
- package/src/utils/getContractName.unit.test.ts +64 -0
- package/src/utils/getErrorResponse.ts +20 -0
- package/src/utils/getHoneySwapMessage.test.ts +116 -0
- package/src/utils/getHoneySwapMessage.ts +70 -0
- package/src/utils/getServerSideClient.ts +49 -0
- package/src/utils/getTestClient.ts +19 -0
- package/src/utils/hasAnyTruthyValues.ts +17 -0
- package/src/utils/index.ts +27 -0
- package/src/utils/isDifferenceExceedingThreshold.ts +13 -0
- package/src/utils/isSubgraphStale.ts +10 -0
- package/src/utils/math.ts +28 -0
- package/src/utils/math.unit.test.ts +49 -0
- package/src/utils/parseBaseArgs.ts +23 -0
- package/src/utils/parseBaseArgs.unit.test.ts +55 -0
- package/src/utils/poolNamings.ts +54 -0
- package/src/utils/pythHoneyUtils.ts +3 -0
- package/src/utils/sentryBeforeSend.ts +52 -0
- package/src/utils/test-utils.ts +2 -0
- package/src/utils/time.ts +106 -0
- package/src/utils/time.unit.test.ts +76 -0
- package/src/utils/tokenWrapping.ts +16 -0
- package/src/utils/tokens.ts +106 -0
- package/src/utils/tokens.unit.test.ts +98 -0
- package/src/utils/truncateHash.ts +20 -0
- package/src/utils/truncateHash.unit.test.ts +19 -0
- package/src/utils/validatorUptimeStatus.ts +30 -0
- package/dist/chunk-5OAABMMU.mjs +0 -2
- package/dist/chunk-5OAABMMU.mjs.map +0 -1
- package/dist/chunk-EODAKI5K.cjs +0 -2
- package/dist/chunk-EODAKI5K.cjs.map +0 -1
- package/dist/chunk-IZDT74H4.mjs +0 -2
- package/dist/chunk-IZDT74H4.mjs.map +0 -1
- package/dist/chunk-M5GUTM7K.mjs +0 -4
- package/dist/chunk-YRJAQDEO.cjs +0 -2
- package/dist/chunk-YRJAQDEO.cjs.map +0 -1
- /package/dist/{chunk-3WCYP277.mjs.map → chunk-AMRJ4B36.mjs.map} +0 -0
- /package/dist/{chunk-ZLCBHOSV.mjs.map → chunk-KMKUXP2S.mjs.map} +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type Address, isAddress, type PublicClient } from "viem";
|
|
2
|
+
|
|
3
|
+
import { InvalidArgumentError } from "./InvalidArgumentError";
|
|
4
|
+
|
|
5
|
+
function _isDefined<T>(value: T): value is NonNullable<T> {
|
|
6
|
+
return value !== undefined && value !== null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type _AssertFn<T> = (value: T) => { expectedType: string; isValid: boolean };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal assertion function.
|
|
13
|
+
* @throws An InvalidArgumentError if the value is not valid.
|
|
14
|
+
*/
|
|
15
|
+
function _assert<T>({
|
|
16
|
+
value,
|
|
17
|
+
property,
|
|
18
|
+
fn,
|
|
19
|
+
}: {
|
|
20
|
+
value: T;
|
|
21
|
+
property: string;
|
|
22
|
+
fn: _AssertFn<T>;
|
|
23
|
+
}) {
|
|
24
|
+
const result = fn(value);
|
|
25
|
+
if (!result.isValid) {
|
|
26
|
+
throw new InvalidArgumentError({
|
|
27
|
+
property,
|
|
28
|
+
value,
|
|
29
|
+
expected: result.expectedType,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _assertDefined<T>({
|
|
35
|
+
value,
|
|
36
|
+
property,
|
|
37
|
+
fn,
|
|
38
|
+
}: {
|
|
39
|
+
value: T;
|
|
40
|
+
property: string;
|
|
41
|
+
fn: (value: T) => { expectedType: string; isValid: boolean };
|
|
42
|
+
}) {
|
|
43
|
+
_assert({
|
|
44
|
+
value,
|
|
45
|
+
property,
|
|
46
|
+
fn: (value) => {
|
|
47
|
+
const isDefined = _isDefined(value);
|
|
48
|
+
const { isValid, expectedType } = fn(value);
|
|
49
|
+
return {
|
|
50
|
+
expectedType,
|
|
51
|
+
isValid: isDefined && isValid,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Asserts that a value is defined.
|
|
59
|
+
* @throws An InvalidArgumentError if the value is undefined or null.
|
|
60
|
+
*/
|
|
61
|
+
export function assertDefined<T>(
|
|
62
|
+
/**
|
|
63
|
+
* The value to assert.
|
|
64
|
+
*/
|
|
65
|
+
value: T,
|
|
66
|
+
/**
|
|
67
|
+
* The property name.
|
|
68
|
+
*/
|
|
69
|
+
property: string,
|
|
70
|
+
): asserts value is NonNullable<T> {
|
|
71
|
+
_assertDefined({
|
|
72
|
+
value,
|
|
73
|
+
property,
|
|
74
|
+
fn: (value) => ({ expectedType: "defined", isValid: _isDefined(value) }),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Asserts that a value is a PublicClient.
|
|
80
|
+
* @throws An InvalidArgumentError if the value is undefined or not a PublicClient.
|
|
81
|
+
*/
|
|
82
|
+
export function assertPublicClient(
|
|
83
|
+
/**
|
|
84
|
+
* The value to assert.
|
|
85
|
+
*/
|
|
86
|
+
value: PublicClient | undefined,
|
|
87
|
+
/**
|
|
88
|
+
* The property name.
|
|
89
|
+
*/
|
|
90
|
+
property: string = "publicClient",
|
|
91
|
+
): asserts value is PublicClient {
|
|
92
|
+
// there's no current way to check if a value is a PublicClient, so we just assert it's defined and `value: PublicClient` will do the rest
|
|
93
|
+
assertDefined(value, property);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Asserts that a value is an address (20 bytes).
|
|
98
|
+
* @throws An InvalidArgumentError if the value is undefined, null, not a string, or not an address.
|
|
99
|
+
*/
|
|
100
|
+
export function assertAddress(
|
|
101
|
+
/**
|
|
102
|
+
* The value to assert.
|
|
103
|
+
*/
|
|
104
|
+
value: string | undefined,
|
|
105
|
+
/**
|
|
106
|
+
* The property name.
|
|
107
|
+
*/
|
|
108
|
+
property: string,
|
|
109
|
+
): asserts value is Address {
|
|
110
|
+
_assertDefined({
|
|
111
|
+
value,
|
|
112
|
+
property,
|
|
113
|
+
fn: (value) => ({
|
|
114
|
+
expectedType: "Address",
|
|
115
|
+
isValid: typeof value === "string" && isAddress(value),
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Asserts that a value is a number greater than 0.
|
|
122
|
+
* @throws An InvalidArgumentError if the value is undefined, null, not a string or number, or not a number greater than 0.
|
|
123
|
+
*/
|
|
124
|
+
export function assertAmount(
|
|
125
|
+
/**
|
|
126
|
+
* The value to assert.
|
|
127
|
+
*/
|
|
128
|
+
value: unknown,
|
|
129
|
+
/**
|
|
130
|
+
* The property name.
|
|
131
|
+
*/
|
|
132
|
+
property: string,
|
|
133
|
+
): asserts value is string | number {
|
|
134
|
+
_assertDefined({
|
|
135
|
+
value,
|
|
136
|
+
property,
|
|
137
|
+
fn: (value) => ({
|
|
138
|
+
expectedType: "number",
|
|
139
|
+
isValid:
|
|
140
|
+
(typeof value === "string" || typeof value === "number") &&
|
|
141
|
+
Number(value) > 0,
|
|
142
|
+
}),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { assertAddress, assertAmount, assertDefined } from "./assert";
|
|
4
|
+
import { InvalidArgumentError } from "./InvalidArgumentError";
|
|
5
|
+
|
|
6
|
+
describe("assertDefined", () => {
|
|
7
|
+
it("does not throw when value is defined", () => {
|
|
8
|
+
expect(() => assertDefined("value", "testProp")).not.toThrow();
|
|
9
|
+
expect(() => assertDefined(0, "testProp")).not.toThrow();
|
|
10
|
+
expect(() => assertDefined(false, "testProp")).not.toThrow();
|
|
11
|
+
expect(() => assertDefined([], "testProp")).not.toThrow();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("throws InvalidArgumentError when value is undefined", () => {
|
|
15
|
+
expect(() => assertDefined(undefined, "testProp")).toThrow(
|
|
16
|
+
InvalidArgumentError,
|
|
17
|
+
);
|
|
18
|
+
try {
|
|
19
|
+
assertDefined(undefined, "testProp");
|
|
20
|
+
} catch (e: unknown) {
|
|
21
|
+
expect(e).toBeInstanceOf(InvalidArgumentError);
|
|
22
|
+
if (e instanceof InvalidArgumentError) {
|
|
23
|
+
expect(e.property).toBe("testProp");
|
|
24
|
+
expect(e.value).toBe(undefined);
|
|
25
|
+
expect(e.expected).toBe("defined");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("throws InvalidArgumentError when value is null", () => {
|
|
31
|
+
expect(() => assertDefined(null, "testProp")).toThrow(InvalidArgumentError);
|
|
32
|
+
try {
|
|
33
|
+
assertDefined(null, "testProp");
|
|
34
|
+
} catch (e: unknown) {
|
|
35
|
+
expect(e).toBeInstanceOf(InvalidArgumentError);
|
|
36
|
+
if (e instanceof InvalidArgumentError) {
|
|
37
|
+
expect(e.property).toBe("testProp");
|
|
38
|
+
expect(e.value).toBe(null);
|
|
39
|
+
expect(e.expected).toBe("defined");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("assertAddress", () => {
|
|
46
|
+
const validAddress = "0x0000000000000000000000000000000000000001";
|
|
47
|
+
const invalidAddress = "0x123";
|
|
48
|
+
|
|
49
|
+
it("does not throw for a valid address", () => {
|
|
50
|
+
expect(() => assertAddress(validAddress, "addr")).not.toThrow();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("throws InvalidArgumentError for undefined", () => {
|
|
54
|
+
expect(() => assertAddress(undefined, "addr")).toThrow(
|
|
55
|
+
InvalidArgumentError,
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("throws InvalidArgumentError for null", () => {
|
|
60
|
+
expect(() => assertAddress(null, "addr")).toThrow(InvalidArgumentError);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("throws InvalidArgumentError for non-string", () => {
|
|
64
|
+
expect(() => assertAddress(123, "addr")).toThrow(InvalidArgumentError);
|
|
65
|
+
expect(() => assertAddress({}, "addr")).toThrow(InvalidArgumentError);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("throws InvalidArgumentError for invalid address string", () => {
|
|
69
|
+
expect(() => assertAddress(invalidAddress, "addr")).toThrow(
|
|
70
|
+
InvalidArgumentError,
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("assertAmount", () => {
|
|
76
|
+
const validAmount = "1";
|
|
77
|
+
const invalidAmount = "-1";
|
|
78
|
+
|
|
79
|
+
it("does not throw for a valid amount", () => {
|
|
80
|
+
expect(() => assertAmount(validAmount, "amount")).not.toThrow();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("throws InvalidArgumentError for undefined", () => {
|
|
84
|
+
expect(() => assertAmount(undefined, "amount")).toThrow(
|
|
85
|
+
InvalidArgumentError,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("throws InvalidArgumentError for null", () => {
|
|
90
|
+
expect(() => assertAddress(null, "addr")).toThrow(InvalidArgumentError);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("throws InvalidArgumentError for invalid amount", () => {
|
|
94
|
+
expect(() => assertAddress(invalidAmount, "amount")).toThrow(
|
|
95
|
+
InvalidArgumentError,
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("throws InvalidArgumentError for amount less than or equal to 0", () => {
|
|
100
|
+
expect(() => assertAmount("-1", "amount")).toThrow(InvalidArgumentError);
|
|
101
|
+
expect(() => assertAmount(-1, "amount")).toThrow(InvalidArgumentError);
|
|
102
|
+
|
|
103
|
+
expect(() => assertAmount("0", "amount")).toThrow(InvalidArgumentError);
|
|
104
|
+
expect(() => assertAmount(0, "amount")).toThrow(InvalidArgumentError);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("throws InvalidArgumentError for non-numeric value", () => {
|
|
108
|
+
expect(() => assertAmount("0.", "amount")).toThrow(InvalidArgumentError);
|
|
109
|
+
});
|
|
110
|
+
});
|