Skip to content

Commit

Permalink
Merge pull request #180 from VenusProtocol/add-etherfi-bnb-subgraph
Browse files Browse the repository at this point in the history
feat: add etherfi promo subgraph for bnb
  • Loading branch information
coreyar authored Sep 25, 2024
2 parents 07a44c4 + e0aad23 commit eee92b2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
14 changes: 11 additions & 3 deletions subgraphs/etherfi-promo/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -22,24 +22,32 @@ const main = () => {
vWeEthsAddress: sepoliaILDeployments.addresses.VToken_vweETHs_LiquidStakedETH,
vWeEthStartBlock: '0',
vWeEthsStartBlock: '0',
template: 'template.yaml',
},
sepolia: {
network: 'sepolia',
vWeEthAddress: sepoliaILDeployments.addresses.VToken_vweETH_LiquidStakedETH,
vWeEthsAddress: sepoliaILDeployments.addresses.VToken_vweETHs_LiquidStakedETH,
vWeEthStartBlock: '5659827',
vWeEthsStartBlock: '6536644',
template: 'template.yaml',
},
ethereum: {
network: 'mainnet',
vWeEthAddress: ethereumILDeployments.addresses.VToken_vweETH_LiquidStakedETH,
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);
};
Expand Down
2 changes: 2 additions & 0 deletions subgraphs/etherfi-promo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 35 additions & 0 deletions subgraphs/etherfi-promo/template-bsc.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit eee92b2

Please sign in to comment.