@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
3
4
|
|
|
4
5
|
import type { GetHoneyVaultsBalanceResponse } from "~/actions/honey/getHoneyVaultsBalance";
|
|
5
6
|
import {
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
} from "~/contexts/HoneyConfigProvider";
|
|
9
10
|
import type { BalanceToken, Token } from "~/types/dex";
|
|
10
11
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
12
|
+
import { isToken } from "~/utils/tokens";
|
|
11
13
|
import { useCappedGlobally } from "./useCappedGlobally";
|
|
12
14
|
import { useCappedRelatively } from "./useCappedRelatively";
|
|
13
15
|
import { useHoneyBalances } from "./useHoneyBalances";
|
|
@@ -81,14 +83,14 @@ const getIsLiquidityLowerThan = ({
|
|
|
81
83
|
state.collaterals[0].address.toLowerCase(),
|
|
82
84
|
);
|
|
83
85
|
const isLow = new BigNumber(
|
|
84
|
-
redeemedVaultBalance?.
|
|
86
|
+
redeemedVaultBalance?.balance.formatted ?? "0",
|
|
85
87
|
).lte(lowerThan);
|
|
86
88
|
// Get what collaterals are below the threshold to suggest others to the user
|
|
87
89
|
const isLiquidityLowCollaterals = collateralList.filter((coll) => {
|
|
88
90
|
const vaultBalance = vaultsBalances?.find(
|
|
89
91
|
(vault) => vault.address.toLowerCase() === coll.address.toLowerCase(),
|
|
90
92
|
);
|
|
91
|
-
return new BigNumber(vaultBalance?.
|
|
93
|
+
return new BigNumber(vaultBalance?.balance.formatted ?? "0").lte(
|
|
92
94
|
lowerThan,
|
|
93
95
|
);
|
|
94
96
|
});
|
|
@@ -133,16 +135,14 @@ const getRedeemMoreThanLiquidity = ({
|
|
|
133
135
|
(vault) => vault.address.toLowerCase() === coll.address.toLowerCase(),
|
|
134
136
|
);
|
|
135
137
|
const amountToRedeem = state.toAmount[state.collaterals.indexOf(coll)];
|
|
136
|
-
return new BigNumber(vaultBalance?.
|
|
138
|
+
return new BigNumber(vaultBalance?.balance.formatted ?? "0").lt(
|
|
137
139
|
amountToRedeem ?? "0",
|
|
138
140
|
);
|
|
139
141
|
},
|
|
140
142
|
);
|
|
141
143
|
return {
|
|
142
|
-
isMore: !!isRedeemMoreThanLiquidityCollaterals.find(
|
|
143
|
-
(coll)
|
|
144
|
-
coll.address.toLowerCase() ===
|
|
145
|
-
state.collaterals[0].address.toLowerCase(),
|
|
144
|
+
isMore: !!isRedeemMoreThanLiquidityCollaterals.find((coll) =>
|
|
145
|
+
isToken(coll, state.collaterals[0]),
|
|
146
146
|
),
|
|
147
147
|
isRedeemMoreThanLiquidityCollaterals,
|
|
148
148
|
};
|
|
@@ -169,7 +169,7 @@ function getExceedingBalance({
|
|
|
169
169
|
const isMint = state.actionType === "mint";
|
|
170
170
|
if (!isMint && honeyBalances) {
|
|
171
171
|
return new BigNumber(state.fromAmount[0]).gt(
|
|
172
|
-
honeyBalances[config.honey.token]?.
|
|
172
|
+
honeyBalances[config.honey.token]?.balance.formatted ?? "0",
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
if (
|
|
@@ -180,12 +180,12 @@ function getExceedingBalance({
|
|
|
180
180
|
) {
|
|
181
181
|
if (!state.isBasketModeEnabled) {
|
|
182
182
|
return new BigNumber(
|
|
183
|
-
honeyBalances[state.collaterals[0].address]?.
|
|
183
|
+
honeyBalances[state.collaterals[0].address]?.balance.formatted,
|
|
184
184
|
).lt(state.fromAmount[0]);
|
|
185
185
|
}
|
|
186
186
|
return state.collaterals.some((coll, idx) => {
|
|
187
187
|
const amount = state.fromAmount[idx];
|
|
188
|
-
return new BigNumber(honeyBalances[coll.address]?.
|
|
188
|
+
return new BigNumber(honeyBalances[coll.address]?.balance.formatted).lt(
|
|
189
189
|
amount,
|
|
190
190
|
);
|
|
191
191
|
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import useSWR from "swr";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useBeraWallet,
|
|
6
|
+
useConfig,
|
|
7
|
+
usePublicClient,
|
|
8
|
+
} from "@berachain/wagmi/hooks";
|
|
5
9
|
|
|
6
10
|
import { getWalletBalances } from "~/actions/tokens/getWalletBalances";
|
|
7
11
|
import { useHoneyConfig } from "~/contexts/HoneyConfigProvider";
|
|
@@ -38,7 +42,7 @@ export const useHoneyBalances = (): DefaultHookReturnType<
|
|
|
38
42
|
const publicClient = usePublicClient();
|
|
39
43
|
const { address: account } = useBeraWallet();
|
|
40
44
|
const { collateralList } = useHoneyConfig(); // needed
|
|
41
|
-
|
|
45
|
+
const wagmiConfig = useConfig();
|
|
42
46
|
const QUERY_KEY =
|
|
43
47
|
account && collateralList && publicClient
|
|
44
48
|
? (["useHoneyBalances", account, collateralList] as const)
|
|
@@ -54,7 +58,7 @@ export const useHoneyBalances = (): DefaultHookReturnType<
|
|
|
54
58
|
const tokenBalances = await getWalletBalances({
|
|
55
59
|
account,
|
|
56
60
|
tokenList,
|
|
57
|
-
|
|
61
|
+
wagmiConfig,
|
|
58
62
|
});
|
|
59
63
|
|
|
60
64
|
const balancesMap = tokenBalances?.reduce(
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
type TokenWithOrder,
|
|
8
8
|
useHoneyConfig,
|
|
9
9
|
} from "~/contexts/HoneyConfigProvider";
|
|
10
|
-
import { HoneySwapAction
|
|
10
|
+
import { HoneySwapAction } from "~/enum/honey";
|
|
11
|
+
import type { HoneySwapActions } from "~/types/honeySwap";
|
|
11
12
|
import { isToken } from "~/utils/tokens";
|
|
12
13
|
import { useIsBasketModeEnabled } from "./useIsBasketModeEnabled";
|
|
13
14
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getHoneyVaultsBalance,
|
|
8
8
|
} from "~/actions/honey/getHoneyVaultsBalance";
|
|
9
9
|
import { useHoneyConfig } from "~/contexts/HoneyConfigProvider";
|
|
10
|
-
import { POLLING } from "~/enum";
|
|
10
|
+
import { POLLING } from "~/enum/polling";
|
|
11
11
|
import { assertPublicClient } from "~/errors/assert";
|
|
12
12
|
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
13
13
|
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
import { useHoneyConfig } from "~/contexts/HoneyConfigProvider";
|
|
10
10
|
import { POLLING } from "~/enum/polling";
|
|
11
11
|
import { assertPublicClient } from "~/errors/assert";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Token } from "~/types/dex";
|
|
13
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
13
14
|
import { usePythLatestPrices } from "./usePythLatestPrices";
|
|
14
15
|
|
|
15
16
|
export interface UseIsBadCollateralResponse
|
|
@@ -6,7 +6,7 @@ import { isBasketModeEnabled } from "~/actions/honey/isBasketModeEnabled";
|
|
|
6
6
|
import { useHoneyConfig } from "~/contexts/HoneyConfigProvider";
|
|
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 type { IHoneySwapState } from "./useHoneySwapState";
|
|
11
11
|
import { usePythLatestPrices } from "./usePythLatestPrices";
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import useSWR, { type SWRResponse } from "swr";
|
|
2
2
|
|
|
3
|
-
import { getPythLatestPrices } from "~/actions";
|
|
4
3
|
import type { PythLatestUpdates } from "~/actions/honey/getPythLatestPrices";
|
|
4
|
+
import { getPythLatestPrices } from "~/actions/honey/getPythLatestPrices";
|
|
5
5
|
import type { DefaultHookOptions } from "~/types/global";
|
|
6
6
|
import type { PythPriceFeedMap } from "~/types/honeySwap";
|
|
7
7
|
|
|
@@ -10,10 +10,10 @@ import { getRewardVaultStakingToken } from "~/actions/pol/getRewardVaultStakingT
|
|
|
10
10
|
import { getStakingTokenInformation } from "~/actions/pol/getStakingTokenInformation";
|
|
11
11
|
import { getTokenInformation } from "~/actions/tokens/getTokenInformation";
|
|
12
12
|
import { assertPublicClient } from "~/errors/assert";
|
|
13
|
-
import type { DefaultHookOptions } from "~/types";
|
|
13
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
14
14
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const useOnChainRewardVaultQueryKey = (address: Address | undefined) =>
|
|
17
17
|
address && isAddress(address)
|
|
18
18
|
? (["onChainRewardVault", address.toLowerCase() as Address] as const)
|
|
19
19
|
: null;
|
|
@@ -75,6 +75,7 @@ export const useOnChainRewardVault = (
|
|
|
75
75
|
incentives.map((add) =>
|
|
76
76
|
getTokenInformation({
|
|
77
77
|
address: add.token,
|
|
78
|
+
chainId: publicClient.chain.id,
|
|
78
79
|
publicClient: publicClient,
|
|
79
80
|
}),
|
|
80
81
|
),
|
|
@@ -4,7 +4,7 @@ import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
|
4
4
|
|
|
5
5
|
import { type GlobalData, getGlobalData } from "~/actions/pol/getGlobalData";
|
|
6
6
|
import { assertPublicClient } from "~/errors/assert";
|
|
7
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
7
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
8
8
|
|
|
9
9
|
export const usePollGlobalData = (
|
|
10
10
|
options?: DefaultHookOptions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import useSWRImmutable from "swr/immutable";
|
|
2
2
|
|
|
3
3
|
import { type GetMarkets, getMarkets } from "~/actions/pol/getMarkets";
|
|
4
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
4
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
5
5
|
|
|
6
6
|
export interface UsePollMarketsResponse
|
|
7
7
|
extends DefaultHookReturnType<GetMarkets> {}
|
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
getSWBeraWithdrawal,
|
|
8
8
|
type StakedBeraWithdrawal,
|
|
9
9
|
} from "~/actions/pol/getSWBeraWithdrawal";
|
|
10
|
-
import { POLLING } from "~/enum";
|
|
10
|
+
import { POLLING } from "~/enum/polling";
|
|
11
11
|
import { assertPublicClient } from "~/errors/assert";
|
|
12
|
-
import type { DefaultHookOptions } from "~/types";
|
|
12
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
13
13
|
|
|
14
14
|
export function useQueuedBeraUnlock(
|
|
15
15
|
{
|
|
16
|
-
|
|
16
|
+
receiptTokenAddresses,
|
|
17
17
|
account,
|
|
18
18
|
version,
|
|
19
19
|
}: {
|
|
20
|
-
|
|
20
|
+
receiptTokenAddresses: Address[];
|
|
21
21
|
account?: Address | string;
|
|
22
22
|
version: "V1" | "V2";
|
|
23
23
|
},
|
|
@@ -26,15 +26,14 @@ export function useQueuedBeraUnlock(
|
|
|
26
26
|
const publicClient = usePublicClient();
|
|
27
27
|
|
|
28
28
|
const QUERY_KEY =
|
|
29
|
-
|
|
30
|
-
isAddress(receiptTokenAddress) &&
|
|
29
|
+
receiptTokenAddresses &&
|
|
31
30
|
account &&
|
|
32
31
|
publicClient &&
|
|
33
32
|
isAddress(account) &&
|
|
34
33
|
version
|
|
35
34
|
? ([
|
|
36
35
|
"useQueuedBeraUnlock",
|
|
37
|
-
|
|
36
|
+
receiptTokenAddresses,
|
|
38
37
|
account,
|
|
39
38
|
version,
|
|
40
39
|
] as const)
|
|
@@ -46,16 +45,19 @@ export function useQueuedBeraUnlock(
|
|
|
46
45
|
typeof QUERY_KEY
|
|
47
46
|
>(
|
|
48
47
|
QUERY_KEY,
|
|
49
|
-
async ([,
|
|
48
|
+
async ([, receiptTokenAddresses, account, version]) => {
|
|
50
49
|
assertPublicClient(publicClient);
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
receiptTokenAddress
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
return await Promise.all(
|
|
52
|
+
receiptTokenAddresses.map(async (receiptTokenAddress) => {
|
|
53
|
+
return await getSWBeraWithdrawal({
|
|
54
|
+
contractAddress: receiptTokenAddress,
|
|
55
|
+
accountAddress: account,
|
|
56
|
+
publicClient,
|
|
57
|
+
version,
|
|
58
|
+
});
|
|
59
|
+
}),
|
|
60
|
+
).then((results) => results.flat());
|
|
59
61
|
},
|
|
60
62
|
{
|
|
61
63
|
refreshInterval: POLLING.FAST,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import useSWR from "swr";
|
|
2
2
|
import { type Address, isAddress } from "viem";
|
|
3
3
|
|
|
4
|
+
import { defaultChainId } from "@berachain/config/internal";
|
|
5
|
+
|
|
4
6
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
7
|
|
|
6
8
|
import { getRewardTokenToBeraRate } from "~/actions/pol/getRewardTokenToBeraRate";
|
|
7
|
-
import { assertPublicClient
|
|
8
|
-
import
|
|
9
|
+
import { assertPublicClient } from "~/errors/assert";
|
|
10
|
+
import { InvalidArgumentError } from "~/errors/InvalidArgumentError";
|
|
11
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
9
12
|
|
|
10
13
|
export const useRewardTokenToBeraRate = (
|
|
11
14
|
{
|
|
@@ -18,7 +21,7 @@ export const useRewardTokenToBeraRate = (
|
|
|
18
21
|
const QUERY_KEY = address
|
|
19
22
|
? (["useRewardTokenToBeraRate", address] as const)
|
|
20
23
|
: null;
|
|
21
|
-
const publicClient = usePublicClient();
|
|
24
|
+
const publicClient = usePublicClient({ chainId: defaultChainId });
|
|
22
25
|
|
|
23
26
|
return useSWR(
|
|
24
27
|
QUERY_KEY,
|
|
@@ -4,7 +4,7 @@ import type { Address } from "viem";
|
|
|
4
4
|
import type { ApiVaultFragment } from "@berachain/graphql/pol/api";
|
|
5
5
|
|
|
6
6
|
import { getRewardVault } from "~/actions/pol/getRewardVault";
|
|
7
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
7
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
8
8
|
import { useOnChainRewardVault } from "./useOnChainRewardVault";
|
|
9
9
|
|
|
10
10
|
export interface UseRewardVaultResponse
|
|
@@ -4,7 +4,7 @@ import type { GetVaultsQueryVariables } from "@berachain/graphql/pol/api";
|
|
|
4
4
|
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
5
|
|
|
6
6
|
import { getRewardVaults } from "~/actions/pol/getRewardVaults";
|
|
7
|
-
import type { DefaultHookOptions } from "~/types";
|
|
7
|
+
import type { DefaultHookOptions } from "~/types/global";
|
|
8
8
|
|
|
9
9
|
export const useRewardVaultsQueryKey = (
|
|
10
10
|
filter?: GetVaultsQueryVariables,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
|
|
4
|
+
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
|
+
|
|
6
|
+
import { getSWBeraVaultMetadata } from "~/actions/pol/getSWBeraVaultMetadata";
|
|
7
|
+
import { useBlockTime } from "~/contexts/block-time-provider";
|
|
8
|
+
import { POLLING } from "~/enum/polling";
|
|
9
|
+
import { assertPublicClient } from "~/errors/assert";
|
|
10
|
+
|
|
11
|
+
export const useSWBeraVaultMetadata = (receiptTokenAddress?: Address) => {
|
|
12
|
+
const publicClient = usePublicClient();
|
|
13
|
+
const blockTime = useBlockTime();
|
|
14
|
+
const QUERY_KEY =
|
|
15
|
+
receiptTokenAddress && publicClient && blockTime
|
|
16
|
+
? ([
|
|
17
|
+
"useStakingVaultMetadata",
|
|
18
|
+
receiptTokenAddress,
|
|
19
|
+
publicClient,
|
|
20
|
+
blockTime,
|
|
21
|
+
] as const)
|
|
22
|
+
: null;
|
|
23
|
+
return useSWR(
|
|
24
|
+
QUERY_KEY,
|
|
25
|
+
async ([, address, publicClient, blockTime]) => {
|
|
26
|
+
assertPublicClient(publicClient);
|
|
27
|
+
return getSWBeraVaultMetadata({
|
|
28
|
+
address,
|
|
29
|
+
publicClient,
|
|
30
|
+
blockTime,
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
{ refreshInterval: POLLING.FAST },
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
|
|
3
|
+
import type { GqlVaultSnapshotDataRange } from "@berachain/graphql/dex/api";
|
|
4
|
+
|
|
5
|
+
import { getStakedBeraSnapshots } from "~/actions/pol/getStakedBeraSnapshots";
|
|
6
|
+
import type { DefaultHookReturnType } from "~/types/global";
|
|
7
|
+
import { dailyResolution } from "~/utils/filter";
|
|
8
|
+
|
|
9
|
+
type UseStakedAPR = {
|
|
10
|
+
_timestamp: number;
|
|
11
|
+
apr: string;
|
|
12
|
+
}[];
|
|
13
|
+
export function useStakedAPR({
|
|
14
|
+
range,
|
|
15
|
+
}: {
|
|
16
|
+
range: GqlVaultSnapshotDataRange;
|
|
17
|
+
}): DefaultHookReturnType<UseStakedAPR> {
|
|
18
|
+
const QUERY_KEY = range ? (["useStakedAPR", range] as const) : null;
|
|
19
|
+
const swrResponse = useSWR(QUERY_KEY, async ([, range]) => {
|
|
20
|
+
const unsortedStakedBeraSnapshots = await getStakedBeraSnapshots({
|
|
21
|
+
range,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const sortedStakedBeraSnapshots = dailyResolution(
|
|
25
|
+
unsortedStakedBeraSnapshots.sort((a, b) => a.timestamp - b.timestamp),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return sortedStakedBeraSnapshots.map((item) => ({
|
|
29
|
+
_timestamp: item.timestamp,
|
|
30
|
+
apr: item.apr,
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...swrResponse,
|
|
36
|
+
refresh: () => swrResponse.mutate(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useBeraWallet,
|
|
5
|
+
useConfig,
|
|
6
|
+
usePublicClient,
|
|
7
|
+
} from "@berachain/wagmi/hooks";
|
|
8
|
+
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
9
|
+
|
|
10
|
+
import { getEarnedStakedBeraVault } from "~/actions/pol/getEarnedStakedBeraVault";
|
|
11
|
+
import { getRewardTokenToBeraRate } from "~/actions/pol/getRewardTokenToBeraRate";
|
|
12
|
+
import { getStakedBeraAPR } from "~/actions/pol/getStakedBeraAPR";
|
|
13
|
+
import { getTokenCurrentPrices } from "~/actions/prices/getTokenCurrentPrices";
|
|
14
|
+
import { getWalletBalances } from "~/actions/tokens/getWalletBalances";
|
|
15
|
+
import { useBeraFlag } from "~/contexts/BeraFlags/BeraFlags";
|
|
16
|
+
import { POLLING } from "~/enum/polling";
|
|
17
|
+
import { assertDefined, assertPublicClient } from "~/errors/assert";
|
|
18
|
+
import type { StakedBeraAsset } from "~/types/pol";
|
|
19
|
+
import type { StakingConfig } from "~/types/staking";
|
|
20
|
+
|
|
21
|
+
export const useStakedData = (stakingConfigs: StakingConfig[]) => {
|
|
22
|
+
const window = useBeraFlag("swberaAprWindow");
|
|
23
|
+
|
|
24
|
+
const wagmiConfig = useConfig();
|
|
25
|
+
const publicClient = usePublicClient();
|
|
26
|
+
const { address: account } = useBeraWallet();
|
|
27
|
+
const QUERY_KEY =
|
|
28
|
+
account && wagmiConfig && stakingConfigs
|
|
29
|
+
? (["useStakedData", account, stakingConfigs, window] as const)
|
|
30
|
+
: null;
|
|
31
|
+
return useSWR<StakedBeraAsset[] | undefined, any, typeof QUERY_KEY>(
|
|
32
|
+
QUERY_KEY,
|
|
33
|
+
async ([, account, stakingConfigs, window]) => {
|
|
34
|
+
assertDefined(wagmiConfig, "wagmiConfig");
|
|
35
|
+
assertPublicClient(publicClient);
|
|
36
|
+
// get the apr for staking
|
|
37
|
+
const apr = await getStakedBeraAPR({ window });
|
|
38
|
+
// pull out the receipt tokens from the staking configs
|
|
39
|
+
const receiptTokens = stakingConfigs.map((config) => config.receiptToken);
|
|
40
|
+
// get the staked balances for the receipt tokens
|
|
41
|
+
const stakedBalancesData = await getWalletBalances({
|
|
42
|
+
account,
|
|
43
|
+
tokenList: receiptTokens,
|
|
44
|
+
wagmiConfig,
|
|
45
|
+
});
|
|
46
|
+
const data: StakedBeraAsset[] = await Promise.all(
|
|
47
|
+
stakingConfigs.map(async (stakingConfig): Promise<StakedBeraAsset> => {
|
|
48
|
+
// get the staking token & input/receipt token
|
|
49
|
+
const stakingToken = stakingConfig.receiptToken;
|
|
50
|
+
const inputToken = stakingConfig.inputTokens[0];
|
|
51
|
+
|
|
52
|
+
const [earnings, inputTokenPriceData, exchangeRateNowRaw] =
|
|
53
|
+
await Promise.all([
|
|
54
|
+
// get the earned input token for the staking token
|
|
55
|
+
getEarnedStakedBeraVault({
|
|
56
|
+
address: stakingToken.address,
|
|
57
|
+
account,
|
|
58
|
+
}),
|
|
59
|
+
// NOT BERA PRICE, INPUT TOKEN PRICE
|
|
60
|
+
getTokenCurrentPrices({ addressIn: [inputToken.address] }),
|
|
61
|
+
// use getRewardTokenToBeraRate to get the exchange rate
|
|
62
|
+
getRewardTokenToBeraRate({
|
|
63
|
+
address: stakingToken.address,
|
|
64
|
+
publicClient,
|
|
65
|
+
}),
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
// input token price
|
|
69
|
+
const inputTokenPrice =
|
|
70
|
+
inputTokenPriceData[inputToken.address]?.price ?? 0;
|
|
71
|
+
// staked asset balance
|
|
72
|
+
const stakedBalance =
|
|
73
|
+
stakedBalancesData?.find((b) => b.address === stakingToken.address)
|
|
74
|
+
?.balance.raw ?? "0";
|
|
75
|
+
|
|
76
|
+
const exchangeRateNow = exchangeRateNowRaw ?? 0;
|
|
77
|
+
|
|
78
|
+
// unrealised gains is the users earnings
|
|
79
|
+
const unrealisedGains = new BigNumber(earnings.earningsTotal).minus(
|
|
80
|
+
earnings.earningsRealized,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const total = new BigNumber(stakedBalance).multipliedBy(
|
|
84
|
+
exchangeRateNow,
|
|
85
|
+
);
|
|
86
|
+
// desposited is the users deposited amount
|
|
87
|
+
const desposited = total.minus(unrealisedGains);
|
|
88
|
+
|
|
89
|
+
// in terms of bera
|
|
90
|
+
const stakedAmount = desposited.dividedBy(10 ** inputToken.decimals);
|
|
91
|
+
const earnedAmount = unrealisedGains.dividedBy(
|
|
92
|
+
10 ** inputToken.decimals,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// in terms of usd
|
|
96
|
+
const stakedAmountUsd = stakedAmount.multipliedBy(inputTokenPrice);
|
|
97
|
+
const earnedAmountUsd = earnedAmount.multipliedBy(inputTokenPrice);
|
|
98
|
+
|
|
99
|
+
const data: StakedBeraAsset = {
|
|
100
|
+
token: inputToken,
|
|
101
|
+
apr: apr ?? 0,
|
|
102
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
103
|
+
earnedAmount: earnedAmount.toNumber(),
|
|
104
|
+
stakedAmountUsd: stakedAmountUsd.toNumber(),
|
|
105
|
+
earnedAmountUsd: earnedAmountUsd.toNumber(),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return data;
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
return data;
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
refreshInterval: POLLING.FAST,
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
|
|
4
|
+
import { getStakingDailyAssets } from "~/actions/pol/getStakingDailyAssets";
|
|
5
|
+
import type { DefaultHookReturnType } from "~/types/global";
|
|
6
|
+
import { dailyResolution } from "~/utils/filter";
|
|
7
|
+
|
|
8
|
+
type UseStakedBeraSnapshot = Record<
|
|
9
|
+
Address,
|
|
10
|
+
{
|
|
11
|
+
_timestamp: number;
|
|
12
|
+
total_assets: string;
|
|
13
|
+
}[]
|
|
14
|
+
>;
|
|
15
|
+
export function useStakedSnapshots({
|
|
16
|
+
range,
|
|
17
|
+
addresses,
|
|
18
|
+
}: {
|
|
19
|
+
addresses: Address[];
|
|
20
|
+
range: 30 | 60 | 90;
|
|
21
|
+
}): DefaultHookReturnType<UseStakedBeraSnapshot> {
|
|
22
|
+
const QUERY_KEY = range
|
|
23
|
+
? (["useStakedSnapshots", range, addresses] as const)
|
|
24
|
+
: null;
|
|
25
|
+
const swrResponse = useSWR(QUERY_KEY, async ([, range, addresses]) => {
|
|
26
|
+
const [...sortedStakingDailyAssetsArray] = await Promise.all([
|
|
27
|
+
...addresses.map(async (address) => {
|
|
28
|
+
const unstakingDailyAssets = await getStakingDailyAssets({
|
|
29
|
+
address,
|
|
30
|
+
range,
|
|
31
|
+
});
|
|
32
|
+
const sortedStakingDailyAssets = dailyResolution(
|
|
33
|
+
unstakingDailyAssets.sort((a, b) => a._timestamp - b._timestamp),
|
|
34
|
+
);
|
|
35
|
+
return {
|
|
36
|
+
[address]: sortedStakingDailyAssets,
|
|
37
|
+
};
|
|
38
|
+
}),
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
// Merge all address data into a single object
|
|
42
|
+
return sortedStakingDailyAssetsArray.reduce(
|
|
43
|
+
(acc, addressData) => ({ ...acc, ...addressData }),
|
|
44
|
+
{} as Record<Address, { _timestamp: number; total_assets: string }[]>,
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...swrResponse,
|
|
50
|
+
refresh: () => swrResponse.mutate(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import useSWR from "swr";
|
|
2
|
+
|
|
3
|
+
import type { Address } from "@berachain/config";
|
|
4
|
+
|
|
5
|
+
import { usePublicClient } from "@berachain/wagmi/hooks";
|
|
6
|
+
|
|
7
|
+
import { getTotalStakedAmount } from "~/actions/pol/getTotalStakedAmount";
|
|
8
|
+
import type { DefaultHookReturnType } from "~/types/global";
|
|
9
|
+
|
|
10
|
+
export function useTotalStakedAmount({
|
|
11
|
+
vaultAddresses,
|
|
12
|
+
}: {
|
|
13
|
+
vaultAddresses: Address[];
|
|
14
|
+
}): DefaultHookReturnType<Record<Address, bigint>> {
|
|
15
|
+
const publicClient = usePublicClient();
|
|
16
|
+
|
|
17
|
+
const swrResponse = useSWR(
|
|
18
|
+
vaultAddresses && publicClient
|
|
19
|
+
? ["useTotalStakedAmount", vaultAddresses]
|
|
20
|
+
: null,
|
|
21
|
+
([, vaultAddresses]) => {
|
|
22
|
+
return getTotalStakedAmount({ vaultAddresses, publicClient });
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
...swrResponse,
|
|
28
|
+
refresh: () => swrResponse.mutate(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { Address } from "viem";
|
|
|
3
3
|
|
|
4
4
|
import { useBeraWallet, usePublicClient } from "@berachain/wagmi/hooks";
|
|
5
5
|
|
|
6
|
-
import { getUserVaultInfo } from "~/actions/";
|
|
6
|
+
import { getUserVaultInfo } from "~/actions/pol/getUserVaultInfo";
|
|
7
7
|
import { POLLING } from "~/enum/polling";
|
|
8
8
|
import { assertPublicClient } from "~/errors/assert";
|
|
9
9
|
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
@@ -4,7 +4,7 @@ import type { Address } from "viem";
|
|
|
4
4
|
import type { ApiValidatorFragment } from "@berachain/graphql/pol/api";
|
|
5
5
|
|
|
6
6
|
import { getVaultValidators } from "~/actions/pol/getVaultValidators";
|
|
7
|
-
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types";
|
|
7
|
+
import type { DefaultHookOptions, DefaultHookReturnType } from "~/types/global";
|
|
8
8
|
|
|
9
9
|
export interface UsePollValidatorInfoResponse
|
|
10
10
|
extends DefaultHookReturnType<ApiValidatorFragment[] | undefined> {}
|