Skip to content

Conversation

@jsy1218
Copy link
Member

@jsy1218 jsy1218 commented Nov 6, 2025

Currently, we see two problems with the async lambda call (async caching update):

  1. when tokenIn/tokenOut is ETH, and in cache entries there are only WETH/* cached routes, then routing will not make a ETH async call, but only WETH async call
  2. when tokenIn/tokenOut is WETH, regardless of what's in the cache entries, routing will only make WETH async call, no ETH async call.

Desired behavior is:

  1. when tokenIn/tokenOut is ETH, we make two async calls, one for ETH/, the other for WETH/
  2. when tokenIn/tokenOut is WETH, we also make two async calls, one for ETH/, the other for WETH/

In order to achieve this, we need to make sure, we always try to query the dynamo with both ETH/* and WETH/* cache entries.

Copy link
Member Author

jsy1218 commented Nov 6, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jsy1218 jsy1218 marked this pull request as ready for review November 6, 2025 00:45
@graphite-app graphite-app bot requested a review from cgkol November 6, 2025 00:54
@graphite-app graphite-app bot requested review from a team and xrsv November 6, 2025 00:54
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 6, 2025

Graphite Automations

"Request reviewers once CI passes on routing-api repo" took an action on this PR • (11/06/25)

4 reviewers were added and 1 assignee was added to this PR based on Siyu Jiang (See-You John)'s automation.

@cgkol
Copy link
Collaborator

cgkol commented Nov 6, 2025

We also pass through those permit params just in case the tokenIn already has the permit2.

what dos this mean exactly? all tokens have permit2 right?

},
queryStringParameters: {
tokenInAddress: getSymbolOrAddress(partitionKey.currencyIn, partitionKey.chainId),
tokenInAddress: currencyIn.isNative ? currencyIn.symbol : currencyIn.address,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am still having a hard time wrapping my head around this;

is the issue that partitionKey.currencyIn might incorrectly not be classified as addressZero aka the native token, therefore, we won't update correctly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this does the same thing as before;

when you have a native, you would pass down ADDRESS_ZERO which before would be updated with the symbol. Now, you are passing the symbol just by checking if its native or not, but that sa check you can do based on the currencyIn address (which should be 0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be reverted

tokenInAddress: currencyIn.isNative ? currencyIn.symbol : currencyIn.address,
tokenInChainId: partitionKey.chainId.toString(),
tokenOutAddress: getSymbolOrAddress(partitionKey.currencyOut, partitionKey.chainId),
tokenOutAddress: currencyOut.isNative ? currencyOut.symbol : currencyOut.address,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be reverted

Comment on lines 557 to 569
slippageTolerance: swapOptions?.slippageTolerance?.toFixed(2),
simulateFromAddress: swapOptions?.simulate?.fromAddress,
recipient: swapOptions?.recipient,
deadline:
parseInt((swapOptions as SwapOptionsUniversalRouter).deadlineOrPreviousBlockhash?.toString() ?? '0') -
Math.floor(Date.now() / 1000),
permitSignature: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.signature,
permitNonce: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.details?.nonce,
permitExpiration: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.details?.expiration,
permitAmount: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.details?.amount,
permitToken: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.details?.token,
permitSpender: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.spender,
permitSigDeadline: (swapOptions as SwapOptionsUniversalRouter).inputTokenPermit?.sigDeadline,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we prob need to keep those

@jsy1218 jsy1218 changed the title fix: pass in correct async lambda query string params for caching and deleting cached routes upon sim failures fix: always sends two async calls when the tokenIn or tokenOut is either ETH or WETH Nov 7, 2025
Copy link
Collaborator

@cgkol cgkol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with the new changes, you guarantee that you'll pull cache results for both eth/weth everytime you call either, but are we guaranteed that it will update both?

}

const result = await this.ddbClient.query(queryParams).promise()
const additionalQueryParams = DynamoRouteCachingProvider.getAdditionalQueryParams(currencyIn, currencyOut, tradeType, chainId, includesV4Pool, this.routesTableName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add some comments epxlaining why we do this

@jsy1218 jsy1218 force-pushed the siyujiang/route-777-debug-why-cached-routes-are-not-getting-updated branch from 6780fc5 to 68c55cf Compare November 9, 2025 21:56
@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​uniswap/​sdk-core@​7.8.0 ⏵ 7.9.09810074 +195 +3100
Updated@​uniswap/​smart-order-router@​4.22.30 ⏵ 4.22.3194 -610010097 -370 -30

View full report

Copy link
Collaborator

@cgkol cgkol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete code from other places

alphaRouterConfig,
swapOptions
)
} else if (currencyIn.isNative || currencyOut.isNative) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will probably work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants