Skip to content

Commit

Permalink
Merge pull request #261 from OlympusDAO/block-handler-fantom
Browse files Browse the repository at this point in the history
Implement Block Handler for Fantom
  • Loading branch information
0xJem authored Jun 6, 2024
2 parents bbeba34 + 85b3196 commit d2b856d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
6 changes: 6 additions & 0 deletions subgraphs/fantom/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# protocol-metrics-fantom

## v1.0.4 (2023-10-09)

- Shift to polling block handler
- Deploy on Graph Protocol Decentralized Network
4 changes: 2 additions & 2 deletions subgraphs/fantom/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "QmSBMNhnzbe4c4cwznLUsFkE4H5XZfiVqLHnNZYA48EPwy",
"version": "0.1.0",
"id": "QmNUJtrE5Hiwj5eBeF5gSubY2vhuMdjaZnZsaq6vVY2aba",
"version": "1.0.4",
"org": "olympusdao",
"name": "protocol-metrics-fantom"
}
20 changes: 1 addition & 19 deletions subgraphs/fantom/src/contracts/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TokenCategoryPOL, TokenCategoryStable, TokenCategoryVolatile, TokenDefinition } from "../../../shared/src/contracts/TokenDefinition";
import { AAVE_ALLOCATOR, AAVE_ALLOCATOR_V2, BALANCER_ALLOCATOR, BONDS_DEPOSIT, BONDS_INVERSE_DEPOSIT, CONVEX_ALLOCATOR1, CONVEX_ALLOCATOR2, CONVEX_ALLOCATOR3, CONVEX_CVX_ALLOCATOR, CONVEX_CVX_VL_ALLOCATOR, CROSS_CHAIN_ARBITRUM, CROSS_CHAIN_FANTOM, CROSS_CHAIN_POLYGON, DAO_WALLET, LUSD_ALLOCATOR, RARI_ALLOCATOR, TREASURY_ADDRESS_V1, TREASURY_ADDRESS_V2, TREASURY_ADDRESS_V3, VEFXS_ALLOCATOR } from "../../../shared/src/Wallets";
import { CROSS_CHAIN_FANTOM, DAO_WALLET } from "../../../shared/src/Wallets";

export const BLOCKCHAIN = "Fantom";

