diff --git a/src/components/DepositsTable/cells/RouteCell.tsx b/src/components/DepositsTable/cells/RouteCell.tsx index 5819b0391..e8ed1124e 100644 --- a/src/components/DepositsTable/cells/RouteCell.tsx +++ b/src/components/DepositsTable/cells/RouteCell.tsx @@ -3,9 +3,10 @@ import styled from "@emotion/styled"; import { Text } from "components/Text"; import { IconPair } from "components/IconPair"; import { Deposit } from "hooks/useDeposits"; -import { getChainInfo } from "utils"; +import { ChainInfo, getChainInfo, isHyperLiquidBoundDeposit } from "utils"; import { BaseCell } from "./BaseCell"; +import { externConfigs } from "constants/chains/configs"; type Props = { deposit: Deposit; @@ -13,8 +14,13 @@ type Props = { }; export function RouteCell({ deposit, width }: Props) { + const isHyperLiquidDeposit = isHyperLiquidBoundDeposit(deposit); + const sourceChain = getChainInfo(deposit.sourceChainId); - const destinationChain = getChainInfo(deposit.destinationChainId); + const destinationChain: Pick = + isHyperLiquidDeposit + ? externConfigs["hyper-liquid"] + : getChainInfo(deposit.destinationChainId); return ( diff --git a/src/utils/hyperliquid.ts b/src/utils/hyperliquid.ts new file mode 100644 index 000000000..990318a6c --- /dev/null +++ b/src/utils/hyperliquid.ts @@ -0,0 +1,32 @@ +import { Deposit } from "hooks/useDeposits"; +import { CHAIN_IDs } from "@across-protocol/constants"; +import { utils } from "ethers"; + +export function isHyperLiquidBoundDeposit(deposit: Deposit) { + if (deposit.destinationChainId !== CHAIN_IDs.ARBITRUM || !deposit.message) { + return false; + } + + try { + // Try to decode the message as Instructions struct + const decoded = utils.defaultAbiCoder.decode( + [ + "tuple(tuple(address target, bytes callData, uint256 value)[] calls, address fallbackRecipient)", + ], + deposit.message + ); + + // Check if it has exactly 2 calls + if (decoded[0].calls.length !== 2) { + return false; + } + + // Check if second call is to HyperLiquid Bridge2 contract + return ( + decoded[0].calls[1].target.toLowerCase() === + "0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7".toLowerCase() + ); + } catch { + return false; + } +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 271e0c6c3..9031b1b66 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,3 +22,4 @@ export * from "./types"; export * from "./network"; export * from "./url"; export * from "./sdk"; +export * from "./hyperliquid"; diff --git a/src/views/Bridge/hooks/useBridgeAction.ts b/src/views/Bridge/hooks/useBridgeAction.ts index 1a792c150..83a5ad45a 100644 --- a/src/views/Bridge/hooks/useBridgeAction.ts +++ b/src/views/Bridge/hooks/useBridgeAction.ts @@ -125,8 +125,8 @@ export function useBridgeAction( // 4. We must construct a payload to send to HL's Bridge2 contract // 5. The user must sign this signature - // For now let's assume a 0.05% loss in the amount - const amount = frozenDepositArgs.amount.mul(9995).div(10000); + // For now let's assume a 2% loss in the amount + const amount = frozenDepositArgs.amount.mul(98).div(100); // Build the payload const hyperLiquidPayload = await generateHyperLiquidPayload(