@berachain/berajs 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BeraError-D1HS_rbb.d.cts → BeraError-_mQdkanr.d.cts} +35 -10
- package/dist/{BeraError-D1HS_rbb.d.ts → BeraError-_mQdkanr.d.ts} +35 -10
- package/dist/HoneyConfigProvider-CK6mOKFH.d.ts +390 -0
- package/dist/HoneyConfigProvider-Ca3ouozs.d.cts +390 -0
- package/dist/{RequestError-D8AE6xnI.d.cts → RequestError-A8XJ6QR9.d.cts} +1 -1
- package/dist/{RequestError-m4jxyM7D.d.ts → RequestError-Dk97z8rm.d.ts} +1 -1
- package/dist/abi/exports.cjs +2 -0
- package/dist/abi/exports.cjs.map +1 -0
- package/dist/abi/{index.d.cts → exports.d.cts} +12369 -9122
- package/dist/abi/{index.d.ts → exports.d.ts} +12369 -9122
- package/dist/abi/exports.mjs +2 -0
- package/dist/abi/exports.mjs.map +1 -0
- package/dist/actions/exports.cjs +2 -0
- package/dist/actions/exports.cjs.map +1 -0
- package/dist/actions/{index.d.cts → exports.d.cts} +79 -107
- package/dist/actions/{index.d.ts → exports.d.ts} +79 -107
- package/dist/actions/exports.mjs +2 -0
- package/dist/actions/exports.mjs.map +1 -0
- package/dist/chunk-22J3YJDN.cjs +2 -0
- package/dist/chunk-22J3YJDN.cjs.map +1 -0
- package/dist/chunk-2LL3P5PN.mjs +2 -0
- package/dist/chunk-2LL3P5PN.mjs.map +1 -0
- package/dist/chunk-3YXSUBA5.mjs +2 -0
- package/dist/chunk-3YXSUBA5.mjs.map +1 -0
- package/dist/chunk-55L7STYD.mjs +2 -0
- package/dist/chunk-55L7STYD.mjs.map +1 -0
- package/dist/chunk-575OK77P.mjs +2 -0
- package/dist/chunk-575OK77P.mjs.map +1 -0
- package/dist/chunk-6LDOG5RL.cjs +2 -0
- package/dist/chunk-6LDOG5RL.cjs.map +1 -0
- package/dist/chunk-7LNBSOVV.cjs +2 -0
- package/dist/chunk-7LNBSOVV.cjs.map +1 -0
- package/dist/chunk-7SMWQ6SN.mjs +2 -0
- package/dist/chunk-7SMWQ6SN.mjs.map +1 -0
- package/dist/chunk-7WRTK7RJ.mjs +2 -0
- package/dist/chunk-7WRTK7RJ.mjs.map +1 -0
- package/dist/chunk-A4UDYSB6.mjs +4 -0
- package/dist/chunk-A4UDYSB6.mjs.map +1 -0
- package/dist/chunk-AX2YQQFQ.mjs +2 -0
- package/dist/chunk-AX2YQQFQ.mjs.map +1 -0
- package/dist/chunk-C3FHGFLK.mjs +2 -0
- package/dist/chunk-C3FHGFLK.mjs.map +1 -0
- package/dist/chunk-C6ZGUO4H.cjs +2 -0
- package/dist/chunk-C6ZGUO4H.cjs.map +1 -0
- package/dist/chunk-CYKCYPFR.cjs +2 -0
- package/dist/chunk-CYKCYPFR.cjs.map +1 -0
- package/dist/chunk-ECRMUMTA.mjs +2 -0
- package/dist/chunk-ECRMUMTA.mjs.map +1 -0
- package/dist/chunk-F4BKSBEM.mjs +2 -0
- package/dist/chunk-F4BKSBEM.mjs.map +1 -0
- package/dist/chunk-FCWDGE62.cjs +2 -0
- package/dist/chunk-FCWDGE62.cjs.map +1 -0
- package/dist/chunk-FL2N3XHK.cjs +2 -0
- package/dist/chunk-FL2N3XHK.cjs.map +1 -0
- package/dist/chunk-MUCEYO3E.cjs +4 -0
- package/dist/chunk-MUCEYO3E.cjs.map +1 -0
- package/dist/chunk-NAXAZJJY.mjs +2 -0
- package/dist/chunk-NAXAZJJY.mjs.map +1 -0
- package/dist/chunk-OGJMSGB2.mjs +2 -0
- package/dist/chunk-OGJMSGB2.mjs.map +1 -0
- package/dist/chunk-OIYXOKTT.cjs +2 -0
- package/dist/chunk-OIYXOKTT.cjs.map +1 -0
- package/dist/chunk-P2Q7CMUD.cjs +2 -0
- package/dist/chunk-P2Q7CMUD.cjs.map +1 -0
- package/dist/chunk-PKXAW6MO.cjs +2 -0
- package/dist/chunk-PKXAW6MO.cjs.map +1 -0
- package/dist/chunk-Q3SCM6WL.mjs +2 -0
- package/dist/chunk-Q3SCM6WL.mjs.map +1 -0
- package/dist/chunk-SWMJQOH6.cjs +2 -0
- package/dist/chunk-SWMJQOH6.cjs.map +1 -0
- package/dist/chunk-TEBJWAVU.mjs +2 -0
- package/dist/chunk-TEBJWAVU.mjs.map +1 -0
- package/dist/chunk-THATXCJK.mjs +2 -0
- package/dist/chunk-THATXCJK.mjs.map +1 -0
- package/dist/chunk-VP7XUOSI.cjs +2 -0
- package/dist/chunk-VP7XUOSI.cjs.map +1 -0
- package/dist/chunk-VXL2ZZ4X.cjs +2 -0
- package/dist/chunk-VXL2ZZ4X.cjs.map +1 -0
- package/dist/chunk-WRFDB3QJ.cjs +2 -0
- package/dist/chunk-WRFDB3QJ.cjs.map +1 -0
- package/dist/chunk-XNJLSA6P.cjs +2 -0
- package/dist/chunk-XNJLSA6P.cjs.map +1 -0
- package/dist/chunk-YXLFOEZN.mjs +2 -0
- package/dist/chunk-YXLFOEZN.mjs.map +1 -0
- package/dist/chunk-YZV5LKIP.cjs +2 -0
- package/dist/chunk-YZV5LKIP.cjs.map +1 -0
- package/dist/contexts/exports.cjs +2 -0
- package/dist/contexts/exports.cjs.map +1 -0
- package/dist/contexts/{index.d.cts → exports.d.cts} +10 -27
- package/dist/contexts/{index.d.ts → exports.d.ts} +10 -27
- package/dist/contexts/exports.mjs +2 -0
- package/dist/contexts/exports.mjs.map +1 -0
- package/dist/{defaultFlags-V-tJs2K8.d.cts → defaultFlags-d0kPbT0i.d.cts} +1 -1
- package/dist/{defaultFlags-V-tJs2K8.d.ts → defaultFlags-d0kPbT0i.d.ts} +1 -1
- package/dist/dex-C_BB0b0O.d.cts +37 -0
- package/dist/dex-C_BB0b0O.d.ts +37 -0
- package/dist/enum/exports.cjs +2 -0
- package/dist/enum/exports.cjs.map +1 -0
- package/dist/enum/exports.d.cts +23 -0
- package/dist/enum/exports.d.ts +23 -0
- package/dist/enum/exports.mjs +2 -0
- package/dist/enum/exports.mjs.map +1 -0
- package/dist/errors/exports.cjs +2 -0
- package/dist/errors/exports.cjs.map +1 -0
- package/dist/errors/exports.d.cts +408 -0
- package/dist/errors/exports.d.ts +408 -0
- package/dist/errors/exports.mjs +2 -0
- package/dist/{getValidatorQueuedOperatorAddress-Ne2zoiiV.d.ts → getValidatorQueuedOperatorAddress-Dstyaomr.d.cts} +125 -15
- package/dist/{getValidatorQueuedOperatorAddress-9xY2RUGe.d.cts → getValidatorQueuedOperatorAddress-RW4OMcD1.d.ts} +125 -15
- package/dist/global.d-CN6l2b9E.d.cts +473 -0
- package/dist/global.d-wYu8G8IQ.d.ts +473 -0
- package/dist/honey-CYm0RWf4.d.cts +14 -0
- package/dist/honey-CYm0RWf4.d.ts +14 -0
- package/dist/hooks/exports.cjs +4 -0
- package/dist/hooks/exports.cjs.map +1 -0
- package/dist/hooks/{index.d.cts → exports.d.cts} +218 -176
- package/dist/hooks/{index.d.ts → exports.d.ts} +218 -176
- package/dist/hooks/exports.mjs +4 -0
- package/dist/hooks/exports.mjs.map +1 -0
- package/dist/{txnEnum-BQKDfaeH.d.cts → txnEnum-BlBYhNRl.d.cts} +75 -1
- package/dist/{txnEnum-BQKDfaeH.d.ts → txnEnum-BlBYhNRl.d.ts} +75 -1
- package/dist/types/exports.cjs +1 -0
- package/dist/types/exports.cjs.map +1 -0
- package/dist/types/exports.d.cts +57 -0
- package/dist/types/exports.d.ts +57 -0
- package/dist/types/exports.mjs +1 -0
- package/dist/{useHoneySwapState-C-9BV4VB.d.cts → useHoneySwapState-B-vmIP1b.d.cts} +1 -1
- package/dist/{useHoneySwapState-CUY5Sm1b.d.ts → useHoneySwapState-D1DKG_Of.d.ts} +1 -1
- package/dist/utils/exports.cjs +2 -0
- package/dist/utils/exports.cjs.map +1 -0
- package/dist/utils/{index.d.cts → exports.d.cts} +83 -20
- package/dist/utils/{index.d.ts → exports.d.ts} +83 -20
- package/dist/utils/exports.mjs +2 -0
- package/dist/utils/exports.mjs.map +1 -0
- package/package.json +19 -20
- package/src/abi/{index.ts → exports.ts} +3 -0
- package/src/abi/pol/LSTStakerVault.ts +2032 -0
- package/src/abi/utils/openChainErrors.ts +71 -30
- package/src/abi/utils/thirdwebMinimalAccount.ts +616 -0
- package/src/actions/clients/BeraApolloClient.ts +8 -6
- package/src/actions/dex/__tests__/aggregators.unit.test.ts +2 -5
- package/src/actions/dex/aggregators/base.ts +74 -16
- package/src/actions/dex/aggregators/bex.ts +54 -74
- package/src/actions/dex/aggregators/bgt.ts +31 -8
- package/src/actions/dex/aggregators/{enso.ts → enso/enso.ts} +18 -14
- package/src/actions/dex/aggregators/enso/ensoErc4626.debug.test.ts +37 -0
- package/src/actions/dex/aggregators/enso/ensoErc4626.ts +176 -0
- package/src/actions/dex/aggregators/erc4626.ts +122 -0
- package/src/actions/dex/aggregators/fly.ts +59 -53
- package/src/actions/dex/aggregators/haiku.ts +52 -54
- package/src/actions/dex/aggregators/honey.ts +54 -45
- package/src/actions/dex/aggregators/kyberswap.ts +41 -39
- package/src/actions/dex/aggregators/oogabooga.ts +47 -46
- package/src/actions/dex/aggregators/openOcean.ts +51 -46
- package/src/actions/dex/aggregators/wbera.ts +54 -42
- package/src/actions/dex/b-sdk.ts +5 -2
- package/src/actions/dex/getIsTokenExploited.ts +2 -2
- package/src/actions/enso/{zap.ts → getEnsoSwapBundle.ts} +4 -5
- package/src/actions/enso/getEnsoUserTokensWithBalances.debug.test.ts +73 -0
- package/src/actions/enso/{getEnsoUserToken.ts → getEnsoUserTokensWithBalances.ts} +42 -30
- package/src/actions/enso/util.ts +1 -1
- package/src/actions/{index.ts → exports.ts} +5 -0
- package/src/actions/governance/__tests__/checkProposalField.unit.test.ts +1 -1
- package/src/actions/governance/__tests__/getQuorum.integration.test.ts +1 -1
- package/src/actions/governance/checkProposalField.ts +1 -1
- package/src/actions/governance/computeActualStatus.ts +1 -1
- package/src/actions/governance/getBodyErrors.ts +1 -1
- package/src/actions/governance/getDecodedFunctionData.ts +1 -4
- package/src/actions/governance/getProposalDetails.ts +2 -2
- package/src/actions/governance/getProposalFromTx.ts +1 -2
- package/src/actions/governance/getProposalParams.ts +7 -8
- package/src/actions/governance/getQuorum.ts +1 -2
- package/src/actions/honey/getCollateralWeights.ts +1 -1
- package/src/actions/honey/getHoneyCollaterals.ts +1 -0
- package/src/actions/honey/getHoneyVaultsBalance.ts +51 -55
- package/src/actions/honey/getSwapPayload.ts +37 -35
- package/src/actions/honey/tests/pyth.integration.test.ts +0 -1
- package/src/actions/pol/__tests__/getAllValidators.integration.test.ts +1 -1
- package/src/actions/pol/getEarnedStakedBeraVault.ts +31 -0
- package/src/actions/pol/getGlobalData.ts +14 -13
- package/src/actions/pol/getLSTStakeConfig.ts +67 -0
- package/src/actions/pol/getMarkets.ts +1 -1
- package/src/actions/pol/getRewardProofsByValidator.ts +1 -1
- package/src/actions/pol/getRewardVaultIncentives.ts +3 -5
- package/src/actions/pol/getRewardVaults.ts +2 -3
- package/src/actions/pol/getSWBeraVaultMetadata.ts +7 -5
- package/src/actions/pol/getSWBeraWithdrawal.ts +41 -27
- package/src/actions/pol/getStakeWithdrawalCooldown.ts +5 -7
- package/src/actions/pol/getStakingDailyAssets.ts +24 -0
- package/src/actions/pol/getStakingTokenInformation.ts +3 -4
- package/src/actions/pol/getTotalStakedAmount.ts +47 -0
- package/src/actions/pol/getUserClaimableIncentives.ts +1 -1
- package/src/actions/pol/getUserVaults.ts +8 -6
- package/src/actions/pol/getUserVaultsBalance.ts +4 -16
- package/src/actions/prices/getTokenCurrentPrices.ts +8 -3
- package/src/actions/tokens/getAllowances.ts +68 -41
- package/src/actions/tokens/getTokenInformation.ts +4 -1
- package/src/actions/tokens/getTokens.ts +1 -1
- package/src/actions/tokens/getUnderlyingToken.ts +53 -0
- package/src/actions/tokens/getWalletBalances.integration.test.ts +53 -14
- package/src/actions/tokens/getWalletBalances.ts +69 -43
- package/src/actions/transactions/beraWriteContract.integration.test.ts +18 -6
- package/src/actions/transactions/beraWriteContract.ts +3 -3
- package/src/actions/validators/getUserActiveValidators.ts +2 -3
- package/src/actions/validators/getUserBoostsOnValidator.ts +2 -3
- package/src/contexts/BeraFlags/defaultFlags.ts +4 -0
- package/src/contexts/SwrFallback.tsx +13 -3
- package/src/contexts/TokensProvider.tsx +35 -8
- package/src/contexts/block-time-provider.tsx +1 -1
- package/src/contexts/{index.ts → exports.ts} +0 -1
- package/src/data/contracts.ts +17 -2
- package/src/enum/contracts.ts +13 -0
- package/src/enum/dex.ts +29 -0
- package/src/enum/{index.ts → exports.ts} +3 -0
- package/src/enum/governance.ts +61 -0
- package/src/enum/honey.ts +12 -0
- package/src/enum/txnEnum.ts +1 -0
- package/src/errors/BeraError.ts +61 -13
- package/src/errors/BeraMonitoring.ts +66 -0
- package/src/errors/BeraTracing.ts +79 -0
- package/src/errors/BeraTracing.unit.test.ts +198 -0
- package/src/errors/RequestError.ts +29 -3
- package/src/errors/assert.ts +4 -2
- package/src/errors/assert.unit.test.ts +6 -2
- package/src/errors/errorMap.ts +19 -8
- package/src/errors/{index.ts → exports.ts} +7 -0
- package/src/errors/getErrorMessage.ts +67 -9
- package/src/errors/getRevertReason.integration.test.ts +18 -6
- package/src/errors/getRevertReason.ts +41 -2
- package/src/errors/initBeraError.ts +52 -7
- package/src/errors/parseViemError.ts +114 -27
- package/src/errors/severity.ts +12 -0
- package/src/hooks/bend/useGetConvertToAssets.ts +3 -2
- package/src/hooks/dex/useAggregatorsQuotes.ts +126 -365
- package/src/hooks/dex/useAllUserPools.ts +1 -1
- package/src/hooks/dex/useApiPool.ts +1 -1
- package/src/hooks/dex/useCreatePool.ts +6 -5
- package/src/hooks/dex/useExploitedTokens.ts +1 -1
- package/src/hooks/dex/useLiquidityMismatch.ts +2 -5
- package/src/hooks/dex/useLpPosition.ts +21 -20
- package/src/hooks/dex/useMultipleTokenApprovalsWithSlippage.ts +40 -29
- package/src/hooks/dex/usePollPoolCreationRelayerApproval.ts +1 -1
- package/src/hooks/dex/usePoolEvents.ts +1 -1
- package/src/hooks/dex/usePools.ts +1 -1
- package/src/hooks/dex/usePriceImpact.ts +40 -0
- package/src/hooks/dex/useSingleAggregatorQuote.ts +350 -0
- package/src/hooks/enso/useBendZapSupply.ts +216 -0
- package/src/hooks/enso/useEnsoSwapBundle.ts +107 -0
- package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +43 -0
- package/src/hooks/enso/useZapStakeBera.ts +113 -0
- package/src/hooks/{index.ts → exports.ts} +17 -10
- package/src/hooks/governance/useCreateProposal.ts +8 -8
- package/src/hooks/governance/usePollAllProposals.ts +1 -1
- package/src/hooks/governance/usePollProposal.ts +1 -1
- package/src/hooks/governance/usePollProposalThreshold.ts +1 -1
- package/src/hooks/governance/usePollUserDelegates.ts +1 -1
- package/src/hooks/governance/useProposalState.ts +2 -2
- package/src/hooks/honey/useCappedGlobally.ts +2 -1
- package/src/hooks/honey/useCappedRelatively.ts +1 -1
- package/src/hooks/honey/useCollateralWeights.ts +2 -1
- package/src/hooks/honey/useHoneyAlerts.ts +11 -11
- package/src/hooks/honey/useHoneyBalances.ts +7 -3
- package/src/hooks/honey/useHoneyGlobalData.ts +2 -1
- package/src/hooks/honey/useHoneySwapState.ts +2 -1
- package/src/hooks/honey/useHoneyVaultsBalance.ts +1 -1
- package/src/hooks/honey/useIsBadCollateralAsset.ts +2 -1
- package/src/hooks/honey/useIsBasketModeEnabled.ts +1 -1
- package/src/hooks/honey/usePythLatestPrices.ts +1 -1
- package/src/hooks/pol/useOnChainRewardVault.ts +3 -2
- package/src/hooks/pol/usePollGlobalData.ts +1 -1
- package/src/hooks/pol/usePollMarkets.ts +1 -1
- package/src/hooks/pol/useQueuedBeraUnlock.ts +17 -15
- package/src/hooks/pol/useRewardTokenToBeraRate.ts +6 -3
- package/src/hooks/pol/useRewardVault.ts +1 -1
- package/src/hooks/pol/useRewardVaults.ts +1 -1
- package/src/hooks/pol/useSWBeraVaultMetadata.ts +35 -0
- package/src/hooks/pol/useStakedAPR.ts +38 -0
- package/src/hooks/pol/useStakedData.ts +117 -0
- package/src/hooks/pol/useStakedSnapshots.ts +52 -0
- package/src/hooks/pol/useTotalStakedAmount.ts +30 -0
- package/src/hooks/pol/useUserVaultInfo.ts +1 -1
- package/src/hooks/pol/useVaultValidators.ts +1 -1
- package/src/hooks/tokens/useMultipleTokenInformation.ts +15 -6
- package/src/hooks/tokens/usePollAllowances.ts +15 -19
- package/src/hooks/tokens/usePollBalance.ts +8 -4
- package/src/hooks/tokens/usePollWalletBalances.ts +14 -11
- package/src/hooks/tokens/useStakingTokenInformation.ts +2 -1
- package/src/hooks/tokens/useTokenCurrentPrice.ts +4 -2
- package/src/hooks/tokens/useTokenCurrentPrices.ts +92 -13
- package/src/hooks/tokens/useTokenInformation.ts +11 -6
- package/src/hooks/tokens/useTokenPrice.ts +21 -0
- package/src/hooks/tokens/useTokenPrices.ts +133 -0
- package/src/hooks/tokens/useTokens.ts +1 -0
- package/src/hooks/tokens/useUnderlyingAsset.ts +23 -0
- package/src/hooks/useContractWrite/useBeraContractWrite.ts +2 -1
- package/src/hooks/validators/useAllValidators.ts +1 -1
- package/src/hooks/validators/useApiValidator.ts +1 -1
- package/src/hooks/validators/useDailyValidatorBlockStats.ts +1 -1
- package/src/hooks/validators/useManagedValidatorByAccount.ts +1 -1
- package/src/hooks/validators/useManagedValidatorRole.ts +1 -1
- package/src/hooks/validators/useOnChainValidator.ts +1 -1
- package/src/hooks/validators/useStakingPoolBatch.ts +1 -1
- package/src/hooks/validators/useUserActiveValidators.ts +1 -1
- package/src/hooks/validators/useUserBoostsOnValidator.ts +1 -1
- package/src/hooks/validators/useUserClaimableIncentives.ts +8 -8
- package/src/hooks/validators/useValidator.ts +1 -1
- package/src/hooks/validators/useValidatorAnalytics.ts +1 -1
- package/src/hooks/validators/useValidatorCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedCommission.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedOperatorAddress.ts +1 -1
- package/src/hooks/validators/useValidatorQueuedRewardAllocation.ts +1 -1
- package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
- package/src/types/{dex.ts → dex.d.ts} +96 -67
- package/src/types/{enso.ts → enso.d.ts} +1 -1
- package/src/types/exports.ts +8 -0
- package/src/types/{global.ts → global.d.ts} +1 -30
- package/src/types/{governance.ts → governance.d.ts} +2 -64
- package/src/types/{honeySwap.ts → honeySwap.d.ts} +1 -13
- package/src/types/{pol.ts → pol.d.ts} +12 -1
- package/src/types/staking.d.ts +22 -0
- package/src/utils/createEmitter.ts +122 -0
- package/src/utils/createEmitter.unit.test.ts +149 -0
- package/src/utils/{index.ts → exports.ts} +3 -2
- package/src/utils/filter.ts +34 -0
- package/src/utils/formatNumber.ts +1 -1
- package/src/utils/formatNumber.unit.test.ts +2 -1
- package/src/utils/formatTokenList.ts +4 -10
- package/src/utils/getHoneySwapMessage.test.ts +1 -2
- package/src/utils/getServerSideClient.ts +4 -5
- package/src/utils/isDifferenceExceedingThreshold.ts +1 -1
- package/src/utils/layerZeroScan.ts +122 -0
- package/src/utils/math.ts +1 -1
- package/src/utils/parseWhiskToken.ts +15 -0
- package/src/utils/poolNamings.ts +1 -1
- package/src/utils/tokens.ts +23 -7
- package/dist/HoneyConfigProvider-6PXZJMSU.d.cts +0 -562
- package/dist/HoneyConfigProvider-CwDFrt02.d.ts +0 -562
- package/dist/abi/index.cjs +0 -2
- package/dist/abi/index.cjs.map +0 -1
- package/dist/abi/index.mjs +0 -2
- package/dist/actions/index.cjs +0 -2
- package/dist/actions/index.cjs.map +0 -1
- package/dist/actions/index.mjs +0 -2
- package/dist/aggregatorsRouter-Cny4B_MB.d.cts +0 -593
- package/dist/aggregatorsRouter-Cny4B_MB.d.ts +0 -593
- package/dist/chunk-22MQVFHP.cjs +0 -2
- package/dist/chunk-22MQVFHP.cjs.map +0 -1
- package/dist/chunk-3TKSVFZ3.mjs +0 -2
- package/dist/chunk-3TKSVFZ3.mjs.map +0 -1
- package/dist/chunk-6VF3RF53.cjs +0 -3
- package/dist/chunk-6VF3RF53.cjs.map +0 -1
- package/dist/chunk-6W22TFYA.mjs +0 -2
- package/dist/chunk-6W22TFYA.mjs.map +0 -1
- package/dist/chunk-AMRJ4B36.mjs +0 -2
- package/dist/chunk-AMRJ4B36.mjs.map +0 -1
- package/dist/chunk-DS2ZDVKU.mjs +0 -2
- package/dist/chunk-DS2ZDVKU.mjs.map +0 -1
- package/dist/chunk-ED43NYSE.cjs +0 -2
- package/dist/chunk-ED43NYSE.cjs.map +0 -1
- package/dist/chunk-EU4WFADK.cjs +0 -2
- package/dist/chunk-EU4WFADK.cjs.map +0 -1
- package/dist/chunk-HCTFDGXL.mjs +0 -2
- package/dist/chunk-HCTFDGXL.mjs.map +0 -1
- package/dist/chunk-IOSYBHKU.mjs +0 -2
- package/dist/chunk-IOSYBHKU.mjs.map +0 -1
- package/dist/chunk-JMKLDDKY.cjs +0 -2
- package/dist/chunk-JMKLDDKY.cjs.map +0 -1
- package/dist/chunk-KMKUXP2S.mjs +0 -3
- package/dist/chunk-KMKUXP2S.mjs.map +0 -1
- package/dist/chunk-OJXJ6CZ4.mjs +0 -4
- package/dist/chunk-OJXJ6CZ4.mjs.map +0 -1
- package/dist/chunk-PHIOKO3A.mjs +0 -2
- package/dist/chunk-PHIOKO3A.mjs.map +0 -1
- package/dist/chunk-QCK474XD.cjs +0 -2
- package/dist/chunk-QCK474XD.cjs.map +0 -1
- package/dist/chunk-REDXXUK7.cjs +0 -2
- package/dist/chunk-REDXXUK7.cjs.map +0 -1
- package/dist/chunk-S74ZMG2G.cjs +0 -2
- package/dist/chunk-S74ZMG2G.cjs.map +0 -1
- package/dist/chunk-TOAXF4YW.cjs +0 -2
- package/dist/chunk-TOAXF4YW.cjs.map +0 -1
- package/dist/chunk-UZ5CB33M.cjs +0 -2
- package/dist/chunk-UZ5CB33M.cjs.map +0 -1
- package/dist/chunk-VYWYJR63.mjs +0 -2
- package/dist/chunk-VYWYJR63.mjs.map +0 -1
- package/dist/chunk-XFPTQMAK.cjs +0 -4
- package/dist/chunk-XFPTQMAK.cjs.map +0 -1
- package/dist/chunk-YK4NINF5.mjs +0 -2
- package/dist/chunk-YK4NINF5.mjs.map +0 -1
- package/dist/contexts/index.cjs +0 -2
- package/dist/contexts/index.cjs.map +0 -1
- package/dist/contexts/index.mjs +0 -2
- package/dist/contexts/index.mjs.map +0 -1
- package/dist/enum/index.cjs +0 -2
- package/dist/enum/index.cjs.map +0 -1
- package/dist/enum/index.d.cts +0 -31
- package/dist/enum/index.d.ts +0 -31
- package/dist/enum/index.mjs +0 -2
- package/dist/enum/index.mjs.map +0 -1
- package/dist/errors/index.cjs +0 -2
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.d.cts +0 -204
- package/dist/errors/index.d.ts +0 -204
- package/dist/errors/index.mjs +0 -2
- package/dist/errors/index.mjs.map +0 -1
- package/dist/hooks/index.cjs +0 -4
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.mjs +0 -4
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/staking-F9Nx9TKD.d.ts +0 -246
- package/dist/staking-f4BpYH7l.d.cts +0 -246
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.d.cts +0 -56
- package/dist/types/index.d.ts +0 -56
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.mjs +0 -2
- package/dist/utils/index.mjs.map +0 -1
- package/src/actions/dex/getTransactionCount.ts +0 -29
- package/src/actions/enso/bend.ts +0 -143
- package/src/actions/enso/getEnsoUserToken.debug.test.ts +0 -57
- package/src/contexts/berajsProvider/context.tsx +0 -49
- package/src/contexts/berajsProvider/index.ts +0 -2
- package/src/contexts/berajsProvider/useBeraJs.ts +0 -18
- package/src/hooks/dex/usePollVaultIsPaused.ts +0 -30
- package/src/hooks/enso/useBendTransactionRequests.ts +0 -247
- package/src/hooks/enso/useEnsoZap.ts +0 -166
- package/src/hooks/enso/useZapTransactionRequests.ts +0 -81
- package/src/hooks/pol/useEarnedStakedBeraVault.ts +0 -59
- package/src/hooks/pol/useStakedBeraSnapshots.ts +0 -27
- package/src/hooks/transactions/TransactionStoreContext.tsx +0 -59
- package/src/hooks/transactions/transactionStore.ts +0 -275
- package/src/hooks/transactions/transactionStore.unit.test.ts +0 -508
- package/src/hooks/transactions/useAddRecentTransaction.ts +0 -29
- package/src/hooks/transactions/useRecentTransactions.ts +0 -27
- package/src/hooks/validators/validatorRoleManager.ts +0 -0
- package/src/types/index.ts +0 -8
- package/src/types/staking.ts +0 -7
- package/src/utils/formatAggregatorsQuotes.ts +0 -57
- package/src/utils/formatAggregatorsQuotes.unit.test.ts +0 -191
- package/src/utils/sentryBeforeSend.ts +0 -52
- /package/dist/{abi/index.mjs.map → errors/exports.mjs.map} +0 -0
- /package/dist/{actions/index.mjs.map → types/exports.mjs.map} +0 -0
- /package/src/actions/dex/{__tests__ → aggregators}/haiku.integration.test.ts +0 -0
- /package/src/types/{bribe-boost.ts → bribe-boost.d.ts} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { BigNumber } from "bignumber.js";
|
|
2
1
|
import { type Address, formatUnits } from "viem";
|
|
3
2
|
|
|
4
3
|
import { ChainId } from "@berachain/config/internal";
|
|
5
4
|
|
|
5
|
+
import BigNumber from "@berachain/utils/pkg/bignumber.js";
|
|
6
|
+
|
|
6
7
|
import {
|
|
7
8
|
getHoneyPreview,
|
|
8
9
|
type HoneyPreviewArgs,
|
|
@@ -12,14 +13,15 @@ import { getHoneyVaultsBalance } from "~/actions/honey/getHoneyVaultsBalance";
|
|
|
12
13
|
import { getSwapPayload } from "~/actions/honey/getSwapPayload";
|
|
13
14
|
import { isBasketModeEnabled } from "~/actions/honey/isBasketModeEnabled";
|
|
14
15
|
import type { HoneyConfigContextReturn } from "~/contexts/HoneyConfigProvider";
|
|
16
|
+
import { Aggregators } from "~/enum/dex";
|
|
15
17
|
import { assertPublicClient } from "~/errors/assert";
|
|
16
18
|
import { BeraError } from "~/errors/BeraError";
|
|
17
19
|
import { InvalidArgumentError } from "~/errors/InvalidArgumentError";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import type {
|
|
21
|
+
IAggregatorArgs,
|
|
22
|
+
IRawAggregatorQuote,
|
|
23
|
+
Token,
|
|
24
|
+
TokenWithMetadata,
|
|
23
25
|
} from "~/types/dex";
|
|
24
26
|
import { getHoneyToken, isToken } from "~/utils/tokens";
|
|
25
27
|
import { BaseAggregator } from "./base";
|
|
@@ -40,11 +42,12 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
40
42
|
readonly type = "rpc";
|
|
41
43
|
|
|
42
44
|
readonly honeyToken: TokenWithMetadata = getHoneyToken(this);
|
|
45
|
+
|
|
43
46
|
/**
|
|
44
47
|
* Determines if the swap is a honey mint or redeem based on the tokenIn, tokenOut and the colalterals passed.
|
|
45
48
|
* @returns True if the swap is a honey mint or redeem
|
|
46
49
|
*/
|
|
47
|
-
|
|
50
|
+
isHoneyNativeSwap({
|
|
48
51
|
tokenIn,
|
|
49
52
|
tokenOut,
|
|
50
53
|
honeyNativeState,
|
|
@@ -66,6 +69,26 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
66
69
|
);
|
|
67
70
|
}
|
|
68
71
|
|
|
72
|
+
checkChainSupport({
|
|
73
|
+
tokenIn,
|
|
74
|
+
tokenOut,
|
|
75
|
+
honeyNativeState,
|
|
76
|
+
}: {
|
|
77
|
+
tokenIn: Token;
|
|
78
|
+
tokenOut: Token;
|
|
79
|
+
honeyNativeState?: Pick<HoneyConfigContextReturn, "collateralList">;
|
|
80
|
+
}): boolean {
|
|
81
|
+
return (
|
|
82
|
+
super.checkChainSupport({ tokenIn, tokenOut }) &&
|
|
83
|
+
tokenIn.chainId === tokenOut.chainId &&
|
|
84
|
+
this.isHoneyNativeSwap({
|
|
85
|
+
tokenIn: tokenIn.address,
|
|
86
|
+
tokenOut: tokenOut.address,
|
|
87
|
+
honeyNativeState,
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
69
92
|
async getQuote({
|
|
70
93
|
tokenIn,
|
|
71
94
|
tokenOut,
|
|
@@ -73,7 +96,7 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
73
96
|
publicClient,
|
|
74
97
|
account,
|
|
75
98
|
honeyNativeState,
|
|
76
|
-
}: IHoneyNativeArgs): Promise<IRawAggregatorQuote
|
|
99
|
+
}: IHoneyNativeArgs): Promise<IRawAggregatorQuote | undefined> {
|
|
77
100
|
const { collateralList: collaterals } = honeyNativeState ?? {};
|
|
78
101
|
if (!collaterals) {
|
|
79
102
|
throw new InvalidArgumentError({
|
|
@@ -85,24 +108,10 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
85
108
|
}
|
|
86
109
|
assertPublicClient(publicClient);
|
|
87
110
|
|
|
88
|
-
this.
|
|
111
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
89
112
|
|
|
90
113
|
const isMint = isToken(tokenOut, this.honeyToken);
|
|
91
114
|
|
|
92
|
-
// these should never happen but just in case
|
|
93
|
-
// checking that the tokenOut & tokenIn are correct to allow mint or redeem
|
|
94
|
-
if (
|
|
95
|
-
!HoneyNativeAggregator.isHoneyNativeSwap({
|
|
96
|
-
tokenIn: tokenIn as Address,
|
|
97
|
-
tokenOut: tokenOut as Address,
|
|
98
|
-
honeyNativeState,
|
|
99
|
-
})
|
|
100
|
-
) {
|
|
101
|
-
throw new BeraError({
|
|
102
|
-
message: "Honey Aggregator only supports minting or redeeming Honey",
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
115
|
/**
|
|
107
116
|
* The collaterals on Honey are managed with a state that changes the order based on the selected collateral.
|
|
108
117
|
* hub does not do that, so we need to order the collaterals based on the tokenIn.
|
|
@@ -112,10 +121,7 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
112
121
|
|
|
113
122
|
// Check if the token requested as collateral is a valid collateral token that can be used to mint or redeem honey
|
|
114
123
|
const collateral = collaterals.find((collateral) =>
|
|
115
|
-
isToken(
|
|
116
|
-
collateral.address,
|
|
117
|
-
isMint ? (tokenIn as Address) : (tokenOut as Address),
|
|
118
|
-
),
|
|
124
|
+
isToken(collateral.address, isMint ? tokenIn.address : tokenOut.address),
|
|
119
125
|
);
|
|
120
126
|
if (!collateral) {
|
|
121
127
|
throw new BeraError({
|
|
@@ -190,7 +196,7 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
190
196
|
|
|
191
197
|
// check if the vault has enough liquidity to redeem the collateral
|
|
192
198
|
const haveEnoughLiquidity = !isMint
|
|
193
|
-
? new BigNumber(collateralVaultBalance?.
|
|
199
|
+
? new BigNumber(collateralVaultBalance?.balance.formatted ?? "0").gte(
|
|
194
200
|
formatUnits(
|
|
195
201
|
collateralsQuote[collateral.address],
|
|
196
202
|
collateral.decimals,
|
|
@@ -206,21 +212,18 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
206
212
|
* Get the swap payload for the Honey mint
|
|
207
213
|
* If the account is not provided, we will not get the payload
|
|
208
214
|
*/
|
|
209
|
-
const payload =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
isPythWrapperEnabled: false,
|
|
222
|
-
})
|
|
223
|
-
: undefined;
|
|
215
|
+
const payload = await getSwapPayload({
|
|
216
|
+
state: {
|
|
217
|
+
actionType: isMint ? "mint" : "redeem",
|
|
218
|
+
fromAmount: [honeyFormattedAmountIn],
|
|
219
|
+
collaterals: hubOrderedCollaterals,
|
|
220
|
+
isBasketModeEnabled: false, // In Hub, we don't support basket mode
|
|
221
|
+
},
|
|
222
|
+
collateralList: hubOrderedCollaterals,
|
|
223
|
+
publicClient,
|
|
224
|
+
priceFeedMap: undefined,
|
|
225
|
+
isPythWrapperEnabled: false,
|
|
226
|
+
});
|
|
224
227
|
|
|
225
228
|
// In case the user is not connected the payload will not be generated but the preview yes
|
|
226
229
|
if (!payload && account) {
|
|
@@ -234,10 +237,16 @@ export class HoneyNativeAggregator extends BaseAggregator {
|
|
|
234
237
|
amountOut: isMint
|
|
235
238
|
? honeyQuote.toString()
|
|
236
239
|
: collateralsQuote[collateral.address].toString(),
|
|
237
|
-
|
|
240
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
241
|
+
tokenIn,
|
|
242
|
+
rawAmount: amount,
|
|
243
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
244
|
+
}),
|
|
238
245
|
name: Aggregators.Honey,
|
|
239
246
|
swapFeeBps: 0,
|
|
240
|
-
|
|
247
|
+
getCalldata: ({ account }) => {
|
|
248
|
+
return payload({ account });
|
|
249
|
+
},
|
|
241
250
|
};
|
|
242
251
|
}
|
|
243
252
|
}
|
|
@@ -3,11 +3,8 @@ 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
|
-
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 { BaseAggregator } from "./base";
|
|
12
9
|
|
|
13
10
|
class KyberSwapAggregator extends BaseAggregator {
|
|
@@ -30,13 +27,13 @@ class KyberSwapAggregator extends BaseAggregator {
|
|
|
30
27
|
proxyAggregatorsThroughVercel = false,
|
|
31
28
|
rewardVault,
|
|
32
29
|
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
33
|
-
this.
|
|
30
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
34
31
|
const {
|
|
35
32
|
isTokenInNative,
|
|
36
33
|
isTokenOutNative,
|
|
37
34
|
tokenInAddress,
|
|
38
35
|
tokenOutAddress,
|
|
39
|
-
} = this.parseAddresses(tokenIn, tokenOut);
|
|
36
|
+
} = this.parseAddresses(tokenIn.address, tokenOut.address);
|
|
40
37
|
|
|
41
38
|
const inputAmountAfterFees = this.getAmountAfterFees(
|
|
42
39
|
amount,
|
|
@@ -62,13 +59,14 @@ class KyberSwapAggregator extends BaseAggregator {
|
|
|
62
59
|
const formattedQuote = {
|
|
63
60
|
amountOut: routeData.data.routeSummary.amountOut,
|
|
64
61
|
amountIn: amount,
|
|
65
|
-
spender: this.config.bex.aggregatorsRouter,
|
|
66
62
|
name: this.name,
|
|
67
63
|
swapFeeBps: aggregatorsFeeBps!,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
65
|
+
tokenIn,
|
|
66
|
+
rawAmount: amount,
|
|
67
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
68
|
+
}),
|
|
69
|
+
} satisfies IRawAggregatorQuote;
|
|
72
70
|
|
|
73
71
|
// Get the build route data for transaction
|
|
74
72
|
const buildRouteBody = {
|
|
@@ -105,35 +103,39 @@ class KyberSwapAggregator extends BaseAggregator {
|
|
|
105
103
|
isNative: isTokenInNative,
|
|
106
104
|
});
|
|
107
105
|
|
|
108
|
-
const outputData = {
|
|
109
|
-
tokenOut: tokenOutAddress,
|
|
110
|
-
receiver: account,
|
|
111
|
-
minAmountOut: this.getMinAmountOut(formattedQuote.amountOut, slippage),
|
|
112
|
-
isNative: isTokenOutNative,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const aggregatorData = {
|
|
116
|
-
aggregator: buildData.data.routerAddress,
|
|
117
|
-
data: buildData.data.data,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
106
|
return {
|
|
121
107
|
...formattedQuote,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
108
|
+
getCalldata: ({ account }) => {
|
|
109
|
+
const outputData = {
|
|
110
|
+
tokenOut: tokenOutAddress,
|
|
111
|
+
receiver: account,
|
|
112
|
+
minAmountOut: this.getMinAmountOut(
|
|
113
|
+
formattedQuote.amountOut,
|
|
114
|
+
slippage,
|
|
115
|
+
),
|
|
116
|
+
isNative: isTokenOutNative,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const aggregatorData = {
|
|
120
|
+
aggregator: buildData.data.routerAddress,
|
|
121
|
+
data: buildData.data.data,
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
params: [
|
|
125
|
+
inputData,
|
|
126
|
+
outputData,
|
|
127
|
+
aggregatorData,
|
|
128
|
+
{
|
|
129
|
+
rewardVault: rewardVault ?? zeroAddress,
|
|
130
|
+
isSwapAndStake: !!rewardVault,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
functionName: "swap",
|
|
134
|
+
abi: aggregatorsRouterAbi,
|
|
135
|
+
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
136
|
+
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
137
|
+
address: this.config.bex.aggregatorsRouter,
|
|
138
|
+
};
|
|
137
139
|
},
|
|
138
140
|
};
|
|
139
141
|
}
|
|
@@ -3,11 +3,8 @@ 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
|
-
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 { BaseAggregator } from "./base";
|
|
12
9
|
|
|
13
10
|
class OogaboogaAggregator extends BaseAggregator {
|
|
@@ -20,19 +17,18 @@ class OogaboogaAggregator extends BaseAggregator {
|
|
|
20
17
|
tokenOut,
|
|
21
18
|
amount,
|
|
22
19
|
slippage,
|
|
23
|
-
account = zeroAddress,
|
|
24
20
|
aggregatorsFeeBps,
|
|
25
21
|
proxyAggregatorsThroughVercel = false,
|
|
26
22
|
rewardVault,
|
|
27
23
|
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
28
|
-
this.
|
|
24
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
29
25
|
|
|
30
26
|
const {
|
|
31
27
|
tokenInAddress,
|
|
32
28
|
tokenOutAddress,
|
|
33
29
|
isTokenInNative,
|
|
34
30
|
isTokenOutNative,
|
|
35
|
-
} = this.parseAddresses(tokenIn, tokenOut);
|
|
31
|
+
} = this.parseAddresses(tokenIn.address, tokenOut.address);
|
|
36
32
|
|
|
37
33
|
const inputAmountAfterFees = this.getAmountAfterFees(
|
|
38
34
|
amount,
|
|
@@ -58,50 +54,55 @@ class OogaboogaAggregator extends BaseAggregator {
|
|
|
58
54
|
const formattedQuote = {
|
|
59
55
|
amountOut: quote.assumedAmountOut,
|
|
60
56
|
amountIn: amount,
|
|
61
|
-
|
|
57
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
58
|
+
tokenIn,
|
|
59
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
60
|
+
rawAmount: amount,
|
|
61
|
+
}),
|
|
62
62
|
name: this.name,
|
|
63
63
|
priceImpactPercentage: quote.priceImpact,
|
|
64
64
|
swapFeeBps: aggregatorsFeeBps!,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// if no account, return quote early
|
|
68
|
-
if (account === zeroAddress) return formattedQuote;
|
|
69
|
-
|
|
70
|
-
const inputData = this.getInputData({
|
|
71
|
-
tokenIn: tokenInAddress,
|
|
72
|
-
amountIn: amount,
|
|
73
|
-
isNative: isTokenInNative,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const outputData = {
|
|
77
|
-
tokenOut: tokenOutAddress,
|
|
78
|
-
receiver: account,
|
|
79
|
-
minAmountOut: this.getMinAmountOut(formattedQuote.amountOut, slippage),
|
|
80
|
-
isNative: isTokenOutNative,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const aggregatorData = {
|
|
84
|
-
aggregator: quote.tx?.to,
|
|
85
|
-
data: quote.tx?.data,
|
|
86
|
-
};
|
|
65
|
+
} satisfies IRawAggregatorQuote;
|
|
87
66
|
|
|
88
67
|
return {
|
|
89
68
|
...formattedQuote,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
69
|
+
getCalldata: ({ account }) => {
|
|
70
|
+
const inputData = this.getInputData({
|
|
71
|
+
tokenIn: tokenInAddress,
|
|
72
|
+
amountIn: amount,
|
|
73
|
+
isNative: isTokenInNative,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const outputData = {
|
|
77
|
+
tokenOut: tokenOutAddress,
|
|
78
|
+
receiver: account,
|
|
79
|
+
minAmountOut: this.getMinAmountOut(
|
|
80
|
+
formattedQuote.amountOut,
|
|
81
|
+
slippage,
|
|
82
|
+
),
|
|
83
|
+
isNative: isTokenOutNative,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const aggregatorData = {
|
|
87
|
+
aggregator: quote.tx?.to,
|
|
88
|
+
data: quote.tx?.data,
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
params: [
|
|
92
|
+
inputData,
|
|
93
|
+
outputData,
|
|
94
|
+
aggregatorData,
|
|
95
|
+
{
|
|
96
|
+
rewardVault: rewardVault ?? zeroAddress,
|
|
97
|
+
isSwapAndStake: !!rewardVault,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
functionName: "swap",
|
|
101
|
+
abi: aggregatorsRouterAbi,
|
|
102
|
+
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
103
|
+
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
104
|
+
address: this.config.bex.aggregatorsRouter,
|
|
105
|
+
};
|
|
105
106
|
},
|
|
106
107
|
};
|
|
107
108
|
}
|
|
@@ -3,13 +3,11 @@ import { zeroAddress } from "viem";
|
|
|
3
3
|
import { ChainId } from "@berachain/config/internal";
|
|
4
4
|
|
|
5
5
|
import { aggregatorsRouterAbi } from "~/abi/bex/aggregatorsRouter";
|
|
6
|
-
import {
|
|
6
|
+
import { Aggregators } from "~/enum/dex";
|
|
7
|
+
import { assertPublicClient } from "~/errors/assert";
|
|
8
|
+
import { InvalidArgumentError } from "~/errors/InvalidArgumentError";
|
|
7
9
|
import { RequestError } from "~/errors/RequestError";
|
|
8
|
-
import {
|
|
9
|
-
Aggregators,
|
|
10
|
-
type IAggregatorArgs,
|
|
11
|
-
type IRawAggregatorQuote,
|
|
12
|
-
} from "~/types";
|
|
10
|
+
import type { IAggregatorArgs, IRawAggregatorQuote } from "~/types/dex";
|
|
13
11
|
import { BaseAggregator } from "./base";
|
|
14
12
|
|
|
15
13
|
class OpenOceanAggregator extends BaseAggregator {
|
|
@@ -26,22 +24,21 @@ class OpenOceanAggregator extends BaseAggregator {
|
|
|
26
24
|
slippage,
|
|
27
25
|
account = zeroAddress,
|
|
28
26
|
aggregatorsFeeBps,
|
|
29
|
-
tokenInDecimals,
|
|
30
27
|
publicClient,
|
|
31
28
|
rewardVault,
|
|
32
29
|
}: IAggregatorArgs): Promise<IRawAggregatorQuote> {
|
|
33
30
|
assertPublicClient(publicClient);
|
|
34
31
|
|
|
35
|
-
if (!
|
|
32
|
+
if (!tokenIn.decimals) {
|
|
36
33
|
throw new InvalidArgumentError({
|
|
37
|
-
property: "
|
|
38
|
-
value:
|
|
34
|
+
property: "tokenIn.decimals",
|
|
35
|
+
value: tokenIn.decimals,
|
|
39
36
|
expected: "number",
|
|
40
37
|
chainId: this.chainId,
|
|
41
38
|
});
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
this.
|
|
41
|
+
this.assertChainSupport({ tokenIn, tokenOut });
|
|
45
42
|
|
|
46
43
|
const inputAmountAfterFees = this.getAmountAfterFees(
|
|
47
44
|
amount,
|
|
@@ -53,7 +50,7 @@ class OpenOceanAggregator extends BaseAggregator {
|
|
|
53
50
|
tokenOutAddress,
|
|
54
51
|
isTokenInNative,
|
|
55
52
|
isTokenOutNative,
|
|
56
|
-
} = this.parseAddresses(tokenIn, tokenOut);
|
|
53
|
+
} = this.parseAddresses(tokenIn.address, tokenOut.address);
|
|
57
54
|
|
|
58
55
|
const gasPrice = (await publicClient.getGasPrice()).toString();
|
|
59
56
|
|
|
@@ -94,46 +91,54 @@ class OpenOceanAggregator extends BaseAggregator {
|
|
|
94
91
|
const formattedQuote = {
|
|
95
92
|
amountOut: quoteData.data.outAmount,
|
|
96
93
|
amountIn: amount,
|
|
97
|
-
|
|
94
|
+
allowanceRequirements: this.parseAllowanceRequirements({
|
|
95
|
+
tokenIn,
|
|
96
|
+
rawAmount: amount,
|
|
97
|
+
spender: this.config.bex.aggregatorsRouter,
|
|
98
|
+
}),
|
|
98
99
|
name: this.name,
|
|
99
100
|
swapFeeBps: aggregatorsFeeBps!,
|
|
100
101
|
};
|
|
101
102
|
|
|
102
|
-
const inputData = this.getInputData({
|
|
103
|
-
tokenIn: tokenInAddress,
|
|
104
|
-
amountIn: amount,
|
|
105
|
-
isNative: isTokenInNative,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const outputData = {
|
|
109
|
-
tokenOut: tokenOutAddress,
|
|
110
|
-
receiver: account,
|
|
111
|
-
minAmountOut: this.getMinAmountOut(formattedQuote.amountOut, slippage),
|
|
112
|
-
isNative: isTokenOutNative,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const aggregatorData = {
|
|
116
|
-
aggregator: quoteData.data.to,
|
|
117
|
-
data: quoteData.data.data,
|
|
118
|
-
};
|
|
119
|
-
|
|
120
103
|
return {
|
|
121
104
|
...formattedQuote,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
105
|
+
getCalldata: ({ account }) => {
|
|
106
|
+
const inputData = this.getInputData({
|
|
107
|
+
tokenIn: tokenInAddress,
|
|
108
|
+
amountIn: amount,
|
|
109
|
+
isNative: isTokenInNative,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const outputData = {
|
|
113
|
+
tokenOut: tokenOutAddress,
|
|
114
|
+
receiver: account,
|
|
115
|
+
minAmountOut: this.getMinAmountOut(
|
|
116
|
+
formattedQuote.amountOut,
|
|
117
|
+
slippage,
|
|
118
|
+
),
|
|
119
|
+
isNative: isTokenOutNative,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const aggregatorData = {
|
|
123
|
+
aggregator: quoteData.data.to,
|
|
124
|
+
data: quoteData.data.data,
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
params: [
|
|
128
|
+
inputData,
|
|
129
|
+
outputData,
|
|
130
|
+
aggregatorData,
|
|
131
|
+
{
|
|
132
|
+
rewardVault: rewardVault ?? zeroAddress,
|
|
133
|
+
isSwapAndStake: !!rewardVault,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
functionName: "swap",
|
|
137
|
+
abi: aggregatorsRouterAbi,
|
|
138
|
+
// send full amount to router first, which will deduct the swap fee before executing trade
|
|
139
|
+
value: isTokenInNative ? BigInt(amount) : BigInt("0"),
|
|
140
|
+
address: this.config.bex.aggregatorsRouter,
|
|
141
|
+
};
|
|
137
142
|
},
|
|
138
143
|
};
|
|
139
144
|
}
|