From c99ddbd9bdfd68628b2de5e5c740efd8db22eba2 Mon Sep 17 00:00:00 2001 From: harsh9200 Date: Tue, 25 Jun 2024 06:28:03 +0530 Subject: [PATCH] Update schema network enum --- .../config/templates/renzo.template.yaml | 8 +-- subgraphs/renzo/schema.graphql | 2 + subgraphs/renzo/src/mappings/ezEthMappings.ts | 56 +++++-------------- 3 files changed, 18 insertions(+), 48 deletions(-) diff --git a/subgraphs/renzo/protocols/renzo/config/templates/renzo.template.yaml b/subgraphs/renzo/protocols/renzo/config/templates/renzo.template.yaml index a11eb83d75..b1fd47c5b2 100644 --- a/subgraphs/renzo/protocols/renzo/config/templates/renzo.template.yaml +++ b/subgraphs/renzo/protocols/renzo/config/templates/renzo.template.yaml @@ -185,10 +185,8 @@ dataSources: file: ./abis/Prices/Uniswap/Factory.json - name: UniswapPair file: ./abis/Prices/Uniswap/Pair.json - callHandlers: - - function: mint(address,uint256) - handler: handleMint - - function: burn(address,uint256) - handler: handleBurn + eventHandlers: + - event: Transfer(indexed address,indexed address,uint256) + handler: handleTransfer file: ./src/mappings/ezEthMappings.ts {{ /ezETH }} diff --git a/subgraphs/renzo/schema.graphql b/subgraphs/renzo/schema.graphql index 802cb7bf84..a747534243 100644 --- a/subgraphs/renzo/schema.graphql +++ b/subgraphs/renzo/schema.graphql @@ -7,8 +7,10 @@ enum Network { ARWEAVE_MAINNET AURORA AVALANCHE + BASE BOBA BSC # aka BNB Chain + BLAST_MAINNET CELO COSMOS CRONOS diff --git a/subgraphs/renzo/src/mappings/ezEthMappings.ts b/subgraphs/renzo/src/mappings/ezEthMappings.ts index ec95a2d6e4..46d2b47475 100644 --- a/subgraphs/renzo/src/mappings/ezEthMappings.ts +++ b/subgraphs/renzo/src/mappings/ezEthMappings.ts @@ -1,32 +1,11 @@ -import { Versions } from "../versions"; +import { readValue } from "../common/utils"; import { SDK } from "../sdk/protocols/generic"; import * as constants from "../common/constants"; import { ERC20 } from "../../generated/ezETH/ERC20"; import { Pool } from "../sdk/protocols/generic/pool"; -import { ProtocolConfig } from "../sdk/protocols/config"; -import { Pricer, TokenInit, readValue } from "../common/utils"; -import { MintCall, BurnCall } from "../../generated/ezETH/ezETH"; -import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; - -export function initializeSDKFromCall(call: ethereum.Call): SDK { - const protocolConfig = new ProtocolConfig( - constants.Protocol.ID, - constants.Protocol.NAME, - constants.Protocol.SLUG, - Versions - ); - const tokenPricer = new Pricer(); - const tokenInitializer = new TokenInit(); - - const sdk = SDK.initializeFromCall( - protocolConfig, - tokenPricer, - tokenInitializer, - call - ); - - return sdk; -} +import { Transfer } from "../../generated/ezETH/ezETH"; +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { initializeSDKFromEvent } from "../common/initializers"; export function getOrCreatePool(poolAddress: Address, sdk: SDK): Pool { const pool = sdk.Pools.loadPool(poolAddress); @@ -61,26 +40,17 @@ export function updatePoolTvlAndSupply(pool: Pool): void { pool.setOutputTokenSupply(tvl); } -export function handleMint(call: MintCall): void { - const sender = call.inputs._user; - - const sdk = initializeSDKFromCall(call); - const pool = getOrCreatePool(call.to, sdk); - - updatePoolTvlAndSupply(pool); - - const account = sdk.Accounts.loadAccount(sender); - account.trackActivity(); -} - -export function handleBurn(call: BurnCall): void { - const sender = call.inputs._user; +export function handleTransfer(event: Transfer): void { + const from = event.params.from; + const to = event.params.to; - const sdk = initializeSDKFromCall(call); - const pool = getOrCreatePool(call.to, sdk); + const sdk = initializeSDKFromEvent(event); + const pool = getOrCreatePool(event.address, sdk); updatePoolTvlAndSupply(pool); - const account = sdk.Accounts.loadAccount(sender); - account.trackActivity(); + const fromAccount = sdk.Accounts.loadAccount(from); + const toAccount = sdk.Accounts.loadAccount(to); + fromAccount.trackActivity(); + toAccount.trackActivity(); }