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

chore: [SC-13761] common way to handle internal packages #8

Merged
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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ dist
artifacts

# tsbuildinfo
*.tsbuildinfo
*.tsbuildinfo

# geneated GraphQL types
/**/types/graphql/*.ts

# nx files
.nx
10 changes: 3 additions & 7 deletions apps/summerfi-api/lib/automation-subgraph/graphql.config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
schema: schema.graphql
documents: './queries/**/*.graphql'
config:
namingConvention:
enumValues: keep
generates:
src/types/graphql/generated.ts:
plugins:
Expand Down Expand Up @@ -27,10 +30,3 @@ generates:
MetaTagAttributes: Record<string, string>
UploadId: string
- typed-document-node
extensions:
endpoints:
Default GraphQL Endpoint:
url: https://5twcsg71b5.execute-api.us-east-1.amazonaws.com/staging/summer-automation
headers:
user-agent: JS GraphQL
introspect: false
10 changes: 4 additions & 6 deletions apps/summerfi-api/lib/automation-subgraph/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"name": "automation-subgraph",
"version": "1.0.0",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"tsc": "tsc",
"watch": "tsc -w",
"test": "jest",
"build": "tsc -b -v",
"generate-ts-types": "graphql-codegen --config graphql.config.yml"
},
"files": [
"dist"
],
"author": "Jacob",
"license": "UNLICENSED",
"dependencies": {
"@aws-lambda-powertools/logger": "^1.17.0",
"graphql-request": "^6.1.0",
"shared": "*"
"shared": "workspace:*"
}
}
10 changes: 1 addition & 9 deletions apps/summerfi-api/lib/automation-subgraph/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"composite": true,
"declaration": true,
"declarationMap": true
"outDir": "dist"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"],
"references": [
{
"path": "../shared"
}
]
}
15 changes: 10 additions & 5 deletions apps/summerfi-api/lib/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
"test": "jest",
"build": "tsc -b -v"
},
"files": [
"dist"
],
"author": "Jacob",
"license": "UNLICENSED"
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./*": {
"import": "./dist/*.js",
"types": "./dist/*.d.ts"
}
}
}
8 changes: 4 additions & 4 deletions apps/summerfi-api/lib/contracts/src/get-triggers-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export type AaveBasicBuy = {
maxCoverage: string
debtToken: string
collateralToken: string
opHash: string
execLtv: string
operationName: string
executionLtv: string
targetLtv: string
maxBuyPrice: string
deviation: string
Expand All @@ -96,8 +96,8 @@ export type AaveBasicSell = {
maxCoverage: string
debtToken: string
collateralToken: string
opHash: string
execLtv: string
operationName: string
executionLtv: string
targetLtv: string
minSellPrice: string
deviation: string
Expand Down
5 changes: 1 addition & 4 deletions apps/summerfi-api/lib/contracts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"composite": true,
"declaration": true,
"declarationMap": true
"outDir": "dist"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
Expand Down
11 changes: 6 additions & 5 deletions apps/summerfi-api/lib/get-triggers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
"test": "jest",
"build": "esbuild --bundle src/index.ts --platform=node --target=node20 --outfile=dist/index.js"
},
"author": "Jacob",
"license": "UNLICENSED",
"dependencies": {
"@aws-lambda-powertools/logger": "^1.17.0",
"@aws-lambda-powertools/metrics": "^1.17.0",
"@aws-lambda-powertools/tracer": "^1.17.0",
"graphql-request": "^6.1.0",
"shared": "*",
"automation-subgraph": "*",
"contracts": "*",
"shared": "workspace:*",
"automation-subgraph": "workspace:*",
"contracts": "workspace:*",
"zod": "^3.22.4"
},
"devDependencies": {
"esbuild": "^0.19.11"
}
}
25 changes: 21 additions & 4 deletions apps/summerfi-api/lib/get-triggers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export const handler = async (event: APIGatewayProxyEventV2): Promise<APIGateway

const triggers = await automationSubgraphClient.getTriggers(params)

logger.info(`Got ${triggers.triggers.length} triggers`, {
triggers: triggers.triggers,
account: params.dpm,
})

const aaveStopLossToCollateral: AaveStopLossToCollateral | undefined = triggers.triggers
.filter((trigger) => trigger.triggerType == AaveStopLossToCollateralV2ID)
.map((trigger) => {
Expand Down Expand Up @@ -160,8 +165,14 @@ export const handler = async (event: APIGatewayProxyEventV2): Promise<APIGateway
maxCoverage: trigger.decodedData[trigger.decodedDataNames.indexOf('maxCoverage')],
debtToken: trigger.decodedData[trigger.decodedDataNames.indexOf('debtToken')],
collateralToken: trigger.decodedData[trigger.decodedDataNames.indexOf('collateralToken')],
opHash: trigger.decodedData[trigger.decodedDataNames.indexOf('opHash')],
execLtv: trigger.decodedData[trigger.decodedDataNames.indexOf('execLtv')],
operationName: trigger.decodedData[trigger.decodedDataNames.indexOf('operationName')],
executionLtv:
trigger.decodedData[
Math.max(
trigger.decodedDataNames.indexOf('execLtv'),
trigger.decodedData.indexOf('executionLtv'),
)
],
targetLtv: trigger.decodedData[trigger.decodedDataNames.indexOf('targetLtv')],
maxBuyPrice: trigger.decodedData[trigger.decodedDataNames.indexOf('maxBuyPrice')],
deviation: trigger.decodedData[trigger.decodedDataNames.indexOf('deviation')],
Expand All @@ -185,8 +196,14 @@ export const handler = async (event: APIGatewayProxyEventV2): Promise<APIGateway
maxCoverage: trigger.decodedData[trigger.decodedDataNames.indexOf('maxCoverage')],
debtToken: trigger.decodedData[trigger.decodedDataNames.indexOf('debtToken')],
collateralToken: trigger.decodedData[trigger.decodedDataNames.indexOf('collateralToken')],
opHash: trigger.decodedData[trigger.decodedDataNames.indexOf('opHash')],
execLtv: trigger.decodedData[trigger.decodedDataNames.indexOf('execLtv')],
operationName: trigger.decodedData[trigger.decodedDataNames.indexOf('operationName')],
executionLtv:
trigger.decodedData[
Math.max(
trigger.decodedDataNames.indexOf('execLtv'),
trigger.decodedData.indexOf('executionLtv'),
)
],
targetLtv: trigger.decodedData[trigger.decodedDataNames.indexOf('targetLtv')],
minSellPrice: trigger.decodedData[trigger.decodedDataNames.indexOf('minSellPrice')],
deviation: trigger.decodedData[trigger.decodedDataNames.indexOf('deviation')],
Expand Down
11 changes: 0 additions & 11 deletions apps/summerfi-api/lib/get-triggers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
"rootDir": "src",
"outDir": "dist"
},
"references": [
{
"path": "../shared"
},
{
"path": "../automation-subgraph"
},
{
"path": "../contracts"
}
],
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
3 changes: 2 additions & 1 deletion apps/summerfi-api/lib/portfolio-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"devDependencies": {
},
"dependencies": {
"shared": "*",
"node-fetch": "^3.3.2",
"shared": "workspace:*",
"zod": "^3.22.4"
}
}
2 changes: 1 addition & 1 deletion apps/summerfi-api/lib/portfolio-assets/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-relative-import-paths/no-relative-import-paths */
import { z } from 'zod'
import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'

