Skip to content

Commit

Permalink
refactor to BIP45
Browse files Browse the repository at this point in the history
  • Loading branch information
soilking committed May 22, 2024
1 parent a6d6bb8 commit 06a4b11
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions projects/subgraph-bean/src/utils/LockedBeans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { loadOrCreatePool } from "./Pool";
import { loadOrCreateTwaOracle } from "./price/TwaOracle";

export function calcLockedBeans(blockNumber: BigInt): BigInt {
// If BIP44 is deployed - return the result from the contract
// If BIP45 is deployed - return the result from the contract
// Future improvement when actual deployment block is known, can check block and avoid this call in earlier blocks.
if (blockNumber > BigInt.fromU32(19764699)) {
if (blockNumber > BigInt.fromU32(19922925)) {
// If we are trying to calculate locked beans on the same block as the sunrise, use the values from the previous hour
const twaOracle = loadOrCreateTwaOracle(getUnderlyingUnripe(blockNumber).toHexString());
const twaReserves =
Expand Down
10 changes: 5 additions & 5 deletions projects/subgraph-bean/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dataSources:
- name: Beanstalk
file: ../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
- name: SeedGauge
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP44.json
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
Expand All @@ -45,7 +45,7 @@ dataSources:
- name: Beanstalk
file: ../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
- name: SeedGauge
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP44.json
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
Expand Down Expand Up @@ -75,7 +75,7 @@ dataSources:
- name: Beanstalk
file: ../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
- name: SeedGauge
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP44.json
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json
eventHandlers:
- event: TokenExchange(indexed address,int128,uint256,int128,uint256)
handler: handleTokenExchange
Expand Down Expand Up @@ -107,7 +107,7 @@ dataSources:
- name: Beanstalk
file: ../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
- name: SeedGauge
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP44.json
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json
- name: PreReplant
file: ../subgraph-core/abis/Beanstalk/Beanstalk-Pre-Replant.json
- name: BeanstalkPrice
Expand Down Expand Up @@ -260,7 +260,7 @@ dataSources:
- name: Beanstalk
file: ../subgraph-core/abis/Beanstalk/Beanstalk-Replanted.json
- name: SeedGauge
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP44.json
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json
eventHandlers:
- event: AddLiquidity(uint256[],uint256,address)
handler: handleAddLiquidity
Expand Down
4 changes: 2 additions & 2 deletions projects/subgraph-beanstalk/src/GaugeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
WhitelistToken,
TotalGerminatingStalkChanged,
TotalStalkChangedFromGermination
} from "../generated/BIP44-SeedGauge/Beanstalk";
} from "../generated/BIP45-SeedGauge/Beanstalk";
import { handleRateChange } from "./utils/Field";
import {
loadSilo,
Expand Down Expand Up @@ -165,7 +165,7 @@ export function handleTotalStalkChangedFromGermination(event: TotalStalkChangedF

// WHITELIST / GAUGE CONFIGURATION SETTINGS //

export function handleWhitelistToken_BIP44(event: WhitelistToken): void {
export function handleWhitelistToken_BIP45(event: WhitelistToken): void {
let siloSettings = loadWhitelistTokenSetting(event.params.token);

siloSettings.selector = event.params.selector;
Expand Down
6 changes: 3 additions & 3 deletions projects/subgraph-beanstalk/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ dataSources:
handler: handlePodOrderFilled_v2
file: ./src/MarketplaceHandler.ts
- kind: ethereum/contract
name: BIP44-SeedGauge
name: BIP45-SeedGauge
network: mainnet
source:
address: "0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5"
Expand All @@ -751,7 +751,7 @@ dataSources:
- SeedGauge
abis:
- name: Beanstalk
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP44.json
file: ../subgraph-core/abis/Beanstalk/Beanstalk-BIP45.json
- name: BeanstalkPrice
file: ../subgraph-core/abis/BeanstalkPrice.json
eventHandlers:
Expand All @@ -772,7 +772,7 @@ dataSources:
- event: TotalStalkChangedFromGermination(int256,int256)
handler: handleTotalStalkChangedFromGermination
- event: WhitelistToken(indexed address,bytes4,uint32,uint256,bytes4,bytes4,uint128,uint64)
handler: handleWhitelistToken_BIP44
handler: handleWhitelistToken_BIP45
- event: UpdateGaugeSettings(indexed address,bytes4,bytes4,uint64)
handler: handleUpdateGaugeSettings
file: ./src/GaugeHandler.ts
4 changes: 2 additions & 2 deletions projects/subgraph-beanstalk/tests/SeedGauge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
handleUpdateAverageStalkPerBdvPerSeason,
handleFarmerGerminatingStalkBalanceChanged,
handleTotalGerminatingBalanceChanged,
handleWhitelistToken_BIP44,
handleWhitelistToken_BIP45,
handleUpdateGaugeSettings,
handleTotalGerminatingStalkChanged,
handleTotalStalkChangedFromGermination
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("Seed Gauge", () => {

describe("Owner Configuration", () => {
test("event: WhitelistToken", () => {
handleWhitelistToken_BIP44(
handleWhitelistToken_BIP45(
createWhitelistTokenV4Event(
BEAN_ERC20.toHexString(),
"0x12345678",
Expand Down
4 changes: 2 additions & 2 deletions projects/subgraph-beanstalk/tests/event-mocking/Field.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address, BigInt, Bytes, ethereum } from "@graphprotocol/graph-ts";
import { newMockEvent } from "matchstick-as/assembly/index";
import { Sow, PlotTransfer } from "../../generated/Field/Beanstalk";
import { TemperatureChange } from "../../generated/BIP44-SeedGauge/Beanstalk";
import { TemperatureChange } from "../../generated/BIP45-SeedGauge/Beanstalk";

import { BEANSTALK } from "../../../subgraph-core/utils/Constants";

Expand All @@ -14,7 +14,7 @@ const mockBeanstalkEvent = (): ethereum.Event => {

export function createWeatherChangeEvent(season: BigInt, caseID: BigInt, change: i32): void {}

// BIP44 renamed
// BIP45 renamed
export function createTemperatureChangeEvent(season: BigInt, caseId: BigInt, absChange: i32): TemperatureChange {
let event = changetype<TemperatureChange>(mockBeanstalkEvent());
event.parameters = new Array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
UpdateGaugeSettings,
TotalGerminatingStalkChanged,
TotalStalkChangedFromGermination
} from "../../generated/BIP44-SeedGauge/Beanstalk";
} from "../../generated/BIP45-SeedGauge/Beanstalk";

import { BEANSTALK } from "../../../subgraph-core/utils/Constants";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { newMockEvent } from "matchstick-as/assembly/index";
import { BEANSTALK } from "../../../subgraph-core/utils/Constants";
import { WhitelistToken as WhitelistToken_V2, DewhitelistToken } from "../../generated/Silo-Replanted/Beanstalk";
import { WhitelistToken as WhitelistToken_V3 } from "../../generated/Silo-V3/Beanstalk";
import { WhitelistToken as WhitelistToken_V4 } from "../../generated/BIP44-SeedGauge/Beanstalk";
import { WhitelistToken as WhitelistToken_V4 } from "../../generated/BIP45-SeedGauge/Beanstalk";

// Default mock to include beanstalk address
const mockBeanstalkEvent = (): ethereum.Event => {
Expand Down

0 comments on commit 06a4b11

Please sign in to comment.