Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add avax, use sdk-core constants #246

Merged
merged 9 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ The best way to develop and test the API is to deploy your own instance to AWS.
# MAINNET = 1
# ROPSTEN = 3
# RINKEBY = 4
# GÖRLI = 5
# GOERLI = 5
# KOVAN = 42
# OPTIMISM = 10
# OPTIMISTIC_KOVAN = 69
# ARBITRUM_ONE = 42161
# ARBITRUM_RINKEBY = 421611
# POLYGON = 137
# POLYGON_MUMBAI = 80001
# BSC = 56
# BNB = 56
TENDERLY_USER = '' # For enabling Tenderly simulations
TENDERLY_PROJECT = '' # For enabling Tenderly simulations
TENDERLY_ACCESS_KEY = '' # For enabling Tenderly simulations
Expand Down
3 changes: 2 additions & 1 deletion bin/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@uniswap/smart-order-router'
import { ChainId } from '@uniswap/sdk-core'
import * as cdk from 'aws-cdk-lib'
import { CfnOutput, SecretValue, Stack, StackProps, Stage, StageProps } from 'aws-cdk-lib'
import * as chatbot from 'aws-cdk-lib/aws-chatbot'
Expand Down Expand Up @@ -269,6 +269,7 @@ const jsonRpcProviders = {
WEB3_RPC_42220: process.env.JSON_RPC_PROVIDER_42220!,
WEB3_RPC_44787: process.env.JSON_RPC_PROVIDER_44787!,
WEB3_RPC_56: process.env.JSON_RPC_PROVIDER_56!,
WEB3_RPC_43114: process.env.JSON_RPC_PROVIDER_43114!,
}

// Local dev stack
Expand Down
5 changes: 3 additions & 2 deletions bin/stacks/routing-api-stack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChainId, SUPPORTED_CHAINS } from '@uniswap/smart-order-router'
import { SUPPORTED_CHAINS } from '@uniswap/smart-order-router'
import * as cdk from 'aws-cdk-lib'
import { ChainId } from '@uniswap/sdk-core'
import { CfnOutput, Duration } from 'aws-cdk-lib'
import * as aws_apigateway from 'aws-cdk-lib/aws-apigateway'
import { MethodLoggingLevel } from 'aws-cdk-lib/aws-apigateway'
Expand All @@ -16,7 +17,7 @@ import { RoutingDashboardStack } from './routing-dashboard-stack'
import { RoutingLambdaStack } from './routing-lambda-stack'
import { RoutingDatabaseStack } from './routing-database-stack'

export const CHAINS_NOT_MONITORED: ChainId[] = [ChainId.GÖRLI, ChainId.POLYGON_MUMBAI]
export const CHAINS_NOT_MONITORED: ChainId[] = [ChainId.GOERLI, ChainId.POLYGON_MUMBAI]

