Skip to content

Commit

Permalink
Update schema network enum
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh9200 committed Jun 25, 2024
1 parent 8c52483 commit c99ddbd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 2 additions & 0 deletions subgraphs/renzo/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ enum Network {
ARWEAVE_MAINNET
AURORA
AVALANCHE
BASE
BOBA
BSC # aka BNB Chain
BLAST_MAINNET
CELO
COSMOS
CRONOS
Expand Down
56 changes: 13 additions & 43 deletions subgraphs/renzo/src/mappings/ezEthMappings.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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();
}

0 comments on commit c99ddbd

Please sign in to comment.