Expand All @@ -8,6 +7,7 @@ import { DebankToken } from 'shared/debank-types'
import { NetworkNames, PortfolioWalletAsset, PortfolioAssetsResponse } from 'shared/domain-types'
import { DebankNetworkNameToOurs, DebankNetworkNames } from 'shared/debank-helpers'
import { addressSchema } from 'shared/validators'
import fetch from 'node-fetch';

const paramsSchema = z.object({
address: addressSchema,
Expand Down
5 changes: 0 additions & 5 deletions apps/summerfi-api/lib/portfolio-assets/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"rootDir": "src",
"outDir": "dist"
},
"references": [
{
"path": "../shared"
}
],
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
2 changes: 1 addition & 1 deletion apps/summerfi-api/lib/portfolio-migrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"license": "UNLICENSED",
"dependencies": {
"@oasisdex/addresses": "^0.1.14",
"shared": "*",
"shared": "workspace:*",
"viem": "^1.19.3",
"zod": "^3.22.4"
}
Expand Down
8 changes: 0 additions & 8 deletions apps/summerfi-api/lib/portfolio-migrations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
"rootDir": "src",
"outDir": "dist",
"baseUrl": "src",
"paths": {
"shared/*": ["../../shared/src/*"]
}
},
"references": [
{
"path": "../shared"
}
],
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
2 changes: 1 addition & 1 deletion apps/summerfi-api/lib/portfolio-overview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"graphql": "^16.8.1",
"graphql-request": "^6.1.0",
"shared": "*",
"shared": "workspace:*",
"zod": "^3.22.4",
"node-fetch": "^3.3.2"
}
Expand Down
13 changes: 6 additions & 7 deletions apps/summerfi-api/lib/portfolio-overview/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/* eslint-disable no-relative-import-paths/no-relative-import-paths */
import { z } from 'zod'
import type { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'

import { getDefaultErrorMessage } from 'shared/src/helpers'
import { ResponseBadRequest, ResponseInternalServerError, ResponseOk } from 'shared/src/responses'
import { getDefaultErrorMessage } from 'shared/helpers'
import { ResponseBadRequest, ResponseInternalServerError, ResponseOk } from 'shared/responses'
import {
DebankComplexProtocol,
DebankPortfolioItemObject,
DebankSimpleProtocol,
} from 'shared/src/debank-types'
import { PortfolioOverviewResponse } from 'shared/src/domain-types'
import { DEBANK_SUPPORTED_CHAIN_IDS } from 'shared/src/debank-helpers'
} from 'shared/debank-types'
import { PortfolioOverviewResponse } from 'shared/domain-types'
import { DEBANK_SUPPORTED_CHAIN_IDS } from 'shared/debank-helpers'
import { getSupportedPositions } from './utils'
import { addressSchema } from 'shared/src/validators'
import { addressSchema } from 'shared/validators'
import fetch from 'node-fetch'

