Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Deployed at:
- [Arbitrum](https://thegraph.com/explorer/subgraphs/8Zxb1kVv9ZBChHXEPSgtC5u5gjCijMn5k8ErpzRYWNgH?view=Overview&chain=arbitrum-one)
- [Fantom](https://thegraph.com/explorer/subgraphs/3qSJTWdWJETFzht814HVV9rVafwRLQp3k9mZhCF39bYd?v=1&view=Query&chain=arbitrum-one)
- [Base](https://thegraph.com/explorer/subgraphs/3YAC1Gj2AUFCQ8wd4DaBQmqU3DJZjKyr45dQykAtXuMU?view=Overview&chain=arbitrum-one)
- [Berachain](https://thegraph.com/explorer/subgraphs/5KjntDTvo4DumbAkXdkrzNBdta2NujCc73TRYwgTdVun?view=Query&chain=arbitrum-one)

## Initial Setup

Expand Down
26 changes: 1 addition & 25 deletions bin/subgraph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,30 +254,6 @@ program
);
});

program
.command("deploy:hosted")
.description("Deploy subgraph to the Hosted Service")
.argument("<subgraph>", `the subgraph to use, one of: ${subgraphNames.join(", ")}`, parseSubgraph)
.action((subgraph: string) => {
const config = readConfig(getSubgraphConfigurationFilePath(subgraph));
assertConfig(config);

const subgraphSafe = subgraph.replace("-", "_");

console.info("*** Deploying to Hosted Service");
spawnProcess(
`yarn graph deploy --deploy-key ${process.env[`GRAPH_TOKEN_${subgraphSafe}`]
} --product hosted-service --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ --output-dir ${getBuildOutputDirectory(
subgraph,
)} ${config.org}/${config.name} ${getSubgraphManifestFilePath(subgraph)}`,
(codegenExitCode: number) => {
if (codegenExitCode > 0) {
process.exit(codegenExitCode);
}
},
);
});

program
.command("deploy:studio")
.description("Deploy subgraph to Subgraph Studio")
Expand All @@ -289,7 +265,7 @@ program
console.info("*** Deploying to Subgraph Studio");
spawnProcess(
`yarn graph deploy --deploy-key ${process.env[`GRAPH_STUDIO_TOKEN`]
} --product subgraph-studio --version-label ${config.version
} --version-label ${config.version
} --output-dir ${getBuildOutputDirectory(subgraph)} ${config.name
} ${getSubgraphManifestFilePath(subgraph)}`,
(codegenExitCode: number) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@apollo/client": "^3.8.4",
"@graphprotocol/graph-cli": "^0.79.0",
"@graphprotocol/graph-cli": "^0.96.0",
"@graphprotocol/graph-ts": "^0.35.0",
"assemblyscript-json": "^1.1.0",
"commander": "^9.4.0",
Expand Down
4 changes: 4 additions & 0 deletions subgraphs/berachain/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Berachain Subgraph Changelog

## 1.2.8 (2025-03-25)

- Adds support for Infrared Kodiak OHM-HONEY Reward Vault

## 1.1.4 (2025-02-20)

- Adds support for Beradrome Kodiak OHM-HONEY Reward Vault v2
Expand Down
4 changes: 2 additions & 2 deletions subgraphs/berachain/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "QmWkca2atv4YwqUaEJcowWSmAXsvxNieKqXNwtFoVGdX7A",
"id": "QmUS1PXuvVUrnTiAYSJBmyHojMxteiCRPd1DfamJsTxye8",
"org": "olympusdao",
"name": "protocol-metrics-berachain",
"version": "1.1.4"
"version": "1.2.8"
}
31 changes: 21 additions & 10 deletions subgraphs/berachain/src/contracts/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { TokenCategoryPOL, TokenCategoryStable, TokenCategoryVolatile, TokenDefi
export const BLOCKCHAIN = "Berachain";

// Tokens
export const ERC20_BGT = "0x656b95E550C07a9ffe548bd4085c72418Ceb1dba".toLowerCase();
export const ERC20_OHM = "0x18878Df23e2a36f81e820e4b47b4A40576D3159C".toLowerCase();
export const ERC20_IBERA = "0x9b6761bf2397Bb5a6624a856cC84A3A14Dcd3fe5".toLowerCase();
export const ERC20_IBGT = "0xac03CABA51e17c86c921E1f6CBFBdC91F8BB2E6b".toLowerCase();
export const ERC20_STARGATE_USDC = "0x549943e04f40284185054145c6E4e9568C1D3241".toLowerCase();
export const ERC20_HONEY = "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce".toLowerCase();
export const ERC20_WBERA = "0x6969696969696969696969696969696969696969".toLowerCase();
Expand All @@ -17,16 +19,7 @@ export const LP_UNISWAP_V3_WBERA_HONEY = "0x1127f801cb3ab7bdf8923272949aa7dba94b
export const LP_KODIAK_OHM_HONEY = "0x98bDEEde9A45C28d229285d9d6e9139e9F505391".toLowerCase();
export const LP_BERADROME_KODIAK_OHM_HONEY = "0x555BAd9EC18dB19dED0057D2517242399d1c5D87".toLowerCase();
export const LP_KODIAK_IBERA_WBERA = "0x8dD1C3e5fB96ca0E45Fe3c3CC521Ad44e12F3e47".toLowerCase();

// Token definitions
export const ERC20_TOKENS_BERACHAIN = new Map<string, TokenDefinition>();
ERC20_TOKENS_BERACHAIN.set(ERC20_IBERA, new TokenDefinition(ERC20_IBERA, TokenCategoryVolatile, false, false)); // Illiquid
ERC20_TOKENS_BERACHAIN.set(ERC20_STARGATE_USDC, new TokenDefinition(ERC20_STARGATE_USDC, TokenCategoryStable, true, false));
ERC20_TOKENS_BERACHAIN.set(ERC20_HONEY, new TokenDefinition(ERC20_HONEY, TokenCategoryStable, true, false));
ERC20_TOKENS_BERACHAIN.set(ERC20_WBERA, new TokenDefinition(ERC20_WBERA, TokenCategoryVolatile, true, true));
ERC20_TOKENS_BERACHAIN.set(NATIVE_BERA, new TokenDefinition(NATIVE_BERA, TokenCategoryVolatile, true, true));
ERC20_TOKENS_BERACHAIN.set(LP_KODIAK_OHM_HONEY, new TokenDefinition(LP_KODIAK_OHM_HONEY, TokenCategoryPOL, true, false));
ERC20_TOKENS_BERACHAIN.set(LP_BERADROME_KODIAK_OHM_HONEY, new TokenDefinition(LP_BERADROME_KODIAK_OHM_HONEY, TokenCategoryPOL, true, false));
export const LP_KODIAK_IBGT_WBERA = "0x12bf773F18cEC56F14e7cb91d82984eF5A3148EE".toLowerCase();

export const OHM_TOKENS = [ERC20_OHM];

Expand All @@ -40,6 +33,19 @@ export const INFRARED_CUSTODIAN = "0xb65e74f6b2c0633e30ba1be75db818bb9522a81a".t
export const UNISWAP_V3_POSITION_MANAGER = "0xFE5E8C83FFE4d9627A75EaA7Fee864768dB989bD".toLowerCase();
export const BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V1 = "0x017B4DD27782E2FE3421e71F33ce54801aF696F8".toLowerCase();
export const BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V2 = "0x8e5b2DF607B43C8D0F28035210D4e1aD1E72b8ed".toLowerCase();
export const INFRARED_KODIAK_OHM_HONEY_VAULT = "0xa57Cb177Beebc35A1A26A286951a306d9B752524".toLowerCase();

// Token definitions
export const ERC20_TOKENS_BERACHAIN = new Map<string, TokenDefinition>();
ERC20_TOKENS_BERACHAIN.set(ERC20_IBERA, new TokenDefinition(ERC20_IBERA, TokenCategoryVolatile, false, false)); // Illiquid
ERC20_TOKENS_BERACHAIN.set(ERC20_IBGT, new TokenDefinition(ERC20_IBGT, TokenCategoryVolatile, false, false)); // Illiquid
ERC20_TOKENS_BERACHAIN.set(ERC20_STARGATE_USDC, new TokenDefinition(ERC20_STARGATE_USDC, TokenCategoryStable, true, false));
ERC20_TOKENS_BERACHAIN.set(ERC20_HONEY, new TokenDefinition(ERC20_HONEY, TokenCategoryStable, true, false));
ERC20_TOKENS_BERACHAIN.set(ERC20_WBERA, new TokenDefinition(ERC20_WBERA, TokenCategoryVolatile, true, true));
ERC20_TOKENS_BERACHAIN.set(NATIVE_BERA, new TokenDefinition(NATIVE_BERA, TokenCategoryVolatile, true, true));
ERC20_TOKENS_BERACHAIN.set(LP_KODIAK_OHM_HONEY, new TokenDefinition(LP_KODIAK_OHM_HONEY, TokenCategoryPOL, true, false));
ERC20_TOKENS_BERACHAIN.set(LP_BERADROME_KODIAK_OHM_HONEY, new TokenDefinition(LP_BERADROME_KODIAK_OHM_HONEY, TokenCategoryPOL, true, false));
ERC20_TOKENS_BERACHAIN.set(INFRARED_KODIAK_OHM_HONEY_VAULT, new TokenDefinition(INFRARED_KODIAK_OHM_HONEY_VAULT, TokenCategoryPOL, true, false));

export const PROTOCOL_ADDRESSES = [
DAO_MULTISIG,
Expand Down Expand Up @@ -92,14 +98,17 @@ export const getWalletAddressesForContract = (contractAddress: string): string[]
export const CONTRACT_NAME_MAP = new Map<string, string>();
CONTRACT_NAME_MAP.set(BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V1, "Beradrome Kodiak OHM-HONEY Reward Vault V1");
CONTRACT_NAME_MAP.set(BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V2, "Beradrome Kodiak OHM-HONEY Reward Vault V2");
CONTRACT_NAME_MAP.set(ERC20_BGT, "Bera Governance Token");
CONTRACT_NAME_MAP.set(DAO_MULTISIG, "DAO MS (Berachain)");
CONTRACT_NAME_MAP.set(DAO_OPS_MULTISIG, "DAO Operations MS (Berachain)");
CONTRACT_NAME_MAP.set(ERC20_HONEY, "Honey");
CONTRACT_NAME_MAP.set(ERC20_IBERA, "Infrared BERA");
CONTRACT_NAME_MAP.set(ERC20_IBGT, "Infrared BGT");
CONTRACT_NAME_MAP.set(ERC20_OHM, "OHM");
CONTRACT_NAME_MAP.set(ERC20_STARGATE_USDC, "Bridged USDC (Stargate)");
CONTRACT_NAME_MAP.set(ERC20_WBERA, "Wrapped BERA");
CONTRACT_NAME_MAP.set(INFRARED_CUSTODIAN, "Infrared Custodian");
CONTRACT_NAME_MAP.set(INFRARED_KODIAK_OHM_HONEY_VAULT, "Infrared Kodiak OHM-HONEY Reward Vault");
CONTRACT_NAME_MAP.set(LP_BERADROME_KODIAK_OHM_HONEY, "Beradrome Kodiak OHM-HONEY LP");
CONTRACT_NAME_MAP.set(LP_KODIAK_OHM_HONEY, "Kodiak OHM-HONEY LP");
CONTRACT_NAME_MAP.set(NATIVE_BERA, "BERA");
Expand All @@ -108,6 +117,8 @@ CONTRACT_NAME_MAP.set(TRSRY, "TRSRY Module");

export const CONTRACT_ABBREVIATION_MAP = new Map<string, string>();
CONTRACT_ABBREVIATION_MAP.set(ERC20_IBERA, "iBERA");
CONTRACT_ABBREVIATION_MAP.set(ERC20_IBGT, "iBGT");
CONTRACT_ABBREVIATION_MAP.set(ERC20_STARGATE_USDC, "USDC.e");
CONTRACT_ABBREVIATION_MAP.set(ERC20_WBERA, "wBERA");
CONTRACT_ABBREVIATION_MAP.set(ERC20_BGT, "BGT");
CONTRACT_ABBREVIATION_MAP.set(NATIVE_BERA, "BERA");
6 changes: 4 additions & 2 deletions subgraphs/berachain/src/contracts/LiquidityConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PriceHandler } from "../../../shared/src/price/PriceHandler";
import { PriceHandlerRemapping } from "../../../shared/src/price/PriceHandlerRemapping";
import { PriceHandlerUniswapV3Quoter } from "../../../shared/src/price/PriceHandlerUniswapV3Quoter";
import { PriceHandlerKodiakIsland } from "../price/PriceHandlerKodiakIsland";
import { BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V1, BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V2, ERC20_HONEY, ERC20_IBERA, ERC20_OHM, ERC20_WBERA, LP_BERADROME_KODIAK_OHM_HONEY, LP_KODIAK_IBERA_WBERA, LP_KODIAK_OHM_HONEY, LP_UNISWAP_V3_WBERA_HONEY, NATIVE_BERA } from "./Constants";
import { BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V1, BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V2, ERC20_HONEY, ERC20_IBERA, ERC20_IBGT, ERC20_OHM, ERC20_WBERA, INFRARED_KODIAK_OHM_HONEY_VAULT, LP_BERADROME_KODIAK_OHM_HONEY, LP_KODIAK_IBERA_WBERA, LP_KODIAK_IBGT_WBERA, LP_KODIAK_OHM_HONEY, LP_UNISWAP_V3_WBERA_HONEY, NATIVE_BERA } from "./Constants";
import { getContractName } from "./Contracts";

const KODIAK_QUOTER = "0x644C8D6E501f7C994B74F5ceA96abe65d0BA662B".toLowerCase();
Expand All @@ -11,7 +11,8 @@ const KODIAK_QUOTER = "0x644C8D6E501f7C994B74F5ceA96abe65d0BA662B".toLowerCase()
const kodiakOhmHoney = new PriceHandlerKodiakIsland([ERC20_HONEY, ERC20_OHM], KODIAK_QUOTER, LP_KODIAK_OHM_HONEY, null, null, getContractName);
const beradromeKodiakOhmHoneyV1 = new PriceHandlerKodiakIsland([ERC20_HONEY, ERC20_OHM], KODIAK_QUOTER, LP_KODIAK_OHM_HONEY, BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V1, LP_BERADROME_KODIAK_OHM_HONEY, getContractName);
const beradromeKodiakOhmHoneyV2 = new PriceHandlerKodiakIsland([ERC20_HONEY, ERC20_OHM], KODIAK_QUOTER, LP_KODIAK_OHM_HONEY, BERADROME_KODIAK_OHM_HONEY_REWARD_VAULT_V2, LP_BERADROME_KODIAK_OHM_HONEY, getContractName);
export const OWNED_LIQUIDITY_HANDLERS = [kodiakOhmHoney, beradromeKodiakOhmHoneyV1, beradromeKodiakOhmHoneyV2];
const infraredKodiakOhmHoney = new PriceHandlerKodiakIsland([ERC20_HONEY, ERC20_OHM], KODIAK_QUOTER, LP_KODIAK_OHM_HONEY, INFRARED_KODIAK_OHM_HONEY_VAULT, INFRARED_KODIAK_OHM_HONEY_VAULT, getContractName);
export const OWNED_LIQUIDITY_HANDLERS = [kodiakOhmHoney, beradromeKodiakOhmHoneyV1, beradromeKodiakOhmHoneyV2, infraredKodiakOhmHoney];

// Price handlers
// Price lookup is enabled for these tokens
Expand All @@ -21,5 +22,6 @@ export const PRICE_HANDLERS: PriceHandler[] = [
beradromeKodiakOhmHoneyV1,
beradromeKodiakOhmHoneyV2,
new PriceHandlerUniswapV3Quoter([ERC20_IBERA, ERC20_WBERA], KODIAK_QUOTER, LP_KODIAK_IBERA_WBERA, getContractName),
new PriceHandlerUniswapV3Quoter([ERC20_IBGT, ERC20_WBERA], KODIAK_QUOTER, LP_KODIAK_IBGT_WBERA, getContractName),
new PriceHandlerRemapping(NATIVE_BERA, ERC20_WBERA, getContractName),
];
37 changes: 19 additions & 18 deletions subgraphs/berachain/src/price/PriceHandlerKodiakIsland.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
protected contractLookup: ContractNameLookup;

constructor(tokens: string[], quoter: string, poolAddress: string, rewardVault: string | null, rewardVaultToken: string | null, contractLookup: ContractNameLookup) {
// If the reward vault is set, the reward vault token must be set
if (rewardVault !== null && rewardVaultToken === null) {
throw new Error(`${PriceHandlerKodiakIsland.CLASS}: rewardVaultToken is null, but rewardVault is set`);
}
// // If the reward vault is set, the reward vault token must be set
// if (rewardVault !== null && rewardVaultToken === null) {
// throw new Error(`${PriceHandlerKodiakIsland.CLASS}: rewardVaultToken is null, but rewardVault is set`);
// }

// If the reward vault is not set, the reward vault token must not be set
if (rewardVault === null && rewardVaultToken !== null) {
throw new Error(`${PriceHandlerKodiakIsland.CLASS}: rewardVaultToken is set, but rewardVault is not set`);
}
// // If the reward vault is not set, the reward vault token must not be set
// if (rewardVault === null && rewardVaultToken !== null) {
// throw new Error(`${PriceHandlerKodiakIsland.CLASS}: rewardVaultToken is set, but rewardVault is not set`);
// }

this.tokens = tokens;
this.quoter = quoter;
Expand Down Expand Up @@ -65,7 +65,8 @@ export class PriceHandlerKodiakIsland implements PriceHandler {

const contract = BeradromeKodiakIslandRewardVault.bind(Address.fromString(rewardVault));

if (contract === null || contract.try_stakeToken().reverted) {
// balanceOf() shared between Beradrome and Infrared, and is what is actually used
if (contract === null || contract.try_balanceOf(Address.zero()).reverted) {
log.debug("{} contract ({}) reverted at block {}", [
FUNCTION,
this.contractLookup(this.poolAddress),
Expand All @@ -81,14 +82,14 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
* Returns the unique identifier for the pool.
*
* This implementation returns the pool address by default.
* If a reward vault is set, it will return the reward vault token.
* If a reward vault is set, it will return the reward vault.
*
* @returns
*/
getId(): string {
if (this.rewardVault !== null) {
const rewardVaultToken = this.rewardVaultToken;
return rewardVaultToken === null ? "Unknown" : rewardVaultToken;
const rewardVaultToken = this.rewardVaultToken;
if (rewardVaultToken !== null) {
return rewardVaultToken;
}

return this.poolAddress;
Expand All @@ -103,7 +104,7 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
}

getPrice(tokenAddress: string, priceLookup: PriceLookup, block: BigInt): PriceLookupResult | null {
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getPrice:`;
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getPrice:${this.getId()}:`;

// Get the contract
const contract = this.getPoolTokenContract(block);
Expand Down Expand Up @@ -195,7 +196,7 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
}

getTotalValue(excludedTokens: string[], priceLookup: PriceLookup, block: BigInt): BigDecimal | null {
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getTotalValue:`;
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getTotalValue:${this.getId()}:`;
const contract = this.getPoolTokenContract(block);
if (!contract) {
return null;
Expand Down Expand Up @@ -239,7 +240,7 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
}

getUnitPrice(priceLookup: PriceLookup, block: BigInt): BigDecimal | null {
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getUnitPrice:`;
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getUnitPrice:${this.getId()}:`;
const contract = this.getPoolTokenContract(block);
if (!contract) {
return null;
Expand All @@ -259,7 +260,7 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
}

getBalance(walletAddress: string, block: BigInt): BigDecimal {
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getBalance:`;
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getBalance:${this.getId()}:`;
const poolTokenContract = this.getPoolTokenContract(block);
if (!poolTokenContract) {
log.warning("{} Unable to determine balance as the contract ({}) reverted at block {}", [
Expand Down Expand Up @@ -304,7 +305,7 @@ export class PriceHandlerKodiakIsland implements PriceHandler {
}

getUnderlyingTokenBalance(walletAddress: string, tokenAddress: string, block: BigInt): BigDecimal {
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getUnderlyingTokenBalance:`;
const FUNCTION = `${PriceHandlerKodiakIsland.CLASS}: getUnderlyingTokenBalance:${this.getId()}:`;
const contract = this.getPoolTokenContract(block);
if (!contract) {
return BigDecimal.zero();
Expand Down
5 changes: 5 additions & 0 deletions subgraphs/berachain/subgraph.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
specVersion: 0.0.8
description: Olympus Protocol Metrics Subgraph - Berachain
repository: https://github.com/OlympusDAO/olympus-protocol-metrics-subgraph
features:
- grafting
graft:
base: QmWkca2atv4YwqUaEJcowWSmAXsvxNieKqXNwtFoVGdX7A # 1.1.4
block: 2735780 # Infrared vault deployment
schema:
file: ../../schema.graphql
dataSources:
Expand Down
3 changes: 1 addition & 2 deletions subgraphs/shared/src/price/PriceHandlerUniswapV3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Address, BigDecimal, BigInt } from "@graphprotocol/graph-ts";
import { log } from "matchstick-as";
import { Address, BigDecimal, BigInt, log } from "@graphprotocol/graph-ts";

import { UniswapV3Pair } from "../../generated/Price/UniswapV3Pair";
import { UniswapV3PositionManager } from "../../generated/Price/UniswapV3PositionManager";
Expand Down
Loading
Loading