Skip to content

Commit

Permalink
modify type
Browse files Browse the repository at this point in the history
  • Loading branch information
xumoyan committed Aug 20, 2024
1 parent 4bbac49 commit adc9576
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion bin/stacks/routing-api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class RoutingAPIStack extends cdk.Stack {
poolCacheBucket3,
poolCacheKey,
poolCacheGzipKey,
poolCacheLambdaNameArray,
tokenListCacheBucket,
} = new RoutingCachingStack(this, 'RoutingCachingStack', {
chatbotSNSArn,
Expand Down
7 changes: 5 additions & 2 deletions lib/handlers/marshalling/route-marshaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MarshalledToken, TokenMarshaller } from './token-marshaller'
import { MarshalledPair, PairMarshaller } from './pair-marshaller'
import { MarshalledPool, PoolMarshaller } from './pool-marshaller'
import { Pool } from '@uniswap/v3-sdk'
import { Pair } from '@uniswap/v2-sdk'

export interface MarshalledV2Route {
protocol: Protocol
Expand Down Expand Up @@ -52,9 +53,9 @@ export class RouteMarshaller {
output: TokenMarshaller.marshal(route.output),
pools: route.pools.map((tpool) => {
if (tpool instanceof Pool) {
return PoolMarshaller.marshal(tpool)
return PoolMarshaller.marshal(tpool as Pool)
} else {
return PairMarshaller.marshal(tpool)
return PairMarshaller.marshal(tpool as Pair)
}
}),
}
Expand Down Expand Up @@ -92,6 +93,8 @@ export class RouteMarshaller {
TokenMarshaller.unmarshal(mixedRoute.input),
TokenMarshaller.unmarshal(mixedRoute.output)
)
default:
throw new Error(`Unknown protocol ${marshalledRoute.protocol}`)
}
}
}
7 changes: 4 additions & 3 deletions lib/handlers/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { CurrencyLookup } from '../CurrencyLookup'
import { SwapOptionsFactory } from './SwapOptionsFactory'
import { GlobalRpcProviders } from '../../rpc/GlobalRpcProviders'
import semver from 'semver'
import { Pair } from '@uniswap/v2-sdk'

export class QuoteHandler extends APIGLambdaHandler<
ContainerInjected,
Expand Down Expand Up @@ -508,12 +509,12 @@ export class QuoteHandler extends APIGLambdaHandler<
amountOut: edgeAmountOut,
})
} else {
const reserve0 = nextPool.reserve0
const reserve1 = nextPool.reserve1
const reserve0 = (nextPool as Pair).reserve0
const reserve1 = (nextPool as Pair).reserve1

curRoute.push({
type: 'v2-pool',
address: v2PoolProvider.getPoolAddress(nextPool.token0, nextPool.token1).poolAddress,
address: v2PoolProvider.getPoolAddress((nextPool as Pair).token0, (nextPool as Pair).token1).poolAddress,
tokenIn: {
chainId: tokenIn.chainId,
decimals: tokenIn.decimals.toString(),
Expand Down

0 comments on commit adc9576

Please sign in to comment.