From d2cdf8afb3ee5d4e0aa20819e0e12588a089ed7e Mon Sep 17 00:00:00 2001 From: Cocoahomology <83151536+Cocoahomology@users.noreply.github.com> Date: Thu, 30 Jun 2022 04:32:37 -0400 Subject: [PATCH] change AWS account --- package.json | 4 ++-- serverless.yml | 31 ++++++------------------------- src/cli/dynamodb.ts | 2 +- src/fetchCoingeckoData.ts | 2 +- src/getPegged.ts | 2 +- src/getPeggedChains.ts | 2 +- src/getPeggeds.ts | 2 +- src/triggerFetchCoingeckoData.ts | 2 +- src/triggerStorePegged.ts | 2 +- src/utils/s3.ts | 2 +- src/utils/shared/dynamodb.ts | 4 ++-- 11 files changed, 18 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 25c537d..78ec975 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "pretest": "npm run prebuild", "build": "sls package", "updateAdapters": "cd DefiLlama-Adapters && git pull", - "fillOld": "set AWS_REGION='us-east-1' && set tableName='prod-table' && npx ts-node src/cli/fillOld.ts", - "fillLast": "export AWS_REGION='eu-central-1' && export tableName='prod-table' && npx ts-node src/cli/fillLast.ts" + "fillOld": "set AWS_REGION='eu-central-1' && set tableName='prod-stablecoins-table' && npx ts-node src/cli/fillOld.ts", + "fillLast": "export AWS_REGION='eu-central-1' && export tableName='prod-stablecoins-table' && npx ts-node src/cli/fillLast.ts" }, "devDependencies": { "@babel/core": "^7.13.10", diff --git a/serverless.yml b/serverless.yml index 4688c70..4c2103c 100644 --- a/serverless.yml +++ b/serverless.yml @@ -1,4 +1,4 @@ -service: cocoahomology +service: llama-stablecoins package: individually: true @@ -8,7 +8,7 @@ provider: name: aws runtime: nodejs14.x memorySize: 130 - region: us-east-1 + region: eu-central-1 endpointType: REGIONAL # Set to regional because the api gateway will be behind a cloudfront distribution stage: dev # Default to dev if no stage is specified tracing: # Enable X-Ray tracing (debugging) @@ -70,7 +70,7 @@ custom: prune: automatic: true number: 5 # Number of versions to keep - tableName: prod-table + tableName: prod-stablecoins-table functions: fallback: @@ -130,11 +130,13 @@ functions: handler: src/triggerStorePegged.default timeout: 900 events: - - schedule: cron(0 * * * ? *) + - schedule: cron(20 * * * ? *) storePeggedPrices: handler: src/storePeggedPrices.default timeout: 900 memorySize: 1024 + events: + - schedule: cron(*/30 * * * ? *) fetchCoingeckoData: handler: src/fetchCoingeckoData.default timeout: 900 @@ -180,27 +182,6 @@ resources: ResponseType: DEFAULT_5XX RestApiId: Ref: 'ApiGatewayRestApi' - # required to enable request path parameter caching in API Gateway - ApiGatewayMethodPeggedchartsChainVarGet: - Properties: - RequestParameters: - method.request.path.chain : false - Integration: - RequestParameters: - integration.request.path.chain: method.request.path.chain - CacheNamespace: ApiGatewayMethodChainVarGetCacheNS - CacheKeyParameters: - - method.request.path.chain - ApiGatewayMethodPeggedPeggedVarGet: - Properties: - RequestParameters: - method.request.path.pegged : false - Integration: - RequestParameters: - integration.request.path.pegged: method.request.path.pegged - CacheNamespace: ApiGatewayMethodPeggedPeggedVarGetCacheNS - CacheKeyParameters: - - method.request.path.pegged plugins: - serverless-esbuild diff --git a/src/cli/dynamodb.ts b/src/cli/dynamodb.ts index 1d2ee53..7243a91 100644 --- a/src/cli/dynamodb.ts +++ b/src/cli/dynamodb.ts @@ -10,7 +10,7 @@ export const hourlyPrefix = "hourlyTvl"; export const dailyPrefix = "dailyTvl"; export const dynamoPrefix = dailyPrefix; -export const TableName = "prod-table"; +export const TableName = "prod-stablecoins-table"; export const maxProtocolId = 300; export const getDailyTxs = (protocolId: string) => diff --git a/src/fetchCoingeckoData.ts b/src/fetchCoingeckoData.ts index e5d3339..72e2c01 100644 --- a/src/fetchCoingeckoData.ts +++ b/src/fetchCoingeckoData.ts @@ -94,7 +94,7 @@ const handler = async (event: any, context: AWSLambda.Context) => { return; } else { await sleep(Math.max(context.getRemainingTimeInMillis() - 10e3, 0)); // Wait until there's 10 seconds left - await invokeLambda(`cocoahomology-dev-fetchCoingeckoData`, { + await invokeLambda(`llama-stablecoins-dev-fetchCoingeckoData`, { coins: rejected, depth: depth + 1, }); diff --git a/src/getPegged.ts b/src/getPegged.ts index e4951bf..e823386 100644 --- a/src/getPegged.ts +++ b/src/getPegged.ts @@ -37,7 +37,7 @@ export async function craftProtocolResponse( ) { let prices = {} as any; prices = await fetch( - "https://cocoahomology-datasets.s3.amazonaws.com/peggedPrices.json" + "https://llama-stablecoins-data.s3.eu-central-1.amazonaws.com/peggedPrices.json" ) .then((res: any) => res.json()) .catch(() => { diff --git a/src/getPeggedChains.ts b/src/getPeggedChains.ts index 68cc6c0..b3fe9e2 100644 --- a/src/getPeggedChains.ts +++ b/src/getPeggedChains.ts @@ -14,7 +14,7 @@ export async function craftPeggedChainsResponse() { const chainMcap = {} as { [chain: string]: number }; let prices = {} as any; prices = await fetch( - "https://cocoahomology-datasets.s3.amazonaws.com/peggedPrices.json" + "https://llama-stablecoins-data.s3.eu-central-1.amazonaws.com/peggedPrices.json" ) .then((res: any) => res.json()) .catch(() => { diff --git a/src/getPeggeds.ts b/src/getPeggeds.ts index f9614c4..6471741 100644 --- a/src/getPeggeds.ts +++ b/src/getPeggeds.ts @@ -53,7 +53,7 @@ export async function craftProtocolsResponse( let prices = {} as any; if (getPrices) { prices = await fetch( - "https://cocoahomology-datasets.s3.amazonaws.com/peggedPrices.json" + "https://llama-stablecoins-data.s3.eu-central-1.amazonaws.com/peggedPrices.json" ) .then((res: any) => res.json()) .catch(() => { diff --git a/src/triggerFetchCoingeckoData.ts b/src/triggerFetchCoingeckoData.ts index 9d8242e..0df792a 100644 --- a/src/triggerFetchCoingeckoData.ts +++ b/src/triggerFetchCoingeckoData.ts @@ -12,7 +12,7 @@ const handler = async () => { coins: coins.slice(i, i + step), depth: 0, }; - await invokeLambda(`cocoahomology-dev-fetchCoingeckoData`, event); + await invokeLambda(`llama-stablecoins-dev-fetchCoingeckoData`, event); } }; diff --git a/src/triggerStorePegged.ts b/src/triggerStorePegged.ts index 3256e4e..e8d0cec 100644 --- a/src/triggerStorePegged.ts +++ b/src/triggerStorePegged.ts @@ -21,7 +21,7 @@ const handler = async () => { const event = { peggedIndexes: peggedIndexes.slice(i, i + step), }; - await Promise.all([invokeLambda(`cocoahomology-dev-storePeggedAssets`, event), timeout(10000)]); + await Promise.all([invokeLambda(`llama-stablecoins-dev-storePeggedAssets`, event), timeout(10000)]); } }; diff --git a/src/utils/s3.ts b/src/utils/s3.ts index 56a5851..0f0e35b 100644 --- a/src/utils/s3.ts +++ b/src/utils/s3.ts @@ -1,7 +1,7 @@ import aws from "aws-sdk"; import type { Readable } from "stream"; -const datasetBucket = "cocoahomology-datasets"; +const datasetBucket = "llama-stablecoins-data"; function next21Minutedate() { const dt = new Date(); diff --git a/src/utils/shared/dynamodb.ts b/src/utils/shared/dynamodb.ts index 75dd21c..d194c23 100644 --- a/src/utils/shared/dynamodb.ts +++ b/src/utils/shared/dynamodb.ts @@ -2,9 +2,9 @@ import AWS from "aws-sdk"; import sleep from "./sleep"; const client = new AWS.DynamoDB.DocumentClient({ - region: "us-east-1", + region: "eu-central-1", }); -export const TableName = "prod-table"; +export const TableName = "prod-stablecoins-table"; const dynamodb = { get: (