@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
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type Address, isAddress, zeroAddress } from "viem";
|
|
1
|
+
import { type Address, formatUnits, isAddress, zeroAddress } from "viem";
|
|
3
2
|
|
|
4
3
|
import type { BeraConfig, ChainId } from "@berachain/config/internal";
|
|
5
4
|
|
|
5
|
+
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
6
|
+
|
|
7
|
+
import type { HoneyConfigContextReturn } from "~/contexts/HoneyConfigProvider";
|
|
8
|
+
import type { Aggregators } from "~/enum/dex";
|
|
6
9
|
import { BeraError } from "~/errors/BeraError";
|
|
7
10
|
import { initBeraError } from "~/errors/initBeraError";
|
|
8
|
-
import type {
|
|
9
|
-
Aggregators,
|
|
10
|
-
IAggregatorArgs,
|
|
11
|
-
IRawAggregatorQuote,
|
|
12
|
-
} from "~/types/dex";
|
|
11
|
+
import type { IAggregatorArgs, IRawAggregatorQuote, Token } from "~/types/dex";
|
|
13
12
|
import { beraFetch } from "~/utils/beraFetch";
|
|
14
13
|
import { parseBaseArgs } from "~/utils/parseBaseArgs";
|
|
15
14
|
import { isToken } from "~/utils/tokens";
|
|
16
15
|
|
|
17
16
|
export abstract class BaseAggregator {
|
|
18
17
|
abstract name: Aggregators;
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Supported chains for the aggregator.
|
|
20
|
+
* If null, the aggregator is supported on all chains.
|
|
21
|
+
*/
|
|
22
|
+
abstract supportedChains: number[] | null;
|
|
20
23
|
static PATH_NOT_FOUND_REASON = "NO_SWAP_PATHS";
|
|
21
24
|
|
|
25
|
+
needsAccountForQuote: boolean = false;
|
|
22
26
|
notFoundMessages: string[] = [];
|
|
23
27
|
|
|
24
28
|
config: BeraConfig;
|
|
@@ -41,7 +45,7 @@ export abstract class BaseAggregator {
|
|
|
41
45
|
args: IAggregatorArgs,
|
|
42
46
|
):
|
|
43
47
|
| Promise<IRawAggregatorQuote | undefined>
|
|
44
|
-
| Promise<IRawAggregatorQuote
|
|
48
|
+
| Promise<IRawAggregatorQuote | undefined>;
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* return wbera for native tokens to accomodate the aggregator's router logic
|
|
@@ -75,7 +79,9 @@ export abstract class BaseAggregator {
|
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
/**
|
|
78
|
-
* Calculate input amount after fees
|
|
82
|
+
* Calculate input amount after fees.
|
|
83
|
+
*
|
|
84
|
+
* @returns Amount in wad format
|
|
79
85
|
*/
|
|
80
86
|
protected getAmountAfterFees(
|
|
81
87
|
amount: string,
|
|
@@ -102,20 +108,20 @@ export abstract class BaseAggregator {
|
|
|
102
108
|
amountIn,
|
|
103
109
|
isNative,
|
|
104
110
|
isPermit2Approval = false,
|
|
105
|
-
permit2SpenderAddress
|
|
111
|
+
permit2SpenderAddress,
|
|
106
112
|
}: {
|
|
107
113
|
tokenIn: Address;
|
|
108
114
|
amountIn: string;
|
|
109
115
|
isNative: boolean;
|
|
110
116
|
isPermit2Approval?: boolean;
|
|
111
|
-
permit2SpenderAddress?: Address;
|
|
117
|
+
permit2SpenderAddress?: Address | null;
|
|
112
118
|
}) {
|
|
113
119
|
return {
|
|
114
120
|
tokenIn,
|
|
115
121
|
amountIn: BigInt(amountIn),
|
|
116
122
|
isNative,
|
|
117
123
|
isPermit2Approval,
|
|
118
|
-
permit2SpenderAddress,
|
|
124
|
+
permit2SpenderAddress: permit2SpenderAddress ?? zeroAddress,
|
|
119
125
|
};
|
|
120
126
|
}
|
|
121
127
|
|
|
@@ -137,13 +143,65 @@ export abstract class BaseAggregator {
|
|
|
137
143
|
return BigInt(minAmountOut.toFixed(0));
|
|
138
144
|
}
|
|
139
145
|
|
|
146
|
+
protected parseAllowanceRequirements({
|
|
147
|
+
tokenIn,
|
|
148
|
+
rawAmount,
|
|
149
|
+
spender,
|
|
150
|
+
}: {
|
|
151
|
+
tokenIn: Token;
|
|
152
|
+
rawAmount: string;
|
|
153
|
+
spender: Address;
|
|
154
|
+
}) {
|
|
155
|
+
return isToken(tokenIn, "BERA")
|
|
156
|
+
? []
|
|
157
|
+
: [
|
|
158
|
+
{
|
|
159
|
+
token: tokenIn,
|
|
160
|
+
amount: {
|
|
161
|
+
raw: rawAmount,
|
|
162
|
+
formatted: formatUnits(BigInt(rawAmount), tokenIn.decimals),
|
|
163
|
+
},
|
|
164
|
+
spender,
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
|
|
140
169
|
/**
|
|
141
170
|
* Check if chain is supported
|
|
142
171
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
checkChainSupport({
|
|
173
|
+
tokenIn,
|
|
174
|
+
tokenOut,
|
|
175
|
+
}: {
|
|
176
|
+
tokenIn: Token;
|
|
177
|
+
tokenOut: Token;
|
|
178
|
+
// needed in honey native aggregator
|
|
179
|
+
honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
|
|
180
|
+
// needed in ERC4626 aggregator
|
|
181
|
+
underlyingToken?: Token | null;
|
|
182
|
+
}): boolean {
|
|
183
|
+
if (this.supportedChains === null) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
this.supportedChains.includes(tokenIn.chainId) &&
|
|
189
|
+
this.supportedChains.includes(tokenOut.chainId)
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
assertChainSupport({
|
|
194
|
+
tokenIn,
|
|
195
|
+
tokenOut,
|
|
196
|
+
underlyingToken,
|
|
197
|
+
}: {
|
|
198
|
+
tokenIn: Token;
|
|
199
|
+
tokenOut: Token;
|
|
200
|
+
underlyingToken?: Token | null;
|
|
201
|
+
}): void {
|
|
202
|
+
if (!this.checkChainSupport({ tokenIn, tokenOut, underlyingToken })) {
|
|
145
203
|
throw new BeraError({
|
|
146
|
-
message: `${this.name}
|
|
204
|
+
message: `${this.name} does not support tokens chain ID: ${tokenIn.chainId} and ${tokenOut.chainId}`,
|
|
147
205
|
level: "error",
|
|
148
206
|
});
|
|
149
207
|
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
Token,
|
|
8
8
|
TokenAmount,
|
|
9
9
|
} from "@berachain-foundation/berancer-sdk";
|
|
10
|
-
import * as Sentry from "@sentry/nextjs";
|
|
11
10
|
import { decodeFunctionData, formatEther, zeroAddress } from "viem";
|
|
12
11
|
|
|
13
12
|
import { getUriFromLink } from "@berachain/config";
|
|
@@ -15,15 +14,12 @@ import { ChainId } from "@berachain/config/internal";
|
|
|
15
14
|
|
|
16
15
|
import { balancerVaultAbi } from "~/abi/bex/balancerVault";
|
|
17
16
|
import { BalancerApi } from "~/actions/dex/b-sdk";
|
|
17
|
+
import { Aggregators } from "~/enum/dex";
|
|
18
18
|
import { assertPublicClient } from "~/errors/assert";
|
|
19
19
|
import { BeraError } from "~/errors/BeraError";
|
|
20
|
-
import {
|
|
20
|
+
import { BeraMonitoring } from "~/errors/BeraMonitoring";
|
|
21
21
|
import { RequestError } from "~/errors/RequestError";
|
|
22
|
-
import {
|
|
23
|
-
Aggregators,
|
|
24
|
-
type IAggregatorArgs,
|
|
25
|
-
type IRawAggregatorQuote,
|
|
26
|
-
} from "~/types";
|
|
22
|
+
import type { IAggregatorArgs, IRawAggregatorQuote } from "~/types/dex";
|
|
27
23
|
import { isToken } from "~/utils/tokens";
|
|
28
24
|
import { BaseAggregator } from "./base";
|
|
29
25
|
|
|
@@ -63,12 +59,17 @@ class BexAggregator extends BaseAggregator {
|
|
|
63
59
|
/**
|
|
64
60
|
* Helper to check for stale SOR prices
|
|
65
61
|
*/
|
|
66
|
-
private checkStalePrices(
|
|
67
|
-
onChainAmount
|
|
68
|
-
sorPaths
|
|
69
|
-
sorAmount
|
|
70
|
-
queryData
|
|
71
|
-
|
|
62
|
+
private checkStalePrices({
|
|
63
|
+
onChainAmount,
|
|
64
|
+
sorPaths,
|
|
65
|
+
sorAmount,
|
|
66
|
+
queryData,
|
|
67
|
+
}: {
|
|
68
|
+
onChainAmount: TokenAmount;
|
|
69
|
+
sorPaths: { pools: string[] }[];
|
|
70
|
+
sorAmount: string;
|
|
71
|
+
queryData: IAggregatorArgs;
|
|
72
|
+
}): void {
|
|
72
73
|
// Check for stale prices
|
|
73
74
|
const deltaFromSorAmount =
|
|
74
75
|
Number.parseFloat(formatEther(onChainAmount.scale18)) /
|
|
@@ -87,9 +88,6 @@ class BexAggregator extends BaseAggregator {
|
|
|
87
88
|
level: "warning",
|
|
88
89
|
message:
|
|
89
90
|
"SOR returned stale prices. Delta from return amount is more than 5%",
|
|
90
|
-
});
|
|
91
|
-
Sentry.captureException(error, {
|
|
92
|
-
level: "warning",
|
|
93
91
|
extra: {
|
|
94
92
|
deltaFromSorAmount,
|
|
95
93
|
pools: sorPaths.map((p) => p.pools),
|
|
@@ -99,10 +97,11 @@ class BexAggregator extends BaseAggregator {
|
|
|
99
97
|
},
|
|
100
98
|
fingerprint: ["SOR_STALE_PRICES"],
|
|
101
99
|
});
|
|
100
|
+
BeraMonitoring.captureException(error);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
async getQuote(args: IAggregatorArgs): Promise<IRawAggregatorQuote
|
|
104
|
+
async getQuote(args: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
106
105
|
const balancerApi = new BalancerApi(
|
|
107
106
|
this.url,
|
|
108
107
|
// @ts-expect-error b-sdk has more chains than berajs
|
|
@@ -111,47 +110,27 @@ class BexAggregator extends BaseAggregator {
|
|
|
111
110
|
const {
|
|
112
111
|
tokenIn,
|
|
113
112
|
tokenOut,
|
|
114
|
-
tokenInDecimals,
|
|
115
|
-
tokenOutDecimals,
|
|
116
113
|
amount,
|
|
117
114
|
slippage,
|
|
118
115
|
account = zeroAddress,
|
|
119
116
|
publicClient,
|
|
120
117
|
} = args;
|
|
121
|
-
this.
|
|
118
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
122
119
|
|
|
123
120
|
assertPublicClient(publicClient);
|
|
124
121
|
|
|
125
|
-
if (!tokenInDecimals) {
|
|
126
|
-
throw new InvalidArgumentError({
|
|
127
|
-
property: "tokenInDecimals",
|
|
128
|
-
value: tokenInDecimals,
|
|
129
|
-
expected: "number",
|
|
130
|
-
chainId: this.chainId,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!tokenOutDecimals) {
|
|
135
|
-
throw new InvalidArgumentError({
|
|
136
|
-
property: "tokenOutDecimals",
|
|
137
|
-
value: tokenOutDecimals,
|
|
138
|
-
expected: "number",
|
|
139
|
-
chainId: this.chainId,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
122
|
const wberaIsBera = isToken(tokenIn, "BERA") || isToken(tokenOut, "BERA");
|
|
144
123
|
|
|
145
124
|
// Initialize tokens
|
|
146
125
|
const tokenInV3 = new Token(
|
|
147
126
|
this.chainId,
|
|
148
|
-
this.convertZeroToWrapped(tokenIn
|
|
149
|
-
|
|
127
|
+
this.convertZeroToWrapped(tokenIn.address),
|
|
128
|
+
tokenIn.decimals,
|
|
150
129
|
);
|
|
151
130
|
const tokenOutV3 = new Token(
|
|
152
131
|
this.chainId,
|
|
153
|
-
this.convertZeroToWrapped(tokenOut
|
|
154
|
-
|
|
132
|
+
this.convertZeroToWrapped(tokenOut.address),
|
|
133
|
+
tokenOut.decimals,
|
|
155
134
|
);
|
|
156
135
|
|
|
157
136
|
const tokenAmount = TokenAmount.fromRawAmount(
|
|
@@ -206,47 +185,48 @@ class BexAggregator extends BaseAggregator {
|
|
|
206
185
|
throw new Error("No Bex paths found");
|
|
207
186
|
}
|
|
208
187
|
|
|
209
|
-
this.checkStalePrices(
|
|
210
|
-
queryOutput.expectedAmountOut,
|
|
188
|
+
this.checkStalePrices({
|
|
189
|
+
onChainAmount: queryOutput.expectedAmountOut,
|
|
211
190
|
sorPaths,
|
|
212
191
|
sorAmount,
|
|
213
|
-
args,
|
|
214
|
-
);
|
|
192
|
+
queryData: args,
|
|
193
|
+
});
|
|
215
194
|
|
|
216
195
|
// format quote response
|
|
217
|
-
|
|
196
|
+
return {
|
|
218
197
|
amountOut: queryOutput.expectedAmountOut.amount.toString(),
|
|
219
198
|
amountIn: amount,
|
|
220
|
-
|
|
199
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
200
|
+
tokenIn,
|
|
201
|
+
rawAmount: amount,
|
|
202
|
+
spender: queryOutput.to,
|
|
203
|
+
}),
|
|
221
204
|
name: this.name,
|
|
222
205
|
priceImpactPercentage: this.calculatePriceImpact(priceImpact),
|
|
223
206
|
swapFeeBps: 0,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
abi: balancerVaultAbi,
|
|
248
|
-
address: callData.to,
|
|
249
|
-
value: callData.value || BigInt(0),
|
|
207
|
+
getCalldata: ({ account }) => {
|
|
208
|
+
// generate user transaction data
|
|
209
|
+
const callData = swap.buildCall({
|
|
210
|
+
slippage: Slippage.fromPercentage(slippage.toString() as `${number}`),
|
|
211
|
+
deadline: BigInt(Math.round(Date.now() / 1000) + DEFAULT_DEADLINE),
|
|
212
|
+
queryOutput,
|
|
213
|
+
sender: account as Address,
|
|
214
|
+
recipient: account as Address,
|
|
215
|
+
wethIsEth: wberaIsBera,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const { args: params, functionName } = decodeFunctionData({
|
|
219
|
+
abi: balancerVaultAbi,
|
|
220
|
+
data: callData.callData,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
params,
|
|
225
|
+
functionName,
|
|
226
|
+
abi: balancerVaultAbi,
|
|
227
|
+
address: callData.to,
|
|
228
|
+
value: callData.value || BigInt(0),
|
|
229
|
+
};
|
|
250
230
|
},
|
|
251
231
|
};
|
|
252
232
|
}
|
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
import { ChainId } from "@berachain/config/internal";
|
|
2
2
|
|
|
3
|
+
import { Aggregators } from "~/enum/dex";
|
|
3
4
|
import { InvalidArgumentError } from "~/errors/InvalidArgumentError";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "~/types";
|
|
9
|
-
import { isToken } from "~/utils/tokens";
|
|
5
|
+
import type {
|
|
6
|
+
IAggregatorArgs,
|
|
7
|
+
IRawAggregatorQuote,
|
|
8
|
+
MinimalERC20,
|
|
9
|
+
} from "~/types/dex";
|
|
10
|
+
import { beraToken, isToken } from "~/utils/tokens";
|
|
10
11
|
import { BaseAggregator } from "./base";
|
|
11
12
|
|
|
12
13
|
class RedeemBgtAggregator extends BaseAggregator {
|
|
13
14
|
name = Aggregators.RedeemBgt;
|
|
14
15
|
supportedChains = [ChainId.MAINNET, ChainId.BEPOLIA];
|
|
15
16
|
readonly type = "rpc";
|
|
17
|
+
|
|
18
|
+
checkChainSupport({
|
|
19
|
+
tokenIn,
|
|
20
|
+
tokenOut,
|
|
21
|
+
}: {
|
|
22
|
+
tokenIn: MinimalERC20;
|
|
23
|
+
tokenOut: MinimalERC20;
|
|
24
|
+
}): boolean {
|
|
25
|
+
if (!super.checkChainSupport({ tokenIn, tokenOut })) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
// only supported on same chain
|
|
31
|
+
tokenIn.chainId === tokenOut.chainId &&
|
|
32
|
+
isToken(tokenIn, "BGT", { chainId: tokenIn.chainId }) &&
|
|
33
|
+
isToken(tokenOut, "BERA")
|
|
34
|
+
);
|
|
35
|
+
}
|
|
16
36
|
// handles native swaps: wrap and unwrap
|
|
17
37
|
async getQuote({
|
|
18
38
|
tokenIn,
|
|
@@ -21,7 +41,10 @@ class RedeemBgtAggregator extends BaseAggregator {
|
|
|
21
41
|
IAggregatorArgs,
|
|
22
42
|
"slippage" | "feeBps" | "tokenOut" | "account"
|
|
23
43
|
>): Promise<IRawAggregatorQuote> {
|
|
24
|
-
this.
|
|
44
|
+
this.assertChainSupport({
|
|
45
|
+
tokenIn,
|
|
46
|
+
tokenOut: { ...beraToken, chainId: tokenIn.chainId },
|
|
47
|
+
});
|
|
25
48
|
|
|
26
49
|
if (!isToken(tokenIn, "BGT", { config: this.config })) {
|
|
27
50
|
throw new InvalidArgumentError({
|
|
@@ -35,7 +58,7 @@ class RedeemBgtAggregator extends BaseAggregator {
|
|
|
35
58
|
return {
|
|
36
59
|
amountOut: amount,
|
|
37
60
|
amountIn: amount,
|
|
38
|
-
|
|
61
|
+
allowanceRequirements: [],
|
|
39
62
|
name: Aggregators.RedeemBgt,
|
|
40
63
|
isNativeSwap: true,
|
|
41
64
|
swapFeeBps: 0,
|
|
@@ -3,22 +3,23 @@ import { zeroAddress } from "viem";
|
|
|
3
3
|
import { ChainId } from "@berachain/config/internal";
|
|
4
4
|
|
|
5
5
|
import { aggregatorsRouterAbi } from "~/abi/bex/aggregatorsRouter";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { BaseAggregator } from "./base";
|
|
12
|
-
|
|
13
|
-
class EnsoAggregator extends BaseAggregator {
|
|
6
|
+
import { Aggregators } from "~/enum/dex";
|
|
7
|
+
import type { IAggregatorArgs, IRawAggregatorQuote } from "~/types/dex";
|
|
8
|
+
import { BaseAggregator } from "../base";
|
|
9
|
+
|
|
10
|
+
export class EnsoAggregator extends BaseAggregator {
|
|
14
11
|
name = Aggregators.Enso;
|
|
15
12
|
supportedChains = [ChainId.MAINNET];
|
|
16
13
|
readonly type = "rest";
|
|
14
|
+
needsAccountForQuote = true;
|
|
17
15
|
|
|
18
16
|
notFoundMessages: string[] = [
|
|
19
17
|
"Could not build shortcuts for route",
|
|
18
|
+
"Could not quote shortcuts for route",
|
|
20
19
|
"Swap not found for a required underlying of defi route,",
|
|
20
|
+
"No route found from",
|
|
21
21
|
];
|
|
22
|
+
|
|
22
23
|
async getQuote({
|
|
23
24
|
tokenIn,
|
|
24
25
|
tokenOut,
|
|
@@ -29,14 +30,14 @@ class EnsoAggregator extends BaseAggregator {
|
|
|
29
30
|
proxyAggregatorsThroughVercel = false,
|
|
30
31
|
rewardVault,
|
|
31
32
|
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
32
|
-
this.
|
|
33
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
33
34
|
|
|
34
35
|
const {
|
|
35
36
|
tokenInAddress,
|
|
36
37
|
tokenOutAddress,
|
|
37
38
|
isTokenInNative,
|
|
38
39
|
isTokenOutNative,
|
|
39
|
-
} = this.parseAddresses(tokenIn, tokenOut);
|
|
40
|
+
} = this.parseAddresses(tokenIn.address, tokenOut.address);
|
|
40
41
|
|
|
41
42
|
const inputAmountAfterFees = this.getAmountAfterFees(
|
|
42
43
|
amount,
|
|
@@ -86,11 +87,14 @@ class EnsoAggregator extends BaseAggregator {
|
|
|
86
87
|
return {
|
|
87
88
|
amountOut: quote.amountOut.toString(),
|
|
88
89
|
amountIn: amount,
|
|
89
|
-
|
|
90
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
91
|
+
tokenIn,
|
|
92
|
+
rawAmount: amount,
|
|
93
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
94
|
+
}),
|
|
90
95
|
name: this.name,
|
|
91
96
|
swapFeeBps: aggregatorsFeeBps!,
|
|
92
|
-
|
|
93
|
-
calldata: {
|
|
97
|
+
getCalldata: () => ({
|
|
94
98
|
params: [
|
|
95
99
|
inputData,
|
|
96
100
|
outputData,
|
|
@@ -105,7 +109,7 @@ class EnsoAggregator extends BaseAggregator {
|
|
|
105
109
|
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
106
110
|
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
107
111
|
address: this.config.bex.aggregatorsRouter,
|
|
108
|
-
},
|
|
112
|
+
}),
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
115
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { berachain } from "viem/chains";
|
|
2
|
+
import { describe, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { mainnet } from "@berachain/config/mainnet";
|
|
5
|
+
|
|
6
|
+
import { beraToken, getHoneyToken } from "~/utils/tokens";
|
|
7
|
+
import { ensoErc4626 } from "./ensoErc4626";
|
|
8
|
+
|
|
9
|
+
describe("ensoErc4626", () => {
|
|
10
|
+
it("should return a quote", async () => {
|
|
11
|
+
const re7Honey = {
|
|
12
|
+
...beraToken,
|
|
13
|
+
address: mainnet.bend.production.supportedVaults[0],
|
|
14
|
+
chainId: berachain.id,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const optimism = {
|
|
18
|
+
address: "0x4200000000000000000000000000000000000042",
|
|
19
|
+
decimals: 18,
|
|
20
|
+
symbol: "OP",
|
|
21
|
+
name: "Optimism",
|
|
22
|
+
chainId: 10,
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
const quote = await ensoErc4626.getQuote({
|
|
26
|
+
tokenIn: optimism,
|
|
27
|
+
tokenOut: re7Honey,
|
|
28
|
+
account: "0x79f453D56C4bC66586215827FbBc7B34Bc006b33",
|
|
29
|
+
amount: "10000000000000000000",
|
|
30
|
+
slippage: 1,
|
|
31
|
+
underlyingToken: getHoneyToken({ chainId: re7Honey.chainId }),
|
|
32
|
+
rewardVault: "0xdb6e93cd7bddc45ebc411619792fc5f977316c38",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log(quote);
|
|
36
|
+
});
|
|
37
|
+
});
|