Skip to content

Commit 5fa0e57

Browse files
authored
Merge pull request #293 from OlympusDAO/metamorpho-vault
Ethereum: MetaMorpho Vault, Convex Allocator
2 parents 33f6e56 + b312a00 commit 5fa0e57

File tree

11 files changed

+68
-9
lines changed

11 files changed

+68
-9
lines changed

.github/workflows/query.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Setup Node
5555
uses: actions/setup-node@v3
5656
with:
57-
node-version: "18"
57+
node-version: "20"
5858
cache: "yarn"
5959
- name: Install
6060
run: |
@@ -91,7 +91,7 @@ jobs:
9191
- name: Setup Node
9292
uses: actions/setup-node@v3
9393
with:
94-
node-version: "18"
94+
node-version: "20"
9595
cache: "yarn"
9696
# Looks for an existing comment, so it can be updated
9797
- name: Find Existing Comment

subgraphs/ethereum/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Subgraph Changelog
22

3+
## 5.6.4 (2025-04-16)
4+
5+
- Adds support for Guardian Olympus sUSDS Vault
6+
- Exclude balances from the Convex Allocator going forward (bricked)
7+
38
## 5.5.4 (2025-02-18)
49

510
- Adds support for indexing native ETH

subgraphs/ethereum/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": "QmebupLuGiu5wcS7P9BYpKCFsAFEjFR3dybb3xELqttSv5",
2+
"id": "QmdeAd2f79EHqki57gBcd8jbNK2xGyaYCHSV4YK4vouPCe",
33
"org": "olympusdao",
44
"name": "olympus-protocol-metrics",
5-
"version": "5.5.4"
5+
"version": "5.6.4"
66
}