const paramsSchema = z.object({
Expand Down
5 changes: 0 additions & 5 deletions apps/summerfi-api/lib/portfolio-overview/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"rootDir": "src",
"outDir": "dist"
},
"references": [
{
"path": "../shared"
}
],
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
13 changes: 7 additions & 6 deletions apps/summerfi-api/lib/setup-trigger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
"test": "jest",
"build": "esbuild src/index.ts --bundle --minify --platform=node --target=node20 --outfile=dist/index.js --sourcemap"
},
"author": "Jacob",
"license": "UNLICENSED",
"dependencies": {
"@oasisdex/addresses": "^0.1.18",
"@oasisdex/dma-library": "0.5.26-beta.2",
"@oasisdex/addresses": "0.1.16-dma-v2-workers.1",
"@oasisdex/dma-library": "0.5.21-dma-v2-workers.2",
"@aws-lambda-powertools/logger": "^1.17.0",
"@aws-lambda-powertools/metrics": "^1.17.0",
"@aws-lambda-powertools/tracer": "^1.17.0",
"node-fetch": "^3.3.2",
"shared": "*",
"contracts": "*",
"shared": "workspace:*",
"contracts": "workspace:*",
"viem": "^1.19.11",
"zod": "^3.22.4"
},
"devDependencies": {
"esbuild": "^0.19.11"
}
}
Loading