@velora-dex/widget 0.0.23 → 0.1.0-rc.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/_virtual/index.js +1 -1
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/drawer.d.ts +2 -2
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +2 -2
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/sonner.js +1 -2
- package/dist/components/ui/sonner.js.map +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/components/web3/AccountButton.js.map +1 -1
- package/dist/components/web3/ConnectExternalProvider/AutoconnectExternal.js.map +1 -1
- package/dist/components/web3/ConnectWallets/WalletConnectButtons.d.ts.map +1 -1
- package/dist/components/web3/ConnectWallets/WalletConnectButtons.js +23 -14
- package/dist/components/web3/ConnectWallets/WalletConnectButtons.js.map +1 -1
- package/dist/components/web3/ConnectWallets/index.js.map +1 -1
- package/dist/components/web3/ConnectWallets/privy/button.js.map +1 -1
- package/dist/components/web3/ConnectWallets/privy/connectRunner.d.ts.map +1 -1
- package/dist/components/web3/ConnectWallets/privy/connectRunner.js +0 -2
- package/dist/components/web3/ConnectWallets/privy/connectRunner.js.map +1 -1
- package/dist/components/web3/ConnectWallets/privy/iframe.js.map +1 -1
- package/dist/components/web3/ConnectWallets/privy/provider.js.map +1 -1
- package/dist/components/web3/ConnectWallets/walletIcons.d.ts +30 -0
- package/dist/components/web3/ConnectWallets/walletIcons.d.ts.map +1 -1
- package/dist/components/web3/ConnectWallets/walletIcons.js +84 -2
- package/dist/components/web3/ConnectWallets/walletIcons.js.map +1 -1
- package/dist/components/web3/ConnectedWallet/ConnectedWallet.d.ts.map +1 -1
- package/dist/components/web3/ConnectedWallet/ConnectedWallet.js +69 -65
- package/dist/components/web3/ConnectedWallet/ConnectedWallet.js.map +1 -1
- package/dist/components/web3/providers.d.ts +3 -0
- package/dist/components/web3/providers.d.ts.map +1 -1
- package/dist/components/web3/providers.js +18 -1
- package/dist/components/web3/providers.js.map +1 -1
- package/dist/components/widget/AppHeader/ActivityButton.js.map +1 -1
- package/dist/components/widget/AppHeader/AppHeader.d.ts.map +1 -1
- package/dist/components/widget/AppHeader/AppHeader.js +49 -55
- package/dist/components/widget/AppHeader/AppHeader.js.map +1 -1
- package/dist/components/widget/Details/DetailWithTooltip.js.map +1 -1
- package/dist/components/widget/Details/DetailWithValueList.js.map +1 -1
- package/dist/components/widget/Details/DetailWithValueListExpandable.js.map +1 -1
- package/dist/components/widget/Details/SwapDetailsExpandable.js.map +1 -1
- package/dist/components/widget/Dialog/ConnectWalletDialog/ConnectWalletDialog.js.map +1 -1
- package/dist/components/widget/Dialog/DialogRoot.js.map +1 -1
- package/dist/components/widget/Dialog/ReceiverAddressDialog/ReceiverAddressDialog.js +2 -2
- package/dist/components/widget/Dialog/ReceiverAddressDialog/ReceiverAddressDialog.js.map +1 -1
- package/dist/components/widget/Dialog/ReceiverAddressDialog/ReceiverAddressInput.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.d.ts.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.js +125 -78
- package/dist/components/widget/Dialog/SelectTokenDialog/SelectTokenDialog.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/AcrossTokenList.d.ts +5 -2
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/AcrossTokenList.d.ts.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/AcrossTokenList.js +10 -8
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/AcrossTokenList.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/RegularTokenList.d.ts +5 -2
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/RegularTokenList.d.ts.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/RegularTokenList.js +10 -8
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/RegularTokenList.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/index.d.ts +11 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/index.d.ts.map +1 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/index.js +101 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/index.js.map +1 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/tokens.d.ts +5 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/tokens.d.ts.map +1 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/tokens.js +186 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenCloud/tokens.js.map +1 -0
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenListBody.d.ts +6 -2
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenListBody.d.ts.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenListBody.js +33 -20
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenListBody/TokenListBody.js.map +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenSearch.js +1 -1
- package/dist/components/widget/Dialog/SelectTokenDialog/TokenSearch.js.map +1 -1
- package/dist/components/widget/Dialog/state/dialogAtom.js.map +1 -1
- package/dist/components/widget/Drawer/Overlay.d.ts +9 -0
- package/dist/components/widget/Drawer/Overlay.d.ts.map +1 -0
- package/dist/components/widget/Drawer/Overlay.js +62 -0
- package/dist/components/widget/Drawer/Overlay.js.map +1 -0
- package/dist/components/widget/Drawer/index.d.ts +3 -1
- package/dist/components/widget/Drawer/index.d.ts.map +1 -1
- package/dist/components/widget/Drawer/index.js +65 -37
- package/dist/components/widget/Drawer/index.js.map +1 -1
- package/dist/components/widget/Drawer/state/useDrawerControls.d.ts +27 -1
- package/dist/components/widget/Drawer/state/useDrawerControls.d.ts.map +1 -1
- package/dist/components/widget/Drawer/state/useDrawerControls.js +91 -2
- package/dist/components/widget/Drawer/state/useDrawerControls.js.map +1 -1
- package/dist/components/widget/Dropdown/DropdownWithItems.d.ts.map +1 -1
- package/dist/components/widget/Dropdown/DropdownWithItems.js +5 -3
- package/dist/components/widget/Dropdown/DropdownWithItems.js.map +1 -1
- package/dist/components/widget/Dropdown/types.d.ts +2 -1
- package/dist/components/widget/Dropdown/types.d.ts.map +1 -1
- package/dist/components/widget/Icon/CheckIcon.js.map +1 -1
- package/dist/components/widget/Icon/ChevronIcon.js.map +1 -1
- package/dist/components/widget/Icon/DeltaIcon.js.map +1 -1
- package/dist/components/widget/Icon/EllipseIcon.js.map +1 -1
- package/dist/components/widget/Icon/InfoIcon.js.map +1 -1
- package/dist/components/widget/Icon/MarketIcon.js.map +1 -1
- package/dist/components/widget/Icon/SliderIcon.js.map +1 -1
- package/dist/components/widget/Line/Line.js.map +1 -1
- package/dist/components/widget/NetworkIcon/NetworkIconSquare.js.map +1 -1
- package/dist/components/widget/NetworkSwitcher/CompactNetworkSwitcher.d.ts.map +1 -1
- package/dist/components/widget/NetworkSwitcher/CompactNetworkSwitcher.js +14 -10
- package/dist/components/widget/NetworkSwitcher/CompactNetworkSwitcher.js.map +1 -1
- package/dist/components/widget/NetworkSwitcher/NetworkSwitcherDropdown.d.ts.map +1 -1
- package/dist/components/widget/NetworkSwitcher/NetworkSwitcherDropdown.js +10 -8
- package/dist/components/widget/NetworkSwitcher/NetworkSwitcherDropdown.js.map +1 -1
- package/dist/components/widget/NetworkSwitcher/types.d.ts +2 -2
- package/dist/components/widget/NetworkSwitcher/types.d.ts.map +1 -1
- package/dist/components/widget/NetworkWithIcon/NetworkIconWithChevron.js.map +1 -1
- package/dist/components/widget/NetworkWithIcon/NetworkWithIcon.js.map +1 -1
- package/dist/components/widget/PoweredBy/PoweredBy.js.map +1 -1
- package/dist/components/widget/ReceiverAddress/ReceiverAddress.js.map +1 -1
- package/dist/components/widget/ReceiverAddress/state/receiverAddressAtom.js.map +1 -1
- package/dist/components/widget/ReceiverAddress/state/subscriptions.d.ts.map +1 -1
- package/dist/components/widget/ReceiverAddress/state/subscriptions.js +1 -2
- package/dist/components/widget/ReceiverAddress/state/subscriptions.js.map +1 -1
- package/dist/components/widget/RowVirtualizer/RowVirtualizerFixed.d.ts +1 -1
- package/dist/components/widget/RowVirtualizer/RowVirtualizerFixed.d.ts.map +1 -1
- package/dist/components/widget/RowVirtualizer/RowVirtualizerFixed.js +5 -1
- package/dist/components/widget/RowVirtualizer/RowVirtualizerFixed.js.map +1 -1
- package/dist/components/widget/RowVirtualizer/types.d.ts +1 -0
- package/dist/components/widget/RowVirtualizer/types.d.ts.map +1 -1
- package/dist/components/widget/SelectToken/SelectTokenButton.js.map +1 -1
- package/dist/components/widget/SwapModeSwitcher/SwapModeSwitcherExpandable.js.map +1 -1
- package/dist/components/widget/SwapModeSwitcher/state/swapModeActionsAtom.js.map +1 -1
- package/dist/components/widget/SwapModeSwitcher/state/swapSideAtom.js.map +1 -1
- package/dist/components/widget/SwapRate/SwapRate.d.ts.map +1 -1
- package/dist/components/widget/SwapRate/SwapRate.js +3 -0
- package/dist/components/widget/SwapRate/SwapRate.js.map +1 -1
- package/dist/components/widget/Toasts/CustomToast.js.map +1 -1
- package/dist/components/widget/TokenBadge/TokenBadge.d.ts.map +1 -1
- package/dist/components/widget/TokenBadge/TokenBadge.js +1 -1
- package/dist/components/widget/TokenBadge/TokenBadge.js.map +1 -1
- package/dist/components/widget/TokenInput/EmptyInput.js.map +1 -1
- package/dist/components/widget/TokenInput/index.js +1 -1
- package/dist/components/widget/TokenInput/index.js.map +1 -1
- package/dist/components/widget/TokenSwitcher/TokenSwitcher.js.map +1 -1
- package/dist/components/widget/TradeOverview/DeltaOrderTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/MarketSwapTradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/Step/Step.js.map +1 -1
- package/dist/components/widget/TradeOverview/Step/utils.js.map +1 -1
- package/dist/components/widget/TradeOverview/Stepper.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/Stepper.js +39 -21
- package/dist/components/widget/TradeOverview/Stepper.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/TradeCompleteFooter.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/TradeCompleteHeader.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/TradeCompletedDetails.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/index.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/useTradeCompleteDetails.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/useTradeCompleteDetails.js +40 -72
- package/dist/components/widget/TradeOverview/TradeComplete/useTradeCompleteDetails.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/utils.d.ts +23 -3
- package/dist/components/widget/TradeOverview/TradeComplete/utils.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeComplete/utils.js +68 -20
- package/dist/components/widget/TradeOverview/TradeComplete/utils.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeDetails.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeDetailsDisplay.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/TradeErrorDetails.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/TradeErrorFooter.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/index.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeError/utils.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverview.d.ts.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverview.js +40 -56
- package/dist/components/widget/TradeOverview/TradeOverview.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverviewFooter.js.map +1 -1
- package/dist/components/widget/TradeOverview/TradeOverviewHeader.js.map +1 -1
- package/dist/components/widget/TradeOverview/VerticalDash.js.map +1 -1
- package/dist/components/widget/TradeOverview/tradeFlowContext.js.map +1 -1
- package/dist/components/widget/TradeParameters/DeltaParameter.js.map +1 -1
- package/dist/components/widget/TradeParameters/EIP1559Parameter.js.map +1 -1
- package/dist/components/widget/TradeParameters/SlippageParameter/CustomSlippageInput.js.map +1 -1
- package/dist/components/widget/TradeParameters/SlippageParameter/EditSlippage.js.map +1 -1
- package/dist/components/widget/TradeParameters/SlippageParameter/SlippageParameter.js +2 -2
- package/dist/components/widget/TradeParameters/SlippageParameter/SlippageParameter.js.map +1 -1
- package/dist/components/widget/TradeParameters/SlippageParameter/hooks/useCustomSlippageProps.d.ts.map +1 -1
- package/dist/components/widget/TradeParameters/SlippageParameter/hooks/useCustomSlippageProps.js +42 -19
- package/dist/components/widget/TradeParameters/SlippageParameter/hooks/useCustomSlippageProps.js.map +1 -1
- package/dist/components/widget/TradeParameters/TradeParameters.js.map +1 -1
- package/dist/components/widget/TradeParameters/TransactionSpeedParameter.js +3 -3
- package/dist/components/widget/TradeParameters/TransactionSpeedParameter.js.map +1 -1
- package/dist/components/widget/TradeParameters/hooks/useIsNotDefaultAnyParameter.js.map +1 -1
- package/dist/components/widget/TradeParameters/state/slippageParamActionsAtom.js.map +1 -1
- package/dist/components/widget/Warning/InsufficientBalanceMessage.js.map +1 -1
- package/dist/components/widget/Warning/Warning.js.map +1 -1
- package/dist/components/widget/Warning/WarningMessage.js.map +1 -1
- package/dist/components/widget/WrapEth/WrapEthContent.js.map +1 -1
- package/dist/components/widget/WrapEth/WrapEthDrawerButton.js.map +1 -1
- package/dist/components/widget/WrapEth/hooks/useSubmitDepositTxMutation.d.ts.map +1 -1
- package/dist/components/widget/WrapEth/hooks/useSubmitDepositTxMutation.js +18 -24
- package/dist/components/widget/WrapEth/hooks/useSubmitDepositTxMutation.js.map +1 -1
- package/dist/components/widget/WrapEth/hooks/useWrapEthProps.js.map +1 -1
- package/dist/components/widget/YouGet/YouGet.js.map +1 -1
- package/dist/configurator/Configurator.d.ts.map +1 -1
- package/dist/core/ConnectWalletDrawerButton.js.map +1 -1
- package/dist/core/Toaster.js.map +1 -1
- package/dist/core/TradeFlowButton.js +154 -126
- package/dist/core/TradeFlowButton.js.map +1 -1
- package/dist/core/Updaters.d.ts.map +1 -1
- package/dist/core/Updaters.js +2 -0
- package/dist/core/Updaters.js.map +1 -1
- package/dist/core/across/utils.d.ts.map +1 -1
- package/dist/core/across/utils.js +1 -2
- package/dist/core/across/utils.js.map +1 -1
- package/dist/core/button/hooks/useWidgetButtonExtraProps.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +90 -55
- package/dist/core/index.js.map +1 -1
- package/dist/core/inputs/hooks/useTokenFromInputProps.js.map +1 -1
- package/dist/core/inputs/hooks/useTokenSwitcherProps.js.map +1 -1
- package/dist/core/inputs/hooks/useTokenToInputProps.d.ts.map +1 -1
- package/dist/core/inputs/hooks/useTokenToInputProps.js +16 -19
- package/dist/core/inputs/hooks/useTokenToInputProps.js.map +1 -1
- package/dist/core/inputs/state/inputAmountAtom.js.map +1 -1
- package/dist/core/inputs/state/selectedTokenActionsAtom.d.ts.map +1 -1
- package/dist/core/inputs/state/selectedTokenActionsAtom.js +2 -2
- package/dist/core/inputs/state/selectedTokenActionsAtom.js.map +1 -1
- package/dist/core/inputs/state/selectedTokenAtom.js.map +1 -1
- package/dist/core/inputs/state/store.d.ts +6 -0
- package/dist/core/inputs/state/store.d.ts.map +1 -0
- package/dist/core/inputs/state/store.js +6 -0
- package/dist/core/inputs/state/store.js.map +1 -0
- package/dist/core/inputs/state/subscriptions.js.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +4 -5
- package/dist/core/logger.js.map +1 -1
- package/dist/core/state/chainToAtom.d.ts +2 -2
- package/dist/core/state/chainToAtom.js.map +1 -1
- package/dist/core/state/configActionsAtom.d.ts +1 -1
- package/dist/core/state/configActionsAtom.js.map +1 -1
- package/dist/core/state/configAtom.js.map +1 -1
- package/dist/core/state/externalProviderAtom.js.map +1 -1
- package/dist/core/swapDetails/fees.js.map +1 -1
- package/dist/core/swapDetails/orderRouting.js.map +1 -1
- package/dist/core/swapDetails/priceImpact.js.map +1 -1
- package/dist/core/swapDetails/useSwapDetailsListProps.d.ts.map +1 -1
- package/dist/core/swapDetails/useSwapDetailsListProps.js +0 -1
- package/dist/core/swapDetails/useSwapDetailsListProps.js.map +1 -1
- package/dist/core/swapDetails/youGet.d.ts +1 -3
- package/dist/core/swapDetails/youGet.d.ts.map +1 -1
- package/dist/core/swapDetails/youGet.js +1 -3
- package/dist/core/swapDetails/youGet.js.map +1 -1
- package/dist/crosschain_token_list.json +3230 -0
- package/dist/external/.pnpm/{react-compiler-runtime@19.1.0-rc.2_react@19.1.0 → react-compiler-runtime@19.1.0-rc.2_react@19.1.1}/external/react-compiler-runtime/dist/index.js.map +1 -1
- package/dist/external/.pnpm/{vaul@1.1.2_patch_hash_07b36ba5def3805dde9d543a880ba9e4caf55e5eb58e544faaa2c186846bf3c1__15df56ff48174365d34843c037ea8a33 → vaul@1.1.2_patch_hash_07b36ba5def3805dde9d543a880ba9e4caf55e5eb58e544faaa2c186846bf3c1__7f2d7d5ed11750fbec42b3f5689c802d}/external/vaul/dist/index.js.map +1 -1
- package/dist/hooks/gas/useGasPrices.js.map +1 -1
- package/dist/hooks/getCode/useIsAccountContract.js.map +1 -1
- package/dist/hooks/getCode/useIsContractAtAddress.js.map +1 -1
- package/dist/hooks/permit/hooks/common/useSignArbitraryTypedData.js.map +1 -1
- package/dist/hooks/permit/hooks/common/useSignPermit.js.map +1 -1
- package/dist/hooks/permit/hooks/common/useWalletSupportsPermit.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/useGetPermitInfo.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/useGetSafePermitInfo.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/usePermit1Nonce.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/useSignTokenPermit1.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/useTokenFromPermit1Nonce.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/useTokenFromPermitInfo.js.map +1 -1
- package/dist/hooks/permit/hooks/permit1/useTryToSignPermit1.js.map +1 -1
- package/dist/hooks/permit/hooks/permit2/usePermit2Allowance.js.map +1 -1
- package/dist/hooks/permit/hooks/permit2/usePermit2TransferFromNonce.js.map +1 -1
- package/dist/hooks/permit/hooks/permit2/useSignTokenPermit2TransferFrom.js.map +1 -1
- package/dist/hooks/permit/hooks/permit2/useTokenFromPermit2TransferFromNonce.js.map +1 -1
- package/dist/hooks/permit/utils/construct.js.map +1 -1
- package/dist/hooks/permit/utils/detect.js.map +1 -1
- package/dist/hooks/permit/utils/domainSeparator.js.map +1 -1
- package/dist/hooks/permit/utils/encodeArgs.js +1 -1
- package/dist/hooks/permit/utils/encodeArgs.js.map +1 -1
- package/dist/hooks/permit/utils/trySignPermit1.js.map +1 -1
- package/dist/hooks/permit/utils/utils.js.map +1 -1
- package/dist/hooks/sdk/useGetContracts.js.map +1 -1
- package/dist/hooks/sdk/useSpender.js.map +1 -1
- package/dist/hooks/swap/prices/delta/mutations/useCreateDeltaOrder.d.ts +3 -2
- package/dist/hooks/swap/prices/delta/mutations/useCreateDeltaOrder.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/mutations/useCreateDeltaOrder.js.map +1 -1
- package/dist/hooks/swap/prices/delta/orders/utils.d.ts +8 -6
- package/dist/hooks/swap/prices/delta/orders/utils.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/orders/utils.js +7 -4
- package/dist/hooks/swap/prices/delta/orders/utils.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useBridgeInfo.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaOrders.d.ts +2 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaOrders.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.d.ts +16 -2
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js +64 -3
- package/dist/hooks/swap/prices/delta/queries/useDeltaPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useIsTokenSupportedInDelta.js.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.d.ts +8 -0
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.d.ts.map +1 -1
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.js +12 -3
- package/dist/hooks/swap/prices/delta/queries/useWatchDeltaOrder.js.map +1 -1
- package/dist/hooks/swap/prices/market/mutations/useBuildTx.js.map +1 -1
- package/dist/hooks/swap/prices/market/mutations/useSendMarketSwapTx.js.map +1 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.d.ts +14 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.d.ts.map +1 -1
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.js +60 -2
- package/dist/hooks/swap/prices/market/queries/useMarketPriceQuery.js.map +1 -1
- package/dist/hooks/swap/prices/market/queries/useSpenderAndContracts.js.map +1 -1
- package/dist/hooks/swap/prices/usePricesParams.js.map +1 -1
- package/dist/hooks/swap/prices/useSwapPrices.js.map +1 -1
- package/dist/hooks/swap/prices/useTokenInputsFromPrice.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/common/errors.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/common/useApproveOrPermit.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/common/useConstructGasParams.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/common/useSignPermit1Or2.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts +5 -4
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js +207 -458
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.js +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaSwapStep.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.d.ts +1 -0
- package/dist/hooks/swap/tradeFlow/useMarketFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js +210 -411
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketSwapStep.js.map +1 -1
- package/dist/hooks/tokens/allowance/useGenericTokenAllowance.js.map +1 -1
- package/dist/hooks/tokens/allowance/useTokenAllowance.js.map +1 -1
- package/dist/hooks/tokens/balances/queries.js.map +1 -1
- package/dist/hooks/tokens/balances/useAttachTokenBalanceMultichain.d.ts.map +1 -1
- package/dist/hooks/tokens/balances/useAttachTokenBalanceMultichain.js +18 -7
- package/dist/hooks/tokens/balances/useAttachTokenBalanceMultichain.js.map +1 -1
- package/dist/hooks/tokens/balances/useInvalidateTokenData.d.ts +3 -2
- package/dist/hooks/tokens/balances/useInvalidateTokenData.d.ts.map +1 -1
- package/dist/hooks/tokens/balances/useInvalidateTokenData.js +60 -77
- package/dist/hooks/tokens/balances/useInvalidateTokenData.js.map +1 -1
- package/dist/hooks/tokens/balances/useIsInsufficientTokenBalance.js.map +1 -1
- package/dist/hooks/tokens/balances/useMultichainTokenBalances.js.map +1 -1
- package/dist/hooks/tokens/balances/useSelectedTokenBalances.d.ts +5 -0
- package/dist/hooks/tokens/balances/useSelectedTokenBalances.d.ts.map +1 -0
- package/dist/hooks/tokens/balances/useSelectedTokenBalances.js +38 -0
- package/dist/hooks/tokens/balances/useSelectedTokenBalances.js.map +1 -0
- package/dist/hooks/tokens/balances/useTokenBalance.d.ts +15 -0
- package/dist/hooks/tokens/balances/useTokenBalance.d.ts.map +1 -1
- package/dist/hooks/tokens/balances/useTokenBalance.js +2 -0
- package/dist/hooks/tokens/balances/useTokenBalance.js.map +1 -1
- package/dist/hooks/tokens/prices/queries.js.map +1 -1
- package/dist/hooks/tokens/prices/useMultichainTokenPrices.js.map +1 -1
- package/dist/hooks/tokens/prices/useTokenPrices.js.map +1 -1
- package/dist/hooks/tokens/useNativeToken.js.map +1 -1
- package/dist/hooks/tokens/useTokenLists.js.map +1 -1
- package/dist/hooks/tokens/useTokenTaxFee.js.map +1 -1
- package/dist/hooks/tokens/useTokensByAddress.js.map +1 -1
- package/dist/hooks/tokens/useTokensFromAcross.js.map +1 -1
- package/dist/hooks/txs/mutations/useApprove.js.map +1 -1
- package/dist/hooks/txs/mutations/useDepositWeth.js.map +1 -1
- package/dist/hooks/txs/mutations/useSendTx.js.map +1 -1
- package/dist/hooks/txs/queries/useAwaitTx.js.map +1 -1
- package/dist/hooks/txs/queries/utils.d.ts +3 -0
- package/dist/hooks/txs/queries/utils.d.ts.map +1 -0
- package/dist/hooks/txs/queries/utils.js +6 -0
- package/dist/hooks/txs/queries/utils.js.map +1 -0
- package/dist/hooks/useAvailableCrosses.js.map +1 -1
- package/dist/hooks/useBridgeInfo.js.map +1 -1
- package/dist/hooks/useDebouncedInputState.js.map +1 -1
- package/dist/hooks/useEIP1559Enabled.js.map +1 -1
- package/dist/hooks/useGlobalDeltaEnabled.js.map +1 -1
- package/dist/hooks/useIsCrosschainPossible.js.map +1 -1
- package/dist/hooks/useMinViemClient.js.map +1 -1
- package/dist/hooks/useSDK.js +1 -1
- package/dist/hooks/useSDK.js.map +1 -1
- package/dist/hooks/useSlippage.js.map +1 -1
- package/dist/lib/constants/index.d.ts +1 -1
- package/dist/lib/constants/index.d.ts.map +1 -1
- package/dist/lib/constants/index.js +1 -1
- package/dist/lib/constants/index.js.map +1 -1
- package/dist/lib/ipfs.js.map +1 -1
- package/dist/lib/queryClient.d.ts.map +1 -1
- package/dist/lib/queryClient.js +32 -2
- package/dist/lib/queryClient.js.map +1 -1
- package/dist/lib/utils/copyToClipboard.js.map +1 -1
- package/dist/lib/utils/delta.js.map +1 -1
- package/dist/lib/utils/formatTokenBalance.js.map +1 -1
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/logger.js.map +1 -1
- package/dist/lib/utils/price.d.ts +2 -6
- package/dist/lib/utils/price.d.ts.map +1 -1
- package/dist/lib/utils/price.js +6 -13
- package/dist/lib/utils/price.js.map +1 -1
- package/dist/lib/utils/priceImpact.d.ts.map +1 -1
- package/dist/lib/utils/priceImpact.js +1 -1
- package/dist/lib/utils/priceImpact.js.map +1 -1
- package/dist/lib/utils/providerErrors.js.map +1 -1
- package/dist/lib/utils/removeZeroDecimals.js.map +1 -1
- package/dist/lib/utils/toasts.d.ts +2 -2
- package/dist/lib/utils/toasts.d.ts.map +1 -1
- package/dist/lib/utils/toasts.js +0 -24
- package/dist/lib/utils/toasts.js.map +1 -1
- package/dist/lib/web3/wagmi/config.d.ts +12 -2
- package/dist/lib/web3/wagmi/config.d.ts.map +1 -1
- package/dist/lib/web3/wagmi/config.js +5 -2
- package/dist/lib/web3/wagmi/config.js.map +1 -1
- package/dist/lib/web3/wagmi/constants.d.ts +12 -2
- package/dist/lib/web3/wagmi/constants.d.ts.map +1 -1
- package/dist/lib/web3/wagmi/isInsideSafeIframe.d.ts +25 -0
- package/dist/lib/web3/wagmi/isInsideSafeIframe.d.ts.map +1 -0
- package/dist/lib/web3/wagmi/isInsideSafeIframe.js +113 -0
- package/dist/lib/web3/wagmi/isInsideSafeIframe.js.map +1 -0
- package/dist/styles.css +84 -12
- package/dist/tokens/lists/constants.js.map +1 -1
- package/dist/tokens/lists/download.js.map +1 -1
- package/dist/tokens/lists/hooks.js.map +1 -1
- package/dist/tokens/lists/lists.json.d.ts +84 -2
- package/dist/tokens/lists/lists.json.js +104 -2
- package/dist/tokens/lists/lists.json.js.map +1 -1
- package/dist/tokens/lists/state/observer.js +2 -2
- package/dist/tokens/lists/state/observer.js.map +1 -1
- package/dist/tokens/lists/state/tokenListsActionsAtom.js.map +1 -1
- package/dist/tokens/lists/state/tokenListsStateAtom.d.ts +2 -2
- package/dist/tokens/lists/utils.js +1 -1
- package/dist/tokens/overrides.js.map +1 -1
- package/dist/tokens/queries.js.map +1 -1
- package/dist/tokens/stabeCoins/hooks.js.map +1 -1
- package/dist/tokens/state/constructTokens.js.map +1 -1
- package/dist/tokens/state/tokensAtom.js.map +1 -1
- package/dist/tokens/utils/filtering.js.map +1 -1
- package/dist/tokens/utils/sets.js.map +1 -1
- package/dist/tokens/utils/sorting.js.map +1 -1
- package/dist/tokens/utils/transferAmountsFromReceipt.d.ts +51 -0
- package/dist/tokens/utils/transferAmountsFromReceipt.d.ts.map +1 -0
- package/dist/tokens/utils/transferAmountsFromReceipt.js +281 -0
- package/dist/tokens/utils/transferAmountsFromReceipt.js.map +1 -0
- package/package.json +33 -32
- package/dist/hooks/swap/tradeFlow/common/useTrackedPrice.d.ts +0 -25
- package/dist/hooks/swap/tradeFlow/common/useTrackedPrice.d.ts.map +0 -1
- package/dist/hooks/swap/tradeFlow/common/useTrackedPrice.js +0 -103
- package/dist/hooks/swap/tradeFlow/common/useTrackedPrice.js.map +0 -1
- /package/dist/external/.pnpm/{react-compiler-runtime@19.1.0-rc.2_react@19.1.0 → react-compiler-runtime@19.1.0-rc.2_react@19.1.1}/external/react-compiler-runtime/dist/index.js +0 -0
- /package/dist/external/.pnpm/{vaul@1.1.2_patch_hash_07b36ba5def3805dde9d543a880ba9e4caf55e5eb58e544faaa2c186846bf3c1__15df56ff48174365d34843c037ea8a33 → vaul@1.1.2_patch_hash_07b36ba5def3805dde9d543a880ba9e4caf55e5eb58e544faaa2c186846bf3c1__7f2d7d5ed11750fbec42b3f5689c802d}/external/vaul/dist/index.js +0 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { d as distExports } from '../../_virtual/index.js';
|
|
2
|
+
import { decodeEventLog, erc20Abi } from 'viem';
|
|
3
|
+
import { getBalance } from 'viem/actions';
|
|
4
|
+
import { ETH_ADDRESS_LOWERCASE } from '../constants.js';
|
|
5
|
+
import { gatherObjectsByProp } from '../../lib/utils/index.js';
|
|
6
|
+
import { useQuery } from '@tanstack/react-query';
|
|
7
|
+
import { useClient } from 'wagmi';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { assert } from 'ts-essentials';
|
|
10
|
+
import { isETH } from './eth.js';
|
|
11
|
+
import { createLogger } from '../../lib/utils/logger.js';
|
|
12
|
+
|
|
13
|
+
const TRANSFER_EVENT_SIGNATURE = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
|
|
14
|
+
function getERC20TransferAmountsFromReceipt({
|
|
15
|
+
receipt,
|
|
16
|
+
tokens,
|
|
17
|
+
senderAddress,
|
|
18
|
+
receiverAddress
|
|
19
|
+
}) {
|
|
20
|
+
const result = gatherObjectsByProp(tokens, (token) => token.address.toLowerCase(), (token) => ({
|
|
21
|
+
token: token.address,
|
|
22
|
+
sentAmount: 0n,
|
|
23
|
+
receivedAmount: 0n
|
|
24
|
+
}));
|
|
25
|
+
const tokensSet = new Set(tokens.map((token) => token.address.toLowerCase()));
|
|
26
|
+
const fromAddressLowercase = senderAddress.toLowerCase();
|
|
27
|
+
const toAddressLowercase = receiverAddress.toLowerCase();
|
|
28
|
+
for (const log of receipt.logs) {
|
|
29
|
+
const logAddressLowercase = log.address.toLowerCase();
|
|
30
|
+
if (log.topics[0] === TRANSFER_EVENT_SIGNATURE && tokensSet.has(logAddressLowercase)) {
|
|
31
|
+
try {
|
|
32
|
+
const decoded = decodeEventLog({
|
|
33
|
+
abi: erc20Abi,
|
|
34
|
+
data: log.data,
|
|
35
|
+
topics: log.topics,
|
|
36
|
+
eventName: "Transfer"
|
|
37
|
+
});
|
|
38
|
+
const {
|
|
39
|
+
from: fromAddress,
|
|
40
|
+
to: toAddress,
|
|
41
|
+
value
|
|
42
|
+
} = decoded.args;
|
|
43
|
+
const tokenTransfer = result[logAddressLowercase];
|
|
44
|
+
if (!tokenTransfer) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (fromAddress.toLowerCase() === fromAddressLowercase) {
|
|
48
|
+
tokenTransfer.sentAmount += value;
|
|
49
|
+
}
|
|
50
|
+
if (toAddress.toLowerCase() === toAddressLowercase) {
|
|
51
|
+
tokenTransfer.receivedAmount += value;
|
|
52
|
+
}
|
|
53
|
+
} catch (_error) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
async function getNativeTokenTransfer({
|
|
61
|
+
receipt,
|
|
62
|
+
senderAddress,
|
|
63
|
+
receiverAddress,
|
|
64
|
+
client
|
|
65
|
+
}) {
|
|
66
|
+
const beforeBlockNumber = receipt.blockNumber - 1n;
|
|
67
|
+
const afterBlockNumber = receipt.blockNumber;
|
|
68
|
+
const senderPromises = [
|
|
69
|
+
// Get balances before the transaction
|
|
70
|
+
getBalance(client, {
|
|
71
|
+
address: senderAddress,
|
|
72
|
+
blockNumber: beforeBlockNumber
|
|
73
|
+
}),
|
|
74
|
+
// Get balances after the transaction
|
|
75
|
+
getBalance(client, {
|
|
76
|
+
address: senderAddress,
|
|
77
|
+
blockNumber: afterBlockNumber
|
|
78
|
+
})
|
|
79
|
+
];
|
|
80
|
+
const senderIsReceiver = senderAddress.toLowerCase() === receiverAddress.toLowerCase();
|
|
81
|
+
const receiverPromises = senderIsReceiver ? (
|
|
82
|
+
// reuse sender promises if sender is receiver
|
|
83
|
+
senderPromises
|
|
84
|
+
) : [
|
|
85
|
+
// Get balances before the transaction
|
|
86
|
+
getBalance(client, {
|
|
87
|
+
address: receiverAddress,
|
|
88
|
+
blockNumber: beforeBlockNumber
|
|
89
|
+
}),
|
|
90
|
+
// Get balances after the transaction
|
|
91
|
+
getBalance(client, {
|
|
92
|
+
address: receiverAddress,
|
|
93
|
+
blockNumber: afterBlockNumber
|
|
94
|
+
})
|
|
95
|
+
];
|
|
96
|
+
const [senderBalanceBefore, senderBalanceAfter, receiverBalanceBefore, receiverBalanceAfter] = await Promise.all([...senderPromises, ...receiverPromises]);
|
|
97
|
+
let sentAmount = senderBalanceBefore - senderBalanceAfter;
|
|
98
|
+
let receivedAmount = receiverBalanceAfter - receiverBalanceBefore;
|
|
99
|
+
const gasCost = receipt.gasUsed * receipt.effectiveGasPrice;
|
|
100
|
+
if (senderAddress.toLowerCase() === receipt.from.toLowerCase()) {
|
|
101
|
+
sentAmount -= gasCost;
|
|
102
|
+
}
|
|
103
|
+
if (senderAddress.toLowerCase() === receiverAddress.toLowerCase()) {
|
|
104
|
+
receivedAmount += gasCost;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
token: ETH_ADDRESS_LOWERCASE,
|
|
108
|
+
// Native token address
|
|
109
|
+
sentAmount: sentAmount > 0n ? sentAmount : 0n,
|
|
110
|
+
receivedAmount: receivedAmount > 0n ? receivedAmount : 0n
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async function getTokenTransfersFromReceipt({
|
|
114
|
+
receipt,
|
|
115
|
+
tokens,
|
|
116
|
+
senderAddress,
|
|
117
|
+
receiverAddress,
|
|
118
|
+
client
|
|
119
|
+
}) {
|
|
120
|
+
const tokensWithoutNative = tokens.filter((token) => !isETH(token));
|
|
121
|
+
const tokenTransfers = getERC20TransferAmountsFromReceipt({
|
|
122
|
+
receipt,
|
|
123
|
+
tokens: tokensWithoutNative,
|
|
124
|
+
senderAddress,
|
|
125
|
+
receiverAddress
|
|
126
|
+
});
|
|
127
|
+
if (tokensWithoutNative.length < tokens.length) {
|
|
128
|
+
const nativeTokenTransfer = await getNativeTokenTransfer({
|
|
129
|
+
receipt,
|
|
130
|
+
senderAddress,
|
|
131
|
+
receiverAddress,
|
|
132
|
+
client
|
|
133
|
+
});
|
|
134
|
+
tokenTransfers[ETH_ADDRESS_LOWERCASE] = nativeTokenTransfer;
|
|
135
|
+
}
|
|
136
|
+
return tokenTransfers;
|
|
137
|
+
}
|
|
138
|
+
function validateAmount({
|
|
139
|
+
calculatedAmount,
|
|
140
|
+
expectedAmount,
|
|
141
|
+
tolerancePercent = 15
|
|
142
|
+
// max slippage %
|
|
143
|
+
}) {
|
|
144
|
+
if (expectedAmount === 0n) {
|
|
145
|
+
return expectedAmount;
|
|
146
|
+
}
|
|
147
|
+
const tolerance = expectedAmount * BigInt(tolerancePercent) / 100n;
|
|
148
|
+
const minExpected = expectedAmount - tolerance;
|
|
149
|
+
const maxExpected = expectedAmount + tolerance;
|
|
150
|
+
if (calculatedAmount >= minExpected && calculatedAmount <= maxExpected) {
|
|
151
|
+
return calculatedAmount;
|
|
152
|
+
} else {
|
|
153
|
+
return expectedAmount;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const logger1 = createLogger("Swap:amounts:Expected");
|
|
157
|
+
const logger2 = createLogger("Swap:amounts:Detected");
|
|
158
|
+
function getTokenTransfersFromReceiptWithLimits({
|
|
159
|
+
detectedTokenTransfers,
|
|
160
|
+
expectedTokenTransfers
|
|
161
|
+
}) {
|
|
162
|
+
const validatedTokenTransfers = {};
|
|
163
|
+
logger1.once.log("Expected token transfers", expectedTokenTransfers);
|
|
164
|
+
logger2.once.log("Detected token transfers", detectedTokenTransfers);
|
|
165
|
+
for (const [tokenAddress, calculatedTransfer] of Object.entries(detectedTokenTransfers)) {
|
|
166
|
+
const expectedTransfer = expectedTokenTransfers[tokenAddress];
|
|
167
|
+
if (!expectedTransfer) {
|
|
168
|
+
validatedTokenTransfers[tokenAddress] = calculatedTransfer;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const validatedTransfer = {
|
|
172
|
+
token: calculatedTransfer.token,
|
|
173
|
+
sentAmount: validateAmount({
|
|
174
|
+
calculatedAmount: calculatedTransfer.sentAmount,
|
|
175
|
+
expectedAmount: expectedTransfer.sentAmount
|
|
176
|
+
}),
|
|
177
|
+
receivedAmount: validateAmount({
|
|
178
|
+
calculatedAmount: calculatedTransfer.receivedAmount,
|
|
179
|
+
expectedAmount: expectedTransfer.receivedAmount
|
|
180
|
+
})
|
|
181
|
+
};
|
|
182
|
+
validatedTokenTransfers[tokenAddress] = validatedTransfer;
|
|
183
|
+
}
|
|
184
|
+
return validatedTokenTransfers;
|
|
185
|
+
}
|
|
186
|
+
function useTokenTransfersFromReceipt(t0) {
|
|
187
|
+
const $ = distExports.c(20);
|
|
188
|
+
const {
|
|
189
|
+
receipt,
|
|
190
|
+
tokens,
|
|
191
|
+
senderAddress,
|
|
192
|
+
receiverAddress,
|
|
193
|
+
expectedTokenTransfers,
|
|
194
|
+
chainId
|
|
195
|
+
} = t0;
|
|
196
|
+
let t1;
|
|
197
|
+
if ($[0] !== chainId) {
|
|
198
|
+
t1 = {
|
|
199
|
+
chainId
|
|
200
|
+
};
|
|
201
|
+
$[0] = chainId;
|
|
202
|
+
$[1] = t1;
|
|
203
|
+
} else {
|
|
204
|
+
t1 = $[1];
|
|
205
|
+
}
|
|
206
|
+
const client = useClient(t1);
|
|
207
|
+
let t2;
|
|
208
|
+
if ($[2] !== expectedTokenTransfers) {
|
|
209
|
+
t2 = (data) => {
|
|
210
|
+
if (!expectedTokenTransfers) {
|
|
211
|
+
return data;
|
|
212
|
+
}
|
|
213
|
+
return getTokenTransfersFromReceiptWithLimits({
|
|
214
|
+
detectedTokenTransfers: data,
|
|
215
|
+
expectedTokenTransfers
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
$[2] = expectedTokenTransfers;
|
|
219
|
+
$[3] = t2;
|
|
220
|
+
} else {
|
|
221
|
+
t2 = $[3];
|
|
222
|
+
}
|
|
223
|
+
const select = t2;
|
|
224
|
+
const t3 = receipt?.transactionHash;
|
|
225
|
+
const t4 = receipt?.logs.length;
|
|
226
|
+
let t5;
|
|
227
|
+
if ($[4] !== receiverAddress || $[5] !== senderAddress || $[6] !== t3 || $[7] !== t4) {
|
|
228
|
+
t5 = ["token-transfers-from-receipt", t3, t4, senderAddress, receiverAddress];
|
|
229
|
+
$[4] = receiverAddress;
|
|
230
|
+
$[5] = senderAddress;
|
|
231
|
+
$[6] = t3;
|
|
232
|
+
$[7] = t4;
|
|
233
|
+
$[8] = t5;
|
|
234
|
+
} else {
|
|
235
|
+
t5 = $[8];
|
|
236
|
+
}
|
|
237
|
+
let t6;
|
|
238
|
+
if ($[9] !== client || $[10] !== receipt || $[11] !== receiverAddress || $[12] !== senderAddress || $[13] !== tokens) {
|
|
239
|
+
t6 = async () => {
|
|
240
|
+
assert(receipt, "Receipt is required");
|
|
241
|
+
assert(senderAddress, "Sender address is required");
|
|
242
|
+
assert(receiverAddress, "Receiver address is required");
|
|
243
|
+
return getTokenTransfersFromReceipt({
|
|
244
|
+
receipt,
|
|
245
|
+
tokens,
|
|
246
|
+
senderAddress,
|
|
247
|
+
receiverAddress,
|
|
248
|
+
client
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
$[9] = client;
|
|
252
|
+
$[10] = receipt;
|
|
253
|
+
$[11] = receiverAddress;
|
|
254
|
+
$[12] = senderAddress;
|
|
255
|
+
$[13] = tokens;
|
|
256
|
+
$[14] = t6;
|
|
257
|
+
} else {
|
|
258
|
+
t6 = $[14];
|
|
259
|
+
}
|
|
260
|
+
const t7 = !!receipt && receipt.logs.length > 0 && tokens.length > 0 && !!senderAddress && !!receiverAddress;
|
|
261
|
+
let t8;
|
|
262
|
+
if ($[15] !== select || $[16] !== t5 || $[17] !== t6 || $[18] !== t7) {
|
|
263
|
+
t8 = {
|
|
264
|
+
queryKey: t5,
|
|
265
|
+
queryFn: t6,
|
|
266
|
+
select,
|
|
267
|
+
enabled: t7
|
|
268
|
+
};
|
|
269
|
+
$[15] = select;
|
|
270
|
+
$[16] = t5;
|
|
271
|
+
$[17] = t6;
|
|
272
|
+
$[18] = t7;
|
|
273
|
+
$[19] = t8;
|
|
274
|
+
} else {
|
|
275
|
+
t8 = $[19];
|
|
276
|
+
}
|
|
277
|
+
return useQuery(t8);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export { getERC20TransferAmountsFromReceipt, getNativeTokenTransfer, getTokenTransfersFromReceipt, getTokenTransfersFromReceiptWithLimits, useTokenTransfersFromReceipt };
|
|
281
|
+
//# sourceMappingURL=transferAmountsFromReceipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transferAmountsFromReceipt.js","sources":["../../../src/tokens/utils/transferAmountsFromReceipt.ts"],"sourcesContent":["import {\n type Address,\n type TransactionReceipt,\n type Client,\n decodeEventLog,\n erc20Abi,\n} from \"viem\";\nimport { getBalance } from \"viem/actions\";\nimport type { Token } from \"../state/types\";\nimport { ETH_ADDRESS_LOWERCASE } from \"../constants\";\nimport { gatherObjectsByProp } from \"@/lib/utils\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useClient } from \"wagmi\";\nimport type { SupportedChainId } from \"@/lib/web3/wagmi/types\";\nimport { useCallback } from \"react\";\nimport { assert, type MarkOptional } from \"ts-essentials\";\nimport { isETH } from \"./eth\";\nimport { createLogger } from \"@/lib/utils/logger\";\n\ntype TransferAmountsFromReceiptInput = {\n receipt: TransactionReceipt;\n tokens: Pick<Token, \"address\">[];\n senderAddress: Address;\n receiverAddress: Address;\n};\n\nexport type TokenTransfers = {\n token: Address;\n sentAmount: bigint;\n receivedAmount: bigint;\n};\n\ntype TransferAmountsFromReceiptResult = Record<Address, TokenTransfers>;\n\n// ERC20 Transfer event signature: Transfer(address,address,uint256)\nconst TRANSFER_EVENT_SIGNATURE =\n \"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\";\n\n// give TransactionReceipt and tokens finds all transfers of Tokens to receiverAddress and returns amounts\nexport function getERC20TransferAmountsFromReceipt({\n receipt,\n tokens,\n senderAddress,\n receiverAddress,\n}: TransferAmountsFromReceiptInput): TransferAmountsFromReceiptResult {\n // Initialize result mapping with one entry per token\n const result: Record<Address, TokenTransfers> = gatherObjectsByProp(\n tokens,\n (token) => token.address.toLowerCase(),\n (token) => ({\n token: token.address as Address,\n sentAmount: 0n,\n receivedAmount: 0n,\n })\n );\n\n // Create a map for quick token lookup\n const tokensSet = new Set(tokens.map((token) => token.address.toLowerCase()));\n\n const fromAddressLowercase = senderAddress.toLowerCase();\n const toAddressLowercase = receiverAddress.toLowerCase();\n\n // Parse all logs in the transaction receipt\n for (const log of receipt.logs) {\n const logAddressLowercase = log.address.toLowerCase() as Address;\n // Check if this is a Transfer event from one of our tokens\n if (\n log.topics[0] === TRANSFER_EVENT_SIGNATURE &&\n tokensSet.has(logAddressLowercase)\n ) {\n try {\n // Parse the Transfer event parameters\n // topics[0] = event signature\n // topics[1] = from address (padded to 32 bytes)\n // topics[2] = to address (padded to 32 bytes)\n // data = value (uint256)\n\n const decoded = decodeEventLog({\n abi: erc20Abi,\n data: log.data,\n topics: log.topics,\n eventName: \"Transfer\",\n });\n\n const { from: fromAddress, to: toAddress, value } = decoded.args;\n\n const tokenTransfer = result[logAddressLowercase];\n if (!tokenTransfer) {\n continue;\n }\n\n // Check if the transfer is from sender to someone else\n if (fromAddress.toLowerCase() === fromAddressLowercase) {\n tokenTransfer.sentAmount += value;\n }\n // Check if the transfer is to receiver from someone else\n if (toAddress.toLowerCase() === toAddressLowercase) {\n tokenTransfer.receivedAmount += value;\n }\n } catch (_error) {\n // If parsing fails, skip this log\n continue;\n }\n }\n }\n\n return result;\n}\n\ntype NativeTokenTransferInput = {\n receipt: TransactionReceipt;\n senderAddress: Address;\n receiverAddress: Address;\n client: Client;\n};\n\nexport async function getNativeTokenTransfer({\n receipt,\n senderAddress,\n receiverAddress,\n client,\n}: NativeTokenTransferInput): Promise<TokenTransfers> {\n const beforeBlockNumber = receipt.blockNumber - 1n;\n const afterBlockNumber = receipt.blockNumber;\n\n /*\n if the transaction was the only one transaction involving the sender and receiver\n in the block it was mined, and if the transaction was a SwapTransaction only,\n not some bulk transaction or a flashbot transaction, then we can consider\n that the ETH balances difference matches the ETH Swap amount.\n */\n\n const senderPromises = [\n // Get balances before the transaction\n getBalance(client, {\n address: senderAddress,\n blockNumber: beforeBlockNumber,\n }),\n // Get balances after the transaction\n getBalance(client, {\n address: senderAddress,\n blockNumber: afterBlockNumber,\n }),\n ] as const;\n\n const senderIsReceiver =\n senderAddress.toLowerCase() === receiverAddress.toLowerCase();\n\n const receiverPromises = senderIsReceiver\n ? // reuse sender promises if sender is receiver\n senderPromises\n : ([\n // Get balances before the transaction\n getBalance(client, {\n address: receiverAddress,\n blockNumber: beforeBlockNumber,\n }),\n // Get balances after the transaction\n getBalance(client, {\n address: receiverAddress,\n blockNumber: afterBlockNumber,\n }),\n ] as const);\n\n const [\n senderBalanceBefore,\n senderBalanceAfter,\n receiverBalanceBefore,\n receiverBalanceAfter,\n ] = await Promise.all([...senderPromises, ...receiverPromises]);\n\n // Calculate the differences\n let sentAmount = senderBalanceBefore - senderBalanceAfter; // difference in balances = sent ETH + paid gas\n let receivedAmount = receiverBalanceAfter - receiverBalanceBefore;\n const gasCost = receipt.gasUsed * receipt.effectiveGasPrice;\n\n // if sender is the transaction sender (it may not be if a Relayer was involved)\n if (senderAddress.toLowerCase() === receipt.from.toLowerCase()) {\n // Adjust sentAmount for gas:\n // Subtract gas cost from sentAmount to get actual ETH sent (excluding gas fees)\n sentAmount -= gasCost;\n }\n\n // if sender is receiver, then need to adjust receivedAmount for gas\n if (senderAddress.toLowerCase() === receiverAddress.toLowerCase()) {\n receivedAmount += gasCost; // gas was paid out of the receivedAmount, so make this the amount before gas paid\n }\n\n return {\n token: ETH_ADDRESS_LOWERCASE, // Native token address\n sentAmount: sentAmount > 0n ? sentAmount : 0n,\n receivedAmount: receivedAmount > 0n ? receivedAmount : 0n,\n };\n}\n\ntype TokenTransfersFromReceiptInput = TransferAmountsFromReceiptInput & {\n client: Client;\n};\n\nexport async function getTokenTransfersFromReceipt({\n receipt,\n tokens,\n senderAddress,\n receiverAddress,\n client,\n}: TokenTransfersFromReceiptInput): Promise<TransferAmountsFromReceiptResult> {\n const tokensWithoutNative = tokens.filter((token) => !isETH(token));\n\n const tokenTransfers = getERC20TransferAmountsFromReceipt({\n receipt,\n tokens: tokensWithoutNative,\n senderAddress,\n receiverAddress,\n });\n\n // there was a native Token in the list\n if (tokensWithoutNative.length < tokens.length) {\n const nativeTokenTransfer = await getNativeTokenTransfer({\n receipt,\n senderAddress,\n receiverAddress,\n client,\n });\n\n tokenTransfers[ETH_ADDRESS_LOWERCASE] = nativeTokenTransfer;\n }\n\n return tokenTransfers;\n}\n\ntype TokenTransfersFromReceiptWithLimitsInput = {\n detectedTokenTransfers: Record<Address, TokenTransfers>;\n expectedTokenTransfers: Record<Address, TokenTransfers>;\n};\n\n// Helper function to validate an amount against expected value with tolerance\nfunction validateAmount({\n calculatedAmount,\n expectedAmount,\n tolerancePercent = 15, // max slippage %\n}: {\n calculatedAmount: bigint;\n expectedAmount: bigint;\n tolerancePercent?: number;\n}): bigint {\n if (expectedAmount === 0n) {\n // If expected is 0, use expected\n return expectedAmount;\n }\n\n // Check if calculated is within tolerance of expected\n const tolerance = (expectedAmount * BigInt(tolerancePercent)) / 100n;\n const minExpected = expectedAmount - tolerance;\n const maxExpected = expectedAmount + tolerance;\n\n if (calculatedAmount >= minExpected && calculatedAmount <= maxExpected) {\n return calculatedAmount;\n } else {\n return expectedAmount;\n }\n}\n\nconst logger1 = createLogger(\"Swap:amounts:Expected\");\nconst logger2 = createLogger(\"Swap:amounts:Detected\");\n\nexport function getTokenTransfersFromReceiptWithLimits({\n detectedTokenTransfers,\n expectedTokenTransfers,\n}: TokenTransfersFromReceiptWithLimitsInput): TransferAmountsFromReceiptResult {\n // Validate and adjust amounts based on expected values\n const validatedTokenTransfers: Record<Address, TokenTransfers> = {};\n\n logger1.once.log(\"Expected token transfers\", expectedTokenTransfers);\n logger2.once.log(\"Detected token transfers\", detectedTokenTransfers);\n\n for (const [tokenAddress, calculatedTransfer] of Object.entries(\n detectedTokenTransfers\n )) {\n const expectedTransfer = expectedTokenTransfers[tokenAddress as Address];\n\n if (!expectedTransfer) {\n // No expected value, use calculated\n validatedTokenTransfers[tokenAddress as Address] = calculatedTransfer;\n continue;\n }\n\n const validatedTransfer: TokenTransfers = {\n token: calculatedTransfer.token,\n sentAmount: validateAmount({\n calculatedAmount: calculatedTransfer.sentAmount,\n expectedAmount: expectedTransfer.sentAmount,\n }),\n receivedAmount: validateAmount({\n calculatedAmount: calculatedTransfer.receivedAmount,\n expectedAmount: expectedTransfer.receivedAmount,\n }),\n };\n\n validatedTokenTransfers[tokenAddress as Address] = validatedTransfer;\n }\n\n return validatedTokenTransfers;\n}\n\ntype UseTokenTransfersFromReceiptInput = TransferAmountsFromReceiptInput & {\n chainId: SupportedChainId;\n expectedTokenTransfers: Record<Address, TokenTransfers>;\n};\n\n/**\n * @param expectedTokenTransfers - expected token transfers, if provided, will be used to validate the detected token transfers\n * @param chainId - chain id\n * @param receipt - transaction receipt\n * @param tokens - tokens\n * @param senderAddress - sender address\n * @param receiverAddress - receiver address\n * @returns - token transfers from receipt validated against expected token transfers\n * @note - ETH transfers are a best guess, and may not be accurate (falls back to expected token transfers)\n */\nexport function useTokenTransfersFromReceipt({\n receipt,\n tokens,\n senderAddress,\n receiverAddress,\n expectedTokenTransfers,\n chainId,\n}: MarkOptional<\n UseTokenTransfersFromReceiptInput,\n \"receipt\" | \"senderAddress\" | \"receiverAddress\" | \"expectedTokenTransfers\"\n>): UseQueryResult<TransferAmountsFromReceiptResult, Error> {\n const client = useClient({ chainId });\n\n const select = useCallback(\n (data: TransferAmountsFromReceiptResult) => {\n if (!expectedTokenTransfers) {\n return data;\n }\n\n return getTokenTransfersFromReceiptWithLimits({\n detectedTokenTransfers: data,\n expectedTokenTransfers,\n });\n },\n [expectedTokenTransfers]\n );\n\n return useQuery({\n queryKey: [\n \"token-transfers-from-receipt\",\n receipt?.transactionHash,\n receipt?.logs.length,\n senderAddress,\n receiverAddress,\n ],\n queryFn: async () => {\n assert(receipt, \"Receipt is required\");\n assert(senderAddress, \"Sender address is required\");\n assert(receiverAddress, \"Receiver address is required\");\n\n return getTokenTransfersFromReceipt({\n receipt,\n tokens,\n senderAddress,\n receiverAddress,\n client,\n });\n },\n select,\n enabled:\n !!receipt &&\n receipt.logs.length > 0 &&\n tokens.length > 0 &&\n !!senderAddress &&\n !!receiverAddress,\n });\n}\n"],"names":["TRANSFER_EVENT_SIGNATURE","getERC20TransferAmountsFromReceipt","receipt","tokens","senderAddress","receiverAddress","result","gatherObjectsByProp","token","address","toLowerCase","sentAmount","receivedAmount","tokensSet","Set","map","fromAddressLowercase","toAddressLowercase","log","logs","logAddressLowercase","topics","has","decoded","decodeEventLog","abi","erc20Abi","data","eventName","from","fromAddress","to","toAddress","value","args","tokenTransfer","_error","getNativeTokenTransfer","client","beforeBlockNumber","blockNumber","afterBlockNumber","senderPromises","getBalance","senderIsReceiver","receiverPromises","senderBalanceBefore","senderBalanceAfter","receiverBalanceBefore","receiverBalanceAfter","Promise","all","gasCost","gasUsed","effectiveGasPrice","ETH_ADDRESS_LOWERCASE","getTokenTransfersFromReceipt","tokensWithoutNative","filter","isETH","tokenTransfers","length","nativeTokenTransfer","validateAmount","calculatedAmount","expectedAmount","tolerancePercent","tolerance","BigInt","minExpected","maxExpected","logger1","createLogger","logger2","getTokenTransfersFromReceiptWithLimits","detectedTokenTransfers","expectedTokenTransfers","validatedTokenTransfers","once","tokenAddress","calculatedTransfer","Object","entries","expectedTransfer","validatedTransfer","useTokenTransfersFromReceipt","t0","$","_c","chainId","t1","useClient","t2","select","t3","transactionHash","t4","t5","t6","assert","t7","t8","queryKey","queryFn","enabled","useQuery"],"mappings":";;;;;;;;;;;;AAmCA,MAAMA,wBAAAA,GACJ,oEAAA;AAGK,SAASC,kCAAAA,CAAmC;AAAA,EACjDC,OAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC;AAC+B,CAAA,EAAqC;AAEpE,EAAA,MAAMC,MAAAA,GAA0CC,oBAC9CJ,MAAAA,EACCK,CAAAA,KAAAA,KAAUA,MAAMC,OAAAA,CAAQC,WAAAA,IACxBF,CAAAA,KAAAA,MAAW;AAAA,IACVA,OAAOA,KAAAA,CAAMC,OAAAA;AAAAA,IACbE,UAAAA,EAAY,EAAA;AAAA,IACZC,cAAAA,EAAgB;AAAA,GAClB,CACF,CAAA;AAGA,EAAA,MAAMC,SAAAA,GAAY,IAAIC,GAAAA,CAAIX,MAAAA,CAAOY,GAAAA,CAAKP,WAAUA,KAAAA,CAAMC,OAAAA,CAAQC,WAAAA,EAAa,CAAC,CAAA;AAE5E,EAAA,MAAMM,oBAAAA,GAAuBZ,cAAcM,WAAAA,EAAY;AACvD,EAAA,MAAMO,kBAAAA,GAAqBZ,gBAAgBK,WAAAA,EAAY;AAGvD,EAAA,KAAA,MAAWQ,GAAAA,IAAOhB,QAAQiB,IAAAA,EAAM;AAC9B,IAAA,MAAMC,mBAAAA,GAAsBF,GAAAA,CAAIT,OAAAA,CAAQC,WAAAA,EAAY;AAEpD,IAAA,IACEQ,GAAAA,CAAIG,OAAO,CAAC,CAAA,KAAMrB,4BAClBa,SAAAA,CAAUS,GAAAA,CAAIF,mBAAmB,CAAA,EACjC;AACA,MAAA,IAAI;AAOF,QAAA,MAAMG,UAAUC,cAAAA,CAAe;AAAA,UAC7BC,GAAAA,EAAKC,QAAAA;AAAAA,UACLC,MAAMT,GAAAA,CAAIS,IAAAA;AAAAA,UACVN,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bf,CAAA;AAAC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velora-dex/widget",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"dev": "vite build --watch",
|
|
21
21
|
"dev:configurator": "vite --clearScreen false",
|
|
22
22
|
"build": "tsc -b && vite build",
|
|
23
|
+
"prepack": "pnpm build",
|
|
23
24
|
"postbuild": "pnpm postprocess:css",
|
|
24
25
|
"postprocess:css": "sed -i.bak 's/:root,\\s*:host/.velora-widget/g' dist/styles.css && rm dist/styles.css.bak",
|
|
25
26
|
"build:configurator": "tsc -b && vite build --config vite.configurator.config.ts",
|
|
@@ -29,36 +30,36 @@
|
|
|
29
30
|
"analyze:circular-deps-graph": "madge --circular $(find ./src -name '*.ts' -o -name '*.tsx') --image graph.svg"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@eslint/js": "^9.
|
|
33
|
-
"@tailwindcss/vite": "^4.1.
|
|
34
|
-
"@tanstack/eslint-plugin-query": "^5.
|
|
33
|
+
"@eslint/js": "^9.32.0",
|
|
34
|
+
"@tailwindcss/vite": "^4.1.11",
|
|
35
|
+
"@tanstack/eslint-plugin-query": "^5.83.1",
|
|
35
36
|
"@types/big.js": "^6.2.2",
|
|
36
|
-
"@types/node": "^20.19.
|
|
37
|
-
"@types/react": "^19.1.
|
|
38
|
-
"@types/react-dom": "^19.1.
|
|
39
|
-
"@vitejs/plugin-react": "^4.
|
|
37
|
+
"@types/node": "^20.19.9",
|
|
38
|
+
"@types/react": "^19.1.9",
|
|
39
|
+
"@types/react-dom": "^19.1.7",
|
|
40
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
40
41
|
"babel-plugin-react-compiler": "19.1.0-rc.2",
|
|
41
|
-
"eslint": "^9.
|
|
42
|
+
"eslint": "^9.32.0",
|
|
42
43
|
"eslint-plugin-react-hooks": "6.0.0-rc1",
|
|
43
44
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
44
|
-
"globals": "^16.
|
|
45
|
+
"globals": "^16.3.0",
|
|
45
46
|
"madge": "^8.0.0",
|
|
46
|
-
"react": "^19.1.
|
|
47
|
-
"react-dom": "^19.1.
|
|
48
|
-
"tailwindcss": "^4.1.
|
|
49
|
-
"tw-animate-css": "^1.3.
|
|
50
|
-
"typescript": "~5.
|
|
51
|
-
"typescript-eslint": "^8.
|
|
52
|
-
"vite": "^
|
|
47
|
+
"react": "^19.1.1",
|
|
48
|
+
"react-dom": "^19.1.1",
|
|
49
|
+
"tailwindcss": "^4.1.11",
|
|
50
|
+
"tw-animate-css": "^1.3.6",
|
|
51
|
+
"typescript": "~5.9.2",
|
|
52
|
+
"typescript-eslint": "^8.39.0",
|
|
53
|
+
"vite": "^7.0.6",
|
|
53
54
|
"vite-plugin-dts": "^4.5.4",
|
|
54
55
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
55
|
-
"vite-plugin-node-polyfills": "^0.
|
|
56
|
+
"vite-plugin-node-polyfills": "^0.24.0",
|
|
56
57
|
"vite-plugin-svgr": "^4.3.0"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"@lottiefiles/dotlottie-react": "^0.14.4",
|
|
60
|
-
"@privy-io/react-auth": "^2.
|
|
61
|
-
"@privy-io/wagmi": "^1.0.
|
|
61
|
+
"@privy-io/react-auth": "^2.21.1",
|
|
62
|
+
"@privy-io/wagmi": "^1.0.5",
|
|
62
63
|
"@radix-ui/react-accordion": "^1.2.11",
|
|
63
64
|
"@radix-ui/react-dialog": "^1.1.14",
|
|
64
65
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
@@ -67,31 +68,31 @@
|
|
|
67
68
|
"@radix-ui/react-slot": "^1.2.3",
|
|
68
69
|
"@radix-ui/react-switch": "^1.2.5",
|
|
69
70
|
"@radix-ui/react-tooltip": "^1.2.7",
|
|
70
|
-
"@tanstack/react-pacer": "^0.
|
|
71
|
-
"@tanstack/react-query": "^5.
|
|
72
|
-
"@tanstack/react-query-devtools": "^5.
|
|
73
|
-
"@tanstack/react-virtual": "^3.13.
|
|
71
|
+
"@tanstack/react-pacer": "^0.14.0",
|
|
72
|
+
"@tanstack/react-query": "^5.84.1",
|
|
73
|
+
"@tanstack/react-query-devtools": "^5.84.1",
|
|
74
|
+
"@tanstack/react-virtual": "^3.13.12",
|
|
74
75
|
"@uniswap/token-lists": "1.0.0-beta.34",
|
|
75
|
-
"@velora-dex/sdk": "
|
|
76
|
-
"@wagmi/core": "^2.
|
|
77
|
-
"axios": "^1.
|
|
76
|
+
"@velora-dex/sdk": "8.1.1-dev.1",
|
|
77
|
+
"@wagmi/core": "^2.18.1",
|
|
78
|
+
"axios": "^1.11.0",
|
|
78
79
|
"big.js": "^7.0.1",
|
|
79
80
|
"class-variance-authority": "^0.7.1",
|
|
80
81
|
"clsx": "^2.1.1",
|
|
81
82
|
"copy-to-clipboard": "^3.3.3",
|
|
82
83
|
"immer": "^10.1.1",
|
|
83
|
-
"jotai": "^2.
|
|
84
|
+
"jotai": "^2.13.0",
|
|
84
85
|
"jotai-devtools": "^0.12.0",
|
|
85
86
|
"jotai-immer": "^0.4.1",
|
|
86
|
-
"lucide-react": "^0.
|
|
87
|
+
"lucide-react": "^0.536.0",
|
|
87
88
|
"react-compiler-runtime": "19.1.0-rc.2",
|
|
88
89
|
"react-number-format": "^5.4.4",
|
|
89
|
-
"sonner": "^2.0.
|
|
90
|
+
"sonner": "^2.0.7",
|
|
90
91
|
"tailwind-merge": "^3.3.1",
|
|
91
92
|
"ts-essentials": "^10.1.1",
|
|
92
93
|
"vaul": "^1.1.2",
|
|
93
|
-
"viem": "
|
|
94
|
-
"wagmi": "^2.
|
|
94
|
+
"viem": "^2.33.2",
|
|
95
|
+
"wagmi": "^2.16.1"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"react": "^18.x || ^19.x",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
type MinPriceObject = {
|
|
2
|
-
srcAmount: string;
|
|
3
|
-
destAmount: string;
|
|
4
|
-
};
|
|
5
|
-
type UseTrackedPriceInput<P extends MinPriceObject> = {
|
|
6
|
-
price?: P;
|
|
7
|
-
slippage: number;
|
|
8
|
-
side: "BUY" | "SELL";
|
|
9
|
-
};
|
|
10
|
-
type UseTrackedPriceResult<P extends MinPriceObject> = {
|
|
11
|
-
set: {
|
|
12
|
-
usingPrice(price?: P | null): void;
|
|
13
|
-
finalPrice(price?: P | null): void;
|
|
14
|
-
approvedAmount(amount?: bigint | null): void;
|
|
15
|
-
};
|
|
16
|
-
get: {
|
|
17
|
-
usingPrice(): P | null;
|
|
18
|
-
finalPrice(): P | null;
|
|
19
|
-
approvedAmount(): bigint | null;
|
|
20
|
-
};
|
|
21
|
-
resetTrackedPrice: () => void;
|
|
22
|
-
};
|
|
23
|
-
export declare function useTrackedPrice<P extends MinPriceObject>({ price, side, slippage, }: UseTrackedPriceInput<P>): UseTrackedPriceResult<P>;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=useTrackedPrice.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTrackedPrice.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/swap/tradeFlow/common/useTrackedPrice.ts"],"names":[],"mappings":"AAGA,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,oBAAoB,CAAC,CAAC,SAAS,cAAc,IAAI;IACpD,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;CACtB,CAAC;AAEF,KAAK,qBAAqB,CAAC,CAAC,SAAS,cAAc,IAAI;IACrD,GAAG,EAAE;QACH,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QACnC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QACnC,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;KAC9C,CAAC;IACF,GAAG,EAAE;QACH,UAAU,IAAI,CAAC,GAAG,IAAI,CAAC;QACvB,UAAU,IAAI,CAAC,GAAG,IAAI,CAAC;QACvB,cAAc,IAAI,MAAM,GAAG,IAAI,CAAC;KACjC,CAAC;IACF,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,EACxD,KAAK,EACL,IAAI,EACJ,QAAQ,GACT,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAgFpD"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { d as distExports } from '../../../../_virtual/index.js';
|
|
2
|
-
import { applySlippage } from '../../../../lib/utils/price.js';
|
|
3
|
-
import { useRef, useLayoutEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
function useTrackedPrice(t0) {
|
|
6
|
-
const $ = distExports.c(8);
|
|
7
|
-
const {
|
|
8
|
-
price,
|
|
9
|
-
side,
|
|
10
|
-
slippage
|
|
11
|
-
} = t0;
|
|
12
|
-
const usingPriceRef = useRef(price || null);
|
|
13
|
-
const finalPriceRef = useRef(null);
|
|
14
|
-
const approvedAmountRef = useRef(null);
|
|
15
|
-
let t1;
|
|
16
|
-
let t2;
|
|
17
|
-
if ($[0] !== price || $[1] !== side || $[2] !== slippage) {
|
|
18
|
-
t1 = () => {
|
|
19
|
-
if (!price) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (finalPriceRef.current) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (approvedAmountRef.current) {
|
|
26
|
-
const amountsAfterSlippage = applySlippage({
|
|
27
|
-
srcAmount: price.srcAmount,
|
|
28
|
-
destAmount: price.destAmount
|
|
29
|
-
}, slippage, side);
|
|
30
|
-
if (BigInt(amountsAfterSlippage.srcAmount) > approvedAmountRef.current) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
usingPriceRef.current = price;
|
|
35
|
-
};
|
|
36
|
-
t2 = [price, side, slippage];
|
|
37
|
-
$[0] = price;
|
|
38
|
-
$[1] = side;
|
|
39
|
-
$[2] = slippage;
|
|
40
|
-
$[3] = t1;
|
|
41
|
-
$[4] = t2;
|
|
42
|
-
} else {
|
|
43
|
-
t1 = $[3];
|
|
44
|
-
t2 = $[4];
|
|
45
|
-
}
|
|
46
|
-
useLayoutEffect(t1, t2);
|
|
47
|
-
let t3;
|
|
48
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
|
-
t3 = () => {
|
|
50
|
-
usingPriceRef.current = null;
|
|
51
|
-
finalPriceRef.current = null;
|
|
52
|
-
approvedAmountRef.current = null;
|
|
53
|
-
};
|
|
54
|
-
$[5] = t3;
|
|
55
|
-
} else {
|
|
56
|
-
t3 = $[5];
|
|
57
|
-
}
|
|
58
|
-
const resetTrackedPrice = t3;
|
|
59
|
-
let t4;
|
|
60
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
61
|
-
t4 = {
|
|
62
|
-
usingPrice(price_0) {
|
|
63
|
-
usingPriceRef.current = price_0 ?? null;
|
|
64
|
-
},
|
|
65
|
-
finalPrice(price_1) {
|
|
66
|
-
finalPriceRef.current = price_1 ?? null;
|
|
67
|
-
},
|
|
68
|
-
approvedAmount(amount) {
|
|
69
|
-
approvedAmountRef.current = amount ?? null;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
$[6] = t4;
|
|
73
|
-
} else {
|
|
74
|
-
t4 = $[6];
|
|
75
|
-
}
|
|
76
|
-
const set = t4;
|
|
77
|
-
let t5;
|
|
78
|
-
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
79
|
-
const get = {
|
|
80
|
-
usingPrice() {
|
|
81
|
-
return usingPriceRef.current;
|
|
82
|
-
},
|
|
83
|
-
finalPrice() {
|
|
84
|
-
return finalPriceRef.current;
|
|
85
|
-
},
|
|
86
|
-
approvedAmount() {
|
|
87
|
-
return approvedAmountRef.current;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
t5 = {
|
|
91
|
-
set,
|
|
92
|
-
get,
|
|
93
|
-
resetTrackedPrice
|
|
94
|
-
};
|
|
95
|
-
$[7] = t5;
|
|
96
|
-
} else {
|
|
97
|
-
t5 = $[7];
|
|
98
|
-
}
|
|
99
|
-
return t5;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { useTrackedPrice };
|
|
103
|
-
//# sourceMappingURL=useTrackedPrice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTrackedPrice.js","sources":["../../../../../src/hooks/swap/tradeFlow/common/useTrackedPrice.ts"],"sourcesContent":["import { applySlippage } from \"@/lib/utils/price\";\nimport { useLayoutEffect, useRef } from \"react\";\n\ntype MinPriceObject = {\n srcAmount: string;\n destAmount: string;\n};\n\ntype UseTrackedPriceInput<P extends MinPriceObject> = {\n price?: P;\n slippage: number;\n side: \"BUY\" | \"SELL\";\n};\n\ntype UseTrackedPriceResult<P extends MinPriceObject> = {\n set: {\n usingPrice(price?: P | null): void;\n finalPrice(price?: P | null): void;\n approvedAmount(amount?: bigint | null): void;\n };\n get: {\n usingPrice(): P | null;\n finalPrice(): P | null;\n approvedAmount(): bigint | null;\n };\n resetTrackedPrice: () => void;\n};\n\nexport function useTrackedPrice<P extends MinPriceObject>({\n price,\n side,\n slippage,\n}: UseTrackedPriceInput<P>): UseTrackedPriceResult<P> {\n // keep track of the latest price so that we start trade flow for the most up-to-date price\n const usingPriceRef = useRef<P | null>(price || null);\n\n // price that was used to build the tx\n const finalPriceRef = useRef<P | null>(null);\n\n // keep track of the approved amount so that we know how much allowance was used,\n // and disallow new prices that would require more allowance than was used\n const approvedAmountRef = useRef<bigint | null>(null);\n\n // keep track of the latest price\n useLayoutEffect(() => {\n if (!price) return;\n\n // price finalized, no need to update anything anymore\n if (finalPriceRef.current) return;\n\n // if we already approved some amount\n if (approvedAmountRef.current) {\n // slightly higher amount if BUY with slippage\n const amountsAfterSlippage = applySlippage(\n {\n srcAmount: price.srcAmount,\n destAmount: price.destAmount,\n },\n slippage,\n side\n );\n\n if (BigInt(amountsAfterSlippage.srcAmount) > approvedAmountRef.current) {\n // if new price requires more allowance than was used, disallow it\n return;\n }\n }\n\n usingPriceRef.current = price;\n }, [price, side, slippage]);\n\n // reset tracked price,\n // allows to restart tracking on retry\n const resetTrackedPrice: UseTrackedPriceResult<P>[\"resetTrackedPrice\"] =\n () => {\n usingPriceRef.current = null;\n finalPriceRef.current = null;\n approvedAmountRef.current = null;\n };\n\n const set: UseTrackedPriceResult<P>[\"set\"] = {\n usingPrice(price?: P) {\n // allow to reset when price? is provided\n usingPriceRef.current = price ?? null;\n },\n finalPrice(price?: P) {\n // allow to set when price? is provided\n finalPriceRef.current = price ?? null;\n },\n approvedAmount(amount?: bigint) {\n // allow to reset when amount? is provided\n approvedAmountRef.current = amount ?? null;\n },\n };\n\n const get: UseTrackedPriceResult<P>[\"get\"] = {\n usingPrice() {\n return usingPriceRef.current;\n },\n finalPrice() {\n return finalPriceRef.current;\n },\n approvedAmount() {\n return approvedAmountRef.current;\n },\n };\n\n return {\n set,\n get,\n resetTrackedPrice,\n };\n}\n"],"names":["useTrackedPrice","t0","$","_c","price","side","slippage","usingPriceRef","useRef","finalPriceRef","approvedAmountRef","t1","t2","current","amountsAfterSlippage","applySlippage","srcAmount","destAmount","BigInt","useLayoutEffect","t3","Symbol","for","resetTrackedPrice","t4","usingPrice","price_0","finalPrice","price_1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