From fd2929204dfef0fd4ec9bb325e33ea5dbba06ab0 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Sat, 23 Sep 2023 21:08:13 -0700 Subject: [PATCH 01/20] feat: analytics --- libs/analytics/.babelrc | 12 + libs/analytics/.eslintrc.json | 18 ++ libs/analytics/README.md | 7 + libs/analytics/project.json | 16 ++ libs/analytics/src/index.ts | 1 + libs/analytics/src/lib/analytics.stories.tsx | 63 +++++ libs/analytics/src/lib/analytics.tsx | 232 +++++++++++++++++++ libs/analytics/tsconfig.json | 17 ++ libs/analytics/tsconfig.lib.json | 24 ++ libs/shared/theme/src/Palette.stories.tsx | 7 + libs/shared/theme/src/theme.tsx | 2 + package.json | 2 + pnpm-lock.yaml | 21 ++ tsconfig.base.json | 3 + 14 files changed, 425 insertions(+) create mode 100644 libs/analytics/.babelrc create mode 100644 libs/analytics/.eslintrc.json create mode 100644 libs/analytics/README.md create mode 100644 libs/analytics/project.json create mode 100644 libs/analytics/src/index.ts create mode 100644 libs/analytics/src/lib/analytics.stories.tsx create mode 100644 libs/analytics/src/lib/analytics.tsx create mode 100644 libs/analytics/tsconfig.json create mode 100644 libs/analytics/tsconfig.lib.json diff --git a/libs/analytics/.babelrc b/libs/analytics/.babelrc new file mode 100644 index 000000000..1ea870ead --- /dev/null +++ b/libs/analytics/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/analytics/.eslintrc.json b/libs/analytics/.eslintrc.json new file mode 100644 index 000000000..a39ac5d05 --- /dev/null +++ b/libs/analytics/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/analytics/README.md b/libs/analytics/README.md new file mode 100644 index 000000000..87e988a75 --- /dev/null +++ b/libs/analytics/README.md @@ -0,0 +1,7 @@ +# analytics + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test analytics` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/analytics/project.json b/libs/analytics/project.json new file mode 100644 index 000000000..5247073ae --- /dev/null +++ b/libs/analytics/project.json @@ -0,0 +1,16 @@ +{ + "name": "analytics", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/analytics/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/analytics/**/*.{ts,tsx,js,jsx}"] + } + } + } +} diff --git a/libs/analytics/src/index.ts b/libs/analytics/src/index.ts new file mode 100644 index 000000000..4454600c0 --- /dev/null +++ b/libs/analytics/src/index.ts @@ -0,0 +1 @@ +export * from './lib/analytics'; diff --git a/libs/analytics/src/lib/analytics.stories.tsx b/libs/analytics/src/lib/analytics.stories.tsx new file mode 100644 index 000000000..ccb98af5d --- /dev/null +++ b/libs/analytics/src/lib/analytics.stories.tsx @@ -0,0 +1,63 @@ +import { faker } from '@faker-js/faker'; +import { Container } from '@mui/material'; +import dayjs from 'dayjs'; + +import { Analytics } from './analytics'; + +import type { Meta, StoryObj } from '@storybook/react'; + +faker.seed(4548); + +function array(n: number, initial: T, fn: (last: T) => T) { + let last: T = initial; + return new Array(n).fill(0).map((_, index) => { + if (index === 0) return last; + return (last = fn(last)); + }); +} + +const ema = (p: number) => { + let last: number; + return (val: number) => { + return (last = (val + (last ?? val) * (p - 1)) / p); + }; +}; + +const smooth = ema(7); + +const meta: Meta = { + component: Analytics, + title: 'Analytics/test', + args: { + title: 'APY', + data: { + datasets: [ + { + type: 'line', + data: array(180, { x: new Date('2023-01-01'), y: 0.05 }, (last) => ({ + x: dayjs(last.x).add(1, 'day').toDate(), + y: faker.number.float({ + min: last.y * 0.9, + max: last.y * 1.1, + }), + })).map((d) => ({ + x: d.x, + y: smooth(d.y), + })), + }, + ], + }, + formatValues: (val) => { + return `${Math.floor(Number(val) * 10000) / 100}%`; + }, + }, + render: (args) => ( + + + + ), +}; + +export default meta; + +export const Default: StoryObj = {}; diff --git a/libs/analytics/src/lib/analytics.tsx b/libs/analytics/src/lib/analytics.tsx new file mode 100644 index 000000000..b9c239d26 --- /dev/null +++ b/libs/analytics/src/lib/analytics.tsx @@ -0,0 +1,232 @@ +import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; + +import { useState } from 'react'; + +import { Box, Paper, Stack, useTheme } from '@mui/material'; +import { Chart, TimeScale } from 'chart.js'; +import dayjs from 'dayjs'; +import { mergeDeepRight } from 'ramda'; +import { Line } from 'react-chartjs-2'; + +import type { ChartData, ChartOptions, Plugin } from 'chart.js'; +import type { ComponentProps } from 'react'; + +Chart.register(TimeScale); + +/** + * TODO: Figure out a proper home for these? + */ +const chartTheme = { + primary1: '#CF75D5', + primary2: '#FEDBA8', + position: '#0074F0', + background: '#828699', + grid: '#2e2f3d', + positive: '#4EBE96', + negative: '#D44E66', +}; + +const full = { xs: 1, sm: 2, md: 3 }; +const half = { xs: 0.5, sm: 1, md: 1.5 }; +const quarter = { xs: 0.25, sm: 0.5, md: 0.75 }; + +export function Analytics(props: { + title: string; + titleProps: ComponentProps; + data: ChartData<'line', { x: Date; y: number }[]>; + formatValues?: (value: number | string) => string | number; +}) { + if (!props.formatValues) { + props.formatValues = (value: number | string) => value; + } + const firstData = props.data.datasets.map((d) => d.data[0]); + const lastData = props.data.datasets.map((d) => d.data[d.data.length - 1]); + const [currentData, setCurrentData] = useState(lastData); + const [hovering, setHovering] = useState(false); + const change = currentData[0].y / firstData[0].y - 1; + return ( + + + + + + + {props.title} + + + + {props.formatValues(currentData[0].y)} + + {change ? ( + 0 + ? chartTheme.positive + : change < 0 + ? chartTheme.negative + : undefined + } + > + {change > 0 ? '+' : null} + {props.formatValues(change)} + + ) : null} + + + {dayjs(currentData[0].x).format('lll')} + + + Filter Options + + + { + const elements = chart.getActiveElements(); + if (elements.length) { + setCurrentData( + elements.map( + (element) => + props.data.datasets[element.datasetIndex].data[ + element.index + ], + ), + ); + setHovering(true); + } else { + setCurrentData(lastData); + setHovering(false); + } + }, + }, + ]} + options={{ + scales: { + y: { + ticks: { + callback: props.formatValues, + }, + }, + }, + }} + /> + + + + + ); +} + +export const DatedLineChart = (props: ComponentProps) => { + const theme = useTheme(); + let options: ChartOptions<'line'> = { + backgroundColor: chartTheme.background, + color: theme.palette.text.secondary, + responsive: true, + interaction: { + mode: 'nearest', + axis: 'x', + intersect: false, + }, + animation: { + easing: 'easeInOutQuad', + }, + scales: { + x: { + grid: { + display: false, + }, + border: { + display: true, + color: chartTheme.grid, + }, + type: 'time', + ticks: { + autoSkip: true, + autoSkipPadding: 50, + maxRotation: 0, + align: 'start', + }, + time: { + unit: 'day', + }, + }, + y: { + grid: { + color: chartTheme.grid, + drawTicks: false, + }, + border: { + display: false, + color: chartTheme.grid, + dash: [3, 3], + }, + position: 'right', + ticks: { + crossAlign: 'far', + }, + }, + }, + elements: { + line: { + borderWidth: 1, + }, + point: { + radius: 0, + }, + }, + borderColor: (ctx) => { + const gradient = ctx.chart.ctx.createLinearGradient( + 0, + 0, + ctx.chart.width, + ctx.chart.height, + ); + gradient.addColorStop(0, chartTheme.primary2); + gradient.addColorStop(1, chartTheme.primary1); + return gradient; + }, + }; + if (props.options) { + options = mergeDeepRight(props.options, options) as ChartOptions<'line'>; + } + return ( + + ); +}; + +const verticalLinePlugin: Plugin<'line'> = { + id: 'verticalLineAtIndex', + afterDraw: (chart) => { + const active = chart.getActiveElements(); + if (active[0]) { + const ctx = chart.ctx; + const x = active[0].element.x; + + ctx.save(); + ctx.beginPath(); + ctx.moveTo(x, chart.chartArea.top); + ctx.lineTo(x, chart.chartArea.bottom); + ctx.setLineDash([2, 2]); + ctx.strokeStyle = chartTheme.position; + ctx.lineWidth = 0.5; + ctx.stroke(); + ctx.restore(); + } + }, +}; diff --git a/libs/analytics/tsconfig.json b/libs/analytics/tsconfig.json new file mode 100644 index 000000000..95cfeb243 --- /dev/null +++ b/libs/analytics/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": false, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "extends": "../../tsconfig.base.json" +} diff --git a/libs/analytics/tsconfig.lib.json b/libs/analytics/tsconfig.lib.json new file mode 100644 index 000000000..cfc484329 --- /dev/null +++ b/libs/analytics/tsconfig.lib.json @@ -0,0 +1,24 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [ + "node", + + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts" + ] + }, + "exclude": [ + "jest.config.ts", + "src/**/*.spec.ts", + "src/**/*.test.ts", + "src/**/*.spec.tsx", + "src/**/*.test.tsx", + "src/**/*.spec.js", + "src/**/*.test.js", + "src/**/*.spec.jsx", + "src/**/*.test.jsx" + ], + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] +} diff --git a/libs/shared/theme/src/Palette.stories.tsx b/libs/shared/theme/src/Palette.stories.tsx index 32ff82147..805accee8 100644 --- a/libs/shared/theme/src/Palette.stories.tsx +++ b/libs/shared/theme/src/Palette.stories.tsx @@ -162,20 +162,27 @@ const PaletteView = ({ palette, ...rest }: PaletteViewProps) => ( > {capitalize(key)} + {/* eslint-disable @typescript-eslint/ban-ts-comment */} + {/* @ts-ignore */} {typeof palette[key] === 'object' ? ( + // @ts-ignore Object.keys(palette[key]).map((k) => ( )) ) : ( + // @ts-ignore )} + {/* eslint-enable @typescript-eslint/ban-ts-comment */} ))} diff --git a/libs/shared/theme/src/theme.tsx b/libs/shared/theme/src/theme.tsx index 61565719c..94cc0f66f 100644 --- a/libs/shared/theme/src/theme.tsx +++ b/libs/shared/theme/src/theme.tsx @@ -14,6 +14,8 @@ export const theme = extendTheme({ dark: '#0274f1', light: '#b361e6', contrastText: '#FAFBFB', + '400': '#CF75D5', // Often used in charts. + '500': '#FEDBA8', // Often used in charts. }, secondary: { main: '#0074F0', diff --git a/package.json b/package.json index e8fd301f1..d3dff97b3 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "@wagmi/core": "^1.4.1", "axios": "^1.5.0", "chart.js": "^4.4.0", + "chartjs-adapter-dayjs-4": "^1.0.4", + "dayjs": "^1.11.10", "graphql": "^16.8.0", "immer": "^10.0.2", "ramda": "^0.29.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index de0bdc9ab..954dcbf45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,12 @@ dependencies: chart.js: specifier: ^4.4.0 version: 4.4.0 + chartjs-adapter-dayjs-4: + specifier: ^1.0.4 + version: 1.0.4(chart.js@4.4.0)(dayjs@1.11.10) + dayjs: + specifier: ^1.11.10 + version: 1.11.10 graphql: specifier: ^16.8.0 version: 16.8.0 @@ -8885,6 +8891,17 @@ packages: '@kurkle/color': 0.3.2 dev: false + /chartjs-adapter-dayjs-4@1.0.4(chart.js@4.4.0)(dayjs@1.11.10): + resolution: {integrity: sha512-yy9BAYW4aNzPVrCWZetbILegTRb7HokhgospPoC3b5iZ5qdlqNmXts2KdSp6AqnjkPAp/YWyHDxLvIvwt5x81w==} + engines: {node: '>=10'} + peerDependencies: + chart.js: '>=4.0.1' + dayjs: ^1.9.7 + dependencies: + chart.js: 4.4.0 + dayjs: 1.11.10 + dev: false + /check-error@1.0.2: resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==} dev: true @@ -9309,6 +9326,10 @@ packages: resolution: {integrity: sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g==} dev: true + /dayjs@1.11.10: + resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} + dev: false + /de-indent@1.0.2: resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==} dev: true diff --git a/tsconfig.base.json b/tsconfig.base.json index 4d831345c..8ac9c5a3b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -20,6 +20,9 @@ "strict": false, "baseUrl": ".", "paths": { + "@origin/analytics": [ + "libs/analytics/src/index.ts" + ], "@origin/oeth/history": [ "libs/oeth/history/src/index.ts" ], From aa7f6b1d87e771655581f4516186dad25e67cd44 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Sat, 23 Sep 2023 21:13:37 -0700 Subject: [PATCH 02/20] feat: analytics --- libs/analytics/src/index.ts | 2 +- ...alytics.stories.tsx => TimeLineChart.stories.tsx} | 12 ++++++------ .../src/lib/{analytics.tsx => TimeLineChart.tsx} | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) rename libs/analytics/src/lib/{analytics.stories.tsx => TimeLineChart.stories.tsx} (82%) rename libs/analytics/src/lib/{analytics.tsx => TimeLineChart.tsx} (99%) diff --git a/libs/analytics/src/index.ts b/libs/analytics/src/index.ts index 4454600c0..e1389c141 100644 --- a/libs/analytics/src/index.ts +++ b/libs/analytics/src/index.ts @@ -1 +1 @@ -export * from './lib/analytics'; +export * from './lib/TimeLineChart'; diff --git a/libs/analytics/src/lib/analytics.stories.tsx b/libs/analytics/src/lib/TimeLineChart.stories.tsx similarity index 82% rename from libs/analytics/src/lib/analytics.stories.tsx rename to libs/analytics/src/lib/TimeLineChart.stories.tsx index ccb98af5d..5dd7b462c 100644 --- a/libs/analytics/src/lib/analytics.stories.tsx +++ b/libs/analytics/src/lib/TimeLineChart.stories.tsx @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { Container } from '@mui/material'; import dayjs from 'dayjs'; -import { Analytics } from './analytics'; +import { TimeLineChart } from './TimeLineChart'; import type { Meta, StoryObj } from '@storybook/react'; @@ -25,9 +25,9 @@ const ema = (p: number) => { const smooth = ema(7); -const meta: Meta = { - component: Analytics, - title: 'Analytics/test', +const meta: Meta = { + component: TimeLineChart, + title: 'Analytics/TimeLineChart', args: { title: 'APY', data: { @@ -53,11 +53,11 @@ const meta: Meta = { }, render: (args) => ( - + ), }; export default meta; -export const Default: StoryObj = {}; +export const Default: StoryObj = {}; diff --git a/libs/analytics/src/lib/analytics.tsx b/libs/analytics/src/lib/TimeLineChart.tsx similarity index 99% rename from libs/analytics/src/lib/analytics.tsx rename to libs/analytics/src/lib/TimeLineChart.tsx index b9c239d26..ef9d6e2c6 100644 --- a/libs/analytics/src/lib/analytics.tsx +++ b/libs/analytics/src/lib/TimeLineChart.tsx @@ -30,7 +30,7 @@ const full = { xs: 1, sm: 2, md: 3 }; const half = { xs: 0.5, sm: 1, md: 1.5 }; const quarter = { xs: 0.25, sm: 0.5, md: 0.75 }; -export function Analytics(props: { +export function TimeLineChart(props: { title: string; titleProps: ComponentProps; data: ChartData<'line', { x: Date; y: number }[]>; From b5580f7aabca7f81d4bab2df9e65b95fad1de3e7 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Sun, 24 Sep 2023 10:00:22 -0700 Subject: [PATCH 03/20] feat: analytics --- libs/analytics/src/lib/TimeLineChart.tsx | 87 ++++++++++++++++-------- 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/libs/analytics/src/lib/TimeLineChart.tsx b/libs/analytics/src/lib/TimeLineChart.tsx index ef9d6e2c6..2fc575b11 100644 --- a/libs/analytics/src/lib/TimeLineChart.tsx +++ b/libs/analytics/src/lib/TimeLineChart.tsx @@ -8,6 +8,7 @@ import dayjs from 'dayjs'; import { mergeDeepRight } from 'ramda'; import { Line } from 'react-chartjs-2'; +import type { Theme } from '@mui/material'; import type { ChartData, ChartOptions, Plugin } from 'chart.js'; import type { ComponentProps } from 'react'; @@ -20,7 +21,6 @@ const chartTheme = { primary1: '#CF75D5', primary2: '#FEDBA8', position: '#0074F0', - background: '#828699', grid: '#2e2f3d', positive: '#4EBE96', negative: '#D44E66', @@ -47,19 +47,25 @@ export function TimeLineChart(props: { return ( - + - + {props.title} - + {props.formatValues(currentData[0].y)} {change ? ( @@ -79,8 +85,8 @@ export function TimeLineChart(props: { ) : null} - - {dayjs(currentData[0].x).format('lll')} + + {dayjs(currentData[0].x).format('ll')} Filter Options @@ -130,8 +136,6 @@ export function TimeLineChart(props: { export const DatedLineChart = (props: ComponentProps) => { const theme = useTheme(); let options: ChartOptions<'line'> = { - backgroundColor: chartTheme.background, - color: theme.palette.text.secondary, responsive: true, interaction: { mode: 'nearest', @@ -185,6 +189,11 @@ export const DatedLineChart = (props: ComponentProps) => { radius: 0, }, }, + layout: { + padding: { + top: 30, // Depended on by `verticalLinePlugin` + }, + }, borderColor: (ctx) => { const gradient = ctx.chart.ctx.createLinearGradient( 0, @@ -203,30 +212,52 @@ export const DatedLineChart = (props: ComponentProps) => { return ( ); }; -const verticalLinePlugin: Plugin<'line'> = { - id: 'verticalLineAtIndex', - afterDraw: (chart) => { - const active = chart.getActiveElements(); - if (active[0]) { - const ctx = chart.ctx; - const x = active[0].element.x; +const verticalLinePlugin = (theme: Theme) => { + const plugin: Plugin<'line'> = { + id: 'verticalLineAtIndex', + afterDraw: (chart) => { + const active = chart.getActiveElements(); + if (active[0]) { + const ctx = chart.ctx; + const x = active[0].element.x; + const data = chart.data.datasets[0].data[ + active[0].index + ] as unknown as { + x: Date; + y: number; + }; - ctx.save(); - ctx.beginPath(); - ctx.moveTo(x, chart.chartArea.top); - ctx.lineTo(x, chart.chartArea.bottom); - ctx.setLineDash([2, 2]); - ctx.strokeStyle = chartTheme.position; - ctx.lineWidth = 0.5; - ctx.stroke(); - ctx.restore(); - } - }, + const heightAboveChart = 30; + ctx.save(); + ctx.beginPath(); + ctx.moveTo(x, chart.chartArea.top - heightAboveChart); + ctx.lineTo(x, chart.chartArea.bottom); + ctx.setLineDash([2, 2]); + ctx.strokeStyle = chartTheme.position; + ctx.lineWidth = 0.5; + ctx.stroke(); + ctx.font = '0.875rem Inter'; + ctx.fillStyle = theme.palette.text.primary; + ctx.textAlign = 'start'; + const text = dayjs(data.x).format('lll'); + const textSize = ctx.measureText(text); + ctx.fillText( + dayjs(data.x).format('lll'), + x + heightAboveChart / 2, + chart.chartArea.top - + heightAboveChart + + textSize.actualBoundingBoxAscent, + ); + ctx.restore(); + } + }, + }; + return plugin; }; From 40c3ebf93488d4efae444f53dc9ebbe1331dae86 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Mon, 25 Sep 2023 17:39:05 -0700 Subject: [PATCH 04/20] chart --- .../src/{lib => }/TimeLineChart.stories.tsx | 5 + .../analytics/src/{lib => }/TimeLineChart.tsx | 106 ++++++++++++++++-- libs/analytics/src/index.ts | 2 +- 3 files changed, 101 insertions(+), 12 deletions(-) rename libs/analytics/src/{lib => }/TimeLineChart.stories.tsx (91%) rename libs/analytics/src/{lib => }/TimeLineChart.tsx (68%) diff --git a/libs/analytics/src/lib/TimeLineChart.stories.tsx b/libs/analytics/src/TimeLineChart.stories.tsx similarity index 91% rename from libs/analytics/src/lib/TimeLineChart.stories.tsx rename to libs/analytics/src/TimeLineChart.stories.tsx index 5dd7b462c..42978764b 100644 --- a/libs/analytics/src/lib/TimeLineChart.stories.tsx +++ b/libs/analytics/src/TimeLineChart.stories.tsx @@ -30,6 +30,11 @@ const meta: Meta = { title: 'Analytics/TimeLineChart', args: { title: 'APY', + filter: { + options: ['1W', '1M', '6M', '1Y', 'All'], + value: '1W', + onChange: (value) => console.log(value), + }, data: { datasets: [ { diff --git a/libs/analytics/src/lib/TimeLineChart.tsx b/libs/analytics/src/TimeLineChart.tsx similarity index 68% rename from libs/analytics/src/lib/TimeLineChart.tsx rename to libs/analytics/src/TimeLineChart.tsx index 2fc575b11..b2f6efef8 100644 --- a/libs/analytics/src/lib/TimeLineChart.tsx +++ b/libs/analytics/src/TimeLineChart.tsx @@ -2,13 +2,13 @@ import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; import { useState } from 'react'; -import { Box, Paper, Stack, useTheme } from '@mui/material'; +import { Box, MenuItem, Paper, Select, Stack, useTheme } from '@mui/material'; import { Chart, TimeScale } from 'chart.js'; import dayjs from 'dayjs'; import { mergeDeepRight } from 'ramda'; import { Line } from 'react-chartjs-2'; -import type { Theme } from '@mui/material'; +import type { Theme } from '@origin/shared/theme'; import type { ChartData, ChartOptions, Plugin } from 'chart.js'; import type { ComponentProps } from 'react'; @@ -30,11 +30,16 @@ const full = { xs: 1, sm: 2, md: 3 }; const half = { xs: 0.5, sm: 1, md: 1.5 }; const quarter = { xs: 0.25, sm: 0.5, md: 0.75 }; -export function TimeLineChart(props: { +export function TimeLineChart(props: { title: string; titleProps: ComponentProps; data: ChartData<'line', { x: Date; y: number }[]>; formatValues?: (value: number | string) => string | number; + filter?: { + options: FilterOption[]; + value: FilterOption; + onChange?: (value: FilterOption) => void; + }; }) { if (!props.formatValues) { props.formatValues = (value: number | string) => value; @@ -46,11 +51,11 @@ export function TimeLineChart(props: { const change = currentData[0].y / firstData[0].y - 1; return ( - + {props.title} - + - Filter Options + + {props.filter && ( + + )} + + - + ); } +export const DateFilterPicker = ({ + options, + value, + onChange, +}: { + options: T[]; + value: T; + onChange?: (val: T) => void; +}) => { + const selectedBackground = + 'linear-gradient(90deg, rgba(140, 102, 252, 0.30) -28.99%, rgba(2, 116, 241, 0.30) 144.97%);'; + const hoverBackground = + 'linear-gradient(90deg, rgba(140, 102, 252, 0.10) -28.99%, rgba(2, 116, 241, 0.10) 144.97%);'; + return ( + theme.palette.grey['700'], + }} + > + {options.map((option) => { + const isSelected = value === option; + return ( + + isSelected + ? theme.palette.text.secondary + : theme.palette.text.primary, + py: { xs: 0.5, sm: 1 }, + px: { xs: 0.75, sm: 1.5 }, + borderRadius: '5px', + cursor: 'pointer', + transition: 'background 2s ease-out 1000ms', + background: isSelected ? selectedBackground : undefined, + '&:hover': { + color: (theme) => theme.palette.text.secondary, + background: isSelected ? selectedBackground : hoverBackground, + }, + }} + onClick={() => onChange?.(option)} + > + {option} + + ); + })} + + ); +}; + export const DatedLineChart = (props: ComponentProps) => { - const theme = useTheme(); + const theme = useTheme(); let options: ChartOptions<'line'> = { responsive: true, interaction: { @@ -245,12 +327,14 @@ const verticalLinePlugin = (theme: Theme) => { ctx.stroke(); ctx.font = '0.875rem Inter'; ctx.fillStyle = theme.palette.text.primary; - ctx.textAlign = 'start'; const text = dayjs(data.x).format('lll'); const textSize = ctx.measureText(text); + const fromLeft = + x + textSize.actualBoundingBoxRight <= chart.chartArea.right; + ctx.textAlign = fromLeft ? 'start' : 'end'; ctx.fillText( dayjs(data.x).format('lll'), - x + heightAboveChart / 2, + x + (fromLeft ? heightAboveChart : -heightAboveChart) / 2, chart.chartArea.top - heightAboveChart + textSize.actualBoundingBoxAscent, diff --git a/libs/analytics/src/index.ts b/libs/analytics/src/index.ts index e1389c141..dd238161b 100644 --- a/libs/analytics/src/index.ts +++ b/libs/analytics/src/index.ts @@ -1 +1 @@ -export * from './lib/TimeLineChart'; +export * from './TimeLineChart'; From 554e6af69a61fb9cad9d7f72f9a042c9f7bd282c Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Mon, 25 Sep 2023 17:39:17 -0700 Subject: [PATCH 05/20] feat: financial statement --- .../src/FinancialStatement.stories.tsx | 65 +++++ libs/analytics/src/FinancialStatement.tsx | 231 ++++++++++++++++++ libs/analytics/src/colors.ts | 2 + 3 files changed, 298 insertions(+) create mode 100644 libs/analytics/src/FinancialStatement.stories.tsx create mode 100644 libs/analytics/src/FinancialStatement.tsx create mode 100644 libs/analytics/src/colors.ts diff --git a/libs/analytics/src/FinancialStatement.stories.tsx b/libs/analytics/src/FinancialStatement.stories.tsx new file mode 100644 index 000000000..82c0d479e --- /dev/null +++ b/libs/analytics/src/FinancialStatement.stories.tsx @@ -0,0 +1,65 @@ +import { faker } from '@faker-js/faker'; + +import { FinancialStatement } from './FinancialStatement'; + +import type { Meta, StoryObj } from '@storybook/react'; + +faker.seed(4548); + +function array(n: number, initial: T, fn: (last: T) => T) { + let last: T = initial; + return new Array(n).fill(0).map((_, index) => { + if (index === 0) return last; + return (last = fn(last)); + }); +} + +function randomValues(min = 100000, max = 30000000) { + return array(2, faker.number.int({ min, max }), (last) => + faker.number.int({ min: last * 0.75, max: last * 1.25 }), + ); +} + +const meta: Meta = { + component: FinancialStatement, + title: 'Analytics/FinancialStatement', + args: { + dataLastUpdated: 123456789, + columns: ['31 August 2023', '1 week ago'], + data: { + Assets: { + Vault: { + ETH: [125000, 0], + WETH: [125000, 1], + stETH: [0, 125000], + rETH: [1, 125000], + frxETH: [0, 0], + }, + Curve: { + ETH: randomValues(), + OETH: randomValues(), + }, + 'Frax Staking': { + ETH: randomValues(), + OETH: randomValues(), + }, + 'Morpho Aave': { + WETH: randomValues(), + }, + Dripper: { + WETH: randomValues(20000, 50000), + }, + }, + Liabilities: { + 'Token supply': { + OETH: randomValues(10000000, 1000000000), + }, + }, + }, + }, + render: (args) => , +}; + +export default meta; + +export const Default: StoryObj = {}; diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx new file mode 100644 index 000000000..326ce2ff4 --- /dev/null +++ b/libs/analytics/src/FinancialStatement.tsx @@ -0,0 +1,231 @@ +import { Box, Paper, Stack, useMediaQuery, useTheme } from '@mui/material'; +import { useIntl } from 'react-intl'; + +import * as colors from './colors'; + +const calculateChange = (from: number, to: number) => { + if (from === 0 && to === 0) return 0; + const change = -(1 - to / from); + return Math[change > 0 ? 'floor' : 'ceil'](change * 10000) / 100; +}; + +export const FinancialStatement = (props: { + dataLastUpdated: number; + columns: string[]; + data: Record>>; +}) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + const columnWeight = props.columns.length + 2; + return ( + theme.palette.text.primary} + fontFamily={'Inter'} + fontSize={{ xs: '.7rem', sm: '.875rem' }} + > + + theme.palette.primary.contrastText} + sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} + fontSize={{ xs: '.875rem', sm: '1.125rem' }} + px={{ xs: 1, sm: 2, md: 4 }} + py={{ xs: 2, sm: 3, md: 4 }} + > + + {props.columns.map((column) => ( + + {column} + + ))} + + {isMobile ? 'Diff' : 'Difference'} + + + + {Object.entries(props.data).map(([title, data]) => ( + + ))} + + ); +}; + +const Table = (props: { + title: string; + data: Record>; +}) => { + const totals = Object.values(props.data).reduce((totals, section) => { + for (const asset of Object.values(section)) { + for (let i = 0; i < asset.length; i++) { + totals[i] = (totals[i] ?? 0) + asset[i]; + } + } + return totals; + }, [] as number[]); + const columnWeight = totals.length + 2; + + return ( + + + {/* Body */} + + {Object.entries(props.data).map(([title, data]) => ( +
+ ))} + + + {/* Total */} + theme.palette.primary.contrastText} + sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} + > + + TOTAL {props.title.toUpperCase()} + + {totals.map((value, index) => ( + + ))} + + + + + ); +}; + +const Section = (props: { title: string; data: Record }) => { + return ( + theme.palette.grey['700'], + }} + px={{ xs: 1, sm: 2, md: 4 }} + gap={{ xs: 1, sm: 2, md: 4 }} + pt={{ xs: 1, sm: 2, md: 4 }} + > + theme.palette.primary.contrastText} + > + {props.title} + + + {Object.entries(props.data).map(([title, data]) => ( + + ))} + + + ); +}; + +const Asset = (props: { title: string; data: number[] }) => { + const columnWeight = props.data.length + 2; + return ( + + + + {props.title} + + {props.data.map((value, index) => ( + + ))} + + + + ); +}; + +export const DataColumn = ({ + value, + columnWeight, +}: { + value: number; + columnWeight: number; +}) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + const intl = useIntl(); + return ( + theme.palette.primary.contrastText} + ml={1} + > + theme.palette.text.primary} + pr={{ xs: 0.1, sm: 0.15, md: 0.2 }} + > + {'$'} + + {intl.formatNumber(value, { + notation: isMobile ? 'compact' : 'standard', + maximumFractionDigits: isMobile ? 1 : 2, + })} + + ); +}; + +export const ChangeColumn = ({ + values, + columnWeight, +}: { + values: number[]; + columnWeight: number; +}) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + const intl = useIntl(); + const change = calculateChange( + values[values.length - 2], + values[values.length - 1], + ); + return ( + + change > 0 + ? colors.positive + : change < 0 + ? colors.negative + : theme.palette.text.primary + } + > + {isFinite(change) && change > 0 && '+'} + {!isNaN(change) && + isFinite(change) && + `${intl.formatNumber(change, { + notation: isMobile ? 'compact' : 'standard', + maximumFractionDigits: isMobile ? 1 : 0, + })}%`} + + ); +}; diff --git a/libs/analytics/src/colors.ts b/libs/analytics/src/colors.ts new file mode 100644 index 000000000..39e02390f --- /dev/null +++ b/libs/analytics/src/colors.ts @@ -0,0 +1,2 @@ +export const positive = '#4EBE96'; +export const negative = '#D44E66'; From 4fe8bd6a3dc32bd82eff8143c562bdc8617eab35 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Mon, 25 Sep 2023 19:10:12 -0700 Subject: [PATCH 06/20] feat: financial statement --- libs/analytics/src/FinancialStatement.tsx | 79 ++++++++++++----------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 326ce2ff4..f1a2a6b47 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -14,9 +14,6 @@ export const FinancialStatement = (props: { columns: string[]; data: Record>>; }) => { - const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down('sm')); - const columnWeight = props.columns.length + 2; return ( - + {Object.entries(props.data).map(([title, data]) => ( +
+ ))} + + ); +}; + +const Header = (props: { columns: string[] }) => { + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + const columnWeight = props.columns.length + 2; + return ( + + theme.palette.primary.contrastText} + sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} + fontSize={{ xs: '.875rem', sm: '1.125rem' }} + px={{ xs: 1, sm: 2, md: 4 }} + py={{ xs: 2, sm: 3, md: 4 }} > - theme.palette.primary.contrastText} - sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} - fontSize={{ xs: '.875rem', sm: '1.125rem' }} - px={{ xs: 1, sm: 2, md: 4 }} - py={{ xs: 2, sm: 3, md: 4 }} - > - - {props.columns.map((column) => ( - - {column} - - ))} + {props.columns.map((column, index) => ( - {isMobile ? 'Diff' : 'Difference'} + {column} - - - {Object.entries(props.data).map(([title, data]) => ( -
- ))} - + ))} + + {isMobile ? 'Diff' : 'Difference'} + + + ); }; From be655a9c5c69e528464f8fd137862438a2cd13f9 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Mon, 25 Sep 2023 20:47:02 -0700 Subject: [PATCH 07/20] feat: financial statement --- .../src/FinancialStatement.stories.tsx | 12 +- libs/analytics/src/FinancialStatement.tsx | 121 +++++++++++++----- 2 files changed, 97 insertions(+), 36 deletions(-) diff --git a/libs/analytics/src/FinancialStatement.stories.tsx b/libs/analytics/src/FinancialStatement.stories.tsx index 82c0d479e..3a2c0c721 100644 --- a/libs/analytics/src/FinancialStatement.stories.tsx +++ b/libs/analytics/src/FinancialStatement.stories.tsx @@ -24,10 +24,14 @@ const meta: Meta = { component: FinancialStatement, title: 'Analytics/FinancialStatement', args: { - dataLastUpdated: 123456789, + ethPrice: 1659.47, + lastUpdated: { + blockNumber: 18036316, + timestamp: Date.parse('2023-09-03T21:42:03Z'), + }, columns: ['31 August 2023', '1 week ago'], data: { - Assets: { + assets: { Vault: { ETH: [125000, 0], WETH: [125000, 1], @@ -50,9 +54,9 @@ const meta: Meta = { WETH: randomValues(20000, 50000), }, }, - Liabilities: { + liabilities: { 'Token supply': { - OETH: randomValues(10000000, 1000000000), + OETH: randomValues(2000000, 40000000), }, }, }, diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index f1a2a6b47..4f24ab76a 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -1,4 +1,12 @@ -import { Box, Paper, Stack, useMediaQuery, useTheme } from '@mui/material'; +import { + Box, + Paper, + Stack, + Typography, + useMediaQuery, + useTheme, +} from '@mui/material'; +import dayjs from 'dayjs'; import { useIntl } from 'react-intl'; import * as colors from './colors'; @@ -6,14 +14,36 @@ import * as colors from './colors'; const calculateChange = (from: number, to: number) => { if (from === 0 && to === 0) return 0; const change = -(1 - to / from); - return Math[change > 0 ? 'floor' : 'ceil'](change * 10000) / 100; + const mod = to < 0 ? -1 : 1; + return (Math[change > 0 ? 'floor' : 'ceil'](change * 10000) / 100) * mod; +}; + +const getTotals = (data: Record>) => { + return Object.values(data).reduce((totals, section) => { + for (const asset of Object.values(section)) { + for (let i = 0; i < asset.length; i++) { + totals[i] = (totals[i] ?? 0) + asset[i]; + } + } + return totals; + }, [] as number[]); }; export const FinancialStatement = (props: { - dataLastUpdated: number; + ethPrice: number; + lastUpdated: { + blockNumber: number; + timestamp: number; + }; columns: string[]; - data: Record>>; + data: Record< + 'assets' | 'liabilities', + Record> + >; }) => { + const assetTotals = getTotals(props.data['assets']); + const liabilityTotals = getTotals(props.data['liabilities']); + return (
- {Object.entries(props.data).map(([title, data]) => ( -
- ))} +
+
+ + + val - liabilityTotals[index])} + /> + + + + {`Last updated ${dayjs(props.lastUpdated.timestamp).format( + 'll', + )} at `} + {`${dayjs(props.lastUpdated.timestamp).format('LT')}, block #${ + props.lastUpdated.blockNumber + }`} + + + {`Using ETH price of $${props.ethPrice} from Chainlink`} + + ); }; @@ -50,10 +107,11 @@ const Header = (props: { columns: string[] }) => { px={{ xs: 1, sm: 2, md: 4 }} py={{ xs: 2, sm: 3, md: 4 }} > + {props.columns.map((column, index) => ( { const Table = (props: { title: string; data: Record>; + totals: number[]; }) => { - const totals = Object.values(props.data).reduce((totals, section) => { - for (const asset of Object.values(section)) { - for (let i = 0; i < asset.length; i++) { - totals[i] = (totals[i] ?? 0) + asset[i]; - } - } - return totals; - }, [] as number[]); - const columnWeight = totals.length + 2; - return ( {/* Total */} - theme.palette.primary.contrastText} - sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} - > - - TOTAL {props.title.toUpperCase()} - - {totals.map((value, index) => ( - - ))} - - + ); }; +const Total = (props: { title: string; totals: number[] }) => { + const columnWeight = props.totals.length + 2; + return ( + theme.palette.primary.contrastText} + sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} + > + + {props.title.toUpperCase()} + + {props.totals.map((value, index) => ( + + ))} + + + ); +}; + const Section = (props: { title: string; data: Record }) => { return ( change > 0 From 280ea1ffe22ce322359cbe171391f1d778e75453 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Tue, 26 Sep 2023 18:02:32 -0700 Subject: [PATCH 08/20] feat: financial statement --- .env | 2 +- .graphqlconfig | 4 - graphql.config.yml | 1 + .../src/FinancialStatement.generated.ts | 163 ++ libs/analytics/src/FinancialStatement.graphql | 62 + .../src/FinancialStatement.stories.tsx | 15 +- libs/analytics/src/FinancialStatement.tsx | 91 +- libs/analytics/src/colors.ts | 2 +- libs/analytics/src/index.ts | 1 + libs/analytics/tsconfig.lib.json | 12 +- libs/oeth/history/src/queries.generated.ts | 34 +- libs/oeth/history/src/queries.graphql | 2 +- libs/oeth/shared/src/clients/graphql.ts | 1 - libs/oeth/shared/src/generated/graphql.ts | 1743 ++++++++++++++--- libs/shared/theme/src/theme.d.ts | 3 + libs/shared/theme/src/theme.tsx | 4 +- 16 files changed, 1853 insertions(+), 287 deletions(-) delete mode 100644 .graphqlconfig create mode 100644 graphql.config.yml create mode 100644 libs/analytics/src/FinancialStatement.generated.ts create mode 100644 libs/analytics/src/FinancialStatement.graphql diff --git a/.env b/.env index edd2c958b..40c5aa9db 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VITE_SUBSQUID_URL="https://squid.subsquid.io/origin-squid/v/v5/graphql" +VITE_SUBSQUID_URL="https://squid.subsquid.io/origin-squid/v/v6/graphql" diff --git a/.graphqlconfig b/.graphqlconfig deleted file mode 100644 index 37ef6aa86..000000000 --- a/.graphqlconfig +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Subsquid GraphQL Schema", - "schemaPath": "https://squid.subsquid.io/origin-squid/v/v5/graphql" -} diff --git a/graphql.config.yml b/graphql.config.yml new file mode 100644 index 000000000..415bc2860 --- /dev/null +++ b/graphql.config.yml @@ -0,0 +1 @@ +schema: https://squid.subsquid.io/origin-squid/v/v6/graphql diff --git a/libs/analytics/src/FinancialStatement.generated.ts b/libs/analytics/src/FinancialStatement.generated.ts new file mode 100644 index 000000000..d795f0c5d --- /dev/null +++ b/libs/analytics/src/FinancialStatement.generated.ts @@ -0,0 +1,163 @@ +import { graphqlClient } from '@origin/oeth/shared'; +import { useQuery } from '@tanstack/react-query'; + +import type * as Types from '@origin/oeth/shared'; +import type { UseQueryOptions } from '@tanstack/react-query'; +export type FinancialStatementReportQueryVariables = Types.Exact<{ + compareDate?: Types.InputMaybe; +}>; + +export type FinancialStatementReportQuery = { + __typename?: 'Query'; + financialStatements: Array<{ + __typename?: 'FinancialStatement'; + blockNumber: number; + timestamp: any; + oeth: { __typename?: 'OETH'; totalSupply: any }; + curveLP: { + __typename?: 'CurveLP'; + eth: any; + ethOwned: any; + oeth: any; + oethOwned: any; + totalSupply: any; + totalSupplyOwned: any; + }; + dripper: { __typename?: 'Dripper'; weth: any }; + fraxStaking: { __typename?: 'FraxStaking'; frxETH: any }; + morphoAave: { __typename?: 'MorphoAave'; weth: any }; + vault: { + __typename?: 'Vault'; + weth: any; + rETH: any; + stETH: any; + frxETH: any; + }; + }>; + financialStatements1W: Array<{ + __typename?: 'FinancialStatement'; + blockNumber: number; + timestamp: any; + oeth: { __typename?: 'OETH'; totalSupply: any }; + curveLP: { + __typename?: 'CurveLP'; + eth: any; + ethOwned: any; + oeth: any; + oethOwned: any; + totalSupply: any; + totalSupplyOwned: any; + }; + dripper: { __typename?: 'Dripper'; weth: any }; + fraxStaking: { __typename?: 'FraxStaking'; frxETH: any }; + morphoAave: { __typename?: 'MorphoAave'; weth: any }; + vault: { + __typename?: 'Vault'; + weth: any; + rETH: any; + stETH: any; + frxETH: any; + }; + }>; +}; + +export const FinancialStatementReportDocument = ` + query FinancialStatementReport($compareDate: DateTime) { + financialStatements(orderBy: id_DESC, limit: 1) { + blockNumber + timestamp + oeth { + totalSupply + } + curveLP { + eth + ethOwned + oeth + oethOwned + totalSupply + totalSupplyOwned + } + dripper { + weth + } + fraxStaking { + frxETH + } + morphoAave { + weth + } + vault { + weth + rETH + stETH + frxETH + } + } + financialStatements1W: financialStatements( + orderBy: id_DESC + limit: 1 + where: {timestamp_lt: $compareDate} + ) { + blockNumber + timestamp + oeth { + totalSupply + } + curveLP { + eth + ethOwned + oeth + oethOwned + totalSupply + totalSupplyOwned + } + dripper { + weth + } + fraxStaking { + frxETH + } + morphoAave { + weth + } + vault { + weth + rETH + stETH + frxETH + } + } +} + `; +export const useFinancialStatementReportQuery = < + TData = FinancialStatementReportQuery, + TError = unknown, +>( + variables?: FinancialStatementReportQueryVariables, + options?: UseQueryOptions, +) => + useQuery( + variables === undefined + ? ['FinancialStatementReport'] + : ['FinancialStatementReport', variables], + graphqlClient< + FinancialStatementReportQuery, + FinancialStatementReportQueryVariables + >(FinancialStatementReportDocument, variables), + options, + ); + +useFinancialStatementReportQuery.getKey = ( + variables?: FinancialStatementReportQueryVariables, +) => + variables === undefined + ? ['FinancialStatementReport'] + : ['FinancialStatementReport', variables]; +useFinancialStatementReportQuery.fetcher = ( + variables?: FinancialStatementReportQueryVariables, + options?: RequestInit['headers'], +) => + graphqlClient< + FinancialStatementReportQuery, + FinancialStatementReportQueryVariables + >(FinancialStatementReportDocument, variables, options); diff --git a/libs/analytics/src/FinancialStatement.graphql b/libs/analytics/src/FinancialStatement.graphql new file mode 100644 index 000000000..d9d9763b1 --- /dev/null +++ b/libs/analytics/src/FinancialStatement.graphql @@ -0,0 +1,62 @@ +query FinancialStatementReport($compareDate: DateTime) { + financialStatements(orderBy: id_DESC, limit: 1) { + blockNumber + timestamp + oeth { + totalSupply + } + curveLP { + eth + ethOwned + oeth + oethOwned + totalSupply + totalSupplyOwned + } + dripper { + weth + } + fraxStaking { + frxETH + } + morphoAave { + weth + } + vault { + weth + rETH + stETH + frxETH + } + } + financialStatements1W: financialStatements(orderBy: id_DESC, limit: 1, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + oeth { + totalSupply + } + curveLP { + eth + ethOwned + oeth + oethOwned + totalSupply + totalSupplyOwned + } + dripper { + weth + } + fraxStaking { + frxETH + } + morphoAave { + weth + } + vault { + weth + rETH + stETH + frxETH + } + } +} diff --git a/libs/analytics/src/FinancialStatement.stories.tsx b/libs/analytics/src/FinancialStatement.stories.tsx index 3a2c0c721..77ab1a5c4 100644 --- a/libs/analytics/src/FinancialStatement.stories.tsx +++ b/libs/analytics/src/FinancialStatement.stories.tsx @@ -1,6 +1,11 @@ import { faker } from '@faker-js/faker'; +import { queryClient } from '@origin/oeth/shared'; +import { QueryClientProvider } from '@tanstack/react-query'; -import { FinancialStatement } from './FinancialStatement'; +import { + FinancialStatement, + LiveFinancialStatement, +} from './FinancialStatement'; import type { Meta, StoryObj } from '@storybook/react'; @@ -67,3 +72,11 @@ const meta: Meta = { export default meta; export const Default: StoryObj = {}; + +export const Live = () => { + return ( + + + + ); +}; diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 4f24ab76a..cd25d5488 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -1,3 +1,5 @@ +import { useState } from 'react'; + import { Box, Paper, @@ -7,9 +9,14 @@ import { useTheme, } from '@mui/material'; import dayjs from 'dayjs'; +import LocalizedFormat from 'dayjs/plugin/localizedFormat'; import { useIntl } from 'react-intl'; +import { formatEther } from 'viem'; import * as colors from './colors'; +import { useFinancialStatementReportQuery } from './FinancialStatement.generated'; + +dayjs.extend(LocalizedFormat); const calculateChange = (from: number, to: number) => { if (from === 0 && to === 0) return 0; @@ -29,6 +36,64 @@ const getTotals = (data: Record>) => { }, [] as number[]); }; +export const LiveFinancialStatement = () => { + const [sevenDaysAgo] = useState(dayjs().subtract(7, 'days').toISOString()); + const { isLoading, data } = useFinancialStatementReportQuery({ + compareDate: sevenDaysAgo, + }); + + if (isLoading || !data) return null; + + const fs = data.financialStatements[0]; + const fs1W = data.financialStatements1W[0]; + const c = (n: string) => Number(formatEther(BigInt(n))); + + if (!fs) return null; + if (!fs1W) return null; + + return ( + + ); +}; + export const FinancialStatement = (props: { ethPrice: number; lastUpdated: { @@ -102,7 +167,9 @@ const Header = (props: { columns: string[] }) => { alignItems={'center'} justifyContent={'space-between'} color={(theme) => theme.palette.primary.contrastText} - sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} + sx={{ + backgroundColor: (theme) => theme.palette.background.paperHeader, + }} fontSize={{ xs: '.875rem', sm: '1.125rem' }} px={{ xs: 1, sm: 2, md: 4 }} py={{ xs: 2, sm: 3, md: 4 }} @@ -145,6 +212,22 @@ const Table = (props: { }} > + {/* Header */} + theme.palette.primary.contrastText} + fontSize={{ xs: '.875rem', sm: '1rem' }} + sx={{ + borderBottomStyle: 'solid', + borderBottomWidth: 1, + borderBottomColor: (theme) => theme.palette.grey['700'], + }} + > + {props.title} + + {/* Body */} {Object.entries(props.data).map(([title, data]) => ( @@ -166,7 +249,7 @@ const Total = (props: { title: string; totals: number[] }) => { direction={'row'} p={{ xs: 1, sm: 2, md: 4 }} color={(theme) => theme.palette.primary.contrastText} - sx={{ backgroundColor: (theme) => theme.palette.grey[800] }} + sx={{ backgroundColor: (theme) => theme.palette.background.paperFooter }} > {props.title.toUpperCase()} @@ -246,7 +329,7 @@ export const DataColumn = ({ color={(theme) => theme.palette.text.primary} pr={{ xs: 0.1, sm: 0.15, md: 0.2 }} > - {'$'} + {'Ξ'} {intl.formatNumber(value, { notation: isMobile ? 'compact' : 'standard', @@ -288,7 +371,7 @@ export const ChangeColumn = ({ isFinite(change) && `${intl.formatNumber(change, { notation: isMobile ? 'compact' : 'standard', - maximumFractionDigits: isMobile ? 1 : 0, + maximumFractionDigits: isMobile ? 1 : 2, })}%`} ); diff --git a/libs/analytics/src/colors.ts b/libs/analytics/src/colors.ts index 39e02390f..7724db78d 100644 --- a/libs/analytics/src/colors.ts +++ b/libs/analytics/src/colors.ts @@ -1,2 +1,2 @@ -export const positive = '#4EBE96'; +export const positive = '#6af18f'; export const negative = '#D44E66'; diff --git a/libs/analytics/src/index.ts b/libs/analytics/src/index.ts index dd238161b..af6469dc7 100644 --- a/libs/analytics/src/index.ts +++ b/libs/analytics/src/index.ts @@ -1 +1,2 @@ export * from './TimeLineChart'; +export * from './FinancialStatement'; diff --git a/libs/analytics/tsconfig.lib.json b/libs/analytics/tsconfig.lib.json index cfc484329..0964e4725 100644 --- a/libs/analytics/tsconfig.lib.json +++ b/libs/analytics/tsconfig.lib.json @@ -4,9 +4,10 @@ "outDir": "../../dist/out-tsc", "types": [ "node", - "@nx/react/typings/cssmodule.d.ts", - "@nx/react/typings/image.d.ts" + "@nx/react/typings/image.d.ts", + "../shared/theme/src/theme.d.ts", + "../../apps/oeth/src/env.d.ts" ] }, "exclude": [ @@ -20,5 +21,10 @@ "src/**/*.spec.jsx", "src/**/*.test.jsx" ], - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.ts", + "src/**/*.tsx" + ] } diff --git a/libs/oeth/history/src/queries.generated.ts b/libs/oeth/history/src/queries.generated.ts index 501572792..6173dcbdb 100644 --- a/libs/oeth/history/src/queries.generated.ts +++ b/libs/oeth/history/src/queries.generated.ts @@ -12,18 +12,19 @@ export type HistoryTableQuery = { __typename?: 'Query'; addressById?: { __typename?: 'Address'; - balance: number; - earned: number; + balance: any; + earned: any; isContract: boolean; - rebasingOption: string; + rebasingOption: Types.RebasingOption; + credits: any; lastUpdated: any; history: Array<{ __typename?: 'History'; - type: string; - value: number; + type: Types.HistoryType; + value: any; txHash: string; timestamp: any; - balance: number; + balance: any; }>; } | null; }; @@ -31,28 +32,25 @@ export type HistoryTableQuery = { export type HistoryTableWithFiltersQueryVariables = Types.Exact<{ address: Types.Scalars['String']['input']; offset: Types.Scalars['Int']['input']; - filters?: Types.InputMaybe< - Array | Types.Scalars['String']['input'] - >; + filters?: Types.InputMaybe | Types.HistoryType>; }>; export type HistoryTableWithFiltersQuery = { __typename?: 'Query'; addressById?: { __typename?: 'Address'; - balance: number; - earned: number; + balance: any; + earned: any; isContract: boolean; - rebasingOption: string; - credits: any; + rebasingOption: Types.RebasingOption; lastUpdated: any; history: Array<{ __typename?: 'History'; - type: string; - value: number; + type: Types.HistoryType; + value: any; txHash: string; timestamp: any; - balance: number; + balance: any; }>; } | null; }; @@ -71,6 +69,7 @@ export const HistoryTableDocument = ` earned isContract rebasingOption + credits lastUpdated history(limit: 20, orderBy: timestamp_DESC, offset: $offset) { type @@ -112,13 +111,12 @@ useHistoryTableQuery.fetcher = ( options, ); export const HistoryTableWithFiltersDocument = ` - query HistoryTableWithFilters($address: String!, $offset: Int!, $filters: [String!]) { + query HistoryTableWithFilters($address: String!, $offset: Int!, $filters: [HistoryType!]) { addressById(id: $address) { balance earned isContract rebasingOption - credits lastUpdated history( limit: 20 diff --git a/libs/oeth/history/src/queries.graphql b/libs/oeth/history/src/queries.graphql index 856707099..dd2da7be0 100644 --- a/libs/oeth/history/src/queries.graphql +++ b/libs/oeth/history/src/queries.graphql @@ -19,7 +19,7 @@ query HistoryTable($address: String!, $offset: Int!) { query HistoryTableWithFilters( $address: String! $offset: Int! - $filters: [String!] + $filters: [HistoryType!] ) { addressById(id: $address) { balance diff --git a/libs/oeth/shared/src/clients/graphql.ts b/libs/oeth/shared/src/clients/graphql.ts index 69069cc09..e19fac5a7 100644 --- a/libs/oeth/shared/src/clients/graphql.ts +++ b/libs/oeth/shared/src/clients/graphql.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ import axios from 'axios'; export const axiosInstance = axios.create({ diff --git a/libs/oeth/shared/src/generated/graphql.ts b/libs/oeth/shared/src/generated/graphql.ts index 6dfa0d6a2..46ccb9947 100644 --- a/libs/oeth/shared/src/generated/graphql.ts +++ b/libs/oeth/shared/src/generated/graphql.ts @@ -199,14 +199,14 @@ export type APiesConnection = { export type Address = { __typename?: 'Address'; - balance: Scalars['Float']['output']; + balance: Scalars['BigInt']['output']; credits: Scalars['BigInt']['output']; - earned: Scalars['Float']['output']; + earned: Scalars['BigInt']['output']; history: Array; id: Scalars['String']['output']; isContract: Scalars['Boolean']['output']; lastUpdated: Scalars['DateTime']['output']; - rebasingOption: Scalars['String']['output']; + rebasingOption: RebasingOption; }; @@ -257,15 +257,15 @@ export enum AddressOrderByInput { export type AddressWhereInput = { AND?: InputMaybe>; OR?: InputMaybe>; - balance_eq?: InputMaybe; - balance_gt?: InputMaybe; - balance_gte?: InputMaybe; - balance_in?: InputMaybe>; + balance_eq?: InputMaybe; + balance_gt?: InputMaybe; + balance_gte?: InputMaybe; + balance_in?: InputMaybe>; balance_isNull?: InputMaybe; - balance_lt?: InputMaybe; - balance_lte?: InputMaybe; - balance_not_eq?: InputMaybe; - balance_not_in?: InputMaybe>; + balance_lt?: InputMaybe; + balance_lte?: InputMaybe; + balance_not_eq?: InputMaybe; + balance_not_in?: InputMaybe>; credits_eq?: InputMaybe; credits_gt?: InputMaybe; credits_gte?: InputMaybe; @@ -275,15 +275,15 @@ export type AddressWhereInput = { credits_lte?: InputMaybe; credits_not_eq?: InputMaybe; credits_not_in?: InputMaybe>; - earned_eq?: InputMaybe; - earned_gt?: InputMaybe; - earned_gte?: InputMaybe; - earned_in?: InputMaybe>; + earned_eq?: InputMaybe; + earned_gt?: InputMaybe; + earned_gte?: InputMaybe; + earned_in?: InputMaybe>; earned_isNull?: InputMaybe; - earned_lt?: InputMaybe; - earned_lte?: InputMaybe; - earned_not_eq?: InputMaybe; - earned_not_in?: InputMaybe>; + earned_lt?: InputMaybe; + earned_lte?: InputMaybe; + earned_not_eq?: InputMaybe; + earned_not_in?: InputMaybe>; history_every?: InputMaybe; history_none?: InputMaybe; history_some?: InputMaybe; @@ -316,23 +316,11 @@ export type AddressWhereInput = { lastUpdated_lte?: InputMaybe; lastUpdated_not_eq?: InputMaybe; lastUpdated_not_in?: InputMaybe>; - rebasingOption_contains?: InputMaybe; - rebasingOption_containsInsensitive?: InputMaybe; - rebasingOption_endsWith?: InputMaybe; - rebasingOption_eq?: InputMaybe; - rebasingOption_gt?: InputMaybe; - rebasingOption_gte?: InputMaybe; - rebasingOption_in?: InputMaybe>; + rebasingOption_eq?: InputMaybe; + rebasingOption_in?: InputMaybe>; rebasingOption_isNull?: InputMaybe; - rebasingOption_lt?: InputMaybe; - rebasingOption_lte?: InputMaybe; - rebasingOption_not_contains?: InputMaybe; - rebasingOption_not_containsInsensitive?: InputMaybe; - rebasingOption_not_endsWith?: InputMaybe; - rebasingOption_not_eq?: InputMaybe; - rebasingOption_not_in?: InputMaybe>; - rebasingOption_not_startsWith?: InputMaybe; - rebasingOption_startsWith?: InputMaybe; + rebasingOption_not_eq?: InputMaybe; + rebasingOption_not_in?: InputMaybe>; }; export type AddressesConnection = { @@ -342,32 +330,1335 @@ export type AddressesConnection = { totalCount: Scalars['Int']['output']; }; -export type HistoriesConnection = { - __typename?: 'HistoriesConnection'; - edges: Array; +export type CurveLp = { + __typename?: 'CurveLP'; + blockNumber: Scalars['Int']['output']; + eth: Scalars['BigInt']['output']; + ethOwned: Scalars['BigInt']['output']; + id: Scalars['String']['output']; + oeth: Scalars['BigInt']['output']; + oethOwned: Scalars['BigInt']['output']; + timestamp: Scalars['DateTime']['output']; + totalSupply: Scalars['BigInt']['output']; + totalSupplyOwned: Scalars['BigInt']['output']; +}; + +export type CurveLpEdge = { + __typename?: 'CurveLPEdge'; + cursor: Scalars['String']['output']; + node: CurveLp; +}; + +export enum CurveLpOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + EthOwnedAsc = 'ethOwned_ASC', + EthOwnedAscNullsFirst = 'ethOwned_ASC_NULLS_FIRST', + EthOwnedDesc = 'ethOwned_DESC', + EthOwnedDescNullsLast = 'ethOwned_DESC_NULLS_LAST', + EthAsc = 'eth_ASC', + EthAscNullsFirst = 'eth_ASC_NULLS_FIRST', + EthDesc = 'eth_DESC', + EthDescNullsLast = 'eth_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + OethOwnedAsc = 'oethOwned_ASC', + OethOwnedAscNullsFirst = 'oethOwned_ASC_NULLS_FIRST', + OethOwnedDesc = 'oethOwned_DESC', + OethOwnedDescNullsLast = 'oethOwned_DESC_NULLS_LAST', + OethAsc = 'oeth_ASC', + OethAscNullsFirst = 'oeth_ASC_NULLS_FIRST', + OethDesc = 'oeth_DESC', + OethDescNullsLast = 'oeth_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + TotalSupplyOwnedAsc = 'totalSupplyOwned_ASC', + TotalSupplyOwnedAscNullsFirst = 'totalSupplyOwned_ASC_NULLS_FIRST', + TotalSupplyOwnedDesc = 'totalSupplyOwned_DESC', + TotalSupplyOwnedDescNullsLast = 'totalSupplyOwned_DESC_NULLS_LAST', + TotalSupplyAsc = 'totalSupply_ASC', + TotalSupplyAscNullsFirst = 'totalSupply_ASC_NULLS_FIRST', + TotalSupplyDesc = 'totalSupply_DESC', + TotalSupplyDescNullsLast = 'totalSupply_DESC_NULLS_LAST' +} + +export type CurveLpWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + ethOwned_eq?: InputMaybe; + ethOwned_gt?: InputMaybe; + ethOwned_gte?: InputMaybe; + ethOwned_in?: InputMaybe>; + ethOwned_isNull?: InputMaybe; + ethOwned_lt?: InputMaybe; + ethOwned_lte?: InputMaybe; + ethOwned_not_eq?: InputMaybe; + ethOwned_not_in?: InputMaybe>; + eth_eq?: InputMaybe; + eth_gt?: InputMaybe; + eth_gte?: InputMaybe; + eth_in?: InputMaybe>; + eth_isNull?: InputMaybe; + eth_lt?: InputMaybe; + eth_lte?: InputMaybe; + eth_not_eq?: InputMaybe; + eth_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + oethOwned_eq?: InputMaybe; + oethOwned_gt?: InputMaybe; + oethOwned_gte?: InputMaybe; + oethOwned_in?: InputMaybe>; + oethOwned_isNull?: InputMaybe; + oethOwned_lt?: InputMaybe; + oethOwned_lte?: InputMaybe; + oethOwned_not_eq?: InputMaybe; + oethOwned_not_in?: InputMaybe>; + oeth_eq?: InputMaybe; + oeth_gt?: InputMaybe; + oeth_gte?: InputMaybe; + oeth_in?: InputMaybe>; + oeth_isNull?: InputMaybe; + oeth_lt?: InputMaybe; + oeth_lte?: InputMaybe; + oeth_not_eq?: InputMaybe; + oeth_not_in?: InputMaybe>; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + totalSupplyOwned_eq?: InputMaybe; + totalSupplyOwned_gt?: InputMaybe; + totalSupplyOwned_gte?: InputMaybe; + totalSupplyOwned_in?: InputMaybe>; + totalSupplyOwned_isNull?: InputMaybe; + totalSupplyOwned_lt?: InputMaybe; + totalSupplyOwned_lte?: InputMaybe; + totalSupplyOwned_not_eq?: InputMaybe; + totalSupplyOwned_not_in?: InputMaybe>; + totalSupply_eq?: InputMaybe; + totalSupply_gt?: InputMaybe; + totalSupply_gte?: InputMaybe; + totalSupply_in?: InputMaybe>; + totalSupply_isNull?: InputMaybe; + totalSupply_lt?: InputMaybe; + totalSupply_lte?: InputMaybe; + totalSupply_not_eq?: InputMaybe; + totalSupply_not_in?: InputMaybe>; +}; + +export type CurveLPsConnection = { + __typename?: 'CurveLPsConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + +export type Dripper = { + __typename?: 'Dripper'; + blockNumber: Scalars['Int']['output']; + id: Scalars['String']['output']; + timestamp: Scalars['DateTime']['output']; + weth: Scalars['BigInt']['output']; +}; + +export type DripperEdge = { + __typename?: 'DripperEdge'; + cursor: Scalars['String']['output']; + node: Dripper; +}; + +export enum DripperOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + WethAsc = 'weth_ASC', + WethAscNullsFirst = 'weth_ASC_NULLS_FIRST', + WethDesc = 'weth_DESC', + WethDescNullsLast = 'weth_DESC_NULLS_LAST' +} + +export type DripperWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + weth_eq?: InputMaybe; + weth_gt?: InputMaybe; + weth_gte?: InputMaybe; + weth_in?: InputMaybe>; + weth_isNull?: InputMaybe; + weth_lt?: InputMaybe; + weth_lte?: InputMaybe; + weth_not_eq?: InputMaybe; + weth_not_in?: InputMaybe>; +}; + +export type DrippersConnection = { + __typename?: 'DrippersConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + +export type FinancialStatement = { + __typename?: 'FinancialStatement'; + blockNumber: Scalars['Int']['output']; + curveLP: CurveLp; + dripper: Dripper; + fraxStaking: FraxStaking; + id: Scalars['String']['output']; + morphoAave: MorphoAave; + oeth: Oeth; + timestamp: Scalars['DateTime']['output']; + vault: Vault; +}; + +export type FinancialStatementEdge = { + __typename?: 'FinancialStatementEdge'; + cursor: Scalars['String']['output']; + node: FinancialStatement; +}; + +export enum FinancialStatementOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + CurveLpBlockNumberAsc = 'curveLP_blockNumber_ASC', + CurveLpBlockNumberAscNullsFirst = 'curveLP_blockNumber_ASC_NULLS_FIRST', + CurveLpBlockNumberDesc = 'curveLP_blockNumber_DESC', + CurveLpBlockNumberDescNullsLast = 'curveLP_blockNumber_DESC_NULLS_LAST', + CurveLpEthOwnedAsc = 'curveLP_ethOwned_ASC', + CurveLpEthOwnedAscNullsFirst = 'curveLP_ethOwned_ASC_NULLS_FIRST', + CurveLpEthOwnedDesc = 'curveLP_ethOwned_DESC', + CurveLpEthOwnedDescNullsLast = 'curveLP_ethOwned_DESC_NULLS_LAST', + CurveLpEthAsc = 'curveLP_eth_ASC', + CurveLpEthAscNullsFirst = 'curveLP_eth_ASC_NULLS_FIRST', + CurveLpEthDesc = 'curveLP_eth_DESC', + CurveLpEthDescNullsLast = 'curveLP_eth_DESC_NULLS_LAST', + CurveLpIdAsc = 'curveLP_id_ASC', + CurveLpIdAscNullsFirst = 'curveLP_id_ASC_NULLS_FIRST', + CurveLpIdDesc = 'curveLP_id_DESC', + CurveLpIdDescNullsLast = 'curveLP_id_DESC_NULLS_LAST', + CurveLpOethOwnedAsc = 'curveLP_oethOwned_ASC', + CurveLpOethOwnedAscNullsFirst = 'curveLP_oethOwned_ASC_NULLS_FIRST', + CurveLpOethOwnedDesc = 'curveLP_oethOwned_DESC', + CurveLpOethOwnedDescNullsLast = 'curveLP_oethOwned_DESC_NULLS_LAST', + CurveLpOethAsc = 'curveLP_oeth_ASC', + CurveLpOethAscNullsFirst = 'curveLP_oeth_ASC_NULLS_FIRST', + CurveLpOethDesc = 'curveLP_oeth_DESC', + CurveLpOethDescNullsLast = 'curveLP_oeth_DESC_NULLS_LAST', + CurveLpTimestampAsc = 'curveLP_timestamp_ASC', + CurveLpTimestampAscNullsFirst = 'curveLP_timestamp_ASC_NULLS_FIRST', + CurveLpTimestampDesc = 'curveLP_timestamp_DESC', + CurveLpTimestampDescNullsLast = 'curveLP_timestamp_DESC_NULLS_LAST', + CurveLpTotalSupplyOwnedAsc = 'curveLP_totalSupplyOwned_ASC', + CurveLpTotalSupplyOwnedAscNullsFirst = 'curveLP_totalSupplyOwned_ASC_NULLS_FIRST', + CurveLpTotalSupplyOwnedDesc = 'curveLP_totalSupplyOwned_DESC', + CurveLpTotalSupplyOwnedDescNullsLast = 'curveLP_totalSupplyOwned_DESC_NULLS_LAST', + CurveLpTotalSupplyAsc = 'curveLP_totalSupply_ASC', + CurveLpTotalSupplyAscNullsFirst = 'curveLP_totalSupply_ASC_NULLS_FIRST', + CurveLpTotalSupplyDesc = 'curveLP_totalSupply_DESC', + CurveLpTotalSupplyDescNullsLast = 'curveLP_totalSupply_DESC_NULLS_LAST', + DripperBlockNumberAsc = 'dripper_blockNumber_ASC', + DripperBlockNumberAscNullsFirst = 'dripper_blockNumber_ASC_NULLS_FIRST', + DripperBlockNumberDesc = 'dripper_blockNumber_DESC', + DripperBlockNumberDescNullsLast = 'dripper_blockNumber_DESC_NULLS_LAST', + DripperIdAsc = 'dripper_id_ASC', + DripperIdAscNullsFirst = 'dripper_id_ASC_NULLS_FIRST', + DripperIdDesc = 'dripper_id_DESC', + DripperIdDescNullsLast = 'dripper_id_DESC_NULLS_LAST', + DripperTimestampAsc = 'dripper_timestamp_ASC', + DripperTimestampAscNullsFirst = 'dripper_timestamp_ASC_NULLS_FIRST', + DripperTimestampDesc = 'dripper_timestamp_DESC', + DripperTimestampDescNullsLast = 'dripper_timestamp_DESC_NULLS_LAST', + DripperWethAsc = 'dripper_weth_ASC', + DripperWethAscNullsFirst = 'dripper_weth_ASC_NULLS_FIRST', + DripperWethDesc = 'dripper_weth_DESC', + DripperWethDescNullsLast = 'dripper_weth_DESC_NULLS_LAST', + FraxStakingBlockNumberAsc = 'fraxStaking_blockNumber_ASC', + FraxStakingBlockNumberAscNullsFirst = 'fraxStaking_blockNumber_ASC_NULLS_FIRST', + FraxStakingBlockNumberDesc = 'fraxStaking_blockNumber_DESC', + FraxStakingBlockNumberDescNullsLast = 'fraxStaking_blockNumber_DESC_NULLS_LAST', + FraxStakingFrxEthAsc = 'fraxStaking_frxETH_ASC', + FraxStakingFrxEthAscNullsFirst = 'fraxStaking_frxETH_ASC_NULLS_FIRST', + FraxStakingFrxEthDesc = 'fraxStaking_frxETH_DESC', + FraxStakingFrxEthDescNullsLast = 'fraxStaking_frxETH_DESC_NULLS_LAST', + FraxStakingIdAsc = 'fraxStaking_id_ASC', + FraxStakingIdAscNullsFirst = 'fraxStaking_id_ASC_NULLS_FIRST', + FraxStakingIdDesc = 'fraxStaking_id_DESC', + FraxStakingIdDescNullsLast = 'fraxStaking_id_DESC_NULLS_LAST', + FraxStakingTimestampAsc = 'fraxStaking_timestamp_ASC', + FraxStakingTimestampAscNullsFirst = 'fraxStaking_timestamp_ASC_NULLS_FIRST', + FraxStakingTimestampDesc = 'fraxStaking_timestamp_DESC', + FraxStakingTimestampDescNullsLast = 'fraxStaking_timestamp_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + MorphoAaveBlockNumberAsc = 'morphoAave_blockNumber_ASC', + MorphoAaveBlockNumberAscNullsFirst = 'morphoAave_blockNumber_ASC_NULLS_FIRST', + MorphoAaveBlockNumberDesc = 'morphoAave_blockNumber_DESC', + MorphoAaveBlockNumberDescNullsLast = 'morphoAave_blockNumber_DESC_NULLS_LAST', + MorphoAaveIdAsc = 'morphoAave_id_ASC', + MorphoAaveIdAscNullsFirst = 'morphoAave_id_ASC_NULLS_FIRST', + MorphoAaveIdDesc = 'morphoAave_id_DESC', + MorphoAaveIdDescNullsLast = 'morphoAave_id_DESC_NULLS_LAST', + MorphoAaveTimestampAsc = 'morphoAave_timestamp_ASC', + MorphoAaveTimestampAscNullsFirst = 'morphoAave_timestamp_ASC_NULLS_FIRST', + MorphoAaveTimestampDesc = 'morphoAave_timestamp_DESC', + MorphoAaveTimestampDescNullsLast = 'morphoAave_timestamp_DESC_NULLS_LAST', + MorphoAaveWethAsc = 'morphoAave_weth_ASC', + MorphoAaveWethAscNullsFirst = 'morphoAave_weth_ASC_NULLS_FIRST', + MorphoAaveWethDesc = 'morphoAave_weth_DESC', + MorphoAaveWethDescNullsLast = 'morphoAave_weth_DESC_NULLS_LAST', + OethBlockNumberAsc = 'oeth_blockNumber_ASC', + OethBlockNumberAscNullsFirst = 'oeth_blockNumber_ASC_NULLS_FIRST', + OethBlockNumberDesc = 'oeth_blockNumber_DESC', + OethBlockNumberDescNullsLast = 'oeth_blockNumber_DESC_NULLS_LAST', + OethIdAsc = 'oeth_id_ASC', + OethIdAscNullsFirst = 'oeth_id_ASC_NULLS_FIRST', + OethIdDesc = 'oeth_id_DESC', + OethIdDescNullsLast = 'oeth_id_DESC_NULLS_LAST', + OethTimestampAsc = 'oeth_timestamp_ASC', + OethTimestampAscNullsFirst = 'oeth_timestamp_ASC_NULLS_FIRST', + OethTimestampDesc = 'oeth_timestamp_DESC', + OethTimestampDescNullsLast = 'oeth_timestamp_DESC_NULLS_LAST', + OethTotalSupplyAsc = 'oeth_totalSupply_ASC', + OethTotalSupplyAscNullsFirst = 'oeth_totalSupply_ASC_NULLS_FIRST', + OethTotalSupplyDesc = 'oeth_totalSupply_DESC', + OethTotalSupplyDescNullsLast = 'oeth_totalSupply_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + VaultBlockNumberAsc = 'vault_blockNumber_ASC', + VaultBlockNumberAscNullsFirst = 'vault_blockNumber_ASC_NULLS_FIRST', + VaultBlockNumberDesc = 'vault_blockNumber_DESC', + VaultBlockNumberDescNullsLast = 'vault_blockNumber_DESC_NULLS_LAST', + VaultFrxEthAsc = 'vault_frxETH_ASC', + VaultFrxEthAscNullsFirst = 'vault_frxETH_ASC_NULLS_FIRST', + VaultFrxEthDesc = 'vault_frxETH_DESC', + VaultFrxEthDescNullsLast = 'vault_frxETH_DESC_NULLS_LAST', + VaultIdAsc = 'vault_id_ASC', + VaultIdAscNullsFirst = 'vault_id_ASC_NULLS_FIRST', + VaultIdDesc = 'vault_id_DESC', + VaultIdDescNullsLast = 'vault_id_DESC_NULLS_LAST', + VaultREthAsc = 'vault_rETH_ASC', + VaultREthAscNullsFirst = 'vault_rETH_ASC_NULLS_FIRST', + VaultREthDesc = 'vault_rETH_DESC', + VaultREthDescNullsLast = 'vault_rETH_DESC_NULLS_LAST', + VaultStEthAsc = 'vault_stETH_ASC', + VaultStEthAscNullsFirst = 'vault_stETH_ASC_NULLS_FIRST', + VaultStEthDesc = 'vault_stETH_DESC', + VaultStEthDescNullsLast = 'vault_stETH_DESC_NULLS_LAST', + VaultTimestampAsc = 'vault_timestamp_ASC', + VaultTimestampAscNullsFirst = 'vault_timestamp_ASC_NULLS_FIRST', + VaultTimestampDesc = 'vault_timestamp_DESC', + VaultTimestampDescNullsLast = 'vault_timestamp_DESC_NULLS_LAST', + VaultWethAsc = 'vault_weth_ASC', + VaultWethAscNullsFirst = 'vault_weth_ASC_NULLS_FIRST', + VaultWethDesc = 'vault_weth_DESC', + VaultWethDescNullsLast = 'vault_weth_DESC_NULLS_LAST' +} + +export type FinancialStatementWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + curveLP?: InputMaybe; + curveLP_isNull?: InputMaybe; + dripper?: InputMaybe; + dripper_isNull?: InputMaybe; + fraxStaking?: InputMaybe; + fraxStaking_isNull?: InputMaybe; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + morphoAave?: InputMaybe; + morphoAave_isNull?: InputMaybe; + oeth?: InputMaybe; + oeth_isNull?: InputMaybe; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + vault?: InputMaybe; + vault_isNull?: InputMaybe; +}; + +export type FinancialStatementsConnection = { + __typename?: 'FinancialStatementsConnection'; + edges: Array; pageInfo: PageInfo; totalCount: Scalars['Int']['output']; }; -export type History = { - __typename?: 'History'; +export type FraxStaking = { + __typename?: 'FraxStaking'; + blockNumber: Scalars['Int']['output']; + frxETH: Scalars['BigInt']['output']; + id: Scalars['String']['output']; + timestamp: Scalars['DateTime']['output']; +}; + +export type FraxStakingEdge = { + __typename?: 'FraxStakingEdge'; + cursor: Scalars['String']['output']; + node: FraxStaking; +}; + +export enum FraxStakingOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + FrxEthAsc = 'frxETH_ASC', + FrxEthAscNullsFirst = 'frxETH_ASC_NULLS_FIRST', + FrxEthDesc = 'frxETH_DESC', + FrxEthDescNullsLast = 'frxETH_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST' +} + +export type FraxStakingWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + frxETH_eq?: InputMaybe; + frxETH_gt?: InputMaybe; + frxETH_gte?: InputMaybe; + frxETH_in?: InputMaybe>; + frxETH_isNull?: InputMaybe; + frxETH_lt?: InputMaybe; + frxETH_lte?: InputMaybe; + frxETH_not_eq?: InputMaybe; + frxETH_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; +}; + +export type FraxStakingsConnection = { + __typename?: 'FraxStakingsConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + +export type HistoriesConnection = { + __typename?: 'HistoriesConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + +export type History = { + __typename?: 'History'; + address: Address; + balance: Scalars['BigInt']['output']; + blockNumber: Scalars['Int']['output']; + id: Scalars['String']['output']; + timestamp: Scalars['DateTime']['output']; + txHash: Scalars['String']['output']; + type: HistoryType; + value: Scalars['BigInt']['output']; +}; + +export type HistoryEdge = { + __typename?: 'HistoryEdge'; + cursor: Scalars['String']['output']; + node: History; +}; + +export enum HistoryOrderByInput { + AddressBalanceAsc = 'address_balance_ASC', + AddressBalanceAscNullsFirst = 'address_balance_ASC_NULLS_FIRST', + AddressBalanceDesc = 'address_balance_DESC', + AddressBalanceDescNullsLast = 'address_balance_DESC_NULLS_LAST', + AddressCreditsAsc = 'address_credits_ASC', + AddressCreditsAscNullsFirst = 'address_credits_ASC_NULLS_FIRST', + AddressCreditsDesc = 'address_credits_DESC', + AddressCreditsDescNullsLast = 'address_credits_DESC_NULLS_LAST', + AddressEarnedAsc = 'address_earned_ASC', + AddressEarnedAscNullsFirst = 'address_earned_ASC_NULLS_FIRST', + AddressEarnedDesc = 'address_earned_DESC', + AddressEarnedDescNullsLast = 'address_earned_DESC_NULLS_LAST', + AddressIdAsc = 'address_id_ASC', + AddressIdAscNullsFirst = 'address_id_ASC_NULLS_FIRST', + AddressIdDesc = 'address_id_DESC', + AddressIdDescNullsLast = 'address_id_DESC_NULLS_LAST', + AddressIsContractAsc = 'address_isContract_ASC', + AddressIsContractAscNullsFirst = 'address_isContract_ASC_NULLS_FIRST', + AddressIsContractDesc = 'address_isContract_DESC', + AddressIsContractDescNullsLast = 'address_isContract_DESC_NULLS_LAST', + AddressLastUpdatedAsc = 'address_lastUpdated_ASC', + AddressLastUpdatedAscNullsFirst = 'address_lastUpdated_ASC_NULLS_FIRST', + AddressLastUpdatedDesc = 'address_lastUpdated_DESC', + AddressLastUpdatedDescNullsLast = 'address_lastUpdated_DESC_NULLS_LAST', + AddressRebasingOptionAsc = 'address_rebasingOption_ASC', + AddressRebasingOptionAscNullsFirst = 'address_rebasingOption_ASC_NULLS_FIRST', + AddressRebasingOptionDesc = 'address_rebasingOption_DESC', + AddressRebasingOptionDescNullsLast = 'address_rebasingOption_DESC_NULLS_LAST', + BalanceAsc = 'balance_ASC', + BalanceAscNullsFirst = 'balance_ASC_NULLS_FIRST', + BalanceDesc = 'balance_DESC', + BalanceDescNullsLast = 'balance_DESC_NULLS_LAST', + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + TxHashAsc = 'txHash_ASC', + TxHashAscNullsFirst = 'txHash_ASC_NULLS_FIRST', + TxHashDesc = 'txHash_DESC', + TxHashDescNullsLast = 'txHash_DESC_NULLS_LAST', + TypeAsc = 'type_ASC', + TypeAscNullsFirst = 'type_ASC_NULLS_FIRST', + TypeDesc = 'type_DESC', + TypeDescNullsLast = 'type_DESC_NULLS_LAST', + ValueAsc = 'value_ASC', + ValueAscNullsFirst = 'value_ASC_NULLS_FIRST', + ValueDesc = 'value_DESC', + ValueDescNullsLast = 'value_DESC_NULLS_LAST' +} + +export enum HistoryType { + Received = 'Received', + Sent = 'Sent', + Swap = 'Swap', + Yield = 'Yield' +} + +export type HistoryWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + address?: InputMaybe; + address_isNull?: InputMaybe; + balance_eq?: InputMaybe; + balance_gt?: InputMaybe; + balance_gte?: InputMaybe; + balance_in?: InputMaybe>; + balance_isNull?: InputMaybe; + balance_lt?: InputMaybe; + balance_lte?: InputMaybe; + balance_not_eq?: InputMaybe; + balance_not_in?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + txHash_contains?: InputMaybe; + txHash_containsInsensitive?: InputMaybe; + txHash_endsWith?: InputMaybe; + txHash_eq?: InputMaybe; + txHash_gt?: InputMaybe; + txHash_gte?: InputMaybe; + txHash_in?: InputMaybe>; + txHash_isNull?: InputMaybe; + txHash_lt?: InputMaybe; + txHash_lte?: InputMaybe; + txHash_not_contains?: InputMaybe; + txHash_not_containsInsensitive?: InputMaybe; + txHash_not_endsWith?: InputMaybe; + txHash_not_eq?: InputMaybe; + txHash_not_in?: InputMaybe>; + txHash_not_startsWith?: InputMaybe; + txHash_startsWith?: InputMaybe; + type_eq?: InputMaybe; + type_in?: InputMaybe>; + type_isNull?: InputMaybe; + type_not_eq?: InputMaybe; + type_not_in?: InputMaybe>; + value_eq?: InputMaybe; + value_gt?: InputMaybe; + value_gte?: InputMaybe; + value_in?: InputMaybe>; + value_isNull?: InputMaybe; + value_lt?: InputMaybe; + value_lte?: InputMaybe; + value_not_eq?: InputMaybe; + value_not_in?: InputMaybe>; +}; + +export type MorphoAave = { + __typename?: 'MorphoAave'; + blockNumber: Scalars['Int']['output']; + id: Scalars['String']['output']; + timestamp: Scalars['DateTime']['output']; + weth: Scalars['BigInt']['output']; +}; + +export type MorphoAaveEdge = { + __typename?: 'MorphoAaveEdge'; + cursor: Scalars['String']['output']; + node: MorphoAave; +}; + +export enum MorphoAaveOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + WethAsc = 'weth_ASC', + WethAscNullsFirst = 'weth_ASC_NULLS_FIRST', + WethDesc = 'weth_DESC', + WethDescNullsLast = 'weth_DESC_NULLS_LAST' +} + +export type MorphoAaveWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + weth_eq?: InputMaybe; + weth_gt?: InputMaybe; + weth_gte?: InputMaybe; + weth_in?: InputMaybe>; + weth_isNull?: InputMaybe; + weth_lt?: InputMaybe; + weth_lte?: InputMaybe; + weth_not_eq?: InputMaybe; + weth_not_in?: InputMaybe>; +}; + +export type MorphoAavesConnection = { + __typename?: 'MorphoAavesConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + +export type Oeth = { + __typename?: 'OETH'; + blockNumber: Scalars['Int']['output']; + id: Scalars['String']['output']; + timestamp: Scalars['DateTime']['output']; + totalSupply: Scalars['BigInt']['output']; +}; + +export type OethEdge = { + __typename?: 'OETHEdge'; + cursor: Scalars['String']['output']; + node: Oeth; +}; + +export enum OethOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + TotalSupplyAsc = 'totalSupply_ASC', + TotalSupplyAscNullsFirst = 'totalSupply_ASC_NULLS_FIRST', + TotalSupplyDesc = 'totalSupply_DESC', + TotalSupplyDescNullsLast = 'totalSupply_DESC_NULLS_LAST' +} + +export type OethWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + totalSupply_eq?: InputMaybe; + totalSupply_gt?: InputMaybe; + totalSupply_gte?: InputMaybe; + totalSupply_in?: InputMaybe>; + totalSupply_isNull?: InputMaybe; + totalSupply_lt?: InputMaybe; + totalSupply_lte?: InputMaybe; + totalSupply_not_eq?: InputMaybe; + totalSupply_not_in?: InputMaybe>; +}; + +export type OetHsConnection = { + __typename?: 'OETHsConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + +export type PageInfo = { + __typename?: 'PageInfo'; + endCursor: Scalars['String']['output']; + hasNextPage: Scalars['Boolean']['output']; + hasPreviousPage: Scalars['Boolean']['output']; + startCursor: Scalars['String']['output']; +}; + +export type Query = { + __typename?: 'Query'; + addressById?: Maybe
; + /** @deprecated Use addressById */ + addressByUniqueInput?: Maybe
; + addresses: Array
; + addressesConnection: AddressesConnection; + apies: Array; + apiesConnection: APiesConnection; + apyById?: Maybe; + /** @deprecated Use apyById */ + apyByUniqueInput?: Maybe; + curveLpById?: Maybe; + /** @deprecated Use curveLpById */ + curveLpByUniqueInput?: Maybe; + curveLps: Array; + curveLpsConnection: CurveLPsConnection; + dripperById?: Maybe; + /** @deprecated Use dripperById */ + dripperByUniqueInput?: Maybe; + drippers: Array; + drippersConnection: DrippersConnection; + financialStatementById?: Maybe; + /** @deprecated Use financialStatementById */ + financialStatementByUniqueInput?: Maybe; + financialStatements: Array; + financialStatementsConnection: FinancialStatementsConnection; + fraxStakingById?: Maybe; + /** @deprecated Use fraxStakingById */ + fraxStakingByUniqueInput?: Maybe; + fraxStakings: Array; + fraxStakingsConnection: FraxStakingsConnection; + histories: Array; + historiesConnection: HistoriesConnection; + historyById?: Maybe; + /** @deprecated Use historyById */ + historyByUniqueInput?: Maybe; + morphoAaveById?: Maybe; + /** @deprecated Use morphoAaveById */ + morphoAaveByUniqueInput?: Maybe; + morphoAaves: Array; + morphoAavesConnection: MorphoAavesConnection; + oethById?: Maybe; + /** @deprecated Use oethById */ + oethByUniqueInput?: Maybe; + oeths: Array; + oethsConnection: OetHsConnection; + rebaseById?: Maybe; + /** @deprecated Use rebaseById */ + rebaseByUniqueInput?: Maybe; + rebaseOptionById?: Maybe; + /** @deprecated Use rebaseOptionById */ + rebaseOptionByUniqueInput?: Maybe; + rebaseOptions: Array; + rebaseOptionsConnection: RebaseOptionsConnection; + rebases: Array; + rebasesConnection: RebasesConnection; + squidStatus?: Maybe; + vaultById?: Maybe; + /** @deprecated Use vaultById */ + vaultByUniqueInput?: Maybe; + vaults: Array; + vaultsConnection: VaultsConnection; +}; + + +export type QueryAddressByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryAddressByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryAddressesArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryAddressesConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryApiesArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryApiesConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryApyByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryApyByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryCurveLpByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryCurveLpByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryCurveLpsArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryCurveLpsConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryDripperByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryDripperByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryDrippersArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryDrippersConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryFinancialStatementByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryFinancialStatementByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryFinancialStatementsArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryFinancialStatementsConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryFraxStakingByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryFraxStakingByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryFraxStakingsArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryFraxStakingsConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryHistoriesArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryHistoriesConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryHistoryByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryHistoryByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryMorphoAaveByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryMorphoAaveByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryMorphoAavesArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryMorphoAavesConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryOethByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryOethByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryOethsArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryOethsConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryRebaseByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryRebaseByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryRebaseOptionByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryRebaseOptionByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryRebaseOptionsArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryRebaseOptionsConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryRebasesArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryRebasesConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + + +export type QueryVaultByIdArgs = { + id: Scalars['String']['input']; +}; + + +export type QueryVaultByUniqueInputArgs = { + where: WhereIdInput; +}; + + +export type QueryVaultsArgs = { + limit?: InputMaybe; + offset?: InputMaybe; + orderBy?: InputMaybe>; + where?: InputMaybe; +}; + + +export type QueryVaultsConnectionArgs = { + after?: InputMaybe; + first?: InputMaybe; + orderBy: Array; + where?: InputMaybe; +}; + +export type Rebase = { + __typename?: 'Rebase'; + apy: Apy; + blockNumber: Scalars['Int']['output']; + id: Scalars['String']['output']; + rebasingCredits: Scalars['BigInt']['output']; + rebasingCreditsPerToken: Scalars['BigInt']['output']; + timestamp: Scalars['DateTime']['output']; + totalSupply: Scalars['BigInt']['output']; + txHash: Scalars['String']['output']; +}; + +export type RebaseEdge = { + __typename?: 'RebaseEdge'; + cursor: Scalars['String']['output']; + node: Rebase; +}; + +export type RebaseOption = { + __typename?: 'RebaseOption'; address: Address; - balance: Scalars['Float']['output']; blockNumber: Scalars['Int']['output']; id: Scalars['String']['output']; + status: RebasingOption; timestamp: Scalars['DateTime']['output']; txHash: Scalars['String']['output']; - type: Scalars['String']['output']; - value: Scalars['Float']['output']; }; -export type HistoryEdge = { - __typename?: 'HistoryEdge'; +export type RebaseOptionEdge = { + __typename?: 'RebaseOptionEdge'; cursor: Scalars['String']['output']; - node: History; + node: RebaseOption; }; -export enum HistoryOrderByInput { +export enum RebaseOptionOrderByInput { AddressBalanceAsc = 'address_balance_ASC', AddressBalanceAscNullsFirst = 'address_balance_ASC_NULLS_FIRST', AddressBalanceDesc = 'address_balance_DESC', @@ -396,10 +1687,6 @@ export enum HistoryOrderByInput { AddressRebasingOptionAscNullsFirst = 'address_rebasingOption_ASC_NULLS_FIRST', AddressRebasingOptionDesc = 'address_rebasingOption_DESC', AddressRebasingOptionDescNullsLast = 'address_rebasingOption_DESC_NULLS_LAST', - BalanceAsc = 'balance_ASC', - BalanceAscNullsFirst = 'balance_ASC_NULLS_FIRST', - BalanceDesc = 'balance_DESC', - BalanceDescNullsLast = 'balance_DESC_NULLS_LAST', BlockNumberAsc = 'blockNumber_ASC', BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', BlockNumberDesc = 'blockNumber_DESC', @@ -408,6 +1695,10 @@ export enum HistoryOrderByInput { IdAscNullsFirst = 'id_ASC_NULLS_FIRST', IdDesc = 'id_DESC', IdDescNullsLast = 'id_DESC_NULLS_LAST', + StatusAsc = 'status_ASC', + StatusAscNullsFirst = 'status_ASC_NULLS_FIRST', + StatusDesc = 'status_DESC', + StatusDescNullsLast = 'status_DESC_NULLS_LAST', TimestampAsc = 'timestamp_ASC', TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', TimestampDesc = 'timestamp_DESC', @@ -415,31 +1706,14 @@ export enum HistoryOrderByInput { TxHashAsc = 'txHash_ASC', TxHashAscNullsFirst = 'txHash_ASC_NULLS_FIRST', TxHashDesc = 'txHash_DESC', - TxHashDescNullsLast = 'txHash_DESC_NULLS_LAST', - TypeAsc = 'type_ASC', - TypeAscNullsFirst = 'type_ASC_NULLS_FIRST', - TypeDesc = 'type_DESC', - TypeDescNullsLast = 'type_DESC_NULLS_LAST', - ValueAsc = 'value_ASC', - ValueAscNullsFirst = 'value_ASC_NULLS_FIRST', - ValueDesc = 'value_DESC', - ValueDescNullsLast = 'value_DESC_NULLS_LAST' + TxHashDescNullsLast = 'txHash_DESC_NULLS_LAST' } -export type HistoryWhereInput = { - AND?: InputMaybe>; - OR?: InputMaybe>; +export type RebaseOptionWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; address?: InputMaybe; address_isNull?: InputMaybe; - balance_eq?: InputMaybe; - balance_gt?: InputMaybe; - balance_gte?: InputMaybe; - balance_in?: InputMaybe>; - balance_isNull?: InputMaybe; - balance_lt?: InputMaybe; - balance_lte?: InputMaybe; - balance_not_eq?: InputMaybe; - balance_not_in?: InputMaybe>; blockNumber_eq?: InputMaybe; blockNumber_gt?: InputMaybe; blockNumber_gte?: InputMaybe; @@ -466,6 +1740,11 @@ export type HistoryWhereInput = { id_not_in?: InputMaybe>; id_not_startsWith?: InputMaybe; id_startsWith?: InputMaybe; + status_eq?: InputMaybe; + status_in?: InputMaybe>; + status_isNull?: InputMaybe; + status_not_eq?: InputMaybe; + status_not_in?: InputMaybe>; timestamp_eq?: InputMaybe; timestamp_gt?: InputMaybe; timestamp_gte?: InputMaybe; @@ -492,187 +1771,13 @@ export type HistoryWhereInput = { txHash_not_in?: InputMaybe>; txHash_not_startsWith?: InputMaybe; txHash_startsWith?: InputMaybe; - type_contains?: InputMaybe; - type_containsInsensitive?: InputMaybe; - type_endsWith?: InputMaybe; - type_eq?: InputMaybe; - type_gt?: InputMaybe; - type_gte?: InputMaybe; - type_in?: InputMaybe>; - type_isNull?: InputMaybe; - type_lt?: InputMaybe; - type_lte?: InputMaybe; - type_not_contains?: InputMaybe; - type_not_containsInsensitive?: InputMaybe; - type_not_endsWith?: InputMaybe; - type_not_eq?: InputMaybe; - type_not_in?: InputMaybe>; - type_not_startsWith?: InputMaybe; - type_startsWith?: InputMaybe; - value_eq?: InputMaybe; - value_gt?: InputMaybe; - value_gte?: InputMaybe; - value_in?: InputMaybe>; - value_isNull?: InputMaybe; - value_lt?: InputMaybe; - value_lte?: InputMaybe; - value_not_eq?: InputMaybe; - value_not_in?: InputMaybe>; -}; - -export type PageInfo = { - __typename?: 'PageInfo'; - endCursor: Scalars['String']['output']; - hasNextPage: Scalars['Boolean']['output']; - hasPreviousPage: Scalars['Boolean']['output']; - startCursor: Scalars['String']['output']; -}; - -export type Query = { - __typename?: 'Query'; - addressById?: Maybe
; - /** @deprecated Use addressById */ - addressByUniqueInput?: Maybe
; - addresses: Array
; - addressesConnection: AddressesConnection; - apies: Array; - apiesConnection: APiesConnection; - apyById?: Maybe; - /** @deprecated Use apyById */ - apyByUniqueInput?: Maybe; - histories: Array; - historiesConnection: HistoriesConnection; - historyById?: Maybe; - /** @deprecated Use historyById */ - historyByUniqueInput?: Maybe; - rebaseById?: Maybe; - /** @deprecated Use rebaseById */ - rebaseByUniqueInput?: Maybe; - rebases: Array; - rebasesConnection: RebasesConnection; - squidStatus?: Maybe; -}; - - -export type QueryAddressByIdArgs = { - id: Scalars['String']['input']; -}; - - -export type QueryAddressByUniqueInputArgs = { - where: WhereIdInput; -}; - - -export type QueryAddressesArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - orderBy?: InputMaybe>; - where?: InputMaybe; -}; - - -export type QueryAddressesConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; - orderBy: Array; - where?: InputMaybe; -}; - - -export type QueryApiesArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - orderBy?: InputMaybe>; - where?: InputMaybe; -}; - - -export type QueryApiesConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; - orderBy: Array; - where?: InputMaybe; -}; - - -export type QueryApyByIdArgs = { - id: Scalars['String']['input']; -}; - - -export type QueryApyByUniqueInputArgs = { - where: WhereIdInput; -}; - - -export type QueryHistoriesArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - orderBy?: InputMaybe>; - where?: InputMaybe; -}; - - -export type QueryHistoriesConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; - orderBy: Array; - where?: InputMaybe; -}; - - -export type QueryHistoryByIdArgs = { - id: Scalars['String']['input']; -}; - - -export type QueryHistoryByUniqueInputArgs = { - where: WhereIdInput; -}; - - -export type QueryRebaseByIdArgs = { - id: Scalars['String']['input']; -}; - - -export type QueryRebaseByUniqueInputArgs = { - where: WhereIdInput; -}; - - -export type QueryRebasesArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - orderBy?: InputMaybe>; - where?: InputMaybe; -}; - - -export type QueryRebasesConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; - orderBy: Array; - where?: InputMaybe; -}; - -export type Rebase = { - __typename?: 'Rebase'; - apy: Apy; - blockNumber: Scalars['Int']['output']; - id: Scalars['String']['output']; - rebasingCredits: Scalars['BigInt']['output']; - rebasingCreditsPerToken: Scalars['BigInt']['output']; - timestamp: Scalars['DateTime']['output']; - totalSupply: Scalars['BigInt']['output']; - txHash: Scalars['String']['output']; }; -export type RebaseEdge = { - __typename?: 'RebaseEdge'; - cursor: Scalars['String']['output']; - node: Rebase; +export type RebaseOptionsConnection = { + __typename?: 'RebaseOptionsConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; }; export enum RebaseOrderByInput { @@ -839,12 +1944,148 @@ export type RebasesConnection = { totalCount: Scalars['Int']['output']; }; +export enum RebasingOption { + OptIn = 'OptIn', + OptOut = 'OptOut' +} + export type SquidStatus = { __typename?: 'SquidStatus'; /** The height of the processed part of the chain */ height?: Maybe; }; +export type Vault = { + __typename?: 'Vault'; + blockNumber: Scalars['Int']['output']; + frxETH: Scalars['BigInt']['output']; + id: Scalars['String']['output']; + rETH: Scalars['BigInt']['output']; + stETH: Scalars['BigInt']['output']; + timestamp: Scalars['DateTime']['output']; + weth: Scalars['BigInt']['output']; +}; + +export type VaultEdge = { + __typename?: 'VaultEdge'; + cursor: Scalars['String']['output']; + node: Vault; +}; + +export enum VaultOrderByInput { + BlockNumberAsc = 'blockNumber_ASC', + BlockNumberAscNullsFirst = 'blockNumber_ASC_NULLS_FIRST', + BlockNumberDesc = 'blockNumber_DESC', + BlockNumberDescNullsLast = 'blockNumber_DESC_NULLS_LAST', + FrxEthAsc = 'frxETH_ASC', + FrxEthAscNullsFirst = 'frxETH_ASC_NULLS_FIRST', + FrxEthDesc = 'frxETH_DESC', + FrxEthDescNullsLast = 'frxETH_DESC_NULLS_LAST', + IdAsc = 'id_ASC', + IdAscNullsFirst = 'id_ASC_NULLS_FIRST', + IdDesc = 'id_DESC', + IdDescNullsLast = 'id_DESC_NULLS_LAST', + REthAsc = 'rETH_ASC', + REthAscNullsFirst = 'rETH_ASC_NULLS_FIRST', + REthDesc = 'rETH_DESC', + REthDescNullsLast = 'rETH_DESC_NULLS_LAST', + StEthAsc = 'stETH_ASC', + StEthAscNullsFirst = 'stETH_ASC_NULLS_FIRST', + StEthDesc = 'stETH_DESC', + StEthDescNullsLast = 'stETH_DESC_NULLS_LAST', + TimestampAsc = 'timestamp_ASC', + TimestampAscNullsFirst = 'timestamp_ASC_NULLS_FIRST', + TimestampDesc = 'timestamp_DESC', + TimestampDescNullsLast = 'timestamp_DESC_NULLS_LAST', + WethAsc = 'weth_ASC', + WethAscNullsFirst = 'weth_ASC_NULLS_FIRST', + WethDesc = 'weth_DESC', + WethDescNullsLast = 'weth_DESC_NULLS_LAST' +} + +export type VaultWhereInput = { + AND?: InputMaybe>; + OR?: InputMaybe>; + blockNumber_eq?: InputMaybe; + blockNumber_gt?: InputMaybe; + blockNumber_gte?: InputMaybe; + blockNumber_in?: InputMaybe>; + blockNumber_isNull?: InputMaybe; + blockNumber_lt?: InputMaybe; + blockNumber_lte?: InputMaybe; + blockNumber_not_eq?: InputMaybe; + blockNumber_not_in?: InputMaybe>; + frxETH_eq?: InputMaybe; + frxETH_gt?: InputMaybe; + frxETH_gte?: InputMaybe; + frxETH_in?: InputMaybe>; + frxETH_isNull?: InputMaybe; + frxETH_lt?: InputMaybe; + frxETH_lte?: InputMaybe; + frxETH_not_eq?: InputMaybe; + frxETH_not_in?: InputMaybe>; + id_contains?: InputMaybe; + id_containsInsensitive?: InputMaybe; + id_endsWith?: InputMaybe; + id_eq?: InputMaybe; + id_gt?: InputMaybe; + id_gte?: InputMaybe; + id_in?: InputMaybe>; + id_isNull?: InputMaybe; + id_lt?: InputMaybe; + id_lte?: InputMaybe; + id_not_contains?: InputMaybe; + id_not_containsInsensitive?: InputMaybe; + id_not_endsWith?: InputMaybe; + id_not_eq?: InputMaybe; + id_not_in?: InputMaybe>; + id_not_startsWith?: InputMaybe; + id_startsWith?: InputMaybe; + rETH_eq?: InputMaybe; + rETH_gt?: InputMaybe; + rETH_gte?: InputMaybe; + rETH_in?: InputMaybe>; + rETH_isNull?: InputMaybe; + rETH_lt?: InputMaybe; + rETH_lte?: InputMaybe; + rETH_not_eq?: InputMaybe; + rETH_not_in?: InputMaybe>; + stETH_eq?: InputMaybe; + stETH_gt?: InputMaybe; + stETH_gte?: InputMaybe; + stETH_in?: InputMaybe>; + stETH_isNull?: InputMaybe; + stETH_lt?: InputMaybe; + stETH_lte?: InputMaybe; + stETH_not_eq?: InputMaybe; + stETH_not_in?: InputMaybe>; + timestamp_eq?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>; + timestamp_isNull?: InputMaybe; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not_eq?: InputMaybe; + timestamp_not_in?: InputMaybe>; + weth_eq?: InputMaybe; + weth_gt?: InputMaybe; + weth_gte?: InputMaybe; + weth_in?: InputMaybe>; + weth_isNull?: InputMaybe; + weth_lt?: InputMaybe; + weth_lte?: InputMaybe; + weth_not_eq?: InputMaybe; + weth_not_in?: InputMaybe>; +}; + +export type VaultsConnection = { + __typename?: 'VaultsConnection'; + edges: Array; + pageInfo: PageInfo; + totalCount: Scalars['Int']['output']; +}; + export type WhereIdInput = { id: Scalars['String']['input']; }; diff --git a/libs/shared/theme/src/theme.d.ts b/libs/shared/theme/src/theme.d.ts index 5c6377f01..4d7b7d54a 100644 --- a/libs/shared/theme/src/theme.d.ts +++ b/libs/shared/theme/src/theme.d.ts @@ -3,6 +3,9 @@ import '@mui/material/Button'; declare module '@mui/material/styles' { interface TypeBackground { + paper: string; + paperHeader: string; + paperFooter: string; gradient1: string; gradient2: string; gradient3: string; diff --git a/libs/shared/theme/src/theme.tsx b/libs/shared/theme/src/theme.tsx index 321bfdc49..d5753d476 100644 --- a/libs/shared/theme/src/theme.tsx +++ b/libs/shared/theme/src/theme.tsx @@ -14,8 +14,6 @@ export const theme = extendTheme({ dark: '#0274f1', light: '#b361e6', contrastText: '#FAFBFB', - '400': '#CF75D5', // Often used in charts. - '500': '#FEDBA8', // Often used in charts. }, secondary: { main: '#0074F0', @@ -23,6 +21,8 @@ export const theme = extendTheme({ divider: '#101113', background: { paper: '#1E1F25', + paperHeader: '#23242A', + paperFooter: '#23242A', default: '#101113', // TODO cleanup these gradients after theme is properly configured -> gradients can be generated based on css vars gradient1: 'linear-gradient(90deg,#8c66fc -28.99%,#0274f1 144.97%)', From e376f938f41b7121cb8de1e6f95ea262b33353cc Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Tue, 26 Sep 2023 19:06:11 -0700 Subject: [PATCH 09/20] feat: financial statement --- .../src/FinancialStatement.generated.ts | 4 +-- libs/analytics/src/FinancialStatement.graphql | 2 +- libs/analytics/src/FinancialStatement.tsx | 26 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libs/analytics/src/FinancialStatement.generated.ts b/libs/analytics/src/FinancialStatement.generated.ts index d795f0c5d..39162283a 100644 --- a/libs/analytics/src/FinancialStatement.generated.ts +++ b/libs/analytics/src/FinancialStatement.generated.ts @@ -34,7 +34,7 @@ export type FinancialStatementReportQuery = { frxETH: any; }; }>; - financialStatements1W: Array<{ + financialStatementsCompare: Array<{ __typename?: 'FinancialStatement'; blockNumber: number; timestamp: any; @@ -93,7 +93,7 @@ export const FinancialStatementReportDocument = ` frxETH } } - financialStatements1W: financialStatements( + financialStatementsCompare: financialStatements( orderBy: id_DESC limit: 1 where: {timestamp_lt: $compareDate} diff --git a/libs/analytics/src/FinancialStatement.graphql b/libs/analytics/src/FinancialStatement.graphql index d9d9763b1..3a7e3bac4 100644 --- a/libs/analytics/src/FinancialStatement.graphql +++ b/libs/analytics/src/FinancialStatement.graphql @@ -29,7 +29,7 @@ query FinancialStatementReport($compareDate: DateTime) { frxETH } } - financialStatements1W: financialStatements(orderBy: id_DESC, limit: 1, where: {timestamp_lt: $compareDate}) { + financialStatementsCompare: financialStatements(orderBy: id_DESC, limit: 1, where: {timestamp_lt: $compareDate}) { blockNumber timestamp oeth { diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index cd25d5488..3642bcc51 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -45,11 +45,11 @@ export const LiveFinancialStatement = () => { if (isLoading || !data) return null; const fs = data.financialStatements[0]; - const fs1W = data.financialStatements1W[0]; + const fsC = data.financialStatementsCompare[0]; const c = (n: string) => Number(formatEther(BigInt(n))); if (!fs) return null; - if (!fs1W) return null; + if (!fsC) return null; return ( { timestamp: Date.parse(fs.timestamp), }} columns={[ - dayjs(fs1W.timestamp).format('lll'), + dayjs(fsC.timestamp).format('lll'), dayjs(fs.timestamp).format('lll'), ]} data={{ assets: { Vault: { - WETH: [fs1W.vault.weth, fs.vault.weth].map(c), - stETH: [fs1W.vault.stETH, fs.vault.stETH].map(c), - rETH: [fs1W.vault.rETH, fs.vault.rETH].map(c), - frxETH: [fs1W.vault.frxETH, fs.vault.frxETH].map(c), + WETH: [fsC.vault.weth, fs.vault.weth].map(c), + stETH: [fsC.vault.stETH, fs.vault.stETH].map(c), + rETH: [fsC.vault.rETH, fs.vault.rETH].map(c), + frxETH: [fsC.vault.frxETH, fs.vault.frxETH].map(c), }, Curve: { - ETH: [fs1W.curveLP.eth, fs.curveLP.eth].map(c), - OETH: [fs1W.curveLP.oeth, fs.curveLP.oeth].map(c), + ETH: [fsC.curveLP.eth, fs.curveLP.eth].map(c), + OETH: [fsC.curveLP.oeth, fs.curveLP.oeth].map(c), }, 'Frax Staking': { - frxETH: [fs1W.fraxStaking.frxETH, fs.fraxStaking.frxETH].map(c), + frxETH: [fsC.fraxStaking.frxETH, fs.fraxStaking.frxETH].map(c), }, 'Morpho Aave': { - WETH: [fs1W.morphoAave.weth, fs.morphoAave.weth].map(c), + WETH: [fsC.morphoAave.weth, fs.morphoAave.weth].map(c), }, Dripper: { - WETH: [fs1W.dripper.weth, fs.dripper.weth].map(c), + WETH: [fsC.dripper.weth, fs.dripper.weth].map(c), }, }, liabilities: { 'Token Supply': { - OETH: [fs1W.oeth.totalSupply, fs.oeth.totalSupply].map(c), + OETH: [fsC.oeth.totalSupply, fs.oeth.totalSupply].map(c), }, }, }} From 74ab56f4160a073005a7b529c2aa6cf1b3d5c118 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 27 Sep 2023 11:34:30 -0700 Subject: [PATCH 10/20] feat: financial statement move financial statement 'object' to front-end as a view query --- .../src/FinancialStatement.generated.ts | 223 +++++++--------- libs/analytics/src/FinancialStatement.graphql | 88 +++--- libs/analytics/src/FinancialStatement.tsx | 64 +++-- libs/oeth/shared/src/generated/graphql.ts | 252 ------------------ 4 files changed, 171 insertions(+), 456 deletions(-) diff --git a/libs/analytics/src/FinancialStatement.generated.ts b/libs/analytics/src/FinancialStatement.generated.ts index 39162283a..590f96524 100644 --- a/libs/analytics/src/FinancialStatement.generated.ts +++ b/libs/analytics/src/FinancialStatement.generated.ts @@ -3,161 +3,130 @@ import { useQuery } from '@tanstack/react-query'; import type * as Types from '@origin/oeth/shared'; import type { UseQueryOptions } from '@tanstack/react-query'; -export type FinancialStatementReportQueryVariables = Types.Exact<{ +export type FinancialStatementQueryVariables = Types.Exact<{ compareDate?: Types.InputMaybe; }>; -export type FinancialStatementReportQuery = { +export type FinancialStatementQuery = { __typename?: 'Query'; - financialStatements: Array<{ - __typename?: 'FinancialStatement'; + oeths: Array<{ + __typename?: 'OETH'; blockNumber: number; timestamp: any; - oeth: { __typename?: 'OETH'; totalSupply: any }; - curveLP: { - __typename?: 'CurveLP'; - eth: any; - ethOwned: any; - oeth: any; - oethOwned: any; - totalSupply: any; - totalSupplyOwned: any; - }; - dripper: { __typename?: 'Dripper'; weth: any }; - fraxStaking: { __typename?: 'FraxStaking'; frxETH: any }; - morphoAave: { __typename?: 'MorphoAave'; weth: any }; - vault: { - __typename?: 'Vault'; - weth: any; - rETH: any; - stETH: any; - frxETH: any; - }; + totalSupply: any; }>; - financialStatementsCompare: Array<{ - __typename?: 'FinancialStatement'; + curveLps: Array<{ + __typename?: 'CurveLP'; blockNumber: number; timestamp: any; - oeth: { __typename?: 'OETH'; totalSupply: any }; - curveLP: { - __typename?: 'CurveLP'; - eth: any; - ethOwned: any; - oeth: any; - oethOwned: any; - totalSupply: any; - totalSupplyOwned: any; - }; - dripper: { __typename?: 'Dripper'; weth: any }; - fraxStaking: { __typename?: 'FraxStaking'; frxETH: any }; - morphoAave: { __typename?: 'MorphoAave'; weth: any }; - vault: { - __typename?: 'Vault'; - weth: any; - rETH: any; - stETH: any; - frxETH: any; - }; + eth: any; + ethOwned: any; + oeth: any; + oethOwned: any; + totalSupply: any; + totalSupplyOwned: any; + }>; + morphoAaves: Array<{ + __typename?: 'MorphoAave'; + blockNumber: number; + timestamp: any; + weth: any; + }>; + fraxStakings: Array<{ + __typename?: 'FraxStaking'; + blockNumber: number; + timestamp: any; + frxETH: any; + }>; + drippers: Array<{ + __typename?: 'Dripper'; + blockNumber: number; + timestamp: any; + weth: any; + }>; + vaults: Array<{ + __typename?: 'Vault'; + blockNumber: number; + timestamp: any; + weth: any; + rETH: any; + stETH: any; + frxETH: any; }>; }; -export const FinancialStatementReportDocument = ` - query FinancialStatementReport($compareDate: DateTime) { - financialStatements(orderBy: id_DESC, limit: 1) { +export const FinancialStatementDocument = ` + query FinancialStatement($compareDate: DateTime) { + oeths(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + totalSupply + } + curveLps(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { blockNumber timestamp - oeth { - totalSupply - } - curveLP { - eth - ethOwned - oeth - oethOwned - totalSupply - totalSupplyOwned - } - dripper { - weth - } - fraxStaking { - frxETH - } - morphoAave { - weth - } - vault { - weth - rETH - stETH - frxETH - } + eth + ethOwned + oeth + oethOwned + totalSupply + totalSupplyOwned } - financialStatementsCompare: financialStatements( - orderBy: id_DESC - limit: 1 - where: {timestamp_lt: $compareDate} - ) { + morphoAaves(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { blockNumber timestamp - oeth { - totalSupply - } - curveLP { - eth - ethOwned - oeth - oethOwned - totalSupply - totalSupplyOwned - } - dripper { - weth - } - fraxStaking { - frxETH - } - morphoAave { - weth - } - vault { - weth - rETH - stETH - frxETH - } + weth + } + fraxStakings(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + frxETH + } + drippers(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + weth + } + vaults(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + weth + rETH + stETH + frxETH } } `; -export const useFinancialStatementReportQuery = < - TData = FinancialStatementReportQuery, +export const useFinancialStatementQuery = < + TData = FinancialStatementQuery, TError = unknown, >( - variables?: FinancialStatementReportQueryVariables, - options?: UseQueryOptions, + variables?: FinancialStatementQueryVariables, + options?: UseQueryOptions, ) => - useQuery( + useQuery( variables === undefined - ? ['FinancialStatementReport'] - : ['FinancialStatementReport', variables], - graphqlClient< - FinancialStatementReportQuery, - FinancialStatementReportQueryVariables - >(FinancialStatementReportDocument, variables), + ? ['FinancialStatement'] + : ['FinancialStatement', variables], + graphqlClient( + FinancialStatementDocument, + variables, + ), options, ); -useFinancialStatementReportQuery.getKey = ( - variables?: FinancialStatementReportQueryVariables, +useFinancialStatementQuery.getKey = ( + variables?: FinancialStatementQueryVariables, ) => variables === undefined - ? ['FinancialStatementReport'] - : ['FinancialStatementReport', variables]; -useFinancialStatementReportQuery.fetcher = ( - variables?: FinancialStatementReportQueryVariables, + ? ['FinancialStatement'] + : ['FinancialStatement', variables]; +useFinancialStatementQuery.fetcher = ( + variables?: FinancialStatementQueryVariables, options?: RequestInit['headers'], ) => - graphqlClient< - FinancialStatementReportQuery, - FinancialStatementReportQueryVariables - >(FinancialStatementReportDocument, variables, options); + graphqlClient( + FinancialStatementDocument, + variables, + options, + ); diff --git a/libs/analytics/src/FinancialStatement.graphql b/libs/analytics/src/FinancialStatement.graphql index 3a7e3bac4..a7d29425a 100644 --- a/libs/analytics/src/FinancialStatement.graphql +++ b/libs/analytics/src/FinancialStatement.graphql @@ -1,62 +1,40 @@ -query FinancialStatementReport($compareDate: DateTime) { - financialStatements(orderBy: id_DESC, limit: 1) { +query FinancialStatement($compareDate: DateTime) { + oeths(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { blockNumber timestamp - oeth { - totalSupply - } - curveLP { - eth - ethOwned - oeth - oethOwned - totalSupply - totalSupplyOwned - } - dripper { - weth - } - fraxStaking { - frxETH - } - morphoAave { - weth - } - vault { - weth - rETH - stETH - frxETH - } + totalSupply } - financialStatementsCompare: financialStatements(orderBy: id_DESC, limit: 1, where: {timestamp_lt: $compareDate}) { + curveLps(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { blockNumber timestamp - oeth { - totalSupply - } - curveLP { - eth - ethOwned - oeth - oethOwned - totalSupply - totalSupplyOwned - } - dripper { - weth - } - fraxStaking { - frxETH - } - morphoAave { - weth - } - vault { - weth - rETH - stETH - frxETH - } + eth + ethOwned + oeth + oethOwned + totalSupply + totalSupplyOwned + } + morphoAaves(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + weth + } + fraxStakings(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + frxETH + } + drippers(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + weth + } + vaults(limit: 1, orderBy: id_DESC, where: {timestamp_lt: $compareDate}) { + blockNumber + timestamp + weth + rETH + stETH + frxETH } } diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 3642bcc51..9b7df302d 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -14,7 +14,7 @@ import { useIntl } from 'react-intl'; import { formatEther } from 'viem'; import * as colors from './colors'; -import { useFinancialStatementReportQuery } from './FinancialStatement.generated'; +import { useFinancialStatementQuery } from './FinancialStatement.generated'; dayjs.extend(LocalizedFormat); @@ -37,56 +37,76 @@ const getTotals = (data: Record>) => { }; export const LiveFinancialStatement = () => { + const endOfToday = dayjs().endOf('day').toISOString(); const [sevenDaysAgo] = useState(dayjs().subtract(7, 'days').toISOString()); - const { isLoading, data } = useFinancialStatementReportQuery({ + const { isLoading: fsIsLoading, data: fs } = useFinancialStatementQuery({ + compareDate: endOfToday, + }); + const { isLoading: fsCIsLoading, data: fsC } = useFinancialStatementQuery({ compareDate: sevenDaysAgo, }); - if (isLoading || !data) return null; + if (fsIsLoading || !fs) return null; + if (fsCIsLoading || !fsC) return null; - const fs = data.financialStatements[0]; - const fsC = data.financialStatementsCompare[0]; - const c = (n: string) => Number(formatEther(BigInt(n))); + const c = (n?: string) => Number(formatEther(BigInt(n ?? 0))); - if (!fs) return null; - if (!fsC) return null; + const blockNumber = Math.max( + fs.vaults[0]?.blockNumber, + fs.curveLps[0]?.blockNumber, + fs.morphoAaves[0]?.blockNumber, + fs.drippers[0]?.blockNumber, + fs.oeths[0]?.blockNumber, + fs.fraxStakings[0]?.blockNumber, + ); + const timestamp = Math.max( + fs.vaults[0]?.timestamp, + fs.curveLps[0]?.timestamp, + fs.morphoAaves[0]?.timestamp, + fs.drippers[0]?.timestamp, + fs.oeths[0]?.timestamp, + fs.fraxStakings[0]?.timestamp, + ); return ( >; - OR?: InputMaybe>; - blockNumber_eq?: InputMaybe; - blockNumber_gt?: InputMaybe; - blockNumber_gte?: InputMaybe; - blockNumber_in?: InputMaybe>; - blockNumber_isNull?: InputMaybe; - blockNumber_lt?: InputMaybe; - blockNumber_lte?: InputMaybe; - blockNumber_not_eq?: InputMaybe; - blockNumber_not_in?: InputMaybe>; - curveLP?: InputMaybe; - curveLP_isNull?: InputMaybe; - dripper?: InputMaybe; - dripper_isNull?: InputMaybe; - fraxStaking?: InputMaybe; - fraxStaking_isNull?: InputMaybe; - id_contains?: InputMaybe; - id_containsInsensitive?: InputMaybe; - id_endsWith?: InputMaybe; - id_eq?: InputMaybe; - id_gt?: InputMaybe; - id_gte?: InputMaybe; - id_in?: InputMaybe>; - id_isNull?: InputMaybe; - id_lt?: InputMaybe; - id_lte?: InputMaybe; - id_not_contains?: InputMaybe; - id_not_containsInsensitive?: InputMaybe; - id_not_endsWith?: InputMaybe; - id_not_eq?: InputMaybe; - id_not_in?: InputMaybe>; - id_not_startsWith?: InputMaybe; - id_startsWith?: InputMaybe; - morphoAave?: InputMaybe; - morphoAave_isNull?: InputMaybe; - oeth?: InputMaybe; - oeth_isNull?: InputMaybe; - timestamp_eq?: InputMaybe; - timestamp_gt?: InputMaybe; - timestamp_gte?: InputMaybe; - timestamp_in?: InputMaybe>; - timestamp_isNull?: InputMaybe; - timestamp_lt?: InputMaybe; - timestamp_lte?: InputMaybe; - timestamp_not_eq?: InputMaybe; - timestamp_not_in?: InputMaybe>; - vault?: InputMaybe; - vault_isNull?: InputMaybe; -}; - -export type FinancialStatementsConnection = { - __typename?: 'FinancialStatementsConnection'; - edges: Array; - pageInfo: PageInfo; - totalCount: Scalars['Int']['output']; -}; - export type FraxStaking = { __typename?: 'FraxStaking'; blockNumber: Scalars['Int']['output']; @@ -1269,11 +1048,6 @@ export type Query = { dripperByUniqueInput?: Maybe; drippers: Array; drippersConnection: DrippersConnection; - financialStatementById?: Maybe; - /** @deprecated Use financialStatementById */ - financialStatementByUniqueInput?: Maybe; - financialStatements: Array; - financialStatementsConnection: FinancialStatementsConnection; fraxStakingById?: Maybe; /** @deprecated Use fraxStakingById */ fraxStakingByUniqueInput?: Maybe; @@ -1417,32 +1191,6 @@ export type QueryDrippersConnectionArgs = { }; -export type QueryFinancialStatementByIdArgs = { - id: Scalars['String']['input']; -}; - - -export type QueryFinancialStatementByUniqueInputArgs = { - where: WhereIdInput; -}; - - -export type QueryFinancialStatementsArgs = { - limit?: InputMaybe; - offset?: InputMaybe; - orderBy?: InputMaybe>; - where?: InputMaybe; -}; - - -export type QueryFinancialStatementsConnectionArgs = { - after?: InputMaybe; - first?: InputMaybe; - orderBy: Array; - where?: InputMaybe; -}; - - export type QueryFraxStakingByIdArgs = { id: Scalars['String']['input']; }; From 3734b1d978c85894bb2ba2d67cb76147940580d4 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 27 Sep 2023 14:04:25 -0700 Subject: [PATCH 11/20] feat: financial statement usd/eth price switcher --- libs/analytics/src/FinancialStatement.tsx | 197 ++++++++++++++++------ libs/shared/providers/src/prices/hooks.ts | 18 ++ 2 files changed, 167 insertions(+), 48 deletions(-) diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 9b7df302d..4a7926c90 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -1,13 +1,16 @@ -import { useState } from 'react'; +import { createContext, useContext, useState } from 'react'; import { + alpha, Box, + Button, Paper, Stack, Typography, useMediaQuery, useTheme, } from '@mui/material'; +import { useChainlinkEthUsd } from '@origin/shared/providers'; import dayjs from 'dayjs'; import LocalizedFormat from 'dayjs/plugin/localizedFormat'; import { useIntl } from 'react-intl'; @@ -45,9 +48,11 @@ export const LiveFinancialStatement = () => { const { isLoading: fsCIsLoading, data: fsC } = useFinancialStatementQuery({ compareDate: sevenDaysAgo, }); + const { isLoading: ethPriceIsLoading, data: ethPrice } = useChainlinkEthUsd(); if (fsIsLoading || !fs) return null; if (fsCIsLoading || !fsC) return null; + if (ethPriceIsLoading || !ethPrice) return null; const c = (n?: string) => Number(formatEther(BigInt(n ?? 0))); @@ -60,17 +65,17 @@ export const LiveFinancialStatement = () => { fs.fraxStakings[0]?.blockNumber, ); const timestamp = Math.max( - fs.vaults[0]?.timestamp, - fs.curveLps[0]?.timestamp, - fs.morphoAaves[0]?.timestamp, - fs.drippers[0]?.timestamp, - fs.oeths[0]?.timestamp, - fs.fraxStakings[0]?.timestamp, + Date.parse(fs.vaults[0]?.timestamp), + Date.parse(fs.curveLps[0]?.timestamp), + Date.parse(fs.morphoAaves[0]?.timestamp), + Date.parse(fs.drippers[0]?.timestamp), + Date.parse(fs.oeths[0]?.timestamp), + Date.parse(fs.fraxStakings[0]?.timestamp), ); return ( { ); }; +const FinancialStatementContext = createContext({ + ethPrice: undefined as number | undefined, + showUsdPrice: false, +}); + export const FinancialStatement = (props: { - ethPrice: number; + ethPrice?: number; lastUpdated: { blockNumber: number; timestamp: number; @@ -126,48 +136,138 @@ export const FinancialStatement = (props: { Record> >; }) => { + const intl = useIntl(); const assetTotals = getTotals(props.data['assets']); const liabilityTotals = getTotals(props.data['liabilities']); + const [showUsdPrice, setShowUsdPrice] = useState(!!props.ethPrice); return ( - theme.palette.text.primary} - fontFamily={'Inter'} - fontSize={{ xs: '.7rem', sm: '.875rem' }} + -
-
-
- - - val - liabilityTotals[index])} + theme.palette.text.primary} + fontFamily={'Inter'} + fontSize={{ xs: '.7rem', sm: '.875rem' }} + > + + theme.palette.background.paper, + }} + > + + + + +
+
- - - - {`Last updated ${dayjs(props.lastUpdated.timestamp).format( - 'll', - )} at `} - {`${dayjs(props.lastUpdated.timestamp).format('LT')}, block #${ - props.lastUpdated.blockNumber - }`} - - - {`Using ETH price of $${props.ethPrice} from Chainlink`} - - - +
+ + + val - liabilityTotals[index], + )} + /> + + theme.palette.primary.contrastText} + > + + {`Last updated ${dayjs(props.lastUpdated.timestamp).format( + 'll', + )} at `} + {`${dayjs(props.lastUpdated.timestamp).format('LT')}, block #${ + props.lastUpdated.blockNumber + }`} + + + {props.ethPrice && + `Using ETH price of $${intl.formatNumber(props.ethPrice, { + maximumFractionDigits: 2, + })} from Chainlink`} + + + + ); }; @@ -195,7 +295,7 @@ const Header = (props: { columns: string[] }) => { py={{ xs: 2, sm: 3, md: 4 }} > - {props.columns.map((column, index) => ( + {props.columns.map((column) => ( theme.palette.text.primary} pr={{ xs: 0.1, sm: 0.15, md: 0.2 }} > - {'Ξ'} + {showUsdPrice && ethPrice ? '$' : 'Ξ'} - {intl.formatNumber(value, { + {intl.formatNumber(showUsdPrice && ethPrice ? value * ethPrice : value, { notation: isMobile ? 'compact' : 'standard', maximumFractionDigits: isMobile ? 1 : 2, })} diff --git a/libs/shared/providers/src/prices/hooks.ts b/libs/shared/providers/src/prices/hooks.ts index 41a09ab0f..c37e21d92 100644 --- a/libs/shared/providers/src/prices/hooks.ts +++ b/libs/shared/providers/src/prices/hooks.ts @@ -64,3 +64,21 @@ export const usePrices = ( ...options, }); }; + +export const useChainlinkEthUsd = () => { + return useQuery({ + queryKey: ['useChainlinkUsd'], + queryFn: async () => { + const usd = await readContract({ + address: contracts.mainnet.ChainlinkOracle.address, + abi: contracts.mainnet.ChainlinkOracle.abi, + functionName: 'ethUsdPrice', + }); + + const floatUsd = +formatUnits(usd, 6); + const gweiUsd = floatUsd * 1e-9; + + return { usd, floatUsd, gweiUsd }; + }, + }); +}; From f71133ee3908124a20a30efc29b58ff300980beb Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 27 Sep 2023 14:29:20 -0700 Subject: [PATCH 12/20] feat: financial statement style fix --- libs/analytics/src/FinancialStatement.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 4a7926c90..9f9d35a57 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -367,6 +367,7 @@ const Total = (props: { title: string; totals: number[] }) => { return ( theme.palette.primary.contrastText} sx={{ backgroundColor: (theme) => theme.palette.background.paperFooter }} From 0b36f9b35626e5aa3b6d277c7cdd8963d686e21f Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Wed, 27 Sep 2023 16:17:18 -0700 Subject: [PATCH 13/20] feat: financial statement show relative time, small -0% fix, style fix --- libs/analytics/src/FinancialStatement.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 9f9d35a57..15362716f 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -13,6 +13,7 @@ import { import { useChainlinkEthUsd } from '@origin/shared/providers'; import dayjs from 'dayjs'; import LocalizedFormat from 'dayjs/plugin/localizedFormat'; +import RelativeTime from 'dayjs/plugin/relativeTime'; import { useIntl } from 'react-intl'; import { formatEther } from 'viem'; @@ -20,12 +21,16 @@ import * as colors from './colors'; import { useFinancialStatementQuery } from './FinancialStatement.generated'; dayjs.extend(LocalizedFormat); +dayjs.extend(RelativeTime); const calculateChange = (from: number, to: number) => { if (from === 0 && to === 0) return 0; const change = -(1 - to / from); const mod = to < 0 ? -1 : 1; - return (Math[change > 0 ? 'floor' : 'ceil'](change * 10000) / 100) * mod; + const result = + (Math[change > 0 ? 'floor' : 'ceil'](change * 10000) / 100) * mod; + if (result.toFixed(2) === '0.00') return 0; // Weed out tiny rounding issues + return result; }; const getTotals = (data: Record>) => { @@ -80,10 +85,7 @@ export const LiveFinancialStatement = () => { blockNumber, timestamp, }} - columns={[ - dayjs(endOfToday).format('lll'), - dayjs(sevenDaysAgo).format('lll'), - ]} + columns={[dayjs(sevenDaysAgo).fromNow(), dayjs(endOfToday).format('ll')]} data={{ assets: { Vault: { @@ -368,6 +370,7 @@ const Total = (props: { title: string; totals: number[] }) => { theme.palette.primary.contrastText} sx={{ backgroundColor: (theme) => theme.palette.background.paperFooter }} From 604063e3dc111d8b348f5477970e771298037f98 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 28 Sep 2023 09:02:28 -0700 Subject: [PATCH 14/20] feat: financial statement export default --- libs/analytics/src/FinancialStatement.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/analytics/src/FinancialStatement.tsx index 15362716f..afc3bbd8b 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/analytics/src/FinancialStatement.tsx @@ -121,6 +121,8 @@ export const LiveFinancialStatement = () => { ); }; +export default LiveFinancialStatement; + const FinancialStatementContext = createContext({ ethPrice: undefined as number | undefined, showUsdPrice: false, From 5b6b7ae01af067e824fbe224fa75e6311f4df0b2 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 28 Sep 2023 16:13:14 -0700 Subject: [PATCH 15/20] feat: financial statement as a package, but doesn't abide by `@nx/enforce-module-boundaries` --- libs/analytics/src/index.ts | 1 - libs/financial-statement/.babelrc | 12 ++++++ libs/financial-statement/.eslintrc.json | 34 +++++++++++++++ libs/financial-statement/README.md | 7 +++ libs/financial-statement/package.json | 12 ++++++ libs/financial-statement/project.json | 38 ++++++++++++++++ .../src/FinancialStatement.generated.ts | 0 .../src/FinancialStatement.graphql | 0 .../src/FinancialStatement.stories.tsx | 0 .../src/FinancialStatement.tsx | 20 +++++++-- .../src/colors.ts | 0 libs/financial-statement/src/index.ts | 2 + libs/financial-statement/tsconfig.json | 25 +++++++++++ libs/financial-statement/tsconfig.lib.json | 28 ++++++++++++ libs/financial-statement/vite.config.ts | 43 +++++++++++++++++++ libs/shared/utils/src/BigInt.ts | 2 +- tsconfig.base.json | 3 ++ 17 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 libs/financial-statement/.babelrc create mode 100644 libs/financial-statement/.eslintrc.json create mode 100644 libs/financial-statement/README.md create mode 100644 libs/financial-statement/package.json create mode 100644 libs/financial-statement/project.json rename libs/{analytics => financial-statement}/src/FinancialStatement.generated.ts (100%) rename libs/{analytics => financial-statement}/src/FinancialStatement.graphql (100%) rename libs/{analytics => financial-statement}/src/FinancialStatement.stories.tsx (100%) rename libs/{analytics => financial-statement}/src/FinancialStatement.tsx (95%) rename libs/{analytics => financial-statement}/src/colors.ts (100%) create mode 100644 libs/financial-statement/src/index.ts create mode 100644 libs/financial-statement/tsconfig.json create mode 100644 libs/financial-statement/tsconfig.lib.json create mode 100644 libs/financial-statement/vite.config.ts diff --git a/libs/analytics/src/index.ts b/libs/analytics/src/index.ts index af6469dc7..dd238161b 100644 --- a/libs/analytics/src/index.ts +++ b/libs/analytics/src/index.ts @@ -1,2 +1 @@ export * from './TimeLineChart'; -export * from './FinancialStatement'; diff --git a/libs/financial-statement/.babelrc b/libs/financial-statement/.babelrc new file mode 100644 index 000000000..1ea870ead --- /dev/null +++ b/libs/financial-statement/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/financial-statement/.eslintrc.json b/libs/financial-statement/.eslintrc.json new file mode 100644 index 000000000..78d5588fd --- /dev/null +++ b/libs/financial-statement/.eslintrc.json @@ -0,0 +1,34 @@ +{ + "extends": [ + "plugin:@nx/react", + "../../.eslintrc.json" + ], + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts", + "*.tsx", + "*.js", + "*.jsx" + ], + "rules": {} + }, + { + "files": [ + "*.ts", + "*.tsx" + ], + "rules": {} + }, + { + "files": [ + "*.js", + "*.jsx" + ], + "rules": {} + } + ] +} diff --git a/libs/financial-statement/README.md b/libs/financial-statement/README.md new file mode 100644 index 000000000..896f5172c --- /dev/null +++ b/libs/financial-statement/README.md @@ -0,0 +1,7 @@ +# financial-statement + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test financial-statement` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/financial-statement/package.json b/libs/financial-statement/package.json new file mode 100644 index 000000000..4ffe0f055 --- /dev/null +++ b/libs/financial-statement/package.json @@ -0,0 +1,12 @@ +{ + "name": "@origin/financial-statement", + "version": "0.0.4", + "main": "./index.js", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js" + } + } +} diff --git a/libs/financial-statement/project.json b/libs/financial-statement/project.json new file mode 100644 index 000000000..9fd87d021 --- /dev/null +++ b/libs/financial-statement/project.json @@ -0,0 +1,38 @@ +{ + "name": "financial-statement", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/financial-statement/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": [ + "{options.outputFile}" + ], + "options": { + "lintFilePatterns": [ + "libs/financial-statement/**/*.{ts,tsx,js,jsx}" + ] + } + }, + "build": { + "executor": "@nx/vite:build", + "outputs": [ + "{options.outputPath}" + ], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/libs/financial-statement" + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } + } + } +} diff --git a/libs/analytics/src/FinancialStatement.generated.ts b/libs/financial-statement/src/FinancialStatement.generated.ts similarity index 100% rename from libs/analytics/src/FinancialStatement.generated.ts rename to libs/financial-statement/src/FinancialStatement.generated.ts diff --git a/libs/analytics/src/FinancialStatement.graphql b/libs/financial-statement/src/FinancialStatement.graphql similarity index 100% rename from libs/analytics/src/FinancialStatement.graphql rename to libs/financial-statement/src/FinancialStatement.graphql diff --git a/libs/analytics/src/FinancialStatement.stories.tsx b/libs/financial-statement/src/FinancialStatement.stories.tsx similarity index 100% rename from libs/analytics/src/FinancialStatement.stories.tsx rename to libs/financial-statement/src/FinancialStatement.stories.tsx diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/financial-statement/src/FinancialStatement.tsx similarity index 95% rename from libs/analytics/src/FinancialStatement.tsx rename to libs/financial-statement/src/FinancialStatement.tsx index afc3bbd8b..48bd51606 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/financial-statement/src/FinancialStatement.tsx @@ -4,17 +4,21 @@ import { alpha, Box, Button, + Experimental_CssVarsProvider, Paper, Stack, Typography, useMediaQuery, useTheme, } from '@mui/material'; +import { queryClient } from '@origin/oeth/shared'; import { useChainlinkEthUsd } from '@origin/shared/providers'; +import { theme } from '@origin/shared/theme'; +import { QueryClientProvider } from '@tanstack/react-query'; import dayjs from 'dayjs'; import LocalizedFormat from 'dayjs/plugin/localizedFormat'; import RelativeTime from 'dayjs/plugin/relativeTime'; -import { useIntl } from 'react-intl'; +import { IntlProvider, useIntl } from 'react-intl'; import { formatEther } from 'viem'; import * as colors from './colors'; @@ -44,6 +48,18 @@ const getTotals = (data: Record>) => { }, [] as number[]); }; +export default function SelfContainedFinancialStatement() { + return ( + + + + + + + + ); +} + export const LiveFinancialStatement = () => { const endOfToday = dayjs().endOf('day').toISOString(); const [sevenDaysAgo] = useState(dayjs().subtract(7, 'days').toISOString()); @@ -121,8 +137,6 @@ export const LiveFinancialStatement = () => { ); }; -export default LiveFinancialStatement; - const FinancialStatementContext = createContext({ ethPrice: undefined as number | undefined, showUsdPrice: false, diff --git a/libs/analytics/src/colors.ts b/libs/financial-statement/src/colors.ts similarity index 100% rename from libs/analytics/src/colors.ts rename to libs/financial-statement/src/colors.ts diff --git a/libs/financial-statement/src/index.ts b/libs/financial-statement/src/index.ts new file mode 100644 index 000000000..06500c227 --- /dev/null +++ b/libs/financial-statement/src/index.ts @@ -0,0 +1,2 @@ +export * from './FinancialStatement'; +export { default } from './FinancialStatement'; diff --git a/libs/financial-statement/tsconfig.json b/libs/financial-statement/tsconfig.json new file mode 100644 index 000000000..465c6c894 --- /dev/null +++ b/libs/financial-statement/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": false, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": false, + "types": [ + "vite/client" + ] + }, + "files": [ + "../../node_modules/@nx/react/typings/cssmodule.d.ts", + "../../node_modules/@nx/react/typings/image.d.ts", + "../../libs/shared/theme/src/theme.d.ts", + "../../apps/oeth/src/env.d.ts" + ], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "extends": "../../tsconfig.base.json" +} diff --git a/libs/financial-statement/tsconfig.lib.json b/libs/financial-statement/tsconfig.lib.json new file mode 100644 index 000000000..0cf346b95 --- /dev/null +++ b/libs/financial-statement/tsconfig.lib.json @@ -0,0 +1,28 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [ + "node", + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts", + "vite/client" + ] + }, + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.ts", + "src/**/*.tsx" + ] +} diff --git a/libs/financial-statement/vite.config.ts b/libs/financial-statement/vite.config.ts new file mode 100644 index 000000000..b90ea8e97 --- /dev/null +++ b/libs/financial-statement/vite.config.ts @@ -0,0 +1,43 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import react from '@vitejs/plugin-react'; +import * as path from 'path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/financial-statement', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + react(), + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'financial-statement', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}); diff --git a/libs/shared/utils/src/BigInt.ts b/libs/shared/utils/src/BigInt.ts index d96a687fb..ad952a512 100644 --- a/libs/shared/utils/src/BigInt.ts +++ b/libs/shared/utils/src/BigInt.ts @@ -1,2 +1,2 @@ -export const jsonStringifyReplacer = (key, value) => +export const jsonStringifyReplacer = (key: string, value: unknown) => typeof value === 'bigint' ? value.toString() : value; diff --git a/tsconfig.base.json b/tsconfig.base.json index 8ac9c5a3b..7c07e697e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -23,6 +23,9 @@ "@origin/analytics": [ "libs/analytics/src/index.ts" ], + "@origin/financial-statement": [ + "libs/financial-statement/src/index.ts" + ], "@origin/oeth/history": [ "libs/oeth/history/src/index.ts" ], From fc2ad0898954f7a4ed894bc97c47fcfee13d2f57 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 28 Sep 2023 17:22:21 -0700 Subject: [PATCH 16/20] feat: financial statement abide by `@nx/enforce-module-boundaries`, converting packages to be buildable --- libs/financial-statement/package.json | 2 +- libs/financial-statement/tsconfig.json | 6 -- libs/financial-statement/tsconfig.lib.json | 8 +- libs/financial-statement/vite.config.ts | 3 +- libs/oeth/history/src/components/Filters.tsx | 101 ++++++++++-------- .../history/src/components/HistoryCard.tsx | 4 +- libs/oeth/shared/.babelrc | 7 +- libs/oeth/shared/README.md | 2 +- libs/oeth/shared/package.json | 12 +++ libs/oeth/shared/project.json | 26 +++-- libs/oeth/shared/tsconfig.json | 5 +- libs/oeth/shared/tsconfig.lib.json | 25 ++++- libs/oeth/shared/vite.config.ts | 43 ++++++++ libs/shared/providers/README.md | 2 +- libs/shared/providers/package.json | 12 +++ libs/shared/providers/project.json | 18 ++++ libs/shared/providers/tsconfig.json | 4 +- libs/shared/providers/tsconfig.lib.json | 25 ++++- libs/shared/providers/vite.config.ts | 43 ++++++++ libs/shared/theme/.eslintrc.json | 26 ++++- libs/shared/theme/README.md | 2 +- libs/shared/theme/package.json | 12 +++ libs/shared/theme/project.json | 26 ++++- libs/shared/theme/tsconfig.json | 4 +- libs/shared/theme/tsconfig.lib.json | 29 +++-- libs/shared/theme/vite.config.ts | 42 ++++++++ 26 files changed, 385 insertions(+), 104 deletions(-) create mode 100644 libs/oeth/shared/package.json create mode 100644 libs/oeth/shared/vite.config.ts create mode 100644 libs/shared/providers/package.json create mode 100644 libs/shared/providers/vite.config.ts create mode 100644 libs/shared/theme/package.json create mode 100644 libs/shared/theme/vite.config.ts diff --git a/libs/financial-statement/package.json b/libs/financial-statement/package.json index 4ffe0f055..dc344a9db 100644 --- a/libs/financial-statement/package.json +++ b/libs/financial-statement/package.json @@ -1,6 +1,6 @@ { "name": "@origin/financial-statement", - "version": "0.0.4", + "version": "0.0.5", "main": "./index.js", "types": "./index.d.ts", "exports": { diff --git a/libs/financial-statement/tsconfig.json b/libs/financial-statement/tsconfig.json index 465c6c894..29f9136bb 100644 --- a/libs/financial-statement/tsconfig.json +++ b/libs/financial-statement/tsconfig.json @@ -9,12 +9,6 @@ "vite/client" ] }, - "files": [ - "../../node_modules/@nx/react/typings/cssmodule.d.ts", - "../../node_modules/@nx/react/typings/image.d.ts", - "../../libs/shared/theme/src/theme.d.ts", - "../../apps/oeth/src/env.d.ts" - ], "include": [], "references": [ { diff --git a/libs/financial-statement/tsconfig.lib.json b/libs/financial-statement/tsconfig.lib.json index 0cf346b95..380fb00a1 100644 --- a/libs/financial-statement/tsconfig.lib.json +++ b/libs/financial-statement/tsconfig.lib.json @@ -4,11 +4,15 @@ "outDir": "../../dist/out-tsc", "types": [ "node", - "@nx/react/typings/cssmodule.d.ts", - "@nx/react/typings/image.d.ts", "vite/client" ] }, + "files": [ + "../../node_modules/@nx/react/typings/cssmodule.d.ts", + "../../node_modules/@nx/react/typings/image.d.ts", + "../../libs/shared/theme/src/theme.d.ts", + "../../apps/oeth/src/env.d.ts" + ], "exclude": [ "**/*.spec.ts", "**/*.test.ts", diff --git a/libs/financial-statement/vite.config.ts b/libs/financial-statement/vite.config.ts index b90ea8e97..d0e3b91da 100644 --- a/libs/financial-statement/vite.config.ts +++ b/libs/financial-statement/vite.config.ts @@ -11,8 +11,7 @@ export default defineConfig({ plugins: [ dts({ entryRoot: 'src', - tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), - skipDiagnostics: true, + tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), }), react(), nxViteTsPaths(), diff --git a/libs/oeth/history/src/components/Filters.tsx b/libs/oeth/history/src/components/Filters.tsx index 420d8488c..abb1b55b1 100644 --- a/libs/oeth/history/src/components/Filters.tsx +++ b/libs/oeth/history/src/components/Filters.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import { alpha, @@ -21,6 +21,8 @@ import { useIntl } from 'react-intl'; import { HistoryFilterButton } from './HistoryButton'; +import type { HistoryType } from '@origin/oeth/shared'; + const styles = { fontSize: '0.75rem', fontWeight: 500, @@ -29,16 +31,19 @@ const styles = { }; interface Props { - onChange: (values: string[]) => void; + onChange: (values: HistoryType[]) => void; } export function HistoryFilters({ onChange }: Props) { - const [selected, setSelectedTypes] = useState([]); + const [selected, setSelectedTypes] = useState([]); const intl = useIntl(); const theme = useTheme(); const [anchorEl, setAnchorEl] = useState(null); - function selection(e: React.ChangeEvent, label: string) { + function selection( + e: React.ChangeEvent, + label: HistoryType, + ) { setSelectedTypes((prev) => { if (e.target.checked) { return [...prev, label]; @@ -94,52 +99,54 @@ export function HistoryFilters({ onChange }: Props) { - {['Yield', 'Swap', 'Sent', 'Received'].map((label) => ( - theme.palette.grey[700], - }, - }} - > - - {label} - - - } - icon={} + {(['Yield', 'Swap', 'Sent', 'Received'] as HistoryType[]).map( + (label) => ( + alpha(theme.palette.secondary.main, 0.4), - strokeWidth: '1px', - stroke: (theme) => theme.palette.primary.main, - }, - '&:hover:has(input:not(:checked)) svg': { - fill: (theme) => alpha(theme.palette.secondary.main, 0.4), + paddingInline: 2, + paddingBlock: 0, + paddingTop: 0, + paddingBottom: 0, + ...styles, + ':hover': { + background: (theme) => theme.palette.grey[700], }, }} - onChange={(e) => selection(e, label)} - /> - - ))} + > + + {label} + + + } + icon={} + sx={{ + '& svg, input': { + width: '1.25rem', + height: '1.25rem', + top: 'auto', + left: 'auto', + }, + '&:hover:has(input:checked) svg': { + fill: (theme) => alpha(theme.palette.secondary.main, 0.4), + strokeWidth: '1px', + stroke: (theme) => theme.palette.primary.main, + }, + '&:hover:has(input:not(:checked)) svg': { + fill: (theme) => alpha(theme.palette.secondary.main, 0.4), + }, + }} + onChange={(e) => selection(e, label)} + /> + + ), + )} ([]); + const [filters, setFilters] = useState([]); const { address, isConnected } = useAccount(); const { data, isFetching } = useHistoryTableWithFiltersQuery( diff --git a/libs/oeth/shared/.babelrc b/libs/oeth/shared/.babelrc index 9f606b4ff..1ea870ead 100644 --- a/libs/oeth/shared/.babelrc +++ b/libs/oeth/shared/.babelrc @@ -4,12 +4,9 @@ "@nx/react/babel", { "runtime": "automatic", - "useBuiltIns": "usage", - "importSource": "@emotion/react" + "useBuiltIns": "usage" } ] ], - "plugins": [ - "@emotion/babel-plugin" - ] + "plugins": [] } diff --git a/libs/oeth/shared/README.md b/libs/oeth/shared/README.md index 06209ca3c..4363b6d83 100644 --- a/libs/oeth/shared/README.md +++ b/libs/oeth/shared/README.md @@ -4,4 +4,4 @@ This library was generated with [Nx](https://nx.dev). ## Running unit tests -Run `nx test oeth-shared` to execute the unit tests via [Jest](https://jestjs.io). +Run `nx test oeth-shared` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/oeth/shared/package.json b/libs/oeth/shared/package.json new file mode 100644 index 000000000..fb09ea1b7 --- /dev/null +++ b/libs/oeth/shared/package.json @@ -0,0 +1,12 @@ +{ + "name": "@origin/oeth/shared", + "version": "0.0.1", + "main": "./index.js", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js" + } + } +} diff --git a/libs/oeth/shared/project.json b/libs/oeth/shared/project.json index 1bd971a92..2e92f651a 100644 --- a/libs/oeth/shared/project.json +++ b/libs/oeth/shared/project.json @@ -5,14 +5,6 @@ "projectType": "library", "tags": [], "targets": { - "codegen-graphql": { - "executor": "nx:run-commands", - "options": { - "commands": [ - "pnpm graphql-codegen --config 'libs/oeth/shared/codegen.ts'" - ] - } - }, "lint": { "executor": "@nx/linter:eslint", "outputs": [ @@ -23,6 +15,24 @@ "libs/oeth/shared/**/*.{ts,tsx,js,jsx}" ] } + }, + "build": { + "executor": "@nx/vite:build", + "outputs": [ + "{options.outputPath}" + ], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/libs/oeth/shared" + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } } } } diff --git a/libs/oeth/shared/tsconfig.json b/libs/oeth/shared/tsconfig.json index dd78c9fd2..33b686fe4 100644 --- a/libs/oeth/shared/tsconfig.json +++ b/libs/oeth/shared/tsconfig.json @@ -4,8 +4,9 @@ "allowJs": false, "esModuleInterop": false, "allowSyntheticDefaultImports": true, - "strict": false, - "jsxImportSource": "@emotion/react" + "types": [ + "vite/client" + ] }, "files": [], "include": [], diff --git a/libs/oeth/shared/tsconfig.lib.json b/libs/oeth/shared/tsconfig.lib.json index 49c6d19e5..d69c6c235 100644 --- a/libs/oeth/shared/tsconfig.lib.json +++ b/libs/oeth/shared/tsconfig.lib.json @@ -2,14 +2,31 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../../dist/out-tsc", - "types": ["node"] + "types": [ + "node", + "vite/client" + ] }, "files": [ "../../../node_modules/@nx/react/typings/cssmodule.d.ts", "../../../node_modules/@nx/react/typings/image.d.ts", "../../../libs/shared/theme/src/theme.d.ts", - "../../../apps/oeth/src/env.d.ts", + "../../../apps/oeth/src/env.d.ts" ], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"], - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.ts", + "src/**/*.tsx" + ] } diff --git a/libs/oeth/shared/vite.config.ts b/libs/oeth/shared/vite.config.ts new file mode 100644 index 000000000..e94106db1 --- /dev/null +++ b/libs/oeth/shared/vite.config.ts @@ -0,0 +1,43 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import react from '@vitejs/plugin-react'; +import * as path from 'path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; + +export default defineConfig({ + cacheDir: '../../../node_modules/.vite/oeth-shared', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + react(), + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'oeth-shared', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}); diff --git a/libs/shared/providers/README.md b/libs/shared/providers/README.md index 41bd7cbc3..c22bffd93 100644 --- a/libs/shared/providers/README.md +++ b/libs/shared/providers/README.md @@ -4,4 +4,4 @@ This library was generated with [Nx](https://nx.dev). ## Running unit tests -Run `nx test shared-providers` to execute the unit tests via [Jest](https://jestjs.io). +Run `nx test shared-providers` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/shared/providers/package.json b/libs/shared/providers/package.json new file mode 100644 index 000000000..1f65153a1 --- /dev/null +++ b/libs/shared/providers/package.json @@ -0,0 +1,12 @@ +{ + "name": "@origin/shared/providers", + "version": "0.0.1", + "main": "./index.js", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js" + } + } +} diff --git a/libs/shared/providers/project.json b/libs/shared/providers/project.json index 9b4551d2b..b5ecff67e 100644 --- a/libs/shared/providers/project.json +++ b/libs/shared/providers/project.json @@ -15,6 +15,24 @@ "libs/shared/providers/**/*.{ts,tsx,js,jsx}" ] } + }, + "build": { + "executor": "@nx/vite:build", + "outputs": [ + "{options.outputPath}" + ], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/libs/shared/providers" + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } } } } diff --git a/libs/shared/providers/tsconfig.json b/libs/shared/providers/tsconfig.json index 90fcf85c5..33b686fe4 100644 --- a/libs/shared/providers/tsconfig.json +++ b/libs/shared/providers/tsconfig.json @@ -4,7 +4,9 @@ "allowJs": false, "esModuleInterop": false, "allowSyntheticDefaultImports": true, - "strict": false + "types": [ + "vite/client" + ] }, "files": [], "include": [], diff --git a/libs/shared/providers/tsconfig.lib.json b/libs/shared/providers/tsconfig.lib.json index 56427f111..04eb567cf 100644 --- a/libs/shared/providers/tsconfig.lib.json +++ b/libs/shared/providers/tsconfig.lib.json @@ -2,13 +2,32 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../../dist/out-tsc", - "types": ["node"] + "types": [ + "node", + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts", + "vite/client" + ] }, "files": [ "../../../node_modules/@nx/react/typings/cssmodule.d.ts", "../../../node_modules/@nx/react/typings/image.d.ts", "../../../libs/shared/theme/src/theme.d.ts" ], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"], - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.ts", + "src/**/*.tsx" + ] } diff --git a/libs/shared/providers/vite.config.ts b/libs/shared/providers/vite.config.ts new file mode 100644 index 000000000..b9efcde15 --- /dev/null +++ b/libs/shared/providers/vite.config.ts @@ -0,0 +1,43 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import react from '@vitejs/plugin-react'; +import * as path from 'path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; + +export default defineConfig({ + cacheDir: '../../../node_modules/.vite/shared-providers', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + react(), + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'shared-providers', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}); diff --git a/libs/shared/theme/.eslintrc.json b/libs/shared/theme/.eslintrc.json index 75b85077d..a786f2cf3 100644 --- a/libs/shared/theme/.eslintrc.json +++ b/libs/shared/theme/.eslintrc.json @@ -1,17 +1,33 @@ { - "extends": ["plugin:@nx/react", "../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "extends": [ + "plugin:@nx/react", + "../../../.eslintrc.json" + ], + "ignorePatterns": [ + "!**/*" + ], "overrides": [ { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "files": [ + "*.ts", + "*.tsx", + "*.js", + "*.jsx" + ], "rules": {} }, { - "files": ["*.ts", "*.tsx"], + "files": [ + "*.ts", + "*.tsx" + ], "rules": {} }, { - "files": ["*.js", "*.jsx"], + "files": [ + "*.js", + "*.jsx" + ], "rules": {} } ] diff --git a/libs/shared/theme/README.md b/libs/shared/theme/README.md index ede11943e..68d6d5700 100644 --- a/libs/shared/theme/README.md +++ b/libs/shared/theme/README.md @@ -4,4 +4,4 @@ This library was generated with [Nx](https://nx.dev). ## Running unit tests -Run `nx test shared-theme` to execute the unit tests via [Jest](https://jestjs.io). +Run `nx test shared-theme` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/shared/theme/package.json b/libs/shared/theme/package.json new file mode 100644 index 000000000..8cdbeab7f --- /dev/null +++ b/libs/shared/theme/package.json @@ -0,0 +1,12 @@ +{ + "name": "@origin/shared/theme", + "version": "0.0.1", + "main": "./index.js", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js" + } + } +} diff --git a/libs/shared/theme/project.json b/libs/shared/theme/project.json index cdf7bda72..2f00efdc5 100644 --- a/libs/shared/theme/project.json +++ b/libs/shared/theme/project.json @@ -7,9 +7,31 @@ "targets": { "lint": { "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], + "outputs": [ + "{options.outputFile}" + ], "options": { - "lintFilePatterns": ["libs/shared/theme/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "libs/shared/theme/**/*.{ts,tsx,js,jsx}" + ] + } + }, + "build": { + "executor": "@nx/vite:build", + "outputs": [ + "{options.outputPath}" + ], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/libs/shared/theme" + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } } } } diff --git a/libs/shared/theme/tsconfig.json b/libs/shared/theme/tsconfig.json index 89f8ac085..33b686fe4 100644 --- a/libs/shared/theme/tsconfig.json +++ b/libs/shared/theme/tsconfig.json @@ -4,7 +4,9 @@ "allowJs": false, "esModuleInterop": false, "allowSyntheticDefaultImports": true, - "strict": true + "types": [ + "vite/client" + ] }, "files": [], "include": [], diff --git a/libs/shared/theme/tsconfig.lib.json b/libs/shared/theme/tsconfig.lib.json index 79e57218a..e86a631d1 100644 --- a/libs/shared/theme/tsconfig.lib.json +++ b/libs/shared/theme/tsconfig.lib.json @@ -2,7 +2,10 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../../dist/out-tsc", - "types": ["node"] + "types": [ + "node", + "vite/client" + ] }, "files": [ "../../../node_modules/@nx/react/typings/cssmodule.d.ts", @@ -10,15 +13,19 @@ "./src/theme.d.ts" ], "exclude": [ - "jest.config.ts", - "src/**/*.spec.ts", - "src/**/*.test.ts", - "src/**/*.spec.tsx", - "src/**/*.test.tsx", - "src/**/*.spec.js", - "src/**/*.test.js", - "src/**/*.spec.jsx", - "src/**/*.test.jsx" + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" ], - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.ts", + "src/**/*.tsx" + ] } diff --git a/libs/shared/theme/vite.config.ts b/libs/shared/theme/vite.config.ts new file mode 100644 index 000000000..35b25237b --- /dev/null +++ b/libs/shared/theme/vite.config.ts @@ -0,0 +1,42 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import react from '@vitejs/plugin-react'; +import * as path from 'path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; + +export default defineConfig({ + cacheDir: '../../../node_modules/.vite/shared-theme', + + plugins: [ + dts({ + entryRoot: 'src', + tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), + }), + react(), + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'shared-theme', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}); From a047b87711839b5e147341029523239696c70fa6 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 29 Sep 2023 08:49:00 -0700 Subject: [PATCH 17/20] add back codegen-graphql target --- libs/oeth/shared/project.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/oeth/shared/project.json b/libs/oeth/shared/project.json index 2e92f651a..8cbcef75e 100644 --- a/libs/oeth/shared/project.json +++ b/libs/oeth/shared/project.json @@ -5,6 +5,14 @@ "projectType": "library", "tags": [], "targets": { + "codegen-graphql": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "pnpm graphql-codegen --config 'libs/oeth/shared/codegen.ts'" + ] + } + }, "lint": { "executor": "@nx/linter:eslint", "outputs": [ From 55b4ead7a8465ef5686a9ae1ff60d5e133d64ae0 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 29 Sep 2023 08:51:39 -0700 Subject: [PATCH 18/20] remove `dayjs`, use `date-fns` --- libs/analytics/src/TimeLineChart.stories.tsx | 4 +-- libs/analytics/src/TimeLineChart.tsx | 20 ++++++----- .../src/FinancialStatement.tsx | 34 +++++++++---------- .../providers/src/chart/registerChart.ts | 2 ++ package.json | 2 -- pnpm-lock.yaml | 21 ------------ 6 files changed, 32 insertions(+), 51 deletions(-) diff --git a/libs/analytics/src/TimeLineChart.stories.tsx b/libs/analytics/src/TimeLineChart.stories.tsx index 42978764b..7bb596621 100644 --- a/libs/analytics/src/TimeLineChart.stories.tsx +++ b/libs/analytics/src/TimeLineChart.stories.tsx @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; import { Container } from '@mui/material'; -import dayjs from 'dayjs'; +import { addDays } from 'date-fns'; import { TimeLineChart } from './TimeLineChart'; @@ -40,7 +40,7 @@ const meta: Meta = { { type: 'line', data: array(180, { x: new Date('2023-01-01'), y: 0.05 }, (last) => ({ - x: dayjs(last.x).add(1, 'day').toDate(), + x: addDays(last.x, 1), y: faker.number.float({ min: last.y * 0.9, max: last.y * 1.1, diff --git a/libs/analytics/src/TimeLineChart.tsx b/libs/analytics/src/TimeLineChart.tsx index b2f6efef8..fdf84b8d5 100644 --- a/libs/analytics/src/TimeLineChart.tsx +++ b/libs/analytics/src/TimeLineChart.tsx @@ -1,10 +1,8 @@ -import 'chartjs-adapter-dayjs-4/dist/chartjs-adapter-dayjs-4.esm'; - import { useState } from 'react'; import { Box, MenuItem, Paper, Select, Stack, useTheme } from '@mui/material'; -import { Chart, TimeScale } from 'chart.js'; -import dayjs from 'dayjs'; +import { registerChart } from '@origin/shared/providers'; +import { intlFormat } from 'date-fns'; import { mergeDeepRight } from 'ramda'; import { Line } from 'react-chartjs-2'; @@ -12,7 +10,7 @@ import type { Theme } from '@origin/shared/theme'; import type { ChartData, ChartOptions, Plugin } from 'chart.js'; import type { ComponentProps } from 'react'; -Chart.register(TimeScale); +registerChart(); /** * TODO: Figure out a proper home for these? @@ -91,7 +89,7 @@ export function TimeLineChart(props: { ) : null} - {dayjs(currentData[0].x).format('ll')} + {intlFormat(currentData[0].x)} @@ -327,13 +325,19 @@ const verticalLinePlugin = (theme: Theme) => { ctx.stroke(); ctx.font = '0.875rem Inter'; ctx.fillStyle = theme.palette.text.primary; - const text = dayjs(data.x).format('lll'); + const text = intlFormat(data.x); const textSize = ctx.measureText(text); const fromLeft = x + textSize.actualBoundingBoxRight <= chart.chartArea.right; ctx.textAlign = fromLeft ? 'start' : 'end'; ctx.fillText( - dayjs(data.x).format('lll'), + intlFormat(data.x, { + year: 'numeric', + month: 'numeric', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + }), x + (fromLeft ? heightAboveChart : -heightAboveChart) / 2, chart.chartArea.top - heightAboveChart + diff --git a/libs/financial-statement/src/FinancialStatement.tsx b/libs/financial-statement/src/FinancialStatement.tsx index 48bd51606..54d6c06c7 100644 --- a/libs/financial-statement/src/FinancialStatement.tsx +++ b/libs/financial-statement/src/FinancialStatement.tsx @@ -4,7 +4,7 @@ import { alpha, Box, Button, - Experimental_CssVarsProvider, + Experimental_CssVarsProvider as CssVarsProvider, Paper, Stack, Typography, @@ -15,18 +15,19 @@ import { queryClient } from '@origin/oeth/shared'; import { useChainlinkEthUsd } from '@origin/shared/providers'; import { theme } from '@origin/shared/theme'; import { QueryClientProvider } from '@tanstack/react-query'; -import dayjs from 'dayjs'; -import LocalizedFormat from 'dayjs/plugin/localizedFormat'; -import RelativeTime from 'dayjs/plugin/relativeTime'; +import { + endOfToday, + formatRelative, + intlFormat, + startOfDay, + subDays, +} from 'date-fns'; import { IntlProvider, useIntl } from 'react-intl'; import { formatEther } from 'viem'; import * as colors from './colors'; import { useFinancialStatementQuery } from './FinancialStatement.generated'; -dayjs.extend(LocalizedFormat); -dayjs.extend(RelativeTime); - const calculateChange = (from: number, to: number) => { if (from === 0 && to === 0) return 0; const change = -(1 - to / from); @@ -51,18 +52,19 @@ const getTotals = (data: Record>) => { export default function SelfContainedFinancialStatement() { return ( - + - + ); } export const LiveFinancialStatement = () => { - const endOfToday = dayjs().endOf('day').toISOString(); - const [sevenDaysAgo] = useState(dayjs().subtract(7, 'days').toISOString()); + const todayEnd = endOfToday(); + const sevenDaysAgo = startOfDay(subDays(todayEnd, 7)); + const { isLoading: fsIsLoading, data: fs } = useFinancialStatementQuery({ compareDate: endOfToday, }); @@ -101,7 +103,7 @@ export const LiveFinancialStatement = () => { blockNumber, timestamp, }} - columns={[dayjs(sevenDaysAgo).fromNow(), dayjs(endOfToday).format('ll')]} + columns={[formatRelative(sevenDaysAgo, new Date()), intlFormat(todayEnd)]} data={{ assets: { Vault: { @@ -270,12 +272,8 @@ export const FinancialStatement = (props: { color={(theme) => theme.palette.primary.contrastText} > - {`Last updated ${dayjs(props.lastUpdated.timestamp).format( - 'll', - )} at `} - {`${dayjs(props.lastUpdated.timestamp).format('LT')}, block #${ - props.lastUpdated.blockNumber - }`} + {`Last updated ${intlFormat(props.lastUpdated.timestamp)}, `} + {`block #${props.lastUpdated.blockNumber}`} {props.ethPrice && diff --git a/libs/shared/providers/src/chart/registerChart.ts b/libs/shared/providers/src/chart/registerChart.ts index 4f21a6436..0b89bb252 100644 --- a/libs/shared/providers/src/chart/registerChart.ts +++ b/libs/shared/providers/src/chart/registerChart.ts @@ -7,6 +7,7 @@ import { LineElement, PointElement, registerables, + TimeScale, } from 'chart.js'; export function registerChart() { @@ -14,6 +15,7 @@ export function registerChart() { ...registerables, CategoryScale, LinearScale, + TimeScale, LineElement, PointElement, ); diff --git a/package.json b/package.json index 1cf7109c0..5bfd3eb8a 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,6 @@ "@wagmi/core": "^1.4.1", "axios": "^1.5.0", "chart.js": "^4.4.0", - "chartjs-adapter-dayjs-4": "^1.0.4", - "dayjs": "^1.11.10", "chartjs-adapter-date-fns": "^3.0.0", "date-fns": "^2.30.0", "graphql": "^16.8.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dc3234ed0..54e8e07a5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,12 +35,6 @@ dependencies: chart.js: specifier: ^4.4.0 version: 4.4.0 - chartjs-adapter-dayjs-4: - specifier: ^1.0.4 - version: 1.0.4(chart.js@4.4.0)(dayjs@1.11.10) - dayjs: - specifier: ^1.11.10 - version: 1.11.10 chartjs-adapter-date-fns: specifier: ^3.0.0 version: 3.0.0(chart.js@4.4.0)(date-fns@2.30.0) @@ -8891,17 +8885,6 @@ packages: '@kurkle/color': 0.3.2 dev: false - /chartjs-adapter-dayjs-4@1.0.4(chart.js@4.4.0)(dayjs@1.11.10): - resolution: {integrity: sha512-yy9BAYW4aNzPVrCWZetbILegTRb7HokhgospPoC3b5iZ5qdlqNmXts2KdSp6AqnjkPAp/YWyHDxLvIvwt5x81w==} - engines: {node: '>=10'} - peerDependencies: - chart.js: '>=4.0.1' - dayjs: ^1.9.7 - dependencies: - chart.js: 4.4.0 - dayjs: 1.11.10 - dev: false - /chartjs-adapter-date-fns@3.0.0(chart.js@4.4.0)(date-fns@2.30.0): resolution: {integrity: sha512-Rs3iEB3Q5pJ973J93OBTpnP7qoGwvq3nUnoMdtxO+9aoJof7UFcRbWcIDteXuYd1fgAvct/32T9qaLyLuZVwCg==} peerDependencies: @@ -9343,10 +9326,6 @@ packages: '@babel/runtime': 7.22.15 dev: false - /dayjs@1.11.10: - resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} - dev: false - /de-indent@1.0.2: resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==} dev: true From de71b12ef51267e8cc4acbebf6263ffc07c49aeb Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Fri, 29 Sep 2023 08:57:58 -0700 Subject: [PATCH 19/20] remove `dayjs`, use `date-fns` --- .../financial-statement/src/FinancialStatement.stories.tsx | 2 +- libs/financial-statement/src/FinancialStatement.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/financial-statement/src/FinancialStatement.stories.tsx b/libs/financial-statement/src/FinancialStatement.stories.tsx index 77ab1a5c4..73f0fd27c 100644 --- a/libs/financial-statement/src/FinancialStatement.stories.tsx +++ b/libs/financial-statement/src/FinancialStatement.stories.tsx @@ -34,7 +34,7 @@ const meta: Meta = { blockNumber: 18036316, timestamp: Date.parse('2023-09-03T21:42:03Z'), }, - columns: ['31 August 2023', '1 week ago'], + columns: ['1 week ago', '31 August 2023'], data: { assets: { Vault: { diff --git a/libs/financial-statement/src/FinancialStatement.tsx b/libs/financial-statement/src/FinancialStatement.tsx index 54d6c06c7..efae3d4ec 100644 --- a/libs/financial-statement/src/FinancialStatement.tsx +++ b/libs/financial-statement/src/FinancialStatement.tsx @@ -17,8 +17,8 @@ import { theme } from '@origin/shared/theme'; import { QueryClientProvider } from '@tanstack/react-query'; import { endOfToday, - formatRelative, intlFormat, + intlFormatDistance, startOfDay, subDays, } from 'date-fns'; @@ -103,7 +103,10 @@ export const LiveFinancialStatement = () => { blockNumber, timestamp, }} - columns={[formatRelative(sevenDaysAgo, new Date()), intlFormat(todayEnd)]} + columns={[ + intlFormatDistance(sevenDaysAgo, new Date()), + intlFormat(todayEnd), + ]} data={{ assets: { Vault: { From edc59295717eebe5170240342ba4b256f171e396 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Fri, 29 Sep 2023 19:51:54 +0200 Subject: [PATCH 20/20] fix: use Enum instead of casting --- libs/oeth/history/src/components/HistoryFilters.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/oeth/history/src/components/HistoryFilters.tsx b/libs/oeth/history/src/components/HistoryFilters.tsx index 4f7033104..b55763624 100644 --- a/libs/oeth/history/src/components/HistoryFilters.tsx +++ b/libs/oeth/history/src/components/HistoryFilters.tsx @@ -11,13 +11,12 @@ import { Typography, useTheme, } from '@mui/material'; +import { HistoryType } from '@origin/oeth/shared'; import { isNilOrEmpty } from '@origin/shared/utils'; import { defineMessage, useIntl } from 'react-intl'; import { HistoryFilterButton } from './HistoryButton'; -import type { HistoryType } from '@origin/oeth/shared'; - const styles = { fontSize: 12, fontWeight: 500, @@ -27,19 +26,19 @@ const styles = { const filterOptions = [ { label: defineMessage({ defaultMessage: 'Yield' }), - value: 'Yield' as HistoryType, + value: HistoryType.Yield, }, { label: defineMessage({ defaultMessage: 'Swap' }), - value: 'Swap' as HistoryType, + value: HistoryType.Swap, }, { label: defineMessage({ defaultMessage: 'Sent' }), - value: 'Sent' as HistoryType, + value: HistoryType.Sent, }, { label: defineMessage({ defaultMessage: 'Received' }), - value: 'Received' as HistoryType, + value: HistoryType.Received, }, ];