-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../components/Analytics/Bean/DeltaB.graphql → ...ents/Analytics/Bean/DeltaBInstant.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
projects/ui/src/components/Analytics/Bean/DeltaBWeighted.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
query SeasonalWeightedDeltaB($season_lte: Int, $first: Int, $season_gte: Int) { | ||
seasons: seasons( | ||
where: { season_lte: $season_lte, season_gte: $season_gte } | ||
first: $first | ||
orderBy: season | ||
orderDirection: desc | ||
) { | ||
id | ||
season | ||
createdAt | ||
deltaB | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
projects/ui/src/components/Analytics/Bean/DeltaBWeighted.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { tickFormatLocale } from '~/components/Analytics/formatters'; | ||
import { LineChartProps } from '~/components/Common/Charts/LineChart'; | ||
import SeasonPlot, { | ||
SeasonPlotBaseProps, | ||
} from '~/components/Common/Charts/SeasonPlot'; | ||
import { BEAN } from '~/constants/tokens'; | ||
import { | ||
SeasonalWeightedDeltaBDocument, | ||
SeasonalWeightedDeltaBQuery, | ||
} from '~/generated/graphql'; | ||
import { SnapshotData } from '~/hooks/beanstalk/useSeasonsQuery'; | ||
import { toTokenUnitsBN } from '~/util'; | ||
|
||
import { FC } from '~/types'; | ||
|
||
const getValue = (season: SnapshotData<SeasonalWeightedDeltaBQuery>) => | ||
toTokenUnitsBN(season.deltaB, BEAN[1].decimals).toNumber(); | ||
const formatValue = (value: number) => | ||
`${value.toLocaleString('en-us', { maximumFractionDigits: 2 })}`; | ||
const statProps = { | ||
title: 'deltaB', | ||
titleTooltip: | ||
'The liquidity and time weighted average shortage of Beans in liquidity pools on the Minting Whitelist at the beginning of every Season.', | ||
gap: 0.25, | ||
}; | ||
|
||
const queryConfig = { | ||
variables: { season_gte: 6074 }, | ||
context: { subgraph: 'beanstalk' }, | ||
}; | ||
|
||
const lineChartProps: Partial<LineChartProps> = { | ||
yTickFormat: tickFormatLocale, | ||
horizontalLineNumber: 0, | ||
}; | ||
|
||
const DeltaBWeighted: FC<{ height?: SeasonPlotBaseProps['height'] }> = ({ | ||
height, | ||
}) => ( | ||
<SeasonPlot<SeasonalWeightedDeltaBQuery> | ||
document={SeasonalWeightedDeltaBDocument} | ||
height={height} | ||
getValue={getValue} | ||
formatValue={formatValue} | ||
queryConfig={queryConfig} | ||
StatProps={statProps} | ||
LineChartProps={lineChartProps} | ||
/> | ||
); | ||
|
||
export default DeltaBWeighted; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters