From e0aad232df6f816e9df763ac224ba6a01f722808 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Fri, 20 Sep 2024 08:28:06 -0300 Subject: [PATCH] feat: add etherfi promo subgraph for bnb --- subgraphs/etherfi-promo/config/index.ts | 14 +++++++-- subgraphs/etherfi-promo/package.json | 2 ++ subgraphs/etherfi-promo/template-bsc.yaml | 35 +++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 subgraphs/etherfi-promo/template-bsc.yaml diff --git a/subgraphs/etherfi-promo/config/index.ts b/subgraphs/etherfi-promo/config/index.ts index 57357a05..8b2d226d 100644 --- a/subgraphs/etherfi-promo/config/index.ts +++ b/subgraphs/etherfi-promo/config/index.ts @@ -5,7 +5,7 @@ import fs from 'fs'; import Mustache from 'mustache'; export const getNetwork = () => { - const supportedNetworks = ['sepolia', 'ethereum', 'docker'] as const; + const supportedNetworks = ['sepolia', 'ethereum', 'docker', 'bsc'] as const; const network = process.env.NETWORK as (typeof supportedNetworks)[number]; if (!supportedNetworks.includes(network)) { throw new Error(`NETWORK env var must be set to one of ${supportedNetworks}`); @@ -22,6 +22,7 @@ const main = () => { vWeEthsAddress: sepoliaILDeployments.addresses.VToken_vweETHs_LiquidStakedETH, vWeEthStartBlock: '0', vWeEthsStartBlock: '0', + template: 'template.yaml', }, sepolia: { network: 'sepolia', @@ -29,6 +30,7 @@ const main = () => { vWeEthsAddress: sepoliaILDeployments.addresses.VToken_vweETHs_LiquidStakedETH, vWeEthStartBlock: '5659827', vWeEthsStartBlock: '6536644', + template: 'template.yaml', }, ethereum: { network: 'mainnet', @@ -36,10 +38,16 @@ const main = () => { vWeEthsAddress: ethereumILDeployments.addresses.VToken_vweETHs_LiquidStakedETH, vWeEthStartBlock: '19638180', vWeEthsStartBlock: '20583508', + template: 'template.yaml', + }, + bsc: { + network: 'bsc', + vWeEthAddress: '0xc5b24f347254bD8cF8988913d1fd0F795274900F', + vWeEthStartBlock: '41956130', + template: 'template-bsc.yaml', }, }; - - const yamlTemplate = fs.readFileSync('template.yaml', 'utf8'); + const yamlTemplate = fs.readFileSync(config[network].template, 'utf8'); const yamlOutput = Mustache.render(yamlTemplate, config[network]); fs.writeFileSync('subgraph.yaml', yamlOutput); }; diff --git a/subgraphs/etherfi-promo/package.json b/subgraphs/etherfi-promo/package.json index dea7c50a..00d55da6 100644 --- a/subgraphs/etherfi-promo/package.json +++ b/subgraphs/etherfi-promo/package.json @@ -18,9 +18,11 @@ "deploy:docker": "yarn prepare:docker && npx graph deploy venusprotocol/etherfi-promo --ipfs http://ipfs:5001 --node http://graph-node:8020/ --version-label ci", "deploy:sepolia": "yarn prepare:sepolia && graph deploy --studio etherfi-promo-sepolia", "deploy:ethereum": "yarn prepare:ethereum && graph deploy --studio etherfi-promo", + "deploy:bsc": "yarn prepare:bsc && graph deploy --studio etherfi-promo-bnb", "prepare:docker": "NETWORK=docker yarn ts-node config/index.ts", "prepare:sepolia": "NETWORK=sepolia yarn ts-node config/index.ts", "prepare:ethereum": "NETWORK=ethereum yarn ts-node config/index.ts", + "prepare:bsc": "NETWORK=bsc yarn ts-node config/index.ts", "generate-subgraph-types": "rm -rf /subgraph-client/.graphclient && npx graphclient build --dir ./subgraph-client", "test": "graph test", "test:integration": "true" diff --git a/subgraphs/etherfi-promo/template-bsc.yaml b/subgraphs/etherfi-promo/template-bsc.yaml new file mode 100644 index 00000000..37bce64e --- /dev/null +++ b/subgraphs/etherfi-promo/template-bsc.yaml @@ -0,0 +1,35 @@ +specVersion: 0.0.4 +description: Venus is an open-source protocol for algorithmic, efficient Money Markets on the BSC blockchain. +repository: https://github.com/VenusProtocol/subgraphs +schema: + file: ./schema.graphql +dataSources: + - kind: ethereum/contract + name: vWeETH + network: {{ network }} + source: + address: "{{ vWeEthAddress }}" + abi: VToken + startBlock: {{ vWeEthStartBlock }} + mapping: + kind: ethereum/events + apiVersion: 0.0.9 + language: wasm/assemblyscript + file: ./src/mappings/vToken.ts + entities: + - SupplierAccount + - BorrowerAccount + abis: + - name: VToken + file: ../../node_modules/@venusprotocol/isolated-pools/artifacts/contracts/VToken.sol/VToken.json + - name: ERC20 + file: ../../node_modules/@venusprotocol/isolated-pools/artifacts/contracts/test/ERC20.sol/ERC20.json + eventHandlers: + - event: Mint(indexed address,uint256,uint256,uint256) + handler: handleMint + - event: Borrow(indexed address,uint256,uint256,uint256) + handler: handleBorrow + - event: Transfer(indexed address,indexed address,uint256) + handler: handleTransfer + - event: AccrueInterest(uint256,uint256,uint256,uint256) + handler: handleAccrueInterest