Skip to content

Commit

Permalink
fix to germinating bdv
Browse files Browse the repository at this point in the history
  • Loading branch information
soilking committed Apr 23, 2024
1 parent 05025b5 commit 84618fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions projects/subgraph-beanstalk/src/YieldHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function updateSiloVAPYs(t: i32, timestamp: BigInt, window: i32): void {

let germinatingBeanBdv: BigDecimal[] = [];
let germinatingGaugeLpBdv: BigDecimal[][] = [];
let germinatingNonGaugeBdv: BigDecimal[] = [];
let germinatingNonGaugeBdv: BigDecimal[] = [ZERO_BD, ZERO_BD];

let staticSeeds: Array<BigDecimal | null> = [];

Expand Down Expand Up @@ -292,7 +292,7 @@ export function calculateAPYPreGauge(
*
* @param season The current season, required for germinating.
* @param germinatingBeanBdv Germinating beans bdv
* @param gaugeLpGerminatingBdv Germinating bdv of each gauge lp
* @param gaugeLpGerminatingBdv Germinating bdv of each gauge lp. Each outer array entry corresponds to one lp
* @param nonGaugeGerminatingBdv Germinating bdv of all non-gauge whitelisted assets
*
* UNRIPE
Expand Down Expand Up @@ -365,7 +365,7 @@ export function calculateGaugeVAPYs(
const index = season.mod(BigInt.fromString("2")) == ZERO_BI ? 1 : 0;
beanBdv = beanBdv.plus(germinatingBeanBdv[index]);
for (let j = 0; j < gaugeLpDepositedBdvCopy.length; ++j) {
gaugeLpDepositedBdvCopy[j] = gaugeLpDepositedBdvCopy[j].plus(gaugeLpGerminatingBdv[index][j]);
gaugeLpDepositedBdvCopy[j] = gaugeLpDepositedBdvCopy[j].plus(gaugeLpGerminatingBdv[j][index]);
}
gaugeBdv = beanBdv.plus(BigDecimal_sum(gaugeLpDepositedBdvCopy));
nonGaugeDepositedBdv.plus(nonGaugeGerminatingBdv[index]);
Expand Down
6 changes: 4 additions & 2 deletions projects/subgraph-beanstalk/tests/YieldHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe("APY Calculations", () => {

describe("With Seed Gauge", () => {
test("Token yields - direct calculation", () => {
// return;
// Calculated in a single call - 5000 ms
const apy = YieldHandler.calculateGaugeVAPYs(
[-1, 0, -2],
Expand All @@ -66,7 +67,7 @@ describe("APY Calculations", () => {
BigDecimal.fromString("4320"),
ZERO_BI,
[ZERO_BD, ZERO_BD],
[[ZERO_BD], [ZERO_BD]],
[[ZERO_BD, ZERO_BD]],
[ZERO_BD, ZERO_BD],
[null, null, ZERO_BD]
);
Expand Down Expand Up @@ -138,10 +139,11 @@ describe("APY Calculations", () => {
beanWhitelistSettings.save();

let beanEthWhitelistSettings = loadWhitelistTokenSetting(BEAN_WETH_CP2_WELL);
beanEthWhitelistSettings.gaugePoints = BigInt.fromString("100000000000000000000");
beanEthWhitelistSettings.gpSelector = Bytes.fromHexString("0x12345678");
beanEthWhitelistSettings.lwSelector = Bytes.fromHexString("0x12345678");
beanEthWhitelistSettings.optimalPercentDepositedBdv = BigInt.fromString("100000000");
beanWhitelistSettings.save();
beanEthWhitelistSettings.save();

let urbeanWhitelistSettings = loadWhitelistTokenSetting(UNRIPE_BEAN);
urbeanWhitelistSettings.stalkEarnedPerSeason = ZERO_BI;
Expand Down

0 comments on commit 84618fc

Please sign in to comment.