From b39418097d535893b9a5231eb92598ce521cc0d0 Mon Sep 17 00:00:00 2001 From: Dong-Ha Kim Date: Tue, 10 Sep 2024 20:33:41 +0700 Subject: [PATCH 1/2] feat(api): add spoke pool addresses to available-routes --- api/available-routes.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/available-routes.ts b/api/available-routes.ts index 471a558cc..78936306f 100644 --- a/api/available-routes.ts +++ b/api/available-routes.ts @@ -9,6 +9,7 @@ import { handleErrorCondition, DISABLED_CHAINS_FOR_AVAILABLE_ROUTES, DISABLED_TOKENS_FOR_AVAILABLE_ROUTES, + getSpokePoolAddress, } from "./_utils"; import { TypedVercelRequest } from "./_types"; @@ -49,6 +50,7 @@ const handler = async ( destinationToken: string; fromTokenSymbol: string; toTokenSymbol: string; + isNative: boolean; }) => ![route.originChainId, route.destinationChainId].some((chainId) => DISABLED_CHAINS_FOR_AVAILABLE_ROUTES.includes(String(chainId)) @@ -72,6 +74,9 @@ const handler = async ( fromTokenSymbol: route.fromTokenSymbol, toTokenSymbol: route.toTokenSymbol, destinationToken: route.toTokenAddress, + isNative: route.isNative, + originSpokePool: getSpokePoolAddress(route.fromChain), + destinationSpokePool: getSpokePoolAddress(route.toChain), }) ).map((route) => ({ originChainId: route.originChainId, @@ -80,6 +85,9 @@ const handler = async ( destinationToken: route.destinationToken, originTokenSymbol: route.fromTokenSymbol, destinationTokenSymbol: route.toTokenSymbol, + isNative: route.isNative, + originSpokePool: route.originSpokePool, + destinationSpokePool: route.destinationSpokePool, })); // Two different explanations for how `stale-while-revalidate` works: From 27743c40e3de81d1655fe5f6cf6b358910dbca7c Mon Sep 17 00:00:00 2001 From: Dong-Ha Kim Date: Tue, 10 Sep 2024 20:52:27 +0700 Subject: [PATCH 2/2] move destination spoke address to fees response --- api/available-routes.ts | 5 ----- api/suggested-fees.ts | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/api/available-routes.ts b/api/available-routes.ts index 78936306f..27d24f6d0 100644 --- a/api/available-routes.ts +++ b/api/available-routes.ts @@ -9,7 +9,6 @@ import { handleErrorCondition, DISABLED_CHAINS_FOR_AVAILABLE_ROUTES, DISABLED_TOKENS_FOR_AVAILABLE_ROUTES, - getSpokePoolAddress, } from "./_utils"; import { TypedVercelRequest } from "./_types"; @@ -75,8 +74,6 @@ const handler = async ( toTokenSymbol: route.toTokenSymbol, destinationToken: route.toTokenAddress, isNative: route.isNative, - originSpokePool: getSpokePoolAddress(route.fromChain), - destinationSpokePool: getSpokePoolAddress(route.toChain), }) ).map((route) => ({ originChainId: route.originChainId, @@ -86,8 +83,6 @@ const handler = async ( originTokenSymbol: route.fromTokenSymbol, destinationTokenSymbol: route.toTokenSymbol, isNative: route.isNative, - originSpokePool: route.originSpokePool, - destinationSpokePool: route.destinationSpokePool, })); // Two different explanations for how `stale-while-revalidate` works: diff --git a/api/suggested-fees.ts b/api/suggested-fees.ts index a204fa51b..fad43638d 100644 --- a/api/suggested-fees.ts +++ b/api/suggested-fees.ts @@ -283,6 +283,7 @@ const handler = async ( exclusiveRelayer, exclusivityDeadline, spokePoolAddress: getSpokePoolAddress(Number(computedOriginChainId)), + destinationSpokePoolAddress: getSpokePoolAddress(destinationChainId), // Note: v3's new fee structure. Below are the correct values for the new fee structure. The above `*Pct` and `*Total` // values are for backwards compatibility which will be removed in the future. totalRelayFee: {