33 CachedRoute ,
44 CachedRoutes ,
55 CacheMode ,
6+ HooksOptions ,
67 ID_TO_NETWORK_NAME ,
78 INTENT ,
89 IRouteCachingProvider ,
@@ -11,6 +12,7 @@ import {
1112 MetricLoggerUnit ,
1213 routeToString ,
1314 SupportedRoutes ,
15+ SwapOptionsUniversalRouter ,
1416} from '@uniswap/smart-order-router'
1517import { AWSError , DynamoDB , Lambda } from 'aws-sdk'
1618import { ChainId , Currency , CurrencyAmount , Fraction , Token , TradeType } from '@uniswap/sdk-core'
@@ -20,7 +22,6 @@ import { PairTradeTypeChainId } from './model/pair-trade-type-chain-id'
2022import { CachedRoutesMarshaller } from '../../marshalling/cached-routes-marshaller'
2123import { PromiseResult } from 'aws-sdk/lib/request'
2224import { DEFAULT_BLOCKS_TO_LIVE_ROUTES_DB } from '../../../util/defaultBlocksToLiveRoutesDB'
23- import { getSymbolOrAddress } from '../../../util/getSymbolOrAddress'
2425import { serializeRouteIds } from '@uniswap/smart-order-router/build/main/util/serializeRouteIds'
2526import { UniversalRouterVersion } from '@uniswap/universal-router-sdk'
2627import { computeProtocolsInvolvedIfMixed } from '../../../util/computeProtocolsInvolvedIfMixed'
@@ -200,6 +201,8 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
200201 partitionKey ,
201202 amount ,
202203 protocols ,
204+ currencyIn ,
205+ currencyOut ,
203206 alphaRouterConfig ,
204207 swapOptions
205208 )
@@ -223,6 +226,8 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
223226 partitionKey : PairTradeTypeChainId ,
224227 amount : CurrencyAmount < Currency > ,
225228 protocols : Protocol [ ] ,
229+ currencyIn : Currency ,
230+ currencyOut : Currency ,
226231 alphaRouterConfig ?: AlphaRouterConfig ,
227232 swapOptions ?: SwapOptions
228233 ) : CachedRoutes {
@@ -358,6 +363,8 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
358363 amount ,
359364 currentBlockNumber ,
360365 cachedRoutes . routes . map ( ( route ) => route . routeId ) ,
366+ currencyIn ,
367+ currencyOut ,
361368 alphaRouterConfig ,
362369 swapOptions
363370 )
@@ -371,6 +378,8 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
371378 amount : CurrencyAmount < Currency > ,
372379 currentBlockNumber : number ,
373380 cachedRoutesRouteIds : number [ ] ,
381+ currencyIn : Currency ,
382+ currencyOut : Currency ,
374383 alphaRouterConfig ?: AlphaRouterConfig ,
375384 swapOptions ?: SwapOptions
376385 ) : Promise < void > {
@@ -413,6 +422,8 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
413422 [ Protocol . V2 , Protocol . V3 , Protocol . V4 , Protocol . MIXED ] ,
414423 amount ,
415424 cachedRoutesRouteIds ,
425+ currencyIn ,
426+ currencyOut ,
416427 alphaRouterConfig ,
417428 swapOptions
418429 )
@@ -430,6 +441,8 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
430441 protocols : Protocol [ ] ,
431442 amount : CurrencyAmount < Currency > ,
432443 cachedRoutesRouteIds : number [ ] ,
444+ currencyIn : Currency ,
445+ currencyOut : Currency ,
433446 alphaRouterConfig ?: AlphaRouterConfig ,
434447 swapOptions ?: SwapOptions
435448 ) : void {
@@ -440,9 +453,9 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
440453 : UniversalRouterVersion . V1_2 ,
441454 } ,
442455 queryStringParameters : {
443- tokenInAddress : getSymbolOrAddress ( partitionKey . currencyIn , partitionKey . chainId ) ,
456+ tokenInAddress : currencyIn . isNative ? currencyIn . symbol : currencyIn . address ,
444457 tokenInChainId : partitionKey . chainId . toString ( ) ,
445- tokenOutAddress : getSymbolOrAddress ( partitionKey . currencyOut , partitionKey . chainId ) ,
458+ tokenOutAddress : currencyOut . isNative ? currencyOut . symbol : currencyOut . address ,
446459 tokenOutChainId : partitionKey . chainId . toString ( ) ,
447460 amount : amount . quotient . toString ( ) ,
448461 type : partitionKey . tradeType === 0 ? 'exactIn' : 'exactOut' ,
@@ -451,8 +464,20 @@ export class DynamoRouteCachingProvider extends IRouteCachingProvider {
451464 requestSource : 'routing-api' ,
452465 cachedRoutesRouteIds : serializeRouteIds ( cachedRoutesRouteIds ) ,
453466 enableDebug : alphaRouterConfig ?. enableDebug ,
454- swapOptions : swapOptions ?. simulate ?. fromAddress ,
455467 enableUniversalRouter : true ,
468+ slippageTolerance : swapOptions ?. slippageTolerance ?. toFixed ( 2 ) ,
469+ simulateFromAddress : swapOptions ?. simulate ?. fromAddress ,
470+ recipient : swapOptions ?. recipient ,
471+ deadline :
472+ parseInt ( ( swapOptions as SwapOptionsUniversalRouter ) . deadlineOrPreviousBlockhash ?. toString ( ) ?? '0' ) -
473+ Math . floor ( Date . now ( ) / 1000 ) ,
474+ permitSignature : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. signature ,
475+ permitNonce : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. details ?. nonce ,
476+ permitExpiration : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. details ?. expiration ,
477+ permitAmount : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. details ?. amount ,
478+ permitToken : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. details ?. token ,
479+ permitSpender : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. spender ,
480+ permitSigDeadline : ( swapOptions as SwapOptionsUniversalRouter ) . inputTokenPermit ?. sigDeadline ,
456481 } ,
457482 }
458483
0 commit comments