@berachain/berajs 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BeraError-D1HS_rbb.d.cts → BeraError-_mQdkanr.d.cts} +35 -10
- package/dist/{BeraError-D1HS_rbb.d.ts → BeraError-_mQdkanr.d.ts} +35 -10
- package/dist/HoneyConfigProvider-CK6mOKFH.d.ts +390 -0
- package/dist/HoneyConfigProvider-Ca3ouozs.d.cts +390 -0
- package/dist/{RequestError-D8AE6xnI.d.cts → RequestError-A8XJ6QR9.d.cts} +1 -1
- package/dist/{RequestError-m4jxyM7D.d.ts → RequestError-Dk97z8rm.d.ts} +1 -1
- package/dist/abi/exports.cjs +2 -0
- package/dist/abi/exports.cjs.map +1 -0
- package/dist/abi/{index.d.cts → exports.d.cts} +12369 -9122
- package/dist/abi/{index.d.ts → exports.d.ts} +12369 -9122
- package/dist/abi/exports.mjs +2 -0
- package/dist/abi/exports.mjs.map +1 -0
- package/dist/actions/exports.cjs +2 -0
- package/dist/actions/exports.cjs.map +1 -0
- package/dist/actions/{index.d.cts → exports.d.cts} +79 -107
- package/dist/actions/{index.d.ts → exports.d.ts} +79 -107
- package/dist/actions/exports.mjs +2 -0
- package/dist/actions/exports.mjs.map +1 -0
- package/dist/chunk-22J3YJDN.cjs +2 -0
- package/dist/chunk-22J3YJDN.cjs.map +1 -0
- package/dist/chunk-2LL3P5PN.mjs +2 -0
- package/dist/chunk-2LL3P5PN.mjs.map +1 -0
- package/dist/chunk-3YXSUBA5.mjs +2 -0
- package/dist/chunk-3YXSUBA5.mjs.map +1 -0
- package/dist/chunk-55L7STYD.mjs +2 -0
- package/dist/chunk-55L7STYD.mjs.map +1 -0
- package/dist/chunk-575OK77P.mjs +2 -0
- package/dist/chunk-575OK77P.mjs.map +1 -0
- package/dist/chunk-6LDOG5RL.cjs +2 -0
- package/dist/chunk-6LDOG5RL.cjs.map +1 -0
- package/dist/chunk-7LNBSOVV.cjs +2 -0
- package/dist/chunk-7LNBSOVV.cjs.map +1 -0
- package/dist/chunk-7SMWQ6SN.mjs +2 -0
- package/dist/chunk-7SMWQ6SN.mjs.map +1 -0
- package/dist/chunk-7WRTK7RJ.mjs +2 -0
- package/dist/chunk-7WRTK7RJ.mjs.map +1 -0
- package/dist/chunk-A4UDYSB6.mjs +4 -0
- package/dist/chunk-A4UDYSB6.mjs.map +1 -0
- package/dist/chunk-AX2YQQFQ.mjs +2 -0
- package/dist/chunk-AX2YQQFQ.mjs.map +1 -0
- package/dist/chunk-C3FHGFLK.mjs +2 -0
- package/dist/chunk-C3FHGFLK.mjs.map +1 -0
- package/dist/chunk-C6ZGUO4H.cjs +2 -0
- package/dist/chunk-C6ZGUO4H.cjs.map +1 -0
- package/dist/chunk-CYKCYPFR.cjs +2 -0
- package/dist/chunk-CYKCYPFR.cjs.map +1 -0
- package/dist/chunk-ECRMUMTA.mjs +2 -0
- package/dist/chunk-ECRMUMTA.mjs.map +1 -0
- package/dist/chunk-F4BKSBEM.mjs +2 -0
- package/dist/chunk-F4BKSBEM.mjs.map +1 -0
- package/dist/chunk-FCWDGE62.cjs +2 -0
- package/dist/chunk-FCWDGE62.cjs.map +1 -0
- package/dist/chunk-FL2N3XHK.cjs +2 -0
- package/dist/chunk-FL2N3XHK.cjs.map +1 -0
- package/dist/chunk-MUCEYO3E.cjs +4 -0
- package/dist/chunk-MUCEYO3E.cjs.map +1 -0
- package/dist/chunk-NAXAZJJY.mjs +2 -0
- package/dist/chunk-NAXAZJJY.mjs.map +1 -0
- package/dist/chunk-OGJMSGB2.mjs +2 -0
- package/dist/chunk-OGJMSGB2.mjs.map +1 -0
- package/dist/chunk-OIYXOKTT.cjs +2 -0
- package/dist/chunk-OIYXOKTT.cjs.map +1 -0
- package/dist/chunk-P2Q7CMUD.cjs +2 -0
- package/dist/chunk-P2Q7CMUD.cjs.map +1 -0
- package/dist/chunk-PKXAW6MO.cjs +2 -0
- package/dist/chunk-PKXAW6MO.cjs.map +1 -0
- package/dist/chunk-Q3SCM6WL.mjs +2 -0
- package/dist/chunk-Q3SCM6WL.mjs.map +1 -0
- package/dist/chunk-SWMJQOH6.cjs +2 -0
- package/dist/chunk-SWMJQOH6.cjs.map +1 -0
- package/dist/chunk-TEBJWAVU.mjs +2 -0
- package/dist/chunk-TEBJWAVU.mjs.map +1 -0
- package/dist/chunk-THATXCJK.mjs +2 -0
- package/dist/chunk-THATXCJK.mjs.map +1 -0
- package/dist/chunk-VP7XUOSI.cjs +2 -0
- package/dist/chunk-VP7XUOSI.cjs.map +1 -0
- package/dist/chunk-VXL2ZZ4X.cjs +2 -0
- package/dist/chunk-VXL2ZZ4X.cjs.map +1 -0
- package/dist/chunk-WRFDB3QJ.cjs +2 -0
- package/dist/chunk-WRFDB3QJ.cjs.map +1 -0
- package/dist/chunk-XNJLSA6P.cjs +2 -0
- package/dist/chunk-XNJLSA6P.cjs.map +1 -0
- package/dist/chunk-YXLFOEZN.mjs +2 -0
- package/dist/chunk-YXLFOEZN.mjs.map +1 -0
- package/dist/chunk-YZV5LKIP.cjs +2 -0
- package/dist/chunk-YZV5LKIP.cjs.map +1 -0
- package/dist/contexts/exports.cjs +2 -0
- package/dist/contexts/exports.cjs.map +1 -0
- package/dist/contexts/{index.d.cts → exports.d.cts} +10 -27
- package/dist/contexts/{index.d.ts → exports.d.ts} +10 -27
- package/dist/contexts/exports.mjs +2 -0
- package/dist/contexts/exports.mjs.map +1 -0
- package/dist/{defaultFlags-V-tJs2K8.d.cts → defaultFlags-d0kPbT0i.d.cts} +1 -1
- package/dist/{defaultFlags-V-tJs2K8.d.ts → defaultFlags-d0kPbT0i.d.ts} +1 -1
- package/dist/dex-C_BB0b0O.d.cts +37 -0
- package/dist/dex-C_BB0b0O.d.ts +37 -0
- package/dist/enum/exports.cjs +2 -0
- package/dist/enum/exports.cjs.map +1 -0
- package/dist/enum/exports.d.cts +23 -0
- package/dist/enum/exports.d.ts +23 -0
- package/dist/enum/exports.mjs +2 -0
- package/dist/enum/exports.mjs.map +1 -0
- package/dist/errors/exports.cjs +2 -0
- package/dist/errors/exports.cjs.map +1 -0
- package/dist/errors/exports.d.cts +408 -0
- package/dist/errors/exports.d.ts +408 -0
- package/dist/errors/exports.mjs +2 -0
- package/dist/{getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts → getValidatorQueuedOperatorAddress-Dstyaomr.d.cts} +125 -15
- package/dist/{getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts → getValidatorQueuedOperatorAddress-RW4OMcD1.d.ts} +125 -15
- package/dist/global.d-CN6l2b9E.d.cts +473 -0
- package/dist/global.d-wYu8G8IQ.d.ts +473 -0
- package/dist/honey-CYm0RWf4.d.cts +14 -0
- package/dist/honey-CYm0RWf4.d.ts +14 -0
- package/dist/hooks/exports.cjs +4 -0
- package/dist/hooks/exports.cjs.map +1 -0
- package/dist/hooks/{index.d.cts → exports.d.cts} +218 -176
- package/dist/hooks/{index.d.ts → exports.d.ts} +218 -176
- package/dist/hooks/exports.mjs +4 -0
- package/dist/hooks/exports.mjs.map +1 -0
- package/dist/{txnEnum-BQKDfaeH.d.cts → txnEnum-BlBYhNRl.d.cts} +75 -1
- package/dist/{txnEnum-BQKDfaeH.d.ts → txnEnum-BlBYhNRl.d.ts} +75 -1
- package/dist/types/exports.cjs +1 -0
- package/dist/types/exports.cjs.map +1 -0
- package/dist/types/exports.d.cts +57 -0
- package/dist/types/exports.d.ts +57 -0
- package/dist/types/exports.mjs +1 -0
- package/dist/{useHoneySwapState-C-9BV4VB.d.cts → useHoneySwapState-B-vmIP1b.d.cts} +1 -1
- package/dist/{useHoneySwapState-CUY5Sm1b.d.ts → useHoneySwapState-D1DKG_Of.d.ts} +1 -1
- package/dist/utils/exports.cjs +2 -0
- package/dist/utils/exports.cjs.map +1 -0
- package/dist/utils/{index.d.cts → exports.d.cts} +83 -20
- package/dist/utils/{index.d.ts → exports.d.ts} +83 -20
- package/dist/utils/exports.mjs +2 -0
- package/dist/utils/exports.mjs.map +1 -0
- package/package.json +19 -20
- package/src/abi/{index.ts → exports.ts} +3 -0
- package/src/abi/pol/LSTStakerVault.ts +2032 -0
- package/src/abi/utils/openChainErrors.ts +71 -30
- package/src/abi/utils/thirdwebMinimalAccount.ts +616 -0
- package/src/actions/clients/BeraApolloClient.ts +8 -6
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +2 -5
- package/src/actions/dex/aggregators/base.ts +74 -16
- package/src/actions/dex/aggregators/bex.ts +54 -74
- package/src/actions/dex/aggregators/bgt.ts +31 -8
- package/src/actions/dex/aggregators/{enso.ts → enso/enso.ts} +18 -14
- package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +37 -0
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +176 -0
- package/src/actions/dex/aggregators/erc4626.ts +122 -0
- package/src/actions/dex/aggregators/fly.ts +59 -53
- package/src/actions/dex/aggregators/haiku.ts +52 -54
- package/src/actions/dex/aggregators/honey.ts +54 -45
- package/src/actions/dex/aggregators/kyberswap.ts +41 -39
- package/src/actions/dex/aggregators/oogabooga.ts +47 -46
- package/src/actions/dex/aggregators/openOcean.ts +51 -46
- package/src/actions/dex/aggregators/wbera.ts +54 -42
- package/src/actions/dex/b-sdk.ts +5 -2
- package/src/actions/dex/getIsTokenExploited.ts +2 -2
- package/src/actions/enso/{zap.ts → getEnsoSwapBundle.ts} +4 -5
- package/src/actions/enso/getEnsoUserTokensWithBalances.debug.test.ts +73 -0
- package/src/actions/enso/{getEnsoUserToken.ts → getEnsoUserTokensWithBalances.ts} +42 -30
- package/src/actions/enso/util.ts +1 -1
- package/src/actions/{index.ts → exports.ts} +5 -0
- package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +1 -1
- package/src/actions/governance/__tests__/getQuorum.integration.test.ts +1 -1
- package/src/actions/governance/checkProposalField.ts +1 -1
- package/src/actions/governance/computeActualStatus.ts +1 -1
- package/src/actions/governance/getBodyErrors.ts +1 -1
- package/src/actions/governance/getDecodedFunctionData.ts +1 -4
- package/src/actions/governance/getProposalDetails.ts +2 -2
- package/src/actions/governance/getProposalFromTx.ts +1 -2
- package/src/actions/governance/getProposalParams.ts +7 -8
- package/src/actions/governance/getQuorum.ts +1 -2
- package/src/actions/honey/getCollateralWeights.ts +1 -1
- package/src/actions/honey/getHoneyCollaterals.ts +1 -0
- package/src/actions/honey/getHoneyVaultsBalance.ts +51 -55
- package/src/actions/honey/getSwapPayload.ts +37 -35
- package/src/actions/honey/tests/pyth.integration.test.ts +0 -1
- package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +1 -1
- package/src/actions/pol/getEarnedStakedBeraVault.ts +31 -0
- package/src/actions/pol/getGlobalData.ts +14 -13
- package/src/actions/pol/getLSTStakeConfig.ts +67 -0
- package/src/actions/pol/getMarkets.ts +1 -1
- package/src/actions/pol/getRewardProofsByValidator.ts +1 -1
- package/src/actions/pol/getRewardVaultIncentives.ts +3 -5
- package/src/actions/pol/getRewardVaults.ts +2 -3
- package/src/actions/pol/getSWBeraVaultMetadata.ts +7 -5
- package/src/actions/pol/getSWBeraWithdrawal.ts +41 -27
- package/src/actions/pol/getStakeWithdrawalCooldown.ts +5 -7
- package/src/actions/pol/getStakingDailyAssets.ts +24 -0
- package/src/actions/pol/getStakingTokenInformation.ts +3 -4
- package/src/actions/pol/getTotalStakedAmount.ts +47 -0
- package/src/actions/pol/getUserClaimableIncentives.ts +1 -1
- package/src/actions/pol/getUserVaults.ts +8 -6
- package/src/actions/pol/getUserVaultsBalance.ts +4 -16
- package/src/actions/prices/getTokenCurrentPrices.ts +8 -3
- package/src/actions/tokens/getAllowances.ts +68 -41
- package/src/actions/tokens/getTokenInformation.ts +4 -1
- package/src/actions/tokens/getTokens.ts +1 -1
- package/src/actions/tokens/getUnderlyingToken.ts +53 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +53 -14
- package/src/actions/tokens/getWalletBalances.ts +69 -43
- package/src/actions/transactions/beraWriteContract.integration.test.ts +18 -6
- package/src/actions/transactions/beraWriteContract.ts +3 -3
- package/src/actions/validators/getUserActiveValidators.ts +2 -3
- package/src/actions/validators/getUserBoostsOnValidator.ts +2 -3
- package/src/contexts/BeraFlags/defaultFlags.ts +4 -0
- package/src/contexts/SwrFallback.tsx +13 -3
- package/src/contexts/TokensProvider.tsx +35 -8
- package/src/contexts/block-time-provider.tsx +1 -1
- package/src/contexts/{index.ts → exports.ts} +0 -1
- package/src/data/contracts.ts +17 -2
- package/src/enum/contracts.ts +13 -0
- package/src/enum/dex.ts +29 -0
- package/src/enum/{index.ts → exports.ts} +3 -0
- package/src/enum/governance.ts +61 -0
- package/src/enum/honey.ts +12 -0
- package/src/enum/txnEnum.ts +1 -0
- package/src/errors/BeraError.ts +61 -13
- package/src/errors/BeraMonitoring.ts +66 -0
- package/src/errors/BeraTracing.ts +79 -0
- package/src/errors/BeraTracing.unit.test.ts +198 -0
- package/src/errors/RequestError.ts +29 -3
- package/src/errors/assert.ts +4 -2
- package/src/errors/assert.unit.test.ts +6 -2
- package/src/errors/errorMap.ts +19 -8
- package/src/errors/{index.ts → exports.ts} +7 -0
- package/src/errors/getErrorMessage.ts +67 -9
- package/src/errors/getRevertReason.integration.test.ts +18 -6
- package/src/errors/getRevertReason.ts +41 -2
- package/src/errors/initBeraError.ts +52 -7
- package/src/errors/parseViemError.ts +114 -27
- package/src/errors/severity.ts +12 -0
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -2
- package/src/hooks/dex/useAggregatorsQuotes.ts +126 -365
- package/src/hooks/dex/useAllUserPools.ts +1 -1
- package/src/hooks/dex/useApiPool.ts +1 -1
- package/src/hooks/dex/useCreatePool.ts +6 -5
- package/src/hooks/dex/useExploitedTokens.ts +1 -1
- package/src/hooks/dex/useLiquidityMismatch.ts +2 -5
- package/src/hooks/dex/useLpPosition.ts +21 -20
- package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +40 -29
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -1
- package/src/hooks/dex/usePoolEvents.ts +1 -1
- package/src/hooks/dex/usePools.ts +1 -1
- package/src/hooks/dex/usePriceImpact.ts +40 -0
- package/src/hooks/dex/useSingleAggregatorQuote.ts +350 -0
- package/src/hooks/enso/useBendZapSupply.ts +216 -0
- package/src/hooks/enso/useEnsoSwapBundle.ts +107 -0
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +43 -0
- package/src/hooks/enso/useZapStakeBera.ts +113 -0
- package/src/hooks/{index.ts → exports.ts} +17 -10
- package/src/hooks/governance/useCreateProposal.ts +8 -8
- package/src/hooks/governance/usePollAllProposals.ts +1 -1
- package/src/hooks/governance/usePollProposal.ts +1 -1
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
- package/src/hooks/governance/usePollUserDelegates.ts +1 -1
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/honey/useCappedGlobally.ts +2 -1
- package/src/hooks/honey/useCappedRelatively.ts +1 -1
- package/src/hooks/honey/useCollateralWeights.ts +2 -1
- package/src/hooks/honey/useHoneyAlerts.ts +11 -11
- package/src/hooks/honey/useHoneyBalances.ts +7 -3
- package/src/hooks/honey/useHoneyGlobalData.ts +2 -1
- package/src/hooks/honey/useHoneySwapState.ts +2 -1
- package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -1
- package/src/hooks/honey/useIsBadCollateralAsset.ts +2 -1
- package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -1
- package/src/hooks/honey/usePythLatestPrices.ts +1 -1
- package/src/hooks/pol/useOnChainRewardVault.ts +3 -2
- package/src/hooks/pol/usePollGlobalData.ts +1 -1
- package/src/hooks/pol/usePollMarkets.ts +1 -1
- package/src/hooks/pol/useQueuedBeraUnlock.ts +17 -15
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +6 -3
- package/src/hooks/pol/useRewardVault.ts +1 -1
- package/src/hooks/pol/useRewardVaults.ts +1 -1
- package/src/hooks/pol/useSWBeraVaultMetadata.ts +35 -0
- package/src/hooks/pol/useStakedAPR.ts +38 -0
- package/src/hooks/pol/useStakedData.ts +117 -0
- package/src/hooks/pol/useStakedSnapshots.ts +52 -0
- package/src/hooks/pol/useTotalStakedAmount.ts +30 -0
- package/src/hooks/pol/useUserVaultInfo.ts +1 -1
- package/src/hooks/pol/useVaultValidators.ts +1 -1
- package/src/hooks/tokens/useMultipleTokenInformation.ts +15 -6
- package/src/hooks/tokens/usePollAllowances.ts +15 -19
- package/src/hooks/tokens/usePollBalance.ts +8 -4
- package/src/hooks/tokens/usePollWalletBalances.ts +14 -11
- package/src/hooks/tokens/useStakingTokenInformation.ts +2 -1
- package/src/hooks/tokens/useTokenCurrentPrice.ts +4 -2
- package/src/hooks/tokens/useTokenCurrentPrices.ts +92 -13
- package/src/hooks/tokens/useTokenInformation.ts +11 -6
- package/src/hooks/tokens/useTokenPrice.ts +21 -0
- package/src/hooks/tokens/useTokenPrices.ts +133 -0
- package/src/hooks/tokens/useTokens.ts +1 -0
- package/src/hooks/tokens/useUnderlyingAsset.ts +23 -0
- package/src/hooks/useContractWrite/useBeraContractWrite.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +1 -1
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
- package/src/hooks/validators/useManagedValidatorByAccount.ts +1 -1
- package/src/hooks/validators/useManagedValidatorRole.ts +1 -1
- package/src/hooks/validators/useOnChainValidator.ts +1 -1
- package/src/hooks/validators/useStakingPoolBatch.ts +1 -1
- package/src/hooks/validators/useUserActiveValidators.ts +1 -1
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
- package/src/hooks/validators/useUserClaimableIncentives.ts +8 -8
- package/src/hooks/validators/useValidator.ts +1 -1
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
- package/src/hooks/validators/useValidatorCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -1
- package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
- package/src/types/{dex.ts → dex.d.ts} +96 -67
- package/src/types/{enso.ts → enso.d.ts} +1 -1
- package/src/types/exports.ts +8 -0
- package/src/types/{global.ts → global.d.ts} +1 -30
- package/src/types/{governance.ts → governance.d.ts} +2 -64
- package/src/types/{honeySwap.ts → honeySwap.d.ts} +1 -13
- package/src/types/{pol.ts → pol.d.ts} +12 -1
- package/src/types/staking.d.ts +22 -0
- package/src/utils/createEmitter.ts +122 -0
- package/src/utils/createEmitter.unit.test.ts +149 -0
- package/src/utils/{index.ts → exports.ts} +3 -2
- package/src/utils/filter.ts +34 -0
- package/src/utils/formatNumber.ts +1 -1
- package/src/utils/formatNumber.unit.test.ts +2 -1
- package/src/utils/formatTokenList.ts +4 -10
- package/src/utils/getHoneySwapMessage.test.ts +1 -2
- package/src/utils/getServerSideClient.ts +4 -5
- package/src/utils/isDifferenceExceedingThreshold.ts +1 -1
- package/src/utils/layerZeroScan.ts +122 -0
- package/src/utils/math.ts +1 -1
- package/src/utils/parseWhiskToken.ts +15 -0
- package/src/utils/poolNamings.ts +1 -1
- package/src/utils/tokens.ts +23 -7
- package/dist/HoneyConfigProvider-6PXZJMSU.d.cts +0 -562
- package/dist/HoneyConfigProvider-CwDFrt02.d.ts +0 -562
- package/dist/abi/index.cjs +0 -2
- package/dist/abi/index.cjs.map +0 -1
- package/dist/abi/index.mjs +0 -2
- package/dist/actions/index.cjs +0 -2
- package/dist/actions/index.cjs.map +0 -1
- package/dist/actions/index.mjs +0 -2
- package/dist/aggregatorsRouter-Cny4B_MB.d.cts +0 -593
- package/dist/aggregatorsRouter-Cny4B_MB.d.ts +0 -593
- package/dist/chunk-22MQVFHP.cjs +0 -2
- package/dist/chunk-22MQVFHP.cjs.map +0 -1
- package/dist/chunk-3TKSVFZ3.mjs +0 -2
- package/dist/chunk-3TKSVFZ3.mjs.map +0 -1
- package/dist/chunk-6VF3RF53.cjs +0 -3
- package/dist/chunk-6VF3RF53.cjs.map +0 -1
- package/dist/chunk-6W22TFYA.mjs +0 -2
- package/dist/chunk-6W22TFYA.mjs.map +0 -1
- package/dist/chunk-AMRJ4B36.mjs +0 -2
- package/dist/chunk-AMRJ4B36.mjs.map +0 -1
- package/dist/chunk-DS2ZDVKU.mjs +0 -2
- package/dist/chunk-DS2ZDVKU.mjs.map +0 -1
- package/dist/chunk-ED43NYSE.cjs +0 -2
- package/dist/chunk-ED43NYSE.cjs.map +0 -1
- package/dist/chunk-EU4WFADK.cjs +0 -2
- package/dist/chunk-EU4WFADK.cjs.map +0 -1
- package/dist/chunk-HCTFDGXL.mjs +0 -2
- package/dist/chunk-HCTFDGXL.mjs.map +0 -1
- package/dist/chunk-IOSYBHKU.mjs +0 -2
- package/dist/chunk-IOSYBHKU.mjs.map +0 -1
- package/dist/chunk-JMKLDDKY.cjs +0 -2
- package/dist/chunk-JMKLDDKY.cjs.map +0 -1
- package/dist/chunk-KMKUXP2S.mjs +0 -3
- package/dist/chunk-KMKUXP2S.mjs.map +0 -1
- package/dist/chunk-OJXJ6CZ4.mjs +0 -4
- package/dist/chunk-OJXJ6CZ4.mjs.map +0 -1
- package/dist/chunk-PHIOKO3A.mjs +0 -2
- package/dist/chunk-PHIOKO3A.mjs.map +0 -1
- package/dist/chunk-QCK474XD.cjs +0 -2
- package/dist/chunk-QCK474XD.cjs.map +0 -1
- package/dist/chunk-REDXXUK7.cjs +0 -2
- package/dist/chunk-REDXXUK7.cjs.map +0 -1
- package/dist/chunk-S74ZMG2G.cjs +0 -2
- package/dist/chunk-S74ZMG2G.cjs.map +0 -1
- package/dist/chunk-TOAXF4YW.cjs +0 -2
- package/dist/chunk-TOAXF4YW.cjs.map +0 -1
- package/dist/chunk-UZ5CB33M.cjs +0 -2
- package/dist/chunk-UZ5CB33M.cjs.map +0 -1
- package/dist/chunk-VYWYJR63.mjs +0 -2
- package/dist/chunk-VYWYJR63.mjs.map +0 -1
- package/dist/chunk-XFPTQMAK.cjs +0 -4
- package/dist/chunk-XFPTQMAK.cjs.map +0 -1
- package/dist/chunk-YK4NINF5.mjs +0 -2
- package/dist/chunk-YK4NINF5.mjs.map +0 -1
- package/dist/contexts/index.cjs +0 -2
- package/dist/contexts/index.cjs.map +0 -1
- package/dist/contexts/index.mjs +0 -2
- package/dist/contexts/index.mjs.map +0 -1
- package/dist/enum/index.cjs +0 -2
- package/dist/enum/index.cjs.map +0 -1
- package/dist/enum/index.d.cts +0 -31
- package/dist/enum/index.d.ts +0 -31
- package/dist/enum/index.mjs +0 -2
- package/dist/enum/index.mjs.map +0 -1
- package/dist/errors/index.cjs +0 -2
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.d.cts +0 -204
- package/dist/errors/index.d.ts +0 -204
- package/dist/errors/index.mjs +0 -2
- package/dist/errors/index.mjs.map +0 -1
- package/dist/hooks/index.cjs +0 -4
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.mjs +0 -4
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/staking-F9Nx9TKD.d.ts +0 -246
- package/dist/staking-f4BpYH7l.d.cts +0 -246
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -56
- package/dist/types/index.d.ts +0 -56
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.mjs +0 -2
- package/dist/utils/index.mjs.map +0 -1
- package/src/actions/dex/getTransactionCount.ts +0 -29
- package/src/actions/enso/bend.ts +0 -143
- package/src/actions/enso/getEnsoUserToken.debug.test.ts +0 -57
- package/src/contexts/berajsProvider/context.tsx +0 -49
- package/src/contexts/berajsProvider/index.ts +0 -2
- package/src/contexts/berajsProvider/useBeraJs.ts +0 -18
- package/src/hooks/dex/usePollVaultIsPaused.ts +0 -30
- package/src/hooks/enso/useBendTransactionRequests.ts +0 -247
- package/src/hooks/enso/useEnsoZap.ts +0 -166
- package/src/hooks/enso/useZapTransactionRequests.ts +0 -81
- package/src/hooks/pol/useEarnedStakedBeraVault.ts +0 -59
- package/src/hooks/pol/useStakedBeraSnapshots.ts +0 -27
- package/src/hooks/transactions/TransactionStoreContext.tsx +0 -59
- package/src/hooks/transactions/transactionStore.ts +0 -275
- package/src/hooks/transactions/transactionStore.unit.test.ts +0 -508
- package/src/hooks/transactions/useAddRecentTransaction.ts +0 -29
- package/src/hooks/transactions/useRecentTransactions.ts +0 -27
- package/src/hooks/validators/validatorRoleManager.ts +0 -0
- package/src/types/index.ts +0 -8
- package/src/types/staking.ts +0 -7
- package/src/utils/formatAggregatorsQuotes.ts +0 -57
- package/src/utils/formatAggregatorsQuotes.unit.test.ts +0 -191
- package/src/utils/sentryBeforeSend.ts +0 -52
- /package/dist/{abi/index.mjs.map → errors/exports.mjs.map} +0 -0
- /package/dist/{actions/index.mjs.map → types/exports.mjs.map} +0 -0
- /package/src/actions/dex/{__tests__ → aggregators}/haiku.integration.test.ts +0 -0
- /package/src/types/{bribe-boost.ts → bribe-boost.d.ts} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { BundleAction } from "@ensofinance/sdk";
|
|
2
|
+
import { type Address, ethAddress, type Hex, zeroAddress } from "viem";
|
|
3
|
+
|
|
4
|
+
import { getEnsoClient } from "~/actions/clients/getEnsoClient";
|
|
5
|
+
import { Aggregators } from "~/enum/dex";
|
|
6
|
+
import { assertAddress } from "~/errors/assert";
|
|
7
|
+
import type { IAggregatorArgs, IRawAggregatorQuote } from "~/types/dex";
|
|
8
|
+
import { BaseAggregator } from "../base";
|
|
9
|
+
|
|
10
|
+
class EnsoErc4626Aggregator extends BaseAggregator {
|
|
11
|
+
name = Aggregators.EnsoErc4626;
|
|
12
|
+
supportedChains = null;
|
|
13
|
+
readonly type = "rest";
|
|
14
|
+
needsAccountForQuote = true;
|
|
15
|
+
|
|
16
|
+
notFoundMessages: string[] = [
|
|
17
|
+
"Could not build shortcuts for route",
|
|
18
|
+
"Could not quote shortcuts for route",
|
|
19
|
+
"Swap not found for a required underlying of defi route,",
|
|
20
|
+
"No route found from",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
async getQuote({
|
|
24
|
+
tokenIn,
|
|
25
|
+
tokenOut,
|
|
26
|
+
amount,
|
|
27
|
+
slippage,
|
|
28
|
+
account = zeroAddress,
|
|
29
|
+
aggregatorsFeeBps,
|
|
30
|
+
proxyAggregatorsThroughVercel = false,
|
|
31
|
+
rewardVault,
|
|
32
|
+
underlyingToken,
|
|
33
|
+
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
34
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
35
|
+
|
|
36
|
+
assertAddress(account, "account");
|
|
37
|
+
|
|
38
|
+
const ensoClient = getEnsoClient({
|
|
39
|
+
useProxy: !proxyAggregatorsThroughVercel,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (tokenIn.address === zeroAddress) tokenIn.address = ethAddress;
|
|
43
|
+
if (tokenOut.address === zeroAddress) tokenOut.address = ethAddress;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This is the token that will be swapped by enso, but might not be the same as the token out.
|
|
47
|
+
*
|
|
48
|
+
* If an underlying token is provided, we'll swap to that and then deposit it into the vault,
|
|
49
|
+
* assuming that token out is an ERC4626 vault.
|
|
50
|
+
*/
|
|
51
|
+
const zapTokenOut = underlyingToken ?? tokenOut;
|
|
52
|
+
|
|
53
|
+
const bundleActions: BundleAction[] = [
|
|
54
|
+
// this is the base route action, which will swap the token in to the zap token out
|
|
55
|
+
// it handles cross-chain swaps and refunds the user if the swap fails
|
|
56
|
+
// this might even be the only action if no underlying token or reward vault is provided
|
|
57
|
+
{
|
|
58
|
+
protocol: "enso",
|
|
59
|
+
action: "route",
|
|
60
|
+
args: {
|
|
61
|
+
tokenIn: tokenIn.address,
|
|
62
|
+
tokenOut: zapTokenOut.address,
|
|
63
|
+
destinationChainId:
|
|
64
|
+
// must be undefined if the token is the same chain
|
|
65
|
+
tokenIn.chainId === zapTokenOut.chainId
|
|
66
|
+
? undefined
|
|
67
|
+
: zapTokenOut.chainId,
|
|
68
|
+
refundReceiver: account,
|
|
69
|
+
amountIn: amount,
|
|
70
|
+
slippage: slippage * 100, // Enso expects slippage in basis points
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
if (underlyingToken) {
|
|
76
|
+
// deposit the underlying token into the vault
|
|
77
|
+
// this works both for Staked BERA/iBera and Bend Vaults
|
|
78
|
+
bundleActions.push({
|
|
79
|
+
protocol: "erc4626",
|
|
80
|
+
action: "deposit",
|
|
81
|
+
args: {
|
|
82
|
+
amountIn: { useOutputOfCallAt: 0 },
|
|
83
|
+
tokenIn: underlyingToken.address,
|
|
84
|
+
primaryAddress: tokenOut.address,
|
|
85
|
+
tokenOut: tokenOut.address,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (rewardVault) {
|
|
91
|
+
// if an address is provided, funds will be staked into the reward vault
|
|
92
|
+
|
|
93
|
+
// offset dynamically reads length of bundleActions array to get the output of the previous call
|
|
94
|
+
const offset = bundleActions.length;
|
|
95
|
+
bundleActions.push(
|
|
96
|
+
{
|
|
97
|
+
protocol: "enso",
|
|
98
|
+
action: "balance",
|
|
99
|
+
args: {
|
|
100
|
+
token: tokenOut.address,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
protocol: "erc20",
|
|
105
|
+
action: "approve",
|
|
106
|
+
args: {
|
|
107
|
+
amount: { useOutputOfCallAt: offset },
|
|
108
|
+
spender: rewardVault,
|
|
109
|
+
token: tokenOut.address,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
protocol: "enso",
|
|
114
|
+
action: "call",
|
|
115
|
+
args: {
|
|
116
|
+
address: rewardVault,
|
|
117
|
+
args: [account, { useOutputOfCallAt: offset }],
|
|
118
|
+
method: "stakeOnBehalf",
|
|
119
|
+
abi: "function stakeOnBehalf(address account, uint256 amount) external",
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
protocol: "enso",
|
|
124
|
+
action: "balance",
|
|
125
|
+
args: {
|
|
126
|
+
token: rewardVault,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const bundle = await ensoClient.getBundleData(
|
|
133
|
+
{
|
|
134
|
+
fromAddress: account,
|
|
135
|
+
receiver: account,
|
|
136
|
+
spender: account,
|
|
137
|
+
chainId: tokenIn.chainId,
|
|
138
|
+
routingStrategy: "router",
|
|
139
|
+
},
|
|
140
|
+
bundleActions,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const tokenOutAddress = (rewardVault?.toLowerCase() ??
|
|
144
|
+
tokenOut.address.toLowerCase()) as Address;
|
|
145
|
+
|
|
146
|
+
const amountOut =
|
|
147
|
+
// @ts-expect-error enso has not typed this but is returned sometimes from API.
|
|
148
|
+
bundle.minAmountsOut[tokenOutAddress] ??
|
|
149
|
+
bundle.amountsOut[tokenOutAddress] ??
|
|
150
|
+
"0";
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
amountOut,
|
|
154
|
+
amountIn: amount,
|
|
155
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
156
|
+
tokenIn,
|
|
157
|
+
rawAmount: amount,
|
|
158
|
+
spender: bundle.tx.to,
|
|
159
|
+
}),
|
|
160
|
+
name: this.name,
|
|
161
|
+
swapFeeBps: 0,
|
|
162
|
+
priceImpactPercentage: bundle.priceImpact
|
|
163
|
+
? bundle.priceImpact / 100
|
|
164
|
+
: null,
|
|
165
|
+
getCalldata: () => ({
|
|
166
|
+
address: bundle.tx.to,
|
|
167
|
+
data: bundle.tx.data as Hex,
|
|
168
|
+
value: BigInt(bundle.tx.value ?? 0),
|
|
169
|
+
// not returning gas limit because it's usually underestimated by enso.
|
|
170
|
+
// gasLimit: BigInt(bundle.gas),
|
|
171
|
+
}),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export const ensoErc4626 = new EnsoErc4626Aggregator();
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { erc4626Abi, formatUnits } from "viem";
|
|
2
|
+
|
|
3
|
+
import { stakeBeraVaultAbi } from "~/abi/pol/stakeBeraVault";
|
|
4
|
+
import { ContractName } from "~/enum/contracts";
|
|
5
|
+
import { Aggregators } from "~/enum/dex";
|
|
6
|
+
import { assertDefined, assertPublicClient } from "~/errors/assert";
|
|
7
|
+
import type { IAggregatorArgs, IRawAggregatorQuote, Token } from "~/types/dex";
|
|
8
|
+
import type { IContractWrite } from "~/types/global";
|
|
9
|
+
import { isToken } from "~/utils/tokens";
|
|
10
|
+
import { BaseAggregator } from "./base";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Aggregator that handles direct deposits into ERC4626 vault tokens.
|
|
14
|
+
* Instead of routing through a DEX, this deposits the underlying asset directly
|
|
15
|
+
* into the vault contract (e.g. WBERA → swBERA, HONEY → iBERA, or Bend vault underlying → vault token).
|
|
16
|
+
*
|
|
17
|
+
* Special-cases native BERA → swBERA via `depositNative` (no approval needed).
|
|
18
|
+
*/
|
|
19
|
+
class ERC4626Aggregator extends BaseAggregator {
|
|
20
|
+
name = Aggregators.ERC4626;
|
|
21
|
+
supportedChains = null;
|
|
22
|
+
readonly type = "rpc";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns true when tokenOut is an ERC4626 vault whose underlying asset matches tokenIn,
|
|
26
|
+
* or when depositing native BERA into swBERA.
|
|
27
|
+
*/
|
|
28
|
+
checkChainSupport({
|
|
29
|
+
tokenIn,
|
|
30
|
+
tokenOut,
|
|
31
|
+
underlyingToken,
|
|
32
|
+
}: {
|
|
33
|
+
tokenIn: Token;
|
|
34
|
+
tokenOut: Token;
|
|
35
|
+
underlyingToken?: Token;
|
|
36
|
+
}): boolean {
|
|
37
|
+
const result =
|
|
38
|
+
super.checkChainSupport({ tokenIn, tokenOut, underlyingToken }) &&
|
|
39
|
+
!!underlyingToken &&
|
|
40
|
+
underlyingToken?.chainId === tokenOut.chainId &&
|
|
41
|
+
(isToken(underlyingToken, tokenIn) ||
|
|
42
|
+
// this is a special case for the swbera vault
|
|
43
|
+
(isToken(tokenIn, "BERA") && isToken(tokenOut, "SWBERA")));
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Fetches a deposit quote by calling `convertToShares` on the vault.
|
|
50
|
+
* Returns calldata for either `deposit` (ERC20) or `depositNative` (BERA → swBERA).
|
|
51
|
+
*/
|
|
52
|
+
async getQuote({
|
|
53
|
+
tokenIn,
|
|
54
|
+
tokenOut,
|
|
55
|
+
amount,
|
|
56
|
+
underlyingToken,
|
|
57
|
+
publicClient,
|
|
58
|
+
}: Omit<
|
|
59
|
+
IAggregatorArgs,
|
|
60
|
+
"slippage" | "feeBps"
|
|
61
|
+
>): Promise<IRawAggregatorQuote> {
|
|
62
|
+
this.assertChainSupport({ tokenIn, tokenOut, underlyingToken });
|
|
63
|
+
|
|
64
|
+
assertDefined(underlyingToken, "underlyingToken");
|
|
65
|
+
assertPublicClient(publicClient);
|
|
66
|
+
|
|
67
|
+
const rawOutputAmount = await publicClient.readContract({
|
|
68
|
+
address: tokenOut.address,
|
|
69
|
+
abi: erc4626Abi,
|
|
70
|
+
functionName: "convertToShares",
|
|
71
|
+
args: [BigInt(amount)],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const isSwBeraNative =
|
|
75
|
+
isToken(tokenOut, "SWBERA") && isToken(tokenIn, "BERA");
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
amountOut: rawOutputAmount.toString(),
|
|
79
|
+
amountIn: amount,
|
|
80
|
+
allowanceRequirements: isSwBeraNative
|
|
81
|
+
? []
|
|
82
|
+
: [
|
|
83
|
+
{
|
|
84
|
+
token: tokenIn,
|
|
85
|
+
spender: tokenOut.address,
|
|
86
|
+
amount: {
|
|
87
|
+
raw: amount,
|
|
88
|
+
formatted: formatUnits(BigInt(amount), tokenIn.decimals),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
name: Aggregators.ERC4626,
|
|
93
|
+
isNativeSwap: false,
|
|
94
|
+
swapFeeBps: 0,
|
|
95
|
+
getCalldata: ({ account }) =>
|
|
96
|
+
isSwBeraNative
|
|
97
|
+
? ({
|
|
98
|
+
abi: stakeBeraVaultAbi,
|
|
99
|
+
address: tokenOut.address,
|
|
100
|
+
functionName: "depositNative",
|
|
101
|
+
params: [BigInt(amount), account],
|
|
102
|
+
value: BigInt(amount),
|
|
103
|
+
} satisfies Omit<
|
|
104
|
+
IContractWrite<typeof stakeBeraVaultAbi, "depositNative">,
|
|
105
|
+
"message" | "actionType"
|
|
106
|
+
>)
|
|
107
|
+
: ({
|
|
108
|
+
abi: erc4626Abi,
|
|
109
|
+
address: tokenOut.address,
|
|
110
|
+
functionName: "deposit",
|
|
111
|
+
contractName: ContractName.ERC4626,
|
|
112
|
+
params: [BigInt(amount), account],
|
|
113
|
+
value: 0n,
|
|
114
|
+
} satisfies Omit<
|
|
115
|
+
IContractWrite<typeof erc4626Abi, "deposit">,
|
|
116
|
+
"message" | "actionType"
|
|
117
|
+
>),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const erc4626Deposit = new ERC4626Aggregator();
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { zeroAddress } from "viem";
|
|
1
|
+
import { type Address, type Hex, zeroAddress } from "viem";
|
|
2
2
|
|
|
3
3
|
import { ChainId } from "@berachain/config/internal";
|
|
4
4
|
|
|
5
5
|
import { aggregatorsRouterAbi } from "~/abi/bex/aggregatorsRouter";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
type IAggregatorArgs,
|
|
9
|
-
type IRawAggregatorQuote,
|
|
10
|
-
} from "~/types";
|
|
6
|
+
import { Aggregators } from "~/enum/dex";
|
|
7
|
+
import type { IAggregatorArgs, IRawAggregatorQuote } from "~/types/dex";
|
|
11
8
|
import { isToken } from "~/utils/tokens";
|
|
12
9
|
import { BaseAggregator } from "./base";
|
|
13
10
|
|
|
14
|
-
const BASE_URL = "https://api.
|
|
11
|
+
const BASE_URL = "https://api.fly.trade/aggregator";
|
|
15
12
|
|
|
16
13
|
class FlyAggregator extends BaseAggregator {
|
|
17
14
|
name = Aggregators.Fly;
|
|
18
15
|
supportedChains = [ChainId.MAINNET];
|
|
19
16
|
readonly type = "rest";
|
|
17
|
+
|
|
20
18
|
notFoundMessages: string[] = [
|
|
21
19
|
"Couldn't recognize to token",
|
|
20
|
+
"Couldn't recognize from token",
|
|
22
21
|
"There is not enough liquidity. Amount is too high.",
|
|
23
22
|
"Routes were not found",
|
|
24
23
|
];
|
|
@@ -28,18 +27,18 @@ class FlyAggregator extends BaseAggregator {
|
|
|
28
27
|
tokenOut,
|
|
29
28
|
amount,
|
|
30
29
|
slippage,
|
|
31
|
-
account
|
|
30
|
+
account,
|
|
32
31
|
aggregatorsFeeBps,
|
|
33
32
|
rewardVault,
|
|
34
33
|
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
35
|
-
this.
|
|
34
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
36
35
|
|
|
37
36
|
const {
|
|
38
37
|
tokenInAddress,
|
|
39
38
|
tokenOutAddress,
|
|
40
39
|
isTokenInNative,
|
|
41
40
|
isTokenOutNative,
|
|
42
|
-
} = this.parseAddresses(tokenIn, tokenOut);
|
|
41
|
+
} = this.parseAddresses(tokenIn.address, tokenOut.address);
|
|
43
42
|
|
|
44
43
|
const inputAmountAfterFees = this.getAmountAfterFees(
|
|
45
44
|
amount,
|
|
@@ -57,12 +56,11 @@ class FlyAggregator extends BaseAggregator {
|
|
|
57
56
|
network: "berachain",
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
59
|
+
// fly will transfer funds from the executor and will send amountOut to the executor
|
|
60
|
+
// which in turn will send the funds to the account
|
|
61
|
+
params.set("fromAddress", this.config.bex.aggregatorsRouterExecutor);
|
|
62
|
+
params.set("toAddress", this.config.bex.aggregatorsRouterExecutor);
|
|
63
|
+
|
|
66
64
|
url.search = params.toString();
|
|
67
65
|
|
|
68
66
|
const response = await this.fetch(url);
|
|
@@ -72,62 +70,70 @@ class FlyAggregator extends BaseAggregator {
|
|
|
72
70
|
const formattedQuote = {
|
|
73
71
|
amountOut: quoteData.amountOut,
|
|
74
72
|
amountIn: amount,
|
|
75
|
-
|
|
73
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
74
|
+
tokenIn,
|
|
75
|
+
rawAmount: amount,
|
|
76
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
77
|
+
}),
|
|
76
78
|
name: this.name,
|
|
77
79
|
swapFeeBps: aggregatorsFeeBps ?? 0,
|
|
78
80
|
};
|
|
79
|
-
// if no account, return quote early
|
|
80
|
-
if (account === zeroAddress) return formattedQuote;
|
|
81
81
|
|
|
82
82
|
// fetch transaction data immediately to improve UX and prevent potential failures during swap execution
|
|
83
83
|
const txUrl = new URL(`${BASE_URL}/transaction`);
|
|
84
|
+
|
|
84
85
|
this.url = txUrl.toString();
|
|
85
86
|
|
|
86
87
|
const txParams = new URLSearchParams({
|
|
87
88
|
quoteId: quoteData.id,
|
|
88
89
|
estimateGas: "false",
|
|
89
90
|
});
|
|
91
|
+
|
|
90
92
|
txUrl.search = txParams.toString();
|
|
91
93
|
|
|
92
94
|
const txResponse = await this.fetch(txUrl);
|
|
93
95
|
|
|
94
|
-
const txData
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
amountIn: amount,
|
|
99
|
-
isNative: isTokenInNative,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const outputData = {
|
|
103
|
-
tokenOut: tokenOutAddress,
|
|
104
|
-
receiver: account,
|
|
105
|
-
minAmountOut: this.getMinAmountOut(quoteData.amountOut, slippage),
|
|
106
|
-
isNative: isTokenOutNative,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const aggregatorData = {
|
|
110
|
-
aggregator: txData.to,
|
|
111
|
-
data: txData.data,
|
|
112
|
-
};
|
|
96
|
+
const txData: {
|
|
97
|
+
to: Address;
|
|
98
|
+
data: Hex;
|
|
99
|
+
} = await txResponse.json();
|
|
113
100
|
|
|
114
101
|
return {
|
|
115
102
|
...formattedQuote,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
103
|
+
getCalldata: ({ account }) => {
|
|
104
|
+
const inputData = this.getInputData({
|
|
105
|
+
tokenIn: tokenInAddress,
|
|
106
|
+
amountIn: amount,
|
|
107
|
+
isNative: isTokenInNative,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const outputData = {
|
|
111
|
+
tokenOut: tokenOutAddress,
|
|
112
|
+
receiver: account,
|
|
113
|
+
minAmountOut: this.getMinAmountOut(quoteData.amountOut, slippage),
|
|
114
|
+
isNative: isTokenOutNative,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const aggregatorData = {
|
|
118
|
+
aggregator: txData?.to,
|
|
119
|
+
data: txData?.data,
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
params: [
|
|
123
|
+
inputData,
|
|
124
|
+
outputData,
|
|
125
|
+
aggregatorData,
|
|
126
|
+
{
|
|
127
|
+
rewardVault: rewardVault ?? zeroAddress,
|
|
128
|
+
isSwapAndStake: !!rewardVault,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
functionName: "swap",
|
|
132
|
+
abi: aggregatorsRouterAbi,
|
|
133
|
+
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
134
|
+
value: isToken(tokenIn, "BERA") ? BigInt(amount) : BigInt("0"),
|
|
135
|
+
address: this.config.bex.aggregatorsRouter,
|
|
136
|
+
};
|
|
131
137
|
},
|
|
132
138
|
};
|
|
133
139
|
}
|
|
@@ -2,14 +2,10 @@ import { formatUnits, parseUnits, zeroAddress } from "viem";
|
|
|
2
2
|
|
|
3
3
|
import { ChainId } from "@berachain/config/internal";
|
|
4
4
|
|
|
5
|
-
import { aggregatorsRouterAbi } from "~/abi";
|
|
5
|
+
import { aggregatorsRouterAbi } from "~/abi/bex/aggregatorsRouter";
|
|
6
|
+
import { Aggregators, SwapReferrer } from "~/enum/dex";
|
|
6
7
|
import { BeraError } from "~/errors/BeraError";
|
|
7
|
-
import {
|
|
8
|
-
Aggregators,
|
|
9
|
-
type IAggregatorArgs,
|
|
10
|
-
type IRawAggregatorQuote,
|
|
11
|
-
} from "~/types";
|
|
12
|
-
import { SwapReferrer } from "~/types/dex";
|
|
8
|
+
import type { IAggregatorArgs, IRawAggregatorQuote } from "~/types/dex";
|
|
13
9
|
import { BaseAggregator } from "./base";
|
|
14
10
|
|
|
15
11
|
class HaikuAggregator extends BaseAggregator {
|
|
@@ -28,28 +24,25 @@ class HaikuAggregator extends BaseAggregator {
|
|
|
28
24
|
tokenOut,
|
|
29
25
|
amount,
|
|
30
26
|
slippage,
|
|
31
|
-
account = zeroAddress,
|
|
32
|
-
tokenInDecimals,
|
|
33
|
-
tokenOutDecimals,
|
|
34
27
|
aggregatorsFeeBps,
|
|
35
28
|
proxyAggregatorsThroughVercel = false,
|
|
36
29
|
referrer,
|
|
37
30
|
rewardVault,
|
|
38
31
|
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
39
|
-
if (
|
|
32
|
+
if (tokenIn.decimals === undefined || tokenOut.decimals === undefined) {
|
|
40
33
|
throw new BeraError({
|
|
41
34
|
message: "Missing required params",
|
|
42
35
|
level: "error",
|
|
43
36
|
});
|
|
44
37
|
}
|
|
45
38
|
|
|
46
|
-
this.
|
|
39
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
47
40
|
const {
|
|
48
41
|
tokenInAddress,
|
|
49
42
|
tokenOutAddress,
|
|
50
43
|
isTokenInNative,
|
|
51
44
|
isTokenOutNative,
|
|
52
|
-
} = this.parseAddresses(tokenIn, tokenOut);
|
|
45
|
+
} = this.parseAddresses(tokenIn.address, tokenOut.address);
|
|
53
46
|
|
|
54
47
|
const inputAmountAfterFees = this.getAmountAfterFees(
|
|
55
48
|
amount,
|
|
@@ -65,7 +58,7 @@ class HaikuAggregator extends BaseAggregator {
|
|
|
65
58
|
input_positions: {
|
|
66
59
|
[`bera:${tokenInAddress}`]: formatUnits(
|
|
67
60
|
BigInt(inputAmountAfterFees),
|
|
68
|
-
|
|
61
|
+
tokenIn.decimals,
|
|
69
62
|
),
|
|
70
63
|
},
|
|
71
64
|
target_weights: {
|
|
@@ -99,17 +92,18 @@ class HaikuAggregator extends BaseAggregator {
|
|
|
99
92
|
const formattedQuote = {
|
|
100
93
|
amountOut: parseUnits(
|
|
101
94
|
quoteData.balances[0].amount,
|
|
102
|
-
|
|
95
|
+
tokenOut.decimals,
|
|
103
96
|
).toString(),
|
|
104
97
|
amountIn: amount,
|
|
105
|
-
|
|
98
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
99
|
+
tokenIn,
|
|
100
|
+
rawAmount: amount,
|
|
101
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
102
|
+
}),
|
|
106
103
|
name: this.name,
|
|
107
104
|
swapFeeBps: aggregatorsFeeBps!,
|
|
108
105
|
};
|
|
109
106
|
|
|
110
|
-
// If no account, return quote early
|
|
111
|
-
if (account === zeroAddress) return formattedQuote;
|
|
112
|
-
|
|
113
107
|
this.url = proxyAggregatorsThroughVercel
|
|
114
108
|
? `/api/aggregators?aggregator=haikuSolve`
|
|
115
109
|
: `${this.config.bex.aggregatorsProxyUrl}/${proxyPath}/v1/solveIntent`;
|
|
@@ -126,43 +120,47 @@ class HaikuAggregator extends BaseAggregator {
|
|
|
126
120
|
|
|
127
121
|
const solveData = await solveResponse.json();
|
|
128
122
|
|
|
129
|
-
const inputData = this.getInputData({
|
|
130
|
-
tokenIn: tokenInAddress,
|
|
131
|
-
amountIn: amount,
|
|
132
|
-
isNative: isTokenInNative,
|
|
133
|
-
isPermit2Approval: true, // haiku requires permit2 approval
|
|
134
|
-
permit2SpenderAddress: this.config.bex.haikuAgentAddress,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const outputData = {
|
|
138
|
-
tokenOut: tokenOutAddress,
|
|
139
|
-
receiver: account,
|
|
140
|
-
minAmountOut: this.getMinAmountOut(formattedQuote.amountOut, slippage),
|
|
141
|
-
isNative: isTokenOutNative,
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const aggregatorData = {
|
|
145
|
-
aggregator: solveData.to,
|
|
146
|
-
data: solveData.data,
|
|
147
|
-
};
|
|
148
|
-
|
|
149
123
|
return {
|
|
150
124
|
...formattedQuote,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
125
|
+
getCalldata: ({ account }) => {
|
|
126
|
+
const inputData = this.getInputData({
|
|
127
|
+
tokenIn: tokenInAddress,
|
|
128
|
+
amountIn: amount,
|
|
129
|
+
isNative: isTokenInNative,
|
|
130
|
+
isPermit2Approval: true, // haiku requires permit2 approval
|
|
131
|
+
permit2SpenderAddress: this.config.bex.haikuAgentAddress,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const outputData = {
|
|
135
|
+
tokenOut: tokenOutAddress,
|
|
136
|
+
receiver: account,
|
|
137
|
+
minAmountOut: this.getMinAmountOut(
|
|
138
|
+
formattedQuote.amountOut,
|
|
139
|
+
slippage,
|
|
140
|
+
),
|
|
141
|
+
isNative: isTokenOutNative,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const aggregatorData = {
|
|
145
|
+
aggregator: solveData.to,
|
|
146
|
+
data: solveData.data,
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
params: [
|
|
150
|
+
inputData,
|
|
151
|
+
outputData,
|
|
152
|
+
aggregatorData,
|
|
153
|
+
{
|
|
154
|
+
rewardVault: rewardVault ?? zeroAddress,
|
|
155
|
+
isSwapAndStake: !!rewardVault,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
functionName: "swap",
|
|
159
|
+
abi: aggregatorsRouterAbi,
|
|
160
|
+
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
161
|
+
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
162
|
+
address: this.config.bex.aggregatorsRouter,
|
|
163
|
+
};
|
|
166
164
|
},
|
|
167
165
|
};
|
|
168
166
|
}
|