Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include v1 BEAN3CRV and BEANLUSD in liquidity to supply calc #701

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions projects/subgraph-bean/src/utils/Bean.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { BigDecimal, BigInt } from "@graphprotocol/graph-ts";
import { Bean, BeanDailySnapshot, BeanHourlySnapshot, Pool } from "../../generated/schema";
import { BEAN_3CRV, BEAN_ERC20_V1, BEAN_ERC20, BEAN_WETH_V1, BEAN_WETH_CP2_WELL } from "../../../subgraph-core/utils/Constants";
import {
BEAN_3CRV,
BEAN_ERC20_V1,
BEAN_ERC20,
BEAN_WETH_V1,
BEAN_WETH_CP2_WELL,
BEAN_3CRV_V1,
BEAN_LUSD_V1
} from "../../../subgraph-core/utils/Constants";
import { dayFromTimestamp, hourFromTimestamp } from "../../../subgraph-core/utils/Dates";
import { toDecimal, ZERO_BD, ZERO_BI } from "../../../subgraph-core/utils/Decimals";
import { getV1Crosses } from "./Cross";
Expand Down Expand Up @@ -150,10 +158,19 @@ export function getBeanTokenAddress(blockNumber: BigInt): string {

export function updateBeanSupplyPegPercent(blockNumber: BigInt): void {
if (blockNumber < BigInt.fromString("15278082")) {
let pool = loadOrCreatePool(BEAN_WETH_V1.toHexString(), blockNumber);
let bean = loadBean(BEAN_ERC20_V1.toHexString());

bean.supplyInPegLP = toDecimal(pool.reserves[1]).div(toDecimal(bean.supply));
let pool = loadOrCreatePool(BEAN_WETH_V1.toHexString(), blockNumber);

let lpSupply = toDecimal(pool.reserves[1]);

pool = loadOrCreatePool(BEAN_3CRV_V1.toHexString(), blockNumber);
lpSupply = lpSupply.plus(toDecimal(pool.reserves[0]));

pool = loadOrCreatePool(BEAN_LUSD_V1.toHexString(), blockNumber);
lpSupply = lpSupply.plus(toDecimal(pool.reserves[0]));

bean.supplyInPegLP = lpSupply.div(toDecimal(bean.supply));
bean.save();
} else {
let pegSupply = ZERO_BI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const formatValue = (value: number) =>
const statProps = {
title: 'Liquidity to Supply Ratio',
titleTooltip:
`The ratio of Beans in liquidity pools on the Oracle Whitelist per Bean, displayed as a percentage, at the beginning of every Season. The Liquidity to Supply Ratio is a useful indicator of Beanstalk's health.`,
`The ratio of Beans in liquidity pools on the Oracle Whitelist per Bean, displayed as a percentage, at the beginning of every Season. The Liquidity to Supply Ratio is a useful indicator of Beanstalk's health. Pre-exploit values include liquidity in pools on the Deposit Whitelist.`,
gap: 0.25,
};
const queryConfig = {
Expand Down