Expand Down Expand Up @@ -40,19 +40,7 @@ ERC20_TOKENS_FANTOM.set(LP_UNISWAP_V2_WFTM_GOHM, new TokenDefinition(LP_UNISWAP_
export const OHM_TOKENS = [ERC20_GOHM];

export const CONTRACT_NAME_MAP = new Map<string, string>();
CONTRACT_NAME_MAP.set(AAVE_ALLOCATOR_V2, "Aave Allocator V2");
CONTRACT_NAME_MAP.set(AAVE_ALLOCATOR, "Aave Allocator V1");
CONTRACT_NAME_MAP.set(BALANCER_ALLOCATOR, "Balancer Allocator");
CONTRACT_NAME_MAP.set(BONDS_DEPOSIT, "Bond Depository");
CONTRACT_NAME_MAP.set(BONDS_INVERSE_DEPOSIT, "Bond (Inverse) Depository");
CONTRACT_NAME_MAP.set(CONVEX_ALLOCATOR1, "Convex Allocator 1");
CONTRACT_NAME_MAP.set(CONVEX_ALLOCATOR2, "Convex Allocator 2");
CONTRACT_NAME_MAP.set(CONVEX_ALLOCATOR3, "Convex Allocator 3");
CONTRACT_NAME_MAP.set(CONVEX_CVX_ALLOCATOR, "Convex Allocator");
CONTRACT_NAME_MAP.set(CONVEX_CVX_VL_ALLOCATOR, "Convex vlCVX Allocator");
CONTRACT_NAME_MAP.set(CROSS_CHAIN_ARBITRUM, "Cross-Chain Arbitrum");
CONTRACT_NAME_MAP.set(CROSS_CHAIN_FANTOM, "Cross-Chain Fantom");
CONTRACT_NAME_MAP.set(CROSS_CHAIN_POLYGON, "Cross-Chain Polygon");
CONTRACT_NAME_MAP.set(DAO_WALLET, "Treasury MS (Formerly DAO Wallet)");
CONTRACT_NAME_MAP.set(ERC20_BEETS, "Beethoven");
CONTRACT_NAME_MAP.set(ERC20_BOO, "SpookySwap");
Expand All @@ -71,12 +59,6 @@ CONTRACT_NAME_MAP.set(LP_UNISWAP_V2_WFTM_BEETS, "UniswapV2 wFTM-BEETS Liquidity
CONTRACT_NAME_MAP.set(LP_UNISWAP_V2_WFTM_ETH, "UniswapV2 wFTM-ETH Liquidity Pool");
CONTRACT_NAME_MAP.set(LP_UNISWAP_V2_WFTM_OXD, "UniswapV2 wFTM-OXD Liquidity Pool");
CONTRACT_NAME_MAP.set(LP_UNISWAP_V2_WFTM_USDC, "UniswapV2 wFTM-USDC Liquidity Pool");
CONTRACT_NAME_MAP.set(LUSD_ALLOCATOR, "LUSD Allocator");
CONTRACT_NAME_MAP.set(RARI_ALLOCATOR, "Rari Allocator");
CONTRACT_NAME_MAP.set(TREASURY_ADDRESS_V1, "Treasury Wallet V1");
CONTRACT_NAME_MAP.set(TREASURY_ADDRESS_V2, "Treasury Wallet V2");
CONTRACT_NAME_MAP.set(TREASURY_ADDRESS_V3, "Treasury Wallet V3");
CONTRACT_NAME_MAP.set(VEFXS_ALLOCATOR, "VeFXS Allocator");

export const CONTRACT_ABBREVIATION_MAP = new Map<string, string>();
CONTRACT_NAME_MAP.set(ERC20_BEETS, "BEETS");
Expand Down
4 changes: 2 additions & 2 deletions subgraphs/fantom/src/contracts/Contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts";
import { ERC20 } from "../../../shared/generated/Price/ERC20";
import { TokenRecord } from "../../../shared/generated/schema";
import { getERC20TokenRecordFromWallet } from "../../../shared/src/contracts/ERC20";
import { WALLET_ADDRESSES } from "../../../shared/src/Wallets";
import {
BLOCKCHAIN,
CONTRACT_ABBREVIATION_MAP,
CONTRACT_NAME_MAP,
ERC20_TOKENS_FANTOM,
} from "./Constants";
import { FANTOM_PROTOCOL_ADDRESSES } from "./ProtocolAddresses";

export function getContractName(
contractAddress: string,
Expand Down Expand Up @@ -51,7 +51,7 @@ export const getWalletAddressesForContract = (contractAddress: string): string[]
const nonTreasuryAddresses = NON_TREASURY_ASSET_WHITELIST.has(contractAddress.toLowerCase())
? NON_TREASURY_ASSET_WHITELIST.get(contractAddress.toLowerCase())
: [];
const newAddresses = WALLET_ADDRESSES.slice(0);
const newAddresses = FANTOM_PROTOCOL_ADDRESSES.slice(0);

// Add the values of nonTreasuryAddresses, but filter duplicates
for (let i = 0; i < nonTreasuryAddresses.length; i++) {
Expand Down
9 changes: 9 additions & 0 deletions subgraphs/fantom/src/contracts/ProtocolAddresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { CROSS_CHAIN_FANTOM, DAO_WALLET } from "../../../shared/src/Wallets";

/**
* The addresses relevant on Fantom.
*/
export const FANTOM_PROTOCOL_ADDRESSES: string[] = [
CROSS_CHAIN_FANTOM, // Everything is contained in one wallet - no need to iterate over other addresses.
DAO_WALLET, // Just in case there is a snapshot during a bridging action
];
6 changes: 3 additions & 3 deletions subgraphs/fantom/src/treasury/OwnedLiquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
createTokenRecord,
getIsTokenLiquid,
} from "../../../shared/src/utils/TokenRecordHelper";
import { WALLET_ADDRESSES } from "../../../shared/src/Wallets";
import { BLOCKCHAIN, ERC20_TOKENS_FANTOM, OHM_TOKENS } from "../contracts/Constants";
import { getContractName } from "../contracts/Contracts";
import { getPriceRecursive, HANDLERS } from "../price/PriceLookup";
import { FANTOM_PROTOCOL_ADDRESSES } from "../contracts/ProtocolAddresses";

/**
* Returns the token records for a given token. This includes:
Expand Down Expand Up @@ -52,8 +52,8 @@ function getOwnedLiquidityBalance(
return records;
}

for (let i = 0; i < WALLET_ADDRESSES.length; i++) {
const currentWalletAddress = WALLET_ADDRESSES[i];
for (let i = 0; i < FANTOM_PROTOCOL_ADDRESSES.length; i++) {
const currentWalletAddress = FANTOM_PROTOCOL_ADDRESSES[i];

// Get the balance
const balance = liquidityHandler.getBalance(currentWalletAddress, block);
Expand Down

0 comments on commit d2b856d

Please sign in to comment.