Skip to content

Commit

Permalink
feat: shadow tenderly new node endpoint (#726)
Browse files Browse the repository at this point in the history
* feat: shadow tenderly new node endpoint

* fix prettier
  • Loading branch information
jsy1218 authored Jun 7, 2024
1 parent d048796 commit 984bc35
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The best way to develop and test the API is to deploy your own instance to AWS.
TENDERLY_USER = '' # For enabling Tenderly simulations
TENDERLY_PROJECT = '' # For enabling Tenderly simulations
TENDERLY_ACCESS_KEY = '' # For enabling Tenderly simulations
TENDERLY_NODE_API_KEY = '' # For enabling Tenderly node-level RPC access
```
3. Install and build the package
```
Expand Down
6 changes: 6 additions & 0 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class RoutingAPIStage extends Stage {
tenderlyUser: string
tenderlyProject: string
tenderlyAccessKey: string
tenderlyNodeApiKey: string
unicornSecret: string
alchemyQueryKey?: string
decentralizedNetworkApiKey?: string
Expand All @@ -55,6 +56,7 @@ export class RoutingAPIStage extends Stage {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
tenderlyNodeApiKey,
unicornSecret,
alchemyQueryKey,
decentralizedNetworkApiKey,
Expand All @@ -74,6 +76,7 @@ export class RoutingAPIStage extends Stage {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
tenderlyNodeApiKey,
unicornSecret,
alchemyQueryKey,
decentralizedNetworkApiKey,
Expand Down Expand Up @@ -246,6 +249,7 @@ export class RoutingAPIPipeline extends Stack {
tenderlyUser: tenderlyCreds.secretValueFromJson('tenderly-user').toString(),
tenderlyProject: tenderlyCreds.secretValueFromJson('tenderly-project').toString(),
tenderlyAccessKey: tenderlyCreds.secretValueFromJson('tenderly-access-key').toString(),
tenderlyNodeApiKey: tenderlyCreds.secretValueFromJson('tenderly-node-api-key').toString(),
unicornSecret: unicornSecrets.secretValueFromJson('debug-config-unicorn-key').toString(),
alchemyQueryKey: routingApiNewSecrets.secretValueFromJson('alchemy-query-key').toString(),
decentralizedNetworkApiKey: routingApiNewSecrets.secretValueFromJson('decentralized-network-api-key').toString(),
Expand All @@ -271,6 +275,7 @@ export class RoutingAPIPipeline extends Stack {
tenderlyUser: tenderlyCreds.secretValueFromJson('tenderly-user').toString(),
tenderlyProject: tenderlyCreds.secretValueFromJson('tenderly-project').toString(),
tenderlyAccessKey: tenderlyCreds.secretValueFromJson('tenderly-access-key').toString(),
tenderlyNodeApiKey: tenderlyCreds.secretValueFromJson('tenderly-node-api-key').toString(),
unicornSecret: unicornSecrets.secretValueFromJson('debug-config-unicorn-key').toString(),
alchemyQueryKey: routingApiNewSecrets.secretValueFromJson('alchemy-query-key').toString(),
decentralizedNetworkApiKey: routingApiNewSecrets.secretValueFromJson('decentralized-network-api-key').toString(),
Expand Down Expand Up @@ -404,6 +409,7 @@ new RoutingAPIStack(app, 'RoutingAPIStack', {
tenderlyUser: process.env.TENDERLY_USER!,
tenderlyProject: process.env.TENDERLY_PROJECT!,
tenderlyAccessKey: process.env.TENDERLY_ACCESS_KEY!,
tenderlyNodeApiKey: process.env.TENDERLY_NODE_API_KEY!,
unicornSecret: process.env.UNICORN_SECRET!,
})

Expand Down
3 changes: 3 additions & 0 deletions bin/stacks/routing-api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyUser: string
tenderlyProject: string
tenderlyAccessKey: string
tenderlyNodeApiKey: string
unicornSecret: string
alchemyQueryKey?: string
decentralizedNetworkApiKey?: string
Expand All @@ -67,6 +68,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
tenderlyNodeApiKey,
unicornSecret,
alchemyQueryKey,
decentralizedNetworkApiKey,
Expand Down Expand Up @@ -117,6 +119,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
tenderlyNodeApiKey,
routesDynamoDb,
routesDbCachingRequestFlagDynamoDb,
cachedRoutesDynamoDb,
Expand Down
5 changes: 4 additions & 1 deletion bin/stacks/routing-lambda-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface RoutingLambdaStackProps extends cdk.NestedStackProps {
tenderlyUser: string
tenderlyProject: string
tenderlyAccessKey: string
tenderlyNodeApiKey: string
chatbotSNSArn?: string
routesDynamoDb: aws_dynamodb.Table
routesDbCachingRequestFlagDynamoDb: aws_dynamodb.Table
Expand Down Expand Up @@ -58,6 +59,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
tenderlyNodeApiKey,
routesDynamoDb,
routesDbCachingRequestFlagDynamoDb,
cachedRoutesDynamoDb,
Expand Down Expand Up @@ -117,7 +119,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {

description: 'Routing Lambda',
environment: {
VERSION: '23',
VERSION: '24',
NODE_OPTIONS: '--enable-source-maps',
POOL_CACHE_BUCKET: poolCacheBucket.bucketName,
POOL_CACHE_BUCKET_2: poolCacheBucket2.bucketName,
Expand All @@ -129,6 +131,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {
TENDERLY_USER: tenderlyUser,
TENDERLY_PROJECT: tenderlyProject,
TENDERLY_ACCESS_KEY: tenderlyAccessKey,
TENDERLY_NODE_API_KEY: tenderlyNodeApiKey,
// WARNING: Dynamo table name should be the tableinstance.name, e.g. routesDynamoDb.tableName.
// But we tried and had seen lambd version error:
// The following resource(s) failed to create: [RoutingLambda2CurrentVersion49A1BB948389ce4f9c26b15e2ccb07b4c1bab726].
Expand Down
9 changes: 6 additions & 3 deletions lib/handlers/injector-sor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ import { GlobalRpcProviders } from '../rpc/GlobalRpcProviders'
import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { TrafficSwitchOnChainQuoteProvider } from './quote/provider-migration/v3/traffic-switch-on-chain-quote-provider'
import {
NON_OPTIMISTIC_CACHED_ROUTES_BATCH_PARAMS,
BLOCK_NUMBER_CONFIGS,
GAS_ERROR_FAILURE_OVERRIDES,
NON_OPTIMISTIC_CACHED_ROUTES_BATCH_PARAMS,
OPTIMISTIC_CACHED_ROUTES_BATCH_PARAMS,
RETRY_OPTIONS,
SUCCESS_RATE_FAILURE_OVERRIDES,
OPTIMISTIC_CACHED_ROUTES_BATCH_PARAMS,
} from '../util/onChainQuoteProviderConfigs'
import { v4 } from 'uuid/index'
import { chainProtocols } from '../cron/cache-config'
Expand Down Expand Up @@ -388,13 +388,16 @@ export abstract class InjectorSOR<Router, QueryParams> extends Injector<
process.env.TENDERLY_USER!,
process.env.TENDERLY_PROJECT!,
process.env.TENDERLY_ACCESS_KEY!,
process.env.TENDERLY_NODE_API_KEY!,
v2PoolProvider,
v3PoolProvider,
provider,
portionProvider,
undefined,
// The timeout for the underlying axios call to Tenderly, measured in milliseconds.
2.5 * 1000
2.5 * 1000,
10,
[ChainId.MAINNET]
)

const ethEstimateGasSimulator = new EthEstimateGasSimulator(
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@uniswap/router-sdk": "^1.9.2",
"@uniswap/sdk-core": "^4.2.0",
"@types/semver": "^7.5.8",
"@uniswap/smart-order-router": "3.33.1",
"@uniswap/smart-order-router": "3.34.0",
"@uniswap/token-lists": "^1.0.0-beta.33",
"@uniswap/universal-router-sdk": "^2.1.0",
"@uniswap/v2-sdk": "^4.3.2",
Expand Down

0 comments on commit 984bc35

Please sign in to comment.