export class RoutingAPIStack extends cdk.Stack {
public readonly url: CfnOutput
Expand Down
4 changes: 2 additions & 2 deletions bin/stacks/routing-dashboard-stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@uniswap/smart-order-router'
import { ChainId } from '@uniswap/sdk-core'
import * as cdk from 'aws-cdk-lib'
import * as aws_cloudwatch from 'aws-cdk-lib/aws-cloudwatch'
import { Construct } from 'constructs'
Expand Down Expand Up @@ -36,7 +36,7 @@ export class RoutingDashboardStack extends cdk.NestedStack {
const TESTNETS = [
ChainId.ARBITRUM_GOERLI,
ChainId.POLYGON_MUMBAI,
ChainId.GÖRLI,
ChainId.GOERLI,
ChainId.SEPOLIA,
ChainId.CELO_ALFAJORES,
]
Expand Down
13 changes: 10 additions & 3 deletions lib/cron/cache-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Protocol } from '@uniswap/router-sdk'
import { ChainId, V2SubgraphProvider, V3SubgraphProvider } from '@uniswap/smart-order-router'
import { V2SubgraphProvider, V3SubgraphProvider } from '@uniswap/smart-order-router'
import { ChainId } from '@uniswap/sdk-core'

export const chainProtocols = [
// V3.
Expand Down Expand Up @@ -29,9 +30,15 @@ export const chainProtocols = [
},
{
protocol: Protocol.V3,
chainId: ChainId.BSC,
chainId: ChainId.BNB,
timeout: 90000,
provider: new V3SubgraphProvider(ChainId.BSC, 3, 90000),
provider: new V3SubgraphProvider(ChainId.BNB, 3, 90000),
},
{
protocol: Protocol.V3,
chainId: ChainId.AVALANCHE,
timeout: 90000,
provider: new V3SubgraphProvider(ChainId.AVALANCHE, 3, 90000),
},
// Currently there is no working V3 subgraph for Optimism so we use a static provider.
// V2.
Expand Down
3 changes: 2 additions & 1 deletion lib/cron/cache-pools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Protocol } from '@uniswap/router-sdk'
import { ChainId, setGlobalLogger } from '@uniswap/smart-order-router'
import { setGlobalLogger } from '@uniswap/smart-order-router'
import { EventBridgeEvent, ScheduledHandler } from 'aws-lambda'
import { S3 } from 'aws-sdk'
import { ChainId } from '@uniswap/sdk-core'
import { default as bunyan, default as Logger } from 'bunyan'
import { S3_POOL_CACHE_KEY } from '../util/pool-cache-key'
import { chainProtocols } from './cache-config'
Expand Down
4 changes: 2 additions & 2 deletions lib/dashboards/quote-amounts-widgets-factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TradeType } from '@uniswap/sdk-core'
import { ChainId, ID_TO_NETWORK_NAME } from '@uniswap/smart-order-router'
import { ChainId, TradeType } from '@uniswap/sdk-core'
import { ID_TO_NETWORK_NAME } from '@uniswap/smart-order-router'
import _ from 'lodash'
import { PAIRS_TO_TRACK } from '../handlers/quote/util/pairs-to-track'
import { Widget } from './core/model/widget'
Expand Down
8 changes: 4 additions & 4 deletions lib/handlers/injector-sor.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Token } from '@uniswap/sdk-core'
import { ChainId, Token } from '@uniswap/sdk-core'
import {
CachingGasStationProvider,
CachingTokenListProvider,
CachingTokenProviderWithFallback,
CachingV3PoolProvider,
ChainId,
EIP1559GasPriceProvider,
FallbackTenderlySimulator,
TenderlySimulator,
Expand Down Expand Up @@ -52,11 +51,12 @@ export const SUPPORTED_CHAINS: ChainId[] = [
ChainId.ARBITRUM_GOERLI,
ChainId.POLYGON,
ChainId.POLYGON_MUMBAI,
ChainId.GÖRLI,
ChainId.GOERLI,
ChainId.SEPOLIA,
ChainId.CELO,
ChainId.CELO_ALFAJORES,
ChainId.BSC,
ChainId.BNB,
ChainId.AVALANCHE,
]
const DEFAULT_TOKEN_LIST = 'https://gateway.ipfs.io/ipns/tokens.uniswap.org'

Expand Down
3 changes: 1 addition & 2 deletions lib/handlers/marshalling/cached-routes-marshaller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CachedRoutes } from '@uniswap/smart-order-router'
import { ChainId } from '@uniswap/smart-order-router/build/main/util'
import { TradeType } from '@uniswap/sdk-core'
import { ChainId, TradeType } from '@uniswap/sdk-core'
import { Protocol } from '@uniswap/router-sdk'
import { MarshalledToken, TokenMarshaller } from './token-marshaller'
import { CachedRouteMarshaller, MarshalledCachedRoute } from './cached-route-marshaller'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChainId, IV3PoolProvider, V3PoolAccessor } from '@uniswap/smart-order-router'
import { Token } from '@uniswap/sdk-core'
import { IV3PoolProvider, V3PoolAccessor } from '@uniswap/smart-order-router'
import { ChainId, Token } from '@uniswap/sdk-core'
import { ProviderConfig } from '@uniswap/smart-order-router/build/main/providers/provider'
import { FeeAmount, Pool } from '@uniswap/v3-sdk'
import { IDynamoCache } from '../cache-dynamo'
Expand Down
3 changes: 1 addition & 2 deletions lib/handlers/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Joi from '@hapi/joi'
import { Protocol } from '@uniswap/router-sdk'
import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
import { PermitSingle } from '@uniswap/permit2-sdk'
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { ChainId, Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import {
AlphaRouterConfig,
IRouter,
Expand All @@ -13,7 +13,6 @@ import {
SwapType,
SimulationStatus,
IMetric,
ChainId,
ID_TO_NETWORK_NAME,
} from '@uniswap/smart-order-router'
import { Pool } from '@uniswap/v3-sdk'
Expand Down
3 changes: 1 addition & 2 deletions lib/handlers/quote/util/pairs-to-track.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TradeType } from '@uniswap/sdk-core'
import { ChainId } from '@uniswap/smart-order-router'
import { ChainId, TradeType } from '@uniswap/sdk-core'

export const PAIRS_TO_TRACK: Map<ChainId, Map<TradeType, string[]>> = new Map([
[
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/router-entities/aws-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Protocol } from '@uniswap/router-sdk'
import {
ChainId,
IV2SubgraphProvider,
IV3SubgraphProvider,
log,
V2SubgraphPool,
V3SubgraphPool,
} from '@uniswap/smart-order-router'
import { S3 } from 'aws-sdk'
import { ChainId } from '@uniswap/sdk-core'
import NodeCache from 'node-cache'
import { S3_POOL_CACHE_KEY } from '../../util/pool-cache-key'

Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/router-entities/aws-token-list-provider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
CachingTokenListProvider,
ChainId,
ITokenListProvider,
ITokenProvider,
log,
NodeJSCache,
} from '@uniswap/smart-order-router'
import { ChainId } from '@uniswap/sdk-core'
import { TokenList } from '@uniswap/token-lists'
import S3 from 'aws-sdk/clients/s3'
import NodeCache from 'node-cache'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TradeType } from '@uniswap/sdk-core'
import { CacheMode, ChainId } from '@uniswap/smart-order-router'
import { ChainId, TradeType } from '@uniswap/sdk-core'
import { CacheMode } from '@uniswap/smart-order-router'
import { CachedRoutesStrategy } from './model/cached-routes-strategy'
import { PairTradeTypeChainId } from './model/pair-trade-type-chain-id'
import { CachedRoutesBucket } from './model/cached-routes-bucket'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import {
CachedRoute,
CachedRoutes,
CacheMode,
ChainId,
IRouteCachingProvider,
log,
routeToString,
} from '@uniswap/smart-order-router'
import { DynamoDB } from 'aws-sdk'
import { Currency, CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core'
import { ChainId, Currency, CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core'
import { Protocol } from '@uniswap/router-sdk'
import { CACHED_ROUTES_CONFIGURATION } from './cached-routes-configuration'
import { PairTradeTypeChainId } from './model/pair-trade-type-chain-id'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { ChainId, Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { CachedRoutesBucket } from './cached-routes-bucket'
import { CacheMode, ChainId } from '@uniswap/smart-order-router'
import { CacheMode } from '@uniswap/smart-order-router'

interface CachedRoutesStrategyArgs {
pair: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TradeType } from '@uniswap/sdk-core'
import { CachedRoutes, ChainId } from '@uniswap/smart-order-router'
import { ChainId, TradeType } from '@uniswap/sdk-core'
import { CachedRoutes } from '@uniswap/smart-order-router'

interface PairTradeTypeChainIdArgs {
tokenIn: string
Expand Down
3 changes: 2 additions & 1 deletion lib/handlers/router-entities/v3-aws-subgraph-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChainId, IV3SubgraphProvider, log, V3SubgraphPool, V3SubgraphProvider } from '@uniswap/smart-order-router'
import { IV3SubgraphProvider, log, V3SubgraphPool, V3SubgraphProvider } from '@uniswap/smart-order-router'
import { S3 } from 'aws-sdk'
import { ChainId } from '@uniswap/sdk-core'
import _ from 'lodash'
import NodeCache from 'node-cache'

Expand Down
3 changes: 1 addition & 2 deletions lib/handlers/shared.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Currency, Percent } from '@uniswap/sdk-core'
import { ChainId, Currency, Percent } from '@uniswap/sdk-core'
import {
AlphaRouterConfig,
ChainId,
ITokenListProvider,
ITokenProvider,
MapWithLowerCaseKey,
Expand Down
2 changes: 1 addition & 1 deletion lib/util/pool-cache-key.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Protocol } from '@uniswap/router-sdk'
import { ChainId } from '@uniswap/smart-order-router'
import { ChainId } from '@uniswap/sdk-core'

export const S3_POOL_CACHE_KEY = (baseKey: string, chain: ChainId, protocol: Protocol) =>
`${baseKey}-${chain}-${protocol}`
Loading