@berachain/berajs 0.1.2 → 0.2.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/{BeraError-D1HS_rbb.d.cts → BeraError-_mQdkanr.d.cts} +35 -10
- package/dist/{BeraError-D1HS_rbb.d.ts → BeraError-_mQdkanr.d.ts} +35 -10
- package/dist/HoneyConfigProvider-CK6mOKFH.d.ts +390 -0
- package/dist/HoneyConfigProvider-Ca3ouozs.d.cts +390 -0
- package/dist/{RequestError-D8AE6xnI.d.cts → RequestError-A8XJ6QR9.d.cts} +1 -1
- package/dist/{RequestError-m4jxyM7D.d.ts → RequestError-Dk97z8rm.d.ts} +1 -1
- package/dist/abi/exports.cjs +2 -0
- package/dist/abi/exports.cjs.map +1 -0
- package/dist/abi/{index.d.cts → exports.d.cts} +12369 -9122
- package/dist/abi/{index.d.ts → exports.d.ts} +12369 -9122
- package/dist/abi/exports.mjs +2 -0
- package/dist/abi/exports.mjs.map +1 -0
- package/dist/actions/exports.cjs +2 -0
- package/dist/actions/exports.cjs.map +1 -0
- package/dist/actions/{index.d.cts → exports.d.cts} +79 -107
- package/dist/actions/{index.d.ts → exports.d.ts} +79 -107
- package/dist/actions/exports.mjs +2 -0
- package/dist/actions/exports.mjs.map +1 -0
- package/dist/chunk-22J3YJDN.cjs +2 -0
- package/dist/chunk-22J3YJDN.cjs.map +1 -0
- package/dist/chunk-2LL3P5PN.mjs +2 -0
- package/dist/chunk-2LL3P5PN.mjs.map +1 -0
- package/dist/chunk-3YXSUBA5.mjs +2 -0
- package/dist/chunk-3YXSUBA5.mjs.map +1 -0
- package/dist/chunk-55L7STYD.mjs +2 -0
- package/dist/chunk-55L7STYD.mjs.map +1 -0
- package/dist/chunk-575OK77P.mjs +2 -0
- package/dist/chunk-575OK77P.mjs.map +1 -0
- package/dist/chunk-6LDOG5RL.cjs +2 -0
- package/dist/chunk-6LDOG5RL.cjs.map +1 -0
- package/dist/chunk-7LNBSOVV.cjs +2 -0
- package/dist/chunk-7LNBSOVV.cjs.map +1 -0
- package/dist/chunk-7SMWQ6SN.mjs +2 -0
- package/dist/chunk-7SMWQ6SN.mjs.map +1 -0
- package/dist/chunk-7WRTK7RJ.mjs +2 -0
- package/dist/chunk-7WRTK7RJ.mjs.map +1 -0
- package/dist/chunk-A4UDYSB6.mjs +4 -0
- package/dist/chunk-A4UDYSB6.mjs.map +1 -0
- package/dist/chunk-AX2YQQFQ.mjs +2 -0
- package/dist/chunk-AX2YQQFQ.mjs.map +1 -0
- package/dist/chunk-C3FHGFLK.mjs +2 -0
- package/dist/chunk-C3FHGFLK.mjs.map +1 -0
- package/dist/chunk-C6ZGUO4H.cjs +2 -0
- package/dist/chunk-C6ZGUO4H.cjs.map +1 -0
- package/dist/chunk-CYKCYPFR.cjs +2 -0
- package/dist/chunk-CYKCYPFR.cjs.map +1 -0
- package/dist/chunk-ECRMUMTA.mjs +2 -0
- package/dist/chunk-ECRMUMTA.mjs.map +1 -0
- package/dist/chunk-F4BKSBEM.mjs +2 -0
- package/dist/chunk-F4BKSBEM.mjs.map +1 -0
- package/dist/chunk-FCWDGE62.cjs +2 -0
- package/dist/chunk-FCWDGE62.cjs.map +1 -0
- package/dist/chunk-FL2N3XHK.cjs +2 -0
- package/dist/chunk-FL2N3XHK.cjs.map +1 -0
- package/dist/chunk-MUCEYO3E.cjs +4 -0
- package/dist/chunk-MUCEYO3E.cjs.map +1 -0
- package/dist/chunk-NAXAZJJY.mjs +2 -0
- package/dist/chunk-NAXAZJJY.mjs.map +1 -0
- package/dist/chunk-OGJMSGB2.mjs +2 -0
- package/dist/chunk-OGJMSGB2.mjs.map +1 -0
- package/dist/chunk-OIYXOKTT.cjs +2 -0
- package/dist/chunk-OIYXOKTT.cjs.map +1 -0
- package/dist/chunk-P2Q7CMUD.cjs +2 -0
- package/dist/chunk-P2Q7CMUD.cjs.map +1 -0
- package/dist/chunk-PKXAW6MO.cjs +2 -0
- package/dist/chunk-PKXAW6MO.cjs.map +1 -0
- package/dist/chunk-Q3SCM6WL.mjs +2 -0
- package/dist/chunk-Q3SCM6WL.mjs.map +1 -0
- package/dist/chunk-SWMJQOH6.cjs +2 -0
- package/dist/chunk-SWMJQOH6.cjs.map +1 -0
- package/dist/chunk-TEBJWAVU.mjs +2 -0
- package/dist/chunk-TEBJWAVU.mjs.map +1 -0
- package/dist/chunk-THATXCJK.mjs +2 -0
- package/dist/chunk-THATXCJK.mjs.map +1 -0
- package/dist/chunk-VP7XUOSI.cjs +2 -0
- package/dist/chunk-VP7XUOSI.cjs.map +1 -0
- package/dist/chunk-VXL2ZZ4X.cjs +2 -0
- package/dist/chunk-VXL2ZZ4X.cjs.map +1 -0
- package/dist/chunk-WRFDB3QJ.cjs +2 -0
- package/dist/chunk-WRFDB3QJ.cjs.map +1 -0
- package/dist/chunk-XNJLSA6P.cjs +2 -0
- package/dist/chunk-XNJLSA6P.cjs.map +1 -0
- package/dist/chunk-YXLFOEZN.mjs +2 -0
- package/dist/chunk-YXLFOEZN.mjs.map +1 -0
- package/dist/chunk-YZV5LKIP.cjs +2 -0
- package/dist/chunk-YZV5LKIP.cjs.map +1 -0
- package/dist/contexts/exports.cjs +2 -0
- package/dist/contexts/exports.cjs.map +1 -0
- package/dist/contexts/{index.d.cts → exports.d.cts} +10 -27
- package/dist/contexts/{index.d.ts → exports.d.ts} +10 -27
- package/dist/contexts/exports.mjs +2 -0
- package/dist/contexts/exports.mjs.map +1 -0
- package/dist/{defaultFlags-V-tJs2K8.d.cts → defaultFlags-d0kPbT0i.d.cts} +1 -1
- package/dist/{defaultFlags-V-tJs2K8.d.ts → defaultFlags-d0kPbT0i.d.ts} +1 -1
- package/dist/dex-C_BB0b0O.d.cts +37 -0
- package/dist/dex-C_BB0b0O.d.ts +37 -0
- package/dist/enum/exports.cjs +2 -0
- package/dist/enum/exports.cjs.map +1 -0
- package/dist/enum/exports.d.cts +23 -0
- package/dist/enum/exports.d.ts +23 -0
- package/dist/enum/exports.mjs +2 -0
- package/dist/enum/exports.mjs.map +1 -0
- package/dist/errors/exports.cjs +2 -0
- package/dist/errors/exports.cjs.map +1 -0
- package/dist/errors/exports.d.cts +408 -0
- package/dist/errors/exports.d.ts +408 -0
- package/dist/errors/exports.mjs +2 -0
- package/dist/{getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts → getValidatorQueuedOperatorAddress-Dstyaomr.d.cts} +125 -15
- package/dist/{getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts → getValidatorQueuedOperatorAddress-RW4OMcD1.d.ts} +125 -15
- package/dist/global.d-CN6l2b9E.d.cts +473 -0
- package/dist/global.d-wYu8G8IQ.d.ts +473 -0
- package/dist/honey-CYm0RWf4.d.cts +14 -0
- package/dist/honey-CYm0RWf4.d.ts +14 -0
- package/dist/hooks/exports.cjs +4 -0
- package/dist/hooks/exports.cjs.map +1 -0
- package/dist/hooks/{index.d.cts → exports.d.cts} +218 -176
- package/dist/hooks/{index.d.ts → exports.d.ts} +218 -176
- package/dist/hooks/exports.mjs +4 -0
- package/dist/hooks/exports.mjs.map +1 -0
- package/dist/{txnEnum-BQKDfaeH.d.cts → txnEnum-BlBYhNRl.d.cts} +75 -1
- package/dist/{txnEnum-BQKDfaeH.d.ts → txnEnum-BlBYhNRl.d.ts} +75 -1
- package/dist/types/exports.cjs +1 -0
- package/dist/types/exports.cjs.map +1 -0
- package/dist/types/exports.d.cts +57 -0
- package/dist/types/exports.d.ts +57 -0
- package/dist/types/exports.mjs +1 -0
- package/dist/{useHoneySwapState-C-9BV4VB.d.cts → useHoneySwapState-B-vmIP1b.d.cts} +1 -1
- package/dist/{useHoneySwapState-CUY5Sm1b.d.ts → useHoneySwapState-D1DKG_Of.d.ts} +1 -1
- package/dist/utils/exports.cjs +2 -0
- package/dist/utils/exports.cjs.map +1 -0
- package/dist/utils/{index.d.cts → exports.d.cts} +83 -20
- package/dist/utils/{index.d.ts → exports.d.ts} +83 -20
- package/dist/utils/exports.mjs +2 -0
- package/dist/utils/exports.mjs.map +1 -0
- package/package.json +19 -20
- package/src/abi/{index.ts → exports.ts} +3 -0
- package/src/abi/pol/LSTStakerVault.ts +2032 -0
- package/src/abi/utils/openChainErrors.ts +71 -30
- package/src/abi/utils/thirdwebMinimalAccount.ts +616 -0
- package/src/actions/clients/BeraApolloClient.ts +8 -6
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +2 -5
- package/src/actions/dex/aggregators/base.ts +74 -16
- package/src/actions/dex/aggregators/bex.ts +54 -74
- package/src/actions/dex/aggregators/bgt.ts +31 -8
- package/src/actions/dex/aggregators/{enso.ts → enso/enso.ts} +18 -14
- package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +37 -0
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +176 -0
- package/src/actions/dex/aggregators/erc4626.ts +122 -0
- package/src/actions/dex/aggregators/fly.ts +59 -53
- package/src/actions/dex/aggregators/haiku.ts +52 -54
- package/src/actions/dex/aggregators/honey.ts +54 -45
- package/src/actions/dex/aggregators/kyberswap.ts +41 -39
- package/src/actions/dex/aggregators/oogabooga.ts +47 -46
- package/src/actions/dex/aggregators/openOcean.ts +51 -46
- package/src/actions/dex/aggregators/wbera.ts +54 -42
- package/src/actions/dex/b-sdk.ts +5 -2
- package/src/actions/dex/getIsTokenExploited.ts +2 -2
- package/src/actions/enso/{zap.ts → getEnsoSwapBundle.ts} +4 -5
- package/src/actions/enso/getEnsoUserTokensWithBalances.debug.test.ts +73 -0
- package/src/actions/enso/{getEnsoUserToken.ts → getEnsoUserTokensWithBalances.ts} +42 -30
- package/src/actions/enso/util.ts +1 -1
- package/src/actions/{index.ts → exports.ts} +5 -0
- package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +1 -1
- package/src/actions/governance/__tests__/getQuorum.integration.test.ts +1 -1
- package/src/actions/governance/checkProposalField.ts +1 -1
- package/src/actions/governance/computeActualStatus.ts +1 -1
- package/src/actions/governance/getBodyErrors.ts +1 -1
- package/src/actions/governance/getDecodedFunctionData.ts +1 -4
- package/src/actions/governance/getProposalDetails.ts +2 -2
- package/src/actions/governance/getProposalFromTx.ts +1 -2
- package/src/actions/governance/getProposalParams.ts +7 -8
- package/src/actions/governance/getQuorum.ts +1 -2
- package/src/actions/honey/getCollateralWeights.ts +1 -1
- package/src/actions/honey/getHoneyCollaterals.ts +1 -0
- package/src/actions/honey/getHoneyVaultsBalance.ts +51 -55
- package/src/actions/honey/getSwapPayload.ts +37 -35
- package/src/actions/honey/tests/pyth.integration.test.ts +0 -1
- package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +1 -1
- package/src/actions/pol/getEarnedStakedBeraVault.ts +31 -0
- package/src/actions/pol/getGlobalData.ts +14 -13
- package/src/actions/pol/getLSTStakeConfig.ts +67 -0
- package/src/actions/pol/getMarkets.ts +1 -1
- package/src/actions/pol/getRewardProofsByValidator.ts +1 -1
- package/src/actions/pol/getRewardVaultIncentives.ts +3 -5
- package/src/actions/pol/getRewardVaults.ts +2 -3
- package/src/actions/pol/getSWBeraVaultMetadata.ts +7 -5
- package/src/actions/pol/getSWBeraWithdrawal.ts +41 -27
- package/src/actions/pol/getStakeWithdrawalCooldown.ts +5 -7
- package/src/actions/pol/getStakingDailyAssets.ts +24 -0
- package/src/actions/pol/getStakingTokenInformation.ts +3 -4
- package/src/actions/pol/getTotalStakedAmount.ts +47 -0
- package/src/actions/pol/getUserClaimableIncentives.ts +1 -1
- package/src/actions/pol/getUserVaults.ts +8 -6
- package/src/actions/pol/getUserVaultsBalance.ts +4 -16
- package/src/actions/prices/getTokenCurrentPrices.ts +8 -3
- package/src/actions/tokens/getAllowances.ts +68 -41
- package/src/actions/tokens/getTokenInformation.ts +4 -1
- package/src/actions/tokens/getTokens.ts +1 -1
- package/src/actions/tokens/getUnderlyingToken.ts +53 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +53 -14
- package/src/actions/tokens/getWalletBalances.ts +69 -43
- package/src/actions/transactions/beraWriteContract.integration.test.ts +18 -6
- package/src/actions/transactions/beraWriteContract.ts +3 -3
- package/src/actions/validators/getUserActiveValidators.ts +2 -3
- package/src/actions/validators/getUserBoostsOnValidator.ts +2 -3
- package/src/contexts/BeraFlags/defaultFlags.ts +4 -0
- package/src/contexts/SwrFallback.tsx +13 -3
- package/src/contexts/TokensProvider.tsx +35 -8
- package/src/contexts/block-time-provider.tsx +1 -1
- package/src/contexts/{index.ts → exports.ts} +0 -1
- package/src/data/contracts.ts +17 -2
- package/src/enum/contracts.ts +13 -0
- package/src/enum/dex.ts +29 -0
- package/src/enum/{index.ts → exports.ts} +3 -0
- package/src/enum/governance.ts +61 -0
- package/src/enum/honey.ts +12 -0
- package/src/enum/txnEnum.ts +1 -0
- package/src/errors/BeraError.ts +61 -13
- package/src/errors/BeraMonitoring.ts +66 -0
- package/src/errors/BeraTracing.ts +79 -0
- package/src/errors/BeraTracing.unit.test.ts +198 -0
- package/src/errors/RequestError.ts +29 -3
- package/src/errors/assert.ts +4 -2
- package/src/errors/assert.unit.test.ts +6 -2
- package/src/errors/errorMap.ts +19 -8
- package/src/errors/{index.ts → exports.ts} +7 -0
- package/src/errors/getErrorMessage.ts +67 -9
- package/src/errors/getRevertReason.integration.test.ts +18 -6
- package/src/errors/getRevertReason.ts +41 -2
- package/src/errors/initBeraError.ts +52 -7
- package/src/errors/parseViemError.ts +114 -27
- package/src/errors/severity.ts +12 -0
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -2
- package/src/hooks/dex/useAggregatorsQuotes.ts +126 -365
- package/src/hooks/dex/useAllUserPools.ts +1 -1
- package/src/hooks/dex/useApiPool.ts +1 -1
- package/src/hooks/dex/useCreatePool.ts +6 -5
- package/src/hooks/dex/useExploitedTokens.ts +1 -1
- package/src/hooks/dex/useLiquidityMismatch.ts +2 -5
- package/src/hooks/dex/useLpPosition.ts +21 -20
- package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +40 -29
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -1
- package/src/hooks/dex/usePoolEvents.ts +1 -1
- package/src/hooks/dex/usePools.ts +1 -1
- package/src/hooks/dex/usePriceImpact.ts +40 -0
- package/src/hooks/dex/useSingleAggregatorQuote.ts +350 -0
- package/src/hooks/enso/useBendZapSupply.ts +216 -0
- package/src/hooks/enso/useEnsoSwapBundle.ts +107 -0
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +43 -0
- package/src/hooks/enso/useZapStakeBera.ts +113 -0
- package/src/hooks/{index.ts → exports.ts} +17 -10
- package/src/hooks/governance/useCreateProposal.ts +8 -8
- package/src/hooks/governance/usePollAllProposals.ts +1 -1
- package/src/hooks/governance/usePollProposal.ts +1 -1
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
- package/src/hooks/governance/usePollUserDelegates.ts +1 -1
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/honey/useCappedGlobally.ts +2 -1
- package/src/hooks/honey/useCappedRelatively.ts +1 -1
- package/src/hooks/honey/useCollateralWeights.ts +2 -1
- package/src/hooks/honey/useHoneyAlerts.ts +11 -11
- package/src/hooks/honey/useHoneyBalances.ts +7 -3
- package/src/hooks/honey/useHoneyGlobalData.ts +2 -1
- package/src/hooks/honey/useHoneySwapState.ts +2 -1
- package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -1
- package/src/hooks/honey/useIsBadCollateralAsset.ts +2 -1
- package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -1
- package/src/hooks/honey/usePythLatestPrices.ts +1 -1
- package/src/hooks/pol/useOnChainRewardVault.ts +3 -2
- package/src/hooks/pol/usePollGlobalData.ts +1 -1
- package/src/hooks/pol/usePollMarkets.ts +1 -1
- package/src/hooks/pol/useQueuedBeraUnlock.ts +17 -15
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +6 -3
- package/src/hooks/pol/useRewardVault.ts +1 -1
- package/src/hooks/pol/useRewardVaults.ts +1 -1
- package/src/hooks/pol/useSWBeraVaultMetadata.ts +35 -0
- package/src/hooks/pol/useStakedAPR.ts +38 -0
- package/src/hooks/pol/useStakedData.ts +117 -0
- package/src/hooks/pol/useStakedSnapshots.ts +52 -0
- package/src/hooks/pol/useTotalStakedAmount.ts +30 -0
- package/src/hooks/pol/useUserVaultInfo.ts +1 -1
- package/src/hooks/pol/useVaultValidators.ts +1 -1
- package/src/hooks/tokens/useMultipleTokenInformation.ts +15 -6
- package/src/hooks/tokens/usePollAllowances.ts +15 -19
- package/src/hooks/tokens/usePollBalance.ts +8 -4
- package/src/hooks/tokens/usePollWalletBalances.ts +14 -11
- package/src/hooks/tokens/useStakingTokenInformation.ts +2 -1
- package/src/hooks/tokens/useTokenCurrentPrice.ts +4 -2
- package/src/hooks/tokens/useTokenCurrentPrices.ts +92 -13
- package/src/hooks/tokens/useTokenInformation.ts +11 -6
- package/src/hooks/tokens/useTokenPrice.ts +21 -0
- package/src/hooks/tokens/useTokenPrices.ts +133 -0
- package/src/hooks/tokens/useTokens.ts +1 -0
- package/src/hooks/tokens/useUnderlyingAsset.ts +23 -0
- package/src/hooks/useContractWrite/useBeraContractWrite.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +1 -1
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
- package/src/hooks/validators/useManagedValidatorByAccount.ts +1 -1
- package/src/hooks/validators/useManagedValidatorRole.ts +1 -1
- package/src/hooks/validators/useOnChainValidator.ts +1 -1
- package/src/hooks/validators/useStakingPoolBatch.ts +1 -1
- package/src/hooks/validators/useUserActiveValidators.ts +1 -1
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
- package/src/hooks/validators/useUserClaimableIncentives.ts +8 -8
- package/src/hooks/validators/useValidator.ts +1 -1
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
- package/src/hooks/validators/useValidatorCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -1
- package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
- package/src/types/{dex.ts → dex.d.ts} +96 -67
- package/src/types/{enso.ts → enso.d.ts} +1 -1
- package/src/types/exports.ts +8 -0
- package/src/types/{global.ts → global.d.ts} +1 -30
- package/src/types/{governance.ts → governance.d.ts} +2 -64
- package/src/types/{honeySwap.ts → honeySwap.d.ts} +1 -13
- package/src/types/{pol.ts → pol.d.ts} +12 -1
- package/src/types/staking.d.ts +22 -0
- package/src/utils/createEmitter.ts +122 -0
- package/src/utils/createEmitter.unit.test.ts +149 -0
- package/src/utils/{index.ts → exports.ts} +3 -2
- package/src/utils/filter.ts +34 -0
- package/src/utils/formatNumber.ts +1 -1
- package/src/utils/formatNumber.unit.test.ts +2 -1
- package/src/utils/formatTokenList.ts +4 -10
- package/src/utils/getHoneySwapMessage.test.ts +1 -2
- package/src/utils/getServerSideClient.ts +4 -5
- package/src/utils/isDifferenceExceedingThreshold.ts +1 -1
- package/src/utils/layerZeroScan.ts +122 -0
- package/src/utils/math.ts +1 -1
- package/src/utils/parseWhiskToken.ts +15 -0
- package/src/utils/poolNamings.ts +1 -1
- package/src/utils/tokens.ts +23 -7
- package/dist/HoneyConfigProvider-6PXZJMSU.d.cts +0 -562
- package/dist/HoneyConfigProvider-CwDFrt02.d.ts +0 -562
- package/dist/abi/index.cjs +0 -2
- package/dist/abi/index.cjs.map +0 -1
- package/dist/abi/index.mjs +0 -2
- package/dist/actions/index.cjs +0 -2
- package/dist/actions/index.cjs.map +0 -1
- package/dist/actions/index.mjs +0 -2
- package/dist/aggregatorsRouter-Cny4B_MB.d.cts +0 -593
- package/dist/aggregatorsRouter-Cny4B_MB.d.ts +0 -593
- package/dist/chunk-22MQVFHP.cjs +0 -2
- package/dist/chunk-22MQVFHP.cjs.map +0 -1
- package/dist/chunk-3TKSVFZ3.mjs +0 -2
- package/dist/chunk-3TKSVFZ3.mjs.map +0 -1
- package/dist/chunk-6VF3RF53.cjs +0 -3
- package/dist/chunk-6VF3RF53.cjs.map +0 -1
- package/dist/chunk-6W22TFYA.mjs +0 -2
- package/dist/chunk-6W22TFYA.mjs.map +0 -1
- package/dist/chunk-AMRJ4B36.mjs +0 -2
- package/dist/chunk-AMRJ4B36.mjs.map +0 -1
- package/dist/chunk-DS2ZDVKU.mjs +0 -2
- package/dist/chunk-DS2ZDVKU.mjs.map +0 -1
- package/dist/chunk-ED43NYSE.cjs +0 -2
- package/dist/chunk-ED43NYSE.cjs.map +0 -1
- package/dist/chunk-EU4WFADK.cjs +0 -2
- package/dist/chunk-EU4WFADK.cjs.map +0 -1
- package/dist/chunk-HCTFDGXL.mjs +0 -2
- package/dist/chunk-HCTFDGXL.mjs.map +0 -1
- package/dist/chunk-IOSYBHKU.mjs +0 -2
- package/dist/chunk-IOSYBHKU.mjs.map +0 -1
- package/dist/chunk-JMKLDDKY.cjs +0 -2
- package/dist/chunk-JMKLDDKY.cjs.map +0 -1
- package/dist/chunk-KMKUXP2S.mjs +0 -3
- package/dist/chunk-KMKUXP2S.mjs.map +0 -1
- package/dist/chunk-OJXJ6CZ4.mjs +0 -4
- package/dist/chunk-OJXJ6CZ4.mjs.map +0 -1
- package/dist/chunk-PHIOKO3A.mjs +0 -2
- package/dist/chunk-PHIOKO3A.mjs.map +0 -1
- package/dist/chunk-QCK474XD.cjs +0 -2
- package/dist/chunk-QCK474XD.cjs.map +0 -1
- package/dist/chunk-REDXXUK7.cjs +0 -2
- package/dist/chunk-REDXXUK7.cjs.map +0 -1
- package/dist/chunk-S74ZMG2G.cjs +0 -2
- package/dist/chunk-S74ZMG2G.cjs.map +0 -1
- package/dist/chunk-TOAXF4YW.cjs +0 -2
- package/dist/chunk-TOAXF4YW.cjs.map +0 -1
- package/dist/chunk-UZ5CB33M.cjs +0 -2
- package/dist/chunk-UZ5CB33M.cjs.map +0 -1
- package/dist/chunk-VYWYJR63.mjs +0 -2
- package/dist/chunk-VYWYJR63.mjs.map +0 -1
- package/dist/chunk-XFPTQMAK.cjs +0 -4
- package/dist/chunk-XFPTQMAK.cjs.map +0 -1
- package/dist/chunk-YK4NINF5.mjs +0 -2
- package/dist/chunk-YK4NINF5.mjs.map +0 -1
- package/dist/contexts/index.cjs +0 -2
- package/dist/contexts/index.cjs.map +0 -1
- package/dist/contexts/index.mjs +0 -2
- package/dist/contexts/index.mjs.map +0 -1
- package/dist/enum/index.cjs +0 -2
- package/dist/enum/index.cjs.map +0 -1
- package/dist/enum/index.d.cts +0 -31
- package/dist/enum/index.d.ts +0 -31
- package/dist/enum/index.mjs +0 -2
- package/dist/enum/index.mjs.map +0 -1
- package/dist/errors/index.cjs +0 -2
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.d.cts +0 -204
- package/dist/errors/index.d.ts +0 -204
- package/dist/errors/index.mjs +0 -2
- package/dist/errors/index.mjs.map +0 -1
- package/dist/hooks/index.cjs +0 -4
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.mjs +0 -4
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/staking-F9Nx9TKD.d.ts +0 -246
- package/dist/staking-f4BpYH7l.d.cts +0 -246
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -56
- package/dist/types/index.d.ts +0 -56
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.mjs +0 -2
- package/dist/utils/index.mjs.map +0 -1
- package/src/actions/dex/getTransactionCount.ts +0 -29
- package/src/actions/enso/bend.ts +0 -143
- package/src/actions/enso/getEnsoUserToken.debug.test.ts +0 -57
- package/src/contexts/berajsProvider/context.tsx +0 -49
- package/src/contexts/berajsProvider/index.ts +0 -2
- package/src/contexts/berajsProvider/useBeraJs.ts +0 -18
- package/src/hooks/dex/usePollVaultIsPaused.ts +0 -30
- package/src/hooks/enso/useBendTransactionRequests.ts +0 -247
- package/src/hooks/enso/useEnsoZap.ts +0 -166
- package/src/hooks/enso/useZapTransactionRequests.ts +0 -81
- package/src/hooks/pol/useEarnedStakedBeraVault.ts +0 -59
- package/src/hooks/pol/useStakedBeraSnapshots.ts +0 -27
- package/src/hooks/transactions/TransactionStoreContext.tsx +0 -59
- package/src/hooks/transactions/transactionStore.ts +0 -275
- package/src/hooks/transactions/transactionStore.unit.test.ts +0 -508
- package/src/hooks/transactions/useAddRecentTransaction.ts +0 -29
- package/src/hooks/transactions/useRecentTransactions.ts +0 -27
- package/src/hooks/validators/validatorRoleManager.ts +0 -0
- package/src/types/index.ts +0 -8
- package/src/types/staking.ts +0 -7
- package/src/utils/formatAggregatorsQuotes.ts +0 -57
- package/src/utils/formatAggregatorsQuotes.unit.test.ts +0 -191
- package/src/utils/sentryBeforeSend.ts +0 -52
- /package/dist/{abi/index.mjs.map → errors/exports.mjs.map} +0 -0
- /package/dist/{actions/index.mjs.map → types/exports.mjs.map} +0 -0
- /package/src/actions/dex/{__tests__ → aggregators}/haiku.integration.test.ts +0 -0
- /package/src/types/{bribe-boost.ts → bribe-boost.d.ts} +0 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import useSWR from "swr";
|
|
4
|
+
import { type Address, formatEther, parseUnits, zeroAddress } from "viem";
|
|
5
|
+
|
|
6
|
+
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
7
|
+
|
|
8
|
+
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
9
|
+
|
|
10
|
+
import { ensoErc4626 } from "~/actions/dex/aggregators/enso/ensoErc4626";
|
|
11
|
+
import { POLLING } from "~/enum/polling";
|
|
12
|
+
import {
|
|
13
|
+
assertAddress,
|
|
14
|
+
assertDefined,
|
|
15
|
+
assertPublicClient,
|
|
16
|
+
} from "~/errors/assert";
|
|
17
|
+
import { usePollBalance } from "~/hooks/tokens/usePollBalance";
|
|
18
|
+
import type { BalanceToken, MinimalERC20 } from "~/types/dex";
|
|
19
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
20
|
+
import { isToken } from "~/utils/tokens";
|
|
21
|
+
import { useGetConvertToAssets } from "../bend/useGetConvertToAssets";
|
|
22
|
+
import { usePriceImpact } from "../dex/usePriceImpact";
|
|
23
|
+
import { useTokenPrices } from "../tokens/useTokenPrices";
|
|
24
|
+
|
|
25
|
+
type UseBendZapSupplyArgs = {
|
|
26
|
+
/*
|
|
27
|
+
* The input token to swap from
|
|
28
|
+
*/
|
|
29
|
+
tokenIn?: BalanceToken;
|
|
30
|
+
/*
|
|
31
|
+
* The loan token to swap to
|
|
32
|
+
*/
|
|
33
|
+
loanToken: MinimalERC20;
|
|
34
|
+
/*
|
|
35
|
+
* The bend vault to swap to
|
|
36
|
+
*/
|
|
37
|
+
bendVault: MinimalERC20;
|
|
38
|
+
/*
|
|
39
|
+
* The reward vault to swap to
|
|
40
|
+
*/
|
|
41
|
+
rewardVault?: Address;
|
|
42
|
+
/*
|
|
43
|
+
* The amount of input token to swap
|
|
44
|
+
*/
|
|
45
|
+
amount?: string;
|
|
46
|
+
/*
|
|
47
|
+
* The slippage tolerance to use for the route in percentage
|
|
48
|
+
*/
|
|
49
|
+
slippage?: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get the bend zap supply transaction requests for swapping tokens using Enso.
|
|
54
|
+
* @param {UseBendZapSupplyArgs} props - The props for the hook see {@link UseBendZapSupplyArgs}
|
|
55
|
+
* @returns {DefaultHookReturnType<GetZapTransactionResponse> & {tokens: BalanceToken[], refresh: () => void}}
|
|
56
|
+
*
|
|
57
|
+
* The bend transaction response data with polling enabled, see {@link GetZapTransactionResponse} and {@link BalanceToken}
|
|
58
|
+
* @remarks The hook is only enabled when all parameters are provided and amount is greater than 0
|
|
59
|
+
*/
|
|
60
|
+
export function useBendZapSupply(
|
|
61
|
+
{
|
|
62
|
+
tokenIn,
|
|
63
|
+
loanToken,
|
|
64
|
+
bendVault,
|
|
65
|
+
rewardVault,
|
|
66
|
+
amount,
|
|
67
|
+
slippage,
|
|
68
|
+
}: UseBendZapSupplyArgs,
|
|
69
|
+
options?: DefaultHookOptions,
|
|
70
|
+
) {
|
|
71
|
+
const { getTokenPrice } = useTokenPrices({
|
|
72
|
+
tokens: tokenIn && loanToken ? [tokenIn, loanToken] : undefined,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const swrResponse = useBendZapSupplyHelper(
|
|
76
|
+
{
|
|
77
|
+
tokenIn,
|
|
78
|
+
loanToken,
|
|
79
|
+
bendVault,
|
|
80
|
+
rewardVault,
|
|
81
|
+
amount: amount
|
|
82
|
+
? parseUnits(amount, tokenIn?.decimals ?? 18).toString()
|
|
83
|
+
: undefined,
|
|
84
|
+
slippage,
|
|
85
|
+
},
|
|
86
|
+
options,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const { data: zapSupplyAmount } = useGetConvertToAssets({
|
|
90
|
+
sharesAmount: BigInt(swrResponse.data?.amountOut ?? 0),
|
|
91
|
+
vaultAddress: bendVault.address,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const { data: priceImpact } = usePriceImpact({
|
|
95
|
+
tokenIn: tokenIn,
|
|
96
|
+
tokenOut: loanToken,
|
|
97
|
+
formattedAmountIn: amount,
|
|
98
|
+
formattedAmountOut: zapSupplyAmount?.formatted ?? "0",
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const isCrossChain = tokenIn?.chainId && tokenIn.chainId !== berachainChainId;
|
|
102
|
+
|
|
103
|
+
// fetch native token balance for source chain (needed for bridge fee check)
|
|
104
|
+
const { data: nativeBalanceData, isLoading: isNativeBalanceLoading } =
|
|
105
|
+
usePollBalance(
|
|
106
|
+
{
|
|
107
|
+
address: zeroAddress,
|
|
108
|
+
chainId: isCrossChain ? tokenIn?.chainId : undefined,
|
|
109
|
+
},
|
|
110
|
+
{ opts: { isEnabled: !!isCrossChain } },
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// for cross-chain zaps, check if transaction value exceeds native token balance
|
|
114
|
+
// (tx.value includes bridge fees that must be paid in native token)
|
|
115
|
+
const transactionValue =
|
|
116
|
+
swrResponse.data?.getCalldata?.({ account: zeroAddress })?.value ?? 0n;
|
|
117
|
+
|
|
118
|
+
// check if user has enough native token for bridge fees
|
|
119
|
+
const nativeBalance = nativeBalanceData?.balance ?? {
|
|
120
|
+
raw: "0",
|
|
121
|
+
formatted: "0",
|
|
122
|
+
};
|
|
123
|
+
const hasInsufficientNativeBalance =
|
|
124
|
+
isCrossChain &&
|
|
125
|
+
transactionValue > 0n &&
|
|
126
|
+
!isNativeBalanceLoading &&
|
|
127
|
+
transactionValue > BigInt(nativeBalance.raw);
|
|
128
|
+
|
|
129
|
+
// formatted native fee for gas reserve display
|
|
130
|
+
const nativeFee =
|
|
131
|
+
isCrossChain && transactionValue > 0n
|
|
132
|
+
? formatEther(transactionValue)
|
|
133
|
+
: undefined;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
...swrResponse,
|
|
137
|
+
zapSupplyAmount,
|
|
138
|
+
priceImpact,
|
|
139
|
+
hasInsufficientNativeBalance,
|
|
140
|
+
isCrossChain,
|
|
141
|
+
nativeFee,
|
|
142
|
+
refresh: () => {
|
|
143
|
+
swrResponse.mutate();
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function useBendZapSupplyHelper(
|
|
149
|
+
{
|
|
150
|
+
tokenIn,
|
|
151
|
+
loanToken,
|
|
152
|
+
bendVault,
|
|
153
|
+
rewardVault,
|
|
154
|
+
amount,
|
|
155
|
+
slippage,
|
|
156
|
+
}: UseBendZapSupplyArgs,
|
|
157
|
+
options?: DefaultHookOptions,
|
|
158
|
+
) {
|
|
159
|
+
const { address: fromAddress } = useBeraWallet();
|
|
160
|
+
|
|
161
|
+
const isEnabled =
|
|
162
|
+
!!tokenIn &&
|
|
163
|
+
!!loanToken &&
|
|
164
|
+
!!bendVault &&
|
|
165
|
+
!!amount &&
|
|
166
|
+
!!fromAddress &&
|
|
167
|
+
!isToken(loanToken.address, tokenIn.address) &&
|
|
168
|
+
tokenIn.chainId &&
|
|
169
|
+
Number(amount) > 0 &&
|
|
170
|
+
!!slippage;
|
|
171
|
+
|
|
172
|
+
const publicClientBeraChain = usePublicClient();
|
|
173
|
+
const QUERY_KEY = isEnabled
|
|
174
|
+
? ([
|
|
175
|
+
"useBendZapSupply",
|
|
176
|
+
tokenIn,
|
|
177
|
+
loanToken,
|
|
178
|
+
bendVault,
|
|
179
|
+
rewardVault,
|
|
180
|
+
amount,
|
|
181
|
+
slippage,
|
|
182
|
+
] as const)
|
|
183
|
+
: null;
|
|
184
|
+
|
|
185
|
+
return useSWR(
|
|
186
|
+
QUERY_KEY,
|
|
187
|
+
async ([
|
|
188
|
+
,
|
|
189
|
+
tokenIn,
|
|
190
|
+
loanToken,
|
|
191
|
+
bendVault,
|
|
192
|
+
rewardVault,
|
|
193
|
+
amount,
|
|
194
|
+
slippage,
|
|
195
|
+
]) => {
|
|
196
|
+
assertPublicClient(publicClientBeraChain);
|
|
197
|
+
assertAddress(fromAddress, "fromAddress");
|
|
198
|
+
assertAddress(tokenIn?.address, "tokenInAddress");
|
|
199
|
+
assertDefined(tokenIn?.chainId, "tokenInChainId");
|
|
200
|
+
|
|
201
|
+
return await ensoErc4626.getQuote({
|
|
202
|
+
tokenIn,
|
|
203
|
+
tokenOut: bendVault,
|
|
204
|
+
underlyingToken: loanToken,
|
|
205
|
+
amount,
|
|
206
|
+
slippage,
|
|
207
|
+
account: fromAddress,
|
|
208
|
+
rewardVault,
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
...options?.opts,
|
|
213
|
+
refreshInterval: POLLING.NORMAL,
|
|
214
|
+
},
|
|
215
|
+
);
|
|
216
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { getPublicClient } from "@wagmi/core";
|
|
4
|
+
import useSWR from "swr";
|
|
5
|
+
import { parseUnits } from "viem";
|
|
6
|
+
|
|
7
|
+
import { defaultChainId as berachainChainId } from "@berachain/config/internal";
|
|
8
|
+
|
|
9
|
+
import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
10
|
+
|
|
11
|
+
import { getEnsoClient } from "~/actions/clients/getEnsoClient";
|
|
12
|
+
import { getEnsoSwapBundle } from "~/actions/enso/getEnsoSwapBundle";
|
|
13
|
+
import { POLLING } from "~/enum/polling";
|
|
14
|
+
import {
|
|
15
|
+
assertAddress,
|
|
16
|
+
assertAmount,
|
|
17
|
+
assertDefined,
|
|
18
|
+
assertPublicClient,
|
|
19
|
+
} from "~/errors/assert";
|
|
20
|
+
import type { BalanceToken, MinimalERC20 } from "~/types/dex";
|
|
21
|
+
import type { GetZapTransactionResponse } from "~/types/enso";
|
|
22
|
+
import { usePollWalletBalances } from "../tokens/usePollWalletBalances";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the swap bundle for swapping tokens using Enso.
|
|
26
|
+
* @param {Pick<BalanceToken, "address" | "decimals">} tokenIn - The input token to swap from
|
|
27
|
+
* @param {Pick<BalanceToken, "address" | "decimals">} tokenOut - The output token to swap to
|
|
28
|
+
* @param {string} amount - The amount of input token to swap
|
|
29
|
+
* @param {number} slippage - The slippage tolerance to use for the route in percentage
|
|
30
|
+
* @returns {DefaultHookReturnType<GetZapTransactionResponse> & {tokens: BalanceToken[], refresh: () => void}}
|
|
31
|
+
*
|
|
32
|
+
* The zap transaction response data with polling enabled, see {@link GetZapTransactionResponse} and {@link BalanceToken}
|
|
33
|
+
* @remarks The hook is only enabled when all parameters are provided and amount is greater than 0
|
|
34
|
+
*/
|
|
35
|
+
export function useEnsoSwapBundle({
|
|
36
|
+
tokenIn,
|
|
37
|
+
tokenOut,
|
|
38
|
+
amount,
|
|
39
|
+
slippage,
|
|
40
|
+
}: {
|
|
41
|
+
tokenIn?: Pick<MinimalERC20, "address" | "decimals" | "chainId">;
|
|
42
|
+
tokenOut?: Pick<MinimalERC20, "address" | "decimals">;
|
|
43
|
+
amount?: string;
|
|
44
|
+
slippage?: number;
|
|
45
|
+
}) {
|
|
46
|
+
const { address: fromAddress } = useBeraWallet();
|
|
47
|
+
const wagmiConfig = useConfig();
|
|
48
|
+
const ensoClient = getEnsoClient();
|
|
49
|
+
|
|
50
|
+
const { refresh: refreshBalances } = usePollWalletBalances();
|
|
51
|
+
|
|
52
|
+
const isEnabled =
|
|
53
|
+
!!tokenIn &&
|
|
54
|
+
!!tokenOut &&
|
|
55
|
+
!!amount &&
|
|
56
|
+
Number(amount) > 0 &&
|
|
57
|
+
!!slippage &&
|
|
58
|
+
!!fromAddress &&
|
|
59
|
+
!!tokenIn.chainId;
|
|
60
|
+
|
|
61
|
+
const QUERY_KEY = isEnabled
|
|
62
|
+
? (["useEnsoSwapBundle", tokenIn, tokenOut, amount, slippage] as const)
|
|
63
|
+
: null;
|
|
64
|
+
|
|
65
|
+
const swrResponse = useSWR(
|
|
66
|
+
QUERY_KEY,
|
|
67
|
+
async ([, tokenIn, tokenOut, amount, slippage]) => {
|
|
68
|
+
assertAddress(fromAddress, "fromAddress");
|
|
69
|
+
assertAddress(tokenIn?.address, "tokenInAddress");
|
|
70
|
+
assertDefined(tokenIn?.chainId, "tokenInChainId");
|
|
71
|
+
assertAddress(tokenOut?.address, "tokenOutAddress");
|
|
72
|
+
assertAmount(amount, "amount");
|
|
73
|
+
assertAmount(slippage, "slippage");
|
|
74
|
+
|
|
75
|
+
const publicClient = getPublicClient(wagmiConfig, {
|
|
76
|
+
chainId: tokenIn.chainId,
|
|
77
|
+
});
|
|
78
|
+
assertPublicClient(publicClient);
|
|
79
|
+
|
|
80
|
+
const rawAmount = parseUnits(amount, tokenIn.decimals).toString();
|
|
81
|
+
|
|
82
|
+
return getEnsoSwapBundle({
|
|
83
|
+
fromAddress,
|
|
84
|
+
amountIn: rawAmount,
|
|
85
|
+
tokenIn: tokenIn.address,
|
|
86
|
+
tokenOut: tokenOut.address,
|
|
87
|
+
chainId: tokenIn.chainId,
|
|
88
|
+
ensoClient,
|
|
89
|
+
destinationChainId: berachainChainId,
|
|
90
|
+
slippage,
|
|
91
|
+
publicClient,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
refreshInterval: POLLING.NORMAL,
|
|
96
|
+
isEnabled: isEnabled,
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...swrResponse,
|
|
102
|
+
refresh: () => {
|
|
103
|
+
swrResponse.mutate();
|
|
104
|
+
refreshBalances();
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
|
|
3
|
+
import { useBeraWallet, useConfig } from "@berachain/wagmi/hooks";
|
|
4
|
+
|
|
5
|
+
import { getEnsoClient } from "~/actions/clients/getEnsoClient";
|
|
6
|
+
import { getEnsoUserTokensWithBalances } from "~/actions/enso/getEnsoUserTokensWithBalances";
|
|
7
|
+
import { POLLING } from "~/enum/polling";
|
|
8
|
+
import type { BalanceToken } from "~/types/dex";
|
|
9
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
10
|
+
|
|
11
|
+
export function useEnsoUserTokensWithBalances(
|
|
12
|
+
{ chainId }: { chainId?: number } = {},
|
|
13
|
+
options?: DefaultHookOptions,
|
|
14
|
+
) {
|
|
15
|
+
const { address: fromAddress } = useBeraWallet();
|
|
16
|
+
const wagmiConfig = useConfig();
|
|
17
|
+
const isEnabled = !!fromAddress && (options?.opts?.isEnabled ?? true);
|
|
18
|
+
|
|
19
|
+
const QUERY_KEY =
|
|
20
|
+
isEnabled && wagmiConfig
|
|
21
|
+
? (["useEnsoUserTokensWithBalances", fromAddress, chainId] as const)
|
|
22
|
+
: null;
|
|
23
|
+
|
|
24
|
+
const swrResponse = useSWR(
|
|
25
|
+
QUERY_KEY,
|
|
26
|
+
async ([, fromAddress, chainId]): Promise<BalanceToken[]> =>
|
|
27
|
+
getEnsoUserTokensWithBalances({
|
|
28
|
+
account: fromAddress,
|
|
29
|
+
wagmiConfig,
|
|
30
|
+
chainId: chainId ?? "all",
|
|
31
|
+
ensoClient: getEnsoClient(),
|
|
32
|
+
}),
|
|
33
|
+
{
|
|
34
|
+
refreshInterval: POLLING.NORMAL,
|
|
35
|
+
isEnabled,
|
|
36
|
+
...options?.opts,
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
...swrResponse,
|
|
41
|
+
refresh: () => swrResponse.mutate(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import useSWR from "swr";
|
|
4
|
+
import { formatUnits, parseUnits } from "viem";
|
|
5
|
+
|
|
6
|
+
import { chainConfigs, defaultChainId } from "@berachain/config/internal";
|
|
7
|
+
|
|
8
|
+
import { useBeraWallet } from "@berachain/wagmi/hooks";
|
|
9
|
+
|
|
10
|
+
import { ensoErc4626 } from "~/actions/dex/aggregators/enso/ensoErc4626";
|
|
11
|
+
import { POLLING } from "~/enum/polling";
|
|
12
|
+
import type { MinimalERC20 } from "~/types/dex";
|
|
13
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
14
|
+
import { usePriceImpact } from "../dex/usePriceImpact";
|
|
15
|
+
|
|
16
|
+
type UseZapStakeBeraArgs = {
|
|
17
|
+
inputToken: MinimalERC20 | undefined;
|
|
18
|
+
amount: string;
|
|
19
|
+
underlyingToken: MinimalERC20 | undefined;
|
|
20
|
+
slippage?: number;
|
|
21
|
+
inputTokenPrice?: number;
|
|
22
|
+
tokenOut: MinimalERC20;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* hook to get zap stake BERA transaction data from enso.
|
|
27
|
+
* supports cross-chain zaps from any chain to berachain staking.
|
|
28
|
+
*/
|
|
29
|
+
export function useZapStakeBera(
|
|
30
|
+
{
|
|
31
|
+
inputToken,
|
|
32
|
+
amount,
|
|
33
|
+
underlyingToken,
|
|
34
|
+
slippage,
|
|
35
|
+
tokenOut,
|
|
36
|
+
}: UseZapStakeBeraArgs,
|
|
37
|
+
options?: DefaultHookOptions,
|
|
38
|
+
) {
|
|
39
|
+
const { address: account } = useBeraWallet();
|
|
40
|
+
// enso route simulation needs a real EOA-like address; zeroAddress can fail simulation.
|
|
41
|
+
// use the connected wallet when available, otherwise fallback to our configured aggregator executor.
|
|
42
|
+
const quoteAccount =
|
|
43
|
+
account ?? chainConfigs[defaultChainId].bex.aggregatorsRouterExecutor;
|
|
44
|
+
|
|
45
|
+
const isEnabled =
|
|
46
|
+
!!inputToken &&
|
|
47
|
+
!!amount &&
|
|
48
|
+
Number(amount) > 0 &&
|
|
49
|
+
!!inputToken.chainId &&
|
|
50
|
+
!!underlyingToken &&
|
|
51
|
+
!!slippage;
|
|
52
|
+
|
|
53
|
+
const QUERY_KEY = isEnabled
|
|
54
|
+
? ([
|
|
55
|
+
"useZapStakeBera",
|
|
56
|
+
inputToken,
|
|
57
|
+
amount,
|
|
58
|
+
quoteAccount,
|
|
59
|
+
slippage,
|
|
60
|
+
underlyingToken,
|
|
61
|
+
tokenOut,
|
|
62
|
+
] as const)
|
|
63
|
+
: null;
|
|
64
|
+
|
|
65
|
+
const swrResponse = useSWR(
|
|
66
|
+
QUERY_KEY,
|
|
67
|
+
async ([
|
|
68
|
+
,
|
|
69
|
+
inputToken,
|
|
70
|
+
amount,
|
|
71
|
+
quoteAccount,
|
|
72
|
+
slippage,
|
|
73
|
+
underlyingToken,
|
|
74
|
+
tokenOut,
|
|
75
|
+
]) => {
|
|
76
|
+
const rawAmount = parseUnits(amount, inputToken.decimals).toString();
|
|
77
|
+
|
|
78
|
+
return ensoErc4626.getQuote({
|
|
79
|
+
account: quoteAccount,
|
|
80
|
+
amount: rawAmount,
|
|
81
|
+
tokenIn: inputToken,
|
|
82
|
+
underlyingToken: underlyingToken,
|
|
83
|
+
tokenOut: tokenOut,
|
|
84
|
+
slippage,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
...options?.opts,
|
|
89
|
+
refreshInterval: POLLING.NORMAL,
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
const { data: priceImpactPercentage } = usePriceImpact({
|
|
93
|
+
tokenIn: inputToken,
|
|
94
|
+
tokenOut: tokenOut,
|
|
95
|
+
formattedAmountIn: amount,
|
|
96
|
+
formattedAmountOut: formatUnits(
|
|
97
|
+
BigInt(swrResponse.data?.amountOut ?? "0"),
|
|
98
|
+
tokenOut.decimals,
|
|
99
|
+
),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
...swrResponse,
|
|
104
|
+
data: {
|
|
105
|
+
...swrResponse.data,
|
|
106
|
+
priceImpactPercentage,
|
|
107
|
+
isCrossChain: inputToken && tokenOut.chainId !== inputToken?.chainId,
|
|
108
|
+
},
|
|
109
|
+
refresh: () => {
|
|
110
|
+
swrResponse.mutate();
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file
|
|
2
|
+
* This file avoids more barrel files.
|
|
3
3
|
*
|
|
4
4
|
* It's used to speed up the build process.
|
|
5
5
|
*
|
|
@@ -24,9 +24,15 @@ export * from "./dex/usePool";
|
|
|
24
24
|
export * from "./dex/usePoolEvents";
|
|
25
25
|
export * from "./dex/usePoolHistoricalData";
|
|
26
26
|
export * from "./dex/usePools";
|
|
27
|
-
export * from "./
|
|
28
|
-
|
|
29
|
-
export
|
|
27
|
+
export * from "./dex/usePriceImpact";
|
|
28
|
+
// let's avoid exporting the raw_useSingleAggregatorQuote hook
|
|
29
|
+
export {
|
|
30
|
+
USE_AGGREGATORS_QUOTES_QUERY_KEY,
|
|
31
|
+
useSingleAggregatorQuote,
|
|
32
|
+
} from "./dex/useSingleAggregatorQuote";
|
|
33
|
+
export * from "./enso/useBendZapSupply";
|
|
34
|
+
export * from "./enso/useEnsoSwapBundle";
|
|
35
|
+
export * from "./enso/useZapStakeBera";
|
|
30
36
|
export { useCreateProposal } from "./governance/useCreateProposal";
|
|
31
37
|
export * from "./governance/useGetPastVotes";
|
|
32
38
|
export * from "./governance/useHasVoted";
|
|
@@ -57,7 +63,6 @@ export * from "./perps/usePythUpdateFee";
|
|
|
57
63
|
export * from "./pol/useBgtAprSimulation";
|
|
58
64
|
export { useBgtUnstakedBalance } from "./pol/useBgtUnstakedBalance";
|
|
59
65
|
export { useClaimableFees } from "./pol/useClaimableFees";
|
|
60
|
-
export * from "./pol/useEarnedStakedBeraVault";
|
|
61
66
|
export * from "./pol/useHighestVaultsAPR";
|
|
62
67
|
export * from "./pol/usePollGlobalData";
|
|
63
68
|
export * from "./pol/usePollMarkets";
|
|
@@ -70,7 +75,11 @@ export * from "./pol/useRewardVaultIncentives";
|
|
|
70
75
|
export { useRewardVaultRewards } from "./pol/useRewardVaultRewards";
|
|
71
76
|
export * from "./pol/useRewardVaults";
|
|
72
77
|
export { useRewardVaults } from "./pol/useRewardVaults";
|
|
73
|
-
export * from "./pol/
|
|
78
|
+
export * from "./pol/useStakedAPR";
|
|
79
|
+
export * from "./pol/useStakedData";
|
|
80
|
+
export * from "./pol/useStakedSnapshots";
|
|
81
|
+
export * from "./pol/useSWBeraVaultMetadata";
|
|
82
|
+
export * from "./pol/useTotalStakedAmount";
|
|
74
83
|
export { useUserVaultInfo } from "./pol/useUserVaultInfo";
|
|
75
84
|
export { useUserVaults } from "./pol/useUserVaults";
|
|
76
85
|
export * from "./pol/useVaultAddress";
|
|
@@ -85,12 +94,10 @@ export * from "./tokens/useStakingTokenInformation";
|
|
|
85
94
|
export * from "./tokens/useTokenCurrentPrice";
|
|
86
95
|
export * from "./tokens/useTokenCurrentPrices";
|
|
87
96
|
export * from "./tokens/useTokenInformation";
|
|
97
|
+
export * from "./tokens/useTokenPrice";
|
|
98
|
+
export * from "./tokens/useTokenPrices";
|
|
88
99
|
export * from "./tokens/useTokens";
|
|
89
100
|
export * from "./tokens/useTotalSupply";
|
|
90
|
-
export * from "./transactions/TransactionStoreContext";
|
|
91
|
-
export * from "./transactions/transactionStore";
|
|
92
|
-
export * from "./transactions/useAddRecentTransaction";
|
|
93
|
-
export * from "./transactions/useRecentTransactions";
|
|
94
101
|
export * from "./useBlockToTimestamp";
|
|
95
102
|
export * from "./useContractWrite";
|
|
96
103
|
export * from "./useGetVerifiedAbi";
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
import { useCallback, useEffect, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import { getProposalParams } from "~/actions/governance/getProposalParams";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "
|
|
6
|
+
import { ProposalTypeEnum } from "~/enum/governance";
|
|
7
|
+
import type {
|
|
8
|
+
CustomProposal,
|
|
9
|
+
CustomProposalErrors,
|
|
10
|
+
GovernanceTopic,
|
|
11
|
+
PROPOSAL_GENRE,
|
|
12
|
+
SafeProposalAction,
|
|
13
|
+
} from "~/types/governance";
|
|
14
14
|
|
|
15
15
|
const defaultAction = {
|
|
16
16
|
type: ProposalTypeEnum.CUSTOM_PROPOSAL,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { getAllProposals } from "~/actions/governance/getAllProposals";
|
|
13
13
|
import { POLLING } from "~/enum/polling";
|
|
14
|
-
import type { DefaultHookOptions } from "~/types";
|
|
14
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
15
15
|
|
|
16
16
|
const DEFAULT_PER_PAGE = 10;
|
|
17
17
|
|
|
@@ -10,7 +10,7 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
10
10
|
import { getProposalDetails } from "~/actions/governance/getProposalDetails";
|
|
11
11
|
import { POLLING } from "~/enum/polling";
|
|
12
12
|
import { assertPublicClient } from "~/errors/assert";
|
|
13
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
13
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
14
14
|
|
|
15
15
|
export interface UsePollProposalResponse
|
|
16
16
|
extends DefaultHookReturnType<ProposalWithVotesFragment> {}
|
|
@@ -6,7 +6,7 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
6
6
|
import { governanceAbi } from "~/abi/governance/governance";
|
|
7
7
|
import { POLLING } from "~/enum/polling";
|
|
8
8
|
import { assertPublicClient } from "~/errors/assert";
|
|
9
|
-
import type { DefaultHookReturnType } from "~/types";
|
|
9
|
+
import type { DefaultHookReturnType } from "~/types/global";
|
|
10
10
|
|
|
11
11
|
export const usePollProposalThreshold = (
|
|
12
12
|
governorAddress: Address,
|
|
@@ -6,7 +6,7 @@ import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
6
6
|
import { bgtAbi } from "~/abi/pol/bgt";
|
|
7
7
|
import { POLLING } from "~/enum/polling";
|
|
8
8
|
import { assertPublicClient } from "~/errors/assert";
|
|
9
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
9
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
10
10
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
11
11
|
|
|
12
12
|
export const usePollUserDelegates = (
|
|
@@ -4,9 +4,9 @@ import type { Address } from "viem";
|
|
|
4
4
|
|
|
5
5
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
6
|
|
|
7
|
+
import { governanceAbi } from "~/abi/governance/governance";
|
|
8
|
+
import { ProposalState } from "~/enum/governance";
|
|
7
9
|
import { assertPublicClient } from "~/errors/assert";
|
|
8
|
-
import { ProposalState } from "~/types";
|
|
9
|
-
import { governanceAbi } from "../../abi/governance/governance";
|
|
10
10
|
|
|
11
11
|
const ProposalStateMap: Record<ProposalState, string> = {
|
|
12
12
|
[ProposalState.Pending]: "pending",
|
|
@@ -5,7 +5,8 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
5
5
|
import { getGlobalCapLimit } from "~/actions/honey/getGlobalCapLimit";
|
|
6
6
|
import { useHoneyConfig } from "~/contexts/HoneyConfigProvider";
|
|
7
7
|
import { assertPublicClient } from "~/errors/assert";
|
|
8
|
-
import type {
|
|
8
|
+
import type { Token } from "~/types/dex";
|
|
9
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
9
10
|
import { usePythLatestPrices } from "./usePythLatestPrices";
|
|
10
11
|
|
|
11
12
|
export interface UseCappedGloballyResponse
|
|
@@ -6,7 +6,7 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
6
6
|
import { getRelativeCapLimit } from "~/actions/honey/getRelativeCapLimit";
|
|
7
7
|
import { useHoneyConfig } from "~/contexts/HoneyConfigProvider";
|
|
8
8
|
import { assertPublicClient } from "~/errors/assert";
|
|
9
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
9
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
10
10
|
|
|
11
11
|
export interface UseCappedRelativelyResponse
|
|
12
12
|
extends DefaultHookReturnType<boolean | undefined> {}
|
|
@@ -6,7 +6,8 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
6
6
|
import { getCollateralWeights } from "~/actions/honey/getCollateralWeights";
|
|
7
7
|
import { POLLING } from "~/enum/polling";
|
|
8
8
|
import { assertPublicClient } from "~/errors/assert";
|
|
9
|
-
import type {
|
|
9
|
+
import type { Token } from "~/types/dex";
|
|
10
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
10
11
|
|
|
11
12
|
export interface UseCollateralWeightsResponse
|
|
12
13
|
extends DefaultHookReturnType<Record<Address, bigint> | undefined> {}
|