diff --git a/api/suggested-fees.ts b/api/suggested-fees.ts index 3c5397256..f4737bbf2 100644 --- a/api/suggested-fees.ts +++ b/api/suggested-fees.ts @@ -6,7 +6,11 @@ import { BlockFinder } from "@uma/sdk"; import { VercelResponse } from "@vercel/node"; import { ethers } from "ethers"; import { type, assert, Infer, optional, string } from "superstruct"; -import { disabledL1Tokens, DEFAULT_QUOTE_TIMESTAMP_BUFFER } from "./_constants"; +import { + disabledL1Tokens, + DEFAULT_QUOTE_TIMESTAMP_BUFFER, + DEFAULT_SIMULATED_RECIPIENT_ADDRESS, +} from "./_constants"; import { TypedVercelRequest } from "./_types"; import { getLogger, @@ -79,7 +83,7 @@ const handler = async ( const destinationChainId = Number(_destinationChainId); relayerAddress ??= sdk.constants.DEFAULT_SIMULATED_RELAYER_ADDRESS; - recipientAddress ??= sdk.constants.DEFAULT_SIMULATED_RELAYER_ADDRESS; + recipientAddress ??= DEFAULT_SIMULATED_RECIPIENT_ADDRESS; token = ethers.utils.getAddress(token); const [latestBlock, tokenDetails] = await Promise.all([ diff --git a/src/hooks/useBridgeFees.ts b/src/hooks/useBridgeFees.ts index 4fb798d56..7cc54c444 100644 --- a/src/hooks/useBridgeFees.ts +++ b/src/hooks/useBridgeFees.ts @@ -15,11 +15,17 @@ export function useBridgeFees( amount: ethers.BigNumber, fromChainId?: ChainId, toChainId?: ChainId, - tokenSymbol?: string + tokenSymbol?: string, + recipientAddress?: string ) { const { block } = useBlock(toChainId); const enabledQuery = - !!toChainId && !!fromChainId && !!block && !!tokenSymbol && amount.gt(0); + !!toChainId && + !!fromChainId && + !!block && + !!tokenSymbol && + amount.gt(0) && + !!recipientAddress; const queryKey = enabledQuery ? bridgeFeesQueryKey( tokenSymbol, @@ -38,6 +44,7 @@ export function useBridgeFees( blockTimestamp: block!.timestamp, toChainId: toChainId!, fromChainId: fromChainId!, + recipientAddress: recipientAddress!, }); }, { diff --git a/src/utils/bridge.ts b/src/utils/bridge.ts index c6b669eaa..6976f8a7b 100644 --- a/src/utils/bridge.ts +++ b/src/utils/bridge.ts @@ -32,6 +32,7 @@ type GetBridgeFeesArgs = { blockTimestamp: number; fromChainId: ChainId; toChainId: ChainId; + recipientAddress: string; }; export type GetBridgeFeesResult = BridgeFees & { @@ -52,6 +53,7 @@ export async function getBridgeFees({ tokenSymbol, fromChainId, toChainId, + recipientAddress, }: GetBridgeFeesArgs): Promise { const timeBeforeRequests = Date.now(); const { @@ -66,7 +68,8 @@ export async function getBridgeFees({ amount, getConfig().getTokenInfoBySymbol(fromChainId, tokenSymbol).address, toChainId, - fromChainId + fromChainId, + recipientAddress ); const timeAfterRequests = Date.now(); diff --git a/src/utils/serverless-api/mocked/suggested-fees.mocked.ts b/src/utils/serverless-api/mocked/suggested-fees.mocked.ts index c5f2013fb..5fa235e71 100644 --- a/src/utils/serverless-api/mocked/suggested-fees.mocked.ts +++ b/src/utils/serverless-api/mocked/suggested-fees.mocked.ts @@ -14,7 +14,8 @@ export async function suggestedFeesMockedApiCall( _amount: ethers.BigNumber, _originToken: string, _toChainid: ChainId, - _fromChainid: ChainId + _fromChainid: ChainId, + _recipientAddress: string ): Promise { return { relayerFee: { diff --git a/src/utils/serverless-api/prod/suggested-fees.prod.ts b/src/utils/serverless-api/prod/suggested-fees.prod.ts index a348eb4e7..422afb17e 100644 --- a/src/utils/serverless-api/prod/suggested-fees.prod.ts +++ b/src/utils/serverless-api/prod/suggested-fees.prod.ts @@ -15,13 +15,15 @@ export async function suggestedFeesApiCall( amount: ethers.BigNumber, originToken: string, toChainid: ChainId, - fromChainid: ChainId + fromChainid: ChainId, + recipientAddress: string ): Promise { const response = await axios.get(`/api/suggested-fees`, { params: { token: originToken, destinationChainId: toChainid, originChainId: fromChainid, + recipientAddress, amount: amount.toString(), skipAmountLimit: true, }, diff --git a/src/utils/serverless-api/types.ts b/src/utils/serverless-api/types.ts index 9a5495978..f9c72f9db 100644 --- a/src/utils/serverless-api/types.ts +++ b/src/utils/serverless-api/types.ts @@ -56,7 +56,8 @@ export type SuggestedApiFeeType = ( amount: ethers.BigNumber, originToken: string, toChainid: ChainId, - fromChainid: ChainId + fromChainid: ChainId, + recipientAddress: string ) => Promise; export type RetrieveLinkedWalletType = ( diff --git a/src/views/Bridge/hooks/useTransferQuote.ts b/src/views/Bridge/hooks/useTransferQuote.ts index be997a2e3..187543b18 100644 --- a/src/views/Bridge/hooks/useTransferQuote.ts +++ b/src/views/Bridge/hooks/useTransferQuote.ts @@ -26,7 +26,8 @@ export function useTransferQuote( amountToBridge, selectedRoute.fromChain, selectedRoute.toChain, - selectedRoute.fromTokenSymbol + selectedRoute.fromTokenSymbol, + toAddress ); const limitsQuery = useBridgeLimits( selectedRoute.fromTokenSymbol, diff --git a/src/views/Transactions/hooks/useSpeedUp.tsx b/src/views/Transactions/hooks/useSpeedUp.tsx index 0274344b7..5b4c0b9b8 100644 --- a/src/views/Transactions/hooks/useSpeedUp.tsx +++ b/src/views/Transactions/hooks/useSpeedUp.tsx @@ -19,7 +19,8 @@ export function useSpeedUp(transfer: Deposit, token: Token) { BigNumber.from(transfer.amount), transfer.sourceChainId, transfer.destinationChainId, - token.symbol + token.symbol, + transfer.recipientAddr ); const [speedUpTxLink, setSpeedUpTxLink] = useState("");