Skip to content

Commit

Permalink
improve: use constants
Browse files Browse the repository at this point in the history
Signed-off-by: james-a-morris <[email protected]>
  • Loading branch information
james-a-morris committed Jan 10, 2025
1 parent 518d1d1 commit 8b13467
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,10 @@ export const defaultSwapSlippage = Number(

export const indexerApiBaseUrl =
process.env.REACT_APP_INDEXER_BASE_URL || undefined;

export const hyperLiquidBridge2Address =
"0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7";

export const acrossPlusMulticallHandler: Record<number, string> = {
[CHAIN_IDs.ARBITRUM]: "0x924a9f036260DdD5808007E1AA95f08eD08aA569",
};
8 changes: 5 additions & 3 deletions src/utils/hyperliquid.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Deposit } from "hooks/useDeposits";
import { CHAIN_IDs } from "@across-protocol/constants";
import { utils } from "ethers";
import { compareAddressesSimple } from "./sdk";
import { hyperLiquidBridge2Address } from "./constants";

export function isHyperLiquidBoundDeposit(deposit: Deposit) {
if (deposit.destinationChainId !== CHAIN_IDs.ARBITRUM || !deposit.message) {
Expand All @@ -22,9 +24,9 @@ export function isHyperLiquidBoundDeposit(deposit: Deposit) {
}

// Check if second call is to HyperLiquid Bridge2 contract
return (
decoded[0].calls[1].target.toLowerCase() ===
"0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7".toLowerCase()
return compareAddressesSimple(
decoded[0].calls[1].target,
hyperLiquidBridge2Address
);
} catch {
return false;
Expand Down
8 changes: 5 additions & 3 deletions src/views/Bridge/hooks/useBridgeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
sendSwapAndBridgeTx,
compareAddressesSimple,
getToken,
acrossPlusMulticallHandler,
hyperLiquidBridge2Address,
} from "utils";
import { TransferQuote } from "./useTransferQuote";
import { SelectedRoute } from "../utils";
Expand Down Expand Up @@ -163,7 +165,7 @@ export function useBridgeAction(
value: 0,
},
{
target: "0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7", // Bridge2 contract
target: hyperLiquidBridge2Address,
callData: hyperLiquidPayload,
value: 0,
},
Expand Down Expand Up @@ -271,7 +273,7 @@ export function useBridgeAction(
fillDeadline: frozenFeeQuote.fillDeadline,
message: externalPayload,
toAddress: externalProjectIsHyperLiquid
? "0x924a9f036260DdD5808007E1AA95f08eD08aA569" // Default multicall handler
? acrossPlusMulticallHandler[frozenRoute.toChain]
: frozenDepositArgs.toAddress,
},
spokePool,
Expand Down Expand Up @@ -472,7 +474,7 @@ export async function generateHyperLiquidPayload(

const permitValue = {
owner: source,
spender: "0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7", // Bridge2 contract address
spender: hyperLiquidBridge2Address,
value: amount,
nonce: await usdcContract.nonces(source),
deadline,
Expand Down

0 comments on commit 8b13467

Please sign in to comment.