subgraphs/ethereum/src/utils/Constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ ERC20_TOKENS.set(NATIVE_ETH, new TokenDefinition(NATIVE_ETH, TokenCategoryVolati
316316

317317
export const ERC4626_SDAI = "0x83F20F44975D03b1b09e64809B757c47f942BEeA".toLowerCase();
318318
export const ERC4626_SUSDS = "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD".toLowerCase();
319+
export const ERC4626_GAUNTLET_SUSDS_VAULT = "0x3365184e87d2Bd75961780454A5810BEc956F0dD".toLowerCase();
319320

320321
/**
321322
* Mapping between the contract address of an ERC4626 token and the TokenDefinition.
@@ -325,6 +326,7 @@ export const ERC4626_SUSDS = "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD".toLowe
325326
export const ERC4626_TOKENS = new Map<string, TokenDefinition>();
326327
ERC4626_TOKENS.set(ERC4626_SDAI, new TokenDefinition(ERC4626_SDAI, TokenCategoryStable, true, false));
327328
ERC4626_TOKENS.set(ERC4626_SUSDS, new TokenDefinition(ERC4626_SUSDS, TokenCategoryStable, true, false));
329+
ERC4626_TOKENS.set(ERC4626_GAUNTLET_SUSDS_VAULT, new TokenDefinition(ERC4626_GAUNTLET_SUSDS_VAULT, TokenCategoryStable, true, false));
328330

329331
/**
330332
* Mapping between the non-staked token and the token staked in Convex.
@@ -571,6 +573,7 @@ LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC4626_SDAI, [new PairHandler(PairHandlerTypes.
571573
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC20_SUSHI, [new PairHandler(PairHandlerTypes.UniswapV2, PAIR_UNISWAP_V2_SUSHI_ETH)]);
572574
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC20_STETH, [new PairHandler(PairHandlerTypes.Curve, PAIR_CURVE_ETH_STETH)]);
573575
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC4626_SUSDS, [new PairHandler(PairHandlerTypes.ERC4626, ERC4626_SUSDS)]);
576+
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC4626_GAUNTLET_SUSDS_VAULT, [new PairHandler(PairHandlerTypes.ERC4626, ERC4626_GAUNTLET_SUSDS_VAULT)]);
574577
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC20_SYN, [new PairHandler(PairHandlerTypes.UniswapV2, PAIR_UNISWAP_V2_SYN_FRAX)]);
575578
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC20_THOR, [new PairHandler(PairHandlerTypes.UniswapV2, PAIR_UNISWAP_V2_THOR_ETH)]);
576579
LIQUIDITY_POOL_TOKEN_LOOKUP.set(ERC20_TOKE, [new PairHandler(PairHandlerTypes.UniswapV2, PAIR_UNISWAP_V2_TOKE_ETH)]);
@@ -1048,6 +1051,7 @@ CONTRACT_NAME_MAP.set(ERC20_WSTETH, "wstETH");
10481051
CONTRACT_NAME_MAP.set(ERC20_XSUSHI, "SUSHI - Staked");
10491052
CONTRACT_NAME_MAP.set(ERC4626_SDAI, "Savings DAI");
10501053
CONTRACT_NAME_MAP.set(ERC4626_SUSDS, "Savings USDS");
1054+
CONTRACT_NAME_MAP.set(ERC4626_GAUNTLET_SUSDS_VAULT, "Gauntlet sUSDS Vault");
10511055
CONTRACT_NAME_MAP.set(ETHBOND_CONTRACT1, "ETH Bond 1");
10521056
CONTRACT_NAME_MAP.set(EULER_ADDRESS, "Euler Finance");
10531057
CONTRACT_NAME_MAP.set(EULER_ADDRESS, "Euler Protocol");

subgraphs/ethereum/src/utils/ContractHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import {
7373
TOKE_STAKING,
7474
} from "./Constants";
7575
import { getUSDRate } from "./Price";
76-
import { CONVEX_ALLOCATORS, getWalletAddressesForContract } from "./ProtocolAddresses";
76+
import { getConvexAllocators, getWalletAddressesForContract } from "./ProtocolAddresses";
7777

7878
/**
7979
* The Graph recommends only binding a contract once
@@ -1767,7 +1767,7 @@ export function getConvexStakedRecords(
17671767
const records: TokenRecord[] = [];
17681768

17691769
// Loop through allocators
1770-
const convexAllocators = CONVEX_ALLOCATORS;
1770+
const convexAllocators = getConvexAllocators(blockNumber);
17711771
for (let i = 0; i < convexAllocators.length; i++) {
17721772
const allocatorAddress = convexAllocators[i];
17731773

subgraphs/ethereum/src/utils/Price.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function getPairHandlerNonOhmValue(
9696
const result = getUniswapV3PairTotalValue(pairHandler.getContract(), true, blockNumber);
9797
const totalValue = result.totalValue;
9898
const ohmBalance = result.ohmBalance;
99+
log.debug("getPairHandlerNonOhmValue: totalValue {}, ohmBalance {}", [totalValue.toString(), ohmBalance.toString()]);
100+
99101
if (totalValue.equals(BigDecimal.zero())) {
100102
return null;
101103
}

subgraphs/ethereum/src/utils/ProtocolAddresses.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ export const CONVEX_ALLOCATORS = [
6868
DAO_WALLET,
6969
];
7070

71+
export const getConvexAllocators = (blockNumber: BigInt): string[] => {
72+
// If before the exclusion block, return all allocators
73+
if (blockNumber.lt(BigInt.fromString(CONVEX_ALLOCATOR_DEATH))) {
74+
return CONVEX_ALLOCATORS;
75+
}
76+
77+
// Otherwise remove the bricked allocator
78+
const allocators = CONVEX_ALLOCATORS.slice(0);
79+
for (let i = 0; i < allocators.length; i++) {
80+
if (allocators[i].toLowerCase() == CONVEX_CVX_ALLOCATOR.toLowerCase()) {
81+
log.debug("getConvexAllocators: removing bricked allocator: {}", [CONVEX_CVX_ALLOCATOR]);
82+
allocators.splice(i, 1);
83+
break;
84+
}
85+
}
86+
87+
// Return the allocators
88+
return allocators;
89+
}
90+
7191
/**
7292
* This set of wallet addresses is common across many tokens,
7393
* and can be used for balance lookups.
@@ -117,6 +137,8 @@ TREASURY_BLACKLIST.set(ERC20_SOHM_V1, PROTOCOL_ADDRESSES);
117137
TREASURY_BLACKLIST.set(ERC20_SOHM_V2, PROTOCOL_ADDRESSES);
118138
TREASURY_BLACKLIST.set(ERC20_SOHM_V3, PROTOCOL_ADDRESSES);
119139

140+
const CONVEX_ALLOCATOR_DEATH = "22278800";
141+
120142
/**
121143
* Some wallets (e.g. {DAO_WALLET}) have specific treasury assets mixed into them.
122144
* For this reason, the wallets to be used differ on a per-contract basis.
@@ -148,6 +170,23 @@ export const getWalletAddressesForContract = (contractAddress: string, blockNumb
148170
walletAddresses.push(clearinghouseAddresses[i].toHexString().toLowerCase());
149171
}
150172

173+
// If after the exclusion block, remove the convex allocator
174+
// Reason: funds in it are bricked
175+
if (blockNumber.ge(BigInt.fromString(CONVEX_ALLOCATOR_DEATH))) {
176+
for (let i = 0; i < walletAddresses.length; i++) {
177+
// Check address
178+
if (walletAddresses[i].toLowerCase() != CONVEX_CVX_ALLOCATOR.toLowerCase()) continue;
179+
180+
// Check exclusion block
181+
if (blockNumber.lt(BigInt.fromString(CONVEX_ALLOCATOR_DEATH))) continue;
182+
183+
// Remove the address in-place
184+
walletAddresses.splice(i, 1);
185+
log.debug("getWalletAddressesForContract: removed convex allocator: {}", [CONVEX_CVX_ALLOCATOR]);
186+
break;
187+
}
188+
}
189+
151190
// If the contract isn't on the blacklist, return as normal
152191
if (!TREASURY_BLACKLIST.has(contractAddress.toLowerCase())) {
153192
log.debug("getWalletAddressesForContract: token {} is not on treasury blacklist", [contractAddress]);

subgraphs/ethereum/subgraph.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ repository: https://github.com/OlympusDAO/olympus-protocol-metrics-subgraph
44
features:
55
- grafting
66
graft:
7-
base: QmdGqRrQD4FehyTYTmoK9RvveuR3e4vPDsyuqAYF4Nrmfv # 5.4.10
8-
block: 21810000 # Inclusion of native ETH
7+
base: QmebupLuGiu5wcS7P9BYpKCFsAFEjFR3dybb3xELqttSv5 # 5.5.4
8+
block: 22270000 # Exclusion of Convex Allocator
99
schema:
1010
file: ../../schema.graphql
1111
dataSources:

subgraphs/ethereum/tests/erc4626.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { assert, beforeEach, clearStore, createMockedFunction, describe, log,tes
33

44
import { toBigInt, toDecimal } from "../../shared/src/utils/Decimals";
55
import { TREASURY_ADDRESS_V3 } from "../../shared/src/Wallets";
6-
import { ERC20_USDS, ERC4626_SUSDS } from "../src/utils/Constants";
6+
import { ERC20_USDS, ERC4626_GAUNTLET_SUSDS_VAULT, ERC4626_SUSDS } from "../src/utils/Constants";
77
import { getAllERC4626Balances } from "../src/utils/ERC4626";
88
import { getWalletAddressesForContract } from "../src/utils/ProtocolAddresses";
99
import { mockClearinghouseRegistryAddressNull, mockTreasuryAddressNull } from "./bophadesHelper";
@@ -51,6 +51,7 @@ const mockERC4626Token = (
5151
const mockERC4626Tokens = (): void => {
5252
mockERC4626Token(SDAI, DAI, SDAI_ASSETS_TO_SHARES, 18);
5353
mockERC4626Token(ERC4626_SUSDS, ERC20_USDS, SUSDS_ASSETS_TO_SHARES, 18);
54+
mockERC4626Token(ERC4626_GAUNTLET_SUSDS_VAULT, ERC20_USDS, SUSDS_ASSETS_TO_SHARES, 18);
5455
};
5556

5657
const mockPriceFeeds = (): void => {
@@ -74,6 +75,9 @@ describe("ERC4626", () => {
7475
mockZeroWalletBalances(
7576
ERC4626_SUSDS,
7677
getWalletAddressesForContract(ERC4626_SUSDS, BLOCK_NUMBER));
78+
mockZeroWalletBalances(
79+
ERC4626_GAUNTLET_SUSDS_VAULT,
80+
getWalletAddressesForContract(ERC4626_GAUNTLET_SUSDS_VAULT, BLOCK_NUMBER));
7781
});
7882

7983
test("handles contract revert", () => {
@@ -83,6 +87,7 @@ describe("ERC4626", () => {
8387
// ERC4626 contract reverts
8488
mockERC4626Reverts(SDAI);
8589
mockERC4626Reverts(ERC4626_SUSDS);
90+
mockERC4626Reverts(ERC4626_GAUNTLET_SUSDS_VAULT);
8691

8792
// Mock balance
8893
mockWalletBalance(SDAI, TREASURY_ADDRESS_V3, toBigInt(BigDecimal.fromString("100"), 18));

subgraphs/ethereum/tests/pairHelper.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
ERC20_USDC,
5959
ERC20_WETH,
6060
ERC20_WSTETH,
61+
ERC4626_SUSDS,
6162
FRAX_LOCKING_CONTRACTS,
6263
getContractName,
6364
LQTY_STAKING,
@@ -82,6 +83,7 @@ import {
8283
PAIR_UNISWAP_V3_LQTY_LUSD,
8384
PAIR_UNISWAP_V3_LQTY_WETH,
8485
PAIR_UNISWAP_V3_LUSD_USDC,
86+
PAIR_UNISWAP_V3_OHM_SUSDS,
8587
PAIR_UNISWAP_V3_WETH_BTRFLY_V1,
8688
PAIR_UNISWAP_V3_WETH_BTRFLY_V2,
8789
PAIR_UNISWAP_V3_WETH_OHM,
@@ -336,6 +338,7 @@ export const mockUniswapV3PairsZero = (): void => {
336338
mockRateUniswapV3(PAIR_UNISWAP_V3_WETH_BTRFLY_V1, BigInt.zero(), ERC20_WETH, ERC20_BTRFLY_V1, ERC20_STANDARD_DECIMALS, ERC20_STANDARD_DECIMALS, BigInt.zero(), BigInt.zero(), true);
337339
mockRateUniswapV3(PAIR_UNISWAP_V3_WETH_BTRFLY_V2, BigInt.zero(), ERC20_WETH, ERC20_BTRFLY_V2, ERC20_STANDARD_DECIMALS, ERC20_STANDARD_DECIMALS, BigInt.zero(), BigInt.zero(), true);
338340
mockRateUniswapV3(PAIR_UNISWAP_V3_WETH_OHM, BigInt.zero(), ERC20_WETH, ERC20_OHM_V2, ERC20_STANDARD_DECIMALS, OHM_V2_DECIMALS, BigInt.zero(), BigInt.zero(), true);
341+
mockRateUniswapV3(PAIR_UNISWAP_V3_OHM_SUSDS, BigInt.zero(), ERC20_OHM_V2, ERC4626_SUSDS, OHM_V2_DECIMALS, ERC20_STANDARD_DECIMALS, BigInt.zero(), BigInt.zero(), true);
339342
}
340343

341344
export const mockFxsEthRate = (): void => {

0 commit comments

Comments
 (0)