Skip to content

Commit

Permalink
fix(caching): Use decentralized network v2 subgraph on Mainnet (#715)
Browse files Browse the repository at this point in the history
* fix(caching): Use decentralized network v2 subgraph on Mainnet

* lint

* passing secret

* prettier
  • Loading branch information
mikeki authored May 31, 2024
1 parent e13e449 commit 1730f1f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class RoutingAPIStage extends Stage {
tenderlyAccessKey: string
unicornSecret: string
alchemyQueryKey?: string
decentralizedNetworkApiKey?: string
}
) {
super(scope, id, props)
Expand All @@ -56,6 +57,7 @@ export class RoutingAPIStage extends Stage {
tenderlyAccessKey,
unicornSecret,
alchemyQueryKey,
decentralizedNetworkApiKey,
} = props

const { url } = new RoutingAPIStack(this, 'RoutingAPI', {
Expand All @@ -74,6 +76,7 @@ export class RoutingAPIStage extends Stage {
tenderlyAccessKey,
unicornSecret,
alchemyQueryKey,
decentralizedNetworkApiKey,
})
this.url = url
}
Expand Down Expand Up @@ -244,6 +247,7 @@ export class RoutingAPIPipeline extends Stack {
tenderlyAccessKey: tenderlyCreds.secretValueFromJson('tenderly-access-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(),
})

const betaUsEast2AppStage = pipeline.addStage(betaUsEast2Stage)
Expand All @@ -268,6 +272,7 @@ export class RoutingAPIPipeline extends Stack {
tenderlyAccessKey: tenderlyCreds.secretValueFromJson('tenderly-access-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(),
})

const prodUsEast2AppStage = pipeline.addStage(prodUsEast2Stage)
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 @@ -47,6 +47,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyAccessKey: string
unicornSecret: string
alchemyQueryKey?: string
decentralizedNetworkApiKey?: string
}
) {
super(parent, name, props)
Expand All @@ -68,6 +69,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyAccessKey,
unicornSecret,
alchemyQueryKey,
decentralizedNetworkApiKey,
} = props

const {
Expand All @@ -87,6 +89,7 @@ export class RoutingAPIStack extends cdk.Stack {
pinata_secret,
hosted_zone,
alchemyQueryKey,
decentralizedNetworkApiKey,
})

const {
Expand Down
6 changes: 5 additions & 1 deletion bin/stacks/routing-caching-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface RoutingCachingStackProps extends cdk.NestedStackProps {
hosted_zone?: string
chatbotSNSArn?: string
alchemyQueryKey?: string
decentralizedNetworkApiKey?: string
}

export class RoutingCachingStack extends cdk.NestedStack {
Expand All @@ -39,15 +40,17 @@ export class RoutingCachingStack extends cdk.NestedStack {
public readonly ipfsCleanPoolCachingLambda: aws_lambda_nodejs.NodejsFunction
public readonly poolCacheLambdaNameArray: string[] = []
public readonly alchemyQueryKey: string | undefined = undefined
public readonly decentralizedNetworkApiKey: string | undefined = undefined

constructor(scope: Construct, name: string, props: RoutingCachingStackProps) {
super(scope, name, props)

const { chatbotSNSArn, alchemyQueryKey } = props
const { chatbotSNSArn, alchemyQueryKey, decentralizedNetworkApiKey } = props

const chatBotTopic = chatbotSNSArn ? aws_sns.Topic.fromTopicArn(this, 'ChatbotTopic', chatbotSNSArn) : undefined

this.alchemyQueryKey = alchemyQueryKey
this.decentralizedNetworkApiKey = decentralizedNetworkApiKey

// TODO: Remove and swap to the new bucket below. Kept around for the rollout, but all requests will go to bucket 2.
this.poolCacheBucket = new aws_s3.Bucket(this, 'PoolCacheBucket')
Expand Down Expand Up @@ -132,6 +135,7 @@ export class RoutingCachingStack extends cdk.NestedStack {
POOL_CACHE_KEY: this.poolCacheKey,
POOL_CACHE_GZIP_KEY: this.poolCacheGzipKey,
ALCHEMY_QUERY_KEY: this.alchemyQueryKey ?? '',
DCN_API_KEY: this.decentralizedNetworkApiKey ?? '',
chainId: chainId.toString(),
protocol,
timeout: timeout.toString(),
Expand Down
5 changes: 4 additions & 1 deletion lib/cron/cache-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const v3SubgraphUrlOverride = (chainId: ChainId) => {

const v2SubgraphUrlOverride = (chainId: ChainId) => {
switch (chainId) {
case ChainId.MAINNET:
return `https://gateway-arbitrum.network.thegraph.com/api/${process.env.DCN_API_KEY}/subgraphs/id/AHjUuKYZTVPNXGKp6c2NcL5hEQWDfvSSrqVDGwzosjVn`
case ChainId.ARBITRUM_ONE:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v2-arbitrum/api`
case ChainId.POLYGON:
Expand Down Expand Up @@ -196,7 +198,8 @@ export const chainProtocols = [
true,
1000,
v2TrackedEthThreshold,
v2UntrackedUsdThreshold
v2UntrackedUsdThreshold,
v2SubgraphUrlOverride(ChainId.MAINNET)
), // 1000 is the largest page size supported by thegraph
},
{
Expand Down

0 comments on commit 1730f1f

Please sign in to comment.