@berachain/berajs 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{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} +80 -107
- package/dist/actions/{index.d.ts → exports.d.ts} +80 -107
- package/dist/actions/exports.mjs +2 -0
- package/dist/actions/exports.mjs.map +1 -0
- package/dist/chunk-575OK77P.mjs +2 -0
- package/dist/chunk-575OK77P.mjs.map +1 -0
- package/dist/chunk-7GWTHOLO.mjs +2 -0
- package/dist/chunk-7GWTHOLO.mjs.map +1 -0
- package/dist/chunk-7SC4VD3U.cjs +2 -0
- package/dist/chunk-7SC4VD3U.cjs.map +1 -0
- package/dist/chunk-BHNQX4XC.mjs +2 -0
- package/dist/chunk-BHNQX4XC.mjs.map +1 -0
- package/dist/chunk-BOYZVULX.cjs +2 -0
- package/dist/chunk-BOYZVULX.cjs.map +1 -0
- package/dist/chunk-C3FHGFLK.mjs +2 -0
- package/dist/chunk-C3FHGFLK.mjs.map +1 -0
- package/dist/chunk-C3G5KXCH.mjs +2 -0
- package/dist/chunk-C3G5KXCH.mjs.map +1 -0
- package/dist/chunk-CYKCYPFR.cjs +2 -0
- package/dist/chunk-CYKCYPFR.cjs.map +1 -0
- package/dist/chunk-F4BKSBEM.mjs +2 -0
- package/dist/chunk-F4BKSBEM.mjs.map +1 -0
- package/dist/chunk-FL2N3XHK.cjs +2 -0
- package/dist/chunk-FL2N3XHK.cjs.map +1 -0
- package/dist/chunk-G6NA6NSM.mjs +4 -0
- package/dist/chunk-G6NA6NSM.mjs.map +1 -0
- package/dist/chunk-H2QSRMVS.mjs +2 -0
- package/dist/chunk-H2QSRMVS.mjs.map +1 -0
- package/dist/chunk-IJM76AWK.cjs +4 -0
- package/dist/chunk-IJM76AWK.cjs.map +1 -0
- package/dist/chunk-MTS5SZLA.mjs +2 -0
- package/dist/chunk-MTS5SZLA.mjs.map +1 -0
- package/dist/chunk-MUNAP5TM.cjs +2 -0
- package/dist/chunk-MUNAP5TM.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-OS5AJMYJ.cjs +2 -0
- package/dist/chunk-OS5AJMYJ.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-TJWKS54T.mjs +2 -0
- package/dist/chunk-TJWKS54T.mjs.map +1 -0
- package/dist/chunk-UQUWMHVF.cjs +2 -0
- package/dist/chunk-UQUWMHVF.cjs.map +1 -0
- package/dist/chunk-UXUWSRVV.cjs +2 -0
- package/dist/chunk-UXUWSRVV.cjs.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-WTCBORPB.cjs +2 -0
- package/dist/chunk-WTCBORPB.cjs.map +1 -0
- package/dist/chunk-XNJLSA6P.cjs +2 -0
- package/dist/chunk-XNJLSA6P.cjs.map +1 -0
- package/dist/chunk-YQGZMWDT.mjs +2 -0
- package/dist/chunk-YQGZMWDT.mjs.map +1 -0
- package/dist/chunk-YXLFOEZN.mjs +2 -0
- package/dist/chunk-YXLFOEZN.mjs.map +1 -0
- package/dist/chunk-ZAKA4TGK.cjs +2 -0
- package/dist/chunk-ZAKA4TGK.cjs.map +1 -0
- package/dist/chunk-ZQRACIGR.mjs +2 -0
- package/dist/chunk-ZQRACIGR.mjs.map +1 -0
- package/dist/contexts/exports.cjs +2 -0
- package/dist/contexts/exports.cjs.map +1 -0
- package/dist/contexts/{index.d.ts → exports.d.cts} +19 -28
- package/dist/contexts/{index.d.cts → exports.d.ts} +19 -28
- package/dist/contexts/exports.mjs +2 -0
- package/dist/contexts/exports.mjs.map +1 -0
- package/dist/contracts-CQIPk0Jc.d.cts +74 -0
- package/dist/contracts-CQIPk0Jc.d.ts +74 -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 +24 -0
- package/dist/enum/exports.d.ts +24 -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 +385 -0
- package/dist/errors/exports.d.ts +385 -0
- package/dist/errors/exports.mjs +2 -0
- package/dist/{getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts → getValidatorQueuedOperatorAddress-BX35p2Lv.d.ts} +125 -15
- package/dist/{getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts → getValidatorQueuedOperatorAddress-It0GsdvQ.d.cts} +125 -15
- package/dist/global.d-Ba-NIojH.d.cts +474 -0
- package/dist/global.d-By70bEv2.d.ts +474 -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} +223 -173
- package/dist/hooks/{index.d.ts → exports.d.ts} +223 -173
- package/dist/hooks/exports.mjs +4 -0
- package/dist/hooks/exports.mjs.map +1 -0
- package/dist/{BexStatusProvider-nS3NcdxI.d.cts → transactionStore-BvStaXf3.d.ts} +41 -1
- package/dist/{BexStatusProvider-nS3NcdxI.d.ts → transactionStore-CQrGYSY2.d.cts} +41 -1
- package/dist/{txnEnum-BQKDfaeH.d.cts → txnEnum-BYNbCxla.d.cts} +1 -0
- package/dist/{txnEnum-BQKDfaeH.d.ts → txnEnum-BYNbCxla.d.ts} +1 -0
- package/dist/types/exports.cjs +1 -0
- package/dist/types/exports.cjs.map +1 -0
- package/dist/types/exports.d.cts +58 -0
- package/dist/types/exports.d.ts +58 -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 +16 -17
- 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 +21 -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/{hooks/transactions → contexts}/TransactionStoreContext.tsx +32 -4
- package/src/contexts/block-time-provider.tsx +1 -1
- package/src/contexts/{index.ts → exports.ts} +1 -1
- package/src/data/contracts.ts +16 -1
- 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 +50 -11
- 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 +2 -2
- package/src/errors/assert.ts +4 -2
- package/src/errors/assert.unit.test.ts +6 -2
- package/src/errors/errorMap.ts +16 -6
- package/src/errors/{index.ts → exports.ts} +7 -0
- package/src/errors/getErrorMessage.ts +22 -3
- package/src/errors/getRevertReason.integration.test.ts +17 -5
- 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} +18 -7
- 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/transactions/transactionStore.ts +86 -65
- package/src/hooks/transactions/transactionStore.unit.test.ts +54 -1
- package/src/hooks/transactions/useAddRecentTransaction.ts +1 -1
- package/src/hooks/transactions/useRecentTransactions.ts +1 -1
- package/src/hooks/transactions/useSetTransactionStatus.ts +31 -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/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
|
@@ -2,8 +2,7 @@ import { type Address, formatUnits, type PublicClient } from "viem";
|
|
|
2
2
|
|
|
3
3
|
import { collateralVaultAbi } from "~/abi/honey/collateralVault";
|
|
4
4
|
import { honeyFactoryAbi } from "~/abi/honey/honeyFactory";
|
|
5
|
-
import type { Token } from "~/types/dex";
|
|
6
|
-
import type { TokenBalance } from "~/types/global";
|
|
5
|
+
import type { BalanceToken, Token } from "~/types/dex";
|
|
7
6
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
8
7
|
|
|
9
8
|
interface GetVaultsBalancesArgs extends BeraJS.BaseFunctionArgs {
|
|
@@ -12,7 +11,7 @@ interface GetVaultsBalancesArgs extends BeraJS.BaseFunctionArgs {
|
|
|
12
11
|
honeyFactoryAddress?: Address;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export interface GetHoneyVaultsBalanceResponse extends
|
|
14
|
+
export interface GetHoneyVaultsBalanceResponse extends BalanceToken {
|
|
16
15
|
vault: Address;
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -25,62 +24,59 @@ export async function getHoneyVaultsBalance({
|
|
|
25
24
|
const { config } = parseBaseArgs(args);
|
|
26
25
|
const factory = honeyFactoryAddress ?? config.honey.factory;
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const vaults = await Promise.all(
|
|
28
|
+
collateralList.map(async (coll) => {
|
|
29
|
+
const vault = await client.readContract({
|
|
30
|
+
address: config.honey.factory,
|
|
31
|
+
abi: honeyFactoryAbi,
|
|
32
|
+
functionName: "vaults",
|
|
33
|
+
args: [coll.address],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const [
|
|
37
|
+
shares,
|
|
38
|
+
// this is most likely 0 since we're sending fees to PolFeeCollector
|
|
39
|
+
// here for future proofing
|
|
40
|
+
feeShares,
|
|
41
|
+
// if balance is held in a custodian, we need to return the custodian address
|
|
42
|
+
[isCustodian, custodianAddress],
|
|
43
|
+
] = await Promise.all([
|
|
44
|
+
client.readContract({
|
|
45
|
+
address: vault,
|
|
46
|
+
abi: collateralVaultAbi,
|
|
47
|
+
functionName: "balanceOf",
|
|
48
|
+
args: [factory],
|
|
49
|
+
}),
|
|
50
|
+
client.readContract({
|
|
51
|
+
address: factory,
|
|
33
52
|
abi: honeyFactoryAbi,
|
|
34
|
-
functionName: "
|
|
53
|
+
functionName: "collectedAssetFees",
|
|
35
54
|
args: [coll.address],
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const [
|
|
39
|
-
shares,
|
|
40
|
-
// this is most likely 0 since we're sending fees to PolFeeCollector
|
|
41
|
-
// here for future proofing
|
|
42
|
-
feeShares,
|
|
43
|
-
// if balance is held in a custodian, we need to return the custodian address
|
|
44
|
-
[isCustodian, custodianAddress],
|
|
45
|
-
] = await Promise.all([
|
|
46
|
-
client.readContract({
|
|
47
|
-
address: vault,
|
|
48
|
-
abi: collateralVaultAbi,
|
|
49
|
-
functionName: "balanceOf",
|
|
50
|
-
args: [factory],
|
|
51
|
-
}),
|
|
52
|
-
client.readContract({
|
|
53
|
-
address: factory,
|
|
54
|
-
abi: honeyFactoryAbi,
|
|
55
|
-
functionName: "collectedAssetFees",
|
|
56
|
-
args: [coll.address],
|
|
57
|
-
}),
|
|
58
|
-
client.readContract({
|
|
59
|
-
address: vault,
|
|
60
|
-
abi: collateralVaultAbi,
|
|
61
|
-
functionName: "custodyInfo",
|
|
62
|
-
}),
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
const balance = await client.readContract({
|
|
55
|
+
}),
|
|
56
|
+
client.readContract({
|
|
66
57
|
address: vault,
|
|
67
58
|
abi: collateralVaultAbi,
|
|
68
|
-
functionName: "
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
functionName: "custodyInfo",
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
const balance = await client.readContract({
|
|
64
|
+
address: vault,
|
|
65
|
+
abi: collateralVaultAbi,
|
|
66
|
+
functionName: "convertToAssets",
|
|
67
|
+
args: [shares - feeShares],
|
|
68
|
+
});
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
return {
|
|
71
|
+
...coll,
|
|
72
|
+
balance: {
|
|
73
|
+
raw: balance.toString(),
|
|
74
|
+
formatted: formatUnits(balance, coll.decimals),
|
|
75
|
+
},
|
|
76
|
+
vault: isCustodian ? custodianAddress : vault,
|
|
77
|
+
};
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
} catch (e) {
|
|
83
|
-
console.log(e);
|
|
84
|
-
throw e;
|
|
85
|
-
}
|
|
81
|
+
return vaults;
|
|
86
82
|
}
|
|
@@ -28,12 +28,11 @@ interface GetSwapPayloadReturn {
|
|
|
28
28
|
"nonpayable",
|
|
29
29
|
"mint" | "redeem"
|
|
30
30
|
>;
|
|
31
|
-
value
|
|
31
|
+
value: bigint;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const getSwapPayload = async ({
|
|
35
35
|
state,
|
|
36
|
-
account,
|
|
37
36
|
publicClient,
|
|
38
37
|
priceFeedMap,
|
|
39
38
|
collateralList,
|
|
@@ -44,12 +43,11 @@ export const getSwapPayload = async ({
|
|
|
44
43
|
IHoneySwapState,
|
|
45
44
|
"actionType" | "fromAmount" | "collaterals" | "isBasketModeEnabled"
|
|
46
45
|
>;
|
|
47
|
-
account: Address | undefined;
|
|
48
46
|
collateralList: TokenWithMetadata[];
|
|
49
47
|
publicClient: PublicClient | undefined;
|
|
50
48
|
priceFeedMap?: PythPriceFeedMap;
|
|
51
49
|
isPythWrapperEnabled: boolean;
|
|
52
|
-
}): Promise<GetSwapPayloadReturn> => {
|
|
50
|
+
}): Promise<({ account }: { account: Address }) => GetSwapPayloadReturn> => {
|
|
53
51
|
const { config } = parseBaseArgs(args);
|
|
54
52
|
const honeyToken = getHoneyToken(args);
|
|
55
53
|
const { actionType, fromAmount, collaterals, isBasketModeEnabled } = state;
|
|
@@ -57,7 +55,7 @@ export const getSwapPayload = async ({
|
|
|
57
55
|
? config.honey.pythWrapper
|
|
58
56
|
: config.honey.factory;
|
|
59
57
|
const pairMainAddress = collateralList.map((coll) => coll.address);
|
|
60
|
-
if (
|
|
58
|
+
if (fromAmount[0] && !!pairMainAddress.length) {
|
|
61
59
|
const isMint = actionType === "mint";
|
|
62
60
|
if (isPythWrapperEnabled && publicClient && priceFeedMap) {
|
|
63
61
|
// to mint or redeem we need to update the prices for all the collaterals
|
|
@@ -66,7 +64,7 @@ export const getSwapPayload = async ({
|
|
|
66
64
|
priceFeedId: Object.values(priceFeedMap),
|
|
67
65
|
});
|
|
68
66
|
const calldata = latestPrices.calldata;
|
|
69
|
-
let pythUpdateFee: bigint
|
|
67
|
+
let pythUpdateFee: bigint = 0n;
|
|
70
68
|
try {
|
|
71
69
|
// get the update fee from pyth that will be used inside the contract to update the prices
|
|
72
70
|
pythUpdateFee = await getPythUpdateFee({
|
|
@@ -78,12 +76,38 @@ export const getSwapPayload = async ({
|
|
|
78
76
|
pythUpdateFee = getPythDefaultUpdateFee(collaterals.length);
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
return ({ account }) => {
|
|
80
|
+
const pythPayload: ContractFunctionArgs<
|
|
81
|
+
typeof pythWrapperAbi,
|
|
82
|
+
"payable",
|
|
83
|
+
"mint" | "redeem"
|
|
84
|
+
> = [
|
|
85
|
+
calldata,
|
|
86
|
+
collaterals[0]?.address,
|
|
87
|
+
parseUnits(
|
|
88
|
+
fromAmount[0],
|
|
89
|
+
(isMint ? collaterals[0]?.decimals : honeyToken?.decimals) ?? 18,
|
|
90
|
+
),
|
|
91
|
+
account,
|
|
92
|
+
!!isBasketModeEnabled,
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
address: destinationContractAddress,
|
|
97
|
+
abi: pythWrapperAbi,
|
|
98
|
+
functionName: isMint ? "mint" : "redeem",
|
|
99
|
+
params: pythPayload,
|
|
100
|
+
value: pythUpdateFee,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return ({ account }) => {
|
|
106
|
+
const defaultPayload: ContractFunctionArgs<
|
|
107
|
+
typeof honeyFactoryAbi,
|
|
108
|
+
"nonpayable",
|
|
84
109
|
"mint" | "redeem"
|
|
85
110
|
> = [
|
|
86
|
-
calldata,
|
|
87
111
|
collaterals[0]?.address,
|
|
88
112
|
parseUnits(
|
|
89
113
|
fromAmount[0],
|
|
@@ -92,35 +116,13 @@ export const getSwapPayload = async ({
|
|
|
92
116
|
account,
|
|
93
117
|
!!isBasketModeEnabled,
|
|
94
118
|
];
|
|
95
|
-
|
|
96
119
|
return {
|
|
120
|
+
value: 0n,
|
|
97
121
|
address: destinationContractAddress,
|
|
98
|
-
abi:
|
|
122
|
+
abi: honeyFactoryAbi,
|
|
99
123
|
functionName: isMint ? "mint" : "redeem",
|
|
100
|
-
params:
|
|
101
|
-
value: pythUpdateFee,
|
|
124
|
+
params: defaultPayload,
|
|
102
125
|
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const defaultPayload: ContractFunctionArgs<
|
|
106
|
-
typeof honeyFactoryAbi,
|
|
107
|
-
"nonpayable",
|
|
108
|
-
"mint" | "redeem"
|
|
109
|
-
> = [
|
|
110
|
-
collaterals[0]?.address,
|
|
111
|
-
parseUnits(
|
|
112
|
-
fromAmount[0],
|
|
113
|
-
(isMint ? collaterals[0]?.decimals : honeyToken?.decimals) ?? 18,
|
|
114
|
-
),
|
|
115
|
-
account,
|
|
116
|
-
!!isBasketModeEnabled,
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
address: destinationContractAddress,
|
|
121
|
-
abi: honeyFactoryAbi,
|
|
122
|
-
functionName: isMint ? "mint" : "redeem",
|
|
123
|
-
params: defaultPayload,
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
128
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
1
|
import { describe, expect, it } from "vitest";
|
|
3
2
|
|
|
4
3
|
import { GetValidators } from "@berachain/graphql/pol/api";
|
|
4
|
+
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
5
5
|
|
|
6
6
|
import { getAllValidators } from "~/actions/validators/getAllValidators";
|
|
7
7
|
import { getServerSidePublicClient } from "~/utils/getServerSideClient";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
|
|
3
|
+
import { beraFetchJson } from "~/utils/beraFetch";
|
|
4
|
+
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
5
|
+
|
|
6
|
+
type StakingHistoryData = {
|
|
7
|
+
currentDepositRate: string;
|
|
8
|
+
earningsRealized: string;
|
|
9
|
+
earningsTotal: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type GetEarnedStakedBeraVaultArgs = {
|
|
13
|
+
/**
|
|
14
|
+
* The token that the user has staked
|
|
15
|
+
*/
|
|
16
|
+
address: Address;
|
|
17
|
+
/**
|
|
18
|
+
* The account that the user has staked
|
|
19
|
+
*/
|
|
20
|
+
account: Address;
|
|
21
|
+
};
|
|
22
|
+
export async function getEarnedStakedBeraVault({
|
|
23
|
+
address,
|
|
24
|
+
account,
|
|
25
|
+
...args
|
|
26
|
+
}: BeraJS.BaseFunctionArgs &
|
|
27
|
+
GetEarnedStakedBeraVaultArgs): Promise<StakingHistoryData> {
|
|
28
|
+
const { config } = parseBaseArgs(args);
|
|
29
|
+
const url = `${config.bonder}/vaults/${address}/earnings/${account}`;
|
|
30
|
+
return beraFetchJson<StakingHistoryData>(url);
|
|
31
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import * as Sentry from "@sentry/nextjs";
|
|
2
1
|
import type { PublicClient } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { ApiVaultFragment } from "@berachain/graphql/pol/api";
|
|
5
4
|
|
|
5
|
+
import { BeraMonitoring } from "~/errors/BeraMonitoring";
|
|
6
|
+
import { initBeraError } from "~/errors/initBeraError";
|
|
6
7
|
import { type GlobalInfo, getBGTGlobalInfo } from "./getBGTGlobalInfo";
|
|
7
8
|
import { getBgtTokenTotalBoosts } from "./getBgtTokenTotalBoosts";
|
|
8
9
|
import { getBgtTokenTotalSupply } from "./getBgtTokenTotalSupply";
|
|
@@ -33,27 +34,27 @@ export async function getGlobalData(
|
|
|
33
34
|
]);
|
|
34
35
|
|
|
35
36
|
if (globalDataRes.status === "rejected") {
|
|
36
|
-
|
|
37
|
-
level: "warning",
|
|
38
|
-
|
|
37
|
+
BeraMonitoring.captureException(
|
|
38
|
+
initBeraError({ cause: globalDataRes.reason, level: "warning" }),
|
|
39
|
+
);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
if (globalCuttingBoardRes.status === "rejected") {
|
|
42
|
-
|
|
43
|
-
level: "warning",
|
|
44
|
-
|
|
43
|
+
BeraMonitoring.captureException(
|
|
44
|
+
initBeraError({ cause: globalCuttingBoardRes.reason, level: "warning" }),
|
|
45
|
+
);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
if (bgtTotalSupplyRes.status === "rejected") {
|
|
48
|
-
|
|
49
|
-
level: "warning",
|
|
50
|
-
|
|
49
|
+
BeraMonitoring.captureException(
|
|
50
|
+
initBeraError({ cause: bgtTotalSupplyRes.reason, level: "warning" }),
|
|
51
|
+
);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
if (bgtTotalBoostsRes.status === "rejected") {
|
|
54
|
-
|
|
55
|
-
level: "warning",
|
|
56
|
-
|
|
55
|
+
BeraMonitoring.captureException(
|
|
56
|
+
initBeraError({ cause: bgtTotalBoostsRes.reason, level: "warning" }),
|
|
57
|
+
);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
return {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Address, PublicClient } from "viem";
|
|
2
|
+
|
|
3
|
+
import { lstStakerVaultAbi } from "~/abi/pol/LSTStakerVault";
|
|
4
|
+
import { assertPublicClient } from "~/errors/assert";
|
|
5
|
+
import type { TokenWithMetadata } from "~/types/dex";
|
|
6
|
+
import type { StakingConfig } from "~/types/staking";
|
|
7
|
+
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
8
|
+
import { isToken } from "~/utils/tokens";
|
|
9
|
+
|
|
10
|
+
export type GetLSTStakeConfigArgs = {
|
|
11
|
+
tokenList: TokenWithMetadata[];
|
|
12
|
+
publicClient?: PublicClient;
|
|
13
|
+
lstStakingVaults: Address[];
|
|
14
|
+
} & BeraJS.BaseFunctionArgs;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Builds staking configs from on-chain LST vaults and optional native configs.
|
|
18
|
+
*/
|
|
19
|
+
export async function getLSTStakeConfig({
|
|
20
|
+
tokenList,
|
|
21
|
+
publicClient,
|
|
22
|
+
lstStakingVaults,
|
|
23
|
+
...args
|
|
24
|
+
}: GetLSTStakeConfigArgs): Promise<StakingConfig[]> {
|
|
25
|
+
assertPublicClient(publicClient);
|
|
26
|
+
|
|
27
|
+
const { config } = parseBaseArgs({
|
|
28
|
+
...args,
|
|
29
|
+
chainId: publicClient.chain?.id ?? args.chainId,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const lstStakingTokens = tokenList.filter((token) =>
|
|
33
|
+
lstStakingVaults.includes(token.address),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (lstStakingTokens.length === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const assets = await Promise.all(
|
|
41
|
+
lstStakingTokens.map(async (stakingToken) => {
|
|
42
|
+
// read the asset token address from the lst staking vault
|
|
43
|
+
const assetTokenAddress = await publicClient.readContract({
|
|
44
|
+
address: stakingToken.address,
|
|
45
|
+
abi: lstStakerVaultAbi,
|
|
46
|
+
functionName: "asset",
|
|
47
|
+
});
|
|
48
|
+
return { assetTokenAddress, stakingToken };
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return assets.reduce<StakingConfig[]>(
|
|
53
|
+
(acc, { assetTokenAddress, stakingToken }) => {
|
|
54
|
+
const assetToken = tokenList.find((token) =>
|
|
55
|
+
isToken(token, assetTokenAddress),
|
|
56
|
+
);
|
|
57
|
+
if (!assetToken) return acc;
|
|
58
|
+
acc.push({
|
|
59
|
+
id: stakingToken.address,
|
|
60
|
+
receiptToken: stakingToken,
|
|
61
|
+
inputTokens: [assetToken],
|
|
62
|
+
});
|
|
63
|
+
return acc;
|
|
64
|
+
},
|
|
65
|
+
[],
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
|
|
3
3
|
import { BeraError } from "~/errors/BeraError";
|
|
4
|
-
import type { BribeBoostRewardProof } from "~/types";
|
|
4
|
+
import type { BribeBoostRewardProof } from "~/types/bribe-boost";
|
|
5
5
|
import { getErrorResponse } from "~/utils/getErrorResponse";
|
|
6
6
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isSameAddress } from "@berachain-foundation/berancer-sdk";
|
|
2
|
-
import * as Sentry from "@sentry/nextjs";
|
|
3
2
|
import { type Address, erc20Abi, formatUnits, type PublicClient } from "viem";
|
|
4
3
|
|
|
5
4
|
import { rewardVaultAbi } from "~/abi/pol/rewardVault";
|
|
6
5
|
import { BeraError } from "~/errors/BeraError";
|
|
6
|
+
import { BeraMonitoring } from "~/errors/BeraMonitoring";
|
|
7
7
|
|
|
8
8
|
export interface RewardVaultIncentive {
|
|
9
9
|
token: Address;
|
|
@@ -99,19 +99,17 @@ export async function getRewardVaultIncentives({
|
|
|
99
99
|
|
|
100
100
|
incentives.forEach((result, index) => {
|
|
101
101
|
if (result.status === "rejected") {
|
|
102
|
-
|
|
102
|
+
BeraMonitoring.captureException(
|
|
103
103
|
new BeraError({
|
|
104
104
|
reason: result.reason,
|
|
105
105
|
message: "Incorrect incentives token received.",
|
|
106
106
|
level: "error",
|
|
107
|
-
}),
|
|
108
|
-
{
|
|
109
107
|
extra: {
|
|
110
108
|
token: whitelistedTokens[index],
|
|
111
109
|
address: address,
|
|
112
110
|
error: result.reason,
|
|
113
111
|
},
|
|
114
|
-
},
|
|
112
|
+
}),
|
|
115
113
|
);
|
|
116
114
|
}
|
|
117
115
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type Address, formatUnits } from "viem";
|
|
1
|
+
import { type Address, formatUnits, type PublicClient } from "viem";
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
type ApiVaultFragment,
|
|
@@ -25,7 +24,7 @@ export async function getRewardVaults({
|
|
|
25
24
|
...args
|
|
26
25
|
}: {
|
|
27
26
|
filter?: GetVaultsQueryVariables;
|
|
28
|
-
publicClient?:
|
|
27
|
+
publicClient?: PublicClient | undefined;
|
|
29
28
|
} & BeraJS.BaseFunctionArgs = {}): Promise<GetGaugeData> {
|
|
30
29
|
const bexApiGraphqlClient = getApolloClient("api", args);
|
|
31
30
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
1
|
import { type Address, erc20Abi, type PublicClient } from "viem";
|
|
3
2
|
|
|
3
|
+
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
4
|
+
|
|
4
5
|
import { stakeBeraVaultAbi } from "~/abi/pol/stakeBeraVault";
|
|
5
6
|
import { assertPublicClient } from "~/errors/assert";
|
|
6
7
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
7
|
-
import { getBlockTime } from "./getBlockTime";
|
|
8
8
|
import { getIncentiveFeeClaimStats } from "./getIncentiveFeeClaimStats";
|
|
9
9
|
import { getStakeWithdrawalCooldown } from "./getStakeWithdrawalCooldown";
|
|
10
10
|
|
|
@@ -35,10 +35,12 @@ export interface VaultMetadata {
|
|
|
35
35
|
export async function getSWBeraVaultMetadata({
|
|
36
36
|
address,
|
|
37
37
|
publicClient,
|
|
38
|
+
blockTime,
|
|
38
39
|
...args
|
|
39
40
|
}: {
|
|
40
41
|
address: Address;
|
|
41
42
|
publicClient?: PublicClient;
|
|
43
|
+
blockTime: number;
|
|
42
44
|
} & BeraJS.BaseFunctionArgs): Promise<VaultMetadata> {
|
|
43
45
|
const { config } = parseBaseArgs(args);
|
|
44
46
|
assertPublicClient(publicClient);
|
|
@@ -46,9 +48,8 @@ export async function getSWBeraVaultMetadata({
|
|
|
46
48
|
const hoursWindow = 26; // 26 hours is the window for the vault to ensure at least 1 claim per APR window.
|
|
47
49
|
try {
|
|
48
50
|
// Get current block number
|
|
49
|
-
const [currentBlock
|
|
51
|
+
const [currentBlock] = await Promise.all([
|
|
50
52
|
publicClient.getBlock({ blockTag: "latest" }),
|
|
51
|
-
getBlockTime(),
|
|
52
53
|
]);
|
|
53
54
|
const blocksPerWindow = Math.floor((hoursWindow * 60 * 60) / blockTime); // hoursWindow * 60 minutes * 60 seconds / actual block time
|
|
54
55
|
const blockWindowAgo = currentBlock.number - BigInt(blocksPerWindow);
|
|
@@ -121,7 +122,8 @@ export async function getSWBeraVaultMetadata({
|
|
|
121
122
|
functionName: "totalSupply",
|
|
122
123
|
}),
|
|
123
124
|
getStakeWithdrawalCooldown({
|
|
124
|
-
publicClient
|
|
125
|
+
publicClient,
|
|
126
|
+
address,
|
|
125
127
|
}),
|
|
126
128
|
getIncentiveFeeClaimStats({}),
|
|
127
129
|
]);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Address, PublicClient } from "viem";
|
|
2
2
|
|
|
3
3
|
import { stakeBeraVaultAbi } from "~/abi/pol/stakeBeraVault";
|
|
4
|
-
import { getStakeWithdrawalCooldown } from "~/actions";
|
|
5
|
-
import { formatTimeLeft
|
|
4
|
+
import { getStakeWithdrawalCooldown } from "~/actions/pol/getStakeWithdrawalCooldown";
|
|
5
|
+
import { formatTimeLeft } from "~/utils/formatTimestamps";
|
|
6
|
+
import { msToSeconds } from "~/utils/time";
|
|
7
|
+
import { isToken } from "~/utils/tokens";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Calculates and returns formatted time remaining until a target date
|
|
@@ -27,6 +29,7 @@ function getTimeUntil(targetTime: number): string | undefined {
|
|
|
27
29
|
* Interface representing a staked BERA withdrawal request
|
|
28
30
|
*/
|
|
29
31
|
export interface StakedBeraWithdrawal {
|
|
32
|
+
receiptTokenAddress: Address;
|
|
30
33
|
withdrawalAmount?: bigint;
|
|
31
34
|
timeRemaining?: string;
|
|
32
35
|
withdrawalRequestId?: bigint;
|
|
@@ -56,12 +59,17 @@ type WithdrawalRequestV1 = readonly [
|
|
|
56
59
|
* @param version - The version of the stake vault contract ("V1" or "V2")
|
|
57
60
|
* @returns Promise resolving to an array of withdrawal request information
|
|
58
61
|
*/
|
|
59
|
-
export async function getSWBeraWithdrawal(
|
|
60
|
-
contractAddress
|
|
61
|
-
accountAddress
|
|
62
|
-
publicClient
|
|
63
|
-
version
|
|
64
|
-
|
|
62
|
+
export async function getSWBeraWithdrawal({
|
|
63
|
+
contractAddress,
|
|
64
|
+
accountAddress,
|
|
65
|
+
publicClient,
|
|
66
|
+
version,
|
|
67
|
+
}: {
|
|
68
|
+
contractAddress: Address;
|
|
69
|
+
accountAddress: Address;
|
|
70
|
+
publicClient: PublicClient;
|
|
71
|
+
version: "V1" | "V2";
|
|
72
|
+
}): Promise<StakedBeraWithdrawal[]> {
|
|
65
73
|
const withdrawalRequests: StakedBeraWithdrawal[] = [];
|
|
66
74
|
|
|
67
75
|
function withdrawalRequestV1Helper(
|
|
@@ -76,6 +84,7 @@ export async function getSWBeraWithdrawal(
|
|
|
76
84
|
if (withdrawalAmount > 0) {
|
|
77
85
|
const timeRemaining = getTimeUntil(timeLeft <= 0 ? 0 : readyTime);
|
|
78
86
|
withdrawalRequests.push({
|
|
87
|
+
receiptTokenAddress: contractAddress,
|
|
79
88
|
withdrawalAmount,
|
|
80
89
|
timeRemaining,
|
|
81
90
|
});
|
|
@@ -93,31 +102,35 @@ export async function getSWBeraWithdrawal(
|
|
|
93
102
|
}),
|
|
94
103
|
getStakeWithdrawalCooldown({
|
|
95
104
|
publicClient,
|
|
105
|
+
address: contractAddress,
|
|
96
106
|
}),
|
|
97
107
|
]);
|
|
98
108
|
withdrawalRequestV1Helper(withdrawalRequest, lockPeriod);
|
|
99
109
|
return withdrawalRequests;
|
|
100
110
|
}
|
|
101
111
|
case "V2": {
|
|
102
|
-
const [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
publicClient
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
const [withdrawalRequestIds, lockPeriod] = await Promise.all([
|
|
113
|
+
publicClient.readContract({
|
|
114
|
+
address: contractAddress,
|
|
115
|
+
abi: stakeBeraVaultAbi,
|
|
116
|
+
functionName: "getERC721WithdrawalRequestIds" as const,
|
|
117
|
+
args: [accountAddress],
|
|
118
|
+
}),
|
|
119
|
+
getStakeWithdrawalCooldown({
|
|
120
|
+
publicClient,
|
|
121
|
+
address: contractAddress,
|
|
122
|
+
}),
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
if (isToken(contractAddress, "SWBERA")) {
|
|
126
|
+
const withdrawalRequestV1 = await publicClient.readContract({
|
|
127
|
+
address: contractAddress,
|
|
128
|
+
abi: stakeBeraVaultAbi,
|
|
129
|
+
functionName: "withdrawalRequests" as const,
|
|
130
|
+
args: [accountAddress],
|
|
131
|
+
});
|
|
132
|
+
withdrawalRequestV1Helper(withdrawalRequestV1, lockPeriod);
|
|
133
|
+
}
|
|
121
134
|
|
|
122
135
|
// Process each withdrawal request ID to get detailed information
|
|
123
136
|
const withdrawalResults = await Promise.all(
|
|
@@ -147,6 +160,7 @@ export async function getSWBeraWithdrawal(
|
|
|
147
160
|
withdrawalAmount,
|
|
148
161
|
timeRemaining,
|
|
149
162
|
withdrawalRequestId,
|
|
163
|
+
receiptTokenAddress: contractAddress,
|
|
150
164
|
};
|
|
151
165
|
}
|
|
152
166
|
return null;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import type { PublicClient } from "viem";
|
|
1
|
+
import type { Address, PublicClient } from "viem";
|
|
2
2
|
|
|
3
3
|
import { stakeBeraVaultAbi } from "~/abi/pol/stakeBeraVault";
|
|
4
|
-
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
5
4
|
|
|
6
5
|
export async function getStakeWithdrawalCooldown({
|
|
7
6
|
publicClient,
|
|
8
|
-
|
|
7
|
+
address,
|
|
9
8
|
}: {
|
|
10
9
|
publicClient: PublicClient;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
address: Address;
|
|
11
|
+
}): Promise<number> {
|
|
14
12
|
const lockPeriod = await publicClient.readContract({
|
|
15
|
-
address
|
|
13
|
+
address,
|
|
16
14
|
abi: stakeBeraVaultAbi,
|
|
17
15
|
functionName: "WITHDRAWAL_COOLDOWN" as const,
|
|
18
16
|
});
|